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
2e3534ff
Commit
2e3534ff
authored
Aug 02, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-bindings: handle L2 state
parent
8e605053
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
1 deletion
+66
-1
types.go
op-bindings/solc/types.go
+11
-0
main.go
op-chain-ops/cmd/check-l2/main.go
+50
-1
config.go
op-chain-ops/genesis/config.go
+5
-0
No files found.
op-bindings/solc/types.go
View file @
2e3534ff
...
...
@@ -64,6 +64,17 @@ func (s *StorageLayout) GetStorageLayoutEntry(name string) (StorageLayoutEntry,
return
StorageLayoutEntry
{},
fmt
.
Errorf
(
"%s not found"
,
name
)
}
// GetStorageLayoutType returns the StorageLayoutType where the label matches
// the provided name.
func
(
s
*
StorageLayout
)
GetStorageLayoutType
(
name
string
)
(
StorageLayoutType
,
error
)
{
for
typeName
,
typ
:=
range
s
.
Types
{
if
typeName
==
name
{
return
typ
,
nil
}
}
return
StorageLayoutType
{},
fmt
.
Errorf
(
"%s not found"
,
name
)
}
type
StorageLayoutEntry
struct
{
AstId
uint
`json:"astId"`
Contract
string
`json:"contract"`
...
...
op-chain-ops/cmd/check-l2/main.go
View file @
2e3534ff
...
...
@@ -603,11 +603,15 @@ func checkL2StandardBridge(addr common.Address, client *ethclient.Client) error
if
messenger
!=
predeploys
.
L2CrossDomainMessengerAddr
{
return
fmt
.
Errorf
(
"L2StandardBridge MESSENGER should be %s, got %s"
,
predeploys
.
L2CrossDomainMessengerAddr
,
messenger
)
}
version
,
err
:=
contract
.
Version
(
&
bind
.
CallOpts
{})
if
err
!=
nil
{
return
err
}
initialized
,
err
:=
getInitialized
(
"L2StandardBridge"
,
addr
,
client
)
if
err
!=
nil
{
return
err
}
log
.
Info
(
"L2StandardBridge"
,
"_initialized"
,
initialized
)
log
.
Info
(
"L2StandardBridge version"
,
"version"
,
version
)
return
nil
}
...
...
@@ -805,3 +809,48 @@ func getEIP1967ImplementationAddress(client *ethclient.Client, addr common.Addre
impl
:=
common
.
BytesToAddress
(
slot
)
return
impl
,
nil
}
// checkPredeploy ensures that the predeploy at index i has the correct proxy admin set
func
checkPredeploy
(
client
*
ethclient
.
Client
,
i
uint64
)
error
{
bigAddr
:=
new
(
big
.
Int
)
.
Or
(
genesis
.
BigL2PredeployNamespace
,
new
(
big
.
Int
)
.
SetUint64
(
i
))
addr
:=
common
.
BigToAddress
(
bigAddr
)
if
!
predeploys
.
IsProxied
(
addr
)
{
return
nil
}
admin
,
err
:=
getEIP1967AdminAddress
(
client
,
addr
)
if
err
!=
nil
{
return
err
}
if
admin
!=
predeploys
.
ProxyAdminAddr
{
return
fmt
.
Errorf
(
"%s does not have correct proxy admin set"
,
addr
)
}
return
nil
}
// getInitialized will get the initialized value in storage of a contract.
// This is an incrementing number that starts at 1 and increments each time that
// the contract is upgraded.
func
getInitialized
(
name
string
,
addr
common
.
Address
,
client
*
ethclient
.
Client
)
(
*
big
.
Int
,
error
)
{
layout
,
err
:=
bindings
.
GetStorageLayout
(
name
)
if
err
!=
nil
{
return
nil
,
err
}
entry
,
err
:=
layout
.
GetStorageLayoutEntry
(
"_initialized"
)
if
err
!=
nil
{
return
nil
,
err
}
typ
,
err
:=
layout
.
GetStorageLayoutType
(
entry
.
Type
)
if
err
!=
nil
{
return
nil
,
err
}
slot
:=
common
.
BigToHash
(
big
.
NewInt
(
int64
(
entry
.
Slot
)))
value
,
err
:=
client
.
StorageAt
(
context
.
Background
(),
addr
,
slot
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
if
entry
.
Offset
+
typ
.
NumberOfBytes
>
uint
(
len
(
value
))
{
return
nil
,
fmt
.
Errorf
(
"value length is too short"
)
}
initialized
:=
new
(
big
.
Int
)
.
SetBytes
(
value
[
entry
.
Offset
:
entry
.
Offset
+
typ
.
NumberOfBytes
])
return
initialized
,
nil
}
op-chain-ops/genesis/config.go
View file @
2e3534ff
...
...
@@ -656,6 +656,11 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.Storage
"xDomainMsgSender"
:
"0x000000000000000000000000000000000000dEaD"
,
"msgNonce"
:
0
,
}
storage
[
"L2StandardBridge"
]
=
state
.
StorageValues
{
"_initialized"
:
2
,
"_initializing"
:
false
,
"_MESSENGER"
:
predeploys
.
L2CrossDomainMessengerAddr
,
}
storage
[
"L1Block"
]
=
state
.
StorageValues
{
"number"
:
block
.
Number
(),
"timestamp"
:
block
.
Time
(),
...
...
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