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
8064f0c9
Unverified
Commit
8064f0c9
authored
Oct 03, 2023
by
Sebastian Stammler
Committed by
GitHub
Oct 03, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7511 from ethereum-optimism/fix/op-upgrade-superchain-target
op-upgrade: superchain target
parents
d9b34a58
2aee16b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
main.go
op-chain-ops/cmd/op-upgrade/main.go
+32
-10
No files found.
op-chain-ops/cmd/op-upgrade/main.go
View file @
8064f0c9
...
@@ -2,6 +2,7 @@ package main
...
@@ -2,6 +2,7 @@ package main
import
(
import
(
"encoding/json"
"encoding/json"
"errors"
"fmt"
"fmt"
"os"
"os"
"slices"
"slices"
...
@@ -38,6 +39,11 @@ func main() {
...
@@ -38,6 +39,11 @@ func main() {
Name
:
"chain-ids"
,
Name
:
"chain-ids"
,
Usage
:
"L2 Chain IDs corresponding to chains to upgrade. Corresponds to all chains if empty"
,
Usage
:
"L2 Chain IDs corresponding to chains to upgrade. Corresponds to all chains if empty"
,
},
},
&
cli
.
StringFlag
{
Name
:
"superchain-target"
,
Usage
:
"The name of the superchain to upgrade"
,
EnvVars
:
[]
string
{
"SUPERCHAIN_TARGET"
},
},
&
cli
.
PathFlag
{
&
cli
.
PathFlag
{
Name
:
"deploy-config"
,
Name
:
"deploy-config"
,
Usage
:
"The path to the deploy config file"
,
Usage
:
"The path to the deploy config file"
,
...
@@ -70,9 +76,13 @@ func entrypoint(ctx *cli.Context) error {
...
@@ -70,9 +76,13 @@ func entrypoint(ctx *cli.Context) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
superchainName
,
err
:=
toSuperchainName
(
l1ChainID
.
Uint64
())
if
err
!=
nil
{
superchainName
:=
ctx
.
String
(
"superchain-target"
)
return
err
if
superchainName
==
""
{
superchainName
,
err
=
toSuperchainName
(
l1ChainID
.
Uint64
())
if
err
!=
nil
{
return
err
}
}
}
chainIDs
:=
ctx
.
Uint64Slice
(
"chain-ids"
)
chainIDs
:=
ctx
.
Uint64Slice
(
"chain-ids"
)
...
@@ -116,23 +126,35 @@ func entrypoint(ctx *cli.Context) error {
...
@@ -116,23 +126,35 @@ func entrypoint(ctx *cli.Context) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot create RPC clients: %w"
,
err
)
return
fmt
.
Errorf
(
"cannot create RPC clients: %w"
,
err
)
}
}
// The L1Client is required
if
clients
.
L1Client
==
nil
{
return
errors
.
New
(
"Cannot create L1 client"
)
}
l1ChainID
,
err
:=
clients
.
L1Client
.
ChainID
(
ctx
.
Context
)
l1ChainID
,
err
:=
clients
.
L1Client
.
ChainID
(
ctx
.
Context
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot fetch L1 chain ID: %w"
,
err
)
return
fmt
.
Errorf
(
"cannot fetch L1 chain ID: %w"
,
err
)
}
}
l2ChainID
,
err
:=
clients
.
L2Client
.
ChainID
(
ctx
.
Context
)
if
err
!=
nil
{
// The L2Client is not required, but double check the chain id matches if possible
return
fmt
.
Errorf
(
"cannot fetch L2 chain ID: %w"
,
err
)
if
clients
.
L2Client
!=
nil
{
l2ChainID
,
err
:=
clients
.
L2Client
.
ChainID
(
ctx
.
Context
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot fetch L2 chain ID: %w"
,
err
)
}
if
chainConfig
.
ChainID
!=
l2ChainID
.
Uint64
()
{
return
fmt
.
Errorf
(
"Mismatched chain IDs: %d != %d"
,
chainConfig
.
ChainID
,
l2ChainID
)
}
}
}
log
.
Info
(
chainConfig
.
Name
,
"l1-chain-id"
,
l1ChainID
,
"l2-chain-id"
,
l2ChainID
)
log
.
Info
(
chainConfig
.
Name
,
"l1-chain-id"
,
l1ChainID
,
"l2-chain-id"
,
chainConfig
.
ChainID
)
log
.
Info
(
"Detecting on chain contracts"
)
log
.
Info
(
"Detecting on chain contracts"
)
// Tracking the individual addresses can be deprecated once the system is upgraded
// Tracking the individual addresses can be deprecated once the system is upgraded
// to the new contracts where the system config has a reference to each address.
// to the new contracts where the system config has a reference to each address.
addresses
,
ok
:=
superchain
.
Addresses
[
l2ChainID
.
Uint64
()
]
addresses
,
ok
:=
superchain
.
Addresses
[
chainConfig
.
ChainID
]
if
!
ok
{
if
!
ok
{
return
fmt
.
Errorf
(
"no addresses for chain ID %d"
,
l2ChainID
.
Uint64
()
)
return
fmt
.
Errorf
(
"no addresses for chain ID %d"
,
chainConfig
.
ChainID
)
}
}
versions
,
err
:=
upgrades
.
GetContractVersions
(
ctx
.
Context
,
addresses
,
chainConfig
,
clients
.
L1Client
)
versions
,
err
:=
upgrades
.
GetContractVersions
(
ctx
.
Context
,
addresses
,
chainConfig
,
clients
.
L1Client
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -235,7 +257,7 @@ func toSuperchainName(chainID uint64) (string, error) {
...
@@ -235,7 +257,7 @@ func toSuperchainName(chainID uint64) (string, error) {
}
}
func
writeJSON
(
outfile
string
,
input
interface
{})
error
{
func
writeJSON
(
outfile
string
,
input
interface
{})
error
{
f
,
err
:=
os
.
OpenFile
(
outfile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0
o
755
)
f
,
err
:=
os
.
OpenFile
(
outfile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0
o
666
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
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