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

chore: blob inclusion metrics #11625

Merged
merged 2 commits into from
Jan 30, 2025
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
4 changes: 4 additions & 0 deletions yarn-project/circuit-types/src/stats/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export type L1PublishStats = {
blobDataGas: bigint;
/** Amount of blob gas used. */
blobGasUsed: bigint;
/** Number of blobs in the tx */
blobCount?: number;
/** Number of L1 blocks between tx submission and inclusion */
inclusionBlocks?: number;
};

/** Stats logged for each L1 rollup publish tx.*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class L1PublisherMetrics {
private txBlobDataGasUsed: Histogram;
private txBlobDataGasCost: Histogram;

private readonly blobCountHistogram: Histogram;
private readonly blobInclusionBlocksHistogram: Histogram;
private readonly blobTxSuccessCounter: UpDownCounter;
private readonly blobTxFailureCounter: UpDownCounter;

constructor(client: TelemetryClient, name = 'L1Publisher') {
const meter = client.getMeter(name);

Expand Down Expand Up @@ -71,13 +76,37 @@ export class L1PublisherMetrics {
unit: 'gwei',
valueType: ValueType.INT,
});

this.blobCountHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_COUNT, {
description: 'Number of blobs in L1 transactions',
unit: 'blobs',
valueType: ValueType.INT,
});

this.blobInclusionBlocksHistogram = meter.createHistogram(Metrics.L1_PUBLISHER_BLOB_INCLUSION_BLOCKS, {
description: 'Number of L1 blocks between blob tx submission and inclusion',
unit: 'blocks',
valueType: ValueType.INT,
});

this.blobTxSuccessCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_SUCCESS, {
description: 'Number of successful L1 transactions with blobs',
});

this.blobTxFailureCounter = meter.createUpDownCounter(Metrics.L1_PUBLISHER_BLOB_TX_FAILURE, {
description: 'Number of failed L1 transactions with blobs',
});
}

recordFailedTx(txType: L1TxType) {
this.txCount.add(1, {
[Attributes.L1_TX_TYPE]: txType,
[Attributes.OK]: false,
});

if (txType === 'process') {
this.blobTxFailureCounter.add(1);
}
}

recordSubmitProof(durationMs: number, stats: L1PublishProofStats) {
Expand All @@ -86,6 +115,16 @@ export class L1PublisherMetrics {

recordProcessBlockTx(durationMs: number, stats: L1PublishBlockStats) {
this.recordTx('process', durationMs, stats);

if (stats.blobCount && stats.blobCount > 0) {
this.blobCountHistogram.record(stats.blobCount);

if (stats.inclusionBlocks !== undefined) {
this.blobInclusionBlocksHistogram.record(stats.inclusionBlocks);
}

this.blobTxSuccessCounter.add(1);
}
}

recordClaimEpochProofRightTx(durationMs: number, stats: L1PublishStats) {
Expand Down
10 changes: 10 additions & 0 deletions yarn-project/sequencer-client/src/publisher/l1-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ export class L1Publisher {
txHashes: txHashes ?? [],
};

// Get current block number before sending tx
const startBlock = await this.publicClient.getBlockNumber();

// Publish body and propose block (if not already published)
if (this.interrupted) {
this.log.verbose('L2 block data syncing interrupted while processing blocks.', ctx);
Expand Down Expand Up @@ -637,6 +640,11 @@ export class L1Publisher {
});

const tx = await this.getTransactionStats(receipt.transactionHash);

// Calculate inclusion blocks
const endBlock = receipt.blockNumber;
const inclusionBlocks = Number(endBlock - startBlock);

const stats: L1PublishBlockStats = {
gasPrice: receipt.effectiveGasPrice,
gasUsed: receipt.gasUsed,
Expand All @@ -646,6 +654,8 @@ export class L1Publisher {
...pick(tx!, 'calldataGas', 'calldataSize', 'sender'),
...block.getStats(),
eventName: 'rollup-published-to-l1',
blobCount: blobs.length,
inclusionBlocks,
};
this.log.verbose(`Published L2 block to L1 rollup contract`, { ...stats, ...ctx });
this.metrics.recordProcessBlockTx(timer.ms(), stats);
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/telemetry-client/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export const L1_PUBLISHER_TX_CALLDATA_SIZE = 'aztec.l1_publisher.tx_calldata_siz
export const L1_PUBLISHER_TX_CALLDATA_GAS = 'aztec.l1_publisher.tx_calldata_gas';
export const L1_PUBLISHER_TX_BLOBDATA_GAS_USED = 'aztec.l1_publisher.tx_blobdata_gas_used';
export const L1_PUBLISHER_TX_BLOBDATA_GAS_COST = 'aztec.l1_publisher.tx_blobdata_gas_cost';
export const L1_PUBLISHER_BLOB_COUNT = 'aztec.l1_publisher.blob_count';
export const L1_PUBLISHER_BLOB_INCLUSION_BLOCKS = 'aztec.l1_publisher.blob_inclusion_blocks';
export const L1_PUBLISHER_BLOB_TX_SUCCESS = 'aztec.l1_publisher.blob_tx_success';
export const L1_PUBLISHER_BLOB_TX_FAILURE = 'aztec.l1_publisher.blob_tx_failure';

export const PEER_MANAGER_GOODBYES_SENT = 'aztec.peer_manager.goodbyes_sent';
export const PEER_MANAGER_GOODBYES_RECEIVED = 'aztec.peer_manager.goodbyes_received';
Expand Down