@aztec/prover-node 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97
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/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 +5 -3
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +105 -25
- 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/config.d.ts +8 -10
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +19 -21
- package/dest/factory.d.ts +20 -16
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +48 -63
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -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-proving-job.d.ts +11 -13
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +669 -111
- package/dest/metrics.d.ts +24 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +77 -98
- 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/prover-node-publisher.d.ts +33 -11
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +248 -46
- package/dest/prover-node.d.ts +30 -19
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +512 -81
- package/dest/prover-publisher-factory.d.ts +10 -6
- package/dest/prover-publisher-factory.d.ts.map +1 -1
- package/dest/prover-publisher-factory.js +7 -5
- package/dest/test/index.d.ts +1 -1
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +27 -25
- package/src/actions/download-epoch-proving-job.ts +1 -1
- package/src/actions/rerun-epoch-proving-job.ts +20 -7
- package/src/actions/upload-epoch-proof-failure.ts +1 -1
- package/src/bin/run-failed-epoch.ts +5 -3
- package/src/config.ts +27 -33
- package/src/factory.ts +81 -103
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job-data.ts +31 -25
- package/src/job/epoch-proving-job.ts +228 -117
- package/src/metrics.ts +102 -82
- package/src/monitors/epoch-monitor.ts +10 -17
- package/src/prover-node-publisher.ts +302 -66
- package/src/prover-node.ts +135 -86
- package/src/prover-publisher-factory.ts +19 -11
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import { BatchedBlob, getEthBlobEvaluationInputs } from '@aztec/blob-lib';
|
|
2
|
+
import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
|
|
3
|
+
import type { RollupContract, ViemCommitteeAttestation } from '@aztec/ethereum/contracts';
|
|
4
|
+
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
4
5
|
import { makeTuple } from '@aztec/foundation/array';
|
|
6
|
+
import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
5
7
|
import { areArraysEqual } from '@aztec/foundation/collection';
|
|
8
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
11
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
9
12
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
10
13
|
import { Timer } from '@aztec/foundation/timer';
|
|
11
14
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
12
15
|
import type { PublisherConfig, TxSenderConfig } from '@aztec/sequencer-client';
|
|
13
16
|
import { CommitteeAttestation, CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
17
|
+
import { getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
14
18
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
15
19
|
import type { FeeRecipient, RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
16
20
|
import type { L1PublishProofStats } from '@aztec/stdlib/stats';
|
|
17
21
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
18
22
|
|
|
19
23
|
import { inspect } from 'util';
|
|
20
|
-
import { type Hex, type TransactionReceipt, encodeFunctionData } from 'viem';
|
|
24
|
+
import { type Hex, type TransactionReceipt, encodeFunctionData, formatEther, formatGwei } from 'viem';
|
|
21
25
|
|
|
22
|
-
import { ProverNodePublisherMetrics } from './metrics.js';
|
|
26
|
+
import { type EstimatedSubmitProofStats, ProverNodePublisherMetrics } from './metrics.js';
|
|
23
27
|
|
|
24
28
|
/** Arguments to the submitEpochProof method of the rollup contract */
|
|
25
29
|
export type L1SubmitEpochProofArgs = {
|
|
@@ -29,7 +33,7 @@ export type L1SubmitEpochProofArgs = {
|
|
|
29
33
|
endTimestamp: Fr;
|
|
30
34
|
outHash: Fr;
|
|
31
35
|
proverId: Fr;
|
|
32
|
-
fees: Tuple<FeeRecipient, typeof
|
|
36
|
+
fees: Tuple<FeeRecipient, typeof MAX_CHECKPOINTS_PER_EPOCH>;
|
|
33
37
|
proof: Proof;
|
|
34
38
|
};
|
|
35
39
|
|
|
@@ -37,7 +41,7 @@ export class ProverNodePublisher {
|
|
|
37
41
|
private interrupted = false;
|
|
38
42
|
private metrics: ProverNodePublisherMetrics;
|
|
39
43
|
|
|
40
|
-
protected log
|
|
44
|
+
protected log: Logger;
|
|
41
45
|
|
|
42
46
|
protected rollupContract: RollupContract;
|
|
43
47
|
|
|
@@ -50,10 +54,12 @@ export class ProverNodePublisher {
|
|
|
50
54
|
l1TxUtils: L1TxUtils;
|
|
51
55
|
telemetry?: TelemetryClient;
|
|
52
56
|
},
|
|
57
|
+
bindings?: LoggerBindings,
|
|
53
58
|
) {
|
|
54
59
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
55
60
|
|
|
56
61
|
this.metrics = new ProverNodePublisherMetrics(telemetry, 'ProverNode');
|
|
62
|
+
this.log = createLogger('prover-node:l1-tx-publisher', bindings);
|
|
57
63
|
|
|
58
64
|
this.rollupContract = deps.rollupContract;
|
|
59
65
|
this.l1TxUtils = deps.l1TxUtils;
|
|
@@ -85,24 +91,30 @@ export class ProverNodePublisher {
|
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
public async submitEpochProof(args: {
|
|
88
|
-
epochNumber:
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
epochNumber: EpochNumber;
|
|
95
|
+
fromCheckpoint: CheckpointNumber;
|
|
96
|
+
toCheckpoint: CheckpointNumber;
|
|
91
97
|
publicInputs: RootRollupPublicInputs;
|
|
92
98
|
proof: Proof;
|
|
93
99
|
batchedBlobInputs: BatchedBlob;
|
|
94
100
|
attestations: ViemCommitteeAttestation[];
|
|
95
101
|
}): Promise<boolean> {
|
|
96
|
-
const { epochNumber,
|
|
97
|
-
const ctx = { epochNumber,
|
|
102
|
+
const { epochNumber, fromCheckpoint, toCheckpoint } = args;
|
|
103
|
+
const ctx = { epochNumber, fromCheckpoint, toCheckpoint };
|
|
98
104
|
|
|
99
105
|
if (!this.interrupted) {
|
|
106
|
+
if (!(await this.waitUntilStartBuildsOnProven(args))) {
|
|
107
|
+
this.log.verbose('Checkpoint data syncing interrupted', ctx);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
100
111
|
const timer = new Timer();
|
|
101
112
|
// Validate epoch proof range and hashes are correct before submitting
|
|
102
113
|
await this.validateEpochProofSubmission(args);
|
|
103
114
|
|
|
104
115
|
const txReceipt = await this.sendSubmitEpochProofTx(args);
|
|
105
116
|
if (!txReceipt) {
|
|
117
|
+
this.log.error(`Failed to mine submitEpochProof tx`, undefined, ctx);
|
|
106
118
|
return false;
|
|
107
119
|
}
|
|
108
120
|
|
|
@@ -135,47 +147,98 @@ export class ProverNodePublisher {
|
|
|
135
147
|
}
|
|
136
148
|
|
|
137
149
|
this.metrics.recordFailedTx();
|
|
138
|
-
this.log.error(`Rollup
|
|
150
|
+
this.log.error(`Rollup submitEpochProof tx reverted ${txReceipt.transactionHash}`, undefined, ctx);
|
|
139
151
|
}
|
|
140
152
|
|
|
141
|
-
this.log.verbose('
|
|
153
|
+
this.log.verbose('Checkpoint data syncing interrupted', ctx);
|
|
142
154
|
return false;
|
|
143
155
|
}
|
|
144
156
|
|
|
157
|
+
private async waitUntilStartBuildsOnProven(args: { epochNumber: EpochNumber; fromCheckpoint: CheckpointNumber }) {
|
|
158
|
+
const { epochNumber, fromCheckpoint } = args;
|
|
159
|
+
const provenCheckpoint = await this.getProvenCheckpoint();
|
|
160
|
+
if (this.isStartBuildingOnProven(fromCheckpoint, provenCheckpoint)) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const timeout = await this.getSecondsUntilProofSubmissionWindowEnd(epochNumber);
|
|
165
|
+
this.log.info(`Waiting for proven checkpoint to reach proof start`, {
|
|
166
|
+
epochNumber,
|
|
167
|
+
fromCheckpoint,
|
|
168
|
+
provenCheckpoint,
|
|
169
|
+
timeout,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await retryUntil(
|
|
173
|
+
async () => {
|
|
174
|
+
if (this.interrupted) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const proven = await this.getProvenCheckpoint();
|
|
179
|
+
this.log.verbose(`Proven checkpoint is at ${proven} (waiting for ${fromCheckpoint - 1})`, { epochNumber });
|
|
180
|
+
return this.isStartBuildingOnProven(fromCheckpoint, proven) ? true : undefined;
|
|
181
|
+
},
|
|
182
|
+
`proven checkpoint to reach ${fromCheckpoint - 1}`,
|
|
183
|
+
timeout,
|
|
184
|
+
4,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
return !this.interrupted;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private async getProvenCheckpoint() {
|
|
191
|
+
return (await this.rollupContract.getTips()).proven;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private isStartBuildingOnProven(fromCheckpoint: CheckpointNumber, provenCheckpoint: CheckpointNumber) {
|
|
195
|
+
return fromCheckpoint - 1 <= provenCheckpoint;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
private async getSecondsUntilProofSubmissionWindowEnd(epochNumber: EpochNumber) {
|
|
199
|
+
const deadline = getProofSubmissionDeadlineTimestamp(epochNumber, await this.rollupContract.getRollupConstants());
|
|
200
|
+
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
201
|
+
return Math.max(Number(deadline - now), 0.001);
|
|
202
|
+
}
|
|
203
|
+
|
|
145
204
|
private async validateEpochProofSubmission(args: {
|
|
146
|
-
|
|
147
|
-
|
|
205
|
+
fromCheckpoint: CheckpointNumber;
|
|
206
|
+
toCheckpoint: CheckpointNumber;
|
|
148
207
|
publicInputs: RootRollupPublicInputs;
|
|
149
208
|
proof: Proof;
|
|
150
209
|
batchedBlobInputs: BatchedBlob;
|
|
151
210
|
attestations: ViemCommitteeAttestation[];
|
|
152
211
|
}) {
|
|
153
|
-
const {
|
|
212
|
+
const { fromCheckpoint, toCheckpoint, publicInputs, batchedBlobInputs } = args;
|
|
154
213
|
|
|
155
|
-
// Check that the
|
|
156
|
-
const {
|
|
157
|
-
// Don't publish if proven is beyond our
|
|
158
|
-
if (proven >
|
|
159
|
-
throw new Error(
|
|
214
|
+
// Check that the checkpoint numbers match the expected epoch to be proven
|
|
215
|
+
const { pending, proven } = await this.rollupContract.getTips();
|
|
216
|
+
// Don't publish if proven is beyond our toCheckpoint, pointless to do so
|
|
217
|
+
if (proven > toCheckpoint) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as proven checkpoint is ${proven}`,
|
|
220
|
+
);
|
|
160
221
|
}
|
|
161
|
-
//
|
|
162
|
-
if (
|
|
163
|
-
throw new Error(
|
|
222
|
+
// toCheckpoint can't be greater than pending
|
|
223
|
+
if (toCheckpoint > pending) {
|
|
224
|
+
throw new Error(
|
|
225
|
+
`Cannot submit epoch proof for ${fromCheckpoint}-${toCheckpoint} as proposed checkpoint is ${pending}`,
|
|
226
|
+
);
|
|
164
227
|
}
|
|
165
228
|
|
|
166
|
-
// Check the archive for the immediate
|
|
167
|
-
const
|
|
168
|
-
if (publicInputs.previousArchiveRoot.
|
|
229
|
+
// Check the archive for the immediate checkpoint before the epoch
|
|
230
|
+
const checkpointLog = await this.rollupContract.getCheckpoint(CheckpointNumber(fromCheckpoint - 1));
|
|
231
|
+
if (!publicInputs.previousArchiveRoot.equals(checkpointLog.archive)) {
|
|
169
232
|
throw new Error(
|
|
170
|
-
`Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${
|
|
233
|
+
`Previous archive root mismatch: ${publicInputs.previousArchiveRoot.toString()} !== ${checkpointLog.archive.toString()}`,
|
|
171
234
|
);
|
|
172
235
|
}
|
|
173
236
|
|
|
174
|
-
// Check the archive for the last
|
|
175
|
-
const
|
|
176
|
-
if (publicInputs.endArchiveRoot.
|
|
237
|
+
// Check the archive for the last checkpoint in the epoch
|
|
238
|
+
const endCheckpointLog = await this.rollupContract.getCheckpoint(toCheckpoint);
|
|
239
|
+
if (!publicInputs.endArchiveRoot.equals(endCheckpointLog.archive)) {
|
|
177
240
|
throw new Error(
|
|
178
|
-
`End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${
|
|
241
|
+
`End archive root mismatch: ${publicInputs.endArchiveRoot.toString()} !== ${endCheckpointLog.archive.toString()}`,
|
|
179
242
|
);
|
|
180
243
|
}
|
|
181
244
|
|
|
@@ -193,17 +256,89 @@ export class ProverNodePublisher {
|
|
|
193
256
|
);
|
|
194
257
|
const argsPublicInputs = [...publicInputs.toFields()];
|
|
195
258
|
|
|
196
|
-
if (!areArraysEqual(rollupPublicInputs
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
259
|
+
if (!areArraysEqual(rollupPublicInputs, argsPublicInputs, (a, b) => a.equals(b))) {
|
|
260
|
+
throw await reportPublicInputsMismatch({
|
|
261
|
+
rollupPublicInputs,
|
|
262
|
+
argsPublicInputs,
|
|
263
|
+
fromCheckpoint,
|
|
264
|
+
toCheckpoint,
|
|
265
|
+
rollupContract: this.rollupContract,
|
|
266
|
+
log: this.log,
|
|
267
|
+
});
|
|
201
268
|
}
|
|
202
269
|
}
|
|
203
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Estimates what submitting the epoch proof would have cost on L1 without actually sending it.
|
|
273
|
+
* Runs the same validation as `submitEpochProof`, encodes the calldata, estimates gas, and records metrics.
|
|
274
|
+
* Used when proof publishing is disabled (e.g. PROVER_NODE_DISABLE_PROOF_PUBLISH=true on mainnet).
|
|
275
|
+
*/
|
|
276
|
+
public async analyzeEpochProofSubmission(args: {
|
|
277
|
+
epochNumber: EpochNumber;
|
|
278
|
+
fromCheckpoint: CheckpointNumber;
|
|
279
|
+
toCheckpoint: CheckpointNumber;
|
|
280
|
+
publicInputs: RootRollupPublicInputs;
|
|
281
|
+
proof: Proof;
|
|
282
|
+
batchedBlobInputs: BatchedBlob;
|
|
283
|
+
attestations: ViemCommitteeAttestation[];
|
|
284
|
+
}): Promise<void> {
|
|
285
|
+
const { epochNumber, fromCheckpoint, toCheckpoint } = args;
|
|
286
|
+
|
|
287
|
+
await this.validateEpochProofSubmission(args);
|
|
288
|
+
|
|
289
|
+
const data = this.encodeSubmitEpochProofCalldata(args);
|
|
290
|
+
const senderAddress = this.l1TxUtils.getSenderAddress();
|
|
291
|
+
|
|
292
|
+
const [gasLimit, gasPrice, latestBlock] = await Promise.all([
|
|
293
|
+
this.l1TxUtils.estimateGas(senderAddress.toString() as `0x${string}`, { to: this.rollupContract.address, data }),
|
|
294
|
+
this.l1TxUtils.getGasPrice(),
|
|
295
|
+
this.l1TxUtils.client.getBlock({ blockTag: 'latest' }),
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
const baseFeePerGas = latestBlock.baseFeePerGas ?? 0n;
|
|
299
|
+
const { maxPriorityFeePerGas } = gasPrice;
|
|
300
|
+
|
|
301
|
+
const effectiveFeePerGas = baseFeePerGas + maxPriorityFeePerGas;
|
|
302
|
+
const estimatedTotalFee = gasLimit * effectiveFeePerGas;
|
|
303
|
+
|
|
304
|
+
const stats: EstimatedSubmitProofStats = {
|
|
305
|
+
gasLimit,
|
|
306
|
+
baseFeePerGas,
|
|
307
|
+
maxPriorityFeePerGas,
|
|
308
|
+
estimatedTotalFee,
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
this.log.info(`Estimated epoch proof submission cost (not submitted)`, {
|
|
312
|
+
epochNumber,
|
|
313
|
+
fromCheckpoint,
|
|
314
|
+
toCheckpoint,
|
|
315
|
+
gasLimit: gasLimit.toString(),
|
|
316
|
+
baseFeePerGas: formatGwei(baseFeePerGas),
|
|
317
|
+
maxPriorityFeePerGas: formatGwei(maxPriorityFeePerGas),
|
|
318
|
+
estimatedTotalFeeEth: formatEther(estimatedTotalFee),
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
this.metrics.recordEstimatedSubmitProof(stats);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
private encodeSubmitEpochProofCalldata(args: {
|
|
325
|
+
fromCheckpoint: CheckpointNumber;
|
|
326
|
+
toCheckpoint: CheckpointNumber;
|
|
327
|
+
publicInputs: RootRollupPublicInputs;
|
|
328
|
+
proof: Proof;
|
|
329
|
+
batchedBlobInputs: BatchedBlob;
|
|
330
|
+
attestations: ViemCommitteeAttestation[];
|
|
331
|
+
}): Hex {
|
|
332
|
+
return encodeFunctionData({
|
|
333
|
+
abi: RollupAbi,
|
|
334
|
+
functionName: 'submitEpochRootProof',
|
|
335
|
+
args: [this.getSubmitEpochProofArgs(args)],
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
204
339
|
private async sendSubmitEpochProofTx(args: {
|
|
205
|
-
|
|
206
|
-
|
|
340
|
+
fromCheckpoint: CheckpointNumber;
|
|
341
|
+
toCheckpoint: CheckpointNumber;
|
|
207
342
|
publicInputs: RootRollupPublicInputs;
|
|
208
343
|
proof: Proof;
|
|
209
344
|
batchedBlobInputs: BatchedBlob;
|
|
@@ -213,8 +348,8 @@ export class ProverNodePublisher {
|
|
|
213
348
|
|
|
214
349
|
this.log.info(`Submitting epoch proof to L1 rollup contract`, {
|
|
215
350
|
proofSize: args.proof.withoutPublicInputs().length,
|
|
216
|
-
|
|
217
|
-
|
|
351
|
+
fromCheckpoint: args.fromCheckpoint,
|
|
352
|
+
toCheckpoint: args.toCheckpoint,
|
|
218
353
|
});
|
|
219
354
|
const data = encodeFunctionData({
|
|
220
355
|
abi: RollupAbi,
|
|
@@ -223,53 +358,57 @@ export class ProverNodePublisher {
|
|
|
223
358
|
});
|
|
224
359
|
try {
|
|
225
360
|
const { receipt } = await this.l1TxUtils.sendAndMonitorTransaction({ to: this.rollupContract.address, data });
|
|
361
|
+
if (receipt.status !== 'success') {
|
|
362
|
+
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
|
|
363
|
+
data,
|
|
364
|
+
{
|
|
365
|
+
args: [...txArgs],
|
|
366
|
+
functionName: 'submitEpochRootProof',
|
|
367
|
+
abi: RollupAbi,
|
|
368
|
+
address: this.rollupContract.address,
|
|
369
|
+
},
|
|
370
|
+
/*blobInputs*/ undefined,
|
|
371
|
+
/*stateOverride*/ [],
|
|
372
|
+
);
|
|
373
|
+
this.log.error(`Rollup submit epoch proof tx reverted with ${errorMsg ?? 'unknown error'}`);
|
|
374
|
+
return undefined;
|
|
375
|
+
}
|
|
226
376
|
return receipt;
|
|
227
377
|
} catch (err) {
|
|
228
378
|
this.log.error(`Rollup submit epoch proof failed`, err);
|
|
229
|
-
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
|
|
230
|
-
data,
|
|
231
|
-
{
|
|
232
|
-
args: [...txArgs],
|
|
233
|
-
functionName: 'submitEpochRootProof',
|
|
234
|
-
abi: RollupAbi,
|
|
235
|
-
address: this.rollupContract.address,
|
|
236
|
-
},
|
|
237
|
-
/*blobInputs*/ undefined,
|
|
238
|
-
/*stateOverride*/ [],
|
|
239
|
-
);
|
|
240
|
-
this.log.error(`Rollup submit epoch proof tx reverted. ${errorMsg}`);
|
|
241
379
|
return undefined;
|
|
242
380
|
}
|
|
243
381
|
}
|
|
244
382
|
|
|
245
383
|
private getEpochProofPublicInputsArgs(args: {
|
|
246
|
-
|
|
247
|
-
|
|
384
|
+
fromCheckpoint: CheckpointNumber;
|
|
385
|
+
toCheckpoint: CheckpointNumber;
|
|
248
386
|
publicInputs: RootRollupPublicInputs;
|
|
249
387
|
batchedBlobInputs: BatchedBlob;
|
|
250
388
|
attestations: ViemCommitteeAttestation[];
|
|
251
389
|
}) {
|
|
252
390
|
// Returns arguments for EpochProofLib.sol -> getEpochProofPublicInputs()
|
|
253
391
|
return [
|
|
254
|
-
BigInt(args.
|
|
255
|
-
BigInt(args.
|
|
392
|
+
BigInt(args.fromCheckpoint) /*_start*/,
|
|
393
|
+
BigInt(args.toCheckpoint) /*_end*/,
|
|
256
394
|
{
|
|
257
395
|
previousArchive: args.publicInputs.previousArchiveRoot.toString(),
|
|
258
396
|
endArchive: args.publicInputs.endArchiveRoot.toString(),
|
|
397
|
+
outHash: args.publicInputs.outHash.toString(),
|
|
259
398
|
proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString(),
|
|
260
399
|
} /*_args*/,
|
|
261
|
-
makeTuple(
|
|
400
|
+
makeTuple(MAX_CHECKPOINTS_PER_EPOCH * 2, i =>
|
|
262
401
|
i % 2 === 0
|
|
263
402
|
? args.publicInputs.fees[i / 2].recipient.toField().toString()
|
|
264
403
|
: args.publicInputs.fees[(i - 1) / 2].value.toString(),
|
|
265
404
|
) /*_fees*/,
|
|
266
|
-
args.batchedBlobInputs
|
|
405
|
+
getEthBlobEvaluationInputs(args.batchedBlobInputs) /*_blobPublicInputs*/,
|
|
267
406
|
] as const;
|
|
268
407
|
}
|
|
269
408
|
|
|
270
409
|
private getSubmitEpochProofArgs(args: {
|
|
271
|
-
|
|
272
|
-
|
|
410
|
+
fromCheckpoint: CheckpointNumber;
|
|
411
|
+
toCheckpoint: CheckpointNumber;
|
|
273
412
|
publicInputs: RootRollupPublicInputs;
|
|
274
413
|
proof: Proof;
|
|
275
414
|
batchedBlobInputs: BatchedBlob;
|
|
@@ -283,11 +422,108 @@ export class ProverNodePublisher {
|
|
|
283
422
|
end: argsArray[1],
|
|
284
423
|
args: argsArray[2],
|
|
285
424
|
fees: argsArray[3],
|
|
286
|
-
attestations:
|
|
425
|
+
attestations: CommitteeAttestationsAndSigners.packAttestations(
|
|
287
426
|
args.attestations.map(a => CommitteeAttestation.fromViem(a)),
|
|
288
|
-
)
|
|
427
|
+
),
|
|
289
428
|
blobInputs: argsArray[4],
|
|
290
429
|
proof: proofHex,
|
|
291
430
|
};
|
|
292
431
|
}
|
|
293
432
|
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Decodes a `Root rollup public inputs mismatch`, fetches the on-chain CheckpointLog for any
|
|
436
|
+
* mismatching `checkpointHeaderHashes[i]`, emits a structured error log, and returns a thrown-ready
|
|
437
|
+
* Error with a human-readable summary.
|
|
438
|
+
*
|
|
439
|
+
* Layout of `RootRollupPublicInputs.toFields()`:
|
|
440
|
+
* [0] previousArchiveRoot
|
|
441
|
+
* [1] endArchiveRoot
|
|
442
|
+
* [2] outHash
|
|
443
|
+
* [3 .. 3+N-1] checkpointHeaderHashes[i] for i in 0..N-1 (N = MAX_CHECKPOINTS_PER_EPOCH)
|
|
444
|
+
* [3+N .. 3+3N-1] fees[i] = (recipient, value) for i in 0..N-1
|
|
445
|
+
* [3+3N .. 3+3N+4] EpochConstantData (chainId, version, vkTreeRoot, protocolContractsHash, proverId)
|
|
446
|
+
* [3+3N+5 ..] blobPublicInputs (FinalBlobAccumulator)
|
|
447
|
+
*/
|
|
448
|
+
async function reportPublicInputsMismatch(input: {
|
|
449
|
+
rollupPublicInputs: readonly Fr[];
|
|
450
|
+
argsPublicInputs: readonly Fr[];
|
|
451
|
+
fromCheckpoint: CheckpointNumber;
|
|
452
|
+
toCheckpoint: CheckpointNumber;
|
|
453
|
+
rollupContract: RollupContract;
|
|
454
|
+
log: Logger;
|
|
455
|
+
}): Promise<Error> {
|
|
456
|
+
const { rollupPublicInputs, argsPublicInputs, fromCheckpoint, toCheckpoint, rollupContract, log } = input;
|
|
457
|
+
const N = MAX_CHECKPOINTS_PER_EPOCH;
|
|
458
|
+
const constantsStart = 3 + 3 * N;
|
|
459
|
+
const blobStart = constantsStart + 5;
|
|
460
|
+
const constantLabels = ['chainId', 'version', 'vkTreeRoot', 'protocolContractsHash', 'proverId'];
|
|
461
|
+
|
|
462
|
+
const diffs: { index: number; label: string; rollup: Fr; computed: Fr; checkpointIndex?: number }[] = [];
|
|
463
|
+
const len = Math.max(rollupPublicInputs.length, argsPublicInputs.length);
|
|
464
|
+
for (let i = 0; i < len; i++) {
|
|
465
|
+
const a = rollupPublicInputs[i] ?? Fr.ZERO;
|
|
466
|
+
const b = argsPublicInputs[i] ?? Fr.ZERO;
|
|
467
|
+
if (a.equals(b)) {
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
let label: string;
|
|
471
|
+
let checkpointIndex: number | undefined;
|
|
472
|
+
if (i === 0) {
|
|
473
|
+
label = 'previousArchiveRoot';
|
|
474
|
+
} else if (i === 1) {
|
|
475
|
+
label = 'endArchiveRoot';
|
|
476
|
+
} else if (i === 2) {
|
|
477
|
+
label = 'outHash';
|
|
478
|
+
} else if (i < 3 + N) {
|
|
479
|
+
checkpointIndex = i - 3;
|
|
480
|
+
label = `checkpointHeaderHashes[${checkpointIndex}]`;
|
|
481
|
+
} else if (i < 3 + 3 * N) {
|
|
482
|
+
const feePairIndex = i - (3 + N);
|
|
483
|
+
const feeIndex = Math.floor(feePairIndex / 2);
|
|
484
|
+
const sub = feePairIndex % 2 === 0 ? 'recipient' : 'value';
|
|
485
|
+
label = `fees[${feeIndex}].${sub}`;
|
|
486
|
+
} else if (i < blobStart) {
|
|
487
|
+
label = `constants.${constantLabels[i - constantsStart]}`;
|
|
488
|
+
} else {
|
|
489
|
+
label = `blobPublicInputs[${i - blobStart}]`;
|
|
490
|
+
}
|
|
491
|
+
diffs.push({ index: i, label, rollup: a, computed: b, checkpointIndex });
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// For each mismatching checkpointHeaderHash, fetch the L1 CheckpointLog so the operator can
|
|
495
|
+
// see what was published on-chain alongside the prover's recomputed hash.
|
|
496
|
+
const onChainCheckpoints = await Promise.all(
|
|
497
|
+
diffs
|
|
498
|
+
.filter(d => d.checkpointIndex !== undefined)
|
|
499
|
+
.map(async d => {
|
|
500
|
+
const checkpointNumber = CheckpointNumber(fromCheckpoint + d.checkpointIndex!);
|
|
501
|
+
try {
|
|
502
|
+
const cp = await rollupContract.getCheckpoint(checkpointNumber);
|
|
503
|
+
return { checkpointIndex: d.checkpointIndex!, checkpointNumber, headerHash: cp.headerHash.toString() };
|
|
504
|
+
} catch (err) {
|
|
505
|
+
return { checkpointIndex: d.checkpointIndex!, checkpointNumber, error: (err as Error).message };
|
|
506
|
+
}
|
|
507
|
+
}),
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
log.error(`Root rollup public inputs mismatch`, undefined, {
|
|
511
|
+
fromCheckpoint,
|
|
512
|
+
toCheckpoint,
|
|
513
|
+
numDiffs: diffs.length,
|
|
514
|
+
diffs: diffs.map(d => ({
|
|
515
|
+
index: d.index,
|
|
516
|
+
label: d.label,
|
|
517
|
+
rollup: d.rollup.toString(),
|
|
518
|
+
computed: d.computed.toString(),
|
|
519
|
+
})),
|
|
520
|
+
onChainCheckpoints,
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
const fmt = (inputs: readonly Fr[]) => inputs.map(x => x.toString()).join(', ');
|
|
524
|
+
const summary = diffs.map(d => `[${d.index} ${d.label}] L1=${d.rollup} prover=${d.computed}`).join('\n');
|
|
525
|
+
return new Error(
|
|
526
|
+
`Root rollup public inputs mismatch (${diffs.length} fields differ):\n${summary}\n` +
|
|
527
|
+
`Rollup: ${fmt(rollupPublicInputs)}\nComputed:${fmt(argsPublicInputs)}`,
|
|
528
|
+
);
|
|
529
|
+
}
|