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
e5f73140
Unverified
Commit
e5f73140
authored
Nov 11, 2022
by
mergify[bot]
Committed by
GitHub
Nov 11, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3927 from ethereum-optimism/chain-ops/logging
op-chain-ops: add logging to db migration
parents
1bfe79f2
3698b7e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
1 deletion
+17
-1
migrate.go
op-chain-ops/crossdomain/migrate.go
+3
-1
migrate.go
op-chain-ops/ether/migrate.go
+1
-0
db_migration.go
op-chain-ops/genesis/db_migration.go
+7
-0
setters.go
op-chain-ops/genesis/setters.go
+6
-0
No files found.
op-chain-ops/crossdomain/migrate.go
View file @
e5f73140
...
...
@@ -10,6 +10,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
)
var
(
...
...
@@ -19,7 +20,7 @@ var (
// MigrateWithdrawals will migrate a list of pending withdrawals given a StateDB.
func
MigrateWithdrawals
(
withdrawals
[]
*
LegacyWithdrawal
,
db
vm
.
StateDB
,
l1CrossDomainMessenger
,
l1StandardBridge
*
common
.
Address
)
error
{
for
_
,
legacy
:=
range
withdrawals
{
for
i
,
legacy
:=
range
withdrawals
{
legacySlot
,
err
:=
legacy
.
StorageSlot
()
if
err
!=
nil
{
return
err
...
...
@@ -46,6 +47,7 @@ func MigrateWithdrawals(withdrawals []*LegacyWithdrawal, db vm.StateDB, l1CrossD
}
db
.
SetState
(
predeploys
.
L2ToL1MessagePasserAddr
,
slot
,
abiTrue
)
log
.
Info
(
"Migrated withdrawal"
,
"number"
,
i
,
"slot"
,
slot
)
}
return
nil
}
...
...
op-chain-ops/ether/migrate.go
View file @
e5f73140
...
...
@@ -218,6 +218,7 @@ func MigrateLegacyETH(db ethdb.Database, addresses []common.Address, allowances
// Set the total supply to 0
stateDB
.
SetState
(
predeploys
.
LegacyERC20ETHAddr
,
getOVMETHTotalSupplySlot
(),
common
.
Hash
{})
log
.
Info
(
"Set the totalSupply to 0"
)
if
!
commit
{
log
.
Info
(
"dry run, skipping commit"
)
...
...
op-chain-ops/genesis/db_migration.go
View file @
e5f73140
...
...
@@ -17,6 +17,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
)
...
...
@@ -80,13 +81,18 @@ 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
,
&
config
.
L1StandardBridgeProxy
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot migrate withdrawals: %w"
,
err
)
}
log
.
Info
(
"Completed withdrawal migration"
)
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
)
}
...
...
@@ -120,6 +126,7 @@ func MigrateDB(ldb ethdb.Database, config *DeployConfig, l1Block *types.Block, m
}
if
!
commit
{
log
.
Info
(
"Dry run complete"
)
return
res
,
nil
}
...
...
op-chain-ops/genesis/setters.go
View file @
e5f73140
...
...
@@ -11,6 +11,7 @@ import (
"github.com/ethereum-optimism/optimism/op-chain-ops/state"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
)
// FundDevAccounts will fund each of the development accounts.
...
...
@@ -51,12 +52,14 @@ func setProxies(db vm.StateDB, proxyAdminAddr common.Address, namespace *big.Int
// the proxy admin address. LegacyERC20ETH lives in the
// 0xDead namespace so it can be ignored here
if
addr
==
predeploys
.
GovernanceTokenAddr
||
addr
==
predeploys
.
ProxyAdminAddr
{
log
.
Info
(
"Skipping setting proxy"
,
"address"
,
addr
)
continue
}
db
.
CreateAccount
(
addr
)
db
.
SetCode
(
addr
,
depBytecode
)
db
.
SetState
(
addr
,
AdminSlot
,
proxyAdminAddr
.
Hash
())
log
.
Trace
(
"Set proxy"
,
"address"
,
addr
,
"admin"
,
proxyAdminAddr
)
}
return
nil
}
...
...
@@ -96,17 +99,20 @@ func SetImplementations(db vm.StateDB, storage state.StorageConfig, immutable im
// Use the genrated bytecode when there are immutables
// otherwise use the artifact deployed bytecode
if
bytecode
,
ok
:=
deployResults
[
name
];
ok
{
log
.
Info
(
"Setting deployed bytecode with immutables"
,
"name"
,
name
,
"address"
,
addr
)
db
.
SetCode
(
addr
,
bytecode
)
}
else
{
depBytecode
,
err
:=
bindings
.
GetDeployedBytecode
(
name
)
if
err
!=
nil
{
return
err
}
log
.
Info
(
"Setting deployed bytecode from solc compiler output"
,
"name"
,
name
,
"address"
,
addr
)
db
.
SetCode
(
addr
,
depBytecode
)
}
// Set the storage values
if
storageConfig
,
ok
:=
storage
[
name
];
ok
{
log
.
Info
(
"Setting storage"
,
"name"
,
name
,
"address"
,
*
address
)
if
err
:=
state
.
SetStorage
(
name
,
*
address
,
storageConfig
,
db
);
err
!=
nil
{
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