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
101ab218
Commit
101ab218
authored
May 31, 2023
by
Joshua Gutow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-batcher: Add metrics for pending L2 transaction data size
parent
129032f1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
2 deletions
+49
-2
channel_manager.go
op-batcher/batcher/channel_manager.go
+3
-0
metrics.go
op-batcher/metrics/metrics.go
+43
-2
noop.go
op-batcher/metrics/noop.go
+3
-0
No files found.
op-batcher/batcher/channel_manager.go
View file @
101ab218
...
@@ -228,6 +228,7 @@ func (s *channelManager) processBlocks() error {
...
@@ -228,6 +228,7 @@ func (s *channelManager) processBlocks() error {
}
}
blocksAdded
+=
1
blocksAdded
+=
1
latestL2ref
=
l2BlockRefFromBlockAndL1Info
(
block
,
l1info
)
latestL2ref
=
l2BlockRefFromBlockAndL1Info
(
block
,
l1info
)
s
.
metr
.
RecordL2BlockInChannel
(
block
)
// current block got added but channel is now full
// current block got added but channel is now full
if
s
.
currentChannel
.
IsFull
()
{
if
s
.
currentChannel
.
IsFull
()
{
break
break
...
@@ -298,6 +299,8 @@ func (s *channelManager) AddL2Block(block *types.Block) error {
...
@@ -298,6 +299,8 @@ func (s *channelManager) AddL2Block(block *types.Block) error {
if
s
.
tip
!=
(
common
.
Hash
{})
&&
s
.
tip
!=
block
.
ParentHash
()
{
if
s
.
tip
!=
(
common
.
Hash
{})
&&
s
.
tip
!=
block
.
ParentHash
()
{
return
ErrReorg
return
ErrReorg
}
}
s
.
metr
.
RecordL2BlockInPendingQueue
(
block
)
s
.
blocks
=
append
(
s
.
blocks
,
block
)
s
.
blocks
=
append
(
s
.
blocks
,
block
)
s
.
tip
=
block
.
Hash
()
s
.
tip
=
block
.
Hash
()
...
...
op-batcher/metrics/metrics.go
View file @
101ab218
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus"
...
@@ -30,6 +31,8 @@ type Metricer interface {
...
@@ -30,6 +31,8 @@ type Metricer interface {
RecordL2BlocksLoaded
(
l2ref
eth
.
L2BlockRef
)
RecordL2BlocksLoaded
(
l2ref
eth
.
L2BlockRef
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
RecordChannelOpened
(
id
derive
.
ChannelID
,
numPendingBlocks
int
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
RecordL2BlocksAdded
(
l2ref
eth
.
L2BlockRef
,
numBlocksAdded
,
numPendingBlocks
,
inputBytes
,
outputComprBytes
int
)
RecordL2BlockInPendingQueue
(
block
*
types
.
Block
)
RecordL2BlockInChannel
(
block
*
types
.
Block
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
RecordChannelClosed
(
id
derive
.
ChannelID
,
numPendingBlocks
int
,
numFrames
int
,
inputBytes
int
,
outputComprBytes
int
,
reason
error
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
RecordChannelFullySubmitted
(
id
derive
.
ChannelID
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
RecordChannelTimedOut
(
id
derive
.
ChannelID
)
...
@@ -56,6 +59,8 @@ type Metrics struct {
...
@@ -56,6 +59,8 @@ type Metrics struct {
channelEvs
opmetrics
.
EventVec
channelEvs
opmetrics
.
EventVec
pendingBlocksCount
prometheus
.
GaugeVec
pendingBlocksCount
prometheus
.
GaugeVec
pendingBlocksBytesTotal
prometheus
.
Counter
pendingBlocksBytesCurrent
prometheus
.
Gauge
blocksAddedCount
prometheus
.
Gauge
blocksAddedCount
prometheus
.
Gauge
channelInputBytes
prometheus
.
GaugeVec
channelInputBytes
prometheus
.
GaugeVec
...
@@ -109,6 +114,16 @@ func NewMetrics(procName string) *Metrics {
...
@@ -109,6 +114,16 @@ func NewMetrics(procName string) *Metrics {
Name
:
"pending_blocks_count"
,
Name
:
"pending_blocks_count"
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
Help
:
"Number of pending blocks, not added to a channel yet."
,
},
[]
string
{
"stage"
}),
},
[]
string
{
"stage"
}),
pendingBlocksBytesTotal
:
factory
.
NewCounter
(
prometheus
.
CounterOpts
{
Namespace
:
ns
,
Name
:
"pending_blocks_bytes_total"
,
Help
:
"Total size of transactions in pending blocks as they are fetched from L2"
,
}),
pendingBlocksBytesCurrent
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Name
:
"pending_blocks_bytes_current"
,
Help
:
"Current size of transactions in the pending (fetched from L2 but not in a channel) stage."
,
}),
blocksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
blocksAddedCount
:
factory
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
ns
,
Namespace
:
ns
,
Name
:
"blocks_added_count"
,
Name
:
"blocks_added_count"
,
...
@@ -243,6 +258,18 @@ func (m *Metrics) RecordChannelClosed(id derive.ChannelID, numPendingBlocks int,
...
@@ -243,6 +258,18 @@ func (m *Metrics) RecordChannelClosed(id derive.ChannelID, numPendingBlocks int,
m
.
channelClosedReason
.
Set
(
float64
(
ClosedReasonToNum
(
reason
)))
m
.
channelClosedReason
.
Set
(
float64
(
ClosedReasonToNum
(
reason
)))
}
}
func
(
m
*
Metrics
)
RecordL2BlockInPendingQueue
(
block
*
types
.
Block
)
{
size
:=
float64
(
estimateBatchSize
(
block
))
m
.
pendingBlocksBytesTotal
.
Add
(
size
)
m
.
pendingBlocksBytesCurrent
.
Add
(
size
)
}
func
(
m
*
Metrics
)
RecordL2BlockInChannel
(
block
*
types
.
Block
)
{
size
:=
float64
(
estimateBatchSize
(
block
))
m
.
pendingBlocksBytesCurrent
.
Add
(
-
1
*
size
)
// Refer to RecordL2BlocksAdded to see the current + count of bytes added to a channel
}
func
ClosedReasonToNum
(
reason
error
)
int
{
func
ClosedReasonToNum
(
reason
error
)
int
{
// CLI-3640
// CLI-3640
return
0
return
0
...
@@ -267,3 +294,17 @@ func (m *Metrics) RecordBatchTxSuccess() {
...
@@ -267,3 +294,17 @@ func (m *Metrics) RecordBatchTxSuccess() {
func
(
m
*
Metrics
)
RecordBatchTxFailed
()
{
func
(
m
*
Metrics
)
RecordBatchTxFailed
()
{
m
.
batcherTxEvs
.
Record
(
TxStageFailed
)
m
.
batcherTxEvs
.
Record
(
TxStageFailed
)
}
}
// estimateBatchSize estimates the size of the batch
func
estimateBatchSize
(
block
*
types
.
Block
)
uint64
{
size
:=
uint64
(
70
)
// estimated overhead of batch metadata
for
_
,
tx
:=
range
block
.
Transactions
()
{
// Don't include deposit transactions in the batch.
if
tx
.
IsDepositTx
()
{
continue
}
// Add 2 for the overhead of encoding the tx bytes in a RLP list
size
+=
tx
.
Size
()
+
2
}
return
size
}
op-batcher/metrics/noop.go
View file @
101ab218
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
opmetrics
"github.com/ethereum-optimism/optimism/op-service/metrics"
opmetrics
"github.com/ethereum-optimism/optimism/op-service/metrics"
txmetrics
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
txmetrics
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
"github.com/ethereum/go-ethereum/core/types"
)
)
type
noopMetrics
struct
{
type
noopMetrics
struct
{
...
@@ -23,6 +24,8 @@ func (*noopMetrics) RecordLatestL1Block(l1ref eth.L1BlockRef) {}
...
@@ -23,6 +24,8 @@ func (*noopMetrics) RecordLatestL1Block(l1ref eth.L1BlockRef) {}
func
(
*
noopMetrics
)
RecordL2BlocksLoaded
(
eth
.
L2BlockRef
)
{}
func
(
*
noopMetrics
)
RecordL2BlocksLoaded
(
eth
.
L2BlockRef
)
{}
func
(
*
noopMetrics
)
RecordChannelOpened
(
derive
.
ChannelID
,
int
)
{}
func
(
*
noopMetrics
)
RecordChannelOpened
(
derive
.
ChannelID
,
int
)
{}
func
(
*
noopMetrics
)
RecordL2BlocksAdded
(
eth
.
L2BlockRef
,
int
,
int
,
int
,
int
)
{}
func
(
*
noopMetrics
)
RecordL2BlocksAdded
(
eth
.
L2BlockRef
,
int
,
int
,
int
,
int
)
{}
func
(
*
noopMetrics
)
RecordL2BlockInPendingQueue
(
*
types
.
Block
)
{}
func
(
*
noopMetrics
)
RecordL2BlockInChannel
(
*
types
.
Block
)
{}
func
(
*
noopMetrics
)
RecordChannelClosed
(
derive
.
ChannelID
,
int
,
int
,
int
,
int
,
error
)
{}
func
(
*
noopMetrics
)
RecordChannelClosed
(
derive
.
ChannelID
,
int
,
int
,
int
,
int
,
error
)
{}
...
...
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