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
4c09d293
Commit
4c09d293
authored
Dec 02, 2022
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-migrate: automatically create op-node config
parent
0be4c1c3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
6 deletions
+34
-6
main.go
op-chain-ops/cmd/op-migrate/main.go
+29
-1
config.go
op-chain-ops/genesis/config.go
+3
-3
cmd.go
op-node/cmd/genesis/cmd.go
+2
-2
No files found.
op-chain-ops/cmd/op-migrate/main.go
View file @
4c09d293
...
@@ -2,6 +2,7 @@ package main
...
@@ -2,6 +2,7 @@ package main
import
(
import
(
"context"
"context"
"encoding/json"
"math/big"
"math/big"
"os"
"os"
"path/filepath"
"path/filepath"
...
@@ -90,6 +91,11 @@ func main() {
...
@@ -90,6 +91,11 @@ func main() {
Usage
:
"LevelDB number of handles"
,
Usage
:
"LevelDB number of handles"
,
Value
:
60
,
Value
:
60
,
},
},
cli
.
StringFlag
{
Name
:
"rollup-config-out"
,
Usage
:
"Path that op-node config will be written to disk"
,
Value
:
"rollup.json"
,
},
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
deployConfig
:=
ctx
.
String
(
"deploy-config"
)
deployConfig
:=
ctx
.
String
(
"deploy-config"
)
...
@@ -171,7 +177,17 @@ func main() {
...
@@ -171,7 +177,17 @@ func main() {
dryRun
:=
ctx
.
Bool
(
"dry-run"
)
dryRun
:=
ctx
.
Bool
(
"dry-run"
)
noCheck
:=
ctx
.
Bool
(
"no-check"
)
noCheck
:=
ctx
.
Bool
(
"no-check"
)
if
_
,
err
:=
genesis
.
MigrateDB
(
ldb
,
config
,
block
,
&
migrationData
,
!
dryRun
,
noCheck
);
err
!=
nil
{
res
,
err
:=
genesis
.
MigrateDB
(
ldb
,
config
,
block
,
&
migrationData
,
!
dryRun
,
noCheck
)
if
err
!=
nil
{
return
err
}
opNodeConfig
,
err
:=
config
.
RollupConfig
(
block
,
res
.
TransitionBlockHash
)
if
err
!=
nil
{
return
err
}
if
err
:=
writeJSON
(
ctx
.
String
(
"rollup-config-out"
),
opNodeConfig
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -183,3 +199,15 @@ func main() {
...
@@ -183,3 +199,15 @@ func main() {
log
.
Crit
(
"error in migration"
,
"err"
,
err
)
log
.
Crit
(
"error in migration"
,
"err"
,
err
)
}
}
}
}
func
writeJSON
(
outfile
string
,
input
interface
{})
error
{
f
,
err
:=
os
.
OpenFile
(
outfile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0
o755
)
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
enc
:=
json
.
NewEncoder
(
f
)
enc
.
SetIndent
(
""
,
" "
)
return
enc
.
Encode
(
input
)
}
op-chain-ops/genesis/config.go
View file @
4c09d293
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/rpc"
...
@@ -270,8 +269,9 @@ func (d *DeployConfig) InitDeveloperDeployedAddresses() error {
...
@@ -270,8 +269,9 @@ func (d *DeployConfig) InitDeveloperDeployedAddresses() error {
return
nil
return
nil
}
}
// TODO: convert the input to this function
// RollupConfig converts a DeployConfig to a rollup.Config
// RollupConfig converts a DeployConfig to a rollup.Config
func
(
d
*
DeployConfig
)
RollupConfig
(
l1StartBlock
*
types
.
Block
,
l2Genesis
*
core
.
Genesis
)
(
*
rollup
.
Config
,
error
)
{
func
(
d
*
DeployConfig
)
RollupConfig
(
l1StartBlock
*
types
.
Block
,
l2Genesis
BlockHash
common
.
Hash
)
(
*
rollup
.
Config
,
error
)
{
if
d
.
OptimismPortalProxy
==
(
common
.
Address
{})
{
if
d
.
OptimismPortalProxy
==
(
common
.
Address
{})
{
return
nil
,
errors
.
New
(
"OptimismPortalProxy cannot be address(0)"
)
return
nil
,
errors
.
New
(
"OptimismPortalProxy cannot be address(0)"
)
}
}
...
@@ -286,7 +286,7 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2Genesis *core.G
...
@@ -286,7 +286,7 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2Genesis *core.G
Number
:
l1StartBlock
.
NumberU64
(),
Number
:
l1StartBlock
.
NumberU64
(),
},
},
L2
:
eth
.
BlockID
{
L2
:
eth
.
BlockID
{
Hash
:
l2Genesis
.
ToBlock
()
.
Hash
()
,
Hash
:
l2Genesis
BlockHash
,
Number
:
0
,
Number
:
0
,
},
},
L2Time
:
l1StartBlock
.
Time
(),
L2Time
:
l1StartBlock
.
Time
(),
...
...
op-node/cmd/genesis/cmd.go
View file @
4c09d293
...
@@ -67,7 +67,7 @@ var Subcommands = cli.Commands{
...
@@ -67,7 +67,7 @@ var Subcommands = cli.Commands{
return
err
return
err
}
}
rollupConfig
,
err
:=
config
.
RollupConfig
(
l1StartBlock
,
l2Genesis
)
rollupConfig
,
err
:=
config
.
RollupConfig
(
l1StartBlock
,
l2Genesis
.
ToBlock
()
.
Hash
()
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -155,7 +155,7 @@ var Subcommands = cli.Commands{
...
@@ -155,7 +155,7 @@ var Subcommands = cli.Commands{
return
fmt
.
Errorf
(
"error creating l2 developer genesis: %w"
,
err
)
return
fmt
.
Errorf
(
"error creating l2 developer genesis: %w"
,
err
)
}
}
rollupConfig
,
err
:=
config
.
RollupConfig
(
l1StartBlock
,
l2Genesis
)
rollupConfig
,
err
:=
config
.
RollupConfig
(
l1StartBlock
,
l2Genesis
.
ToBlock
()
.
Hash
()
)
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