Skip to content

Commit 530d2d6

Browse files
committed
feat: always run the upgrade validation script before upgrading
1 parent a433d2f commit 530d2d6

7 files changed

+89
-11
lines changed

contracts/deploy/upgrade-all.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ const deployUpgradeAll: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2020

2121
const upgrade = async (contractName: string, initializer: string, args: any[]) => {
2222
try {
23+
print.highlight(`🔍 Validating upgrade of ${bold(contractName)}`);
24+
await hre.run("compare-storage", { contract: contractName });
25+
print.newline();
2326
print.highlight(`💣 Upgrading ${bold(contractName)}`);
2427
const { confirm } = await prompt.ask({
2528
type: "confirm",
2629
name: "confirm",
2730
message: "Are you sure you want to proceed?",
2831
});
2932
if (!confirm) {
30-
console.log("Operation cancelled by user.");
33+
print.info("Operation cancelled by user.");
3134
return;
3235
}
3336
print.info(`Upgrading ${contractName}...`);

contracts/deploy/upgrade-dispute-kit-v0.8.0.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { deployUpgradable } from "./utils/deployUpgradable";
44
import { HomeChains, isSkipped } from "./utils";
55
import { getContractNamesFromNetwork } from "../scripts/utils/contracts";
6+
import { print, prompt } from "gluegun";
7+
8+
const { bold } = print.colors;
69

710
const deployUpgradeDisputeKit: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
811
const { deployments, getNamedAccounts, getChainId } = hre;
@@ -14,7 +17,20 @@ const deployUpgradeDisputeKit: DeployFunction = async (hre: HardhatRuntimeEnviro
1417

1518
try {
1619
const { disputeKitClassic: contractName } = await getContractNamesFromNetwork(hre);
17-
console.log(`upgrading ${contractName}...`);
20+
print.highlight(`🔍 Validating upgrade of ${bold(contractName)}`);
21+
await hre.run("compare-storage", { contract: contractName });
22+
print.newline();
23+
print.highlight(`💣 Upgrading ${bold(contractName)}`);
24+
const { confirm } = await prompt.ask({
25+
type: "confirm",
26+
name: "confirm",
27+
message: "Are you sure you want to proceed?",
28+
});
29+
if (!confirm) {
30+
print.info("Operation cancelled by user.");
31+
return;
32+
}
33+
print.info(`Upgrading ${contractName}...`);
1834
await deployUpgradable(deployments, contractName, {
1935
contract: contractName,
2036
initializer: "initialize2",

contracts/deploy/upgrade-kleros-core-v0.8.0.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { deployUpgradable } from "./utils/deployUpgradable";
44
import { HomeChains, isSkipped } from "./utils";
55
import { getContractNamesFromNetwork } from "../scripts/utils/contracts";
6+
import { print, prompt } from "gluegun";
7+
8+
const { bold } = print.colors;
69

710
const deployUpgradeKlerosCore: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
811
const { deployments, getNamedAccounts, getChainId } = hre;
@@ -14,7 +17,20 @@ const deployUpgradeKlerosCore: DeployFunction = async (hre: HardhatRuntimeEnviro
1417

1518
try {
1619
const { core: contractName } = await getContractNamesFromNetwork(hre);
17-
console.log(`upgrading ${contractName}...`);
20+
print.highlight(`🔍 Validating upgrade of ${bold(contractName)}`);
21+
await hre.run("compare-storage", { contract: contractName });
22+
print.newline();
23+
print.highlight(`💣 Upgrading ${bold(contractName)}`);
24+
const { confirm } = await prompt.ask({
25+
type: "confirm",
26+
name: "confirm",
27+
message: "Are you sure you want to proceed?",
28+
});
29+
if (!confirm) {
30+
print.info("Operation cancelled by user.");
31+
return;
32+
}
33+
print.info(`Upgrading ${contractName}...`);
1834
await deployUpgradable(deployments, contractName, {
1935
contract: contractName,
2036
initializer: "initialize3",

contracts/deploy/upgrade-sortition-module-v0.8.0.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { deployUpgradable } from "./utils/deployUpgradable";
44
import { HomeChains, isSkipped } from "./utils";
55
import { getContractNamesFromNetwork } from "../scripts/utils/contracts";
6+
import { print, prompt } from "gluegun";
7+
8+
const { bold } = print.colors;
69

710
const deployUpgradeSortitionModule: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
811
const { deployments, getNamedAccounts, getChainId } = hre;
@@ -14,7 +17,20 @@ const deployUpgradeSortitionModule: DeployFunction = async (hre: HardhatRuntimeE
1417

1518
try {
1619
const { sortition: contractName } = await getContractNamesFromNetwork(hre);
17-
console.log(`upgrading ${contractName}...`);
20+
print.highlight(`🔍 Validating upgrade of ${bold(contractName)}`);
21+
await hre.run("compare-storage", { contract: contractName });
22+
print.newline();
23+
print.highlight(`💣 Upgrading ${bold(contractName)}`);
24+
const { confirm } = await prompt.ask({
25+
type: "confirm",
26+
name: "confirm",
27+
message: "Are you sure you want to proceed?",
28+
});
29+
if (!confirm) {
30+
print.info("Operation cancelled by user.");
31+
return;
32+
}
33+
print.info(`Upgrading ${contractName}...`);
1834
await deployUpgradable(deployments, contractName, {
1935
contract: contractName,
2036
initializer: "initialize3",

contracts/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"deploy": "hardhat deploy",
2929
"deploy-local": "hardhat deploy --tags Arbitration,HomeArbitrable --network localhost",
3030
"validate-upgrades": "openzeppelin-upgrades-core validate --exclude 'src/proxy/mock/**/*.sol' --exclude 'src/test/**/*.sol' artifacts/build-info",
31+
"validate-upgrades-against-deployed": "hardhat compare-storage",
3132
"simulate": "hardhat simulate:all",
3233
"simulate-local": "hardhat simulate:all --network localhost",
3334
"viem:generate-devnet": "NODE_NO_WARNINGS=1 wagmi generate -c wagmi.config.devnet.ts",
@@ -77,7 +78,7 @@
7778
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
7879
"@nomicfoundation/hardhat-ethers": "^3.0.8",
7980
"@nomiclabs/hardhat-solhint": "^4.0.1",
80-
"@openzeppelin/upgrades-core": "^1.41.0",
81+
"@openzeppelin/upgrades-core": "^1.42.2",
8182
"@typechain/ethers-v6": "^0.5.1",
8283
"@typechain/hardhat": "^9.1.0",
8384
"@types/chai": "^4.3.20",

contracts/scripts/compareStorageLayout.ts

-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ task("compare-storage", "Compare storage layout between deployed and modified co
5555

5656
const report = getStorageUpgradeReport(originalLayout, updatedLayout, validationOptions);
5757

58-
print.info(`\n${bold("Storage Layout Analysis:")}`);
59-
print.info("=".repeat(100));
60-
6158
if (report.ok) {
6259
print.success("✓ No storage layout incompatibilities found");
6360
return;

yarn.lock

+32-3
Original file line numberDiff line numberDiff line change
@@ -5559,7 +5559,7 @@ __metadata:
55595559
"@nomicfoundation/hardhat-ethers": "npm:^3.0.8"
55605560
"@nomiclabs/hardhat-solhint": "npm:^4.0.1"
55615561
"@openzeppelin/contracts": "npm:^5.2.0"
5562-
"@openzeppelin/upgrades-core": "npm:^1.41.0"
5562+
"@openzeppelin/upgrades-core": "npm:^1.42.2"
55635563
"@typechain/ethers-v6": "npm:^0.5.1"
55645564
"@typechain/hardhat": "npm:^9.1.0"
55655565
"@types/chai": "npm:^4.3.20"
@@ -7402,7 +7402,7 @@ __metadata:
74027402
languageName: node
74037403
linkType: hard
74047404

7405-
"@openzeppelin/upgrades-core@npm:^1.24.1, @openzeppelin/upgrades-core@npm:^1.41.0":
7405+
"@openzeppelin/upgrades-core@npm:^1.24.1":
74067406
version: 1.41.0
74077407
resolution: "@openzeppelin/upgrades-core@npm:1.41.0"
74087408
dependencies:
@@ -7422,6 +7422,26 @@ __metadata:
74227422
languageName: node
74237423
linkType: hard
74247424

7425+
"@openzeppelin/upgrades-core@npm:^1.42.2":
7426+
version: 1.42.2
7427+
resolution: "@openzeppelin/upgrades-core@npm:1.42.2"
7428+
dependencies:
7429+
"@nomicfoundation/slang": "npm:^0.18.3"
7430+
cbor: "npm:^10.0.0"
7431+
chalk: "npm:^4.1.0"
7432+
compare-versions: "npm:^6.0.0"
7433+
debug: "npm:^4.1.1"
7434+
ethereumjs-util: "npm:^7.0.3"
7435+
minimatch: "npm:^9.0.5"
7436+
minimist: "npm:^1.2.7"
7437+
proper-lockfile: "npm:^4.1.1"
7438+
solidity-ast: "npm:^0.4.51"
7439+
bin:
7440+
openzeppelin-upgrades-core: dist/cli/cli.js
7441+
checksum: 10/7000c7cf6822eab2b8a927acc1f09b769004667644e389ae582cd4f87f74433cdd3bc80477f95990d40bb60c15b85e61e5ad4cd47e0e7e70c4e5cbef6cbad10c
7442+
languageName: node
7443+
linkType: hard
7444+
74257445
"@parcel/watcher-android-arm64@npm:2.3.0":
74267446
version: 2.3.0
74277447
resolution: "@parcel/watcher-android-arm64@npm:2.3.0"
@@ -13376,6 +13396,15 @@ __metadata:
1337613396
languageName: node
1337713397
linkType: hard
1337813398

13399+
"cbor@npm:^10.0.0":
13400+
version: 10.0.3
13401+
resolution: "cbor@npm:10.0.3"
13402+
dependencies:
13403+
nofilter: "npm:^3.0.2"
13404+
checksum: 10/ff33c3404c3acc8afc448163a7b32eea39f4f99d641ac496352a6830256617a0b1d49b2862746b6b150e8931b6f6da10572d78c28af3a64b6836881c33c5d942
13405+
languageName: node
13406+
linkType: hard
13407+
1337913408
"cbor@npm:^9.0.0":
1338013409
version: 9.0.2
1338113410
resolution: "cbor@npm:9.0.2"
@@ -25091,7 +25120,7 @@ __metadata:
2509125120
languageName: node
2509225121
linkType: hard
2509325122

25094-
"nofilter@npm:^3.1.0":
25123+
"nofilter@npm:^3.0.2, nofilter@npm:^3.1.0":
2509525124
version: 3.1.0
2509625125
resolution: "nofilter@npm:3.1.0"
2509725126
checksum: 10/f63d87231dfda4b783db17d75b15aac948f78e65f4f1043096ef441147f6667ff74cd4b3f57ada5dbe240be282d3e9838558ac863a66cb04ef25fff7b2b4be4e

0 commit comments

Comments
 (0)