@aztec/prover-node 5.0.0-rc.1 → 5.0.0
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 +73 -68
- package/dest/actions/rerun-epoch-proving-job.d.ts +2 -2
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -1
- package/dest/checkpoint-store.d.ts +42 -37
- package/dest/checkpoint-store.d.ts.map +1 -1
- package/dest/checkpoint-store.js +65 -77
- package/dest/job/checkpoint-prover.d.ts +6 -16
- package/dest/job/checkpoint-prover.d.ts.map +1 -1
- package/dest/job/checkpoint-prover.js +15 -35
- package/dest/job/epoch-session.d.ts +2 -2
- package/dest/job/epoch-session.d.ts.map +1 -1
- package/dest/job/epoch-session.js +20 -9
- package/dest/metrics.d.ts +7 -4
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +14 -6
- package/dest/proof-publishing-service.d.ts +4 -2
- package/dest/proof-publishing-service.d.ts.map +1 -1
- package/dest/proof-publishing-service.js +1 -0
- package/dest/prover-node-publisher.d.ts +5 -5
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +2 -3
- package/dest/prover-node.d.ts +25 -15
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +152 -51
- package/dest/session-manager.d.ts +2 -2
- package/dest/session-manager.d.ts.map +1 -1
- package/dest/session-manager.js +38 -8
- package/package.json +23 -23
- package/src/checkpoint-store.ts +66 -85
- package/src/job/checkpoint-prover.ts +17 -40
- package/src/job/epoch-session.ts +21 -9
- package/src/metrics.ts +15 -12
- package/src/proof-publishing-service.ts +4 -1
- package/src/prover-node-publisher.ts +11 -10
- package/src/prover-node.ts +170 -60
- package/src/session-manager.ts +38 -7
package/README.md
CHANGED
|
@@ -35,7 +35,6 @@ flowchart TB
|
|
|
35
35
|
SessionManager --> EpochTicker[(periodic tick)]
|
|
36
36
|
SessionManager --> FullSessions[(fullSessions)]
|
|
37
37
|
SessionManager --> PartialSessions[(partialSessions)]
|
|
38
|
-
CheckpointStore --> SlotWatcher
|
|
39
38
|
FullSessions -.referenced checkpoints.-> CheckpointStore
|
|
40
39
|
PartialSessions -.referenced checkpoints.-> CheckpointStore
|
|
41
40
|
FullSessions --> TopTreeJob
|
|
@@ -56,8 +55,9 @@ The prover-node splits responsibility between four classes:
|
|
|
56
55
|
- **`CheckpointStore`** — a registry of `CheckpointProver` instances keyed by
|
|
57
56
|
`(checkpointNumber, slot, archiveRoot)`. Each `CheckpointProver` runs its own sub-tree pipeline
|
|
58
57
|
(tx gather → block processing → block-rollup proofs), starting eagerly the moment a
|
|
59
|
-
checkpoint is registered. The store
|
|
60
|
-
|
|
58
|
+
checkpoint is registered. The store holds the canonical checkpoint content that
|
|
59
|
+
`EpochSession`s query when assembling their subsets; a prune cancels and removes the affected
|
|
60
|
+
provers, so every prover in the store is canonical.
|
|
61
61
|
- **`SessionManager`** — owns every live `EpochSession`, the serial reconcile queue,
|
|
62
62
|
the periodic tick, and all `EpochSession` lifecycle decisions. `ProverNode` calls into it
|
|
63
63
|
via `onCheckpointAdded`, `onPrune`, and `startProof`. Every trigger it receives is
|
|
@@ -81,43 +81,38 @@ A `CheckpointProver` is content-addressed by `(checkpoint.number, slot, archiveR
|
|
|
81
81
|
where `archiveRoot` is the checkpoint's own archive root (its post-state). Keying on the
|
|
82
82
|
post-state makes the identity precise: two checkpoints are "the same" iff they produce
|
|
83
83
|
the same archive — so a reorg branch, or a replacement built on the same predecessor but
|
|
84
|
-
with different content, yields a different archive root and a distinct `CheckpointProver
|
|
85
|
-
|
|
84
|
+
with different content, yields a different archive root and a distinct `CheckpointProver`. A prune
|
|
85
|
+
cancels and removes a prover — its sub-tree work forks world-state per block and cannot survive the
|
|
86
|
+
prune — so a re-add, even of identical content, constructs a fresh `CheckpointProver` (block-rollup
|
|
87
|
+
jobs already completed in the proving broker are still reused, as they are content-addressed).
|
|
86
88
|
|
|
87
89
|
```mermaid
|
|
88
90
|
stateDiagram-v2
|
|
89
91
|
[*] --> Created
|
|
90
92
|
Created --> Proving: gather + execute
|
|
91
93
|
Proving --> Proven: sub-tree resolves blockProofs
|
|
92
|
-
Proving --> Cancelled: cancel()
|
|
94
|
+
Proving --> Cancelled: cancel() (prune / shutdown / epoch-session error)
|
|
95
|
+
Proven --> Cancelled: cancel() (prune / reap)
|
|
93
96
|
Proven --> Reaped: reapExpired(epoch)
|
|
94
97
|
Cancelled --> [*]
|
|
95
|
-
|
|
96
|
-
state "Pruned (side)" as Pruned
|
|
97
|
-
Proving --> Pruned: markPruned()
|
|
98
|
-
Pruned --> Proving: markCanonical()
|
|
99
|
-
Proven --> Pruned: markPruned()
|
|
100
|
-
Pruned --> Reaped: SlotWatcher (slot < syncedSlot)
|
|
101
98
|
```
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
###
|
|
110
|
-
|
|
111
|
-
- **Pruned**:
|
|
112
|
-
`
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- **Cancelled**: removed immediately by whichever path called `cancel()` (store
|
|
120
|
-
shutdown, prune past-slot, `EpochSession` error).
|
|
100
|
+
A prune **cancels and removes** the affected `CheckpointProver`s from the store: a prover's
|
|
101
|
+
sub-tree work forks world-state per block, and an L1 prune of a base block faults those reads,
|
|
102
|
+
so there is nothing to preserve across a reorg. A re-add — even of identical content — therefore
|
|
103
|
+
constructs a fresh `CheckpointProver`. `EpochSession`s ask the store for the checkpoints in a slot
|
|
104
|
+
range; every prover in the store is canonical.
|
|
105
|
+
|
|
106
|
+
### Removal rules
|
|
107
|
+
|
|
108
|
+
- **Pruned**: `CheckpointStore.cancelAndRemoveAboveBlock(target)` cancels and removes every
|
|
109
|
+
`CheckpointProver` whose last block is above the prune target, the moment a `chain-pruned`
|
|
110
|
+
event arrives.
|
|
111
|
+
- **Expired**: `CheckpointStore.reapExpired(expiredEpoch)` drops any `CheckpointProver` whose
|
|
112
|
+
epoch is at or below the supplied expired epoch. Once an epoch's proof-submission window has
|
|
113
|
+
closed, its proof can no longer be accepted on L1, so the `CheckpointProver` is no longer needed.
|
|
114
|
+
- **Shutdown**: `CheckpointStore.stop()` cancels every remaining prover and awaits its teardown
|
|
115
|
+
(including teardowns still in flight for provers already removed by a prune or reap).
|
|
121
116
|
|
|
122
117
|
### Eager tx gathering
|
|
123
118
|
|
|
@@ -151,12 +146,18 @@ derived from the canonical content for that slot range.
|
|
|
151
146
|
stateDiagram-v2
|
|
152
147
|
[*] --> initialized
|
|
153
148
|
initialized --> awaiting_checkpoints: start()
|
|
154
|
-
awaiting_checkpoints -->
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
149
|
+
awaiting_checkpoints --> awaiting_root: sub-tree proofs ready, top-tree prove begins
|
|
150
|
+
awaiting_root --> publishing_proof: epoch proof ready, submit to L1
|
|
151
|
+
publishing_proof --> completed: publish succeeds
|
|
152
|
+
publishing_proof --> superseded: longer same-epoch candidate wins
|
|
153
|
+
publishing_proof --> failed: L1 submission errored
|
|
154
|
+
awaiting_checkpoints --> failed: top-tree prove errored
|
|
155
|
+
awaiting_root --> failed: top-tree prove errored
|
|
158
156
|
initialized --> timed_out: deadline
|
|
159
157
|
awaiting_checkpoints --> timed_out: deadline (EpochSession or candidate)
|
|
158
|
+
awaiting_root --> timed_out: deadline (EpochSession or candidate)
|
|
159
|
+
awaiting_checkpoints --> cancelled: cancel()
|
|
160
|
+
awaiting_root --> cancelled: cancel()
|
|
160
161
|
completed --> [*]
|
|
161
162
|
superseded --> [*]
|
|
162
163
|
cancelled --> [*]
|
|
@@ -164,10 +165,16 @@ stateDiagram-v2
|
|
|
164
165
|
failed --> [*]
|
|
165
166
|
```
|
|
166
167
|
|
|
167
|
-
The
|
|
168
|
-
|
|
169
|
-
awaiting each checkpoint's sub-tree result
|
|
170
|
-
|
|
168
|
+
The non-terminal states track the window between `start()` and the L1 submission:
|
|
169
|
+
|
|
170
|
+
- `awaiting-checkpoints` — a `TopTreeJob` is awaiting each checkpoint's sub-tree result
|
|
171
|
+
(`CheckpointProver.whenBlockProofsReady`) before the top-tree prove can begin.
|
|
172
|
+
- `awaiting-root` — the sub-tree proofs are ready and the top-tree (root) prove is running,
|
|
173
|
+
assembling the epoch proof (set via the `TopTreeJob` `beforeProve` hook).
|
|
174
|
+
- `publishing-proof` — the epoch proof is being submitted to L1 via `ProofPublishingService`.
|
|
175
|
+
|
|
176
|
+
`cancel()` and the deadline can fire during any of these pre-submit phases; a terminal state
|
|
177
|
+
set that way wins over the phase transitions (which are guarded by `isTerminal()`).
|
|
171
178
|
|
|
172
179
|
The `EpochSession` does three sequential things: (1) run a `TopTreeJob` over the frozen
|
|
173
180
|
checkpoint subset, (2) hand the resulting proof to `ProofPublishingService` as a
|
|
@@ -276,8 +283,8 @@ sequenceDiagram
|
|
|
276
283
|
alt content key new
|
|
277
284
|
CS->>CP: new CheckpointProver(args)
|
|
278
285
|
CP->>CP: eager gather + sub-tree start
|
|
279
|
-
else content key
|
|
280
|
-
CS->>CP:
|
|
286
|
+
else content key already live
|
|
287
|
+
CS->>CP: reuse existing prover
|
|
281
288
|
end
|
|
282
289
|
PN->>SM: onCheckpointAdded(epoch)
|
|
283
290
|
SM->>SM: queue reconcile({kind:'checkpoint', epoch})
|
|
@@ -294,9 +301,9 @@ sequenceDiagram
|
|
|
294
301
|
participant CS as CheckpointStore
|
|
295
302
|
participant SM as SessionManager
|
|
296
303
|
|
|
297
|
-
L2->>PN: chain-pruned{
|
|
298
|
-
PN->>CS:
|
|
299
|
-
CS->>CS:
|
|
304
|
+
L2->>PN: chain-pruned{block}
|
|
305
|
+
PN->>CS: cancelAndRemoveAboveBlock(prunedToBlock)
|
|
306
|
+
CS->>CS: cancel + remove every CheckpointProver whose last block is above the target
|
|
300
307
|
PN->>SM: onPrune(affectedEpochs)
|
|
301
308
|
SM->>SM: queue reconcile({kind:'prune', affectedEpochs})
|
|
302
309
|
SM->>SM: walk EpochSessions, cancel-and-recreate those with shifted content
|
|
@@ -359,30 +366,28 @@ indexing) leave the mark in place and the next tick retries.
|
|
|
359
366
|
|
|
360
367
|
### checkpoint-added → prune → checkpoint-added (reorg resilience)
|
|
361
368
|
|
|
362
|
-
State: epoch N has checkpoints c1..c4
|
|
363
|
-
|
|
364
|
-
checkpoints `[c1, c2, c3, c4]`.
|
|
369
|
+
State: epoch N has checkpoints c1..c4 (slots s1..s4). `fullSessions[N]` holds `EpochSession`
|
|
370
|
+
**A** with spec `{kind:'full', N, fromSlot:s1, toSlot:s4}`, referencing `[c1, c2, c3, c4]`.
|
|
365
371
|
|
|
366
|
-
1. **chain-pruned arrives, target c3.**
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
changed')`. Epoch N still complete on L1 → reconcile constructs
|
|
370
|
-
the same spec `{full, N, s1, s4}` but checkpoints `[c1, c2, c3]`.
|
|
372
|
+
1. **chain-pruned arrives, target c3.** The store cancels and removes c4 (its last block is
|
|
373
|
+
above the prune target). Reconcile fires: `EpochSession` A's frozen set `[c1, c2, c3, c4]`
|
|
374
|
+
includes the now-cancelled c4, so it no longer matches the store's `[c1, c2, c3]` →
|
|
375
|
+
`A.cancel('canonical content changed')`. Epoch N still complete on L1 → reconcile constructs
|
|
376
|
+
`EpochSession` **B** with the same spec `{full, N, s1, s4}` but checkpoints `[c1, c2, c3]`.
|
|
371
377
|
|
|
372
378
|
2. **`EpochSession` B starts top-tree proving over [c1, c2, c3].**
|
|
373
379
|
|
|
374
|
-
3. **chain-checkpointed arrives, target c4_re (same content key as old c4).** The
|
|
375
|
-
|
|
376
|
-
and
|
|
377
|
-
|
|
378
|
-
root and so get a fresh `CheckpointProver` instead.)
|
|
380
|
+
3. **chain-checkpointed arrives, target c4_re (same content key as old c4).** The old c4
|
|
381
|
+
prover was removed on the prune, so the store constructs a **fresh** `CheckpointProver` for
|
|
382
|
+
c4_re and starts its sub-tree work from scratch. (Its block-rollup jobs are content-addressed
|
|
383
|
+
in the proving broker, so any the old c4 already completed are reused rather than re-proved.)
|
|
379
384
|
|
|
380
|
-
4. **Reconcile fires.** `EpochSession` B's
|
|
381
|
-
|
|
382
|
-
|
|
385
|
+
4. **Reconcile fires.** `EpochSession` B's content for `(s1, s4)` is now `[c1, c2, c3, c4_re]`,
|
|
386
|
+
doesn't match its frozen `[c1, c2, c3]` → `B.cancel(...)`. Construct `EpochSession` **C** with
|
|
387
|
+
the same spec but checkpoints `[c1, c2, c3, c4_re]`.
|
|
383
388
|
|
|
384
|
-
5. **`EpochSession` C reuses the long-lived c1..
|
|
385
|
-
|
|
389
|
+
5. **`EpochSession` C reuses the long-lived c1..c3 `CheckpointProver` instances and the fresh
|
|
390
|
+
c4_re.** Only c4_re's witnesses are regenerated; the top-tree is recomputed. The chonk cache
|
|
386
391
|
survived the reorg because no epoch in this range has expired yet.
|
|
387
392
|
|
|
388
393
|
|
|
@@ -454,19 +459,19 @@ Keying by tx hash makes the cache survive any reorg up to finality; releasing on
|
|
|
454
459
|
finality means we don't grow the cache indefinitely while still keeping every
|
|
455
460
|
reorg-relevant proof.
|
|
456
461
|
|
|
457
|
-
### Why
|
|
462
|
+
### Why is a pruned `CheckpointProver` removed rather than kept for a possible re-add?
|
|
458
463
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
+
A prover's sub-tree work forks world-state per block, and an L1 prune of a base block faults
|
|
465
|
+
those in-flight reads — so the work cannot survive the prune, and there is nothing to preserve
|
|
466
|
+
by keeping the prover around. Removing it on prune and rebuilding on re-add is therefore both
|
|
467
|
+
correct and simpler; the expensive block-rollup proofs are still reused when content re-appears,
|
|
468
|
+
because the proving broker is content-addressed independently of the prover's lifetime.
|
|
464
469
|
|
|
465
470
|
## Configuration
|
|
466
471
|
|
|
467
472
|
| Env var | Description |
|
|
468
473
|
|---|---|
|
|
469
|
-
| `PROVER_NODE_POLLING_INTERVAL_MS` | Polling interval for the L2BlockStream
|
|
474
|
+
| `PROVER_NODE_POLLING_INTERVAL_MS` | Polling interval for the L2BlockStream and the SessionManager periodic tick. Default 1000 ms. |
|
|
470
475
|
| `PROVER_NODE_MAX_PENDING_JOBS` | Cap on the number of non-terminal `EpochSession`s (full + partial). When at limit, reconcile defers opening new full `EpochSession`s; explicit `startProof` calls throw. |
|
|
471
476
|
| `PROVER_NODE_EPOCH_PROVING_DELAY_MS` | Optional sleep at the start of each `EpochSession`, before the TopTreeJob is constructed. Used in tests to give late events time to land. |
|
|
472
477
|
| `TX_GATHERING_TIMEOUT_MS` | Per-block tx gather deadline used by each `CheckpointProver`. |
|
|
@@ -9,5 +9,5 @@ import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
|
9
9
|
* using the state snapshots, and creates a new epoch proving session to prove the downloaded proving job.
|
|
10
10
|
* Proving is done with a local proving broker and agents as specified by the config.
|
|
11
11
|
*/
|
|
12
|
-
export declare function rerunEpochProvingJob(localPath: string, log: Logger, config: DataStoreConfig & ProverBrokerConfig & ProverClientConfig & Pick<L1ContractsConfig, 'aztecEpochDuration'>, genesis?: GenesisData): Promise<"awaiting-checkpoints" | "awaiting-predecessor" | "cancelled" | "completed" | "failed" | "initialized" | "publishing-proof" | "stopped" | "superseded" | "timed-out">;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
12
|
+
export declare function rerunEpochProvingJob(localPath: string, log: Logger, config: DataStoreConfig & ProverBrokerConfig & ProverClientConfig & Pick<L1ContractsConfig, 'aztecEpochDuration'>, genesis?: GenesisData): Promise<"awaiting-checkpoints" | "awaiting-predecessor" | "awaiting-root" | "cancelled" | "completed" | "failed" | "initialized" | "publishing-proof" | "stopped" | "superseded" | "timed-out">;
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVydW4tZXBvY2gtcHJvdmluZy1qb2IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzI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AAO9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAW7D;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,EACjH,OAAO,CAAC,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"rerun-epoch-proving-job.d.ts","sourceRoot":"","sources":["../../src/actions/rerun-epoch-proving-job.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAA+B,MAAM,6BAA6B,CAAC;AAO9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAW7D;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,eAAe,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,EACjH,OAAO,CAAC,EAAE,WAAW,mMAyFtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlockNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
3
3
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
4
4
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
@@ -14,70 +14,75 @@ export type CheckpointProverFactory = (args: CheckpointProverArgs, deps: Checkpo
|
|
|
14
14
|
*
|
|
15
15
|
* The store survives every epoch / session boundary. A prover lives from its first
|
|
16
16
|
* `addOrUpdate` call until either:
|
|
17
|
-
* -
|
|
17
|
+
* - its checkpoint is pruned by an L1 reorg (`cancelAndRemoveAboveBlock`), or
|
|
18
18
|
* - its epoch's proof-submission window has closed (`reapExpired`), so the proof could no
|
|
19
19
|
* longer be accepted on L1 even if produced.
|
|
20
20
|
*
|
|
21
|
-
* A
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* A prover's sub-tree work forks world-state per block and does not survive a prune of a base
|
|
22
|
+
* block, so there is nothing to preserve across a reorg: a pruned prover is cancelled and
|
|
23
|
+
* dropped, and a re-add (even of identical content) constructs a fresh prover.
|
|
24
24
|
*/
|
|
25
25
|
export declare class CheckpointStore {
|
|
26
26
|
private readonly l2BlockSource;
|
|
27
27
|
private readonly proverDeps;
|
|
28
|
-
private readonly options;
|
|
29
28
|
private readonly proverFactoryFn;
|
|
30
29
|
private readonly provers;
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Teardowns of provers already removed from `provers` (by prune or reap), awaited on `stop()`.
|
|
32
|
+
* Keyed by a monotonic id rather than the prover's content id: a prune-then-re-add can leave two
|
|
33
|
+
* teardowns for the same content id in flight at once, which a content-id key would clobber.
|
|
34
|
+
*/
|
|
35
|
+
private readonly pendingTeardowns;
|
|
36
|
+
private nextTeardownId;
|
|
32
37
|
private readonly log;
|
|
33
|
-
constructor(l2BlockSource: Pick<L2BlockSource, '
|
|
34
|
-
slotWatcherPollIntervalMs: number;
|
|
35
|
-
}, bindings?: LoggerBindings, proverFactoryFn?: CheckpointProverFactory);
|
|
38
|
+
constructor(l2BlockSource: Pick<L2BlockSource, 'getL1Constants'>, proverDeps: Omit<CheckpointProverDeps, 'log'>, bindings?: LoggerBindings, proverFactoryFn?: CheckpointProverFactory);
|
|
36
39
|
start(): Promise<void>;
|
|
37
40
|
stop(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Tracks the teardown of a prover just removed from the store so `stop()` can await it. The entry
|
|
43
|
+
* removes itself once teardown settles, so the map stays bounded by the number in flight.
|
|
44
|
+
*/
|
|
45
|
+
private trackTeardown;
|
|
38
46
|
/**
|
|
39
47
|
* Registers a checkpoint with the store. If a prover already exists for the
|
|
40
|
-
* `(number, slot, archive root)` content key
|
|
41
|
-
* otherwise a new prover is constructed.
|
|
48
|
+
* `(number, slot, archive root)` content key it is reused (an at-least-once re-registration of
|
|
49
|
+
* still-canonical content); otherwise a new prover is constructed.
|
|
42
50
|
*/
|
|
43
51
|
addOrUpdate(checkpoint: Checkpoint, data: RegisterCheckpointData): Promise<CheckpointProver>;
|
|
44
52
|
/**
|
|
45
|
-
*
|
|
46
|
-
* `
|
|
47
|
-
*
|
|
53
|
+
* Cancels and removes every prover that holds a block above the prune target. A checkpoint is orphaned by a prune to
|
|
54
|
+
* block `targetBlockNumber` iff its last block sits above the target — including a checkpoint whose range straddles
|
|
55
|
+
* the target (partially orphaned), which block-range marking catches without boundary ambiguity. Keying off the
|
|
56
|
+
* surviving block number (rather than a checkpoint number) is correct even when the source has already
|
|
57
|
+
* re-checkpointed past the divergence: the prune event reports the highest surviving block, which by construction
|
|
58
|
+
* survives on the source, whereas the source's current checkpointed tip can sit above the prune target.
|
|
59
|
+
*
|
|
60
|
+
* The prover's in-flight sub-tree work forks world-state per block and faults once its base block is pruned, so it
|
|
61
|
+
* cannot be reused; it is cancelled (aborting the fork reads) and dropped. A subsequent re-add constructs a fresh
|
|
62
|
+
* prover. Returns the removed provers.
|
|
48
63
|
*/
|
|
49
|
-
|
|
64
|
+
cancelAndRemoveAboveBlock(targetBlockNumber: BlockNumber): CheckpointProver[];
|
|
50
65
|
/**
|
|
51
|
-
* Drops
|
|
52
|
-
*
|
|
53
|
-
*
|
|
66
|
+
* Drops provers whose epoch is at or below the supplied expired epoch. Once an epoch's
|
|
67
|
+
* proof-submission window has closed, its proof can no longer be accepted on L1, so the
|
|
68
|
+
* prover is no longer needed.
|
|
54
69
|
*/
|
|
55
70
|
reapExpired(expiredEpoch: EpochNumber): void;
|
|
56
71
|
/** Returns the prover with the supplied id, or undefined. */
|
|
57
72
|
get(id: string): CheckpointProver | undefined;
|
|
58
73
|
/** Returns the prover for the supplied checkpoint (by its content-addressed id), or undefined. */
|
|
59
74
|
getByCheckpoint(checkpoint: Checkpoint): CheckpointProver | undefined;
|
|
60
|
-
/** Every prover currently in the store
|
|
75
|
+
/** Every prover currently in the store, in insertion order. */
|
|
61
76
|
listAll(): CheckpointProver[];
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Canonical provers whose slot is in the supplied epoch's slot range, sorted by
|
|
66
|
-
* checkpoint number.
|
|
67
|
-
*/
|
|
68
|
-
listCanonicalForEpoch(epoch: EpochNumber): Promise<CheckpointProver[]>;
|
|
69
|
-
/** Canonical provers whose slot falls within `[fromSlot, toSlot]`, sorted by checkpoint number. */
|
|
70
|
-
listCanonicalInSlotRange(fromSlot: SlotNumber, toSlot: SlotNumber): CheckpointProver[];
|
|
77
|
+
/** Provers in the store, sorted by checkpoint number. */
|
|
78
|
+
list(): CheckpointProver[];
|
|
71
79
|
/**
|
|
72
|
-
*
|
|
73
|
-
* slot. Once the chain has moved past, no re-add can revive the prover and its
|
|
74
|
-
* content key is unique enough that an actual re-add would create a new entry.
|
|
75
|
-
*
|
|
76
|
-
* Protected so unit tests can drive a single tick without spinning up the
|
|
77
|
-
* `RunningPromise` and waiting on its interval.
|
|
80
|
+
* Provers whose slot is in the supplied epoch's slot range, sorted by checkpoint number.
|
|
78
81
|
*/
|
|
79
|
-
|
|
82
|
+
listForEpoch(epoch: EpochNumber): Promise<CheckpointProver[]>;
|
|
83
|
+
/** Provers whose slot falls within `[fromSlot, toSlot]`, sorted by checkpoint number. */
|
|
84
|
+
listInSlotRange(fromSlot: SlotNumber, toSlot: SlotNumber): CheckpointProver[];
|
|
80
85
|
}
|
|
81
86
|
/** Sub-set of `L1RollupConstants` actually consumed by the store's slot helpers. */
|
|
82
87
|
export type CheckpointStoreL1Constants = Pick<L1RollupConstants, 'epochDuration'>;
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
88
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hlY2twb2ludC1zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NoZWNrcG9pbnQtc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFvQixXQUFXLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUcsT0FBTyxFQUFlLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBQ3ZGLE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQzNELE9BQU8sRUFBRSxLQUFLLGlCQUFpQixFQUF3QyxNQUFNLDZCQUE2QixDQUFDO0FBRTNHLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxLQUFLLG9CQUFvQixFQUFFLEtBQUssb0JBQW9CLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUVwSCw4R0FBOEc7QUFDOUcsTUFBTSxNQUFNLHNCQUFzQixHQUFHLElBQUksQ0FBQyxvQkFBb0IsRUFBRSxZQUFZLEdBQUcsYUFBYSxDQUFDLENBQUM7QUFFOUYsbUZBQW1GO0FBQ25GLE1BQU0sTUFBTSx1QkFBdUIsR0FBRyxDQUFDLElBQUksRUFBRSxvQkFBb0IsRUFBRSxJQUFJLEVBQUUsb0JBQW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ZLEVBQUUsV0FBVyxHQUFHLElBQUksQ0FpQmxEO0lBRUQsNkRBQTZEO0lBQ3RELEdBQUcsQ0FBQyxFQUFFLEVBQUUsTUFBTSxHQUFHLGdCQUFnQixHQUFHLFNBQVMsQ0FFbkQ7SUFFRCxrR0FBa0c7SUFDM0YsZUFBZSxDQUFDLFVBQVUsRUFBRSxVQUFVLEdBQUcsZ0JBQWdCLEdBQUcsU0FBUyxDQUUzRTtJQUVELCtEQUErRDtJQUN4RCxPQUFPLElBQUksZ0JBQWdCLEVBQUUsQ0FFbkM7SUFFRCx5REFBeUQ7SUFDbEQsSUFBSSxJQUFJLGdCQUFnQixFQUFFLENBRWhDO0lBRUQ7O09BRUc7SUFDVSxZQUFZLENBQUMsS0FBSyxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQyxDQUl6RTtJQUVELHlGQUF5RjtJQUNsRixlQUFlLENBQUMsUUFBUSxFQUFFLFVBQVUsRUFBRSxNQUFNLEVBQUUsVUFBVSxHQUFHLGdCQUFnQixFQUFFLENBRW5GO0NBQ0Y7QUFFRCxvRkFBb0Y7QUFDcEYsTUFBTSxNQUFNLDBCQUEwQixHQUFHLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxlQUFlLENBQUMsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint-store.d.ts","sourceRoot":"","sources":["../src/checkpoint-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"checkpoint-store.d.ts","sourceRoot":"","sources":["../src/checkpoint-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAoB,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC9G,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;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