Skip to content

Commit

Permalink
upgrade tss contract
Browse files Browse the repository at this point in the history
  • Loading branch information
byteflyfunny committed Mar 21, 2024
1 parent b0d0f56 commit cdf9fb5
Show file tree
Hide file tree
Showing 20 changed files with 13 additions and 1,335 deletions.
29 changes: 0 additions & 29 deletions packages/contracts/deploy/001-Lib_AddressManager.deploy.ts
Original file line number Diff line number Diff line change
@@ -1,29 +0,0 @@
/* Imports: Internal */
import { DeployFunction } from 'hardhat-deploy/dist/types'

import { names } from '../src/address-names'
import { hexStringEquals } from '@mantleio/core-utils'

/* Imports: External */

const deployFn: DeployFunction = async (hre) => {
const { deploy } = hre.deployments
const { deployer } = await hre.getNamedAccounts()
const owner = hre.deployConfig.bvmAddressManagerOwner

if (hexStringEquals(deployer, owner)) {
console.log("deployer ", deployer, "can not be owner ", owner)
process.exit(1)
}
await deploy(names.unmanaged.Lib_AddressManager, {
from: deployer,
args: [],
log: true,
waitConfirmations: hre.deployConfig.numDeployConfirmations,
})
}

// This is kept during an upgrade. So no upgrade tag.
deployFn.tags = ['Lib_AddressManager']

export default deployFn
Original file line number Diff line number Diff line change
@@ -1,27 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.ChainStorageContainer_CTC_batches,
contract: 'ChainStorageContainer',
args: [Lib_AddressManager.address, 'CanonicalTransactionChain'],
})
}

deployFn.tags = ['ChainStorageContainer_ctc_batches', 'upgrade']

export default deployFn
Original file line number Diff line number Diff line change
@@ -1,27 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.ChainStorageContainer_SCC_batches,
contract: 'ChainStorageContainer',
args: [Lib_AddressManager.address, 'StateCommitmentChain'],
})
}

deployFn.tags = ['ChainStorageContainer_scc_batches', 'upgrade']

export default deployFn
Original file line number Diff line number Diff line change
@@ -1,31 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.CanonicalTransactionChain,
args: [
Lib_AddressManager.address,
hre.deployConfig.l2BlockGasLimit,
hre.deployConfig.ctcL2GasDiscountDivisor,
hre.deployConfig.ctcEnqueueGasCost,
],
})
}

deployFn.tags = ['CanonicalTransactionChain', 'upgrade']

export default deployFn
26 changes: 0 additions & 26 deletions packages/contracts/deploy/005-BVM_BondManager.deploy.ts
Original file line number Diff line number Diff line change
@@ -1,26 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.BondManager,
args: [Lib_AddressManager.address],
})
}

deployFn.tags = ['BondManager', 'upgrade']

export default deployFn
84 changes: 0 additions & 84 deletions packages/contracts/deploy/006-BVM_L1CrossDomainMessenger.deploy.ts
Original file line number Diff line number Diff line change
@@ -1,84 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { hexStringEquals, awaitCondition } from '@mantleio/core-utils'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.BVM_L1CrossDomainMessenger,
contract: 'L1CrossDomainMessenger',
args: [],
postDeployAction: async (contract) => {
// Theoretically it's not necessary to initialize this contract since it sits behind
// a proxy. However, it's best practice to initialize it anyway just in case there's
// some unknown security hole. It also prevents another user from appearing like an
// official address because it managed to call the initialization function.
console.log(`Initializing L1CrossDomainMessenger (implementation)...`)
await contract.initialize(Lib_AddressManager.address)

console.log(`Checking that contract was correctly initialized...`)
await awaitCondition(
async () => {
return hexStringEquals(
await contract.libAddressManager(),
Lib_AddressManager.address
)
},
5000,
100
)

// Same thing as above, we want to transfer ownership of this contract to the owner of the
// AddressManager. Not technically necessary but seems like the right thing to do.
console.log(
`set pauseowner of L1CrossDomainMessenger (implementation)...`
)
// set the pauseowner
const pauseowner = hre.deployConfig.bvmCrossDomainPauseOwner
await contract.setPauseOwner(pauseowner)
console.log(`Checking that contract pause owner was correctly set...`)
await awaitCondition(
async () => {
console.log(contract.getPauseOwner())
console.log(pauseowner)
return hexStringEquals(await contract.getPauseOwner(), pauseowner)
},
5000,
100
)

// Same thing as above, we want to transfer ownership of this contract to the owner of the
// AddressManager. Not technically necessary but seems like the right thing to do.
console.log(
`Transferring ownership of L1CrossDomainMessenger (implementation)...`
)
const owner = hre.deployConfig.bvmAddressManagerOwner
await contract.transferOwnership(owner)

console.log(`Checking that contract owner was correctly set...`)
await awaitCondition(
async () => {
return hexStringEquals(await contract.owner(), owner)
},
5000,
100
)
},
})
}

deployFn.tags = ['L1CrossDomainMessenger', 'upgrade']

export default deployFn
Original file line number Diff line number Diff line change
@@ -1,29 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)

await deployAndVerifyAndThen({
hre,
name: 'Proxy__BVM_L1CrossDomainMessenger',
contract: 'Lib_ResolvedDelegateProxy',
iface: 'L1CrossDomainMessenger',
args: [Lib_AddressManager.address, 'BVM_L1CrossDomainMessenger'],
})
}

// This is kept during an upgrade. So no upgrade tag.
deployFn.tags = ['Proxy__BVM_L1CrossDomainMessenger']

export default deployFn
35 changes: 0 additions & 35 deletions packages/contracts/deploy/008-BVM_StateCommitmentChain.deploy.ts
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import {
deployAndVerifyAndThen,
getContractFromArtifact,
} from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)
const Proxy__BVM_L1CrossDomainMessenger = await getContractFromArtifact(
hre,
names.managed.contracts.Proxy__BVM_L1CrossDomainMessenger
)

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.StateCommitmentChain,
args: [
Lib_AddressManager.address,
Proxy__BVM_L1CrossDomainMessenger.address,
hre.deployConfig.sccFaultProofWindowSeconds,
hre.deployConfig.sccSequencerPublishWindowSeconds,
],
})
}

deployFn.tags = ['StateCommitmentChain', 'upgrade']

export default deployFn
Original file line number Diff line number Diff line change
@@ -1,23 +0,0 @@
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'

/* Imports: Internal */
import { deployAndVerifyAndThen } from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()

await deployAndVerifyAndThen({
hre,
name: names.managed.contracts.Proxy__BVM_L1StandardBridge,
contract: 'L1ChugSplashProxy',
iface: 'L1StandardBridge',
args: [deployer],
})
}

// This is kept during an upgrade. So no upgrade tag.
deployFn.tags = ['Proxy__BVM_L1StandardBridge']

export default deployFn
Loading

0 comments on commit cdf9fb5

Please sign in to comment.