Skip to content

Commit

Permalink
fix: upgrade & bytecode validation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
viraj124 committed Sep 24, 2024
1 parent d1be73e commit 30a3bcd
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions packages/solidity-contracts/scripts/hardhat/verifyDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ task('verify-deployment', 'Verifies the deployed contract bytecode').setAction(
let deployedBytecode: string;

if (!deployment.linkedData.isProxy) {
const deployedImplementation =
await hre.upgrades.erc1967.getImplementationAddress(
deployment.address
);

deployedBytecode = await hre.ethers.provider.getCode(
deployedImplementation
deployment.address
);
} else continue;

Expand All @@ -33,7 +28,7 @@ task('verify-deployment', 'Verifies the deployed contract bytecode').setAction(
await localHardhat.run('compile');

const ContractFactory = await localHardhat.ethers.getContractFactory(
contractName
deployment.linkedData.factory
);
let localAddress: string;

Expand All @@ -48,16 +43,30 @@ task('verify-deployment', 'Verifies the deployed contract bytecode').setAction(
}
);

console.log('--- Upgrade success');
localAddress = deployment.linkedData.newImplementation;
console.log('--- Upgrade Validated...');

console.log(
'--- Performing mock upgrade to fetch the local bytecode...'
);

const contract = await localHardhat.upgrades.upgradeProxy(
deployment.address,
ContractFactory,
{
kind: 'uups',
constructorArgs: deployment.linkedData.constructorArgs,
}
);

console.log('--- Upgrade successful');
await contract.waitForDeployment();
localAddress = await contract.getAddress();
} else continue;

console.log('--- Fetching local deployment bytecode...');
let localBytecode: string;
if (!deployment.linkedData.isProxy) {
localBytecode = await localHardhat.ethers.provider.getCode(
localAddress
);
localBytecode = await hre.ethers.provider.getCode(localAddress);
} else continue;

console.log('--- Comparing bytecodes...');
Expand Down

0 comments on commit 30a3bcd

Please sign in to comment.