diff --git a/yarn-project/prover-node/src/metrics.ts b/yarn-project/prover-node/src/metrics.ts index f4a6f2ceefae..fe5a21bda55f 100644 --- a/yarn-project/prover-node/src/metrics.ts +++ b/yarn-project/prover-node/src/metrics.ts @@ -26,6 +26,7 @@ export class ProverNodeMetrics { txCalldataGas: Histogram; txBlobDataGasUsed: Histogram; txBlobDataGasCost: Histogram; + txTotalFee: Histogram; private senderBalance: Gauge; @@ -100,6 +101,17 @@ export class ProverNodeMetrics { valueType: ValueType.INT, }); + this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, { + description: 'How much L1 tx costs', + unit: 'gwei', + valueType: ValueType.DOUBLE, + advice: { + explicitBucketBoundaries: [ + 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2, + ], + }, + }); + this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, { unit: 'eth', description: 'The balance of the sender address', @@ -160,5 +172,15 @@ export class ProverNodeMetrics { } catch (e) { // ignore } + + const executionFee = stats.gasUsed * stats.gasPrice; + const blobFee = stats.blobGasUsed * stats.blobDataGas; + const totalFee = executionFee + blobFee; + + try { + this.txTotalFee.record(parseFloat(formatEther(totalFee))); + } catch (e) { + // ignore + } } } diff --git a/yarn-project/sequencer-client/src/publisher/sequencer-publisher-metrics.ts b/yarn-project/sequencer-client/src/publisher/sequencer-publisher-metrics.ts index 9e0861437837..66f41cb588be 100644 --- a/yarn-project/sequencer-client/src/publisher/sequencer-publisher-metrics.ts +++ b/yarn-project/sequencer-client/src/publisher/sequencer-publisher-metrics.ts @@ -24,6 +24,7 @@ export class SequencerPublisherMetrics { private txCalldataGas: Histogram; private txBlobDataGasUsed: Histogram; private txBlobDataGasCost: Histogram; + private txTotalFee: Histogram; private readonly blobCountHistogram: Histogram; private readonly blobInclusionBlocksHistogram: Histogram; @@ -105,6 +106,17 @@ export class SequencerPublisherMetrics { description: 'Number of failed L1 transactions with blobs', }); + this.txTotalFee = meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE, { + description: 'How much L1 tx costs', + unit: 'eth', + valueType: ValueType.DOUBLE, + advice: { + explicitBucketBoundaries: [ + 0.001, 0.002, 0.004, 0.008, 0.01, 0.02, 0.04, 0.08, 0.1, 0.2, 0.4, 0.8, 1, 1.2, 1.4, 1.8, 2, + ], + }, + }); + this.senderBalance = meter.createGauge(Metrics.L1_PUBLISHER_BALANCE, { unit: 'eth', description: 'The balance of the sender address', @@ -172,5 +184,15 @@ export class SequencerPublisherMetrics { } catch (e) { // ignore } + + const executionFee = stats.gasUsed * stats.gasPrice; + const blobFee = stats.blobGasUsed * stats.blobDataGas; + const totalFee = executionFee + blobFee; + + try { + this.txTotalFee.record(parseFloat(formatEther(totalFee))); + } catch (e) { + // ignore + } } } diff --git a/yarn-project/telemetry-client/src/metrics.ts b/yarn-project/telemetry-client/src/metrics.ts index 6b854a0f0afd..ac89da2e7b4d 100644 --- a/yarn-project/telemetry-client/src/metrics.ts +++ b/yarn-project/telemetry-client/src/metrics.ts @@ -70,6 +70,7 @@ export const L1_PUBLISHER_BLOB_INCLUSION_BLOCKS = 'aztec.l1_publisher.blob_inclu 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 L1_PUBLISHER_BALANCE = 'aztec.l1_publisher.balance'; +export const L1_PUBLISHER_TX_TOTAL_FEE = 'aztec.l1_publisher.tx_total_fee'; export const L1_BLOCK_HEIGHT = 'aztec.l1.block_height'; export const L1_BALANCE_ETH = 'aztec.l1.balance';