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
b59d695c
Unverified
Commit
b59d695c
authored
Apr 13, 2023
by
mergify[bot]
Committed by
GitHub
Apr 13, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into fix/ci-syscfg
parents
4a01d275
3c052f25
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
312 additions
and
78 deletions
+312
-78
batch_submitter.go
op-batcher/batcher/batch_submitter.go
+4
-0
cmd.go
op-batcher/cmd/doc/cmd.go
+54
-0
main.go
op-batcher/cmd/main.go
+9
-3
flags.go
op-batcher/flags/flags.go
+23
-18
flags.go
op-node/flags/flags.go
+4
-22
engine_queue.go
op-node/rollup/derive/engine_queue.go
+27
-16
engine_queue_test.go
op-node/rollup/derive/engine_queue_test.go
+100
-0
mock_eth_client.go
op-node/testutils/mock_eth_client.go
+2
-2
cmd.go
op-proposer/cmd/doc/cmd.go
+54
-0
main.go
op-proposer/cmd/main.go
+8
-1
flags.go
op-proposer/flags/flags.go
+21
-14
metrics.go
op-proposer/metrics/metrics.go
+4
-0
tx_metrics.go
op-service/txmgr/metrics/tx_metrics.go
+2
-2
No files found.
op-batcher/batcher/batch_submitter.go
View file @
b59d695c
...
@@ -12,6 +12,7 @@ import (
...
@@ -12,6 +12,7 @@ import (
gethrpc
"github.com/ethereum/go-ethereum/rpc"
gethrpc
"github.com/ethereum/go-ethereum/rpc"
"github.com/urfave/cli"
"github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
...
@@ -30,6 +31,9 @@ const (
...
@@ -30,6 +31,9 @@ const (
// of a closure allows the parameters bound to the top-level main package, e.g.
// of a closure allows the parameters bound to the top-level main package, e.g.
// GitVersion, to be captured and used once the function is executed.
// GitVersion, to be captured and used once the function is executed.
func
Main
(
version
string
,
cliCtx
*
cli
.
Context
)
error
{
func
Main
(
version
string
,
cliCtx
*
cli
.
Context
)
error
{
if
err
:=
flags
.
CheckRequired
(
cliCtx
);
err
!=
nil
{
return
err
}
cfg
:=
NewConfig
(
cliCtx
)
cfg
:=
NewConfig
(
cliCtx
)
if
err
:=
cfg
.
Check
();
err
!=
nil
{
if
err
:=
cfg
.
Check
();
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid CLI flags: %w"
,
err
)
return
fmt
.
Errorf
(
"invalid CLI flags: %w"
,
err
)
...
...
op-batcher/cmd/doc/cmd.go
0 → 100644
View file @
b59d695c
package
doc
import
(
"encoding/json"
"fmt"
"os"
"strings"
"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli"
)
var
Subcommands
=
cli
.
Commands
{
{
Name
:
"metrics"
,
Usage
:
"Dumps a list of supported metrics to stdout"
,
Flags
:
[]
cli
.
Flag
{
cli
.
StringFlag
{
Name
:
"format"
,
Value
:
"markdown"
,
Usage
:
"Output format (json|markdown)"
,
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
m
:=
metrics
.
NewMetrics
(
"default"
)
supportedMetrics
:=
m
.
Document
()
format
:=
ctx
.
String
(
"format"
)
if
format
!=
"markdown"
&&
format
!=
"json"
{
return
fmt
.
Errorf
(
"invalid format: %s"
,
format
)
}
if
format
==
"json"
{
enc
:=
json
.
NewEncoder
(
os
.
Stdout
)
return
enc
.
Encode
(
supportedMetrics
)
}
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetBorders
(
tablewriter
.
Border
{
Left
:
true
,
Top
:
false
,
Right
:
true
,
Bottom
:
false
})
table
.
SetCenterSeparator
(
"|"
)
table
.
SetAutoWrapText
(
false
)
table
.
SetHeader
([]
string
{
"Metric"
,
"Description"
,
"Labels"
,
"Type"
})
var
data
[][]
string
for
_
,
metric
:=
range
supportedMetrics
{
labels
:=
strings
.
Join
(
metric
.
Labels
,
","
)
data
=
append
(
data
,
[]
string
{
metric
.
Name
,
metric
.
Help
,
labels
,
metric
.
Type
})
}
table
.
AppendBulk
(
data
)
table
.
Render
()
return
nil
},
},
}
op-batcher/cmd/main.go
View file @
b59d695c
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/urfave/cli"
"github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/cmd/doc"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
...
@@ -26,10 +27,15 @@ func main() {
...
@@ -26,10 +27,15 @@ func main() {
app
.
Version
=
fmt
.
Sprintf
(
"%s-%s-%s"
,
Version
,
GitCommit
,
GitDate
)
app
.
Version
=
fmt
.
Sprintf
(
"%s-%s-%s"
,
Version
,
GitCommit
,
GitDate
)
app
.
Name
=
"op-batcher"
app
.
Name
=
"op-batcher"
app
.
Usage
=
"Batch Submitter Service"
app
.
Usage
=
"Batch Submitter Service"
app
.
Description
=
"Service for generating and submitting L2 tx batches "
+
app
.
Description
=
"Service for generating and submitting L2 tx batches to L1"
"to L1"
app
.
Action
=
curryMain
(
Version
)
app
.
Action
=
curryMain
(
Version
)
app
.
Commands
=
[]
cli
.
Command
{
{
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
},
}
err
:=
app
.
Run
(
os
.
Args
)
err
:=
app
.
Run
(
os
.
Args
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Crit
(
"Application failed"
,
"message"
,
err
)
log
.
Crit
(
"Application failed"
,
"message"
,
err
)
...
...
op-batcher/flags/flags.go
View file @
b59d695c
package
flags
package
flags
import
(
import
(
"fmt"
"github.com/urfave/cli"
"github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
...
@@ -17,37 +19,32 @@ const envVarPrefix = "OP_BATCHER"
...
@@ -17,37 +19,32 @@ const envVarPrefix = "OP_BATCHER"
var
(
var
(
// Required flags
// Required flags
L1EthRpcFlag
=
cli
.
StringFlag
{
L1EthRpcFlag
=
cli
.
StringFlag
{
Name
:
"l1-eth-rpc"
,
Name
:
"l1-eth-rpc"
,
Usage
:
"HTTP provider URL for L1"
,
Usage
:
"HTTP provider URL for L1"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L1_ETH_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L1_ETH_RPC"
),
}
}
L2EthRpcFlag
=
cli
.
StringFlag
{
L2EthRpcFlag
=
cli
.
StringFlag
{
Name
:
"l2-eth-rpc"
,
Name
:
"l2-eth-rpc"
,
Usage
:
"HTTP provider URL for L2 execution engine"
,
Usage
:
"HTTP provider URL for L2 execution engine"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L2_ETH_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L2_ETH_RPC"
),
}
}
RollupRpcFlag
=
cli
.
StringFlag
{
RollupRpcFlag
=
cli
.
StringFlag
{
Name
:
"rollup-rpc"
,
Name
:
"rollup-rpc"
,
Usage
:
"HTTP provider URL for Rollup node"
,
Usage
:
"HTTP provider URL for Rollup node"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"ROLLUP_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"ROLLUP_RPC"
),
}
}
SubSafetyMarginFlag
=
cli
.
Uint64Flag
{
SubSafetyMarginFlag
=
cli
.
Uint64Flag
{
Name
:
"sub-safety-margin"
,
Name
:
"sub-safety-margin"
,
Usage
:
"The batcher tx submission safety margin (in #L1-blocks) to subtract "
+
Usage
:
"The batcher tx submission safety margin (in #L1-blocks) to subtract "
+
"from a channel's timeout and sequencing window, to guarantee safe inclusion "
+
"from a channel's timeout and sequencing window, to guarantee safe inclusion "
+
"of a channel on L1."
,
"of a channel on L1."
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"SUB_SAFETY_MARGIN"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"SUB_SAFETY_MARGIN"
),
}
}
PollIntervalFlag
=
cli
.
DurationFlag
{
PollIntervalFlag
=
cli
.
DurationFlag
{
Name
:
"poll-interval"
,
Name
:
"poll-interval"
,
Usage
:
"Delay between querying L2 for more transactions and "
+
Usage
:
"Delay between querying L2 for more transactions and "
+
"creating a new batch"
,
"creating a new batch"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"POLL_INTERVAL"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"POLL_INTERVAL"
),
}
}
// Optional flags
// Optional flags
...
@@ -108,8 +105,7 @@ var optionalFlags = []cli.Flag{
...
@@ -108,8 +105,7 @@ var optionalFlags = []cli.Flag{
}
}
func
init
()
{
func
init
()
{
requiredFlags
=
append
(
requiredFlags
,
oprpc
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oprpc
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oplog
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
opmetrics
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
opmetrics
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oppprof
.
CLIFlags
(
envVarPrefix
)
...
)
optionalFlags
=
append
(
optionalFlags
,
oppprof
.
CLIFlags
(
envVarPrefix
)
...
)
...
@@ -121,3 +117,12 @@ func init() {
...
@@ -121,3 +117,12 @@ func init() {
// Flags contains the list of configuration options available to the binary.
// Flags contains the list of configuration options available to the binary.
var
Flags
[]
cli
.
Flag
var
Flags
[]
cli
.
Flag
func
CheckRequired
(
ctx
*
cli
.
Context
)
error
{
for
_
,
f
:=
range
requiredFlags
{
if
!
ctx
.
GlobalIsSet
(
f
.
GetName
())
{
return
fmt
.
Errorf
(
"flag %s is required"
,
f
.
GetName
())
}
}
return
nil
}
op-node/flags/flags.go
View file @
b59d695c
...
@@ -256,28 +256,10 @@ func init() {
...
@@ -256,28 +256,10 @@ func init() {
}
}
func
CheckRequired
(
ctx
*
cli
.
Context
)
error
{
func
CheckRequired
(
ctx
*
cli
.
Context
)
error
{
l1NodeAddr
:=
ctx
.
GlobalString
(
L1NodeAddr
.
Name
)
for
_
,
f
:=
range
requiredFlags
{
if
l1NodeAddr
==
""
{
if
!
ctx
.
GlobalIsSet
(
f
.
GetName
())
{
return
fmt
.
Errorf
(
"flag %s is required"
,
L1NodeAddr
.
Name
)
return
fmt
.
Errorf
(
"flag %s is required"
,
f
.
GetName
())
}
}
l2EngineAddr
:=
ctx
.
GlobalString
(
L2EngineAddr
.
Name
)
if
l2EngineAddr
==
""
{
return
fmt
.
Errorf
(
"flag %s is required"
,
L2EngineAddr
.
Name
)
}
rollupConfig
:=
ctx
.
GlobalString
(
RollupConfig
.
Name
)
network
:=
ctx
.
GlobalString
(
Network
.
Name
)
if
rollupConfig
==
""
&&
network
==
""
{
return
fmt
.
Errorf
(
"flag %s or %s is required"
,
RollupConfig
.
Name
,
Network
.
Name
)
}
if
rollupConfig
!=
""
&&
network
!=
""
{
return
fmt
.
Errorf
(
"cannot specify both %s and %s"
,
RollupConfig
.
Name
,
Network
.
Name
)
}
rpcListenAddr
:=
ctx
.
GlobalString
(
RPCListenAddr
.
Name
)
if
rpcListenAddr
==
""
{
return
fmt
.
Errorf
(
"flag %s is required"
,
RPCListenAddr
.
Name
)
}
if
!
ctx
.
GlobalIsSet
(
RPCListenPort
.
Name
)
{
return
fmt
.
Errorf
(
"flag %s is required"
,
RPCListenPort
.
Name
)
}
}
return
nil
return
nil
}
}
op-node/rollup/derive/engine_queue.go
View file @
b59d695c
...
@@ -17,6 +17,11 @@ import (
...
@@ -17,6 +17,11 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
"github.com/ethereum-optimism/optimism/op-node/rollup/sync"
)
)
type
attributesWithParent
struct
{
attributes
*
eth
.
PayloadAttributes
parent
eth
.
L2BlockRef
}
type
NextAttributesProvider
interface
{
type
NextAttributesProvider
interface
{
Origin
()
eth
.
L1BlockRef
Origin
()
eth
.
L1BlockRef
NextAttributes
(
context
.
Context
,
eth
.
L2BlockRef
)
(
*
eth
.
PayloadAttributes
,
error
)
NextAttributes
(
context
.
Context
,
eth
.
L2BlockRef
)
(
*
eth
.
PayloadAttributes
,
error
)
...
@@ -114,9 +119,8 @@ type EngineQueue struct {
...
@@ -114,9 +119,8 @@ type EngineQueue struct {
triedFinalizeAt
eth
.
L1BlockRef
triedFinalizeAt
eth
.
L1BlockRef
// The queued-up attributes
// The queued-up attributes
safeAttributesParent
eth
.
L2BlockRef
safeAttributes
*
attributesWithParent
safeAttributes
*
eth
.
PayloadAttributes
unsafePayloads
*
PayloadsQueue
// queue of unsafe payloads, ordered by ascending block number, may have gaps and duplicates
unsafePayloads
*
PayloadsQueue
// queue of unsafe payloads, ordered by ascending block number, may have gaps and duplicates
// Tracks which L2 blocks where last derived from which L1 block. At most finalityLookback large.
// Tracks which L2 blocks where last derived from which L1 block. At most finalityLookback large.
finalityData
[]
FinalityData
finalityData
[]
FinalityData
...
@@ -241,9 +245,11 @@ func (eq *EngineQueue) Step(ctx context.Context) error {
...
@@ -241,9 +245,11 @@ func (eq *EngineQueue) Step(ctx context.Context) error {
}
else
if
err
!=
nil
{
}
else
if
err
!=
nil
{
return
err
return
err
}
else
{
}
else
{
eq
.
safeAttributes
=
next
eq
.
safeAttributes
=
&
attributesWithParent
{
eq
.
safeAttributesParent
=
eq
.
safeHead
attributes
:
next
,
eq
.
log
.
Debug
(
"Adding next safe attributes"
,
"safe_head"
,
eq
.
safeHead
,
"next"
,
eq
.
safeAttributes
)
parent
:
eq
.
safeHead
,
}
eq
.
log
.
Debug
(
"Adding next safe attributes"
,
"safe_head"
,
eq
.
safeHead
,
"next"
,
next
)
return
NotEnoughData
return
NotEnoughData
}
}
...
@@ -482,15 +488,19 @@ func (eq *EngineQueue) tryNextSafeAttributes(ctx context.Context) error {
...
@@ -482,15 +488,19 @@ func (eq *EngineQueue) tryNextSafeAttributes(ctx context.Context) error {
return
nil
return
nil
}
}
// validate the safe attributes before processing them. The engine may have completed processing them through other means.
// validate the safe attributes before processing them. The engine may have completed processing them through other means.
if
eq
.
safeHead
!=
eq
.
safeAttributesParent
{
if
eq
.
safeHead
!=
eq
.
safeAttributes
.
parent
{
if
eq
.
safeHead
.
ParentHash
!=
eq
.
safeAttributesParent
.
Hash
{
// Previously the attribute's parent was the safe head. If the safe head advances so safe head's parent is the same as the
return
NewResetError
(
fmt
.
Errorf
(
"safe head changed to %s with parent %s, conflicting with queued safe attributes on top of %s"
,
// attribute's parent then we need to cancel the attributes.
eq
.
safeHead
,
eq
.
safeHead
.
ParentID
(),
eq
.
safeAttributesParent
))
if
eq
.
safeHead
.
ParentHash
==
eq
.
safeAttributes
.
parent
.
Hash
{
eq
.
log
.
Warn
(
"queued safe attributes are stale, safehead progressed"
,
"safe_head"
,
eq
.
safeHead
,
"safe_head_parent"
,
eq
.
safeHead
.
ParentID
(),
"attributes_parent"
,
eq
.
safeAttributes
.
parent
)
eq
.
safeAttributes
=
nil
return
nil
}
}
eq
.
log
.
Warn
(
"queued safe attributes are stale, safe-head progressed"
,
// If something other than a simple advance occurred, perform a full reset
"safe_head"
,
eq
.
safeHead
,
"safe_head_parent"
,
eq
.
safeHead
.
ParentID
(),
"attributes_parent"
,
eq
.
safeAttributesParent
)
return
NewResetError
(
fmt
.
Errorf
(
"safe head changed to %s with parent %s, conflicting with queued safe attributes on top of %s"
,
eq
.
safeAttributes
=
nil
eq
.
safeHead
,
eq
.
safeHead
.
ParentID
(),
eq
.
safeAttributes
.
parent
))
return
nil
}
}
if
eq
.
safeHead
.
Number
<
eq
.
unsafeHead
.
Number
{
if
eq
.
safeHead
.
Number
<
eq
.
unsafeHead
.
Number
{
return
eq
.
consolidateNextSafeAttributes
(
ctx
)
return
eq
.
consolidateNextSafeAttributes
(
ctx
)
...
@@ -520,7 +530,7 @@ func (eq *EngineQueue) consolidateNextSafeAttributes(ctx context.Context) error
...
@@ -520,7 +530,7 @@ func (eq *EngineQueue) consolidateNextSafeAttributes(ctx context.Context) error
}
}
return
NewTemporaryError
(
fmt
.
Errorf
(
"failed to get existing unsafe payload to compare against derived attributes from L1: %w"
,
err
))
return
NewTemporaryError
(
fmt
.
Errorf
(
"failed to get existing unsafe payload to compare against derived attributes from L1: %w"
,
err
))
}
}
if
err
:=
AttributesMatchBlock
(
eq
.
safeAttributes
,
eq
.
safeHead
.
Hash
,
payload
,
eq
.
log
);
err
!=
nil
{
if
err
:=
AttributesMatchBlock
(
eq
.
safeAttributes
.
attributes
,
eq
.
safeHead
.
Hash
,
payload
,
eq
.
log
);
err
!=
nil
{
eq
.
log
.
Warn
(
"L2 reorg: existing unsafe block does not match derived attributes from L1"
,
"err"
,
err
,
"unsafe"
,
eq
.
unsafeHead
,
"safe"
,
eq
.
safeHead
)
eq
.
log
.
Warn
(
"L2 reorg: existing unsafe block does not match derived attributes from L1"
,
"err"
,
err
,
"unsafe"
,
eq
.
unsafeHead
,
"safe"
,
eq
.
safeHead
)
// geth cannot wind back a chain without reorging to a new, previously non-canonical, block
// geth cannot wind back a chain without reorging to a new, previously non-canonical, block
return
eq
.
forceNextSafeAttributes
(
ctx
)
return
eq
.
forceNextSafeAttributes
(
ctx
)
...
@@ -545,7 +555,7 @@ func (eq *EngineQueue) forceNextSafeAttributes(ctx context.Context) error {
...
@@ -545,7 +555,7 @@ func (eq *EngineQueue) forceNextSafeAttributes(ctx context.Context) error {
if
eq
.
safeAttributes
==
nil
{
if
eq
.
safeAttributes
==
nil
{
return
nil
return
nil
}
}
attrs
:=
eq
.
safeAttributes
attrs
:=
eq
.
safeAttributes
.
attributes
errType
,
err
:=
eq
.
StartPayload
(
ctx
,
eq
.
safeHead
,
attrs
,
true
)
errType
,
err
:=
eq
.
StartPayload
(
ctx
,
eq
.
safeHead
,
attrs
,
true
)
if
err
==
nil
{
if
err
==
nil
{
_
,
errType
,
err
=
eq
.
ConfirmPayload
(
ctx
)
_
,
errType
,
err
=
eq
.
ConfirmPayload
(
ctx
)
...
@@ -716,6 +726,7 @@ func (eq *EngineQueue) Reset(ctx context.Context, _ eth.L1BlockRef, _ eth.System
...
@@ -716,6 +726,7 @@ func (eq *EngineQueue) Reset(ctx context.Context, _ eth.L1BlockRef, _ eth.System
eq
.
log
.
Debug
(
"Reset engine queue"
,
"safeHead"
,
safe
,
"unsafe"
,
unsafe
,
"safe_timestamp"
,
safe
.
Time
,
"unsafe_timestamp"
,
unsafe
.
Time
,
"l1Origin"
,
l1Origin
)
eq
.
log
.
Debug
(
"Reset engine queue"
,
"safeHead"
,
safe
,
"unsafe"
,
unsafe
,
"safe_timestamp"
,
safe
.
Time
,
"unsafe_timestamp"
,
unsafe
.
Time
,
"l1Origin"
,
l1Origin
)
eq
.
unsafeHead
=
unsafe
eq
.
unsafeHead
=
unsafe
eq
.
safeHead
=
safe
eq
.
safeHead
=
safe
eq
.
safeAttributes
=
nil
eq
.
finalized
=
finalized
eq
.
finalized
=
finalized
eq
.
resetBuildingState
()
eq
.
resetBuildingState
()
eq
.
needForkchoiceUpdate
=
true
eq
.
needForkchoiceUpdate
=
true
...
...
op-node/rollup/derive/engine_queue_test.go
View file @
b59d695c
...
@@ -15,6 +15,7 @@ import (
...
@@ -15,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum-optimism/optimism/op-node/testutils"
...
@@ -1007,3 +1008,102 @@ func TestBlockBuildingRace(t *testing.T) {
...
@@ -1007,3 +1008,102 @@ func TestBlockBuildingRace(t *testing.T) {
l1F
.
AssertExpectations
(
t
)
l1F
.
AssertExpectations
(
t
)
eng
.
AssertExpectations
(
t
)
eng
.
AssertExpectations
(
t
)
}
}
func
TestResetLoop
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
Logger
(
t
,
log
.
LvlInfo
)
eng
:=
&
testutils
.
MockEngine
{}
l1F
:=
&
testutils
.
MockL1Source
{}
rng
:=
rand
.
New
(
rand
.
NewSource
(
1234
))
refA
:=
testutils
.
RandomBlockRef
(
rng
)
refA0
:=
eth
.
L2BlockRef
{
Hash
:
testutils
.
RandomHash
(
rng
),
Number
:
0
,
ParentHash
:
common
.
Hash
{},
Time
:
refA
.
Time
,
L1Origin
:
refA
.
ID
(),
SequenceNumber
:
0
,
}
gasLimit
:=
eth
.
Uint64Quantity
(
20
_000_000
)
cfg
:=
&
rollup
.
Config
{
Genesis
:
rollup
.
Genesis
{
L1
:
refA
.
ID
(),
L2
:
refA0
.
ID
(),
L2Time
:
refA0
.
Time
,
SystemConfig
:
eth
.
SystemConfig
{
BatcherAddr
:
common
.
Address
{
42
},
Overhead
:
[
32
]
byte
{
123
},
Scalar
:
[
32
]
byte
{
42
},
GasLimit
:
20
_000_000
,
},
},
BlockTime
:
1
,
SeqWindowSize
:
2
,
}
refA1
:=
eth
.
L2BlockRef
{
Hash
:
testutils
.
RandomHash
(
rng
),
Number
:
refA0
.
Number
+
1
,
ParentHash
:
refA0
.
Hash
,
Time
:
refA0
.
Time
+
cfg
.
BlockTime
,
L1Origin
:
refA
.
ID
(),
SequenceNumber
:
1
,
}
refA2
:=
eth
.
L2BlockRef
{
Hash
:
testutils
.
RandomHash
(
rng
),
Number
:
refA1
.
Number
+
1
,
ParentHash
:
refA1
.
Hash
,
Time
:
refA1
.
Time
+
cfg
.
BlockTime
,
L1Origin
:
refA
.
ID
(),
SequenceNumber
:
2
,
}
attrs
:=
&
eth
.
PayloadAttributes
{
Timestamp
:
eth
.
Uint64Quantity
(
refA2
.
Time
),
PrevRandao
:
eth
.
Bytes32
{},
SuggestedFeeRecipient
:
common
.
Address
{},
Transactions
:
nil
,
NoTxPool
:
false
,
GasLimit
:
&
gasLimit
,
}
eng
.
ExpectL2BlockRefByLabel
(
eth
.
Finalized
,
refA0
,
nil
)
eng
.
ExpectL2BlockRefByLabel
(
eth
.
Safe
,
refA1
,
nil
)
eng
.
ExpectL2BlockRefByLabel
(
eth
.
Unsafe
,
refA2
,
nil
)
eng
.
ExpectL2BlockRefByHash
(
refA1
.
Hash
,
refA1
,
nil
)
eng
.
ExpectL2BlockRefByHash
(
refA0
.
Hash
,
refA0
,
nil
)
eng
.
ExpectSystemConfigByL2Hash
(
refA0
.
Hash
,
cfg
.
Genesis
.
SystemConfig
,
nil
)
l1F
.
ExpectL1BlockRefByNumber
(
refA
.
Number
,
refA
,
nil
)
l1F
.
ExpectL1BlockRefByHash
(
refA
.
Hash
,
refA
,
nil
)
l1F
.
ExpectL1BlockRefByHash
(
refA
.
Hash
,
refA
,
nil
)
prev
:=
&
fakeAttributesQueue
{
origin
:
refA
,
attrs
:
attrs
}
eq
:=
NewEngineQueue
(
logger
,
cfg
,
eng
,
metrics
.
NoopMetrics
,
prev
,
l1F
)
eq
.
unsafeHead
=
refA2
eq
.
safeHead
=
refA1
eq
.
finalized
=
refA0
// Qeueue up the safe attributes
require
.
Nil
(
t
,
eq
.
safeAttributes
)
require
.
ErrorIs
(
t
,
eq
.
Step
(
context
.
Background
()),
NotEnoughData
)
require
.
NotNil
(
t
,
eq
.
safeAttributes
)
// Peform the reset
require
.
ErrorIs
(
t
,
eq
.
Reset
(
context
.
Background
(),
eth
.
L1BlockRef
{},
eth
.
SystemConfig
{}),
io
.
EOF
)
// Expect a FCU after the reset
preFc
:=
&
eth
.
ForkchoiceState
{
HeadBlockHash
:
refA2
.
Hash
,
SafeBlockHash
:
refA0
.
Hash
,
FinalizedBlockHash
:
refA0
.
Hash
,
}
eng
.
ExpectForkchoiceUpdate
(
preFc
,
nil
,
nil
,
nil
)
require
.
NoError
(
t
,
eq
.
Step
(
context
.
Background
()),
"clean forkchoice state after reset"
)
// Crux of the test. Should be in a valid state after the reset.
require
.
ErrorIs
(
t
,
eq
.
Step
(
context
.
Background
()),
NotEnoughData
,
"Should be able to step after a reset"
)
l1F
.
AssertExpectations
(
t
)
eng
.
AssertExpectations
(
t
)
}
op-node/testutils/mock_eth_client.go
View file @
b59d695c
...
@@ -83,8 +83,8 @@ func (m *MockEthClient) PayloadByNumber(ctx context.Context, n uint64) (*eth.Exe
...
@@ -83,8 +83,8 @@ func (m *MockEthClient) PayloadByNumber(ctx context.Context, n uint64) (*eth.Exe
return
out
[
0
]
.
(
*
eth
.
ExecutionPayload
),
*
out
[
1
]
.
(
*
error
)
return
out
[
0
]
.
(
*
eth
.
ExecutionPayload
),
*
out
[
1
]
.
(
*
error
)
}
}
func
(
m
*
MockEthClient
)
ExpectPayloadByNumber
(
hash
common
.
Hash
,
payload
*
eth
.
ExecutionPayload
,
err
error
)
{
func
(
m
*
MockEthClient
)
ExpectPayloadByNumber
(
n
uint64
,
payload
*
eth
.
ExecutionPayload
,
err
error
)
{
m
.
Mock
.
On
(
"PayloadByNumber"
,
hash
)
.
Once
()
.
Return
(
payload
,
&
err
)
m
.
Mock
.
On
(
"PayloadByNumber"
,
n
)
.
Once
()
.
Return
(
payload
,
&
err
)
}
}
func
(
m
*
MockEthClient
)
PayloadByLabel
(
ctx
context
.
Context
,
label
eth
.
BlockLabel
)
(
*
eth
.
ExecutionPayload
,
error
)
{
func
(
m
*
MockEthClient
)
PayloadByLabel
(
ctx
context
.
Context
,
label
eth
.
BlockLabel
)
(
*
eth
.
ExecutionPayload
,
error
)
{
...
...
op-proposer/cmd/doc/cmd.go
0 → 100644
View file @
b59d695c
package
doc
import
(
"encoding/json"
"fmt"
"os"
"strings"
"github.com/ethereum-optimism/optimism/op-proposer/metrics"
"github.com/olekukonko/tablewriter"
"github.com/urfave/cli"
)
var
Subcommands
=
cli
.
Commands
{
{
Name
:
"metrics"
,
Usage
:
"Dumps a list of supported metrics to stdout"
,
Flags
:
[]
cli
.
Flag
{
cli
.
StringFlag
{
Name
:
"format"
,
Value
:
"markdown"
,
Usage
:
"Output format (json|markdown)"
,
},
},
Action
:
func
(
ctx
*
cli
.
Context
)
error
{
m
:=
metrics
.
NewMetrics
(
"default"
)
supportedMetrics
:=
m
.
Document
()
format
:=
ctx
.
String
(
"format"
)
if
format
!=
"markdown"
&&
format
!=
"json"
{
return
fmt
.
Errorf
(
"invalid format: %s"
,
format
)
}
if
format
==
"json"
{
enc
:=
json
.
NewEncoder
(
os
.
Stdout
)
return
enc
.
Encode
(
supportedMetrics
)
}
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
table
.
SetBorders
(
tablewriter
.
Border
{
Left
:
true
,
Top
:
false
,
Right
:
true
,
Bottom
:
false
})
table
.
SetCenterSeparator
(
"|"
)
table
.
SetAutoWrapText
(
false
)
table
.
SetHeader
([]
string
{
"Metric"
,
"Description"
,
"Labels"
,
"Type"
})
var
data
[][]
string
for
_
,
metric
:=
range
supportedMetrics
{
labels
:=
strings
.
Join
(
metric
.
Labels
,
","
)
data
=
append
(
data
,
[]
string
{
metric
.
Name
,
metric
.
Help
,
labels
,
metric
.
Type
})
}
table
.
AppendBulk
(
data
)
table
.
Render
()
return
nil
},
},
}
op-proposer/cmd/main.go
View file @
b59d695c
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"github.com/urfave/cli"
"github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-proposer/cmd/doc"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
...
@@ -27,8 +28,14 @@ func main() {
...
@@ -27,8 +28,14 @@ func main() {
app
.
Name
=
"op-proposer"
app
.
Name
=
"op-proposer"
app
.
Usage
=
"L2Output Submitter"
app
.
Usage
=
"L2Output Submitter"
app
.
Description
=
"Service for generating and submitting L2 Output checkpoints to the L2OutputOracle contract"
app
.
Description
=
"Service for generating and submitting L2 Output checkpoints to the L2OutputOracle contract"
app
.
Action
=
curryMain
(
Version
)
app
.
Action
=
curryMain
(
Version
)
app
.
Commands
=
[]
cli
.
Command
{
{
Name
:
"doc"
,
Subcommands
:
doc
.
Subcommands
,
},
}
err
:=
app
.
Run
(
os
.
Args
)
err
:=
app
.
Run
(
os
.
Args
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Crit
(
"Application failed"
,
"message"
,
err
)
log
.
Crit
(
"Application failed"
,
"message"
,
err
)
...
...
op-proposer/flags/flags.go
View file @
b59d695c
package
flags
package
flags
import
(
import
(
"fmt"
"github.com/urfave/cli"
"github.com/urfave/cli"
opservice
"github.com/ethereum-optimism/optimism/op-service"
opservice
"github.com/ethereum-optimism/optimism/op-service"
...
@@ -16,29 +18,25 @@ const envVarPrefix = "OP_PROPOSER"
...
@@ -16,29 +18,25 @@ const envVarPrefix = "OP_PROPOSER"
var
(
var
(
// Required Flags
// Required Flags
L1EthRpcFlag
=
cli
.
StringFlag
{
L1EthRpcFlag
=
cli
.
StringFlag
{
Name
:
"l1-eth-rpc"
,
Name
:
"l1-eth-rpc"
,
Usage
:
"HTTP provider URL for L1"
,
Usage
:
"HTTP provider URL for L1"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L1_ETH_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L1_ETH_RPC"
),
}
}
RollupRpcFlag
=
cli
.
StringFlag
{
RollupRpcFlag
=
cli
.
StringFlag
{
Name
:
"rollup-rpc"
,
Name
:
"rollup-rpc"
,
Usage
:
"HTTP provider URL for the rollup node"
,
Usage
:
"HTTP provider URL for the rollup node"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"ROLLUP_RPC"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"ROLLUP_RPC"
),
}
}
L2OOAddressFlag
=
cli
.
StringFlag
{
L2OOAddressFlag
=
cli
.
StringFlag
{
Name
:
"l2oo-address"
,
Name
:
"l2oo-address"
,
Usage
:
"Address of the L2OutputOracle contract"
,
Usage
:
"Address of the L2OutputOracle contract"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L2OO_ADDRESS"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"L2OO_ADDRESS"
),
}
}
PollIntervalFlag
=
cli
.
DurationFlag
{
PollIntervalFlag
=
cli
.
DurationFlag
{
Name
:
"poll-interval"
,
Name
:
"poll-interval"
,
Usage
:
"Delay between querying L2 for more transactions and "
+
Usage
:
"Delay between querying L2 for more transactions and "
+
"creating a new batch"
,
"creating a new batch"
,
Required
:
true
,
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"POLL_INTERVAL"
),
EnvVar
:
opservice
.
PrefixEnvVar
(
envVarPrefix
,
"POLL_INTERVAL"
),
}
}
// Optional flags
// Optional flags
AllowNonFinalizedFlag
=
cli
.
BoolFlag
{
AllowNonFinalizedFlag
=
cli
.
BoolFlag
{
...
@@ -74,3 +72,12 @@ func init() {
...
@@ -74,3 +72,12 @@ func init() {
// Flags contains the list of configuration options available to the binary.
// Flags contains the list of configuration options available to the binary.
var
Flags
[]
cli
.
Flag
var
Flags
[]
cli
.
Flag
func
CheckRequired
(
ctx
*
cli
.
Context
)
error
{
for
_
,
f
:=
range
requiredFlags
{
if
!
ctx
.
GlobalIsSet
(
f
.
GetName
())
{
return
fmt
.
Errorf
(
"flag %s is required"
,
f
.
GetName
())
}
}
return
nil
}
op-proposer/metrics/metrics.go
View file @
b59d695c
...
@@ -104,3 +104,7 @@ const (
...
@@ -104,3 +104,7 @@ const (
func
(
m
*
Metrics
)
RecordL2BlocksProposed
(
l2ref
eth
.
L2BlockRef
)
{
func
(
m
*
Metrics
)
RecordL2BlocksProposed
(
l2ref
eth
.
L2BlockRef
)
{
m
.
RecordL2Ref
(
BlockProposed
,
l2ref
)
m
.
RecordL2Ref
(
BlockProposed
,
l2ref
)
}
}
func
(
m
*
Metrics
)
Document
()
[]
opmetrics
.
DocumentedMetric
{
return
m
.
factory
.
Document
()
}
op-service/txmgr/metrics/tx_metrics.go
View file @
b59d695c
...
@@ -85,7 +85,7 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
...
@@ -85,7 +85,7 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
txPublishError
:
factory
.
NewCounterVec
(
prometheus
.
CounterOpts
{
txPublishError
:
factory
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"tx_publish_error_count"
,
Name
:
"tx_publish_error_count"
,
Help
:
"Count of publish errors. Label
l
s are sanitized error strings"
,
Help
:
"Count of publish errors. Labels are sanitized error strings"
,
Subsystem
:
"txmgr"
,
Subsystem
:
"txmgr"
,
},
[]
string
{
"error"
}),
},
[]
string
{
"error"
}),
confirmEvent
:
metrics
.
NewEventVec
(
factory
,
ns
,
"txmgr"
,
"confirm"
,
"tx confirm"
,
[]
string
{
"status"
}),
confirmEvent
:
metrics
.
NewEventVec
(
factory
,
ns
,
"txmgr"
,
"confirm"
,
"tx confirm"
,
[]
string
{
"status"
}),
...
@@ -93,7 +93,7 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
...
@@ -93,7 +93,7 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
rpcError
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
rpcError
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"rpc_error_count"
,
Name
:
"rpc_error_count"
,
Help
:
"Tempor
rary: Count of RPC errors (like timeouts) that have occur
rred"
,
Help
:
"Tempor
ary: Count of RPC errors (like timeouts) that have occu
rred"
,
Subsystem
:
"txmgr"
,
Subsystem
:
"txmgr"
,
}),
}),
}
}
...
...
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