Skip to content

Commit ffbea65

Browse files
committed
Add Unified EL metrics for GetBlobsV2
1 parent f91bea7 commit ffbea65

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

packages/client/src/rpc/modules/engine/engine.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
payloadAttributesFieldValidatorsV3,
6464
} from './validators.ts'
6565

66+
import { blob } from 'node:stream/consumers'
6667
import type { Block, ExecutionPayload } from '@ethereumjs/block'
6768
import type { PrefixedHexString } from '@ethereumjs/util'
6869
import type { VM } from '@ethereumjs/vm'
@@ -1545,15 +1546,28 @@ export class Engine {
15451546
}
15461547
}
15471548

1549+
let blobsInPool = 0
1550+
let blobMissed = false
15481551
const blobAndProofsArr: BlobAndProofV2[] = []
15491552
for (const versionedHashHex of params[0]) {
15501553
const blobAndProofs = this.service.txPool.blobAndProofsByHash.get(versionedHashHex)
15511554
if (blobAndProofs === undefined) {
1552-
return null
1555+
blobMissed = true
1556+
} else {
1557+
blobsInPool++
1558+
blobAndProofsArr.push(blobAndProofs)
15531559
}
1554-
blobAndProofsArr.push(blobAndProofs)
15551560
}
15561561

1562+
this.config.metrics?.blobEIP7594ReqTotalGauge.inc(params[0].length)
1563+
this.config.metrics?.blobEIP7594ReqTotalInPoolGauge.inc(blobsInPool)
1564+
1565+
if (blobMissed) {
1566+
this.config.metrics?.blobEIP7594PoolMissGauge.inc()
1567+
return null
1568+
}
1569+
1570+
this.config.metrics?.blobEIP7594PoolHitGauge.inc()
15571571
return blobAndProofsArr
15581572
}
15591573
}

packages/client/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,8 @@ export type PrometheusMetrics = {
156156
feeMarketEIP1559TxGauge: promClient.Gauge<string>
157157
blobEIP4844TxGauge: promClient.Gauge<string>
158158
blobEIP7594TxGauge: promClient.Gauge<string>
159+
blobEIP7594ReqTotalGauge: promClient.Gauge<string>
160+
blobEIP7594ReqTotalInPoolGauge: promClient.Gauge<string>
161+
blobEIP7594PoolHitGauge: promClient.Gauge<string>
162+
blobEIP7594PoolMissGauge: promClient.Gauge<string>
159163
}

packages/client/src/util/metrics.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,21 @@ export const setupMetrics = () => {
2222
name: 'blob_eip_7594_transactions_in_transaction_pool',
2323
help: 'Number of blob EIP 7594 transactions in the client transaction pool',
2424
}),
25+
blobEIP7594ReqTotalGauge: new promClient.Gauge({
26+
name: 'get_blobs_requests_blobs_total',
27+
help: 'Number of blobs requested via GetBlobsV2',
28+
}),
29+
blobEIP7594ReqTotalInPoolGauge: new promClient.Gauge({
30+
name: 'get_blobs_requests_blobs_in_blobpool_total',
31+
help: 'Number of blobs requested via GetBlobsV2 that are present in the blobpool',
32+
}),
33+
blobEIP7594PoolHitGauge: new promClient.Gauge({
34+
name: 'get_blobs_requests_success_total',
35+
help: 'Number of times GetBlobsV2 responded with a success/hit',
36+
}),
37+
blobEIP7594PoolMissGauge: new promClient.Gauge({
38+
name: 'get_blobs_requests_failure_total',
39+
help: 'Number of times GetBlobsV2 responded with a failure/miss',
40+
}),
2541
}
2642
}

packages/client/test/sync/txpool.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ const setup = () => {
6565
name: 'blob_eip_7594_transactions_in_transaction_pool',
6666
help: 'Number of blob EIP 4844 transactions in the client transaction pool',
6767
}),
68+
blobEIP7594ReqTotalGauge: new promClient.Gauge({
69+
name: 'get_blobs_requests_blobs_total',
70+
help: 'Number of blobs requested via GetBlobsV2',
71+
}),
72+
blobEIP7594ReqTotalInPoolGauge: new promClient.Gauge({
73+
name: 'get_blobs_requests_blobs_in_blobpool_total',
74+
help: 'Number of blobs requested via GetBlobsV2 that are present in the blobpool',
75+
}),
76+
blobEIP7594PoolHitGauge: new promClient.Gauge({
77+
name: 'get_blobs_requests_success_total',
78+
help: 'Number of times GetBlobsV2 responded with a success/hit',
79+
}),
80+
blobEIP7594PoolMissGauge: new promClient.Gauge({
81+
name: 'get_blobs_requests_failure_total',
82+
help: 'Number of times GetBlobsV2 responded with a failure/miss',
83+
}),
6884
}
6985

7086
const register = new promClient.Registry()

0 commit comments

Comments
 (0)