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
baa0e305
Unverified
Commit
baa0e305
authored
Nov 30, 2022
by
mergify[bot]
Committed by
GitHub
Nov 30, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4105 from ethereum-optimism/fix/chain-ops-cleanup
op-chain-ops: various cleanup
parents
c1e7f122
9e02ddbd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
11 deletions
+24
-11
main.go
op-chain-ops/cmd/migrate/main.go
+6
-1
legacy_withdrawal.go
op-chain-ops/crossdomain/legacy_withdrawal.go
+3
-3
db_migration.go
op-chain-ops/genesis/db_migration.go
+13
-6
action.go
op-chain-ops/genesis/migration_action/action.go
+2
-1
No files found.
op-chain-ops/cmd/migrate/main.go
View file @
baa0e305
...
@@ -76,6 +76,10 @@ func main() {
...
@@ -76,6 +76,10 @@ func main() {
Name
:
"dry-run"
,
Name
:
"dry-run"
,
Usage
:
"Dry run the upgrade by not committing the database"
,
Usage
:
"Dry run the upgrade by not committing the database"
,
},
},
cli
.
BoolFlag
{
Name
:
"no-check"
,
Usage
:
"Do not perform sanity checks. This should only be used for testing"
,
},
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
deployConfig
:=
ctx
.
String
(
"deploy-config"
)
deployConfig
:=
ctx
.
String
(
"deploy-config"
)
...
@@ -153,7 +157,8 @@ func main() {
...
@@ -153,7 +157,8 @@ func main() {
}
}
dryRun
:=
ctx
.
Bool
(
"dry-run"
)
dryRun
:=
ctx
.
Bool
(
"dry-run"
)
if
_
,
err
:=
genesis
.
MigrateDB
(
ldb
,
config
,
block
,
&
migrationData
,
!
dryRun
);
err
!=
nil
{
noCheck
:=
ctx
.
Bool
(
"no-check"
)
if
_
,
err
:=
genesis
.
MigrateDB
(
ldb
,
config
,
block
,
&
migrationData
,
!
dryRun
,
noCheck
);
err
!=
nil
{
return
err
return
err
}
}
...
...
op-chain-ops/crossdomain/legacy_withdrawal.go
View file @
baa0e305
...
@@ -40,7 +40,7 @@ func NewLegacyWithdrawal(target, sender *common.Address, data []byte, nonce *big
...
@@ -40,7 +40,7 @@ func NewLegacyWithdrawal(target, sender *common.Address, data []byte, nonce *big
func
(
w
*
LegacyWithdrawal
)
Encode
()
([]
byte
,
error
)
{
func
(
w
*
LegacyWithdrawal
)
Encode
()
([]
byte
,
error
)
{
enc
,
err
:=
EncodeCrossDomainMessageV0
(
w
.
Target
,
w
.
Sender
,
w
.
Data
,
w
.
Nonce
)
enc
,
err
:=
EncodeCrossDomainMessageV0
(
w
.
Target
,
w
.
Sender
,
w
.
Data
,
w
.
Nonce
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
fmt
.
Errorf
(
"cannot encode LegacyWithdrawal: %w"
,
err
)
}
}
out
:=
make
([]
byte
,
len
(
enc
)
+
len
(
predeploys
.
L2CrossDomainMessengerAddr
.
Bytes
()))
out
:=
make
([]
byte
,
len
(
enc
)
+
len
(
predeploys
.
L2CrossDomainMessengerAddr
.
Bytes
()))
...
@@ -108,7 +108,7 @@ func (w *LegacyWithdrawal) Decode(data []byte) error {
...
@@ -108,7 +108,7 @@ func (w *LegacyWithdrawal) Decode(data []byte) error {
func
(
w
*
LegacyWithdrawal
)
Hash
()
(
common
.
Hash
,
error
)
{
func
(
w
*
LegacyWithdrawal
)
Hash
()
(
common
.
Hash
,
error
)
{
encoded
,
err
:=
w
.
Encode
()
encoded
,
err
:=
w
.
Encode
()
if
err
!=
nil
{
if
err
!=
nil
{
return
common
.
Hash
{},
nil
return
common
.
Hash
{},
fmt
.
Errorf
(
"cannot hash LegacyWithdrawal: %w"
,
err
)
}
}
hash
:=
crypto
.
Keccak256
(
encoded
)
hash
:=
crypto
.
Keccak256
(
encoded
)
return
common
.
BytesToHash
(
hash
),
nil
return
common
.
BytesToHash
(
hash
),
nil
...
@@ -119,7 +119,7 @@ func (w *LegacyWithdrawal) Hash() (common.Hash, error) {
...
@@ -119,7 +119,7 @@ func (w *LegacyWithdrawal) Hash() (common.Hash, error) {
func
(
w
*
LegacyWithdrawal
)
StorageSlot
()
(
common
.
Hash
,
error
)
{
func
(
w
*
LegacyWithdrawal
)
StorageSlot
()
(
common
.
Hash
,
error
)
{
hash
,
err
:=
w
.
Hash
()
hash
,
err
:=
w
.
Hash
()
if
err
!=
nil
{
if
err
!=
nil
{
return
common
.
Hash
{},
err
return
common
.
Hash
{},
fmt
.
Errorf
(
"cannot compute storage slot: %w"
,
err
)
}
}
preimage
:=
make
([]
byte
,
64
)
preimage
:=
make
([]
byte
,
64
)
copy
(
preimage
,
hash
.
Bytes
())
copy
(
preimage
,
hash
.
Bytes
())
...
...
op-chain-ops/genesis/db_migration.go
View file @
baa0e305
...
@@ -28,7 +28,7 @@ type MigrationResult struct {
...
@@ -28,7 +28,7 @@ type MigrationResult struct {
}
}
// MigrateDB will migrate an old l2geth database to the new bedrock style system
// MigrateDB will migrate an old l2geth database to the new bedrock style system
func
MigrateDB
(
ldb
ethdb
.
Database
,
config
*
DeployConfig
,
l1Block
*
types
.
Block
,
migrationData
*
migration
.
MigrationData
,
commit
bool
)
(
*
MigrationResult
,
error
)
{
func
MigrateDB
(
ldb
ethdb
.
Database
,
config
*
DeployConfig
,
l1Block
*
types
.
Block
,
migrationData
*
migration
.
MigrationData
,
commit
,
noCheck
bool
)
(
*
MigrationResult
,
error
)
{
hash
:=
rawdb
.
ReadHeadHeaderHash
(
ldb
)
hash
:=
rawdb
.
ReadHeadHeaderHash
(
ldb
)
num
:=
rawdb
.
ReadHeaderNumber
(
ldb
,
hash
)
num
:=
rawdb
.
ReadHeaderNumber
(
ldb
,
hash
)
header
:=
rawdb
.
ReadHeader
(
ldb
,
hash
,
*
num
)
header
:=
rawdb
.
ReadHeader
(
ldb
,
hash
,
*
num
)
...
@@ -56,11 +56,18 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
...
@@ -56,11 +56,18 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
return
nil
,
fmt
.
Errorf
(
"cannot serialize withdrawals: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"cannot serialize withdrawals: %w"
,
err
)
}
}
if
err
:=
CheckWithdrawals
(
db
,
withdrawals
);
err
!=
nil
{
if
!
noCheck
{
return
nil
,
fmt
.
Errorf
(
"withdrawals mismatch: %w"
,
err
)
log
.
Info
(
"Checking withdrawals..."
)
if
err
:=
CheckWithdrawals
(
db
,
withdrawals
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"withdrawals mismatch: %w"
,
err
)
}
log
.
Info
(
"Withdrawals accounted for!"
)
}
else
{
log
.
Info
(
"Skipping checking withdrawals"
)
}
}
// Now start the migration
// Now start the migration
log
.
Info
(
"Setting the Proxies"
)
if
err
:=
SetL2Proxies
(
db
);
err
!=
nil
{
if
err
:=
SetL2Proxies
(
db
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot set L2Proxies: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"cannot set L2Proxies: %w"
,
err
)
}
}
...
@@ -181,7 +188,7 @@ func CheckWithdrawals(db vm.StateDB, withdrawals []*crossdomain.LegacyWithdrawal
...
@@ -181,7 +188,7 @@ func CheckWithdrawals(db vm.StateDB, withdrawals []*crossdomain.LegacyWithdrawal
for
_
,
wd
:=
range
withdrawals
{
for
_
,
wd
:=
range
withdrawals
{
slot
,
err
:=
wd
.
StorageSlot
()
slot
,
err
:=
wd
.
StorageSlot
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"cannot check withdrawals: %w"
,
err
)
}
}
knownSlots
[
slot
]
=
true
knownSlots
[
slot
]
=
true
}
}
...
@@ -195,7 +202,7 @@ func CheckWithdrawals(db vm.StateDB, withdrawals []*crossdomain.LegacyWithdrawal
...
@@ -195,7 +202,7 @@ func CheckWithdrawals(db vm.StateDB, withdrawals []*crossdomain.LegacyWithdrawal
return
true
return
true
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
fmt
.
Errorf
(
"cannot iterate over LegacyMessagePasser: %w"
,
err
)
}
}
// Check that all of the slots from storage correspond to a known message
// Check that all of the slots from storage correspond to a known message
...
@@ -211,7 +218,7 @@ func CheckWithdrawals(db vm.StateDB, withdrawals []*crossdomain.LegacyWithdrawal
...
@@ -211,7 +218,7 @@ func CheckWithdrawals(db vm.StateDB, withdrawals []*crossdomain.LegacyWithdrawal
_
,
ok
:=
slots
[
slot
]
_
,
ok
:=
slots
[
slot
]
//nolint:staticcheck
//nolint:staticcheck
if
!
ok
{
if
!
ok
{
//return nil,
fmt.Errorf("Unknown input message: %s", slot)
return
fmt
.
Errorf
(
"Unknown input message: %s"
,
slot
)
}
}
}
}
...
...
op-chain-ops/genesis/migration_action/action.go
View file @
baa0e305
...
@@ -24,6 +24,7 @@ type Config struct {
...
@@ -24,6 +24,7 @@ type Config struct {
StartingL1BlockNumber
uint64
StartingL1BlockNumber
uint64
L2DBPath
string
L2DBPath
string
DryRun
bool
DryRun
bool
NoCheck
bool
}
}
func
Migrate
(
cfg
*
Config
)
(
*
genesis
.
MigrationResult
,
error
)
{
func
Migrate
(
cfg
*
Config
)
(
*
genesis
.
MigrationResult
,
error
)
{
...
@@ -81,5 +82,5 @@ func Migrate(cfg *Config) (*genesis.MigrationResult, error) {
...
@@ -81,5 +82,5 @@ func Migrate(cfg *Config) (*genesis.MigrationResult, error) {
}
}
defer
ldb
.
Close
()
defer
ldb
.
Close
()
return
genesis
.
MigrateDB
(
ldb
,
deployConfig
,
block
,
&
migrationData
,
!
cfg
.
DryRun
)
return
genesis
.
MigrateDB
(
ldb
,
deployConfig
,
block
,
&
migrationData
,
!
cfg
.
DryRun
,
cfg
.
NoCheck
)
}
}
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