010-AddressDictator.deploy.ts 2.6 KB
Newer Older
1
/* Imports: External */
2
import { DeployFunction } from 'hardhat-deploy/dist/types'
3
import { hexStringEquals } from '@eth-optimism/core-utils'
4 5 6

/* Imports: Internal */
import {
7
  deployAndVerifyAndThen,
8
  getContractFromArtifact,
9
} from '../src/deploy-utils'
10
import { getDeployConfig } from '../src/deploy-config'
11
import { names } from '../src/address-names'
12
import { predeploys } from '../src/predeploys'
13 14

const deployFn: DeployFunction = async (hre) => {
15 16
  const deployConfig = getDeployConfig(hre.network.name)

17 18
  const Lib_AddressManager = await getContractFromArtifact(
    hre,
19
    names.unmanaged.Lib_AddressManager
20
  )
21

22 23 24 25
  let namesAndAddresses: {
    name: string
    address: string
  }[] = await Promise.all(
26
    Object.values(names.managed.contracts).map(async (name) => {
27 28
      return {
        name,
29
        address: (await getContractFromArtifact(hre, name)).address,
30
      }
31 32 33
    })
  )

34
  // Add non-deployed addresses to the Address Dictator arguments.
35 36 37 38 39 40 41 42 43 44 45 46
  namesAndAddresses = [
    ...namesAndAddresses,
    // L2CrossDomainMessenger is the address of the predeploy on L2. We can refactor off-chain
    // services such that we can remove the need to set this address, but for now it's easier
    // to simply keep setting the address.
    {
      name: 'L2CrossDomainMessenger',
      address: predeploys.L2CrossDomainMessenger,
    },
    // OVM_Sequencer is the address allowed to submit "Sequencer" blocks to the
    // CanonicalTransactionChain.
    {
47
      name: names.managed.accounts.OVM_Sequencer,
48
      address: deployConfig.ovmSequencerAddress,
49 50 51 52
    },
    // OVM_Proposer is the address allowed to submit state roots (transaction results) to the
    // StateCommitmentChain.
    {
53
      name: names.managed.accounts.OVM_Proposer,
54
      address: deployConfig.ovmProposerAddress,
55 56
    },
  ]
57

58 59
  // Filter out all addresses that will not change, so that the log statement is maximally
  // verifiable and readable.
60 61 62 63 64 65 66 67
  const existingAddresses = {}
  for (const pair of namesAndAddresses) {
    existingAddresses[pair.name] = await Lib_AddressManager.getAddress(
      pair.name
    )
  }
  namesAndAddresses = namesAndAddresses.filter(({ name, address }) => {
    return !hexStringEquals(existingAddresses[name], address)
68
  })
69

70
  await deployAndVerifyAndThen({
71
    hre,
72
    name: names.unmanaged.AddressDictator,
73 74
    args: [
      Lib_AddressManager.address,
75
      deployConfig.ovmAddressManagerOwner,
76 77 78 79 80 81
      namesAndAddresses.map((pair) => {
        return pair.name
      }),
      namesAndAddresses.map((pair) => {
        return pair.address
      }),
82 83 84 85
    ],
  })
}

86
deployFn.tags = ['upgrade', 'AddressDictator']
87 88

export default deployFn