deploy.ts 3.13 KB
Newer Older
1 2 3 4 5 6
/* Imports: External */
import { ethers } from 'ethers'
import { task } from 'hardhat/config'
import * as types from 'hardhat/internal/core/params/argumentTypes'

const DEFAULT_L1_BLOCK_TIME_SECONDS = 15
7
const DEFAULT_CTC_MAX_TRANSACTION_GAS_LIMIT = 11_000_000
8 9
const DEFAULT_CTC_L2_GAS_DISCOUNT_DIVISOR = 32
const DEFAULT_CTC_ENQUEUE_GAS_COST = 60_000
10 11
const DEFAULT_SCC_FRAUD_PROOF_WINDOW = 60 * 60 * 24 * 7 // 7 days
const DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW = 60 * 30 // 30 minutes
12
const DEFAULT_DEPLOY_CONFIRMATIONS = 12
13 14

task('deploy')
15
  // Rollup config options
16 17 18 19 20 21 22 23 24 25 26 27
  .addOptionalParam(
    'l1BlockTimeSeconds',
    'Number of seconds on average between every L1 block.',
    DEFAULT_L1_BLOCK_TIME_SECONDS,
    types.int
  )
  .addOptionalParam(
    'ctcMaxTransactionGasLimit',
    'Max gas limit for L1 queue transactions.',
    DEFAULT_CTC_MAX_TRANSACTION_GAS_LIMIT,
    types.int
  )
28 29 30 31 32 33 34 35 36 37 38 39
  .addOptionalParam(
    'ctcL2GasDiscountDivisor',
    'Max gas limit for L1 queue transactions.',
    DEFAULT_CTC_L2_GAS_DISCOUNT_DIVISOR,
    types.int
  )
  .addOptionalParam(
    'ctcEnqueueGasCost',
    'Max gas limit for L1 queue transactions.',
    DEFAULT_CTC_ENQUEUE_GAS_COST,
    types.int
  )
40 41 42 43 44 45 46 47 48 49 50 51
  .addOptionalParam(
    'sccFraudProofWindow',
    'Number of seconds until a transaction is considered finalized.',
    DEFAULT_SCC_FRAUD_PROOF_WINDOW,
    types.int
  )
  .addOptionalParam(
    'sccSequencerPublishWindow',
    'Number of seconds that the sequencer is exclusively allowed to post state roots.',
    DEFAULT_SCC_SEQUENCER_PUBLISH_WINDOW,
    types.int
  )
52
  // Permissioned address options
53 54 55 56 57 58 59 60 61 62 63 64
  .addOptionalParam(
    'ovmSequencerAddress',
    'Address of the sequencer. Must be provided or this deployment will fail.',
    undefined,
    types.string
  )
  .addOptionalParam(
    'ovmProposerAddress',
    'Address of the account that will propose state roots. Must be provided or this deployment will fail.',
    undefined,
    types.string
  )
65
  .addOptionalParam(
66 67
    'ovmAddressManagerOwner',
    'Address that will own the Lib_AddressManager. Must be provided or this deployment will fail.',
68 69 70
    undefined,
    types.string
  )
71 72 73 74 75 76
  .addOptionalParam(
    'numDeployConfirmations',
    'Number of confirmations to wait for each transaction in the deployment. More is safer.',
    DEFAULT_DEPLOY_CONFIRMATIONS,
    types.int
  )
77 78 79 80 81 82
  .addOptionalParam(
    'forked',
    'Enable this when using a forked network (use "true")',
    undefined,
    types.string
  )
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
  .setAction(async (args, hre: any, runSuper) => {
    // Necessary because hardhat doesn't let us attach non-optional parameters to existing tasks.
    const validateAddressArg = (argName: string) => {
      if (args[argName] === undefined) {
        throw new Error(
          `argument for ${argName} is required but was not provided`
        )
      }
      if (!ethers.utils.isAddress(args[argName])) {
        throw new Error(
          `argument for ${argName} is not a valid address: ${args[argName]}`
        )
      }
    }

    validateAddressArg('ovmSequencerAddress')
    validateAddressArg('ovmProposerAddress')
    validateAddressArg('ovmAddressManagerOwner')

    hre.deployConfig = args
    return runSuper(args)
  })