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
ba2aac34
Unverified
Commit
ba2aac34
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): Add deploy step to wait for ownership transfer
parent
3c7d3ace
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
36 deletions
+127
-36
AddressSetter.sol
...ontracts/contracts/libraries/deployment/AddressSetter.sol
+16
-4
071-set-addresses1.ts
packages/contracts/deploy/071-set-addresses1.ts
+54
-3
111-set-addresses2.ts
packages/contracts/deploy/111-set-addresses2.ts
+50
-25
deploy.ts
packages/contracts/tasks/deploy.ts
+7
-4
No files found.
packages/contracts/contracts/libraries/deployment/AddressSetter.sol
View file @
ba2aac34
...
...
@@ -11,10 +11,10 @@ contract AddressSetter {
* Variables *
*************/
Lib_AddressManager manager;
address finalOwner;
string[] names;
address[] addresses;
Lib_AddressManager
public
manager;
address
public
finalOwner;
string[]
public
names;
address[]
public
addresses;
/***************
* Constructor *
...
...
@@ -64,4 +64,16 @@ contract AddressSetter {
function returnOwnership() external {
manager.transferOwnership(finalOwner);
}
/******************
* View Functions *
******************/
function getNames() external view returns (string[] memory) {
return names;
}
function getAddresses() external view returns (address[] memory) {
return addresses;
}
}
packages/contracts/deploy/071-set-addresses1.ts
View file @
ba2aac34
/* Imports: External */
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
/* Imports: Internal */
import
{
getDeployedContract
}
from
'
../src/hardhat-deploy-ethers
'
import
{
getDeployedContract
,
getReusableContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
// todo: add waitUntilTrue, detect when AddressSetter1 has ownership of the AddressManager
await
(
await
getDeployedContract
(
hre
,
'
AddressSetter1
'
)).
setAddresses
()
const
addressSetter1
=
await
getDeployedContract
(
hre
,
'
AddressSetter1
'
)
const
libAddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
names
=
await
addressSetter1
.
getNames
()
const
addresses
=
await
addressSetter1
.
getAddresses
()
const
finalOwner
=
await
addressSetter1
.
finalOwner
()
console
.
log
(
'
\n
'
,
'
An Address Setter contract has been deployed, with the following address <=> name pairs:
'
)
for
(
let
i
=
0
;
i
<
names
.
length
;
i
++
)
{
console
.
log
(
`
${
addresses
[
i
]}
<=>
${
names
[
i
]}
`
)
}
console
.
log
(
'
\n
'
,
'
Please verify the values above, and the deployment steps up to this point,
'
)
console
.
log
(
` then transfer ownership of the Address Manager at (
${
libAddressManager
.
address
}
)`
)
console
.
log
(
` to the Address Setter contract at
${
addressSetter1
.
address
}
.`
)
await
waitUntilTrue
(
async
()
=>
{
console
.
log
(
'
Checking ownership of Lib_AddressManager
'
)
return
hexStringEquals
(
await
libAddressManager
.
owner
(),
addressSetter1
.
address
)
},
{
// Try every 30 seconds for 500 minutes.
delay
:
30
_000
,
retries
:
1000
,
}
)
// Set the addresses!
await
addressSetter1
.
setAddresses
()
const
currentOwner
=
await
libAddressManager
.
owner
()
console
.
log
(
'
Verifying final ownership of Lib_AddressManager
'
)
if
(
!
hexStringEquals
(
finalOwner
,
currentOwner
))
{
// todo: pause here get user input deciding whether to continue or exit?
console
.
log
(
`The current address manager owner
${
currentOwner
}
, \nis not equal to the expected owner:
${
finalOwner
}
`
)
}
}
deployFn
.
tags
=
[
'
set-addresses
'
,
'
upgrade
'
]
...
...
packages/contracts/deploy/111-set-addresses2.ts
View file @
ba2aac34
/* Imports: External */
import
{
hexStringEquals
}
from
'
@eth-optimism/core-utils
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
/* Imports: Internal */
import
{
registerAddress
,
getDeployedContract
,
getReusableContract
,
waitUntilTrue
,
}
from
'
../src/hardhat-deploy-ethers
'
import
{
predeploys
}
from
'
../src/predeploys
'
// todo: reduce redundancy between this and 071
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
// 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.
// OVM_Sequencer is the address allowed to submit "Sequencer" blocks to the
// CanonicalTransactionChain.
// OVM_Proposer is the address allowed to submit state roots (transaction results) to the
// StateCommitmentChain.
const
names
=
[
'
ChainStorageContainer-CTC-batches
'
,
'
ChainStorageContainer-SCC-batches
'
,
'
CanonicalTransactionChain
'
,
'
StateCommitmentChain
'
,
'
BondManager
'
,
'
OVM_L1CrossDomainMessenger
'
,
'
Proxy__L1CrossDomainMessenger
'
,
'
Proxy__L1StandardBridge
'
,
]
await
Promise
.
all
(
names
.
map
(
async
(
name
)
=>
{
const
address
=
(
await
getDeployedContract
(
hre
,
name
)).
address
await
registerAddress
({
hre
,
name
,
address
})
})
const
addressSetter2
=
await
getDeployedContract
(
hre
,
'
AddressSetter2
'
)
const
libAddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
names
=
await
addressSetter2
.
getNames
()
const
addresses
=
await
addressSetter2
.
getAddresses
()
const
finalOwner
=
await
addressSetter2
.
finalOwner
()
console
.
log
(
'
An Address Setter contract has been deployed, with the following address <=> name pairs:
'
)
for
(
let
i
=
0
;
i
<
names
.
length
;
i
++
)
{
console
.
log
(
`
${
addresses
[
i
]}
<=>
${
names
[
i
]}
`
)
}
console
.
log
(
'
\n
'
,
'
Please verify the values above, and the deployment steps up to this point,
'
)
console
.
log
(
` then transfer ownership of the Address Manager at (
${
libAddressManager
.
address
}
)`
)
console
.
log
(
` to the Address Setter contract at
${
addressSetter2
.
address
}
.`
)
await
waitUntilTrue
(
async
()
=>
{
console
.
log
(
'
Checking ownership of Lib_AddressManager
'
)
return
hexStringEquals
(
await
libAddressManager
.
owner
(),
addressSetter2
.
address
)
},
{
// Try every 30 seconds for 500 minutes.
delay
:
30
_000
,
retries
:
1000
,
}
)
// Set the addresses!
await
addressSetter2
.
setAddresses
()
const
currentOwner
=
await
libAddressManager
.
owner
()
console
.
log
(
'
Verifying final ownership of Lib_AddressManager
'
)
if
(
!
hexStringEquals
(
finalOwner
,
currentOwner
))
{
// todo: pause here get user input deciding whether to continue or exit?
console
.
log
(
`The current address manager owner
${
currentOwner
}
, \nis not equal to the expected owner:
${
finalOwner
}
`
)
}
}
deployFn
.
tags
=
[
'
set-addresses
'
,
'
upgrade
'
]
...
...
packages/contracts/tasks/deploy.ts
View file @
ba2aac34
...
...
@@ -118,16 +118,19 @@ task('deploy')
validateAddressArg
(
'
ovmProposerAddress
'
)
validateAddressArg
(
'
ovmAddressManagerOwner
'
)
// validate potentially conflicting arguments
// Validate potentially conflicting arguments
// When are argName is provided, it indicates an address that will be reused in this deployment.
// When a tagName is provided, it indicates that a new contract will be deployed.
const
validateArgOrTag
=
(
argName
:
string
,
tagName
:
string
)
=>
{
// ensure that both an arg and tag were not provided for a given contract
const
hasTag
=
args
.
tags
.
includes
(
tagName
)
// The 'fresh' tag tells us that a new copy of each contract will be deployed.
const
hasTag
=
args
.
tags
.
includes
(
'
fresh
'
)
||
args
.
tags
.
includes
(
tagName
)
// Ensure that an arg and tag were NOT BOTH provided for a given contract
if
(
hasTag
&&
ethers
.
utils
.
isAddress
(
args
[
argName
]))
{
throw
new
Error
(
`cannot deploy a new
${
tagName
}
if the address of an existing one is provided`
)
}
//
ensure that either a valid address is provided or we'll
deploy a new one.
//
Ensure that either a valid address is provided OR that we
deploy a new one.
try
{
validateAddressArg
(
argName
)
console
.
log
(
...
...
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