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
af9a5eed
Unverified
Commit
af9a5eed
authored
Nov 30, 2022
by
mergify[bot]
Committed by
GitHub
Nov 30, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4118 from ethereum-optimism/fix/migrate-cleanup-2
op-chain-ops: more cleanup in migrate script
parents
3694de47
6c825478
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
24 deletions
+27
-24
migrate.go
op-chain-ops/crossdomain/migrate.go
+9
-11
db_migration.go
op-chain-ops/genesis/db_migration.go
+18
-13
No files found.
op-chain-ops/crossdomain/migrate.go
View file @
af9a5eed
package
crossdomain
import
(
"errors"
"fmt"
"math/big"
...
...
@@ -14,25 +15,22 @@ import (
var
(
abiTrue
=
common
.
Hash
{
31
:
0x01
}
//
errLegacyStorageSlotNotFound = errors.New("cannot find storage slot")
errLegacyStorageSlotNotFound
=
errors
.
New
(
"cannot find storage slot"
)
)
// MigrateWithdrawals will migrate a list of pending withdrawals given a StateDB.
func
MigrateWithdrawals
(
withdrawals
[]
*
LegacyWithdrawal
,
db
vm
.
StateDB
,
l1CrossDomainMessenger
*
common
.
Address
)
error
{
func
MigrateWithdrawals
(
withdrawals
[]
*
LegacyWithdrawal
,
db
vm
.
StateDB
,
l1CrossDomainMessenger
*
common
.
Address
,
noCheck
bool
)
error
{
for
i
,
legacy
:=
range
withdrawals
{
legacySlot
,
err
:=
legacy
.
StorageSlot
()
if
err
!=
nil
{
return
err
}
if
!
noCheck
{
legacyValue
:=
db
.
GetState
(
predeploys
.
LegacyMessagePasserAddr
,
legacySlot
)
if
legacyValue
!=
abiTrue
{
// TODO: Re-enable this once we have the exact data we need on mainnet.
// This is disabled because the data file we're using for testing was
// generated after the database dump, which means that there are extra
// storage slots in the state that don't show up in the withdrawals list.
// return fmt.Errorf("%w: %s", errLegacyStorageSlotNotFound, legacySlot)
continue
return
fmt
.
Errorf
(
"%w: %s"
,
errLegacyStorageSlotNotFound
,
legacySlot
)
}
}
withdrawal
,
err
:=
MigrateWithdrawal
(
legacy
,
l1CrossDomainMessenger
)
...
...
op-chain-ops/genesis/db_migration.go
View file @
af9a5eed
package
genesis
import
(
"bytes"
"fmt"
"math/big"
...
...
@@ -19,7 +20,10 @@ import (
"github.com/ethereum/go-ethereum/trie"
)
var
abiTrue
=
common
.
Hash
{
31
:
0x01
}
var
(
abiTrue
=
common
.
Hash
{
31
:
0x01
}
bedrockTransitionBlockExtraData
=
[]
byte
(
"BEDROCK"
)
)
type
MigrationResult
struct
{
TransitionHeight
uint64
...
...
@@ -33,13 +37,15 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
num
:=
rawdb
.
ReadHeaderNumber
(
ldb
,
hash
)
header
:=
rawdb
.
ReadHeader
(
ldb
,
hash
,
*
num
)
// Leaving this commented out so that it can be used to skip
// the DB migration in development.
//return &MigrationResult{
// TransitionHeight: *num,
// TransitionTimestamp: header.Time,
// TransitionBlockHash: hash,
//}, nil
if
bytes
.
Equal
(
header
.
Extra
,
bedrockTransitionBlockExtraData
)
{
log
.
Info
(
"Detected migration already happened"
,
"root"
,
header
.
Root
,
"blockhash"
,
header
.
Hash
())
return
&
MigrationResult
{
TransitionHeight
:
*
num
,
TransitionTimestamp
:
header
.
Time
,
TransitionBlockHash
:
hash
,
},
nil
}
underlyingDB
:=
state
.
NewDatabaseWithConfig
(
ldb
,
&
trie
.
Config
{
Preimages
:
true
,
...
...
@@ -86,8 +92,8 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
return
nil
,
fmt
.
Errorf
(
"cannot set implementations: %w"
,
err
)
}
log
.
Info
(
"Starting to migrate withdrawals"
)
err
=
crossdomain
.
MigrateWithdrawals
(
withdrawals
,
db
,
&
config
.
L1CrossDomainMessengerProxy
)
log
.
Info
(
"Starting to migrate withdrawals"
,
"no-check"
,
noCheck
)
err
=
crossdomain
.
MigrateWithdrawals
(
withdrawals
,
db
,
&
config
.
L1CrossDomainMessengerProxy
,
noCheck
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot migrate withdrawals: %w"
,
err
)
}
...
...
@@ -96,11 +102,10 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
log
.
Info
(
"Starting to migrate ERC20 ETH"
)
addrs
:=
migrationData
.
Addresses
()
newRoot
,
err
:=
ether
.
MigrateLegacyETH
(
ldb
,
addrs
,
migrationData
.
OvmAllowances
,
int
(
config
.
L1ChainID
),
commit
)
log
.
Info
(
"Completed ERC20 ETH migration"
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot migrate legacy eth: %w"
,
err
)
}
log
.
Info
(
"Completed ERC20 ETH migration"
,
"root"
,
newRoot
)
// Create the bedrock transition block
bedrockHeader
:=
&
types
.
Header
{
...
...
@@ -116,7 +121,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
GasLimit
:
(
uint64
)(
config
.
L2GenesisBlockGasLimit
),
GasUsed
:
0
,
Time
:
uint64
(
config
.
L2OutputOracleStartingTimestamp
),
Extra
:
[]
byte
(
"BEDROCK"
)
,
Extra
:
bedrockTransitionBlockExtraData
,
MixDigest
:
common
.
Hash
{},
Nonce
:
types
.
BlockNonce
{},
BaseFee
:
(
*
big
.
Int
)(
config
.
L2GenesisBlockBaseFeePerGas
),
...
...
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