Skip to content

Commit

Permalink
improve verify script
Browse files Browse the repository at this point in the history
  • Loading branch information
josojo committed Feb 12, 2024
1 parent 04161ed commit af01e12
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/deployment/verifyContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ const pathDeployParameters = path.join(__dirname, './deploy_parameters.json');
const deployOutputParameters = require(pathDeployOutputParameters);
const deployParameters = require(pathDeployParameters);

async function getImplementationAddress(proxyAddress) {
// The specific storage slot for the implementation address as per EIP-1967
const slot = '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc';
// Query the storage at the slot
const implementationAddressHex = await hre.ethers.provider.getStorageAt(proxyAddress, slot);
// Convert the storage result to a proper address format
const implementationAddress = hre.ethers.utils.getAddress(hre.ethers.utils.hexStripZeros(implementationAddressHex));
return implementationAddress;
}

async function main() {
// load deployer account
if (typeof process.env.ETHERSCAN_API_KEY === 'undefined') {
Expand Down Expand Up @@ -121,6 +131,19 @@ async function main() {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify zkEVM implementation address
try {
const implemenation = await getImplementationAddress(deployOutputParameters.polygonZkEVMAddress);
await hre.run(
'verify:verify',
{
address: implemenation,
},
);
} catch (error) {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify global exit root address
try {
await hre.run(
Expand All @@ -133,6 +156,19 @@ async function main() {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify global exit implementation address
try {
const implemenation = await getImplementationAddress(deployOutputParameters.polygonZkEVMGlobalExitRootAddress);
await hre.run(
'verify:verify',
{
address: implemenation,
},
);
} catch (error) {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify bridge
try {
await hre.run(
Expand All @@ -150,6 +186,19 @@ async function main() {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify bridge implementation address
try {
const implemenation = await getImplementationAddress(deployOutputParameters.polygonZkEVMBridgeAddress);
await hre.run(
'verify:verify',
{
address: implemenation,
},
);
} catch (error) {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify forking manager
try {
await hre.run(
Expand All @@ -161,6 +210,19 @@ async function main() {
} catch (error) {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}

// verify fork manager implementation address
try {
const implemenation = await getImplementationAddress(deployOutputParameters.forkingManager);
await hre.run(
'verify:verify',
{
address: implemenation,
},
);
} catch (error) {
expect(error.message.toLowerCase().includes('proxyadmin')).to.be.equal(true);
}
}

main()
Expand Down

0 comments on commit af01e12

Please sign in to comment.