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
6cca247a
Commit
6cca247a
authored
Dec 07, 2023
by
Tei Im
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply suggestions from code reivews
Use duration flag type Dedup long lines
parent
5c6d39b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
main.go
op-chain-ops/cmd/check-derivation/main.go
+16
-16
No files found.
op-chain-ops/cmd/check-derivation/main.go
View file @
6cca247a
...
@@ -44,10 +44,10 @@ func main() {
...
@@ -44,10 +44,10 @@ func main() {
Usage
:
"L2 RPC URL"
,
Usage
:
"L2 RPC URL"
,
EnvVars
:
[]
string
{
"L2_RPC_URL"
},
EnvVars
:
[]
string
{
"L2_RPC_URL"
},
},
},
&
cli
.
Int
Flag
{
&
cli
.
Duration
Flag
{
Name
:
"polling-interval"
,
Name
:
"polling-interval"
,
Value
:
500
,
Value
:
time
.
Millisecond
*
500
,
Usage
:
"Polling interval
(ms)
"
,
Usage
:
"Polling interval"
,
},
},
},
},
Action
:
detectL2Reorg
,
Action
:
detectL2Reorg
,
...
@@ -62,10 +62,10 @@ func main() {
...
@@ -62,10 +62,10 @@ func main() {
Usage
:
"L2 RPC URL"
,
Usage
:
"L2 RPC URL"
,
EnvVars
:
[]
string
{
"L2_RPC_URL"
},
EnvVars
:
[]
string
{
"L2_RPC_URL"
},
},
},
&
cli
.
Int
Flag
{
&
cli
.
Duration
Flag
{
Name
:
"polling-interval"
,
Name
:
"polling-interval"
,
Value
:
1000
,
Value
:
time
.
Millisecond
*
1000
,
Usage
:
"Polling interval
(ms)
"
,
Usage
:
"Polling interval"
,
},
},
&
cli
.
StringFlag
{
&
cli
.
StringFlag
{
Name
:
"private-key"
,
Name
:
"private-key"
,
...
@@ -157,7 +157,7 @@ func detectL2Reorg(cliCtx *cli.Context) error {
...
@@ -157,7 +157,7 @@ func detectL2Reorg(cliCtx *cli.Context) error {
return
err
return
err
}
}
var
pollingInterval
=
time
.
Duration
(
cliCtx
.
Int
(
"polling-interval"
))
*
time
.
Millisecond
var
pollingInterval
=
cliCtx
.
Duration
(
"polling-interval"
)
// blockMap maps blockNumber to blockHash
// blockMap maps blockNumber to blockHash
blockMap
:=
make
(
map
[
uint64
]
common
.
Hash
)
blockMap
:=
make
(
map
[
uint64
]
common
.
Hash
)
var
prevUnsafeHeadNum
uint64
var
prevUnsafeHeadNum
uint64
...
@@ -326,10 +326,7 @@ func checkConsolidation(cliCtx *cli.Context) error {
...
@@ -326,10 +326,7 @@ func checkConsolidation(cliCtx *cli.Context) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
err
!=
nil
{
var
pollingInterval
=
cliCtx
.
Duration
(
"polling-interval"
)
return
err
}
var
pollingInterval
=
time
.
Duration
(
cliCtx
.
Int
(
"polling-interval"
))
*
time
.
Millisecond
privateKey
,
err
:=
getPrivateKey
(
cliCtx
)
privateKey
,
err
:=
getPrivateKey
(
cliCtx
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -355,17 +352,19 @@ func checkConsolidation(cliCtx *cli.Context) error {
...
@@ -355,17 +352,19 @@ func checkConsolidation(cliCtx *cli.Context) error {
// txMap maps txHash to blockID
// txMap maps txHash to blockID
txMap
:=
make
(
map
[
common
.
Hash
]
eth
.
BlockID
)
txMap
:=
make
(
map
[
common
.
Hash
]
eth
.
BlockID
)
for
i
:=
0
;
i
<
txCount
;
i
++
{
for
i
:=
0
;
i
<
txCount
;
i
++
{
var
tx
*
types
.
Transaction
txType
:=
types
.
LegacyTxType
protected
:=
true
switch
i
%
4
{
switch
i
%
4
{
case
0
:
case
0
:
tx
,
err
=
getRandomSignedTransaction
(
ctx
,
cl
,
rng
,
from
,
privateKey
,
l2ChainID
,
types
.
LegacyTxType
,
false
)
protected
=
false
// legacy unprotected TX (Homestead
)
case
1
:
case
1
:
tx
,
err
=
getRandomSignedTransaction
(
ctx
,
cl
,
rng
,
from
,
privateKey
,
l2ChainID
,
types
.
LegacyTxType
,
true
)
// legacy protected TX
case
2
:
case
2
:
tx
,
err
=
getRandomSignedTransaction
(
ctx
,
cl
,
rng
,
from
,
privateKey
,
l2ChainID
,
types
.
AccessListTxType
,
true
)
tx
Type
=
types
.
AccessListTxType
case
3
:
case
3
:
tx
,
err
=
getRandomSignedTransaction
(
ctx
,
cl
,
rng
,
from
,
privateKey
,
l2ChainID
,
types
.
DynamicFeeTxType
,
true
)
tx
Type
=
types
.
DynamicFeeTxType
}
}
tx
,
err
:=
getRandomSignedTransaction
(
ctx
,
cl
,
rng
,
from
,
privateKey
,
l2ChainID
,
txType
,
protected
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -373,6 +372,7 @@ func checkConsolidation(cliCtx *cli.Context) error {
...
@@ -373,6 +372,7 @@ func checkConsolidation(cliCtx *cli.Context) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to send transaction: %w"
,
err
)
return
fmt
.
Errorf
(
"failed to send transaction: %w"
,
err
)
}
}
log
.
Info
(
"Sent transaction"
,
"txType"
,
txType
,
"protected"
,
protected
)
txHash
:=
tx
.
Hash
()
txHash
:=
tx
.
Hash
()
blockId
,
err
:=
confirmTransaction
(
ctx
,
cl
,
l2BlockTime
,
txHash
)
blockId
,
err
:=
confirmTransaction
(
ctx
,
cl
,
l2BlockTime
,
txHash
)
if
err
!=
nil
{
if
err
!=
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