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
fdccb64c
Commit
fdccb64c
authored
Nov 13, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: improve assertions
parent
5fc066de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
main.go
op-chain-ops/cmd/check-l2/main.go
+19
-21
No files found.
op-chain-ops/cmd/check-l2/main.go
View file @
fdccb64c
...
...
@@ -7,6 +7,7 @@ import (
"fmt"
"math/big"
"os"
"strings"
"golang.org/x/sync/errgroup"
...
...
@@ -32,7 +33,7 @@ var (
errInvalidInitialized
=
errors
.
New
(
"invalid initialized value"
)
// errAlreadyInitialized represents a revert from when a contract is already initialized.
// This error is used to assert with `eth_call` on contracts that are `Initializable`
errAlreadyInitialized
=
errors
.
New
(
"
execution reverted:
Initializable: contract is already initialized"
)
errAlreadyInitialized
=
errors
.
New
(
"Initializable: contract is already initialized"
)
)
// Default script for checking that L2 has been configured correctly. This should be extended in the future
...
...
@@ -452,11 +453,7 @@ func checkL2ERC721Bridge(addr common.Address, client *ethclient.Client) error {
if
err
!=
nil
{
return
err
}
msg
:=
ethereum
.
CallMsg
{
To
:
&
addr
,
Data
:
calldata
,
}
if
_
,
err
:=
client
.
CallContract
(
context
.
Background
(),
msg
,
nil
);
err
.
Error
()
!=
errAlreadyInitialized
.
Error
()
{
if
err
:=
checkAlreadyInitialized
(
addr
,
calldata
,
client
);
err
!=
nil
{
return
err
}
...
...
@@ -608,11 +605,7 @@ func checkOptimismMintableERC20Factory(addr common.Address, client *ethclient.Cl
if
err
!=
nil
{
return
err
}
msg
:=
ethereum
.
CallMsg
{
To
:
&
addr
,
Data
:
calldata
,
}
if
_
,
err
:=
client
.
CallContract
(
context
.
Background
(),
msg
,
nil
);
err
.
Error
()
!=
errAlreadyInitialized
.
Error
()
{
if
err
:=
checkAlreadyInitialized
(
addr
,
calldata
,
client
);
err
!=
nil
{
return
err
}
...
...
@@ -708,11 +701,7 @@ func checkL2StandardBridge(addr common.Address, client *ethclient.Client) error
if
err
!=
nil
{
return
err
}
msg
:=
ethereum
.
CallMsg
{
To
:
&
addr
,
Data
:
calldata
,
}
if
_
,
err
:=
client
.
CallContract
(
context
.
Background
(),
msg
,
nil
);
err
.
Error
()
!=
errAlreadyInitialized
.
Error
()
{
if
err
:=
checkAlreadyInitialized
(
addr
,
calldata
,
client
);
err
!=
nil
{
return
err
}
...
...
@@ -846,11 +835,7 @@ func checkL2CrossDomainMessenger(addr common.Address, client *ethclient.Client)
if
err
!=
nil
{
return
err
}
msg
:=
ethereum
.
CallMsg
{
To
:
&
addr
,
Data
:
calldata
,
}
if
_
,
err
:=
client
.
CallContract
(
context
.
Background
(),
msg
,
nil
);
err
.
Error
()
!=
errAlreadyInitialized
.
Error
()
{
if
err
:=
checkAlreadyInitialized
(
addr
,
calldata
,
client
);
err
!=
nil
{
return
err
}
...
...
@@ -1005,3 +990,16 @@ func getStorageValue(name, entryName string, addr common.Address, client *ethcli
}
return
slice
[
entry
.
Offset
:
entry
.
Offset
+
typ
.
NumberOfBytes
],
nil
}
// checkAlreadyInitialized will check if a contract has already been initialized
// based on error message string matching.
func
checkAlreadyInitialized
(
addr
common
.
Address
,
calldata
[]
byte
,
client
*
ethclient
.
Client
)
error
{
msg
:=
ethereum
.
CallMsg
{
To
:
&
addr
,
Data
:
calldata
,
}
if
_
,
err
:=
client
.
CallContract
(
context
.
Background
(),
msg
,
nil
);
!
strings
.
Contains
(
err
.
Error
(),
errAlreadyInitialized
.
Error
())
{
return
err
}
return
nil
}
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