@aztec/prover-client 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/dest/light/lightweight_checkpoint_builder.d.ts +1 -1
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -1
- package/dest/light/lightweight_checkpoint_builder.js +3 -1
- package/dest/mocks/test_context.d.ts +9 -11
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +13 -22
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/checkpoint-proving-state.d.ts +13 -36
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +18 -125
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +116 -62
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +1005 -90
- package/dest/orchestrator/chonk-cache.d.ts +39 -0
- package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
- package/dest/orchestrator/chonk-cache.js +80 -0
- package/dest/orchestrator/index.d.ts +2 -3
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +1 -2
- package/dest/orchestrator/proving-scheduler.d.ts +26 -17
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -1
- package/dest/orchestrator/proving-scheduler.js +28 -25
- package/dest/orchestrator/top-tree-orchestrator.d.ts +11 -6
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/top-tree-orchestrator.js +71 -21
- package/dest/orchestrator/top-tree-proving-state.d.ts +1 -1
- package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.d.ts +3 -3
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/prover-client/prover-client.d.ts +17 -19
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +24 -25
- package/dest/proving_broker/broker_prover_facade.d.ts +3 -3
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +5 -0
- package/dest/proving_broker/proving_broker.d.ts +1 -1
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +60 -17
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -1
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/memory.js +10 -0
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +13 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +30 -3
- package/dest/proving_broker/proving_broker_database.d.ts +15 -1
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/test/epoch_settlement.d.ts +36 -0
- package/dest/test/epoch_settlement.d.ts.map +1 -0
- package/dest/test/epoch_settlement.js +52 -0
- package/dest/test/index.d.ts +2 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/dest/test/mock_prover.d.ts +1 -1
- package/dest/test/mock_prover.js +2 -2
- package/package.json +17 -16
- package/src/light/lightweight_checkpoint_builder.ts +2 -0
- package/src/mocks/test_context.ts +14 -34
- package/src/orchestrator/checkpoint-proving-state.ts +14 -168
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +902 -129
- package/src/orchestrator/chonk-cache.ts +99 -0
- package/src/orchestrator/index.ts +1 -2
- package/src/orchestrator/proving-scheduler.ts +29 -25
- package/src/orchestrator/top-tree-orchestrator.ts +114 -44
- package/src/orchestrator/top-tree-proving-state.ts +0 -1
- package/src/orchestrator/tx-proving-state.ts +3 -3
- package/src/prover-client/prover-client.ts +35 -49
- package/src/proving_broker/broker_prover_facade.ts +4 -2
- package/src/proving_broker/proving_broker.ts +57 -17
- package/src/proving_broker/proving_broker_database/memory.ts +10 -0
- package/src/proving_broker/proving_broker_database/persisted.ts +40 -5
- package/src/proving_broker/proving_broker_database.ts +16 -0
- package/src/test/epoch_settlement.ts +82 -0
- package/src/test/index.ts +1 -0
- package/src/test/mock_prover.ts +2 -2
- package/dest/orchestrator/epoch-proving-context.d.ts +0 -51
- package/dest/orchestrator/epoch-proving-context.d.ts.map +0 -1
- package/dest/orchestrator/epoch-proving-context.js +0 -81
- package/dest/orchestrator/epoch-proving-state.d.ts +0 -75
- package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
- package/dest/orchestrator/epoch-proving-state.js +0 -269
- package/dest/orchestrator/orchestrator.d.ts +0 -118
- package/dest/orchestrator/orchestrator.d.ts.map +0 -1
- package/dest/orchestrator/orchestrator.js +0 -1113
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts +0 -62
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +0 -1
- package/dest/orchestrator/top-tree-proving-scheduler.js +0 -73
- package/dest/prover-client/server-epoch-prover.d.ts +0 -32
- package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
- package/dest/prover-client/server-epoch-prover.js +0 -40
- package/src/orchestrator/epoch-proving-context.ts +0 -101
- package/src/orchestrator/epoch-proving-state.ts +0 -380
- package/src/orchestrator/orchestrator.ts +0 -1111
- package/src/orchestrator/top-tree-proving-scheduler.ts +0 -154
- package/src/prover-client/server-epoch-prover.ts +0 -69
|
@@ -32,9 +32,23 @@ export interface ProvingBrokerDatabase {
|
|
|
32
32
|
* @param err - The error that occurred while processing the proof request
|
|
33
33
|
*/
|
|
34
34
|
setProvingJobError(id: ProvingJobId, err: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Records that a proof request was cancelled. Unlike a result or error this is not terminal:
|
|
37
|
+
* re-enqueuing the same job id revives it, so the aborted state can survive a restart without
|
|
38
|
+
* permanently blocking the proof.
|
|
39
|
+
* @param id - The ID of the cancelled proof request
|
|
40
|
+
*/
|
|
41
|
+
setProvingJobAborted(id: ProvingJobId): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Clears any stored result for a proof request, returning it to the pending state while keeping
|
|
44
|
+
* the job itself. Used when reviving an aborted job so the revival is persisted and a restart
|
|
45
|
+
* cannot resurrect the stale aborted state.
|
|
46
|
+
* @param id - The ID of the proof request whose result should be cleared
|
|
47
|
+
*/
|
|
48
|
+
deleteProvingJobResult(id: ProvingJobId): Promise<void>;
|
|
35
49
|
/**
|
|
36
50
|
* Closes the database
|
|
37
51
|
*/
|
|
38
52
|
close(): Promise<void>;
|
|
39
53
|
}
|
|
40
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmluZ19icm9rZXJfZGF0YWJhc2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcm92aW5nX2Jyb2tlci9wcm92aW5nX2Jyb2tlcl9kYXRhYmFzZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDOUQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLFVBQVUsRUFBRSxZQUFZLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUVuSDs7R0FFRztBQUNILE1BQU0sV0FBVyxxQkFBcUI7SUFDcEM7OztPQUdHO0lBQ0gsYUFBYSxDQUFDLEdBQUcsRUFBRSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRTlDOzs7T0FHRztJQUNILGtDQUFrQyxDQUFDLFdBQVcsRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRTVFOztPQUVHO0lBQ0gsY0FBYyxJQUFJLHFCQUFxQixDQUFDLENBQUMsVUFBVSxFQUFFLHVCQUF1QixHQUFHLFNBQVMsQ0FBQyxDQUFDLENBQUM7SUFFM0Y7Ozs7O09BS0c7SUFDSCxtQkFBbUIsQ0FBQyxFQUFFLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBRSxRQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRXRFOzs7OztPQUtHO0lBQ0gsa0JBQWtCLENBQUMsRUFBRSxFQUFFLFlBQVksRUFBRSxHQUFHLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUVqRTs7Ozs7T0FLRztJQUNILG9CQUFvQixDQUFDLEVBQUUsRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBRXREOzs7OztPQUtHO0lBQ0gsc0JBQXNCLENBQUMsRUFBRSxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7SUFFeEQ7O09BRUc7SUFDSCxLQUFLLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO0NBQ3hCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proving_broker_database.d.ts","sourceRoot":"","sources":["../../src/proving_broker/proving_broker_database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAEnH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;OAGG;IACH,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5E;;OAEG;IACH,cAAc,IAAI,qBAAqB,CAAC,CAAC,UAAU,EAAE,uBAAuB,GAAG,SAAS,CAAC,CAAC,CAAC;IAE3F;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
1
|
+
{"version":3,"file":"proving_broker_database.d.ts","sourceRoot":"","sources":["../../src/proving_broker/proving_broker_database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAEnH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C;;;OAGG;IACH,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5E;;OAEG;IACH,cAAc,IAAI,qBAAqB,CAAC,CAAC,UAAU,EAAE,uBAAuB,GAAG,SAAS,CAAC,CAAC,CAAC;IAE3F;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtE;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import type { CheckpointNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
5
|
+
/** Arguments for {@link settleEpochOutbox}. */
|
|
6
|
+
export type SettleEpochOutboxArgs = {
|
|
7
|
+
/** Cheat codes used to write the computed out hash directly into the L1 Outbox storage. */
|
|
8
|
+
rollupCheatCodes: RollupCheatCodes;
|
|
9
|
+
/** Source of checkpointed L2 blocks for the epoch being settled. */
|
|
10
|
+
l2BlockSource: L2BlockSource;
|
|
11
|
+
/** Epoch to settle. */
|
|
12
|
+
epoch: EpochNumber;
|
|
13
|
+
/**
|
|
14
|
+
* When set, only checkpoints up to and including this number are covered. Used to settle a partial
|
|
15
|
+
* epoch (the AZIP-14 Outbox keeps one root per `numCheckpointsInEpoch`, so a prefix of an epoch can
|
|
16
|
+
* be settled and consumed before the epoch completes). When omitted, every checkpointed block in the
|
|
17
|
+
* epoch is covered.
|
|
18
|
+
*/
|
|
19
|
+
maxCheckpoint?: CheckpointNumber;
|
|
20
|
+
log: Logger;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Computes the epoch out hash over the checkpointed blocks of an epoch (optionally only up to
|
|
24
|
+
* `maxCheckpoint`) and writes it into the L1 Outbox via cheat codes. This is the synthetic,
|
|
25
|
+
* no-prover equivalent of an epoch root proof landing on L1: it makes the L2-to-L1 messages in the
|
|
26
|
+
* covered checkpoints consumable. It does NOT advance the rollup's proven tip — callers
|
|
27
|
+
* `markAsProven` separately so a single prove call can settle multiple epochs before marking proven.
|
|
28
|
+
*
|
|
29
|
+
* Used by the test-only proving drivers: the `AutomineSequencer`'s auto-settle loop and the standalone
|
|
30
|
+
* `EpochTestSettler`. Lives here (rather than in either consumer) so both share one implementation.
|
|
31
|
+
*
|
|
32
|
+
* @returns The last checkpoint number covered by the settled range, or `undefined` if the epoch has
|
|
33
|
+
* no checkpointed blocks (within the `maxCheckpoint` bound).
|
|
34
|
+
*/
|
|
35
|
+
export declare function settleEpochOutbox({ rollupCheatCodes, l2BlockSource, epoch, maxCheckpoint, log }: SettleEpochOutboxArgs): Promise<CheckpointNumber | undefined>;
|
|
36
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXBvY2hfc2V0dGxlbWVudC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvZXBvY2hfc2V0dGxlbWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBQzdELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLFdBQVcsRUFBYyxNQUFNLGlDQUFpQyxDQUFDO0FBRWpHLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGFBQWEsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBR3pELCtDQUErQztBQUMvQyxNQUFNLE1BQU0scUJBQXFCLEdBQUc7SUFDbEMsMkZBQTJGO0lBQzNGLGdCQUFnQixFQUFFLGdCQUFnQixDQUFDO0lBQ25DLG9FQUFvRTtJQUNwRSxhQUFhLEVBQUUsYUFBYSxDQUFDO0lBQzdCLHVCQUF1QjtJQUN2QixLQUFLLEVBQUUsV0FBVyxDQUFDO0lBQ25COzs7OztPQUtHO0lBQ0gsYUFBYSxDQUFDLEVBQUUsZ0JBQWdCLENBQUM7SUFDakMsR0FBRyxFQUFFLE1BQU0sQ0FBQztDQUNiLENBQUM7QUFFRjs7Ozs7Ozs7Ozs7O0dBWUc7QUFDSCx3QkFBc0IsaUJBQWlCLENBQUMsRUFDdEMsZ0JBQWdCLEVBQ2hCLGFBQWEsRUFDYixLQUFLLEVBQ0wsYUFBYSxFQUNiLEdBQUcsRUFDSixFQUFFLHFCQUFxQixHQUFHLE9BQU8sQ0FBQyxnQkFBZ0IsR0FBRyxTQUFTLENBQUMsQ0FxQy9EIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"epoch_settlement.d.ts","sourceRoot":"","sources":["../../src/test/epoch_settlement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAc,MAAM,iCAAiC,CAAC;AAEjG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,2FAA2F;IAC3F,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,oEAAoE;IACpE,aAAa,EAAE,aAAa,CAAC;IAC7B,uBAAuB;IACvB,KAAK,EAAE,WAAW,CAAC;IACnB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,aAAa,EACb,GAAG,EACJ,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAqC/D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { computeEpochOutHash } from '@aztec/stdlib/messaging';
|
|
2
|
+
/**
|
|
3
|
+
* Computes the epoch out hash over the checkpointed blocks of an epoch (optionally only up to
|
|
4
|
+
* `maxCheckpoint`) and writes it into the L1 Outbox via cheat codes. This is the synthetic,
|
|
5
|
+
* no-prover equivalent of an epoch root proof landing on L1: it makes the L2-to-L1 messages in the
|
|
6
|
+
* covered checkpoints consumable. It does NOT advance the rollup's proven tip — callers
|
|
7
|
+
* `markAsProven` separately so a single prove call can settle multiple epochs before marking proven.
|
|
8
|
+
*
|
|
9
|
+
* Used by the test-only proving drivers: the `AutomineSequencer`'s auto-settle loop and the standalone
|
|
10
|
+
* `EpochTestSettler`. Lives here (rather than in either consumer) so both share one implementation.
|
|
11
|
+
*
|
|
12
|
+
* @returns The last checkpoint number covered by the settled range, or `undefined` if the epoch has
|
|
13
|
+
* no checkpointed blocks (within the `maxCheckpoint` bound).
|
|
14
|
+
*/ export async function settleEpochOutbox({ rollupCheatCodes, l2BlockSource, epoch, maxCheckpoint, log }) {
|
|
15
|
+
let blocks = await l2BlockSource.getBlocks({
|
|
16
|
+
epoch,
|
|
17
|
+
onlyCheckpointed: true
|
|
18
|
+
});
|
|
19
|
+
if (maxCheckpoint !== undefined) {
|
|
20
|
+
blocks = blocks.filter((block)=>block.checkpointNumber <= maxCheckpoint);
|
|
21
|
+
}
|
|
22
|
+
if (blocks.length === 0) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
log.info(`Settling epoch ${epoch}${maxCheckpoint !== undefined ? ` up to checkpoint ${maxCheckpoint}` : ''} with blocks ${blocks[0]?.header.getBlockNumber()} to ${blocks.at(-1)?.header.getBlockNumber()}`, {
|
|
26
|
+
epoch,
|
|
27
|
+
maxCheckpoint,
|
|
28
|
+
blocks: blocks.map((block)=>block.toBlockInfo())
|
|
29
|
+
});
|
|
30
|
+
const messagesInEpoch = [];
|
|
31
|
+
// Undefined (not SlotNumber.ZERO) so a first checkpointed block at slot 0 still opens checkpoint 0.
|
|
32
|
+
let previousSlotNumber;
|
|
33
|
+
let checkpointIndex = -1;
|
|
34
|
+
for (const block of blocks){
|
|
35
|
+
const slotNumber = block.header.globalVariables.slotNumber;
|
|
36
|
+
if (slotNumber !== previousSlotNumber) {
|
|
37
|
+
checkpointIndex++;
|
|
38
|
+
messagesInEpoch[checkpointIndex] = [];
|
|
39
|
+
previousSlotNumber = slotNumber;
|
|
40
|
+
}
|
|
41
|
+
messagesInEpoch[checkpointIndex].push(block.body.txEffects.map((txEffect)=>txEffect.l2ToL1Msgs));
|
|
42
|
+
}
|
|
43
|
+
const outHash = computeEpochOutHash(messagesInEpoch);
|
|
44
|
+
if (!outHash.isZero()) {
|
|
45
|
+
await rollupCheatCodes.insertOutbox(epoch, messagesInEpoch.length, outHash.toBigInt());
|
|
46
|
+
} else {
|
|
47
|
+
log.info(`No L2 to L1 messages in epoch ${epoch}`, {
|
|
48
|
+
epoch
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return blocks.at(-1)?.checkpointNumber;
|
|
52
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { settleEpochOutbox, type SettleEpochOutboxArgs } from './epoch_settlement.js';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxLQUFLLHFCQUFxQixFQUFFLE1BQU0sdUJBQXVCLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { settleEpochOutbox } from './epoch_settlement.js';
|
|
@@ -19,7 +19,7 @@ export declare class TestBroker implements ProvingJobProducer {
|
|
|
19
19
|
}
|
|
20
20
|
export declare class MockProver implements ServerCircuitProver {
|
|
21
21
|
constructor();
|
|
22
|
-
getAvmProof(_inputs: AvmCircuitInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<import("@aztec/stdlib/proofs").RecursiveProof<
|
|
22
|
+
getAvmProof(_inputs: AvmCircuitInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<import("@aztec/stdlib/proofs").RecursiveProof<14532>>;
|
|
23
23
|
getBaseParityProof(_inputs: ParityBasePrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<import("@aztec/stdlib/parity").ParityPublicInputs, 410>>;
|
|
24
24
|
getRootParityProof(_inputs: ParityRootPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<import("@aztec/stdlib/parity").ParityPublicInputs, 410>>;
|
|
25
25
|
getPublicChonkVerifierProof(_inputs: PublicChonkVerifierPrivateInputs, _signal?: AbortSignal, _epochNumber?: number): Promise<PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
package/dest/test/mock_prover.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH } from '@aztec/constants';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
3
|
import { makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec/stdlib/proofs';
|
|
@@ -44,7 +44,7 @@ export class TestBroker {
|
|
|
44
44
|
export class MockProver {
|
|
45
45
|
constructor(){}
|
|
46
46
|
getAvmProof(_inputs, _signal, _epochNumber) {
|
|
47
|
-
return Promise.resolve(makeEmptyRecursiveProof(
|
|
47
|
+
return Promise.resolve(makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS));
|
|
48
48
|
}
|
|
49
49
|
getBaseParityProof(_inputs, _signal, _epochNumber) {
|
|
50
50
|
return Promise.resolve(makePublicInputsAndRecursiveProof(makeParityPublicInputs(), makeRecursiveProof(RECURSIVE_PROOF_LENGTH), VerificationKeyData.makeFakeHonk()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.321f6a9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"./orchestrator": "./dest/orchestrator/index.js",
|
|
10
10
|
"./helpers": "./dest/orchestrator/block-building-helpers.js",
|
|
11
11
|
"./light": "./dest/light/index.js",
|
|
12
|
-
"./config": "./dest/config.js"
|
|
12
|
+
"./config": "./dest/config.js",
|
|
13
|
+
"./test": "./dest/test/index.js"
|
|
13
14
|
},
|
|
14
15
|
"typedocOptions": {
|
|
15
16
|
"entryPoints": [
|
|
@@ -68,19 +69,19 @@
|
|
|
68
69
|
]
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
72
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
73
|
-
"@aztec/constants": "0.0.1-commit.
|
|
74
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
75
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
76
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
78
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
79
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
80
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
81
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
82
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
83
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
72
|
+
"@aztec/bb-prover": "0.0.1-commit.321f6a9",
|
|
73
|
+
"@aztec/blob-lib": "0.0.1-commit.321f6a9",
|
|
74
|
+
"@aztec/constants": "0.0.1-commit.321f6a9",
|
|
75
|
+
"@aztec/ethereum": "0.0.1-commit.321f6a9",
|
|
76
|
+
"@aztec/foundation": "0.0.1-commit.321f6a9",
|
|
77
|
+
"@aztec/kv-store": "0.0.1-commit.321f6a9",
|
|
78
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.321f6a9",
|
|
79
|
+
"@aztec/noir-types": "0.0.1-commit.321f6a9",
|
|
80
|
+
"@aztec/protocol-contracts": "0.0.1-commit.321f6a9",
|
|
81
|
+
"@aztec/simulator": "0.0.1-commit.321f6a9",
|
|
82
|
+
"@aztec/stdlib": "0.0.1-commit.321f6a9",
|
|
83
|
+
"@aztec/telemetry-client": "0.0.1-commit.321f6a9",
|
|
84
|
+
"@aztec/world-state": "0.0.1-commit.321f6a9",
|
|
84
85
|
"@iarna/toml": "^2.2.5",
|
|
85
86
|
"commander": "^12.1.0",
|
|
86
87
|
"lodash.chunk": "^4.2.0",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"zod": "^4"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
93
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.321f6a9",
|
|
93
94
|
"@jest/globals": "^30.0.0",
|
|
94
95
|
"@types/jest": "^30.0.0",
|
|
95
96
|
"@types/node": "^22.15.17",
|
|
@@ -275,6 +275,7 @@ export class LightweightCheckpointBuilder {
|
|
|
275
275
|
const timestamp = blocks[blocks.length - 1].timestamp;
|
|
276
276
|
|
|
277
277
|
const totalManaUsed = blocks.reduce((acc, block) => acc.add(block.header.totalManaUsed), Fr.ZERO);
|
|
278
|
+
const accumulatedFees = blocks.reduce((acc, block) => acc.add(block.header.totalFees), Fr.ZERO);
|
|
278
279
|
|
|
279
280
|
const header = CheckpointHeader.from({
|
|
280
281
|
lastArchiveRoot: this.lastArchives[0].root,
|
|
@@ -288,6 +289,7 @@ export class LightweightCheckpointBuilder {
|
|
|
288
289
|
feeRecipient,
|
|
289
290
|
gasFees,
|
|
290
291
|
totalManaUsed,
|
|
292
|
+
accumulatedFees,
|
|
291
293
|
});
|
|
292
294
|
|
|
293
295
|
this.logger.debug(`Completed checkpoint ${this.checkpointNumber}`, {
|
|
@@ -5,13 +5,13 @@ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
|
5
5
|
import { padArrayEnd, times, timesAsync } from '@aztec/foundation/collection';
|
|
6
6
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
7
|
import type { Logger } from '@aztec/foundation/log';
|
|
8
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
8
9
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
9
10
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
10
11
|
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
11
12
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
12
13
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
13
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
-
import { EthAddress } from '@aztec/stdlib/block';
|
|
15
15
|
import type { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
16
16
|
import type { MerkleTreeWriteOperations, ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
17
17
|
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
@@ -36,12 +36,21 @@ import {
|
|
|
36
36
|
getTreeSnapshot,
|
|
37
37
|
insertSideEffects,
|
|
38
38
|
} from '../orchestrator/block-building-helpers.js';
|
|
39
|
-
import type { BlockProvingState } from '../orchestrator/block-proving-state.js';
|
|
40
|
-
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
41
39
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
42
40
|
import { TestBroker } from '../test/mock_prover.js';
|
|
43
41
|
import { getEnvironmentConfig, getSimulator, makeCheckpointConstants, makeGlobals } from './fixtures.js';
|
|
44
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Builds a started `SerialQueue` for use as an orchestrator's deferred-job queue in
|
|
45
|
+
* tests. Production wires a single shared queue via `ProverClient`; tests that construct
|
|
46
|
+
* orchestrators directly use one of these per orchestrator (or share one).
|
|
47
|
+
*/
|
|
48
|
+
export function makeTestDeferredJobQueue(concurrency = 10): SerialQueue {
|
|
49
|
+
const queue = new SerialQueue();
|
|
50
|
+
queue.start(concurrency);
|
|
51
|
+
return queue;
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
export class TestContext {
|
|
46
55
|
private headers: Map<number, BlockHeader> = new Map();
|
|
47
56
|
private checkpoints: Checkpoint[] = [];
|
|
@@ -57,7 +66,6 @@ export class TestContext {
|
|
|
57
66
|
public prover: ServerCircuitProver,
|
|
58
67
|
public broker: TestBroker,
|
|
59
68
|
public brokerProverFacade: BrokerCircuitProverFacade,
|
|
60
|
-
public orchestrator: TestProvingOrchestrator,
|
|
61
69
|
private feePayer: AztecAddress,
|
|
62
70
|
initialFeePayerBalance: Fr,
|
|
63
71
|
private directoriesToCleanup: string[],
|
|
@@ -66,10 +74,6 @@ export class TestContext {
|
|
|
66
74
|
this.feePayerBalance = initialFeePayerBalance;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
|
-
public get epochProver() {
|
|
70
|
-
return this.orchestrator;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
77
|
static async new(
|
|
74
78
|
logger: Logger,
|
|
75
79
|
{
|
|
@@ -82,7 +86,7 @@ export class TestContext {
|
|
|
82
86
|
) {
|
|
83
87
|
const directoriesToCleanup: string[] = [];
|
|
84
88
|
|
|
85
|
-
const feePayer = AztecAddress.
|
|
89
|
+
const feePayer = AztecAddress.fromNumberUnsafe(42222);
|
|
86
90
|
const initialFeePayerBalance = new Fr(10n ** 20n);
|
|
87
91
|
const feePayerSlot = await computeFeePayerBalanceLeafSlot(feePayer);
|
|
88
92
|
const genesis: GenesisData = {
|
|
@@ -118,22 +122,11 @@ export class TestContext {
|
|
|
118
122
|
|
|
119
123
|
const broker = new TestBroker(proverCount, localProver);
|
|
120
124
|
const facade = new BrokerCircuitProverFacade(broker);
|
|
121
|
-
const orchestrator = new TestProvingOrchestrator(ws, facade, EthAddress.ZERO, false, 10);
|
|
122
125
|
|
|
123
126
|
await broker.start();
|
|
124
127
|
facade.start();
|
|
125
128
|
|
|
126
|
-
return new this(
|
|
127
|
-
ws,
|
|
128
|
-
localProver,
|
|
129
|
-
broker,
|
|
130
|
-
facade,
|
|
131
|
-
orchestrator,
|
|
132
|
-
feePayer,
|
|
133
|
-
initialFeePayerBalance,
|
|
134
|
-
directoriesToCleanup,
|
|
135
|
-
logger,
|
|
136
|
-
);
|
|
129
|
+
return new this(ws, localProver, broker, facade, feePayer, initialFeePayerBalance, directoriesToCleanup, logger);
|
|
137
130
|
}
|
|
138
131
|
|
|
139
132
|
public getFork() {
|
|
@@ -353,16 +346,3 @@ export class TestContext {
|
|
|
353
346
|
return endStateReference;
|
|
354
347
|
}
|
|
355
348
|
}
|
|
356
|
-
|
|
357
|
-
class TestProvingOrchestrator extends ProvingOrchestrator {
|
|
358
|
-
public isVerifyBuiltBlockAgainstSyncedStateEnabled = false;
|
|
359
|
-
|
|
360
|
-
// Disable this check by default, since it requires seeding world state with the block being built
|
|
361
|
-
// This is only enabled in some tests with multiple blocks that populate the pending chain via makePendingBlock
|
|
362
|
-
protected override verifyBuiltBlockAgainstSyncedState(provingState: BlockProvingState): Promise<void> {
|
|
363
|
-
if (this.isVerifyBuiltBlockAgainstSyncedStateEnabled) {
|
|
364
|
-
return super.verifyBuiltBlockAgainstSyncedState(provingState);
|
|
365
|
-
}
|
|
366
|
-
return Promise.resolve();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
@@ -1,66 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BatchedBlobAccumulator,
|
|
3
|
-
type FinalBlobBatchingChallenges,
|
|
4
|
-
SpongeBlob,
|
|
5
|
-
encodeCheckpointBlobDataFromBlocks,
|
|
6
|
-
} from '@aztec/blob-lib';
|
|
1
|
+
import { SpongeBlob } from '@aztec/blob-lib';
|
|
7
2
|
import {
|
|
8
3
|
type ARCHIVE_HEIGHT,
|
|
9
|
-
BLOBS_PER_CHECKPOINT,
|
|
10
|
-
FIELDS_PER_BLOB,
|
|
11
4
|
type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
12
5
|
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
13
6
|
NUM_MSGS_PER_BASE_PARITY,
|
|
14
|
-
OUT_HASH_TREE_HEIGHT,
|
|
15
7
|
} from '@aztec/constants';
|
|
16
8
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
17
9
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
18
|
-
import { BLS12Point } from '@aztec/foundation/curves/bls12';
|
|
19
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
20
11
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
21
12
|
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
22
13
|
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import { computeCheckpointOutHash } from '@aztec/stdlib/messaging';
|
|
24
14
|
import { ParityBasePrivateInputs } from '@aztec/stdlib/parity';
|
|
25
|
-
import {
|
|
26
|
-
BlockMergeRollupPrivateInputs,
|
|
27
|
-
BlockRollupPublicInputs,
|
|
28
|
-
CheckpointConstantData,
|
|
29
|
-
CheckpointRollupPublicInputs,
|
|
30
|
-
CheckpointRootRollupHints,
|
|
31
|
-
CheckpointRootRollupPrivateInputs,
|
|
32
|
-
CheckpointRootSingleBlockRollupPrivateInputs,
|
|
33
|
-
} from '@aztec/stdlib/rollup';
|
|
34
|
-
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
15
|
+
import { BlockMergeRollupPrivateInputs, BlockRollupPublicInputs, CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
35
16
|
import type { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
36
17
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
37
18
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
38
19
|
|
|
39
|
-
import {
|
|
20
|
+
import { toProofData } from './block-building-helpers.js';
|
|
40
21
|
import { BlockProvingState, type ProofState } from './block-proving-state.js';
|
|
41
|
-
import type { EpochProvingState } from './epoch-proving-state.js';
|
|
42
|
-
|
|
43
|
-
type OutHashHint = {
|
|
44
|
-
treeSnapshot: AppendOnlyTreeSnapshot;
|
|
45
|
-
siblingPath: Tuple<Fr, typeof OUT_HASH_TREE_HEIGHT>;
|
|
46
|
-
};
|
|
47
22
|
|
|
48
23
|
export class CheckpointProvingState {
|
|
49
24
|
private blockProofs: UnbalancedTreeStore<
|
|
50
25
|
ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
51
26
|
>;
|
|
52
|
-
private checkpointRootProof:
|
|
53
|
-
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
54
|
-
| undefined;
|
|
55
27
|
private blocks: (BlockProvingState | undefined)[] = [];
|
|
56
|
-
private previousOutHashHint: OutHashHint | undefined;
|
|
57
|
-
private outHash: Fr | undefined;
|
|
58
|
-
// The snapshot and sibling path after the checkpoint's out hash is inserted.
|
|
59
|
-
// Stored here to be retrieved for the next checkpoint when it's added.
|
|
60
|
-
private newOutHashHint: OutHashHint | undefined;
|
|
61
|
-
private startBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
62
|
-
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
63
|
-
private blobFields: Fr[] | undefined;
|
|
64
28
|
private error: string | undefined;
|
|
65
29
|
public readonly firstBlockNumber: BlockNumber;
|
|
66
30
|
|
|
@@ -68,7 +32,6 @@ export class CheckpointProvingState {
|
|
|
68
32
|
public readonly index: number,
|
|
69
33
|
public readonly constants: CheckpointConstantData,
|
|
70
34
|
public readonly totalNumBlocks: number,
|
|
71
|
-
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
72
35
|
private readonly headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
73
36
|
private readonly lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
74
37
|
private readonly l1ToL2Messages: Fr[],
|
|
@@ -84,17 +47,16 @@ export class CheckpointProvingState {
|
|
|
84
47
|
Fr,
|
|
85
48
|
typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH
|
|
86
49
|
>,
|
|
87
|
-
public
|
|
88
|
-
|
|
50
|
+
public readonly epochNumber: number,
|
|
51
|
+
/** Owner's liveness check. `verifyState()` returns false once this returns false. */
|
|
52
|
+
private readonly isAlive: () => boolean,
|
|
53
|
+
/** Owner's failure callback. Invoked from `reject` to surface the error upward. */
|
|
54
|
+
private readonly onReject: (reason: string) => void,
|
|
89
55
|
) {
|
|
90
56
|
this.blockProofs = new UnbalancedTreeStore(totalNumBlocks);
|
|
91
57
|
this.firstBlockNumber = BlockNumber(headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber + 1);
|
|
92
58
|
}
|
|
93
59
|
|
|
94
|
-
public get epochNumber(): number {
|
|
95
|
-
return this.parentEpoch.epochNumber;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
60
|
public startNewBlock(
|
|
99
61
|
blockNumber: BlockNumber,
|
|
100
62
|
timestamp: UInt64,
|
|
@@ -176,25 +138,6 @@ export class CheckpointProvingState {
|
|
|
176
138
|
this.blockProofs.setNode(location, { provingOutput });
|
|
177
139
|
}
|
|
178
140
|
|
|
179
|
-
public tryStartProvingCheckpointRoot() {
|
|
180
|
-
if (this.checkpointRootProof?.isProving) {
|
|
181
|
-
return false;
|
|
182
|
-
} else {
|
|
183
|
-
this.checkpointRootProof = { isProving: true };
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public setCheckpointRootRollupProof(
|
|
189
|
-
provingOutput: PublicInputsAndRecursiveProof<
|
|
190
|
-
CheckpointRollupPublicInputs,
|
|
191
|
-
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
192
|
-
>,
|
|
193
|
-
): TreeNodeLocation {
|
|
194
|
-
this.checkpointRootProof = { provingOutput };
|
|
195
|
-
return this.parentEpoch.setCheckpointRootRollupProof(this.index, provingOutput);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
141
|
public getBaseParityInputs(baseParityIndex: number) {
|
|
199
142
|
const messages = padArrayEnd(
|
|
200
143
|
this.l1ToL2Messages.slice(
|
|
@@ -207,53 +150,6 @@ export class CheckpointProvingState {
|
|
|
207
150
|
return new ParityBasePrivateInputs(messages, this.constants.vkTreeRoot, this.constants.proverId);
|
|
208
151
|
}
|
|
209
152
|
|
|
210
|
-
public setOutHashHint(hint: OutHashHint) {
|
|
211
|
-
this.previousOutHashHint = hint;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
public getOutHashHint() {
|
|
215
|
-
return this.previousOutHashHint;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
public accumulateBlockOutHashes() {
|
|
219
|
-
if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (!this.outHash) {
|
|
224
|
-
const messagesPerBlock = this.blocks.map(b => b!.getTxEffects().map(tx => tx.l2ToL1Msgs));
|
|
225
|
-
this.outHash = computeCheckpointOutHash(messagesPerBlock);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return this.outHash;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
public setOutHashHintForNextCheckpoint(hint: OutHashHint) {
|
|
232
|
-
this.newOutHashHint = hint;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
public getOutHashHintForNextCheckpoint() {
|
|
236
|
-
return this.newOutHashHint;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
public async accumulateBlobs(startBlobAccumulator: BatchedBlobAccumulator) {
|
|
240
|
-
if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
this.blobFields = encodeCheckpointBlobDataFromBlocks(this.blocks.map(b => b!.getBlockBlobData()));
|
|
245
|
-
this.endBlobAccumulator = await accumulateBlobs(this.blobFields!, startBlobAccumulator);
|
|
246
|
-
this.startBlobAccumulator = startBlobAccumulator;
|
|
247
|
-
|
|
248
|
-
await this.onBlobAccumulatorSet(this);
|
|
249
|
-
|
|
250
|
-
return this.endBlobAccumulator;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
public getEndBlobAccumulator() {
|
|
254
|
-
return this.endBlobAccumulator;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
153
|
public getParentLocation(location: TreeNodeLocation) {
|
|
258
154
|
return this.blockProofs.getParentLocation(location);
|
|
259
155
|
}
|
|
@@ -267,47 +163,6 @@ export class CheckpointProvingState {
|
|
|
267
163
|
return new BlockMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
268
164
|
}
|
|
269
165
|
|
|
270
|
-
public getCheckpointRootRollupType(): CircuitName {
|
|
271
|
-
return this.totalNumBlocks === 1 ? 'rollup-checkpoint-root-single-block' : 'rollup-checkpoint-root';
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
public async getCheckpointRootRollupInputs() {
|
|
275
|
-
const proofs = this.#getChildProofsForRoot();
|
|
276
|
-
const nonEmptyProofs = proofs.filter(p => !!p);
|
|
277
|
-
if (proofs.length !== nonEmptyProofs.length) {
|
|
278
|
-
throw new Error('At least one child is not ready for the checkpoint root rollup.');
|
|
279
|
-
}
|
|
280
|
-
if (!this.previousOutHashHint) {
|
|
281
|
-
throw new Error('Out hash hint is not set.');
|
|
282
|
-
}
|
|
283
|
-
if (!this.startBlobAccumulator) {
|
|
284
|
-
throw new Error('Start blob accumulator is not set.');
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// `blobFields` must've been set if `startBlobAccumulator` is set (in `accumulateBlobs`).
|
|
288
|
-
const blobFields = this.blobFields!;
|
|
289
|
-
|
|
290
|
-
const { blobCommitments, blobsHash } = await buildBlobHints(blobFields);
|
|
291
|
-
|
|
292
|
-
const hints = CheckpointRootRollupHints.from({
|
|
293
|
-
previousBlockHeader: this.headerOfLastBlockInPreviousCheckpoint,
|
|
294
|
-
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
295
|
-
previousOutHash: this.previousOutHashHint.treeSnapshot,
|
|
296
|
-
newOutHashSiblingPath: this.previousOutHashHint.siblingPath,
|
|
297
|
-
startBlobAccumulator: this.startBlobAccumulator.toBlobAccumulator(),
|
|
298
|
-
finalBlobChallenges: this.finalBlobBatchingChallenges,
|
|
299
|
-
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT),
|
|
300
|
-
blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO, BLOBS_PER_CHECKPOINT),
|
|
301
|
-
blobsHash,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
const [left, right] = nonEmptyProofs.map(p => toProofData(p));
|
|
305
|
-
|
|
306
|
-
return !right
|
|
307
|
-
? new CheckpointRootSingleBlockRollupPrivateInputs(left, hints)
|
|
308
|
-
: new CheckpointRootRollupPrivateInputs([left, right], hints);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
166
|
public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
|
|
312
167
|
const index = Number(blockNumber) - Number(this.firstBlockNumber);
|
|
313
168
|
return this.blocks[index];
|
|
@@ -317,13 +172,8 @@ export class CheckpointProvingState {
|
|
|
317
172
|
return !!this.blockProofs.getSibling(location)?.provingOutput;
|
|
318
173
|
}
|
|
319
174
|
|
|
320
|
-
public isReadyForCheckpointRoot() {
|
|
321
|
-
const allChildProofsReady = this.#getChildProofsForRoot().every(p => !!p);
|
|
322
|
-
return allChildProofsReady && !!this.previousOutHashHint && !!this.startBlobAccumulator;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
175
|
public verifyState() {
|
|
326
|
-
return this.
|
|
176
|
+
return this.isAlive();
|
|
327
177
|
}
|
|
328
178
|
|
|
329
179
|
public getError() {
|
|
@@ -337,14 +187,7 @@ export class CheckpointProvingState {
|
|
|
337
187
|
|
|
338
188
|
public reject(reason: string) {
|
|
339
189
|
this.error = reason;
|
|
340
|
-
this.
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
#getChildProofsForRoot() {
|
|
344
|
-
const rootLocation = { level: 0, index: 0 };
|
|
345
|
-
return this.totalNumBlocks === 1
|
|
346
|
-
? [this.blockProofs.getNode(rootLocation)?.provingOutput] // If there's only 1 block, its proof will be stored at the root.
|
|
347
|
-
: this.blockProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
190
|
+
this.onReject(reason);
|
|
348
191
|
}
|
|
349
192
|
|
|
350
193
|
/**
|
|
@@ -352,7 +195,10 @@ export class CheckpointProvingState {
|
|
|
352
195
|
* Used by `CheckpointSubTreeOrchestrator` to surface its sub-tree result.
|
|
353
196
|
*/
|
|
354
197
|
public getSubTreeOutputProofs() {
|
|
355
|
-
|
|
198
|
+
const rootLocation = { level: 0, index: 0 };
|
|
199
|
+
return this.totalNumBlocks === 1
|
|
200
|
+
? [this.blockProofs.getNode(rootLocation)?.provingOutput] // If there's only 1 block, its proof will be stored at the root.
|
|
201
|
+
: this.blockProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
356
202
|
}
|
|
357
203
|
|
|
358
204
|
/** Sibling path of the archive tree captured before any block in this checkpoint landed. */
|