Skip to content

Commit

Permalink
Deployment improvement (#152)
Browse files Browse the repository at this point in the history
Some modifications to the deployment scripts for easier runnablity and readablity.

(Unfortuantley, verifiying the bridge contract is still not possible.)
  • Loading branch information
josojo authored Jan 4, 2024
1 parent a299831 commit d6275f5
Show file tree
Hide file tree
Showing 8 changed files with 10,052 additions and 14,769 deletions.
1 change: 1 addition & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
paths: [
'@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol',
'@RealityETH/zkevm-contracts/contracts/mocks/ERC20PermitMock.sol',
'@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol',
'@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol',
'@RealityETH/zkevm-contracts/contracts/deployment/PolygonZkEVMDeployer.sol',
'@RealityETH/zkevm-contracts/contracts/PolygonZkEVMGlobalExitRootL2.sol',
Expand Down
9,154 changes: 2,238 additions & 6,916 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions src/deployment/1_deployforkableToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,39 @@ async function main() {
const attemptsDeployProxy = 5;
// Load provider
let currentProvider = ethers.provider;
if (deployParameters.multiplierGas || deployParameters.maxFeePerGas) {
if (process.env.HARDHAT_NETWORK !== 'hardhat') {
currentProvider = new ethers.providers.JsonRpcProvider(`https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}`);
if (deployParameters.maxPriorityFeePerGas && deployParameters.maxFeePerGas) {
console.log(`Hardcoded gas used: MaxPriority${deployParameters.maxPriorityFeePerGas} gwei, MaxFee${deployParameters.maxFeePerGas} gwei`);
const FEE_DATA = {
maxFeePerGas: ethers.utils.parseUnits(deployParameters.maxFeePerGas, 'gwei'),
maxPriorityFeePerGas: ethers.utils.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 {
maxFeePerGas: feedata.maxFeePerGas.mul(deployParameters.multiplierGas).div(1000),
maxPriorityFeePerGas: feedata.maxPriorityFeePerGas.mul(deployParameters.multiplierGas).div(1000),
if (process.env.HARDHAT_NETWORK === 'localhost') {
currentProvider = new ethers.providers.JsonRpcProvider('https://127.0.0.1:8454');
} else {
if (deployParameters.multiplierGas || deployParameters.maxFeePerGas) {
if (process.env.HARDHAT_NETWORK !== 'hardhat') {
currentProvider = new ethers.providers.JsonRpcProvider(`https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}`);
if (deployParameters.maxPriorityFeePerGas && deployParameters.maxFeePerGas) {
console.log(`Hardcoded gas used: MaxPriority${deployParameters.maxPriorityFeePerGas} gwei, MaxFee${deployParameters.maxFeePerGas} gwei`);
const FEE_DATA = {
maxFeePerGas: ethers.utils.parseUnits(deployParameters.maxFeePerGas, 'gwei'),
maxPriorityFeePerGas: ethers.utils.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 {
maxFeePerGas: feedata.maxFeePerGas.mul(deployParameters.multiplierGas).div(1000),
maxPriorityFeePerGas: feedata.maxPriorityFeePerGas.mul(deployParameters.multiplierGas).div(1000),
};
}
currentProvider.getFeeData = overrideFeeData;
}
currentProvider.getFeeData = overrideFeeData;
}
}
}
// Load deployer
let deployer;
if (deployParameters.deployerPvtKey) {
deployer = new ethers.Wallet(deployParameters.deployerPvtKey, currentProvider);
} else if (process.env.HARDHAT_NETWORK === 'localhost') {
[deployer] = (await ethers.getSigners());
} else if (process.env.MNEMONIC) {
deployer = ethers.Wallet.fromMnemonic(process.env.MNEMONIC, 'm/44\'/60\'/0\'/0/0').connect(currentProvider);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/deployment/2_creategenesis.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function main() {
* deploy proxy
* Do not initialize directlythe proxy since we want to deploy the same code on L2 and this will alter the bytecode deployed of the proxy
*/
const transparentProxyFactory = await ethers.getContractFactory('TransparentUpgradeableProxy', deployer);
const transparentProxyFactory = await ethers.getContractFactory('@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol:TransparentUpgradeableProxy', deployer);
const initializeEmptyDataProxy = '0x';
const deployTransactionProxy = (transparentProxyFactory.getDeployTransaction(
bridgeImplementationAddress,
Expand Down Expand Up @@ -155,7 +155,7 @@ async function main() {
/*
*Deployment Global exit root manager
*/
const PolygonZkEVMGlobalExitRootL2Factory = await ethers.getContractFactory('PolygonZkEVMGlobalExitRootL2', deployer);
const PolygonZkEVMGlobalExitRootL2Factory = await ethers.getContractFactory('@RealityETH/zkevm-contracts/contracts/PolygonZkEVMGlobalExitRootL2.sol:PolygonZkEVMGlobalExitRootL2', deployer);
let polygonZkEVMGlobalExitRootL2;
for (let i = 0; i < attemptsDeployProxy; i++) {
try {
Expand All @@ -180,7 +180,7 @@ async function main() {
expect(await upgrades.erc1967.getAdminAddress(polygonZkEVMGlobalExitRootL2.address)).to.be.equal(proxyAdminAddress);
expect(await upgrades.erc1967.getAdminAddress(proxyBridgeAddress)).to.be.equal(proxyAdminAddress);

const timelockContractFactory = await ethers.getContractFactory('PolygonZkEVMTimelock', deployer);
const timelockContractFactory = await ethers.getContractFactory('@RealityETH/zkevm-contracts/contracts/PolygonZkEVMTimelock.sol:PolygonZkEVMTimelock', deployer);
const timelockContract = await timelockContractFactory.deploy(
minDelayTimelock,
[timelockAddress],
Expand Down
Loading

0 comments on commit d6275f5

Please sign in to comment.