Skip to content

Commit

Permalink
fix(core): add flag that allows users to skip the storage slot checker
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Jan 18, 2023
1 parent 2b8af04 commit f14cc8d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .changeset/orange-readers-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@chugsplash/core': patch
'@chugsplash/plugins': patch
---

Add flag that allows users to skip the storage slot checker
2 changes: 1 addition & 1 deletion packages/core/src/config/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const assertValidChugSplashConfigFields = (
}
}

export const assertValidUpgrade = async (
export const assertStorageSlotCheck = async (
provider: providers.Provider,
config: ParsedChugSplashConfig,
artifactPaths: ArtifactPaths,
Expand Down
40 changes: 23 additions & 17 deletions packages/core/src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { create } from 'ipfs-http-client'
import { EXECUTOR, ProxyABI } from '@chugsplash/contracts'

import {
assertValidUpgrade,
assertStorageSlotCheck,
CanonicalChugSplashConfig,
ParsedChugSplashConfig,
} from '../config'
Expand Down Expand Up @@ -123,6 +123,7 @@ export const chugsplashProposeAbstractTask = async (
buildInfoFolder: string,
artifactFolder: string,
canonicalConfigPath: string,
skipStorageCheck: boolean,
stream: NodeJS.WritableStream = process.stderr
) => {
const spinner = ora({ isSilent: silent, stream })
Expand All @@ -132,14 +133,16 @@ export const chugsplashProposeAbstractTask = async (

await initializeChugSplash(provider, signer, EXECUTOR)

await assertValidUpgrade(
provider,
parsedConfig,
artifactPaths,
integration,
remoteExecution,
canonicalConfigPath
)
if (!skipStorageCheck) {
await assertStorageSlotCheck(
provider,
parsedConfig,
artifactPaths,
integration,
remoteExecution,
canonicalConfigPath
)
}

if (
(await isProjectRegistered(signer, parsedConfig.options.projectName)) ===
Expand Down Expand Up @@ -617,6 +620,7 @@ export const chugsplashDeployAbstractTask = async (
canonicalConfigPath: string,
deploymentFolder: string,
integration: Integration,
skipStorageCheck: boolean,
executor?: ChugSplashExecutorType,
stream: NodeJS.WritableStream = process.stderr
): Promise<FoundryContractArtifact[] | undefined> => {
Expand All @@ -639,14 +643,16 @@ export const chugsplashDeployAbstractTask = async (
integration
)

await assertValidUpgrade(
provider,
parsedConfig,
artifactPaths,
integration,
remoteExecution,
canonicalConfigPath
)
if (!skipStorageCheck) {
await assertStorageSlotCheck(
provider,
parsedConfig,
artifactPaths,
integration,
remoteExecution,
canonicalConfigPath
)
}

const projectName = parsedConfig.options.projectName

Expand Down
1 change: 1 addition & 0 deletions packages/plugins/src/hardhat/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const deployAllChugSplashConfigs = async (
canonicalConfigPath,
deploymentFolder,
'hardhat',
true,
executor
)
}
Expand Down
26 changes: 23 additions & 3 deletions packages/plugins/src/hardhat/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const chugsplashDeployTask = async (
noCompile: boolean
confirm: boolean
noWithdraw: boolean
skipStorageCheck: boolean
},
hre: HardhatRuntimeEnvironment
) => {
Expand All @@ -131,6 +132,7 @@ export const chugsplashDeployTask = async (
noCompile,
confirm,
noWithdraw,
skipStorageCheck,
} = args

if (!noCompile) {
Expand Down Expand Up @@ -186,6 +188,7 @@ export const chugsplashDeployTask = async (
canonicalConfigPath,
deploymentFolder,
'hardhat',
skipStorageCheck,
executor
)
}
Expand All @@ -211,6 +214,10 @@ task(TASK_CHUGSPLASH_DEPLOY)
'confirm',
'Automatically confirm contract upgrades. Only applicable if upgrading on a live network.'
)
.addFlag(
'skipStorageCheck',
"Upgrade your contract(s) without checking for storage layout compatibility. Only use this when confident that the upgrade won't lead to storage layout issues."
)
.setAction(chugsplashDeployTask)

export const chugsplashRegisterTask = async (
Expand Down Expand Up @@ -272,11 +279,19 @@ export const chugsplashProposeTask = async (
noCompile: boolean
remoteExecution: boolean
confirm: boolean
skipStorageCheck: boolean
},
hre: HardhatRuntimeEnvironment
) => {
const { configPath, ipfsUrl, silent, noCompile, remoteExecution, confirm } =
args
const {
configPath,
ipfsUrl,
silent,
noCompile,
remoteExecution,
confirm,
skipStorageCheck,
} = args

if (!noCompile) {
await hre.run(TASK_COMPILE, {
Expand Down Expand Up @@ -318,7 +333,8 @@ export const chugsplashProposeTask = async (
artifactPaths,
buildInfoFolder,
artifactFolder,
canonicalConfigPath
canonicalConfigPath,
skipStorageCheck
)
}

Expand All @@ -335,6 +351,10 @@ task(TASK_CHUGSPLASH_PROPOSE)
'confirm',
'Automatically confirm contract upgrades. Only applicable if upgrading on a live network.'
)
.addFlag(
'skipStorageCheck',
"Upgrade your contract(s) without checking for storage layout compatibility. Only use this when confident that the upgrade won't lead to storage layout issues."
)
.setAction(chugsplashProposeTask)

export const chugsplashApproveTask = async (
Expand Down

0 comments on commit f14cc8d

Please sign in to comment.