@aztec/prover-node 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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 +1 -1
- package/dest/actions/download-epoch-proving-job.js +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.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 +2 -2
- package/dest/job/epoch-proving-job-data.d.ts.map +1 -1
- package/dest/job/epoch-proving-job-data.js +1 -1
- 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 +41 -4
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +125 -102
- package/dest/monitors/epoch-monitor.d.ts +1 -1
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +12 -19
- 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 +31 -19
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +222 -78
- package/dest/prover-node.d.ts +122 -72
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +872 -229
- 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 +25 -23
- 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 -113
- package/src/index.ts +2 -0
- package/src/job/checkpoint-prover.ts +468 -0
- package/src/job/epoch-proving-job-data.ts +1 -1
- package/src/job/epoch-session.ts +436 -0
- package/src/job/top-tree-job.ts +227 -0
- package/src/metrics.ts +143 -93
- package/src/monitors/epoch-monitor.ts +6 -14
- package/src/proof-publishing-service.ts +427 -0
- package/src/prover-node-publisher.ts +264 -98
- package/src/prover-node.ts +568 -259
- 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 -62
- package/dest/job/epoch-proving-job.d.ts.map +0 -1
- package/dest/job/epoch-proving-job.js +0 -363
- package/src/job/epoch-proving-job.ts +0 -426
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,60 +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;
|
|
24
26
|
provingJobCheckpoints: Gauge;
|
|
25
27
|
provingJobBlocks: Gauge;
|
|
26
28
|
provingJobTransactions: Gauge;
|
|
27
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
|
+
|
|
28
44
|
constructor(
|
|
29
45
|
private meter: Meter,
|
|
30
46
|
public readonly tracer: Tracer,
|
|
31
47
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
32
48
|
) {
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
description: 'Number of checkpoints in a proven epoch',
|
|
45
|
-
valueType: ValueType.INT,
|
|
46
|
-
});
|
|
47
|
-
this.provingJobBlocks = this.meter.createGauge(Metrics.PROVER_NODE_JOB_BLOCKS, {
|
|
48
|
-
description: 'Number of blocks in a proven epoch',
|
|
49
|
-
valueType: ValueType.INT,
|
|
50
|
-
});
|
|
51
|
-
this.provingJobTransactions = this.meter.createGauge(Metrics.PROVER_NODE_JOB_TRANSACTIONS, {
|
|
52
|
-
description: 'Number of transactions in a proven epoch',
|
|
53
|
-
valueType: ValueType.INT,
|
|
54
|
-
});
|
|
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);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
public recordProvingJob(
|
|
58
|
-
executionTimeMs: number,
|
|
59
|
-
totalTimeMs: number,
|
|
60
|
-
numCheckpoints: number,
|
|
61
|
-
numBlocks: number,
|
|
62
|
-
numTxs: number,
|
|
63
|
-
) {
|
|
64
|
-
this.proverEpochExecutionDuration.record(Math.ceil(executionTimeMs));
|
|
62
|
+
public recordProvingJob(totalTimeMs: number, numCheckpoints: number, numBlocks: number, numTxs: number) {
|
|
65
63
|
this.provingJobDuration.record(totalTimeMs / 1000);
|
|
66
64
|
this.provingJobCheckpoints.record(Math.floor(numCheckpoints));
|
|
67
65
|
this.provingJobBlocks.record(Math.floor(numBlocks));
|
|
68
66
|
this.provingJobTransactions.record(Math.floor(numTxs));
|
|
69
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
|
+
}
|
|
70
129
|
}
|
|
71
130
|
|
|
72
131
|
export class ProverNodeRewardsMetrics {
|
|
@@ -81,15 +140,9 @@ export class ProverNodeRewardsMetrics {
|
|
|
81
140
|
private rollup: RollupContract,
|
|
82
141
|
private logger = createLogger('prover-node:publisher:metrics'),
|
|
83
142
|
) {
|
|
84
|
-
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH
|
|
85
|
-
valueType: ValueType.DOUBLE,
|
|
86
|
-
description: 'The rewards earned',
|
|
87
|
-
});
|
|
143
|
+
this.rewards = this.meter.createObservableGauge(Metrics.PROVER_NODE_REWARDS_PER_EPOCH);
|
|
88
144
|
|
|
89
|
-
this.accumulatedRewards = this.meter
|
|
90
|
-
valueType: ValueType.DOUBLE,
|
|
91
|
-
description: 'The rewards earned (total)',
|
|
92
|
-
});
|
|
145
|
+
this.accumulatedRewards = createUpDownCounterWithDefault(this.meter, Metrics.PROVER_NODE_REWARDS_TOTAL);
|
|
93
146
|
}
|
|
94
147
|
|
|
95
148
|
public async start() {
|
|
@@ -129,6 +182,13 @@ export class ProverNodeRewardsMetrics {
|
|
|
129
182
|
};
|
|
130
183
|
}
|
|
131
184
|
|
|
185
|
+
export type EstimatedSubmitProofStats = {
|
|
186
|
+
gasLimit: bigint;
|
|
187
|
+
baseFeePerGas: bigint;
|
|
188
|
+
maxPriorityFeePerGas: bigint;
|
|
189
|
+
estimatedTotalFee: bigint;
|
|
190
|
+
};
|
|
191
|
+
|
|
132
192
|
export class ProverNodePublisherMetrics {
|
|
133
193
|
gasPrice: Histogram;
|
|
134
194
|
txCount: UpDownCounter;
|
|
@@ -140,6 +200,10 @@ export class ProverNodePublisherMetrics {
|
|
|
140
200
|
txBlobDataGasCost: Histogram;
|
|
141
201
|
txTotalFee: Histogram;
|
|
142
202
|
|
|
203
|
+
private txGasEstimated: Histogram;
|
|
204
|
+
private gasPriceEstimated: Histogram;
|
|
205
|
+
private txTotalFeeEstimated: Histogram;
|
|
206
|
+
|
|
143
207
|
private senderBalance: Gauge;
|
|
144
208
|
private meter: Meter;
|
|
145
209
|
|
|
@@ -150,68 +214,34 @@ export class ProverNodePublisherMetrics {
|
|
|
150
214
|
) {
|
|
151
215
|
this.meter = client.getMeter(name);
|
|
152
216
|
|
|
153
|
-
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE
|
|
154
|
-
description: 'The gas price used for transactions',
|
|
155
|
-
unit: 'gwei',
|
|
156
|
-
valueType: ValueType.DOUBLE,
|
|
157
|
-
});
|
|
217
|
+
this.gasPrice = this.meter.createHistogram(Metrics.L1_PUBLISHER_GAS_PRICE);
|
|
158
218
|
|
|
159
|
-
this.txCount = this.meter
|
|
160
|
-
|
|
219
|
+
this.txCount = createUpDownCounterWithDefault(this.meter, Metrics.L1_PUBLISHER_TX_COUNT, {
|
|
220
|
+
[Attributes.L1_TX_TYPE]: ['submitProof'],
|
|
221
|
+
[Attributes.OK]: [true, false],
|
|
161
222
|
});
|
|
162
223
|
|
|
163
|
-
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION
|
|
164
|
-
description: 'The duration of transaction processing',
|
|
165
|
-
unit: 'ms',
|
|
166
|
-
valueType: ValueType.INT,
|
|
167
|
-
});
|
|
224
|
+
this.txDuration = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_DURATION);
|
|
168
225
|
|
|
169
|
-
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS
|
|
170
|
-
description: 'The gas consumed by transactions',
|
|
171
|
-
unit: 'gas',
|
|
172
|
-
valueType: ValueType.INT,
|
|
173
|
-
});
|
|
226
|
+
this.txGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_GAS);
|
|
174
227
|
|
|
175
|
-
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE
|
|
176
|
-
description: 'The size of the calldata in transactions',
|
|
177
|
-
unit: 'By',
|
|
178
|
-
valueType: ValueType.INT,
|
|
179
|
-
});
|
|
228
|
+
this.txCalldataSize = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_SIZE);
|
|
180
229
|
|
|
181
|
-
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS
|
|
182
|
-
description: 'The gas consumed by the calldata in transactions',
|
|
183
|
-
unit: 'gas',
|
|
184
|
-
valueType: ValueType.INT,
|
|
185
|
-
});
|
|
230
|
+
this.txCalldataGas = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_CALLDATA_GAS);
|
|
186
231
|
|
|
187
|
-
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED
|
|
188
|
-
description: 'The amount of blob gas used in transactions',
|
|
189
|
-
unit: 'gas',
|
|
190
|
-
valueType: ValueType.INT,
|
|
191
|
-
});
|
|
232
|
+
this.txBlobDataGasUsed = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_USED);
|
|
192
233
|
|
|
193
|
-
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST
|
|
194
|
-
description: 'The gas cost of blobs in transactions',
|
|
195
|
-
unit: 'gwei',
|
|
196
|
-
valueType: ValueType.INT,
|
|
197
|
-
});
|
|
234
|
+
this.txBlobDataGasCost = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_BLOBDATA_GAS_COST);
|
|
198
235
|
|
|
199
|
-
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE
|
|
200
|
-
description: 'How much L1 tx costs',
|
|
201
|
-
unit: 'gwei',
|
|
202
|
-
valueType: ValueType.DOUBLE,
|
|
203
|
-
advice: {
|
|
204
|
-
explicitBucketBoundaries: [
|
|
205
|
-
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,
|
|
206
|
-
],
|
|
207
|
-
},
|
|
208
|
-
});
|
|
236
|
+
this.txTotalFee = this.meter.createHistogram(Metrics.L1_PUBLISHER_TX_TOTAL_FEE);
|
|
209
237
|
|
|
210
|
-
this.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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);
|
|
215
245
|
}
|
|
216
246
|
|
|
217
247
|
recordFailedTx() {
|
|
@@ -225,6 +255,26 @@ export class ProverNodePublisherMetrics {
|
|
|
225
255
|
this.recordTx(durationMs, stats);
|
|
226
256
|
}
|
|
227
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
|
+
|
|
228
278
|
public recordSenderBalance(wei: bigint, senderAddress: string) {
|
|
229
279
|
const eth = parseFloat(formatEther(wei, 'wei'));
|
|
230
280
|
this.senderBalance.record(eth, {
|
|
@@ -4,13 +4,7 @@ import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
|
4
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
6
6
|
import { type L1RollupConstants, getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
7
|
-
import {
|
|
8
|
-
type TelemetryClient,
|
|
9
|
-
type Traceable,
|
|
10
|
-
type Tracer,
|
|
11
|
-
getTelemetryClient,
|
|
12
|
-
trackSpan,
|
|
13
|
-
} from '@aztec/telemetry-client';
|
|
7
|
+
import { type TelemetryClient, type Traceable, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
14
8
|
|
|
15
9
|
export interface EpochMonitorHandler {
|
|
16
10
|
handleEpochReadyToProve(epochNumber: EpochNumber): Promise<boolean>;
|
|
@@ -73,12 +67,10 @@ export class EpochMonitor implements Traceable {
|
|
|
73
67
|
this.log.info('Stopped EpochMonitor');
|
|
74
68
|
}
|
|
75
69
|
|
|
76
|
-
@trackSpan('EpochMonitor.work')
|
|
77
70
|
public async work() {
|
|
78
71
|
const { epochToProve, blockNumber, slotNumber } = await this.getEpochNumberToProve();
|
|
79
|
-
this.log.debug(`Epoch to prove: ${epochToProve}`, { blockNumber, slotNumber });
|
|
80
72
|
if (epochToProve === undefined) {
|
|
81
|
-
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 });
|
|
82
74
|
return;
|
|
83
75
|
}
|
|
84
76
|
if (this.latestEpochNumber !== undefined && epochToProve <= this.latestEpochNumber) {
|
|
@@ -93,20 +85,20 @@ export class EpochMonitor implements Traceable {
|
|
|
93
85
|
}
|
|
94
86
|
|
|
95
87
|
if (this.options.provingDelayMs) {
|
|
96
|
-
this.log.
|
|
88
|
+
this.log.warn(`Waiting ${this.options.provingDelayMs}ms before proving epoch ${epochToProve}`);
|
|
97
89
|
await sleep(this.options.provingDelayMs);
|
|
98
90
|
}
|
|
99
91
|
|
|
100
|
-
this.log.
|
|
92
|
+
this.log.verbose(`Epoch ${epochToProve} is ready to be proven`);
|
|
101
93
|
if (await this.handler?.handleEpochReadyToProve(epochToProve)) {
|
|
102
94
|
this.latestEpochNumber = epochToProve;
|
|
103
95
|
}
|
|
104
96
|
}
|
|
105
97
|
|
|
106
98
|
private async getEpochNumberToProve() {
|
|
107
|
-
const lastBlockProven = await this.l2BlockSource.
|
|
99
|
+
const lastBlockProven = (await this.l2BlockSource.getBlockNumber({ tag: 'proven' })) ?? BlockNumber.ZERO;
|
|
108
100
|
const firstBlockToProve = BlockNumber(lastBlockProven + 1);
|
|
109
|
-
const firstBlockHeaderToProve = await this.l2BlockSource.
|
|
101
|
+
const firstBlockHeaderToProve = (await this.l2BlockSource.getBlockData({ number: firstBlockToProve }))?.header;
|
|
110
102
|
if (!firstBlockHeaderToProve) {
|
|
111
103
|
return { epochToProve: undefined, blockNumber: firstBlockToProve };
|
|
112
104
|
}
|