@aztec/prover-node 0.0.1-commit.2f68f620 → 0.0.1-commit.321f6a9
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 +572 -0
- package/dest/actions/rerun-epoch-proving-job.d.ts +12 -3
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/actions/rerun-epoch-proving-job.js +170 -28
- package/dest/checkpoint-store.d.ts +95 -0
- package/dest/checkpoint-store.d.ts.map +1 -0
- package/dest/checkpoint-store.js +178 -0
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -1
- package/dest/factory.d.ts +4 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +1 -6
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/job/checkpoint-prover.d.ts +154 -0
- package/dest/job/checkpoint-prover.d.ts.map +1 -0
- package/dest/job/checkpoint-prover.js +363 -0
- package/dest/job/epoch-session.d.ts +160 -0
- package/dest/job/epoch-session.d.ts.map +1 -0
- package/dest/job/epoch-session.js +744 -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 +25 -8
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +64 -14
- 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 +7 -19
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +38 -96
- package/dest/prover-node.d.ts +133 -66
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +529 -255
- package/dest/session-manager.d.ts +158 -0
- package/dest/session-manager.d.ts.map +1 -0
- package/dest/session-manager.js +486 -0
- package/dest/test/index.d.ts +7 -6
- package/dest/test/index.d.ts.map +1 -1
- package/package.json +24 -23
- package/src/actions/rerun-epoch-proving-job.ts +178 -30
- package/src/checkpoint-store.ts +212 -0
- package/src/config.ts +2 -1
- package/src/factory.ts +4 -8
- package/src/index.ts +1 -0
- package/src/job/checkpoint-prover.ts +496 -0
- package/src/job/epoch-session.ts +462 -0
- package/src/job/top-tree-job.ts +227 -0
- package/src/metrics.ts +65 -23
- package/src/proof-publishing-service.ts +427 -0
- package/src/prover-node-publisher.ts +52 -121
- package/src/prover-node.ts +617 -277
- package/src/session-manager.ts +589 -0
- package/src/test/index.ts +6 -6
- package/dest/job/epoch-proving-job.d.ts +0 -67
- package/dest/job/epoch-proving-job.d.ts.map +0 -1
- package/dest/job/epoch-proving-job.js +0 -912
- package/src/job/epoch-proving-job.ts +0 -531
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
4
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
|
+
/**
|
|
6
|
+
* Backoff after a transient `publisherFactory.create()` failure. The candidate stays
|
|
7
|
+
* in the queue and the drain is re-scheduled after this delay; if the failure persists
|
|
8
|
+
* the candidate's own `deadline` timer caps the total wait.
|
|
9
|
+
*/ const PUBLISHER_ACQUIRE_RETRY_DELAY_MS = 1_000;
|
|
10
|
+
/**
|
|
11
|
+
* Central owner of L1 proof submission. Sessions offer their proofs here as
|
|
12
|
+
* `PublishCandidate`s; the service serialises one publish at a time, picks the
|
|
13
|
+
* longest candidate per epoch as the winner, and resolves the rest as
|
|
14
|
+
* `'superseded'` without spending L1 gas.
|
|
15
|
+
*
|
|
16
|
+
* Construction-time invariants:
|
|
17
|
+
* - Every publish runs against a freshly-created `ProverNodePublisher` from the factory.
|
|
18
|
+
* - Only one publish is ever in flight (`SerialQueue` drain) — no defensive locks.
|
|
19
|
+
* - Once an L1 publish starts, it runs to completion. `withdraw` is a queue-only
|
|
20
|
+
* operation: it removes a candidate that has not yet started publishing. An in-flight
|
|
21
|
+
* candidate is left alone and its outcome (`'published'` / `'failed'`) is reported as
|
|
22
|
+
* usual — the originating session has already moved to a terminal state via `cancel()`
|
|
23
|
+
* and ignores the late outcome.
|
|
24
|
+
*
|
|
25
|
+
* Eligibility for publication is decided against the proven block number read inside
|
|
26
|
+
* the drain (so the value is consistent with the publish that runs on the same drain
|
|
27
|
+
* pass): a candidate is eligible when its predecessor block is proven and (for partial
|
|
28
|
+
* candidates) the candidate's range extends past the proven tip. `onChainProven` is a
|
|
29
|
+
* wake-up signal; it does not pass state into the drain.
|
|
30
|
+
*/ export class ProofPublishingService {
|
|
31
|
+
deps;
|
|
32
|
+
log;
|
|
33
|
+
epochs;
|
|
34
|
+
/**
|
|
35
|
+
* One drain task at a time. Submits, withdrawals, chain-proven advances, and prunes
|
|
36
|
+
* all schedule a `drain` here, so the eligibility re-check and the L1 publish never
|
|
37
|
+
* interleave.
|
|
38
|
+
*
|
|
39
|
+
* Protected so unit tests can `await drainQueue.syncPoint()` to wait for pending
|
|
40
|
+
* drain work to settle deterministically (no sleeps).
|
|
41
|
+
*/ drainQueue;
|
|
42
|
+
/** Tracks the candidate currently being published. Set while drain is awaiting the L1 publish. */ inFlight;
|
|
43
|
+
stopped;
|
|
44
|
+
constructor(deps){
|
|
45
|
+
this.deps = deps;
|
|
46
|
+
this.epochs = new Map();
|
|
47
|
+
this.drainQueue = new SerialQueue();
|
|
48
|
+
this.stopped = false;
|
|
49
|
+
this.log = createLogger('prover-node:proof-publishing-service', deps.bindings);
|
|
50
|
+
this.drainQueue.start();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Offers a proof candidate to the service. The returned promise resolves once the
|
|
54
|
+
* service settles the candidate's fate: `'published'` if it wins and L1 accepts it,
|
|
55
|
+
* `'superseded'` if a longer candidate for the same epoch wins, `'failed'` if the
|
|
56
|
+
* L1 submission errored, `'withdrawn'` if the originating session cancelled,
|
|
57
|
+
* `'expired'` if the candidate's `deadline` elapsed before publishing started.
|
|
58
|
+
*/ submit(candidate) {
|
|
59
|
+
if (this.stopped) {
|
|
60
|
+
return Promise.resolve('withdrawn');
|
|
61
|
+
}
|
|
62
|
+
const { promise, resolve } = promiseWithResolvers();
|
|
63
|
+
let bucket = this.epochs.get(candidate.epoch);
|
|
64
|
+
if (!bucket) {
|
|
65
|
+
bucket = {
|
|
66
|
+
candidates: new Map(),
|
|
67
|
+
resolvers: new Map(),
|
|
68
|
+
expiryTimers: new Map()
|
|
69
|
+
};
|
|
70
|
+
this.epochs.set(candidate.epoch, bucket);
|
|
71
|
+
}
|
|
72
|
+
bucket.candidates.set(candidate.id, candidate);
|
|
73
|
+
bucket.resolvers.set(candidate.id, resolve);
|
|
74
|
+
this.scheduleExpiry(bucket, candidate);
|
|
75
|
+
this.log.info(`Candidate proof ${candidate.id} submitted for publishing`, {
|
|
76
|
+
candidateId: candidate.id,
|
|
77
|
+
epoch: candidate.epoch,
|
|
78
|
+
startBlock: candidate.startBlock,
|
|
79
|
+
endBlock: candidate.endBlock,
|
|
80
|
+
deadline: candidate.deadline?.toISOString()
|
|
81
|
+
});
|
|
82
|
+
this.scheduleDrain();
|
|
83
|
+
return promise;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Pulls a queued candidate from the bucket and resolves its promise as `'withdrawn'`.
|
|
87
|
+
* If the candidate is already being published, the publish runs to completion and the
|
|
88
|
+
* outcome reports whatever L1 returned — callers that cancelled mid-publish must rely
|
|
89
|
+
* on their own terminal-state check to ignore the late outcome. No-op if the candidate
|
|
90
|
+
* is unknown.
|
|
91
|
+
*/ withdraw(candidateId) {
|
|
92
|
+
if (this.inFlight?.id === candidateId) {
|
|
93
|
+
this.log.debug(`Withdraw for in-flight candidate ${candidateId} ignored; publish will run to completion`, {
|
|
94
|
+
candidateId
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
for (const bucket of this.epochs.values()){
|
|
99
|
+
if (bucket.candidates.has(candidateId)) {
|
|
100
|
+
this.log.info(`Candidate ${candidateId} withdrawn`, {
|
|
101
|
+
candidateId
|
|
102
|
+
});
|
|
103
|
+
this.resolveCandidate(bucket, candidateId, 'withdrawn');
|
|
104
|
+
this.scheduleDrain();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Signals that the L1 proven tip has advanced and the queue should be re-evaluated.
|
|
111
|
+
* The drain reads the proven block number from `l2BlockSource` itself rather than
|
|
112
|
+
* relying on the value passed here — that way the eligibility check uses a value read
|
|
113
|
+
* inside the serial drain, not one captured by a concurrent caller of `onChainProven`.
|
|
114
|
+
*/ onChainProven(_provenBlock) {
|
|
115
|
+
this.scheduleDrain();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Stops accepting new submissions, waits for any in-flight publish to settle, and
|
|
119
|
+
* resolves remaining queued candidates as `'withdrawn'`.
|
|
120
|
+
*/ async stop() {
|
|
121
|
+
this.stopped = true;
|
|
122
|
+
await this.drainQueue.end();
|
|
123
|
+
// Anything still parked in a bucket never ran through drain — resolve it as withdrawn so
|
|
124
|
+
// callers awaiting `submit()` aren't left hanging.
|
|
125
|
+
for (const bucket of Array.from(this.epochs.values())){
|
|
126
|
+
for (const id of Array.from(bucket.candidates.keys())){
|
|
127
|
+
this.resolveCandidate(bucket, id, 'withdrawn');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
this.epochs.clear();
|
|
131
|
+
}
|
|
132
|
+
// ---------------- drain ----------------
|
|
133
|
+
scheduleDrain() {
|
|
134
|
+
if (this.stopped) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
void this.drainQueue.put(()=>this.drain()).catch((err)=>{
|
|
138
|
+
this.log.error(`Drain task threw`, err);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async drain() {
|
|
142
|
+
if (this.stopped) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Read the proven block number afresh inside the serial drain so the eligibility
|
|
146
|
+
// check is consistent with the publish that follows it on the same drain pass.
|
|
147
|
+
const proven = await this.readProvenBlockNumber();
|
|
148
|
+
// Process epochs in ascending order: the proven tip advances monotonically, so the lower
|
|
149
|
+
// epoch is the natural next eligible candidate.
|
|
150
|
+
const orderedEpochs = Array.from(this.epochs.keys()).sort((a, b)=>Number(a) - Number(b));
|
|
151
|
+
for (const epoch of orderedEpochs){
|
|
152
|
+
const bucket = this.epochs.get(epoch);
|
|
153
|
+
const eligible = this.pickEpochWinner(bucket, proven);
|
|
154
|
+
if (!eligible) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
await this.publishWinner(epoch, eligible.winner, bucket);
|
|
158
|
+
}
|
|
159
|
+
// Drop empty buckets
|
|
160
|
+
for (const [key, bucket] of Array.from(this.epochs.entries())){
|
|
161
|
+
if (bucket.candidates.size === 0) {
|
|
162
|
+
this.epochs.delete(key);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Picks the winning candidate for a given epoch. Partial candidates whose `endBlock` is
|
|
168
|
+
* already proven on-chain resolve `'superseded'`.
|
|
169
|
+
* Full candidates are never auto-superseded by the proven tip — multiple prover-nodes
|
|
170
|
+
* legitimately submit redundant full epoch proofs (one per prover-id) and L1 records each.
|
|
171
|
+
* Among the remaining candidates with their predecessor proven, the one with the highest
|
|
172
|
+
* `endBlock` wins; the others resolve `'superseded'`.
|
|
173
|
+
*/ pickEpochWinner(bucket, proven) {
|
|
174
|
+
const now = this.deps.dateProvider.now();
|
|
175
|
+
// Resolve any candidate whose deadline has already passed.
|
|
176
|
+
for (const candidate of Array.from(bucket.candidates.values())){
|
|
177
|
+
if (candidate.deadline && candidate.deadline.getTime() <= now) {
|
|
178
|
+
this.resolveCandidate(bucket, candidate.id, 'expired');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Drop partial candidates the proven chain has already caught up to.
|
|
182
|
+
for (const candidate of Array.from(bucket.candidates.values())){
|
|
183
|
+
if (candidate.kind === 'partial' && candidate.endBlock <= proven) {
|
|
184
|
+
this.resolveCandidate(bucket, candidate.id, 'superseded');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const remaining = Array.from(bucket.candidates.values()).filter((c)=>c.startBlock - 1 <= proven);
|
|
188
|
+
if (remaining.length === 0) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
const winner = remaining.reduce((best, c)=>c.endBlock > best.endBlock ? c : best);
|
|
192
|
+
// Every other same-epoch candidate is superseded by the winner.
|
|
193
|
+
for (const candidate of remaining){
|
|
194
|
+
if (candidate.id !== winner.id) {
|
|
195
|
+
this.resolveCandidate(bucket, candidate.id, 'superseded');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
winner
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
async publishWinner(epoch, winner, bucket) {
|
|
203
|
+
let publisher;
|
|
204
|
+
try {
|
|
205
|
+
publisher = await this.deps.publisherFactory.create();
|
|
206
|
+
} catch (err) {
|
|
207
|
+
// Treat this as transient: the publisher pool may be temporarily exhausted
|
|
208
|
+
// (every signer busy, funding tx in flight, etc.). Leave the candidate queued and
|
|
209
|
+
// schedule another drain after a short backoff. If the failure persists past the
|
|
210
|
+
// candidate's deadline the expiry timer will resolve it as `'expired'`.
|
|
211
|
+
this.log.warn(`Failed to acquire publisher for candidate ${winner.id}; retrying`, {
|
|
212
|
+
candidateId: winner.id,
|
|
213
|
+
epoch: winner.epoch,
|
|
214
|
+
retryDelayMs: PUBLISHER_ACQUIRE_RETRY_DELAY_MS,
|
|
215
|
+
err
|
|
216
|
+
});
|
|
217
|
+
setTimeout(()=>this.scheduleDrain(), PUBLISHER_ACQUIRE_RETRY_DELAY_MS);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.inFlight = {
|
|
221
|
+
id: winner.id
|
|
222
|
+
};
|
|
223
|
+
this.log.info(`Publishing candidate ${winner.id}`, {
|
|
224
|
+
candidateId: winner.id,
|
|
225
|
+
epoch: winner.epoch,
|
|
226
|
+
startBlock: winner.startBlock,
|
|
227
|
+
endBlock: winner.endBlock,
|
|
228
|
+
fromCheckpoint: winner.fromCheckpoint,
|
|
229
|
+
toCheckpoint: winner.toCheckpoint
|
|
230
|
+
});
|
|
231
|
+
const outcome = await this.runPublish(winner, publisher);
|
|
232
|
+
this.inFlight = undefined;
|
|
233
|
+
this.resolveCandidate(bucket, winner.id, outcome);
|
|
234
|
+
if (bucket.candidates.size === 0) {
|
|
235
|
+
this.epochs.delete(epoch);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async runPublish(candidate, publisher) {
|
|
239
|
+
const submitArgs = {
|
|
240
|
+
epochNumber: candidate.epoch,
|
|
241
|
+
fromCheckpoint: candidate.fromCheckpoint,
|
|
242
|
+
toCheckpoint: candidate.toCheckpoint,
|
|
243
|
+
publicInputs: candidate.publicInputs,
|
|
244
|
+
proof: candidate.proof,
|
|
245
|
+
batchedBlobInputs: candidate.batchedBlobInputs,
|
|
246
|
+
attestations: candidate.attestations,
|
|
247
|
+
headers: candidate.headers,
|
|
248
|
+
// Stop the L1 tx retrying past the candidate's submission-window deadline.
|
|
249
|
+
deadline: candidate.deadline
|
|
250
|
+
};
|
|
251
|
+
if (this.deps.config.skipSubmitProof) {
|
|
252
|
+
try {
|
|
253
|
+
await publisher.analyzeEpochProofSubmission(submitArgs);
|
|
254
|
+
return 'published';
|
|
255
|
+
} catch (err) {
|
|
256
|
+
this.log.warn(`Failed to analyze estimated L1 fees for candidate ${candidate.id}`, {
|
|
257
|
+
err,
|
|
258
|
+
candidateId: candidate.id,
|
|
259
|
+
epoch: candidate.epoch
|
|
260
|
+
});
|
|
261
|
+
// Analyze-mode failures are recorded but the session shouldn't enter `failed` —
|
|
262
|
+
// the operator opted out of submission. Match the previous EpochSession behaviour.
|
|
263
|
+
return 'published';
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const success = await publisher.submitEpochProof(submitArgs);
|
|
268
|
+
return success ? 'published' : 'failed';
|
|
269
|
+
} catch (err) {
|
|
270
|
+
this.log.error(`Error publishing candidate ${candidate.id}`, err, {
|
|
271
|
+
candidateId: candidate.id,
|
|
272
|
+
epoch: candidate.epoch
|
|
273
|
+
});
|
|
274
|
+
return 'failed';
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
resolveCandidate(bucket, id, outcome) {
|
|
278
|
+
const resolve = bucket.resolvers.get(id);
|
|
279
|
+
const timer = bucket.expiryTimers.get(id);
|
|
280
|
+
if (timer) {
|
|
281
|
+
clearTimeout(timer);
|
|
282
|
+
bucket.expiryTimers.delete(id);
|
|
283
|
+
}
|
|
284
|
+
bucket.candidates.delete(id);
|
|
285
|
+
bucket.resolvers.delete(id);
|
|
286
|
+
if (resolve) {
|
|
287
|
+
this.log.info(`Candidate ${id} resolved as ${outcome}`, {
|
|
288
|
+
candidateId: id,
|
|
289
|
+
outcome
|
|
290
|
+
});
|
|
291
|
+
resolve(outcome);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Arms a per-candidate expiry timer if the candidate carries a deadline. When the timer
|
|
296
|
+
* fires, the candidate resolves as `'expired'` — unless it is already in flight, in
|
|
297
|
+
* which case the publish runs to completion (the timer becomes a no-op). The timer is
|
|
298
|
+
* cleared by `resolveCandidate` whenever the candidate settles for any other reason.
|
|
299
|
+
*/ scheduleExpiry(bucket, candidate) {
|
|
300
|
+
if (!candidate.deadline) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const delay = Math.max(candidate.deadline.getTime() - this.deps.dateProvider.now(), 0);
|
|
304
|
+
const timer = setTimeout(()=>this.handleExpiry(candidate.id), delay);
|
|
305
|
+
bucket.expiryTimers.set(candidate.id, timer);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Protected so unit tests can drive the deadline path without waiting on the real
|
|
309
|
+
* `setTimeout` to fire. Production code calls this only via the per-candidate timer
|
|
310
|
+
* armed in `scheduleExpiry`.
|
|
311
|
+
*/ handleExpiry(candidateId) {
|
|
312
|
+
if (this.inFlight?.id === candidateId) {
|
|
313
|
+
this.log.debug(`Expiry for in-flight candidate ${candidateId} ignored; publish will run to completion`, {
|
|
314
|
+
candidateId
|
|
315
|
+
});
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
for (const bucket of this.epochs.values()){
|
|
319
|
+
if (bucket.candidates.has(candidateId)) {
|
|
320
|
+
this.log.info(`Candidate ${candidateId} expired before publishing`, {
|
|
321
|
+
candidateId
|
|
322
|
+
});
|
|
323
|
+
this.resolveCandidate(bucket, candidateId, 'expired');
|
|
324
|
+
this.scheduleDrain();
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async readProvenBlockNumber() {
|
|
330
|
+
const proven = await this.deps.l2BlockSource.getBlockNumber({
|
|
331
|
+
tag: 'proven'
|
|
332
|
+
});
|
|
333
|
+
return BlockNumber(proven ?? 0);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { BatchedBlob } from '@aztec/blob-lib';
|
|
2
|
-
import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
|
|
3
2
|
import type { RollupContract, ViemCommitteeAttestation } from '@aztec/ethereum/contracts';
|
|
4
3
|
import type { L1TxUtils } from '@aztec/ethereum/l1-tx-utils';
|
|
5
4
|
import { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
6
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
7
|
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
9
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
10
8
|
import type { PublisherConfig, TxSenderConfig } from '@aztec/sequencer-client';
|
|
11
9
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
12
|
-
import type {
|
|
10
|
+
import type { CheckpointHeader, RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
13
11
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
14
12
|
import { type Hex } from 'viem';
|
|
15
13
|
/** Arguments to the submitEpochProof method of the rollup contract */
|
|
@@ -20,11 +18,10 @@ export type L1SubmitEpochProofArgs = {
|
|
|
20
18
|
endTimestamp: Fr;
|
|
21
19
|
outHash: Fr;
|
|
22
20
|
proverId: Fr;
|
|
23
|
-
|
|
21
|
+
headers: CheckpointHeader[];
|
|
24
22
|
proof: Proof;
|
|
25
23
|
};
|
|
26
24
|
export declare class ProverNodePublisher {
|
|
27
|
-
private interrupted;
|
|
28
25
|
private metrics;
|
|
29
26
|
protected log: Logger;
|
|
30
27
|
protected rollupContract: RollupContract;
|
|
@@ -37,15 +34,6 @@ export declare class ProverNodePublisher {
|
|
|
37
34
|
telemetry?: TelemetryClient;
|
|
38
35
|
}, bindings?: LoggerBindings);
|
|
39
36
|
getRollupContract(): RollupContract;
|
|
40
|
-
/**
|
|
41
|
-
* Calling `interrupt` will cause any in progress call to `publishRollup` to return `false` asap.
|
|
42
|
-
* Be warned, the call may return false even if the tx subsequently gets successfully mined.
|
|
43
|
-
* In practice this shouldn't matter, as we'll only ever be calling `interrupt` when we know it's going to fail.
|
|
44
|
-
* A call to `restart` is required before you can continue publishing.
|
|
45
|
-
*/
|
|
46
|
-
interrupt(): void;
|
|
47
|
-
/** Restarts the publisher after calling `interrupt`. */
|
|
48
|
-
restart(): void;
|
|
49
37
|
getSenderAddress(): EthAddress;
|
|
50
38
|
submitEpochProof(args: {
|
|
51
39
|
epochNumber: EpochNumber;
|
|
@@ -55,11 +43,10 @@ export declare class ProverNodePublisher {
|
|
|
55
43
|
proof: Proof;
|
|
56
44
|
batchedBlobInputs: BatchedBlob;
|
|
57
45
|
attestations: ViemCommitteeAttestation[];
|
|
46
|
+
headers: CheckpointHeader[];
|
|
47
|
+
/** Wall-clock deadline (proof-submission window end) past which the L1 tx should stop retrying. */
|
|
48
|
+
deadline?: Date;
|
|
58
49
|
}): Promise<boolean>;
|
|
59
|
-
private waitUntilStartBuildsOnProven;
|
|
60
|
-
private getProvenCheckpoint;
|
|
61
|
-
private isStartBuildingOnProven;
|
|
62
|
-
private getSecondsUntilProofSubmissionWindowEnd;
|
|
63
50
|
private validateEpochProofSubmission;
|
|
64
51
|
/**
|
|
65
52
|
* Estimates what submitting the epoch proof would have cost on L1 without actually sending it.
|
|
@@ -74,10 +61,11 @@ export declare class ProverNodePublisher {
|
|
|
74
61
|
proof: Proof;
|
|
75
62
|
batchedBlobInputs: BatchedBlob;
|
|
76
63
|
attestations: ViemCommitteeAttestation[];
|
|
64
|
+
headers: CheckpointHeader[];
|
|
77
65
|
}): Promise<void>;
|
|
78
66
|
private encodeSubmitEpochProofCalldata;
|
|
79
67
|
private sendSubmitEpochProofTx;
|
|
80
68
|
private getEpochProofPublicInputsArgs;
|
|
81
69
|
private getSubmitEpochProofArgs;
|
|
82
70
|
}
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
71
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmVyLW5vZGUtcHVibGlzaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcHJvdmVyLW5vZGUtcHVibGlzaGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQThCLE1BQU0saUJBQWlCLENBQUM7QUFFMUUsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLHdCQUF3QixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDMUYsT0F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0lBQ1UsMkJBQTJCLENBQUMsSUFBSSxFQUFFO1FBQzdDLFdBQVcsRUFBRSxXQUFXLENBQUM7UUFDekIsY0FBYyxFQUFFLGdCQUFnQixDQUFDO1FBQ2pDLFlBQVksRUFBRSxnQkFBZ0IsQ0FBQztRQUMvQixZQUFZLEVBQUUsc0JBQXNCLENBQUM7UUFDckMsS0FBSyxFQUFFLEtBQUssQ0FBQztRQUNiLGlCQUFpQixFQUFFLFdBQVcsQ0FBQztRQUMvQixZQUFZLEVBQUUsd0JBQXdCLEVBQUUsQ0FBQztRQUN6QyxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsQ0FBQztLQUM3QixHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FzQ2hCO0lBRUQsT0FBTyxDQUFDLDhCQUE4QjtZQWdCeEIsc0JBQXNCO0lBaURwQyxPQUFPLENBQUMsNkJBQTZCO0lBdUJyQyxPQUFPLENBQUMsdUJBQXVCO0NBd0JoQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prover-node-publisher.d.ts","sourceRoot":"","sources":["../src/prover-node-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA8B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"prover-node-publisher.d.ts","sourceRoot":"","sources":["../src/prover-node-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA8B,MAAM,iBAAiB,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE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,EAAE,WAAW,CAAC;QACzB,cAAc,EAAE,gBAAgB,CAAC;QACjC,YAAY,EAAE,gBAAgB,CAAC;QAC/B,YAAY,EAAE,sBAAsB,CAAC;QACrC,KAAK,EAAE,KAAK,CAAC;QACb,iBAAiB,EAAE,WAAW,CAAC;QAC/B,YAAY,EAAE,wBAAwB,EAAE,CAAC;QACzC,OAAO,EAAE,gBAAgB,EAAE,CAAC;QAC5B,mGAAmG;QACnG,QAAQ,CAAC,EAAE,IAAI,CAAC;KACjB,GAAG,OAAO,CAAC,OAAO,CAAC,CA6CnB;YAEa,4BAA4B;IAoE1C;;;;OAIG;IACU,2BAA2B,CAAC,IAAI,EAAE;QAC7C,WAAW,EAAE,WAAW,CAAC;QACzB,cAAc,EAAE,gBAAgB,CAAC;QACjC,YAAY,EAAE,gBAAgB,CAAC;QAC/B,YAAY,EAAE,sBAAsB,CAAC;QACrC,KAAK,EAAE,KAAK,CAAC;QACb,iBAAiB,EAAE,WAAW,CAAC;QAC/B,YAAY,EAAE,wBAAwB,EAAE,CAAC;QACzC,OAAO,EAAE,gBAAgB,EAAE,CAAC;KAC7B,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChB;IAED,OAAO,CAAC,8BAA8B;YAgBxB,sBAAsB;IAiDpC,OAAO,CAAC,6BAA6B;IAuBrC,OAAO,CAAC,uBAAuB;CAwBhC"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { getEthBlobEvaluationInputs } from '@aztec/blob-lib';
|
|
2
2
|
import { MAX_CHECKPOINTS_PER_EPOCH } from '@aztec/constants';
|
|
3
|
-
import { makeTuple } from '@aztec/foundation/array';
|
|
4
3
|
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
5
4
|
import { areArraysEqual } from '@aztec/foundation/collection';
|
|
6
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
6
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
8
7
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
10
8
|
import { Timer } from '@aztec/foundation/timer';
|
|
11
9
|
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
12
10
|
import { CommitteeAttestation, CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
13
|
-
import { getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
14
11
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
15
12
|
import { inspect } from 'util';
|
|
16
13
|
import { encodeFunctionData, formatEther, formatGwei } from 'viem';
|
|
17
14
|
import { ProverNodePublisherMetrics } from './metrics.js';
|
|
18
15
|
export class ProverNodePublisher {
|
|
19
|
-
interrupted = false;
|
|
20
16
|
metrics;
|
|
21
17
|
log;
|
|
22
18
|
rollupContract;
|
|
@@ -33,19 +29,6 @@ export class ProverNodePublisher {
|
|
|
33
29
|
getRollupContract() {
|
|
34
30
|
return this.rollupContract;
|
|
35
31
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Calling `interrupt` will cause any in progress call to `publishRollup` to return `false` asap.
|
|
38
|
-
* Be warned, the call may return false even if the tx subsequently gets successfully mined.
|
|
39
|
-
* In practice this shouldn't matter, as we'll only ever be calling `interrupt` when we know it's going to fail.
|
|
40
|
-
* A call to `restart` is required before you can continue publishing.
|
|
41
|
-
*/ interrupt() {
|
|
42
|
-
this.interrupted = true;
|
|
43
|
-
this.l1TxUtils.interrupt();
|
|
44
|
-
}
|
|
45
|
-
/** Restarts the publisher after calling `interrupt`. */ restart() {
|
|
46
|
-
this.interrupted = false;
|
|
47
|
-
this.l1TxUtils.restart();
|
|
48
|
-
}
|
|
49
32
|
getSenderAddress() {
|
|
50
33
|
return this.l1TxUtils.getSenderAddress();
|
|
51
34
|
}
|
|
@@ -56,86 +39,43 @@ export class ProverNodePublisher {
|
|
|
56
39
|
fromCheckpoint,
|
|
57
40
|
toCheckpoint
|
|
58
41
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
await this.validateEpochProofSubmission(args);
|
|
67
|
-
const txReceipt = await this.sendSubmitEpochProofTx(args);
|
|
68
|
-
if (!txReceipt) {
|
|
69
|
-
this.log.error(`Failed to mine submitEpochProof tx`, undefined, ctx);
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
this.metrics.recordSenderBalance(await this.l1TxUtils.getSenderBalance(), this.l1TxUtils.getSenderAddress().toString());
|
|
74
|
-
} catch (err) {
|
|
75
|
-
this.log.warn(`Failed to record the ETH balance of the prover node: ${err}`);
|
|
76
|
-
}
|
|
77
|
-
// Tx was mined successfully
|
|
78
|
-
if (txReceipt.status === 'success') {
|
|
79
|
-
const tx = await this.l1TxUtils.getTransactionStats(txReceipt.transactionHash);
|
|
80
|
-
const stats = {
|
|
81
|
-
gasPrice: txReceipt.effectiveGasPrice,
|
|
82
|
-
gasUsed: txReceipt.gasUsed,
|
|
83
|
-
transactionHash: txReceipt.transactionHash,
|
|
84
|
-
calldataGas: tx.calldataGas,
|
|
85
|
-
calldataSize: tx.calldataSize,
|
|
86
|
-
sender: tx.sender,
|
|
87
|
-
blobDataGas: 0n,
|
|
88
|
-
blobGasUsed: 0n,
|
|
89
|
-
eventName: 'proof-published-to-l1'
|
|
90
|
-
};
|
|
91
|
-
this.log.info(`Published epoch proof to L1 rollup contract`, {
|
|
92
|
-
...stats,
|
|
93
|
-
...ctx
|
|
94
|
-
});
|
|
95
|
-
this.metrics.recordSubmitProof(timer.ms(), stats);
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
this.metrics.recordFailedTx();
|
|
99
|
-
this.log.error(`Rollup submitEpochProof tx reverted ${txReceipt.transactionHash}`, undefined, ctx);
|
|
42
|
+
const timer = new Timer();
|
|
43
|
+
// Validate epoch proof range and hashes are correct before submitting
|
|
44
|
+
await this.validateEpochProofSubmission(args);
|
|
45
|
+
const txReceipt = await this.sendSubmitEpochProofTx(args);
|
|
46
|
+
if (!txReceipt) {
|
|
47
|
+
this.log.error(`Failed to mine submitEpochProof tx`, undefined, ctx);
|
|
48
|
+
return false;
|
|
100
49
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const { epochNumber, fromCheckpoint } = args;
|
|
106
|
-
const provenCheckpoint = await this.getProvenCheckpoint();
|
|
107
|
-
if (this.isStartBuildingOnProven(fromCheckpoint, provenCheckpoint)) {
|
|
108
|
-
return true;
|
|
50
|
+
try {
|
|
51
|
+
this.metrics.recordSenderBalance(await this.l1TxUtils.getSenderBalance(), this.l1TxUtils.getSenderAddress().toString());
|
|
52
|
+
} catch (err) {
|
|
53
|
+
this.log.warn(`Failed to record the ETH balance of the prover node: ${err}`);
|
|
109
54
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
55
|
+
// Tx was mined successfully
|
|
56
|
+
if (txReceipt.status === 'success') {
|
|
57
|
+
const tx = await this.l1TxUtils.getTransactionStats(txReceipt.transactionHash);
|
|
58
|
+
const stats = {
|
|
59
|
+
gasPrice: txReceipt.effectiveGasPrice,
|
|
60
|
+
gasUsed: txReceipt.gasUsed,
|
|
61
|
+
transactionHash: txReceipt.transactionHash,
|
|
62
|
+
calldataGas: tx.calldataGas,
|
|
63
|
+
calldataSize: tx.calldataSize,
|
|
64
|
+
sender: tx.sender,
|
|
65
|
+
blobDataGas: 0n,
|
|
66
|
+
blobGasUsed: 0n,
|
|
67
|
+
eventName: 'proof-published-to-l1'
|
|
68
|
+
};
|
|
69
|
+
this.log.info(`Published epoch proof to L1 rollup contract`, {
|
|
70
|
+
...stats,
|
|
71
|
+
...ctx
|
|
124
72
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
isStartBuildingOnProven(fromCheckpoint, provenCheckpoint) {
|
|
133
|
-
return fromCheckpoint - 1 <= provenCheckpoint;
|
|
134
|
-
}
|
|
135
|
-
async getSecondsUntilProofSubmissionWindowEnd(epochNumber) {
|
|
136
|
-
const deadline = getProofSubmissionDeadlineTimestamp(epochNumber, await this.rollupContract.getRollupConstants());
|
|
137
|
-
const now = BigInt(Math.floor(Date.now() / 1000));
|
|
138
|
-
return Math.max(Number(deadline - now), 0.001);
|
|
73
|
+
this.metrics.recordSubmitProof(timer.ms(), stats);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
this.metrics.recordFailedTx();
|
|
77
|
+
this.log.error(`Rollup submitEpochProof tx reverted ${txReceipt.transactionHash}`, undefined, ctx);
|
|
78
|
+
return false;
|
|
139
79
|
}
|
|
140
80
|
async validateEpochProofSubmission(args) {
|
|
141
81
|
const { fromCheckpoint, toCheckpoint, publicInputs, batchedBlobInputs } = args;
|
|
@@ -247,6 +187,8 @@ export class ProverNodePublisher {
|
|
|
247
187
|
const { receipt } = await this.l1TxUtils.sendAndMonitorTransaction({
|
|
248
188
|
to: this.proofSubmissionTarget,
|
|
249
189
|
data
|
|
190
|
+
}, {
|
|
191
|
+
txTimeoutAt: args.deadline
|
|
250
192
|
});
|
|
251
193
|
if (receipt.status !== 'success') {
|
|
252
194
|
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(data, {
|
|
@@ -277,7 +219,7 @@ export class ProverNodePublisher {
|
|
|
277
219
|
outHash: args.publicInputs.outHash.toString(),
|
|
278
220
|
proverId: EthAddress.fromField(args.publicInputs.constants.proverId).toString()
|
|
279
221
|
} /*_args*/ ,
|
|
280
|
-
|
|
222
|
+
args.headers.map((header)=>header.toViem()),
|
|
281
223
|
getEthBlobEvaluationInputs(args.batchedBlobInputs)
|
|
282
224
|
];
|
|
283
225
|
}
|
|
@@ -289,7 +231,7 @@ export class ProverNodePublisher {
|
|
|
289
231
|
start: argsArray[0],
|
|
290
232
|
end: argsArray[1],
|
|
291
233
|
args: argsArray[2],
|
|
292
|
-
|
|
234
|
+
headers: argsArray[3],
|
|
293
235
|
attestations: CommitteeAttestationsAndSigners.packAttestations(args.attestations.map((a)=>CommitteeAttestation.fromViem(a))),
|
|
294
236
|
blobInputs: argsArray[4],
|
|
295
237
|
proof: proofHex
|