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
9ee4f3d7
Unverified
Commit
9ee4f3d7
authored
Dec 08, 2022
by
Matthew Slipper
Committed by
GitHub
Dec 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: Fix validation logic (#4316)
parent
98722d8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
28 deletions
+55
-28
check.go
op-chain-ops/genesis/check.go
+27
-13
db_migration.go
op-chain-ops/genesis/db_migration.go
+2
-1
setters.go
op-chain-ops/genesis/setters.go
+26
-14
No files found.
op-chain-ops/genesis/check.go
View file @
9ee4f3d7
...
@@ -42,10 +42,12 @@ func CheckMigratedDB(ldb ethdb.Database) error {
...
@@ -42,10 +42,12 @@ func CheckMigratedDB(ldb ethdb.Database) error {
if
err
:=
CheckPredeploys
(
db
);
err
!=
nil
{
if
err
:=
CheckPredeploys
(
db
);
err
!=
nil
{
return
err
return
err
}
}
log
.
Info
(
"checked predeploys"
)
if
err
:=
CheckLegacyETH
(
db
);
err
!=
nil
{
if
err
:=
CheckLegacyETH
(
db
);
err
!=
nil
{
return
err
return
err
}
}
log
.
Info
(
"checked legacy eth"
)
return
nil
return
nil
}
}
...
@@ -64,24 +66,36 @@ func CheckPredeploys(db vm.StateDB) error {
...
@@ -64,24 +66,36 @@ func CheckPredeploys(db vm.StateDB) error {
return
fmt
.
Errorf
(
"no code found at predeploy %s"
,
addr
)
return
fmt
.
Errorf
(
"no code found at predeploy %s"
,
addr
)
}
}
// There must be an implementation
impl
:=
db
.
GetState
(
addr
,
ImplementationSlot
)
implAddr
:=
common
.
BytesToAddress
(
impl
.
Bytes
())
if
implAddr
==
(
common
.
Address
{})
{
return
fmt
.
Errorf
(
"no implementation for %s"
,
addr
)
}
implCode
:=
db
.
GetCode
(
implAddr
)
if
len
(
implCode
)
==
0
{
return
fmt
.
Errorf
(
"no code found at predeploy impl %s"
,
addr
)
}
// There must be an admin
// There must be an admin
admin
:=
db
.
GetState
(
addr
,
AdminSlot
)
admin
:=
db
.
GetState
(
addr
,
AdminSlot
)
adminAddr
:=
common
.
BytesToAddress
(
admin
.
Bytes
())
adminAddr
:=
common
.
BytesToAddress
(
admin
.
Bytes
())
if
adminAddr
!=
predeploys
.
ProxyAdminAddr
{
if
ad
dr
!=
predeploys
.
ProxyAdminAddr
&&
addr
!=
predeploys
.
GovernanceTokenAddr
&&
ad
minAddr
!=
predeploys
.
ProxyAdminAddr
{
return
fmt
.
Errorf
(
"admin is %s when it should be % for %s"
,
adminAddr
,
predeploys
.
ProxyAdminAddr
,
addr
)
return
fmt
.
Errorf
(
"admin is %s when it should be %
s
for %s"
,
adminAddr
,
predeploys
.
ProxyAdminAddr
,
addr
)
}
}
}
}
// For each predeploy, check that we've set the implementation correctly when
// necessary and that there's code at the implementation.
for
_
,
proxyAddr
:=
range
predeploys
.
Predeploys
{
implAddr
,
special
,
err
:=
mapImplementationAddress
(
proxyAddr
)
if
err
!=
nil
{
return
err
}
if
!
special
{
impl
:=
db
.
GetState
(
*
proxyAddr
,
ImplementationSlot
)
implAddr
:=
common
.
BytesToAddress
(
impl
.
Bytes
())
if
implAddr
==
(
common
.
Address
{})
{
return
fmt
.
Errorf
(
"no implementation for %s"
,
*
proxyAddr
)
}
}
implCode
:=
db
.
GetCode
(
implAddr
)
if
len
(
implCode
)
==
0
{
return
fmt
.
Errorf
(
"no code found at predeploy impl %s"
,
*
proxyAddr
)
}
}
return
nil
return
nil
}
}
...
...
op-chain-ops/genesis/db_migration.go
View file @
9ee4f3d7
...
@@ -5,9 +5,10 @@ import (
...
@@ -5,9 +5,10 @@ import (
"fmt"
"fmt"
"math/big"
"math/big"
"github.com/ethereum-optimism/optimism/op-chain-ops/ether"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
"github.com/ethereum-optimism/optimism/op-chain-ops/ether"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis/migration"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis/migration"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
...
...
op-chain-ops/genesis/setters.go
View file @
9ee4f3d7
...
@@ -76,20 +76,12 @@ func SetImplementations(db vm.StateDB, storage state.StorageConfig, immutable im
...
@@ -76,20 +76,12 @@ func SetImplementations(db vm.StateDB, storage state.StorageConfig, immutable im
for
name
,
address
:=
range
predeploys
.
Predeploys
{
for
name
,
address
:=
range
predeploys
.
Predeploys
{
// Convert the address to the code address unless it is
// Convert the address to the code address unless it is
// designed to not be behind a proxy
// designed to not be behind a proxy
var
addr
common
.
Address
addr
,
special
,
err
:=
mapImplementationAddress
(
address
)
switch
*
address
{
if
err
!=
nil
{
case
predeploys
.
GovernanceTokenAddr
:
return
err
addr
=
predeploys
.
GovernanceTokenAddr
}
case
predeploys
.
LegacyERC20ETHAddr
:
addr
=
predeploys
.
LegacyERC20ETHAddr
if
!
special
{
case
predeploys
.
ProxyAdminAddr
:
addr
=
predeploys
.
ProxyAdminAddr
default
:
addr
,
err
=
AddressToCodeNamespace
(
*
address
)
if
err
!=
nil
{
return
err
}
// Set the implementation slot in the predeploy proxy
db
.
SetState
(
*
address
,
ImplementationSlot
,
addr
.
Hash
())
db
.
SetState
(
*
address
,
ImplementationSlot
,
addr
.
Hash
())
}
}
...
@@ -136,3 +128,23 @@ func SetPrecompileBalances(db vm.StateDB) {
...
@@ -136,3 +128,23 @@ func SetPrecompileBalances(db vm.StateDB) {
db
.
AddBalance
(
addr
,
common
.
Big1
)
db
.
AddBalance
(
addr
,
common
.
Big1
)
}
}
}
}
func
mapImplementationAddress
(
addrP
*
common
.
Address
)
(
common
.
Address
,
bool
,
error
)
{
var
addr
common
.
Address
var
err
error
var
special
bool
switch
*
addrP
{
case
predeploys
.
GovernanceTokenAddr
:
addr
=
predeploys
.
GovernanceTokenAddr
special
=
true
case
predeploys
.
LegacyERC20ETHAddr
:
addr
=
predeploys
.
LegacyERC20ETHAddr
special
=
true
case
predeploys
.
ProxyAdminAddr
:
addr
=
predeploys
.
ProxyAdminAddr
special
=
true
default
:
addr
,
err
=
AddressToCodeNamespace
(
*
addrP
)
}
return
addr
,
special
,
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