Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
586161ae
Unverified
Commit
586161ae
authored
Oct 21, 2021
by
Maurelian
Committed by
Kelvin Fichter
Nov 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(contracts): Replace getLibAddressManager with getReusableContract
parent
2369af74
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
163 additions
and
33 deletions
+163
-33
001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
...eploy/001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
+2
-2
002-OVM_ChainStorageContainer_scc_batches.deploy.ts
...eploy/002-OVM_ChainStorageContainer_scc_batches.deploy.ts
+2
-2
003-OVM_CanonicalTransactionChain.deploy.ts
...tracts/deploy/003-OVM_CanonicalTransactionChain.deploy.ts
+2
-2
004-OVM_StateCommitmentChain.deploy.ts
...s/contracts/deploy/004-OVM_StateCommitmentChain.deploy.ts
+2
-2
005-OVM_BondManager.deploy.ts
packages/contracts/deploy/005-OVM_BondManager.deploy.ts
+2
-2
006-OVM_L1CrossDomainMessenger.deploy.ts
...contracts/deploy/006-OVM_L1CrossDomainMessenger.deploy.ts
+5
-3
007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
...ts/deploy/007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
+5
-3
009-OVM_L1StandardBridge.deploy.ts
packages/contracts/deploy/009-OVM_L1StandardBridge.deploy.ts
+6
-3
010-AddressSetter.deploy.ts
packages/contracts/deploy/010-AddressSetter.deploy.ts
+2
-2
090-OVM_L1StandardBridge.deploy.ts
packages/contracts/deploy/090-OVM_L1StandardBridge.deploy.ts
+135
-0
hardhat-deploy-ethers.ts
packages/contracts/src/hardhat-deploy-ethers.ts
+0
-12
No files found.
packages/contracts/deploy/001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
View file @
586161ae
...
...
@@ -5,11 +5,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
deployAndPostDeploy
,
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
get
ReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/002-OVM_ChainStorageContainer_scc_batches.deploy.ts
View file @
586161ae
...
...
@@ -5,11 +5,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
deployAndPostDeploy
,
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
get
ReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/003-OVM_CanonicalTransactionChain.deploy.ts
View file @
586161ae
...
...
@@ -5,11 +5,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
deployAndPostDeploy
,
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
get
ReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/004-OVM_StateCommitmentChain.deploy.ts
View file @
586161ae
...
...
@@ -5,11 +5,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
deployAndPostDeploy
,
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
get
ReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/005-OVM_BondManager.deploy.ts
View file @
586161ae
...
...
@@ -5,11 +5,11 @@ import { DeployFunction } from 'hardhat-deploy/dist/types'
import
{
deployAndPostDeploy
,
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
get
ReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/006-OVM_L1CrossDomainMessenger.deploy.ts
View file @
586161ae
...
...
@@ -5,13 +5,15 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LibAddressManager
,
get
ReusableContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
// todo: this implementation needs to also have a chugsplash proxy in front of it.
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getLibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
View file @
586161ae
...
...
@@ -5,13 +5,15 @@ import { hexStringEquals } from '@eth-optimism/core-utils'
/* Imports: Internal */
import
{
deployAndPostDeploy
,
get
LibAddressManager
,
get
ReusableContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
// We need to skip this step, because we're keeping the existing proxy.
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getLibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/009-OVM_L1StandardBridge.deploy.ts
View file @
586161ae
...
...
@@ -11,7 +11,7 @@ import {
}
from
'
../src/contract-defs
'
import
{
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
waitUntilTrue
,
getAdvancedContract
,
deployAndRegister
,
...
...
@@ -19,10 +19,13 @@ import {
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
const
Lib_AddressManager
=
await
getLibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
// Set up a reference to the proxy as if it were the L1StandardBridge contract.
const
contract
=
await
get
Deployed
Contract
(
const
contract
=
await
get
Reusable
Contract
(
hre
,
'
Proxy__OVM_L1StandardBridge
'
,
{
...
...
packages/contracts/deploy/010-AddressSetter.deploy.ts
View file @
586161ae
...
...
@@ -5,11 +5,11 @@ import { DeployFunction, DeploymentsExtension } from 'hardhat-deploy/dist/types'
import
{
deployAndPostDeploy
,
getDeployedContract
,
get
LibAddressManager
,
get
ReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
get
LibAddressManager
(
hre
)
const
Lib_AddressManager
=
await
get
ReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
names
=
[
'
ChainStorageContainer-CTC-batches
'
,
...
...
packages/contracts/deploy/090-OVM_L1StandardBridge.deploy.ts
0 → 100644
View file @
586161ae
/* Imports: External */
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
{
ethers
}
from
'
ethers
'
import
{
hexStringEquals
,
sleep
}
from
'
@eth-optimism/core-utils
'
/* Imports: Internal */
import
{
predeploys
}
from
'
../src/predeploys
'
import
{
getContractInterface
,
getContractDefinition
,
}
from
'
../src/contract-defs
'
import
{
getLiveContract
,
waitUntilTrue
,
getAdvancedContract
,
deployAndPostDeploy
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
{
deployer
}
=
await
hre
.
getNamedAccounts
()
const
Lib_AddressManager
=
await
getLiveContract
(
hre
,
'
Lib_AddressManager
'
)
// Set up a reference to the proxy as if it were the L1StandardBridge contract.
const
contract
=
await
getLiveContract
(
hre
,
'
Proxy__OVM_L1StandardBridge
'
,
{
iface
:
'
L1StandardBridge
'
,
signerOrProvider
:
deployer
,
})
// Because of the `iface` parameter supplied to the deployment function above, the `contract`
// variable that we here will have the interface of the L1StandardBridge contract. However,
// we also need to interact with the contract as if it were a L1ChugSplashProxy contract so
// we instantiate a new ethers.Contract object with the same address and signer but with the
// L1ChugSplashProxy interface.
const
proxy
=
getAdvancedContract
({
hre
,
contract
:
new
ethers
.
Contract
(
contract
.
address
,
getContractInterface
(
'
L1ChugSplashProxy
'
),
contract
.
signer
),
})
// First we need to set the correct implementation code. We'll set the code and then check
// that the code was indeed correctly set.
const
bridgeArtifact
=
getContractDefinition
(
'
L1StandardBridge
'
)
const
bridgeCode
=
bridgeArtifact
.
deployedBytecode
console
.
log
(
`Setting bridge code...`
)
await
proxy
.
setCode
(
bridgeCode
)
console
.
log
(
`Confirming that bridge code is correct...`
)
await
waitUntilTrue
(
async
()
=>
{
const
implementation
=
await
proxy
.
callStatic
.
getImplementation
()
return
(
!
hexStringEquals
(
implementation
,
ethers
.
constants
.
AddressZero
)
&&
hexStringEquals
(
await
contract
.
provider
.
getCode
(
implementation
),
bridgeCode
)
)
})
// Next we need to set the `messenger` address by executing a setStorage operation. We'll
// check that this operation was correctly executed by calling `messenger()` and checking
// that the result matches the value we initialized.
const
l1CrossDomainMessengerAddress
=
await
Lib_AddressManager
.
getAddress
(
'
Proxy__OVM_L1CrossDomainMessenger
'
)
// Critical error, should never happen.
if
(
hexStringEquals
(
l1CrossDomainMessengerAddress
,
ethers
.
constants
.
AddressZero
)
)
{
throw
new
Error
(
`L1CrossDomainMessenger address is set to address(0)`
)
}
console
.
log
(
`Setting messenger address to
${
l1CrossDomainMessengerAddress
}
...`
)
await
proxy
.
setStorage
(
ethers
.
utils
.
hexZeroPad
(
'
0x00
'
,
32
),
ethers
.
utils
.
hexZeroPad
(
l1CrossDomainMessengerAddress
,
32
)
)
console
.
log
(
`Confirming that messenger address was correctly set...`
)
await
waitUntilTrue
(
async
()
=>
{
return
hexStringEquals
(
await
contract
.
messenger
(),
l1CrossDomainMessengerAddress
)
})
// Now we set the bridge address in the same manner as the messenger address.
console
.
log
(
`Setting l2 bridge address to
${
predeploys
.
L2StandardBridge
}
...`
)
await
proxy
.
setStorage
(
ethers
.
utils
.
hexZeroPad
(
'
0x01
'
,
32
),
ethers
.
utils
.
hexZeroPad
(
predeploys
.
L2StandardBridge
,
32
)
)
console
.
log
(
`Confirming that l2 bridge address was correctly set...`
)
await
waitUntilTrue
(
async
()
=>
{
return
hexStringEquals
(
await
contract
.
l2TokenBridge
(),
predeploys
.
L2StandardBridge
)
})
// Finally we transfer ownership of the proxy to the ovmAddressManagerOwner address.
const
owner
=
(
hre
as
any
).
deployConfig
.
ovmAddressManagerOwner
console
.
log
(
`Setting owner address to
${
owner
}
...`
)
await
proxy
.
setOwner
(
owner
)
console
.
log
(
`Confirming that owner address was correctly set...`
)
await
waitUntilTrue
(
async
()
=>
{
return
hexStringEquals
(
await
proxy
.
connect
(
proxy
.
signer
.
provider
).
callStatic
.
getOwner
({
from
:
ethers
.
constants
.
AddressZero
,
}),
owner
)
})
// Deploy a copy of the implementation so it can be successfully verified on Etherscan.
console
.
log
(
`Deploying a copy of the bridge for Etherscan verification...`
)
await
deployAndPostDeploy
({
hre
,
name
:
'
L1StandardBridge_for_verification_only
'
,
contract
:
'
L1StandardBridge
'
,
args
:
[],
})
}
deployFn
.
tags
=
[
'
fresh
'
,
'
upgrade
'
,
'
L1StandardBridge
'
]
export
default
deployFn
packages/contracts/src/hardhat-deploy-ethers.ts
View file @
586161ae
...
...
@@ -248,15 +248,3 @@ export const getContractFromArtifact = async (
// Large balance to fund accounts with.
export
const
BIG_BALANCE
=
ethers
.
BigNumber
.
from
(
`0xFFFFFFFFFFFFFFFFFFFF`
)
export
const
getLibAddressManager
=
async
(
hre
:
any
):
Promise
<
Contract
>
=>
{
const
factory
=
await
hre
.
ethers
.
getContractFactory
(
'
Lib_AddressManager
'
)
const
iface
=
factory
.
interface
// try to get the address from the config options
const
addr
=
(
hre
as
any
).
deployConfig
.
libAddressManager
if
(
hre
.
ethers
.
utils
.
isAddress
(
addr
))
{
return
new
Contract
(
addr
,
iface
)
}
else
{
// if an address was not provided, a new manager must have been deployed
return
getDeployedContract
(
hre
,
'
Lib_AddressManager
'
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment