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
caa68a1f
Commit
caa68a1f
authored
Oct 20, 2022
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: handle proxy admin
parent
b6fcc05f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
30 deletions
+25
-30
config.go
op-chain-ops/genesis/config.go
+14
-8
layer_two.go
op-chain-ops/genesis/layer_two.go
+6
-18
setters.go
op-chain-ops/genesis/setters.go
+5
-4
No files found.
op-chain-ops/genesis/config.go
View file @
caa68a1f
...
@@ -104,22 +104,26 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) {
...
@@ -104,22 +104,26 @@ func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error) {
// NewL2ImmutableConfig will create an ImmutableConfig given an instance of a
// NewL2ImmutableConfig will create an ImmutableConfig given an instance of a
// Hardhat and a DeployConfig.
// Hardhat and a DeployConfig.
func
NewL2ImmutableConfig
(
config
*
DeployConfig
,
block
*
types
.
Block
,
proxyL1StandardBridge
,
proxyL1CrossDomainMessenger
,
proxyL1ERC721Bridge
common
.
Addres
s
)
(
immutables
.
ImmutableConfig
,
error
)
{
func
NewL2ImmutableConfig
(
config
*
DeployConfig
,
block
*
types
.
Block
,
l2Addrs
*
L2Addresse
s
)
(
immutables
.
ImmutableConfig
,
error
)
{
immutable
:=
make
(
immutables
.
ImmutableConfig
)
immutable
:=
make
(
immutables
.
ImmutableConfig
)
if
proxyL1ERC721Bridge
==
(
common
.
Address
{})
{
if
l2Addrs
==
nil
{
return
immutable
,
errors
.
New
(
"must pass L1 contract addresses"
)
}
if
l2Addrs
.
ProxyL1ERC721Bridge
==
(
common
.
Address
{})
{
return
immutable
,
errors
.
New
(
"L1ERC721BridgeProxy cannot be address(0)"
)
return
immutable
,
errors
.
New
(
"L1ERC721BridgeProxy cannot be address(0)"
)
}
}
immutable
[
"L2StandardBridge"
]
=
immutables
.
ImmutableValues
{
immutable
[
"L2StandardBridge"
]
=
immutables
.
ImmutableValues
{
"otherBridge"
:
proxyL1StandardBridge
,
"otherBridge"
:
l2Addrs
.
L1StandardBridgeProxy
,
}
}
immutable
[
"L2CrossDomainMessenger"
]
=
immutables
.
ImmutableValues
{
immutable
[
"L2CrossDomainMessenger"
]
=
immutables
.
ImmutableValues
{
"otherMessenger"
:
proxyL1CrossDomainMessenger
,
"otherMessenger"
:
l2Addrs
.
L1CrossDomainMessengerProxy
,
}
}
immutable
[
"L2ERC721Bridge"
]
=
immutables
.
ImmutableValues
{
immutable
[
"L2ERC721Bridge"
]
=
immutables
.
ImmutableValues
{
"messenger"
:
predeploys
.
L2CrossDomainMessengerAddr
,
"messenger"
:
predeploys
.
L2CrossDomainMessengerAddr
,
"otherBridge"
:
p
roxyL1ERC721Bridge
,
"otherBridge"
:
l2Addrs
.
P
roxyL1ERC721Bridge
,
}
}
immutable
[
"OptimismMintableERC721Factory"
]
=
immutables
.
ImmutableValues
{
immutable
[
"OptimismMintableERC721Factory"
]
=
immutables
.
ImmutableValues
{
"bridge"
:
predeploys
.
L2ERC721BridgeAddr
,
"bridge"
:
predeploys
.
L2ERC721BridgeAddr
,
...
@@ -131,7 +135,7 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, proxyL1Stand
...
@@ -131,7 +135,7 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, proxyL1Stand
// NewL2StorageConfig will create a StorageConfig given an instance of a
// NewL2StorageConfig will create a StorageConfig given an instance of a
// Hardhat and a DeployConfig.
// Hardhat and a DeployConfig.
func
NewL2StorageConfig
(
config
*
DeployConfig
,
block
*
types
.
Block
,
proxyL1StandardBridge
common
.
Address
,
proxyL1CrossDomainMessenger
common
.
Addres
s
)
(
state
.
StorageConfig
,
error
)
{
func
NewL2StorageConfig
(
config
*
DeployConfig
,
block
*
types
.
Block
,
l2Addrs
*
L2Addresse
s
)
(
state
.
StorageConfig
,
error
)
{
storage
:=
make
(
state
.
StorageConfig
)
storage
:=
make
(
state
.
StorageConfig
)
if
block
.
Number
()
==
nil
{
if
block
.
Number
()
==
nil
{
...
@@ -140,6 +144,9 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, proxyL1Standar
...
@@ -140,6 +144,9 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, proxyL1Standar
if
block
.
BaseFee
()
==
nil
{
if
block
.
BaseFee
()
==
nil
{
return
storage
,
errors
.
New
(
"block base fee not set"
)
return
storage
,
errors
.
New
(
"block base fee not set"
)
}
}
if
l2Addrs
==
nil
{
return
storage
,
errors
.
New
(
"must pass L1 address info"
)
}
storage
[
"L2ToL1MessagePasser"
]
=
state
.
StorageValues
{
storage
[
"L2ToL1MessagePasser"
]
=
state
.
StorageValues
{
"nonce"
:
0
,
"nonce"
:
0
,
...
@@ -188,8 +195,7 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, proxyL1Standar
...
@@ -188,8 +195,7 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block, proxyL1Standar
"_owner"
:
common
.
Address
{},
"_owner"
:
common
.
Address
{},
}
}
storage
[
"ProxyAdmin"
]
=
state
.
StorageValues
{
storage
[
"ProxyAdmin"
]
=
state
.
StorageValues
{
// TODO: this needs to be configurable
"owner"
:
l2Addrs
.
ProxyAdmin
,
"owner"
:
common
.
Address
{},
}
}
return
storage
,
nil
return
storage
,
nil
}
}
op-chain-ops/genesis/layer_two.go
View file @
caa68a1f
...
@@ -9,6 +9,8 @@ import (
...
@@ -9,6 +9,8 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
)
)
// L2Addresses represents L1 contract addresses
// that are required for the construction of an L2 state
type
L2Addresses
struct
{
type
L2Addresses
struct
{
ProxyAdmin
common
.
Address
ProxyAdmin
common
.
Address
L1StandardBridgeProxy
common
.
Address
L1StandardBridgeProxy
common
.
Address
...
@@ -31,6 +33,7 @@ func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2
...
@@ -31,6 +33,7 @@ func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2
}
}
SetPrecompileBalances
(
db
)
SetPrecompileBalances
(
db
)
// Use the known developer addresses if they are not set
if
l2Addrs
==
nil
{
if
l2Addrs
==
nil
{
l2Addrs
=
&
L2Addresses
{
l2Addrs
=
&
L2Addresses
{
ProxyAdmin
:
predeploys
.
DevProxyAdminAddr
,
ProxyAdmin
:
predeploys
.
DevProxyAdminAddr
,
...
@@ -45,31 +48,16 @@ func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2
...
@@ -45,31 +48,16 @@ func BuildL2DeveloperGenesis(config *DeployConfig, l1StartBlock *types.Block, l2
// BuildL2Genesis will build the L2 Optimism Genesis Block
// BuildL2Genesis will build the L2 Optimism Genesis Block
func
BuildL2Genesis
(
db
*
state
.
MemoryStateDB
,
config
*
DeployConfig
,
l1Block
*
types
.
Block
,
l2Addrs
*
L2Addresses
)
(
*
core
.
Genesis
,
error
)
{
func
BuildL2Genesis
(
db
*
state
.
MemoryStateDB
,
config
*
DeployConfig
,
l1Block
*
types
.
Block
,
l2Addrs
*
L2Addresses
)
(
*
core
.
Genesis
,
error
)
{
// TODO(tynes): need a function for clearing old, unused storage slots.
if
err
:=
SetL2Proxies
(
db
);
err
!=
nil
{
// Each deployed contract on L2 needs to have its existing storage
// inspected and then cleared if they are no longer used.
if
err
:=
SetL2Proxies
(
db
,
l2Addrs
.
ProxyAdmin
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
storage
,
err
:=
NewL2StorageConfig
(
storage
,
err
:=
NewL2StorageConfig
(
config
,
l1Block
,
l2Addrs
)
config
,
l1Block
,
l2Addrs
.
L1StandardBridgeProxy
,
l2Addrs
.
L1CrossDomainMessengerProxy
,
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
immutable
,
err
:=
NewL2ImmutableConfig
(
immutable
,
err
:=
NewL2ImmutableConfig
(
config
,
l1Block
,
l2Addrs
)
config
,
l1Block
,
l2Addrs
.
L1StandardBridgeProxy
,
l2Addrs
.
L1CrossDomainMessengerProxy
,
l2Addrs
.
L1ERC721BridgeProxy
,
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
op-chain-ops/genesis/setters.go
View file @
caa68a1f
...
@@ -25,8 +25,8 @@ func FundDevAccounts(db vm.StateDB) {
...
@@ -25,8 +25,8 @@ func FundDevAccounts(db vm.StateDB) {
// a Proxy and ProxyAdmin deployment present so that the Proxy bytecode
// a Proxy and ProxyAdmin deployment present so that the Proxy bytecode
// can be set in state and the ProxyAdmin can be set as the admin of the
// can be set in state and the ProxyAdmin can be set as the admin of the
// Proxy.
// Proxy.
func
SetL2Proxies
(
db
vm
.
StateDB
,
proxyAdminAddr
common
.
Address
)
error
{
func
SetL2Proxies
(
db
vm
.
StateDB
)
error
{
return
setProxies
(
db
,
proxyAdminAddr
,
bigL2PredeployNamespace
,
2048
)
return
setProxies
(
db
,
pr
edeploys
.
Pr
oxyAdminAddr
,
bigL2PredeployNamespace
,
2048
)
}
}
// SetL1Proxies will set each of the proxies in the state. It requires
// SetL1Proxies will set each of the proxies in the state. It requires
...
@@ -56,7 +56,7 @@ func setProxies(db vm.StateDB, proxyAdminAddr common.Address, namespace *big.Int
...
@@ -56,7 +56,7 @@ func setProxies(db vm.StateDB, proxyAdminAddr common.Address, namespace *big.Int
db
.
CreateAccount
(
addr
)
db
.
CreateAccount
(
addr
)
db
.
SetCode
(
addr
,
depBytecode
)
db
.
SetCode
(
addr
,
depBytecode
)
db
.
SetState
(
addr
,
AdminSlot
,
pr
edeploys
.
Pr
oxyAdminAddr
.
Hash
())
db
.
SetState
(
addr
,
AdminSlot
,
proxyAdminAddr
.
Hash
())
}
}
return
nil
return
nil
}
}
...
@@ -71,7 +71,8 @@ func SetImplementations(db vm.StateDB, storage state.StorageConfig, immutable im
...
@@ -71,7 +71,8 @@ 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
// Convert the address to the code address unless it is
// designed to not be behind a proxy
var
addr
common
.
Address
var
addr
common
.
Address
switch
*
address
{
switch
*
address
{
case
predeploys
.
GovernanceTokenAddr
:
case
predeploys
.
GovernanceTokenAddr
:
...
...
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