Skip to content

Commit

Permalink
fix addRollupType tool
Browse files Browse the repository at this point in the history
  • Loading branch information
krlosMata committed Jul 25, 2024
1 parent 6486e02 commit 4af640c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 39 deletions.
3 changes: 2 additions & 1 deletion tools/addRollupType/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_rollup_type_output.json
add_rollup_type_output-*.json
add_rollup_type.json
genesis.json
21 changes: 11 additions & 10 deletions tools/addRollupType/addRollupType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function main() {
"polygonRollupManagerAddress",
"verifierAddress",
"rollupCompatibilityID",
"genesisRoot"
"genesisRoot",
];

for (const parameterName of mandatoryDeploymentParameters) {
Expand All @@ -47,7 +47,7 @@ async function main() {
consensusContract,
polygonRollupManagerAddress,
verifierAddress,
genesisRoot
genesisRoot,
} = addRollupParameters;

const supportedConensus = ["PolygonZkEVMEtrog", "PolygonValidiumEtrog"];
Expand Down Expand Up @@ -117,21 +117,19 @@ async function main() {

// Sanity checks genesisRoot
if (genesisRoot !== genesis.root) {
throw new Error(
`Genesis root in the 'add_rollup_type.json' does not match the root in the 'genesis.json'`
);
throw new Error(`Genesis root in the 'add_rollup_type.json' does not match the root in the 'genesis.json'`);
}

// get bridge address in genesis file
let genesisBridgeAddress = ethers.constants.AddresZero;
for (let i = 0; i < genesis.genesis.lenght; i++) {
if (genesis.genesis[i].contractName === 'PolygonZkEVMBridge proxy') {
let genesisBridgeAddress = ethers.ZeroAddress;
for (let i = 0; i < genesis.genesis.length; i++) {
if (genesis.genesis[i].contractName === "PolygonZkEVMBridge proxy") {
genesisBridgeAddress = genesis.genesis[i].address;
break;
}
}

if (polygonZkEVMBridgeAddress.toLowerCase() !== genesisBridgeAddress ) {
if (polygonZkEVMBridgeAddress.toLowerCase() !== genesisBridgeAddress.toLowerCase()) {
throw new Error(
`'PolygonZkEVMBridge proxy' root in the 'genesis.json' does not match 'bridgeAddress' in the 'PolygonRollupManager'`
);
Expand All @@ -155,7 +153,10 @@ async function main() {
// Create consensus implementation if needed
let polygonConsensusContractAddress;

if (typeof addRollupParameters.polygonconsensusContract !== 'undefined' && ethers.isAddress(addRollupParameters.polygonconsensusContract)) {
if (
typeof addRollupParameters.polygonconsensusContract !== "undefined" &&
ethers.isAddress(addRollupParameters.polygonconsensusContract)
) {
polygonConsensusContractAddress = addRollupParameters.polygonconsensusContract;
} else {
const PolygonconsensusFactory = (await ethers.getContractFactory(consensusContract, deployer)) as any;
Expand Down
16 changes: 7 additions & 9 deletions tools/addRollupType/addRollupTypeTimelock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function main() {
"verifierAddress",
"rollupCompatibilityID",
"timelockDelay",
"genesisRoot"
"genesisRoot",
];

for (const parameterName of mandatoryDeploymentParameters) {
Expand All @@ -48,7 +48,7 @@ async function main() {
polygonRollupManagerAddress,
verifierAddress,
timelockDelay,
genesisRoot
genesisRoot,
} = addRollupParameters;

const salt = addRollupParameters.timelockSalt || ethers.ZeroHash;
Expand Down Expand Up @@ -121,21 +121,19 @@ async function main() {

// Sanity checks genesisRoot
if (genesisRoot !== genesis.root) {
throw new Error(
`Genesis root in the 'add_rollup_type.json' does not match the root in the 'genesis.json'`
);
throw new Error(`Genesis root in the 'add_rollup_type.json' does not match the root in the 'genesis.json'`);
}

// get bridge address in genesis file
let genesisBridgeAddress = ethers.constants.AddresZero;
for (let i = 0; i < genesis.genesis.lenght; i++) {
if (genesis.genesis[i].contractName === 'PolygonZkEVMBridge proxy') {
let genesisBridgeAddress = ethers.ZeroAddress;
for (let i = 0; i < genesis.genesis.length; i++) {
if (genesis.genesis[i].contractName === "PolygonZkEVMBridge proxy") {
genesisBridgeAddress = genesis.genesis[i].address;
break;
}
}

if (polygonZkEVMBridgeAddress.toLowerCase() !== genesisBridgeAddress ) {
if (polygonZkEVMBridgeAddress.toLowerCase() !== genesisBridgeAddress.toLowerCase()) {
throw new Error(
`'PolygonZkEVMBridge proxy' root in the 'genesis.json' does not match 'bridgeAddress' in the 'PolygonRollupManager'`
);
Expand Down
17 changes: 0 additions & 17 deletions tools/addRollupType/add_rollup_type.json

This file was deleted.

1 change: 1 addition & 0 deletions tools/addRollupType/add_rollup_type.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"consensusContract": "PolygonValidiumEtrog",
"polygonconsensusContract": "",
"polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2",
"verifierAddress": "0x1C3A3da552b8662CD69538356b1E7c2E9CC1EBD8",
"description": "Type: Validium, Version: etrog, genesis: /ipfs/QmUXnRoPbUmZuEZCGyiHjEsoNcFVu3hLtSvhpnfBS2mAYU",
Expand Down
4 changes: 2 additions & 2 deletions tools/deployVerifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm i
- `maxPriorityFeePerGas`: set custom gas
- `multiplierGas`: set custom gas
- A network should be selected when running the script
- examples: `-- sepolia` or `--mainnet`
- 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
Expand All @@ -32,5 +32,5 @@ cp ./tools/deployVerifier/deploy_verifier_parameters.example ./tools/deployVerif
- Set your parameters
- Run tool:
```
npx hardhat run ./tools/deployVerifier/deployVerififer.ts --network sepolia
npx hardhat run ./tools/deployVerifier/deployVerifier.ts --network sepolia
```

0 comments on commit 4af640c

Please sign in to comment.