@aztec/prover-node 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +518 -0
- package/dest/actions/download-epoch-proving-job.d.ts +4 -4
- package/dest/actions/download-epoch-proving-job.js +1 -1
- package/dest/actions/index.d.ts +1 -1
- package/dest/actions/rerun-epoch-proving-job.d.ts +6 -4
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +191 -28
- package/dest/actions/upload-epoch-proof-failure.d.ts +2 -2
- package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -1
- package/dest/bin/run-failed-epoch.d.ts +1 -1
- package/dest/bin/run-failed-epoch.js +6 -5
- package/dest/checkpoint-store.d.ts +87 -0
- package/dest/checkpoint-store.d.ts.map +1 -0
- package/dest/checkpoint-store.js +186 -0
- package/dest/config.d.ts +10 -10
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +27 -22
- package/dest/factory.d.ts +23 -16
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +49 -68
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/job/checkpoint-prover.d.ts +134 -0
- package/dest/job/checkpoint-prover.d.ts.map +1 -0
- package/dest/job/checkpoint-prover.js +353 -0
- package/dest/job/epoch-proving-job-data.d.ts +8 -6
- package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
- package/dest/job/epoch-proving-job-data.js +25 -18
- package/dest/job/epoch-session.d.ts +146 -0
- package/dest/job/epoch-session.d.ts.map +1 -0
- package/dest/job/epoch-session.js +720 -0
- package/dest/job/top-tree-job.d.ts +82 -0
- package/dest/job/top-tree-job.d.ts.map +1 -0
- package/dest/job/top-tree-job.js +152 -0
- package/dest/metrics.d.ts +42 -4
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +128 -99
- package/dest/monitors/epoch-monitor.d.ts +3 -2
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +14 -20
- package/dest/monitors/index.d.ts +1 -1
- package/dest/proof-publishing-service.d.ts +161 -0
- package/dest/proof-publishing-service.d.ts.map +1 -0
- package/dest/proof-publishing-service.js +335 -0
- package/dest/prover-node-publisher.d.ts +36 -23
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +244 -98
- package/dest/prover-node.d.ts +122 -71
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +872 -226
- package/dest/prover-publisher-factory.d.ts +12 -6
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +8 -5
- package/dest/session-manager.d.ts +158 -0
- package/dest/session-manager.d.ts.map +1 -0
- package/dest/session-manager.js +452 -0
- package/dest/test/index.d.ts +7 -6
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/actions/download-epoch-proving-job.ts +1 -1
- package/src/actions/rerun-epoch-proving-job.ts +120 -30
- package/src/actions/upload-epoch-proof-failure.ts +1 -1
- package/src/bin/run-failed-epoch.ts +5 -3
- package/src/checkpoint-store.ts +218 -0
- package/src/config.ts +39 -34
- package/src/factory.ts +86 -111
- package/src/index.ts +2 -0
- package/src/job/checkpoint-prover.ts +468 -0
- package/src/job/epoch-proving-job-data.ts +31 -25
- package/src/job/epoch-session.ts +436 -0
- package/src/job/top-tree-job.ts +227 -0
- package/src/metrics.ts +146 -84
- package/src/monitors/epoch-monitor.ts +10 -17
- package/src/proof-publishing-service.ts +427 -0
- package/src/prover-node-publisher.ts +300 -129
- package/src/prover-node.ts +569 -254
- package/src/prover-publisher-factory.ts +22 -11
- package/src/session-manager.ts +552 -0
- package/src/test/index.ts +6 -6
- package/dest/job/epoch-proving-job.d.ts +0 -69
- package/dest/job/epoch-proving-job.d.ts.map +0 -1
- package/dest/job/epoch-proving-job.js +0 -354
- package/src/job/epoch-proving-job.ts +0 -420
package/src/metrics.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RollupContract } from '@aztec/ethereum';
|
|
1
|
+
import type { RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { L1PublishProofStats, L1PublishStats } from '@aztec/stdlib/stats';
|
|
@@ -13,48 +13,119 @@ import {
|
|
|
13
13
|
type TelemetryClient,
|
|
14
14
|
type Tracer,
|
|
15
15
|
type UpDownCounter,
|
|
16
|
-
|
|
16
|
+
createUpDownCounterWithDefault,
|
|
17
17
|
} from '@aztec/telemetry-client';
|
|
18
18
|
|
|
19
19
|
import { formatEther, formatUnits } from 'viem';
|
|
20
20
|
|
|
21
|
+
import type { CheckpointStore } from './checkpoint-store.js';
|
|
22
|
+
import type { SessionManager } from './session-manager.js';
|
|
23
|
+
|
|
21
24
|
export class ProverNodeJobMetrics {
|
|
22
|
-
proverEpochExecutionDuration: Histogram;
|
|
23
25
|
provingJobDuration: Histogram;
|
|
26
|
+
provingJobCheckpoints: Gauge;
|
|
24
27
|
provingJobBlocks: Gauge;
|
|
25
28
|
provingJobTransactions: Gauge;
|
|
26
29
|
|
|
30
|
+
private blobProcessingDuration: Gauge;
|
|
31
|
+
private blockProcessingDuration: Histogram;
|
|
32
|
+
private checkpointProcessingDuration: Histogram;
|
|
33
|
+
private checkpointProvingDuration: Histogram;
|
|
34
|
+
private checkpointBlocks: Histogram;
|
|
35
|
+
private checkpointTransactions: Histogram;
|
|
36
|
+
|
|
37
|
+
/** Observable gauges for live state. Registered via `observeState(...)` once the
|
|
38
|
+
* CheckpointStore and SessionManager are available. */
|
|
39
|
+
private activeCheckpoints: ObservableGauge | undefined;
|
|
40
|
+
private activeEpochSessions: ObservableGauge | undefined;
|
|
41
|
+
private stateObserver: ((observer: BatchObservableResult) => void) | undefined;
|
|
42
|
+
private stateObservedMetrics: ObservableGauge[] = [];
|
|
43
|
+
|
|
27
44
|
constructor(
|
|
28
45
|
private meter: Meter,
|
|
29
46
|
public readonly tracer: Tracer,
|
|
30
47
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
31
48
|
) {
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
description: 'Number of blocks in a proven epoch',
|
|
44
|
-
valueType: ValueType.INT,
|
|
45
|
-
});
|
|
46
|
-
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS, {
|
|
47
|
-
description: 'Number of transactions in a proven epoch',
|
|
48
|
-
valueType: ValueType.INT,
|
|
49
|
-
});
|
|
49
|
+
this.provingJobDuration = this.meter.createHistogram(Metrics.PROVER_NODE_JOB_DURATION);
|
|
50
|
+
this.provingJobCheckpoints = this.meter.createGauge(Metrics.PROVER_NODE_JOB_CHECKPOINTS);
|
|
51
|
+
this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS);
|
|
52
|
+
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS);
|
|
53
|
+
|
|
54
|
+
this.blobProcessingDuration = this.meter.createGauge(Metrics.PROVER_NODE_BLOB_PROCESSING_LAST_DURATION);
|
|
55
|
+
this.blockProcessingDuration = this.meter.createHistogram(Metrics.PROVER_NODE_BLOCK_PROCESSING_DURATION);
|
|
56
|
+
this.checkpointProcessingDuration = this.meter.createHistogram(Metrics.PROVER_NODE_CHECKPOINT_PROCESSING_DURATION);
|
|
57
|
+
this.checkpointProvingDuration = this.meter.createHistogram(Metrics.PROVER_NODE_CHECKPOINT_PROVING_DURATION);
|
|
58
|
+
this.checkpointBlocks = this.meter.createHistogram(Metrics.PROVER_NODE_CHECKPOINT_BLOCKS);
|
|
59
|
+
this.checkpointTransactions = this.meter.createHistogram(Metrics.PROVER_NODE_CHECKPOINT_TRANSACTIONS);
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
public recordProvingJob(
|
|
53
|
-
this.proverEpochExecutionDuration.record(Math.ceil(executionTimeMs));
|
|
62
|
+
public recordProvingJob(totalTimeMs: number, numCheckpoints: number, numBlocks: number, numTxs: number) {
|
|
54
63
|
this.provingJobDuration.record(totalTimeMs / 1000);
|
|
64
|
+
this.provingJobCheckpoints.record(Math.floor(numCheckpoints));
|
|
55
65
|
this.provingJobBlocks.record(Math.floor(numBlocks));
|
|
56
66
|
this.provingJobTransactions.record(Math.floor(numTxs));
|
|
57
67
|
}
|
|
68
|
+
|
|
69
|
+
public recordBlobProcessing(durationMs: number) {
|
|
70
|
+
this.blobProcessingDuration.record(Math.ceil(durationMs));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public recordBlockProcessing(durationMs: number) {
|
|
74
|
+
this.blockProcessingDuration.record(Math.ceil(durationMs));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public recordCheckpointProcessing(durationMs: number, numBlocks: number, numTxs: number) {
|
|
78
|
+
this.checkpointProcessingDuration.record(Math.ceil(durationMs));
|
|
79
|
+
this.checkpointBlocks.record(Math.floor(numBlocks));
|
|
80
|
+
this.checkpointTransactions.record(Math.floor(numTxs));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public recordCheckpointProving(durationMs: number) {
|
|
84
|
+
this.checkpointProvingDuration.record(Math.ceil(durationMs));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Registers observable gauges for the prover-node's live state: how many canonical
|
|
89
|
+
* checkpoint provers are in the store, and how many epoch sessions are live (broken
|
|
90
|
+
* down by kind). Idempotent — repeated calls re-arm with the latest references.
|
|
91
|
+
*
|
|
92
|
+
* Call this once the `SessionManager` has been constructed (i.e. inside `ProverNode.start()`).
|
|
93
|
+
*/
|
|
94
|
+
public observeState(checkpointStore: CheckpointStore, sessionManager: SessionManager): void {
|
|
95
|
+
this.stopObservingState();
|
|
96
|
+
this.activeCheckpoints = this.meter.createObservableGauge(Metrics.PROVER_NODE_ACTIVE_CHECKPOINTS);
|
|
97
|
+
this.activeEpochSessions = this.meter.createObservableGauge(Metrics.PROVER_NODE_ACTIVE_EPOCH_SESSIONS);
|
|
98
|
+
this.stateObserver = (observer: BatchObservableResult) => {
|
|
99
|
+
observer.observe(this.activeCheckpoints!, checkpointStore.listCanonical().length);
|
|
100
|
+
let full = 0;
|
|
101
|
+
let partial = 0;
|
|
102
|
+
for (const session of sessionManager.allSessions()) {
|
|
103
|
+
if (session.isTerminal()) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (session.getKind() === 'full') {
|
|
107
|
+
full++;
|
|
108
|
+
} else {
|
|
109
|
+
partial++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
observer.observe(this.activeEpochSessions!, full, { [Attributes.EPOCH_SESSION_KIND]: 'full' });
|
|
113
|
+
observer.observe(this.activeEpochSessions!, partial, { [Attributes.EPOCH_SESSION_KIND]: 'partial' });
|
|
114
|
+
};
|
|
115
|
+
this.stateObservedMetrics = [this.activeCheckpoints, this.activeEpochSessions];
|
|
116
|
+
this.meter.addBatchObservableCallback(this.stateObserver, this.stateObservedMetrics);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Tears down the observable callback registered by `observeState`. Idempotent. */
|
|
120
|
+
public stopObservingState(): void {
|
|
121
|
+
if (this.stateObserver) {
|
|
122
|
+
this.meter.removeBatchObservableCallback(this.stateObserver, this.stateObservedMetrics);
|
|
123
|
+
this.stateObserver = undefined;
|
|
124
|
+
this.stateObservedMetrics = [];
|
|
125
|
+
this.activeCheckpoints = undefined;
|
|
126
|
+
this.activeEpochSessions = undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
58
129
|
}
|
|
59
130
|
|
|
60
131
|
export class ProverNodeRewardsMetrics {
|
|
@@ -69,15 +140,9 @@ export class ProverNodeRewardsMetrics {
|
|
|
69
140
|
private rollup: RollupContract,
|
|
70
141
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
71
142
|
) {
|
|
72
|
-
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH
|
|
73
|
-
valueType: ValueType.DOUBLE,
|
|
74
|
-
description: 'The rewards earned',
|
|
75
|
-
});
|
|
143
|
+
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH);
|
|
76
144
|
|
|
77
|
-
this.accumulatedRewards = this.meter
|
|
78
|
-
valueType: ValueType.DOUBLE,
|
|
79
|
-
description: 'The rewards earned (total)',
|
|
80
|
-
});
|
|
145
|
+
this.accumulatedRewards = createUpDownCounterWithDefault(this.meter, Metrics.PROVER_NODE_REWARDS_TOTAL);
|
|
81
146
|
}
|
|
82
147
|
|
|
83
148
|
public async start() {
|
|
@@ -97,7 +162,7 @@ export class ProverNodeRewardsMetrics {
|
|
|
97
162
|
// look at the prev epoch so that we get an accurate value, after proof submission window has closed
|
|
98
163
|
// For example, if proof submission window is 1 epoch, and we are in epoch 2, we should be looking at epoch 0.
|
|
99
164
|
// Similarly, if the proof submission window is 0, and we are in epoch 1, we should be looking at epoch 0.
|
|
100
|
-
const closedEpoch = epoch - BigInt(this.proofSubmissionEpochs) - 1n;
|
|
165
|
+
const closedEpoch = BigInt(epoch) - BigInt(this.proofSubmissionEpochs) - 1n;
|
|
101
166
|
const rewards = await this.rollup.getSpecificProverRewardsForEpoch(closedEpoch, this.coinbase);
|
|
102
167
|
|
|
103
168
|
const fmt = parseFloat(formatUnits(rewards, 18));
|
|
@@ -117,6 +182,13 @@ export class ProverNodeRewardsMetrics {
|
|
|
117
182
|
};
|
|
118
183
|
}
|
|
119
184
|
|
|
185
|
+
export type EstimatedSubmitProofStats = {
|
|
186
|
+
gasLimit: bigint;
|
|
187
|
+
baseFeePerGas: bigint;
|
|
188
|
+
maxPriorityFeePerGas: bigint;
|
|
189
|
+
estimatedTotalFee: bigint;
|
|
190
|
+
};
|
|
191
|
+
|
|
120
192
|
export class ProverNodePublisherMetrics {
|
|
121
193
|
gasPrice: Histogram;
|
|
122
194
|
txCount: UpDownCounter;
|
|
@@ -128,6 +200,10 @@ export class ProverNodePublisherMetrics {
|
|
|
128
200
|
txBlobDataGasCost: Histogram;
|
|
129
201
|
txTotalFee: Histogram;
|
|
130
202
|
|
|
203
|
+
private txGasEstimated: Histogram;
|
|
204
|
+
private gasPriceEstimated: Histogram;
|
|
205
|
+
private txTotalFeeEstimated: Histogram;
|
|
206
|
+
|
|
131
207
|
private senderBalance: Gauge;
|
|
132
208
|
private meter: Meter;
|
|
133
209
|
|
|
@@ -138,68 +214,34 @@ export class ProverNodePublisherMetrics {
|
|
|
138
214
|
) {
|
|
139
215
|
this.meter = client.getMeter(name);
|
|
140
216
|
|
|
141
|
-
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE
|
|
142
|
-
description: 'The gas price used for transactions',
|
|
143
|
-
unit: 'gwei',
|
|
144
|
-
valueType: ValueType.DOUBLE,
|
|
145
|
-
});
|
|
217
|
+
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
146
218
|
|
|
147
|
-
this.txCount = this.meter
|
|
148
|
-
|
|
219
|
+
this.txCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
220
|
+
[Attributes.L1_TX_TYPE]: ['submitProof'],
|
|
221
|
+
[Attributes.OK]: [true, false],
|
|
149
222
|
});
|
|
150
223
|
|
|
151
|
-
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION
|
|
152
|
-
description: 'The duration of transaction processing',
|
|
153
|
-
unit: 'ms',
|
|
154
|
-
valueType: ValueType.INT,
|
|
155
|
-
});
|
|
224
|
+
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
156
225
|
|
|
157
|
-
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS
|
|
158
|
-
description: 'The gas consumed by transactions',
|
|
159
|
-
unit: 'gas',
|
|
160
|
-
valueType: ValueType.INT,
|
|
161
|
-
});
|
|
226
|
+
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
|
|
162
227
|
|
|
163
|
-
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE
|
|
164
|
-
description: 'The size of the calldata in transactions',
|
|
165
|
-
unit: 'By',
|
|
166
|
-
valueType: ValueType.INT,
|
|
167
|
-
});
|
|
228
|
+
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
|
|
168
229
|
|
|
169
|
-
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS
|
|
170
|
-
description: 'The gas consumed by the calldata in transactions',
|
|
171
|
-
unit: 'gas',
|
|
172
|
-
valueType: ValueType.INT,
|
|
173
|
-
});
|
|
230
|
+
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
|
|
174
231
|
|
|
175
|
-
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED
|
|
176
|
-
description: 'The amount of blob gas used in transactions',
|
|
177
|
-
unit: 'gas',
|
|
178
|
-
valueType: ValueType.INT,
|
|
179
|
-
});
|
|
232
|
+
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
|
|
180
233
|
|
|
181
|
-
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST
|
|
182
|
-
description: 'The gas cost of blobs in transactions',
|
|
183
|
-
unit: 'gwei',
|
|
184
|
-
valueType: ValueType.INT,
|
|
185
|
-
});
|
|
234
|
+
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
|
|
186
235
|
|
|
187
|
-
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE
|
|
188
|
-
description: 'How much L1 tx costs',
|
|
189
|
-
unit: 'gwei',
|
|
190
|
-
valueType: ValueType.DOUBLE,
|
|
191
|
-
advice: {
|
|
192
|
-
explicitBucketBoundaries: [
|
|
193
|
-
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,
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
});
|
|
236
|
+
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
197
237
|
|
|
198
|
-
this.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
238
|
+
this.txGasEstimated = this.meter.createHistogram(Metrics.PROVER_NODE_ESTIMATED_SUBMISSION_GAS);
|
|
239
|
+
|
|
240
|
+
this.gasPriceEstimated = this.meter.createHistogram(Metrics.PROVER_NODE_ESTIMATED_SUBMISSION_GAS_PRICE);
|
|
241
|
+
|
|
242
|
+
this.txTotalFeeEstimated = this.meter.createHistogram(Metrics.PROVER_NODE_ESTIMATED_SUBMISSION_TOTAL_FEE);
|
|
243
|
+
|
|
244
|
+
this.senderBalance = this.meter.createGauge(Metrics.L1_PUBLISHER_BALANCE);
|
|
203
245
|
}
|
|
204
246
|
|
|
205
247
|
recordFailedTx() {
|
|
@@ -213,6 +255,26 @@ export class ProverNodePublisherMetrics {
|
|
|
213
255
|
this.recordTx(durationMs, stats);
|
|
214
256
|
}
|
|
215
257
|
|
|
258
|
+
public recordEstimatedSubmitProof(stats: EstimatedSubmitProofStats) {
|
|
259
|
+
const attributes = { [Attributes.L1_TX_TYPE]: 'submitProof' } as const;
|
|
260
|
+
|
|
261
|
+
this.txGasEstimated.record(Number(stats.gasLimit), attributes);
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
this.gasPriceEstimated.record(
|
|
265
|
+
parseInt(formatEther(stats.baseFeePerGas + stats.maxPriorityFeePerGas, 'gwei'), 10),
|
|
266
|
+
);
|
|
267
|
+
} catch {
|
|
268
|
+
// ignore
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
this.txTotalFeeEstimated.record(parseFloat(formatEther(stats.estimatedTotalFee)));
|
|
273
|
+
} catch {
|
|
274
|
+
// ignore
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
216
278
|
public recordSenderBalance(wei: bigint, senderAddress: string) {
|
|
217
279
|
const eth = parseFloat(formatEther(wei, 'wei'));
|
|
218
280
|
this.senderBalance.record(eth, {
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
+
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
3
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
4
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
6
|
import { type L1RollupConstants, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
6
|
-
import {
|
|
7
|
-
type TelemetryClient,
|
|
8
|
-
type Traceable,
|
|
9
|
-
type Tracer,
|
|
10
|
-
getTelemetryClient,
|
|
11
|
-
trackSpan,
|
|
12
|
-
} from '@aztec/telemetry-client';
|
|
7
|
+
import { type TelemetryClient, type Traceable, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
13
8
|
|
|
14
9
|
export interface EpochMonitorHandler {
|
|
15
|
-
handleEpochReadyToProve(epochNumber:
|
|
10
|
+
handleEpochReadyToProve(epochNumber: EpochNumber): Promise<boolean>;
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
/**
|
|
@@ -32,7 +27,7 @@ export class EpochMonitor implements Traceable {
|
|
|
32
27
|
public readonly tracer: Tracer;
|
|
33
28
|
|
|
34
29
|
private handler: EpochMonitorHandler | undefined;
|
|
35
|
-
private latestEpochNumber:
|
|
30
|
+
private latestEpochNumber: EpochNumber | undefined;
|
|
36
31
|
|
|
37
32
|
constructor(
|
|
38
33
|
private readonly l2BlockSource: L2BlockSource,
|
|
@@ -72,12 +67,10 @@ export class EpochMonitor implements Traceable {
|
|
|
72
67
|
this.log.info('Stopped EpochMonitor');
|
|
73
68
|
}
|
|
74
69
|
|
|
75
|
-
@trackSpan('EpochMonitor.work')
|
|
76
70
|
public async work() {
|
|
77
71
|
const { epochToProve, blockNumber, slotNumber } = await this.getEpochNumberToProve();
|
|
78
|
-
this.log.debug(`Epoch to prove: ${epochToProve}`, { blockNumber, slotNumber });
|
|
79
72
|
if (epochToProve === undefined) {
|
|
80
|
-
this.log.trace(`Next block to prove ${blockNumber} not yet mined`, { blockNumber });
|
|
73
|
+
this.log.trace(`Next block to prove ${blockNumber} not yet mined`, { epochToProve, blockNumber, slotNumber });
|
|
81
74
|
return;
|
|
82
75
|
}
|
|
83
76
|
if (this.latestEpochNumber !== undefined && epochToProve <= this.latestEpochNumber) {
|
|
@@ -92,20 +85,20 @@ export class EpochMonitor implements Traceable {
|
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
if (this.options.provingDelayMs) {
|
|
95
|
-
this.log.
|
|
88
|
+
this.log.warn(`Waiting ${this.options.provingDelayMs}ms before proving epoch ${epochToProve}`);
|
|
96
89
|
await sleep(this.options.provingDelayMs);
|
|
97
90
|
}
|
|
98
91
|
|
|
99
|
-
this.log.
|
|
92
|
+
this.log.verbose(`Epoch ${epochToProve} is ready to be proven`);
|
|
100
93
|
if (await this.handler?.handleEpochReadyToProve(epochToProve)) {
|
|
101
94
|
this.latestEpochNumber = epochToProve;
|
|
102
95
|
}
|
|
103
96
|
}
|
|
104
97
|
|
|
105
98
|
private async getEpochNumberToProve() {
|
|
106
|
-
const lastBlockProven = await this.l2BlockSource.
|
|
107
|
-
const firstBlockToProve = lastBlockProven + 1;
|
|
108
|
-
const firstBlockHeaderToProve = await this.l2BlockSource.
|
|
99
|
+
const lastBlockProven = (await this.l2BlockSource.getBlockNumber({ tag: 'proven' })) ?? BlockNumber.ZERO;
|
|
100
|
+
const firstBlockToProve = BlockNumber(lastBlockProven + 1);
|
|
101
|
+
const firstBlockHeaderToProve = (await this.l2BlockSource.getBlockData({ number: firstBlockToProve }))?.header;
|
|
109
102
|
if (!firstBlockHeaderToProve) {
|
|
110
103
|
return { epochToProve: undefined, blockNumber: firstBlockToProve };
|
|
111
104
|
}
|