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

Deployment improvement #152

Merged
merged 7 commits into from
Jan 4, 2024
Merged
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
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') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding config for localhost... not sure why it worked before without this helper

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') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option makes it easier to deploy to the 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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the side effects of having two compiled contracts: (one from foundry and one from hardhat) is that we need to specifiy it more in detail

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
Loading