Skip to content

Commit

Permalink
Merge pull request #180 from 0xPolygonHermez/feature/updateScripts
Browse files Browse the repository at this point in the history
Feature/update scripts
  • Loading branch information
invocamanman authored Jan 26, 2024
2 parents 99d76cb + 924a926 commit b2a62e6
Show file tree
Hide file tree
Showing 39 changed files with 1,211 additions and 142 deletions.
1 change: 1 addition & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if npm run lint; then
cp artifacts/contracts/v2/consensus/zkEVM/PolygonZkEVMExistentEtrog.sol/PolygonZkEVMExistentEtrog.json compiled-contracts/

cp artifacts/contracts/v2/consensus/validium/PolygonValidiumEtrog.sol/PolygonValidiumEtrog.json compiled-contracts/
cp artifacts/contracts/v2/consensus/validium/PolygonDataCommittee.sol/PolygonDataCommittee.json compiled-contracts/
git add compiled-contracts
exit 0
else
Expand Down
4 changes: 2 additions & 2 deletions compiled-contracts/FflonkVerifier.json

Large diffs are not rendered by default.

253 changes: 253 additions & 0 deletions compiled-contracts/PolygonDataCommittee.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonRollupManager.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonRollupManagerMock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonRollupManagerMockInternalTest.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonValidiumEtrog.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMBridgeV2.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMEtrog.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMExistentEtrog.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMGlobalExitRootV2.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/v2/consensus/validium/PolygonValidiumEtrog.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../lib/PolygonRollupBaseEtrog.sol";
import "../../interfaces/IDataAvailabilityProtocol.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/consensus/zkEVM/PolygonZkEVMEtrog.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../lib/PolygonRollupBaseEtrog.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/consensus/zkEVM/PolygonZkEVMExistentEtrog.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.20;
pragma solidity 0.8.20;

import "../../lib/PolygonRollupBaseEtrog.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/interfaces/IDataAvailabilityProtocol.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

interface IDataAvailabilityProtocol {
function getProcotolName() external view returns (string memory);
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/interfaces/IPolygonRollupBase.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

interface IPolygonRollupBase {
function initialize(
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/interfaces/IPolygonRollupManager.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

interface IPolygonRollupManager {
/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/lib/DepositContractBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
pragma solidity ^0.8.20;

/**
* This contract will be used as a helper for all the sparse merkle tree related functions
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/lib/DepositContractV2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "./DepositContractBase.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/lib/LegacyZKEVMStateVariables.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

/**
* Since the current contract of PolygonZkEVM will be upgraded to a PolygonRollupManager there's defined
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/lib/PolygonAccessControlUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/lib/PolygonConstantsBase.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity 0.8.20;
pragma solidity ^0.8.20;

/**
* This contract will contain the constants used across different contracts
Expand Down
2 changes: 1 addition & 1 deletion contracts/v2/lib/PolygonZkEVMGlobalExitRootBaseStorage.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0

pragma solidity 0.8.20;
pragma solidity ^0.8.20;
import "../interfaces/IPolygonZkEVMGlobalExitRootV2.sol";

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/verifiers/FflonkVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ contract FflonkVerifier {
uint256 constant w8_7 = 8613538655231327379234925296132678673308827349856085326283699237864372525723;

// Verifier preprocessed input C_0(x)·[1]_1
uint256 constant C0x = 1399458405278693375564157845951119219674216315698518301618391005223961674672;
uint256 constant C0y = 4753339552187781629812877887300152778714353139514388879046795575382068591682;
uint256 constant C0x = 7005013949998269612234996630658580519456097203281734268590713858661772481668;
uint256 constant C0y = 869093939501355406318588453775243436758538662501260653214950591532352435323;

// Verifier preprocessed input x·[1]_2
uint256 constant X2x1 = 21831381940315734285607113342023901060522397560371972897001948545212302161822;
Expand Down
18 changes: 18 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ const config: HardhatUserConfig = {
count: 20,
},
},
zkevmDevnet: {
url: "http://123:123:123:123:123",
accounts: {
mnemonic: process.env.MNEMONIC || DEFAULT_MNEMONIC,
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
},
},
},
gasReporter: {
enabled: !!process.env.REPORT_GAS,
Expand All @@ -235,6 +244,7 @@ const config: HardhatUserConfig = {
goerli: `${process.env.ETHERSCAN_API_KEY}`,
sepolia: `${process.env.ETHERSCAN_API_KEY}`,
mainnet: `${process.env.ETHERSCAN_API_KEY}`,
zkevmDevnet: `${process.env.ETHERSCAN_API_KEY}`,
},
customChains: [
{
Expand All @@ -253,6 +263,14 @@ const config: HardhatUserConfig = {
browserURL: "https://testnet-zkevm.polygonscan.com/",
},
},
{
network: "zkevmDevnet",
chainId: 123,
urls: {
apiURL: "http://123:123:123:123:123/api",
browserURL: "http://123:123:123:123:123",
},
},
],
},
};
Expand Down
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@
"deploy:testnet:v1ToV2:localhost": "npx hardhat compile && rm -f deployment/v1ToV2/deploy_ongoing.json && npm run prepare:v1ToV2:ZkEVM:localhost && npm run deploy:v1ToV2:localhost",
"docker:v1ToV2:contracts": "./docker/scripts/v1ToV2/deploy-docker.sh",
"dockerv2:v1ToV2:contracts": "sudo ./docker/scripts/v1ToV2/deploy-dockerv2.sh",
"saveDeployment:sepolia": "mkdir -p deployments/sepolia_$(date +%s) && cp -r deployment/v2/deploy_*.json deployments/sepolia_$(date +%s) && cp .openzeppelin/sepolia.json deployments/sepolia_$(date +%s) && cp deployment/v2/genesis.json deployments/sepolia_$(date +%s) && cp deployment/v2/create_rollup_output.json deployments/sepolia_$(date +%s)"
"saveDeployment:sepolia": "mkdir -p deployments/sepolia_$(date +%s) && cp -r deployment/v2/deploy_*.json deployments/sepolia_$(date +%s) && cp .openzeppelin/sepolia.json deployments/sepolia_$(date +%s) && cp deployment/v2/genesis.json deployments/sepolia_$(date +%s) && cp deployment/v2/create_rollup_output.json deployments/sepolia_$(date +%s)",
"testnetPol:upgradeV2:sepolia": "npx hardhat run upgrade/upgradeToV2/testnet/deployTestnetPol.ts --network sepolia",
"testnetPol:upgradeV2:goerli": "npx hardhat run upgrade/upgradeToV2/testnet/deployTestnetPol.ts --network goerli",
"upgradev2:timelock:goerli": "npx hardhat run upgrade/upgradeToV2/upgradeToV2.ts --network goerli && npm run saveUpgradeV2:goerli",
"upgradev2:timelock:sepolia": "npx hardhat run upgrade/upgradeToV2/upgradeToV2.ts --network sepolia && npm run saveUpgradeV2:sepolia",
"verify:upgradeV2:sepolia": "npx hardhat run upgrade/upgradeToV2/verifyContracts.ts --network sepolia",
"verify:upgradeV2:goerli": "npx hardhat run upgrade/upgradeToV2/verifyContracts.ts --network goerli",
"upgradev2L2:timelock:zkevmDevnet": "npx hardhat run upgrade/upgradeToV2/upgradeL2ToV2.ts --network zkevmDevnet",
"saveUpgradeV2:sepolia": "mkdir -p upgrade/upgradeToV2/sepolia_$(date +%s) && cp -r upgrade/upgradeToV2/upgrade_*.json upgrade/upgradeToV2/sepolia_$(date +%s) && cp -r upgrade/upgradeToV2/deploy_*.json upgrade/upgradeToV2/sepolia_$(date +%s) && cp .openzeppelin/sepolia.json upgrade/upgradeToV2/sepolia_$(date +%s)",
"saveUpgradeV2:goerli": "mkdir -p upgrade/upgradeToV2/goerli_$(date +%s) && cp -r upgrade/upgradeToV2/upgrade_*.json upgrade/upgradeToV2/goerli_$(date +%s) && cp -r upgrade/upgradeToV2/deploy_*.json upgrade/upgradeToV2/goerli_$(date +%s) && cp .openzeppelin/goerli.json upgrade/upgradeToV2/goerli_$(date +%s)",
"upgradev2L2:timelock:polygonZKEVMTestnet": "npx hardhat run upgrade/upgradeToV2/upgradeL2ToV2.ts --network polygonZKEVMTestnet",
"upgradev2L2:timelock:polygonZKEVMMainnet": "npx hardhat run upgrade/upgradeToV2/upgradeL2ToV2.ts --network polygonZKEVMMainnet"

}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions upgrade/tool-regen-upgrade-info/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"proxyAddress": "0xaddress",
"implementationName": "PolygonZkEVMUpgraded",
"constructorArgs": [
"0xaddress",
"0xaddress",
"0xaddress",
"0xaddress",
0,
0,
0
]
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved */
const { ethers, upgrades } = require('hardhat');
const path = require('path');
const fs = require('fs');
// require('dotenv').config({ path: path.resolve(__dirname, '../.env') });
import {expect} from "chai";
import path = require("path");
import fs = require("fs");

import {ethers, upgrades} from "hardhat";
const input = require("./input.json");

async function main() {
// load input file
const input = JSON.parse(fs.readFileSync(path.resolve(__dirname, './input.json')));

// Load implementation contract
const PolygonZkEVMFactory = await ethers.getContractFactory(input.implementationName, ethers.provider);
const PolygonZkEVMFactory = (await ethers.getContractFactory(input.implementationName)) as any;

// Import OZ upgrades
await upgrades.forceImport(input.proxyAddress, PolygonZkEVMFactory, {
kind: 'transparent',
kind: "transparent",
constructorArgs: input.constructorArgs,
});
}
Expand Down
115 changes: 115 additions & 0 deletions upgrade/upgradeToV2/testnet/deployTestnetPol.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* eslint-disable no-await-in-loop, no-use-before-define, no-lonely-if */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved */
import {expect} from "chai";
import path = require("path");
import fs = require("fs");

import * as dotenv from "dotenv";
dotenv.config({path: path.resolve(__dirname, "../../../.env")});
import {ethers, upgrades} from "hardhat";
const deployParameters = require("../deploy_parameters.json");

async function main() {
const {trustedSequencer} = deployParameters;

// Load provider
let currentProvider = ethers.provider;
if (deployParameters.multiplierGas || deployParameters.maxFeePerGas) {
if (process.env.HARDHAT_NETWORK !== "hardhat") {
currentProvider = ethers.getDefaultProvider(
`https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}`
) as any;
if (deployParameters.maxPriorityFeePerGas && deployParameters.maxFeePerGas) {
console.log(
`Hardcoded gas used: MaxPriority${deployParameters.maxPriorityFeePerGas} gwei, MaxFee${deployParameters.maxFeePerGas} gwei`
);
const FEE_DATA = new ethers.FeeData(
null,
ethers.parseUnits(deployParameters.maxFeePerGas, "gwei"),
ethers.parseUnits(deployParameters.maxPriorityFeePerGas, "gwei")
);

currentProvider.getFeeData = async () => FEE_DATA;
} else {
console.log("Multiplier gas used: ", deployParameters.multiplierGas);
async function overrideFeeData() {
const feedata = await ethers.provider.getFeeData();
return new ethers.FeeData(
null,
((feedata.maxFeePerGas as bigint) * BigInt(deployParameters.multiplierGas)) / 1000n,
((feedata.maxPriorityFeePerGas as bigint) * BigInt(deployParameters.multiplierGas)) / 1000n
);
}
currentProvider.getFeeData = overrideFeeData;
}
}
}

// Load deployer
let deployer;
if (deployParameters.deployerPvtKey) {
deployer = new ethers.Wallet(deployParameters.deployerPvtKey, currentProvider);
} else if (process.env.MNEMONIC) {
deployer = ethers.HDNodeWallet.fromMnemonic(
ethers.Mnemonic.fromPhrase(process.env.MNEMONIC),
"m/44'/60'/0'/0/0"
).connect(currentProvider);
} else {
[deployer] = await ethers.getSigners();
}

console.log("deploying with: ", deployer.address);

/*
*Deployment pol
*/
const polTokenName = "Pol Token";
const polTokenSymbol = "POL";
const polTokenInitialBalance = ethers.parseEther("20000000");

const polTokenFactory = await ethers.getContractFactory("ERC20PermitMock", deployer);
const polTokenContract = await polTokenFactory.deploy(
polTokenName,
polTokenSymbol,
deployer.address,
polTokenInitialBalance
);
await polTokenContract.waitForDeployment();

console.log("#######################\n");
console.log("pol deployed to:", polTokenContract.target);
console.log("you can verify the new impl address with:");
console.log(
`npx hardhat verify --constructor-args upgrade/arguments.js ${polTokenContract.target} --network ${process.env.HARDHAT_NETWORK}\n`
);
console.log("Copy the following constructor arguments on: upgrade/arguments.js \n", [
polTokenName,
polTokenSymbol,
deployer.address,
polTokenInitialBalance,
]);

const tokensBalance = ethers.parseEther("100000");
await (await polTokenContract.transfer(trustedSequencer, tokensBalance)).wait();
}

main().catch((e) => {
console.error(e);
process.exit(1);
});

// OZ test functions
function genOperation(target: any, value: any, data: any, predecessor: any, salt: any) {
const id = ethers.solidityPackedKeccak256(
["address", "uint256", "bytes", "uint256", "bytes32"],
[target, value, data, predecessor, salt]
);
return {
id,
target,
value,
data,
predecessor,
salt,
};
}
Loading

0 comments on commit b2a62e6

Please sign in to comment.