Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add l2block/interval metrics. Use timeoutCond when waiting for worker ready txs #3380

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add l2block/interval metrics. Use timeoutCond when waiting for worker…
… readyTxs
  • Loading branch information
agnusmor committed Feb 27, 2024
commit 5eeba3198664a05f5b30ac7215cf673a938d043a
8 changes: 8 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ func Test_Defaults(t *testing.T) {
path: "Sequencer.Finalizer.BatchMaxDeltaTimestamp",
expectedValue: types.NewDuration(10 * time.Second),
},
{
path: "Sequencer.Finalizer.Metrics.Interval",
expectedValue: types.NewDuration(60 * time.Minute),
},
{
path: "Sequencer.Finalizer.Metrics.EnableLog",
expectedValue: true,
},
{
path: "Sequencer.StreamServer.Port",
expectedValue: uint16(0),
Expand Down
3 changes: 3 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ StateConsistencyCheckInterval = "5s"
HaltOnBatchNumber = 0
SequentialBatchSanityCheck = false
SequentialProcessL2Block = true
[Sequencer.Finalizer.Metrics]
Interval = "60m"
EnableLog = true
[Sequencer.StreamServer]
Port = 0
Filename = ""
Expand Down
3 changes: 3 additions & 0 deletions config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ StateConsistencyCheckInterval = "5s"
HaltOnBatchNumber = 0
SequentialBatchSanityCheck = false
SequentialProcessL2Block = true
[Sequencer.Finalizer.Metrics]
Interval = "60m"
EnableLog = true
[Sequencer.StreamServer]
Port = 0
Filename = ""
Expand Down
4 changes: 3 additions & 1 deletion docs/config-file/node-config-doc.html

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions docs/config-file/node-config-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,7 @@ StateConsistencyCheckInterval="5s"
| - [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 |
| - [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) |
| - [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 |
| - [Metrics](#Sequencer_Finalizer_Metrics ) | No | object | No | - | Metrics is the config for the sequencer metrics |

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

Expand Down Expand Up @@ -2100,6 +2101,56 @@ in the processPendingL2Blocks go func
SequentialProcessL2Block=true
```

#### <a name="Sequencer_Finalizer_Metrics"></a>10.7.13. `[Sequencer.Finalizer.Metrics]`

**Type:** : `object`
**Description:** Metrics is the config for the sequencer metrics

| Property | Pattern | Type | Deprecated | Definition | Title/Description |
| ------------------------------------------------------ | ------- | ------- | ---------- | ---------- | -------------------------------------------------- |
| - [Interval](#Sequencer_Finalizer_Metrics_Interval ) | No | string | No | - | Duration |
| - [EnableLog](#Sequencer_Finalizer_Metrics_EnableLog ) | No | boolean | No | - | EnableLog is a flag to enable/disable metrics logs |

##### <a name="Sequencer_Finalizer_Metrics_Interval"></a>10.7.13.1. `Sequencer.Finalizer.Metrics.Interval`

**Title:** Duration

**Type:** : `string`

**Default:** `"1h0m0s"`

**Description:** Interval is the interval of time to calculate sequencer metrics

**Examples:**

```json
"1m"
```

```json
"300ms"
```

**Example setting the default value** ("1h0m0s"):
```
[Sequencer.Finalizer.Metrics]
Interval="1h0m0s"
```

##### <a name="Sequencer_Finalizer_Metrics_EnableLog"></a>10.7.13.2. `Sequencer.Finalizer.Metrics.EnableLog`

**Type:** : `boolean`

**Default:** `true`

**Description:** EnableLog is a flag to enable/disable metrics logs

**Example setting the default value** (true):
```
[Sequencer.Finalizer.Metrics]
EnableLog=true
```

### <a name="Sequencer_StreamServer"></a>10.8. `[Sequencer.StreamServer]`

**Type:** : `object`
Expand Down
22 changes: 22 additions & 0 deletions docs/config-file/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,28 @@
"type": "boolean",
"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",
"default": true
},
"Metrics": {
"properties": {
"Interval": {
"type": "string",
"title": "Duration",
"description": "Interval is the interval of time to calculate sequencer metrics",
"default": "1h0m0s",
"examples": [
"1m",
"300ms"
]
},
"EnableLog": {
"type": "boolean",
"description": "EnableLog is a flag to enable/disable metrics logs",
"default": true
}
},
"additionalProperties": false,
"type": "object",
"description": "Metrics is the config for the sequencer metrics"
}
},
"additionalProperties": false,
Expand Down
14 changes: 1 addition & 13 deletions sequencer/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/0xPolygonHermez/zkevm-node/event"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/sequencer/metrics"
"github.com/0xPolygonHermez/zkevm-node/state"
stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics"
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
Expand Down Expand Up @@ -145,11 +144,6 @@ func (f *finalizer) initWIPBatch(ctx context.Context) {

// 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
func (f *finalizer) finalizeWIPBatch(ctx context.Context, closeReason state.ClosingReason) {
start := time.Now()
defer func() {
metrics.ProcessingTime(time.Since(start))
}()

prevTimestamp := f.wipL2Block.timestamp
prevL1InfoTreeIndex := f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex

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

// Wait until all L2 blocks are store
Expand Down Expand Up @@ -374,11 +367,6 @@ func (f *finalizer) batchSanityCheck(ctx context.Context, batchNum uint64, initi
return nil, ErrGetBatchByNumber
}

caller := stateMetrics.DiscardCallerLabel
if f.cfg.SequentialBatchSanityCheck {
caller = stateMetrics.SequencerCallerLabel
}

batchRequest := state.ProcessRequest{
BatchNumber: batch.BatchNumber,
L1InfoRoot_V2: state.GetMockL1InfoRoot(),
Expand All @@ -388,7 +376,7 @@ func (f *finalizer) batchSanityCheck(ctx context.Context, batchNum uint64, initi
TimestampLimit_V2: uint64(time.Now().Unix()),
ForkID: f.stateIntf.GetForkIDByBatchNumber(batch.BatchNumber),
SkipVerifyL1InfoRoot_V2: true,
Caller: caller,
Caller: stateMetrics.DiscardCallerLabel,
ExecutionMode: executor.ExecutionMode0,
}
batchRequest.L1InfoTreeData_V2, _, _, err = f.stateIntf.GetL1InfoTreeDataFromBatchL2Data(ctx, batch.BatchL2Data, nil)
Expand Down
12 changes: 12 additions & 0 deletions sequencer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,16 @@ type FinalizerCfg struct {
// SequentialProcessL2Block indicates if the processing of a L2 Block must be done in the same finalizer go func instead
// in the processPendingL2Blocks go func
SequentialProcessL2Block bool `mapstructure:"SequentialProcessL2Block"`

// Metrics is the config for the sequencer metrics
Metrics MetricsCfg `mapstructure:"Metrics"`
}

// MetricsCfg contains the sequencer metrics configuration properties
type MetricsCfg struct {
// Interval is the interval of time to calculate sequencer metrics
Interval types.Duration `mapstructure:"Interval"`

// EnableLog is a flag to enable/disable metrics logs
EnableLog bool `mapstructure:"EnableLog"`
}
Loading
Loading