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
2a05cc4d
Unverified
Commit
2a05cc4d
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 getReusableContract function
parent
586161ae
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
72 deletions
+62
-72
deploy.ts
packages/contracts/bin/deploy.ts
+1
-0
001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
...eploy/001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
+4
-1
002-OVM_ChainStorageContainer_scc_batches.deploy.ts
...eploy/002-OVM_ChainStorageContainer_scc_batches.deploy.ts
+4
-1
003-OVM_CanonicalTransactionChain.deploy.ts
...tracts/deploy/003-OVM_CanonicalTransactionChain.deploy.ts
+4
-1
004-OVM_StateCommitmentChain.deploy.ts
...s/contracts/deploy/004-OVM_StateCommitmentChain.deploy.ts
+4
-1
005-OVM_BondManager.deploy.ts
packages/contracts/deploy/005-OVM_BondManager.deploy.ts
+4
-1
007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
...ts/deploy/007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
+3
-0
010-AddressSetter.deploy.ts
packages/contracts/deploy/010-AddressSetter.deploy.ts
+16
-3
011-set-addresses.ts
packages/contracts/deploy/011-set-addresses.ts
+22
-1
014-fund-accounts.ts
packages/contracts/deploy/014-fund-accounts.ts
+0
-63
No files found.
packages/contracts/bin/deploy.ts
View file @
2a05cc4d
...
...
@@ -67,6 +67,7 @@ const main = async () => {
ovmAddressManagerOwner
:
deployer
.
address
,
numDeployConfirmations
:
0
,
noCompile
:
process
.
env
.
NO_COMPILE
?
true
:
false
,
tags
:
'
upgrade,Lib_AddressManager,Proxy__L1CrossDomainMessenger,Proxy__L1StandardBridge,deployer-set-addresses
'
,
})
// Stuff below this line is currently required for CI to work properly. We probably want to
...
...
packages/contracts/deploy/001-OVM_ChainStorageContainer_ctc_batches.deploy.ts
View file @
2a05cc4d
...
...
@@ -9,7 +9,10 @@ import {
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/002-OVM_ChainStorageContainer_scc_batches.deploy.ts
View file @
2a05cc4d
...
...
@@ -9,7 +9,10 @@ import {
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/003-OVM_CanonicalTransactionChain.deploy.ts
View file @
2a05cc4d
...
...
@@ -9,7 +9,10 @@ import {
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/004-OVM_StateCommitmentChain.deploy.ts
View file @
2a05cc4d
...
...
@@ -9,7 +9,10 @@ import {
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/005-OVM_BondManager.deploy.ts
View file @
2a05cc4d
...
...
@@ -9,7 +9,10 @@ import {
}
from
'
../src/hardhat-deploy-ethers
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
await
deployAndPostDeploy
({
hre
,
...
...
packages/contracts/deploy/007-Proxy__OVM_L1CrossDomainMessenger.deploy.ts
View file @
2a05cc4d
...
...
@@ -15,6 +15,9 @@ const deployFn: DeployFunction = async (hre) => {
'
Lib_AddressManager
'
)
// todo: this fails when trying to do a fresh deploy, because Lib_ResolvedDelegateProxy
// requires that the implementation has already been set in the Address Manager.
// The revert message is: 'Target address must be initialized'
await
deployAndPostDeploy
({
hre
,
name
:
'
Proxy__OVM_L1CrossDomainMessenger
'
,
...
...
packages/contracts/deploy/010-AddressSetter.deploy.ts
View file @
2a05cc4d
/* Imports: External */
import
{
DeployFunction
,
DeploymentsExtension
}
from
'
hardhat-deploy/dist/types
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
/* Imports: Internal */
import
{
...
...
@@ -7,10 +7,16 @@ import {
getDeployedContract
,
getReusableContract
,
}
from
'
../src/hardhat-deploy-ethers
'
import
{
predeploys
}
from
'
../src/predeploys
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
const
Lib_AddressManager
=
await
getReusableContract
(
hre
,
'
Lib_AddressManager
'
)
// ToDo: Clean up the method of mapping names to addresses esp.
// There's probably a more functional way to generate an object or something.
const
names
=
[
'
ChainStorageContainer-CTC-batches
'
,
'
ChainStorageContainer-SCC-batches
'
,
...
...
@@ -20,7 +26,6 @@ const deployFn: DeployFunction = async (hre) => {
'
OVM_L1CrossDomainMessenger
'
,
'
Proxy__L1CrossDomainMessenger
'
,
'
Proxy__L1StandardBridge
'
,
'
OVM_Proposer
'
,
]
const
addresses
=
await
Promise
.
all
(
...
...
@@ -29,6 +34,14 @@ const deployFn: DeployFunction = async (hre) => {
})
)
// Add non-deployed addresses to the arrays
names
.
push
(
'
L2CrossDomainMessenger
'
)
addresses
.
push
(
predeploys
.
L2CrossDomainMessenger
)
names
.
push
(
'
OVM_Sequencer
'
)
addresses
.
push
((
hre
as
any
).
deployConfig
.
ovmSequencerAddress
)
names
.
push
(
'
OVM_Proposer
'
)
addresses
.
push
((
hre
as
any
).
deployConfig
.
ovmProposerAddress
)
await
deployAndPostDeploy
({
hre
,
name
:
'
AddressSetter
'
,
...
...
packages/contracts/deploy/011-set-addresses.ts
View file @
2a05cc4d
...
...
@@ -2,7 +2,10 @@
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
/* Imports: Internal */
import
{
registerAddress
}
from
'
../src/hardhat-deploy-ethers
'
import
{
registerAddress
,
getDeployedContract
,
}
from
'
../src/hardhat-deploy-ethers
'
import
{
predeploys
}
from
'
../src/predeploys
'
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
...
...
@@ -30,6 +33,24 @@ const deployFn: DeployFunction = async (hre) => {
name
:
'
OVM_Proposer
'
,
address
:
(
hre
as
any
).
deployConfig
.
ovmProposerAddress
,
})
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
})
})
)
}
deployFn
.
tags
=
[
'
set-addresses
'
,
'
upgrade
'
]
...
...
packages/contracts/deploy/014-fund-accounts.ts
deleted
100644 → 0
View file @
586161ae
/* Imports: External */
import
{
sleep
}
from
'
@eth-optimism/core-utils
'
import
{
DeployFunction
}
from
'
hardhat-deploy/dist/types
'
import
{
defaultHardhatNetworkHdAccountsConfigParams
,
defaultHardhatNetworkParams
,
}
from
'
hardhat/internal/core/config/default-config
'
import
{
normalizeHardhatNetworkAccountsConfig
}
from
'
hardhat/internal/core/providers/util
'
/* Imports: Internal */
import
{
getDeployedContract
}
from
'
../src/hardhat-deploy-ethers
'
// This is a TEMPORARY way to fund the default hardhat accounts on L2. The better way to do this is
// to make a modification to hardhat-ovm. However, I don't have the time right now to figure the
// details of how to make that work cleanly. This is fine in the meantime.
const
deployFn
:
DeployFunction
=
async
(
hre
)
=>
{
// Only execute this step if we're on the hardhat chain ID.
const
{
chainId
}
=
await
hre
.
ethers
.
provider
.
getNetwork
()
if
(
chainId
===
defaultHardhatNetworkParams
.
chainId
)
{
const
L1StandardBridge
=
await
getDeployedContract
(
hre
,
'
Proxy__L1StandardBridge
'
,
{
iface
:
'
L1StandardBridge
'
,
}
)
// Default has 20 accounts but we restrict to 20 accounts manually as well just to prevent
// future problems if the number of default accounts increases for whatever reason.
const
accounts
=
normalizeHardhatNetworkAccountsConfig
(
defaultHardhatNetworkHdAccountsConfigParams
).
slice
(
0
,
20
)
// Fund the accounts in parallel to speed things up.
await
Promise
.
all
(
accounts
.
map
(
async
(
account
,
index
)
=>
{
// Add a sleep here to avoid any potential issues with spamming hardhat. Not sure if this
// is strictly necessary but it can't hurt.
await
sleep
(
200
*
index
)
const
wallet
=
new
hre
.
ethers
.
Wallet
(
account
.
privateKey
,
hre
.
ethers
.
provider
)
const
balance
=
await
wallet
.
getBalance
()
const
depositAmount
=
balance
.
div
(
2
)
// Deposit half of the wallet's balance into L2.
await
L1StandardBridge
.
connect
(
wallet
).
depositETH
(
8
_000_000
,
'
0x
'
,
{
value
:
depositAmount
,
gasLimit
:
2
_000_000
,
// Idk, gas estimation was broken and this fixes it.
})
console
.
log
(
`✓ Funded
${
wallet
.
address
}
on L2 with
${
hre
.
ethers
.
utils
.
formatEther
(
depositAmount
)}
ETH`
)
})
)
}
}
deployFn
.
tags
=
[
'
fund-accounts
'
]
export
default
deployFn
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