forked from 0xPolygonHermez/zkevm-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c328c7a
commit 8c78b1d
Showing
14 changed files
with
152 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* eslint-disable no-console, no-unused-vars, no-use-before-define */ | ||
const hre = require('hardhat'); | ||
const { ethers, upgrades } = require('hardhat'); | ||
const path = require('path'); | ||
require('dotenv').config({ path: path.resolve(__dirname, '../.env') }); | ||
|
||
async function main() { | ||
// Set multiplier Gas | ||
const multiplierGas = 3; | ||
const currentProvider = new ethers.providers.JsonRpcProvider(`https://${process.env.HARDHAT_NETWORK}.infura.io/v3/${process.env.INFURA_PROJECT_ID}`); | ||
async function overrideFeeData() { | ||
const feedata = await ethers.provider.getFeeData(); | ||
return { | ||
maxFeePerGas: feedata.maxFeePerGas.mul(multiplierGas), | ||
maxPriorityFeePerGas: feedata.maxPriorityFeePerGas.mul(multiplierGas), | ||
}; | ||
} | ||
currentProvider.getFeeData = overrideFeeData; | ||
|
||
let deployer; | ||
if (process.env.MNEMONIC) { | ||
deployer = ethers.Wallet.fromMnemonic(process.env.MNEMONIC, 'm/44\'/60\'/0\'/0/0').connect(currentProvider); | ||
} else { | ||
[deployer] = (await ethers.getSigners()); | ||
} | ||
|
||
// compìle contracts | ||
await hre.run('compile'); | ||
|
||
const proxyPolygonZkEVMAddress = '0xFD44A8D8f28AadB1Ce916012c7C921f759056Ef7'; | ||
const polygonZkEVMFactory = await ethers.getContractFactory('PolygonZkEVMMock'); | ||
|
||
// Upgrade zkevm | ||
const newImplPolygonZkEVMAddress = await upgrades.prepareUpgrade(proxyPolygonZkEVMAddress, polygonZkEVMFactory); | ||
const proxyAdmin = await upgrades.admin.getInstance(); | ||
|
||
console.log({ newImplPolygonZkEVMAddress }); | ||
|
||
// Use timelock | ||
const operation = genOperation( | ||
proxyAdmin.address, | ||
0, // value | ||
proxyAdmin.interface.encodeFunctionData( | ||
'upgrade', | ||
[proxyPolygonZkEVMAddress, | ||
newImplPolygonZkEVMAddress], | ||
), | ||
ethers.constants.HashZero, // predecesoor | ||
ethers.constants.HashZero, // salt TODO | ||
); | ||
|
||
// Timelock operations | ||
const TimelockFactory = await ethers.getContractFactory('PolygonZkEVMTimelock', deployer); | ||
const minDelay = 10; // TODO upgrade parameter | ||
|
||
// Schedule operation | ||
const scheduleData = TimelockFactory.interface.encodeFunctionData( | ||
'schedule', | ||
[ | ||
operation.target, | ||
operation.value, | ||
operation.data, | ||
operation.predecessor, | ||
operation.salt, | ||
minDelay, | ||
], | ||
); | ||
// Executre operation | ||
const executeData = TimelockFactory.interface.encodeFunctionData( | ||
'execute', | ||
[ | ||
operation.target, | ||
operation.value, | ||
operation.data, | ||
operation.predecessor, | ||
operation.salt, | ||
], | ||
); | ||
|
||
console.log({ scheduleData }); | ||
console.log({ executeData }); | ||
} | ||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
|
||
// OZ test functions | ||
function genOperation(target, value, data, predecessor, salt) { | ||
const id = ethers.utils.solidityKeccak256([ | ||
'address', | ||
'uint256', | ||
'bytes', | ||
'uint256', | ||
'bytes32', | ||
], [ | ||
target, | ||
value, | ||
data, | ||
predecessor, | ||
salt, | ||
]); | ||
return { | ||
id, target, value, data, predecessor, salt, | ||
}; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters