Commit 2369af74 authored by Maurelian's avatar Maurelian Committed by Kelvin Fichter

refactor(contracts): Add config options for upgrade deployments

Also perform validation to prevent passing arguments which conflict, ie. arguments
for upgrades vs. arguments for fresh deployments.
parent 4af29574
...@@ -12,6 +12,7 @@ const DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW = 60 * 30 // 30 minutes ...@@ -12,6 +12,7 @@ const DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW = 60 * 30 // 30 minutes
const DEFAULT_DEPLOY_CONFIRMATIONS = 12 const DEFAULT_DEPLOY_CONFIRMATIONS = 12
task('deploy') task('deploy')
// Rollup config options
.addOptionalParam( .addOptionalParam(
'l1BlockTimeSeconds', 'l1BlockTimeSeconds',
'Number of seconds on average between every L1 block.', 'Number of seconds on average between every L1 block.',
...@@ -48,6 +49,7 @@ task('deploy') ...@@ -48,6 +49,7 @@ task('deploy')
DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW, DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW,
types.int types.int
) )
// Permissioned address options
.addOptionalParam( .addOptionalParam(
'ovmSequencerAddress', 'ovmSequencerAddress',
'Address of the sequencer. Must be provided or this deployment will fail.', 'Address of the sequencer. Must be provided or this deployment will fail.',
...@@ -61,14 +63,27 @@ task('deploy') ...@@ -61,14 +63,27 @@ task('deploy')
types.string types.string
) )
.addOptionalParam( .addOptionalParam(
'libAddressManager', 'ovmAddressManagerOwner',
'Address of the Lib_AddressManager, for use in a deployment which is keeping the existing contract.', 'Address that will own the Lib_AddressManager. Must be provided or this deployment will fail.',
undefined, undefined,
types.string types.string
) )
// Reusable address options
.addOptionalParam( .addOptionalParam(
'ovmAddressManagerOwner', 'proxyL1CrossDomainMessenger',
'Address that will own the Lib_AddressManager. Must be provided or this deployment will fail.', 'Address of the L1CrossDomainMessenger Proxy, for use in a deployment which is keeping the existing contract.',
undefined,
types.string
)
.addOptionalParam(
'proxyL1StandardBridge',
'Address of the L1StandardBridge Proxy, for use in a deployment which is keeping the existing contract.',
undefined,
types.string
)
.addOptionalParam(
'libAddressManager',
'Address of the Lib_AddressManager, for use in a deployment which is keeping the existing contract.',
undefined, undefined,
types.string types.string
) )
...@@ -103,24 +118,38 @@ task('deploy') ...@@ -103,24 +118,38 @@ task('deploy')
validateAddressArg('ovmProposerAddress') validateAddressArg('ovmProposerAddress')
validateAddressArg('ovmAddressManagerOwner') validateAddressArg('ovmAddressManagerOwner')
const hasAddressManagerTag = args.tags // validate potentially conflicting arguments
.split(',') const validateArgOrTag = (argName: string, tagName: string) => {
.includes('Lib_AddressManager') // ensure that both an arg and tag were not provided for a given contract
try { const hasTag = args.tags.includes(tagName)
validateAddressArg('libAddressManager') if (hasTag && ethers.utils.isAddress(args[argName])) {
if (hasAddressManagerTag) {
throw new Error( throw new Error(
'cannot deploy a new Lib_AddressManager if the address of an existing one is provided' `cannot deploy a new ${tagName} if the address of an existing one is provided`
) )
} }
} catch (error) { // ensure that either a valid address is provided or we'll deploy a new one.
if (!hasAddressManagerTag) { try {
throw new Error( validateAddressArg(argName)
'must either deploy a new Lib_AddressManager, or provide the address for an existing one' console.log(
`Running deployments with the existing ${tagName} at ${args[argName]}`
) )
} catch (error) {
if (!hasTag) {
throw new Error(
`${error.message} \nmust either deploy a new ${tagName}, or provide the address for an existing one`
)
}
console.log(`Running deployments with a new ${tagName}`)
} }
} }
validateArgOrTag('libAddressManager', 'Lib_AddressManager')
validateArgOrTag(
'proxyL1CrossDomainMessenger',
'Proxy__L1CrossDomainMessenger'
)
validateArgOrTag('proxyL1StandardBridge', 'Proxy__L1StandardBridge')
hre.deployConfig = args hre.deployConfig = args
return runSuper(args) return runSuper(args)
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment