Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit b7ebf6d

Browse files
authored
Add l2block/interval metrics. Use timeoutCond when waiting for worker readyTxs (#3380) (#3394)
1 parent 7ab2507 commit b7ebf6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+411
-1827
lines changed

config/config_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ func Test_Defaults(t *testing.T) {
129129
path: "Sequencer.Finalizer.BatchMaxDeltaTimestamp",
130130
expectedValue: types.NewDuration(10 * time.Second),
131131
},
132+
{
133+
path: "Sequencer.Finalizer.Metrics.Interval",
134+
expectedValue: types.NewDuration(60 * time.Minute),
135+
},
136+
{
137+
path: "Sequencer.Finalizer.Metrics.EnableLog",
138+
expectedValue: true,
139+
},
132140
{
133141
path: "Sequencer.StreamServer.Port",
134142
expectedValue: uint16(0),

config/default.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ StateConsistencyCheckInterval = "5s"
141141
HaltOnBatchNumber = 0
142142
SequentialBatchSanityCheck = false
143143
SequentialProcessL2Block = true
144+
[Sequencer.Finalizer.Metrics]
145+
Interval = "60m"
146+
EnableLog = true
144147
[Sequencer.StreamServer]
145148
Port = 0
146149
Filename = ""

config/environments/local/local.node.config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ StateConsistencyCheckInterval = "5s"
103103
HaltOnBatchNumber = 0
104104
SequentialBatchSanityCheck = false
105105
SequentialProcessL2Block = true
106+
[Sequencer.Finalizer.Metrics]
107+
Interval = "60m"
108+
EnableLog = true
106109
[Sequencer.StreamServer]
107110
Port = 0
108111
Filename = ""

docs/config-file/node-config-doc.html

Lines changed: 3 additions & 1 deletion
Large diffs are not rendered by default.

docs/config-file/node-config-doc.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,7 @@ StateConsistencyCheckInterval="5s"
19111911
| - [HaltOnBatchNumber](#Sequencer_Finalizer_HaltOnBatchNumber ) | No | integer | No | - | HaltOnBatchNumber specifies the batch number where the Sequencer will stop to process more transactions and generate new batches.<br />The Sequencer will halt after it closes the batch equal to this number |
19121912
| - [SequentialBatchSanityCheck](#Sequencer_Finalizer_SequentialBatchSanityCheck ) | No | boolean | No | - | SequentialBatchSanityCheck indicates if the reprocess of a closed batch (sanity check) must be done in a<br />sequential way (instead than in parallel) |
19131913
| - [SequentialProcessL2Block](#Sequencer_Finalizer_SequentialProcessL2Block ) | No | boolean | No | - | SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead<br />in the processPendingL2Blocks go func |
1914+
| - [Metrics](#Sequencer_Finalizer_Metrics ) | No | object | No | - | Metrics is the config for the sequencer metrics |
19141915

19151916
#### <a name="Sequencer_Finalizer_ForcedBatchesTimeout"></a>10.7.1. `Sequencer.Finalizer.ForcedBatchesTimeout`
19161917

@@ -2155,6 +2156,56 @@ in the processPendingL2Blocks go func
21552156
SequentialProcessL2Block=true
21562157
```
21572158

2159+
#### <a name="Sequencer_Finalizer_Metrics"></a>10.7.13. `[Sequencer.Finalizer.Metrics]`
2160+
2161+
**Type:** : `object`
2162+
**Description:** Metrics is the config for the sequencer metrics
2163+
2164+
| Property | Pattern | Type | Deprecated | Definition | Title/Description |
2165+
| ------------------------------------------------------ | ------- | ------- | ---------- | ---------- | -------------------------------------------------- |
2166+
| - [Interval](#Sequencer_Finalizer_Metrics_Interval ) | No | string | No | - | Duration |
2167+
| - [EnableLog](#Sequencer_Finalizer_Metrics_EnableLog ) | No | boolean | No | - | EnableLog is a flag to enable/disable metrics logs |
2168+
2169+
##### <a name="Sequencer_Finalizer_Metrics_Interval"></a>10.7.13.1. `Sequencer.Finalizer.Metrics.Interval`
2170+
2171+
**Title:** Duration
2172+
2173+
**Type:** : `string`
2174+
2175+
**Default:** `"1h0m0s"`
2176+
2177+
**Description:** Interval is the interval of time to calculate sequencer metrics
2178+
2179+
**Examples:**
2180+
2181+
```json
2182+
"1m"
2183+
```
2184+
2185+
```json
2186+
"300ms"
2187+
```
2188+
2189+
**Example setting the default value** ("1h0m0s"):
2190+
```
2191+
[Sequencer.Finalizer.Metrics]
2192+
Interval="1h0m0s"
2193+
```
2194+
2195+
##### <a name="Sequencer_Finalizer_Metrics_EnableLog"></a>10.7.13.2. `Sequencer.Finalizer.Metrics.EnableLog`
2196+
2197+
**Type:** : `boolean`
2198+
2199+
**Default:** `true`
2200+
2201+
**Description:** EnableLog is a flag to enable/disable metrics logs
2202+
2203+
**Example setting the default value** (true):
2204+
```
2205+
[Sequencer.Finalizer.Metrics]
2206+
EnableLog=true
2207+
```
2208+
21582209
### <a name="Sequencer_StreamServer"></a>10.8. `[Sequencer.StreamServer]`
21592210

21602211
**Type:** : `object`

docs/config-file/node-config-schema.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,28 @@
800800
"type": "boolean",
801801
"description": "SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead\nin the processPendingL2Blocks go func",
802802
"default": true
803+
},
804+
"Metrics": {
805+
"properties": {
806+
"Interval": {
807+
"type": "string",
808+
"title": "Duration",
809+
"description": "Interval is the interval of time to calculate sequencer metrics",
810+
"default": "1h0m0s",
811+
"examples": [
812+
"1m",
813+
"300ms"
814+
]
815+
},
816+
"EnableLog": {
817+
"type": "boolean",
818+
"description": "EnableLog is a flag to enable/disable metrics logs",
819+
"default": true
820+
}
821+
},
822+
"additionalProperties": false,
823+
"type": "object",
824+
"description": "Metrics is the config for the sequencer metrics"
803825
}
804826
},
805827
"additionalProperties": false,

sequencer/batch.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/0xPolygonHermez/zkevm-node/event"
1010
"github.com/0xPolygonHermez/zkevm-node/hex"
1111
"github.com/0xPolygonHermez/zkevm-node/log"
12-
"github.com/0xPolygonHermez/zkevm-node/sequencer/metrics"
1312
"github.com/0xPolygonHermez/zkevm-node/state"
1413
stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics"
1514
"github.com/ethereum/go-ethereum/common"
@@ -145,11 +144,6 @@ func (f *finalizer) initWIPBatch(ctx context.Context) {
145144

146145
// finalizeWIPBatch closes the current batch and opens a new one, potentially processing forced batches between the batch is closed and the resulting new empty batch
147146
func (f *finalizer) finalizeWIPBatch(ctx context.Context, closeReason state.ClosingReason) {
148-
start := time.Now()
149-
defer func() {
150-
metrics.ProcessingTime(time.Since(start))
151-
}()
152-
153147
prevTimestamp := f.wipL2Block.timestamp
154148
prevL1InfoTreeIndex := f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex
155149

@@ -185,7 +179,6 @@ func (f *finalizer) closeAndOpenNewWIPBatch(ctx context.Context, closeReason sta
185179
startWait := time.Now()
186180
f.pendingL2BlocksToProcessWG.Wait()
187181
elapsed := time.Since(startWait)
188-
stateMetrics.ExecutorProcessingTime(string(stateMetrics.SequencerCallerLabel), elapsed)
189182
log.Debugf("waiting for pending L2 blocks to be processed took: %v", elapsed)
190183

191184
// Wait until all L2 blocks are store
@@ -370,11 +363,6 @@ func (f *finalizer) batchSanityCheck(ctx context.Context, batchNum uint64, initi
370363
return nil, ErrGetBatchByNumber
371364
}
372365

373-
caller := stateMetrics.DiscardCallerLabel
374-
if f.cfg.SequentialBatchSanityCheck {
375-
caller = stateMetrics.SequencerCallerLabel
376-
}
377-
378366
batchRequest := state.ProcessRequest{
379367
BatchNumber: batch.BatchNumber,
380368
L1InfoRoot_V2: state.GetMockL1InfoRoot(),
@@ -384,7 +372,7 @@ func (f *finalizer) batchSanityCheck(ctx context.Context, batchNum uint64, initi
384372
TimestampLimit_V2: uint64(time.Now().Unix()),
385373
ForkID: f.stateIntf.GetForkIDByBatchNumber(batch.BatchNumber),
386374
SkipVerifyL1InfoRoot_V2: true,
387-
Caller: caller,
375+
Caller: stateMetrics.DiscardCallerLabel,
388376
}
389377
batchRequest.L1InfoTreeData_V2, _, _, err = f.stateIntf.GetL1InfoTreeDataFromBatchL2Data(ctx, batch.BatchL2Data, nil)
390378
if err != nil {

sequencer/config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,16 @@ type FinalizerCfg struct {
9090
// SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
9191
// in the processPendingL2Blocks go func
9292
SequentialProcessL2Block bool `mapstructure:"SequentialProcessL2Block"`
93+
94+
// Metrics is the config for the sequencer metrics
95+
Metrics MetricsCfg `mapstructure:"Metrics"`
96+
}
97+
98+
// MetricsCfg contains the sequencer metrics configuration properties
99+
type MetricsCfg struct {
100+
// Interval is the interval of time to calculate sequencer metrics
101+
Interval types.Duration `mapstructure:"Interval"`
102+
103+
// EnableLog is a flag to enable/disable metrics logs
104+
EnableLog bool `mapstructure:"EnableLog"`
93105
}

0 commit comments

Comments
 (0)