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
ee66a8e2
Unverified
Commit
ee66a8e2
authored
Dec 06, 2022
by
mergify[bot]
Committed by
GitHub
Dec 06, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4257 from ethereum-optimism/sc/ctb-clean-deploy-2
maint(ctb): remove unnecessary deploy utils
parents
61843b80
0e230f24
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
150 deletions
+92
-150
019-SystemDictatorInit.ts
packages/contracts-bedrock/deploy/019-SystemDictatorInit.ts
+91
-4
deploy-utils.ts
packages/contracts-bedrock/src/deploy-utils.ts
+1
-146
No files found.
packages/contracts-bedrock/deploy/019-SystemDictatorInit.ts
View file @
ee66a8e2
import
assert
from
'
assert
'
import
{
ethers
}
from
'
ethers
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
{
awaitCondition
}
from
'
@eth-optimism/core-utils
'
...
...
@@ -5,9 +7,8 @@ import '@eth-optimism/hardhat-deploy-config'
import
'
hardhat-deploy
'
import
{
assertDictatorConfig
,
makeDictatorConfig
,
getContractsFromArtifacts
,
getDeploymentAddress
,
}
from
'
../src/deploy-utils
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
...
...
@@ -73,7 +74,67 @@ const deployFn: DeployFunction = async (hre) => {
])
// Load the dictator configuration.
const
config
=
await
makeDictatorConfig
(
hre
,
controller
,
finalOwner
,
false
)
const
config
=
{
globalConfig
:
{
proxyAdmin
:
await
getDeploymentAddress
(
hre
,
'
ProxyAdmin
'
),
controller
,
finalOwner
,
addressManager
:
await
getDeploymentAddress
(
hre
,
'
Lib_AddressManager
'
),
},
proxyAddressConfig
:
{
l2OutputOracleProxy
:
await
getDeploymentAddress
(
hre
,
'
L2OutputOracleProxy
'
),
optimismPortalProxy
:
await
getDeploymentAddress
(
hre
,
'
OptimismPortalProxy
'
),
l1CrossDomainMessengerProxy
:
await
getDeploymentAddress
(
hre
,
'
Proxy__OVM_L1CrossDomainMessenger
'
),
l1StandardBridgeProxy
:
await
getDeploymentAddress
(
hre
,
'
Proxy__OVM_L1StandardBridge
'
),
optimismMintableERC20FactoryProxy
:
await
getDeploymentAddress
(
hre
,
'
OptimismMintableERC20FactoryProxy
'
),
l1ERC721BridgeProxy
:
await
getDeploymentAddress
(
hre
,
'
L1ERC721BridgeProxy
'
),
systemConfigProxy
:
await
getDeploymentAddress
(
hre
,
'
SystemConfigProxy
'
),
},
implementationAddressConfig
:
{
l2OutputOracleImpl
:
await
getDeploymentAddress
(
hre
,
'
L2OutputOracle
'
),
optimismPortalImpl
:
await
getDeploymentAddress
(
hre
,
'
OptimismPortal
'
),
l1CrossDomainMessengerImpl
:
await
getDeploymentAddress
(
hre
,
'
L1CrossDomainMessenger
'
),
l1StandardBridgeImpl
:
await
getDeploymentAddress
(
hre
,
'
L1StandardBridge
'
),
optimismMintableERC20FactoryImpl
:
await
getDeploymentAddress
(
hre
,
'
OptimismMintableERC20Factory
'
),
l1ERC721BridgeImpl
:
await
getDeploymentAddress
(
hre
,
'
L1ERC721Bridge
'
),
portalSenderImpl
:
await
getDeploymentAddress
(
hre
,
'
PortalSender
'
),
systemConfigImpl
:
await
getDeploymentAddress
(
hre
,
'
SystemConfig
'
),
},
systemConfigConfig
:
{
owner
:
hre
.
deployConfig
.
systemConfigOwner
,
overhead
:
hre
.
deployConfig
.
gasPriceOracleOverhead
,
scalar
:
hre
.
deployConfig
.
gasPriceOracleDecimals
,
batcherHash
:
hre
.
ethers
.
utils
.
hexZeroPad
(
hre
.
deployConfig
.
batchSenderAddress
,
32
),
gasLimit
:
hre
.
deployConfig
.
l2GenesisBlockGasLimit
,
},
}
// Update the implementation if necessary.
if
(
...
...
@@ -103,7 +164,33 @@ const deployFn: DeployFunction = async (hre) => {
)
// Verify that the contract was initialized correctly.
await
assertDictatorConfig
(
SystemDictator
,
config
)
const
dictatorConfig
=
await
SystemDictator
.
config
()
for
(
const
[
outerConfigKey
,
outerConfigValue
]
of
Object
.
entries
(
config
))
{
for
(
const
[
innerConfigKey
,
innerConfigValue
]
of
Object
.
entries
(
outerConfigValue
))
{
let
have
=
dictatorConfig
[
outerConfigKey
][
innerConfigKey
]
let
want
=
innerConfigValue
as
any
if
(
ethers
.
utils
.
isAddress
(
want
))
{
want
=
want
.
toLowerCase
()
have
=
have
.
toLowerCase
()
}
else
if
(
typeof
want
===
'
number
'
)
{
want
=
ethers
.
BigNumber
.
from
(
want
)
have
=
ethers
.
BigNumber
.
from
(
have
)
assert
(
want
.
eq
(
have
),
`incorrect config for
${
outerConfigKey
}
.
${
innerConfigKey
}
. Want:
${
want
}
, have:
${
have
}
`
)
return
}
assert
(
want
===
have
,
`incorrect config for
${
outerConfigKey
}
.
${
innerConfigKey
}
. Want:
${
want
}
, have:
${
have
}
`
)
}
}
}
// Update the owner if necessary.
...
...
packages/contracts-bedrock/src/deploy-utils.ts
View file @
ee66a8e2
...
...
@@ -3,47 +3,12 @@ import assert from 'assert'
import
{
ethers
,
Contract
}
from
'
ethers
'
import
{
Provider
}
from
'
@ethersproject/abstract-provider
'
import
{
Signer
}
from
'
@ethersproject/abstract-signer
'
import
{
sleep
,
getChainId
}
from
'
@eth-optimism/core-utils
'
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
HardhatRuntimeEnvironment
}
from
'
hardhat/types
'
import
'
hardhat-deploy
'
import
'
@eth-optimism/hardhat-deploy-config
'
import
'
@nomiclabs/hardhat-ethers
'
export
interface
DictatorConfig
{
globalConfig
:
{
proxyAdmin
:
string
controller
:
string
finalOwner
:
string
addressManager
:
string
}
proxyAddressConfig
:
{
l2OutputOracleProxy
:
string
optimismPortalProxy
:
string
l1CrossDomainMessengerProxy
:
string
l1StandardBridgeProxy
:
string
optimismMintableERC20FactoryProxy
:
string
l1ERC721BridgeProxy
:
string
systemConfigProxy
:
string
}
implementationAddressConfig
:
{
l2OutputOracleImpl
:
string
optimismPortalImpl
:
string
l1CrossDomainMessengerImpl
:
string
l1StandardBridgeImpl
:
string
optimismMintableERC20FactoryImpl
:
string
l1ERC721BridgeImpl
:
string
portalSenderImpl
:
string
systemConfigImpl
:
string
}
systemConfigConfig
:
{
owner
:
string
overhead
:
number
scalar
:
number
batcherHash
:
string
gasLimit
:
number
}
}
export
const
deployAndVerifyAndThen
=
async
({
hre
,
name
,
...
...
@@ -234,10 +199,6 @@ export const getContractsFromArtifacts = async (
return
contracts
}
export
const
isHardhatNode
=
async
(
hre
)
=>
{
return
(
await
getChainId
(
hre
.
ethers
.
provider
))
===
31337
}
export
const
assertContractVariable
=
async
(
contract
:
ethers
.
Contract
,
variable
:
string
,
...
...
@@ -276,109 +237,3 @@ export const getDeploymentAddress = async (
const
deployment
=
await
hre
.
deployments
.
get
(
name
)
return
deployment
.
address
}
export
const
makeDictatorConfig
=
async
(
hre
:
any
,
controller
:
string
,
finalOwner
:
string
,
fresh
:
boolean
):
Promise
<
DictatorConfig
>
=>
{
return
{
globalConfig
:
{
proxyAdmin
:
await
getDeploymentAddress
(
hre
,
'
ProxyAdmin
'
),
controller
,
finalOwner
,
addressManager
:
fresh
?
ethers
.
constants
.
AddressZero
:
await
getDeploymentAddress
(
hre
,
'
Lib_AddressManager
'
),
},
proxyAddressConfig
:
{
l2OutputOracleProxy
:
await
getDeploymentAddress
(
hre
,
'
L2OutputOracleProxy
'
),
optimismPortalProxy
:
await
getDeploymentAddress
(
hre
,
'
OptimismPortalProxy
'
),
l1CrossDomainMessengerProxy
:
await
getDeploymentAddress
(
hre
,
fresh
?
'
L1CrossDomainMessengerProxy
'
:
'
Proxy__OVM_L1CrossDomainMessenger
'
),
l1StandardBridgeProxy
:
await
getDeploymentAddress
(
hre
,
fresh
?
'
L1StandardBridgeProxy
'
:
'
Proxy__OVM_L1StandardBridge
'
),
optimismMintableERC20FactoryProxy
:
await
getDeploymentAddress
(
hre
,
'
OptimismMintableERC20FactoryProxy
'
),
l1ERC721BridgeProxy
:
await
getDeploymentAddress
(
hre
,
'
L1ERC721BridgeProxy
'
),
systemConfigProxy
:
await
getDeploymentAddress
(
hre
,
'
SystemConfigProxy
'
),
},
implementationAddressConfig
:
{
l2OutputOracleImpl
:
await
getDeploymentAddress
(
hre
,
'
L2OutputOracle
'
),
optimismPortalImpl
:
await
getDeploymentAddress
(
hre
,
'
OptimismPortal
'
),
l1CrossDomainMessengerImpl
:
await
getDeploymentAddress
(
hre
,
'
L1CrossDomainMessenger
'
),
l1StandardBridgeImpl
:
await
getDeploymentAddress
(
hre
,
'
L1StandardBridge
'
),
optimismMintableERC20FactoryImpl
:
await
getDeploymentAddress
(
hre
,
'
OptimismMintableERC20Factory
'
),
l1ERC721BridgeImpl
:
await
getDeploymentAddress
(
hre
,
'
L1ERC721Bridge
'
),
portalSenderImpl
:
await
getDeploymentAddress
(
hre
,
'
PortalSender
'
),
systemConfigImpl
:
await
getDeploymentAddress
(
hre
,
'
SystemConfig
'
),
},
systemConfigConfig
:
{
owner
:
hre
.
deployConfig
.
systemConfigOwner
,
overhead
:
hre
.
deployConfig
.
gasPriceOracleOverhead
,
scalar
:
hre
.
deployConfig
.
gasPriceOracleDecimals
,
batcherHash
:
hre
.
ethers
.
utils
.
hexZeroPad
(
hre
.
deployConfig
.
batchSenderAddress
,
32
),
gasLimit
:
hre
.
deployConfig
.
l2GenesisBlockGasLimit
,
},
}
}
export
const
assertDictatorConfig
=
async
(
dictator
:
Contract
,
config
:
DictatorConfig
)
=>
{
const
dictatorConfig
=
await
dictator
.
config
()
for
(
const
[
outerConfigKey
,
outerConfigValue
]
of
Object
.
entries
(
config
))
{
for
(
const
[
innerConfigKey
,
innerConfigValue
]
of
Object
.
entries
(
outerConfigValue
))
{
let
have
=
dictatorConfig
[
outerConfigKey
][
innerConfigKey
]
let
want
=
innerConfigValue
as
any
if
(
ethers
.
utils
.
isAddress
(
want
))
{
want
=
want
.
toLowerCase
()
have
=
have
.
toLowerCase
()
}
else
if
(
typeof
want
===
'
number
'
)
{
want
=
ethers
.
BigNumber
.
from
(
want
)
have
=
ethers
.
BigNumber
.
from
(
have
)
assert
(
want
.
eq
(
have
),
`incorrect config for
${
outerConfigKey
}
.
${
innerConfigKey
}
. Want:
${
want
}
, have:
${
have
}
`
)
return
}
assert
(
want
===
have
,
`incorrect config for
${
outerConfigKey
}
.
${
innerConfigKey
}
. Want:
${
want
}
, have:
${
have
}
`
)
}
}
}
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