@aztec/archiver 0.0.1-commit.0dc957cde → 0.0.1-commit.0ec55a70b
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/archiver.d.ts +15 -9
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +85 -53
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +2 -2
- package/dest/errors.d.ts +16 -5
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +29 -6
- package/dest/factory.d.ts +4 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +11 -9
- package/dest/index.d.ts +8 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +7 -1
- package/dest/l1/calldata_retriever.d.ts +2 -1
- package/dest/l1/calldata_retriever.d.ts.map +1 -1
- package/dest/l1/calldata_retriever.js +9 -4
- package/dest/modules/contract_data_source_adapter.d.ts +25 -0
- package/dest/modules/contract_data_source_adapter.d.ts.map +1 -0
- package/dest/modules/contract_data_source_adapter.js +42 -0
- package/dest/modules/data_source_base.d.ts +16 -10
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +71 -60
- package/dest/modules/data_store_updater.d.ts +6 -6
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +42 -40
- package/dest/modules/l1_synchronizer.d.ts +5 -4
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +79 -54
- package/dest/modules/validation.d.ts +4 -3
- package/dest/modules/validation.d.ts.map +1 -1
- package/dest/modules/validation.js +4 -4
- package/dest/store/block_store.d.ts +58 -27
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +152 -75
- package/dest/store/contract_class_store.d.ts +17 -3
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +17 -1
- package/dest/store/contract_instance_store.d.ts +28 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +31 -0
- package/dest/store/data_stores.d.ts +68 -0
- package/dest/store/data_stores.d.ts.map +1 -0
- package/dest/store/data_stores.js +50 -0
- package/dest/store/function_names_cache.d.ts +17 -0
- package/dest/store/function_names_cache.d.ts.map +1 -0
- package/dest/store/function_names_cache.js +30 -0
- package/dest/store/l2_tips_cache.js +1 -1
- package/dest/test/fake_l1_state.d.ts +2 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +25 -8
- package/dest/test/mock_l2_block_source.d.ts +12 -3
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +24 -2
- package/dest/test/noop_l1_archiver.d.ts +4 -4
- package/dest/test/noop_l1_archiver.d.ts.map +1 -1
- package/dest/test/noop_l1_archiver.js +5 -5
- package/package.json +13 -13
- package/src/archiver.ts +91 -49
- package/src/config.ts +2 -1
- package/src/errors.ts +41 -8
- package/src/factory.ts +10 -10
- package/src/index.ts +15 -1
- package/src/l1/calldata_retriever.ts +15 -4
- package/src/modules/contract_data_source_adapter.ts +59 -0
- package/src/modules/data_source_base.ts +75 -57
- package/src/modules/data_store_updater.ts +46 -38
- package/src/modules/l1_synchronizer.ts +92 -60
- package/src/modules/validation.ts +8 -7
- package/src/store/block_store.ts +159 -80
- package/src/store/contract_class_store.ts +28 -2
- package/src/store/contract_instance_store.ts +43 -0
- package/src/store/data_stores.ts +108 -0
- package/src/store/function_names_cache.ts +37 -0
- package/src/store/l2_tips_cache.ts +1 -1
- package/src/test/fake_l1_state.ts +24 -14
- package/src/test/mock_l2_block_source.ts +23 -2
- package/src/test/noop_l1_archiver.ts +6 -6
- package/dest/store/kv_archiver_store.d.ts +0 -383
- package/dest/store/kv_archiver_store.d.ts.map +0 -1
- package/dest/store/kv_archiver_store.js +0 -501
- package/src/store/kv_archiver_store.ts +0 -728
|
@@ -2,7 +2,7 @@ import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/bra
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { type BlockData, BlockHash, CheckpointedL2Block, CommitteeAttestation, L2Block, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
5
|
+
import { type BlockData, type BlockDataWithCheckpointContext, BlockHash, CheckpointedL2Block, CommitteeAttestation, L2Block, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
6
6
|
import { type CheckpointData, type CommonCheckpointData, L1PublishedData, type ProposedCheckpointData, type ProposedCheckpointInput, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
7
7
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
8
8
|
import { BlockHeader, type IndexedTxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
@@ -46,7 +46,7 @@ export declare class BlockStore {
|
|
|
46
46
|
/**
|
|
47
47
|
* Validates that blocks are sequential, have correct indexes, and chain via archive roots.
|
|
48
48
|
* This is the same validation used for both confirmed checkpoints (addCheckpoints) and
|
|
49
|
-
* proposed checkpoints (
|
|
49
|
+
* proposed checkpoints (addProposedCheckpoint).
|
|
50
50
|
*/
|
|
51
51
|
private validateCheckpointBlocks;
|
|
52
52
|
private addBlockToDatabase;
|
|
@@ -80,26 +80,39 @@ export declare class BlockStore {
|
|
|
80
80
|
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
81
81
|
getLatestCheckpointNumber(): Promise<CheckpointNumber>;
|
|
82
82
|
hasProposedCheckpoint(): Promise<boolean>;
|
|
83
|
-
/** Deletes
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Promotes
|
|
87
|
-
* This persists the checkpoint to the store,
|
|
88
|
-
*
|
|
89
|
-
* @param
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
|
|
83
|
+
/** Deletes all pending proposed checkpoints from storage. */
|
|
84
|
+
deleteProposedCheckpoints(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Promotes a specific pending checkpoint to a confirmed checkpoint entry.
|
|
87
|
+
* This persists the checkpoint to the store, removes only that pending entry, and updates the L1 sync point.
|
|
88
|
+
* Remaining pending entries (e.g. N+1, N+2) are left intact — they chain off the just-promoted one.
|
|
89
|
+
* @param checkpointNumber - The checkpoint number to promote.
|
|
90
|
+
* @param l1 - L1 published data for the checkpoint.
|
|
91
|
+
* @param attestations - Committee attestations.
|
|
92
|
+
* @param expectedArchiveRoot - Archive root guard against races.
|
|
93
|
+
*/
|
|
94
|
+
promoteProposedToCheckpointed(checkpointNumber: CheckpointNumber, l1: L1PublishedData, attestations: CommitteeAttestation[], expectedArchiveRoot: Fr): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the latest pending checkpoint (highest-numbered entry), or undefined if none.
|
|
97
|
+
* No fallback to confirmed.
|
|
98
|
+
*/
|
|
99
|
+
getLastProposedCheckpoint(): Promise<ProposedCheckpointData | undefined>;
|
|
100
|
+
/** Returns the pending checkpoint for a specific checkpoint number, or undefined if not found. */
|
|
101
|
+
getProposedCheckpointByNumber(n: CheckpointNumber): Promise<ProposedCheckpointData | undefined>;
|
|
102
|
+
/** Returns all pending checkpoints in ascending checkpoint-number order. */
|
|
103
|
+
getProposedCheckpoints(): Promise<ProposedCheckpointData[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Evicts all pending checkpoints with checkpoint number >= fromNumber.
|
|
106
|
+
* Used for divergent-mined-checkpoint cleanup: when L1 mines checkpoint N with a different archive,
|
|
107
|
+
* all pending >= N must be evicted since they chain off the now-invalid pending N.
|
|
108
|
+
*/
|
|
109
|
+
evictProposedCheckpointsFrom(fromNumber: CheckpointNumber): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Gets the checkpoint at the proposed tip:
|
|
112
|
+
* - latest pending checkpoint if any exist
|
|
99
113
|
* - fallsback to latest confirmed checkpoint otherwise
|
|
100
|
-
* @returns CommonCheckpointData
|
|
101
114
|
*/
|
|
102
|
-
|
|
115
|
+
getLastCheckpoint(): Promise<CommonCheckpointData | undefined>;
|
|
103
116
|
private convertToProposedCheckpointData;
|
|
104
117
|
/**
|
|
105
118
|
* Attempts to get the proposedCheckpoint's number, if there is not one, then fallback to the latest confirmed checkpoint number.
|
|
@@ -118,7 +131,9 @@ export declare class BlockStore {
|
|
|
118
131
|
* @param limit - The number of blocks to return.
|
|
119
132
|
* @returns The requested L2 blocks
|
|
120
133
|
*/
|
|
121
|
-
getCheckpointedBlocks(start: BlockNumber, limit: number):
|
|
134
|
+
getCheckpointedBlocks(start: BlockNumber, limit: number): Promise<CheckpointedL2Block[]>;
|
|
135
|
+
/** Async iterator variant of {@link getCheckpointedBlocks}. */
|
|
136
|
+
iterateCheckpointedBlocks(start: BlockNumber, limit: number): AsyncIterableIterator<CheckpointedL2Block>;
|
|
122
137
|
getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined>;
|
|
123
138
|
getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
|
|
124
139
|
/**
|
|
@@ -127,13 +142,23 @@ export declare class BlockStore {
|
|
|
127
142
|
* @param limit - The number of blocks to return.
|
|
128
143
|
* @returns The requested L2 blocks
|
|
129
144
|
*/
|
|
130
|
-
getBlocks(start: BlockNumber, limit: number):
|
|
145
|
+
getBlocks(start: BlockNumber, limit: number): Promise<L2Block[]>;
|
|
146
|
+
/** Async iterator variant of {@link getBlocks}. */
|
|
147
|
+
iterateBlocks(start: BlockNumber, limit: number): AsyncIterableIterator<L2Block>;
|
|
131
148
|
/**
|
|
132
149
|
* Gets block metadata (without tx data) by block number.
|
|
133
150
|
* @param blockNumber - The number of the block to return.
|
|
134
151
|
* @returns The requested block data.
|
|
135
152
|
*/
|
|
136
153
|
getBlockData(blockNumber: BlockNumber): Promise<BlockData | undefined>;
|
|
154
|
+
/**
|
|
155
|
+
* Gets block metadata plus checkpoint-derived context (L1 publish info, attestations) without
|
|
156
|
+
* deserializing tx bodies. When the block's containing checkpoint has not yet been L1-confirmed,
|
|
157
|
+
* `checkpoint` and `l1` are `undefined` and `attestations` is empty.
|
|
158
|
+
*/
|
|
159
|
+
getBlockDataWithCheckpointContext(blockNumber: BlockNumber): Promise<BlockDataWithCheckpointContext | undefined>;
|
|
160
|
+
/** Returns the checkpoint number that contains the given slot (or undefined if not found). */
|
|
161
|
+
getCheckpointNumberBySlot(slot: SlotNumber): Promise<CheckpointNumber | undefined>;
|
|
137
162
|
/**
|
|
138
163
|
* Gets block metadata (without tx data) by archive root.
|
|
139
164
|
* @param archive - The archive root of the block to return.
|
|
@@ -176,7 +201,9 @@ export declare class BlockStore {
|
|
|
176
201
|
* @param limit - The number of blocks to return.
|
|
177
202
|
* @returns The requested L2 block headers
|
|
178
203
|
*/
|
|
179
|
-
getBlockHeaders(start: BlockNumber, limit: number):
|
|
204
|
+
getBlockHeaders(start: BlockNumber, limit: number): Promise<BlockHeader[]>;
|
|
205
|
+
/** Async iterator variant of {@link getBlockHeaders}. */
|
|
206
|
+
iterateBlockHeaders(start: BlockNumber, limit: number): AsyncIterableIterator<BlockHeader>;
|
|
180
207
|
private getBlockStorages;
|
|
181
208
|
private getBlockDataFromBlockStorage;
|
|
182
209
|
private getBlockFromBlockStorage;
|
|
@@ -216,9 +243,13 @@ export declare class BlockStore {
|
|
|
216
243
|
*/
|
|
217
244
|
getSynchedL1BlockNumber(): Promise<bigint | undefined>;
|
|
218
245
|
setSynchedL1BlockNumber(l1BlockNumber: bigint): Promise<boolean>;
|
|
219
|
-
/**
|
|
220
|
-
*
|
|
221
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Adds a proposed checkpoint to the pending queue.
|
|
248
|
+
* Accepts proposed.checkpointNumber === latestTip + 1, where latestTip is the highest of
|
|
249
|
+
* confirmed and the highest pending checkpoint number.
|
|
250
|
+
* Computes archive and checkpointOutHash from the stored blocks.
|
|
251
|
+
*/
|
|
252
|
+
addProposedCheckpoint(proposed: ProposedCheckpointInput): Promise<void>;
|
|
222
253
|
getProvenCheckpointNumber(): Promise<CheckpointNumber>;
|
|
223
254
|
setProvenCheckpointNumber(checkpointNumber: CheckpointNumber): Promise<boolean>;
|
|
224
255
|
getFinalizedCheckpointNumber(): Promise<CheckpointNumber>;
|
|
@@ -234,4 +265,4 @@ export declare class BlockStore {
|
|
|
234
265
|
*/
|
|
235
266
|
setPendingChainValidationStatus(status: ValidateCheckpointResult | undefined): Promise<void>;
|
|
236
267
|
}
|
|
237
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
268
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yZS9ibG9ja19zdG9yZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsV0FBVyxFQUFFLGdCQUFnQixFQUF5QixVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuSCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFNcEQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQTZDLE1BQU0saUJBQWlCLENBQUM7QUFDcEcsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxFQUNMLEtBQUssU0FBUyxFQUNkLEtBQUssOEJBQThCLEVBQ25DLFNBQVMsRUFFVCxtQkFBbUIsRUFDbkIsb0JBQW9CLEVBQ3BCLE9BQU8sRUFDUCxLQUFLLHdCQUF3QixFQUc5QixNQUFNLHFC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AAC,WAAW,CAAC,CAGnD;IAED;;;OAGG;IACH,uBAAuB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAErD;IAED,uBAAuB,CAAC,aAAa,EAAE,MAAM,oBAE5C;IAED;;;;;OAKG;IACG,qBAAqB,CAAC,QAAQ,EAAE,uBAAuB,iBAsC5D;IAEK,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAQ3D;IAEK,yBAAyB,CAAC,gBAAgB,EAAE,gBAAgB,oBAGjE;IAEK,4BAA4B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAQ9D;IAED,4BAA4B,CAAC,gBAAgB,EAAE,gBAAgB,oBAE9D;IAcD;;;OAGG;IACG,+BAA+B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAMrF;IAED;;;OAGG;IACG,+BAA+B,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjG;CACF"}
|
|
@@ -12,14 +12,15 @@ import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
|
12
12
|
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
13
13
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
14
14
|
import { BlockHeader, TxHash, TxReceipt, TxStatus, deserializeIndexedTxEffect, serializeIndexedTxEffect } from '@aztec/stdlib/tx';
|
|
15
|
-
import { BlockAlreadyCheckpointedError, BlockArchiveNotConsistentError, BlockIndexNotSequentialError, BlockNotFoundError, BlockNumberNotSequentialError, CannotOverwriteCheckpointedBlockError, CheckpointNotFoundError, CheckpointNumberNotSequentialError, InitialCheckpointNumberNotSequentialError, NoProposedCheckpointToPromoteError, ProposedCheckpointArchiveRootMismatchError, ProposedCheckpointNotSequentialError, ProposedCheckpointPromotionNotSequentialError
|
|
15
|
+
import { BlockAlreadyCheckpointedError, BlockArchiveNotConsistentError, BlockCheckpointNumberNotSequentialError, BlockIndexNotSequentialError, BlockNotFoundError, BlockNumberNotSequentialError, CannotOverwriteCheckpointedBlockError, CheckpointNotFoundError, CheckpointNumberNotSequentialError, InitialCheckpointNumberNotSequentialError, NoProposedCheckpointToPromoteError, ProposedCheckpointArchiveRootMismatchError, ProposedCheckpointNotSequentialError, ProposedCheckpointPromotionNotSequentialError } from '../errors.js';
|
|
16
16
|
export { TxReceipt } from '@aztec/stdlib/tx';
|
|
17
17
|
/**
|
|
18
18
|
* LMDB-based block storage for the archiver.
|
|
19
19
|
*/ export class BlockStore {
|
|
20
20
|
db;
|
|
21
21
|
/** Map block number to block data */ #blocks;
|
|
22
|
-
/** Map checkpoint number
|
|
22
|
+
/** Map keyed by checkpoint number holding proposed (locally-validated, not yet L1-confirmed) checkpoints. */ #proposedCheckpoints;
|
|
23
|
+
/** Map checkpoint number to checkpoint data for mined checkpoints only */ #checkpoints;
|
|
23
24
|
/** Map slot number to checkpoint number, for looking up checkpoints by slot range. */ #slotToCheckpoint;
|
|
24
25
|
/** Map block hash to list of tx hashes */ #blockTxs;
|
|
25
26
|
/** Tx hash to serialized IndexedTxEffect */ #txEffects;
|
|
@@ -30,7 +31,6 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
30
31
|
/** Index mapping a contract's address (as a string) to its location in a block */ #contractIndex;
|
|
31
32
|
/** Index mapping block hash to block number */ #blockHashIndex;
|
|
32
33
|
/** Index mapping block archive to block number */ #blockArchiveIndex;
|
|
33
|
-
/** Singleton: assumes max 1-deep pipeline. For deeper pipelining, replace with a map keyed by checkpoint number. */ #proposedCheckpoint;
|
|
34
34
|
#log;
|
|
35
35
|
constructor(db){
|
|
36
36
|
this.db = db;
|
|
@@ -47,7 +47,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
47
47
|
this.#pendingChainValidationStatus = db.openSingleton('archiver_pending_chain_validation_status');
|
|
48
48
|
this.#checkpoints = db.openMap('archiver_checkpoints');
|
|
49
49
|
this.#slotToCheckpoint = db.openMap('archiver_slot_to_checkpoint');
|
|
50
|
-
this.#
|
|
50
|
+
this.#proposedCheckpoints = db.openMap('archiver_proposed_checkpoints');
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Returns the finalized L2 block number. An L2 block is finalized when it was proven
|
|
@@ -78,8 +78,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
78
78
|
const blockLastArchive = block.header.lastArchive.root;
|
|
79
79
|
// Extract the latest block and checkpoint numbers
|
|
80
80
|
const previousBlockNumber = await this.getLatestL2BlockNumber();
|
|
81
|
-
const
|
|
82
|
-
const previousCheckpointNumber = await this.getLatestCheckpointNumber();
|
|
81
|
+
const latestCheckpointNumber = await this.getLatestCheckpointNumber();
|
|
83
82
|
// Verify we're not overwriting checkpointed blocks
|
|
84
83
|
const lastCheckpointedBlockNumber = await this.getCheckpointedL2BlockNumber();
|
|
85
84
|
if (!opts.force && blockNumber <= lastCheckpointedBlockNumber) {
|
|
@@ -94,18 +93,17 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
94
93
|
if (!opts.force && previousBlockNumber !== blockNumber - 1) {
|
|
95
94
|
throw new BlockNumberNotSequentialError(blockNumber, previousBlockNumber);
|
|
96
95
|
}
|
|
97
|
-
//
|
|
98
|
-
//
|
|
96
|
+
// Accept the block if either the confirmed checkpoint or a pending checkpoint matches
|
|
97
|
+
// the expected predecessor. We look for a pending entry at exactly blockCheckpointNumber - 1.
|
|
99
98
|
const expectedCheckpointNumber = blockCheckpointNumber - 1;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
throw new CheckpointNumberNotSequentialError(blockCheckpointNumber, reported, source);
|
|
99
|
+
const hasPendingAtExpected = await this.#proposedCheckpoints.hasAsync(expectedCheckpointNumber);
|
|
100
|
+
if (!opts.force && latestCheckpointNumber !== expectedCheckpointNumber && !hasPendingAtExpected) {
|
|
101
|
+
const [latestPendingKey] = await toArray(this.#proposedCheckpoints.keysAsync({
|
|
102
|
+
reverse: true,
|
|
103
|
+
limit: 1
|
|
104
|
+
}));
|
|
105
|
+
const previous = CheckpointNumber(Math.max(latestCheckpointNumber, latestPendingKey ?? 0));
|
|
106
|
+
throw new BlockCheckpointNumberNotSequentialError(blockNumber, blockCheckpointNumber, previous);
|
|
109
107
|
}
|
|
110
108
|
// Extract the previous block if there is one and see if it is for the same checkpoint or not
|
|
111
109
|
const previousBlockResult = await this.getBlock(previousBlockNumber);
|
|
@@ -181,14 +179,14 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
181
179
|
attestations: checkpoint.attestations.map((attestation)=>attestation.toBuffer()),
|
|
182
180
|
checkpointNumber: checkpoint.checkpoint.number,
|
|
183
181
|
startBlock: checkpoint.checkpoint.blocks[0].number,
|
|
184
|
-
blockCount: checkpoint.checkpoint.blocks.length
|
|
182
|
+
blockCount: checkpoint.checkpoint.blocks.length,
|
|
183
|
+
feeAssetPriceModifier: checkpoint.checkpoint.feeAssetPriceModifier.toString()
|
|
185
184
|
});
|
|
186
185
|
// Update slot-to-checkpoint index
|
|
187
186
|
await this.#slotToCheckpoint.set(checkpoint.checkpoint.header.slotNumber, checkpoint.checkpoint.number);
|
|
187
|
+
// Remove proposed checkpoint if it exists, since L1 is authoritative
|
|
188
|
+
await this.#proposedCheckpoints.delete(checkpoint.checkpoint.number);
|
|
188
189
|
}
|
|
189
|
-
// Clear the proposed checkpoint if any of the confirmed checkpoints match or supersede it
|
|
190
|
-
const lastConfirmedCheckpointNumber = checkpoints[checkpoints.length - 1].checkpoint.number;
|
|
191
|
-
await this.clearProposedCheckpointIfSuperseded(lastConfirmedCheckpointNumber);
|
|
192
190
|
await this.#lastSynchedL1Block.set(checkpoints[checkpoints.length - 1].l1.blockNumber);
|
|
193
191
|
return true;
|
|
194
192
|
});
|
|
@@ -218,7 +216,8 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
218
216
|
attestations: incoming.attestations.map((a)=>a.toBuffer()),
|
|
219
217
|
checkpointNumber: incoming.checkpoint.number,
|
|
220
218
|
startBlock: incoming.checkpoint.blocks[0].number,
|
|
221
|
-
blockCount: incoming.checkpoint.blocks.length
|
|
219
|
+
blockCount: incoming.checkpoint.blocks.length,
|
|
220
|
+
feeAssetPriceModifier: incoming.checkpoint.feeAssetPriceModifier.toString()
|
|
222
221
|
});
|
|
223
222
|
// Update the sync point to reflect the new L1 block
|
|
224
223
|
await this.#lastSynchedL1Block.set(incoming.l1.blockNumber);
|
|
@@ -233,11 +232,12 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
233
232
|
if (previousCheckpointNumber === INITIAL_CHECKPOINT_NUMBER - 1) {
|
|
234
233
|
return undefined;
|
|
235
234
|
}
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
// Check across both proposed and mined checkpoints
|
|
236
|
+
const predecessor = await this.getProposedCheckpointByNumber(previousCheckpointNumber) ?? await this.getCheckpointData(previousCheckpointNumber);
|
|
237
|
+
if (!predecessor) {
|
|
238
238
|
throw new CheckpointNotFoundError(previousCheckpointNumber);
|
|
239
239
|
}
|
|
240
|
-
const previousBlockNumber = BlockNumber(
|
|
240
|
+
const previousBlockNumber = BlockNumber(predecessor.startBlock + predecessor.blockCount - 1);
|
|
241
241
|
const previousBlock = await this.getBlock(previousBlockNumber);
|
|
242
242
|
if (previousBlock === undefined) {
|
|
243
243
|
throw new BlockNotFoundError(previousBlockNumber);
|
|
@@ -247,7 +247,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
247
247
|
/**
|
|
248
248
|
* Validates that blocks are sequential, have correct indexes, and chain via archive roots.
|
|
249
249
|
* This is the same validation used for both confirmed checkpoints (addCheckpoints) and
|
|
250
|
-
* proposed checkpoints (
|
|
250
|
+
* proposed checkpoints (addProposedCheckpoint).
|
|
251
251
|
*/ validateCheckpointBlocks(blocks, previousBlock) {
|
|
252
252
|
for (const block of blocks){
|
|
253
253
|
if (previousBlock) {
|
|
@@ -352,11 +352,8 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
352
352
|
await this.#checkpoints.delete(c);
|
|
353
353
|
this.#log.debug(`Removed checkpoint ${c}`);
|
|
354
354
|
}
|
|
355
|
-
//
|
|
356
|
-
|
|
357
|
-
if (proposedCheckpointNumber > checkpointNumber) {
|
|
358
|
-
await this.#proposedCheckpoint.delete();
|
|
359
|
-
}
|
|
355
|
+
// Evict all pending checkpoints > checkpointNumber (their base chain no longer exists)
|
|
356
|
+
await this.evictProposedCheckpointsFrom(CheckpointNumber(checkpointNumber + 1));
|
|
360
357
|
return {
|
|
361
358
|
blocksRemoved
|
|
362
359
|
};
|
|
@@ -401,6 +398,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
401
398
|
checkpointNumber: CheckpointNumber(checkpointStorage.checkpointNumber),
|
|
402
399
|
startBlock: BlockNumber(checkpointStorage.startBlock),
|
|
403
400
|
blockCount: checkpointStorage.blockCount,
|
|
401
|
+
feeAssetPriceModifier: BigInt(checkpointStorage.feeAssetPriceModifier),
|
|
404
402
|
l1: L1PublishedData.fromBuffer(checkpointStorage.l1),
|
|
405
403
|
attestations: checkpointStorage.attestations.map((buf)=>CommitteeAttestation.fromBuffer(buf))
|
|
406
404
|
};
|
|
@@ -487,20 +485,27 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
487
485
|
return CheckpointNumber(latestCheckpointNumber);
|
|
488
486
|
}
|
|
489
487
|
async hasProposedCheckpoint() {
|
|
490
|
-
const
|
|
491
|
-
|
|
488
|
+
const [key] = await toArray(this.#proposedCheckpoints.keysAsync({
|
|
489
|
+
limit: 1
|
|
490
|
+
}));
|
|
491
|
+
return key !== undefined;
|
|
492
492
|
}
|
|
493
|
-
/** Deletes
|
|
494
|
-
await this.#
|
|
493
|
+
/** Deletes all pending proposed checkpoints from storage. */ async deleteProposedCheckpoints() {
|
|
494
|
+
for await (const key of this.#proposedCheckpoints.keysAsync()){
|
|
495
|
+
await this.#proposedCheckpoints.delete(key);
|
|
496
|
+
}
|
|
495
497
|
}
|
|
496
498
|
/**
|
|
497
|
-
* Promotes
|
|
498
|
-
* This persists the checkpoint to the store,
|
|
499
|
-
*
|
|
500
|
-
* @param
|
|
501
|
-
|
|
499
|
+
* Promotes a specific pending checkpoint to a confirmed checkpoint entry.
|
|
500
|
+
* This persists the checkpoint to the store, removes only that pending entry, and updates the L1 sync point.
|
|
501
|
+
* Remaining pending entries (e.g. N+1, N+2) are left intact — they chain off the just-promoted one.
|
|
502
|
+
* @param checkpointNumber - The checkpoint number to promote.
|
|
503
|
+
* @param l1 - L1 published data for the checkpoint.
|
|
504
|
+
* @param attestations - Committee attestations.
|
|
505
|
+
* @param expectedArchiveRoot - Archive root guard against races.
|
|
506
|
+
*/ async promoteProposedToCheckpointed(checkpointNumber, l1, attestations, expectedArchiveRoot) {
|
|
502
507
|
return await this.db.transactionAsync(async ()=>{
|
|
503
|
-
const proposed = await this.
|
|
508
|
+
const proposed = await this.getProposedCheckpointByNumber(checkpointNumber);
|
|
504
509
|
if (!proposed) {
|
|
505
510
|
throw new NoProposedCheckpointToPromoteError();
|
|
506
511
|
}
|
|
@@ -521,40 +526,67 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
521
526
|
attestations: attestations.map((attestation)=>attestation.toBuffer()),
|
|
522
527
|
checkpointNumber: proposed.checkpointNumber,
|
|
523
528
|
startBlock: proposed.startBlock,
|
|
524
|
-
blockCount: proposed.blockCount
|
|
529
|
+
blockCount: proposed.blockCount,
|
|
530
|
+
feeAssetPriceModifier: proposed.feeAssetPriceModifier.toString()
|
|
525
531
|
});
|
|
526
532
|
// Update the slot-to-checkpoint index
|
|
527
533
|
await this.#slotToCheckpoint.set(proposed.header.slotNumber, proposed.checkpointNumber);
|
|
528
|
-
//
|
|
529
|
-
await this.#
|
|
534
|
+
// Remove only this pending entry — remaining entries N+1, N+2, ... stay valid
|
|
535
|
+
await this.#proposedCheckpoints.delete(proposed.checkpointNumber);
|
|
530
536
|
// Update the last synced L1 block
|
|
531
537
|
await this.#lastSynchedL1Block.set(l1.blockNumber);
|
|
532
538
|
});
|
|
533
539
|
}
|
|
534
|
-
/**
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
540
|
+
/**
|
|
541
|
+
* Returns the latest pending checkpoint (highest-numbered entry), or undefined if none.
|
|
542
|
+
* No fallback to confirmed.
|
|
543
|
+
*/ async getLastProposedCheckpoint() {
|
|
544
|
+
const [key] = await toArray(this.#proposedCheckpoints.keysAsync({
|
|
545
|
+
reverse: true,
|
|
546
|
+
limit: 1
|
|
547
|
+
}));
|
|
548
|
+
if (key === undefined) {
|
|
549
|
+
return undefined;
|
|
538
550
|
}
|
|
551
|
+
const stored = await this.#proposedCheckpoints.getAsync(key);
|
|
552
|
+
return stored ? this.convertToProposedCheckpointData(stored) : undefined;
|
|
539
553
|
}
|
|
540
|
-
/** Returns the
|
|
541
|
-
const stored = await this.#
|
|
542
|
-
|
|
543
|
-
|
|
554
|
+
/** Returns the pending checkpoint for a specific checkpoint number, or undefined if not found. */ async getProposedCheckpointByNumber(n) {
|
|
555
|
+
const stored = await this.#proposedCheckpoints.getAsync(n);
|
|
556
|
+
return stored ? this.convertToProposedCheckpointData(stored) : undefined;
|
|
557
|
+
}
|
|
558
|
+
/** Returns all pending checkpoints in ascending checkpoint-number order. */ async getProposedCheckpoints() {
|
|
559
|
+
const results = [];
|
|
560
|
+
for await (const [, stored] of this.#proposedCheckpoints.entriesAsync()){
|
|
561
|
+
results.push(this.convertToProposedCheckpointData(stored));
|
|
562
|
+
}
|
|
563
|
+
return results;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Evicts all pending checkpoints with checkpoint number >= fromNumber.
|
|
567
|
+
* Used for divergent-mined-checkpoint cleanup: when L1 mines checkpoint N with a different archive,
|
|
568
|
+
* all pending >= N must be evicted since they chain off the now-invalid pending N.
|
|
569
|
+
*/ async evictProposedCheckpointsFrom(fromNumber) {
|
|
570
|
+
const keysToDelete = [];
|
|
571
|
+
for await (const key of this.#proposedCheckpoints.keysAsync()){
|
|
572
|
+
if (key >= fromNumber) {
|
|
573
|
+
keysToDelete.push(key);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
for (const key of keysToDelete){
|
|
577
|
+
await this.#proposedCheckpoints.delete(key);
|
|
544
578
|
}
|
|
545
|
-
return this.convertToProposedCheckpointData(stored);
|
|
546
579
|
}
|
|
547
580
|
/**
|
|
548
|
-
* Gets the checkpoint at the proposed tip
|
|
549
|
-
* - pending checkpoint if
|
|
581
|
+
* Gets the checkpoint at the proposed tip:
|
|
582
|
+
* - latest pending checkpoint if any exist
|
|
550
583
|
* - fallsback to latest confirmed checkpoint otherwise
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
if (!stored) {
|
|
584
|
+
*/ async getLastCheckpoint() {
|
|
585
|
+
const latest = await this.getLastProposedCheckpoint();
|
|
586
|
+
if (!latest) {
|
|
555
587
|
return this.getCheckpointData(await this.getLatestCheckpointNumber());
|
|
556
588
|
}
|
|
557
|
-
return
|
|
589
|
+
return latest;
|
|
558
590
|
}
|
|
559
591
|
convertToProposedCheckpointData(stored) {
|
|
560
592
|
return {
|
|
@@ -572,7 +604,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
572
604
|
* Attempts to get the proposedCheckpoint's number, if there is not one, then fallback to the latest confirmed checkpoint number.
|
|
573
605
|
* @returns CheckpointNumber
|
|
574
606
|
*/ async getProposedCheckpointNumber() {
|
|
575
|
-
const proposed = await this.
|
|
607
|
+
const proposed = await this.getLastCheckpoint();
|
|
576
608
|
if (!proposed) {
|
|
577
609
|
return await this.getLatestCheckpointNumber();
|
|
578
610
|
}
|
|
@@ -582,7 +614,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
582
614
|
* Attempts to get the proposedCheckpoint's block number, if there is not one, then fallback to the checkpointed block number
|
|
583
615
|
* @returns BlockNumber
|
|
584
616
|
*/ async getProposedCheckpointL2BlockNumber() {
|
|
585
|
-
const proposed = await this.
|
|
617
|
+
const proposed = await this.getLastCheckpoint();
|
|
586
618
|
if (!proposed) {
|
|
587
619
|
return await this.getCheckpointedL2BlockNumber();
|
|
588
620
|
}
|
|
@@ -608,7 +640,10 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
608
640
|
* @param start - Number of the first block to return (inclusive).
|
|
609
641
|
* @param limit - The number of blocks to return.
|
|
610
642
|
* @returns The requested L2 blocks
|
|
611
|
-
*/
|
|
643
|
+
*/ getCheckpointedBlocks(start, limit) {
|
|
644
|
+
return toArray(this.iterateCheckpointedBlocks(start, limit));
|
|
645
|
+
}
|
|
646
|
+
/** Async iterator variant of {@link getCheckpointedBlocks}. */ async *iterateCheckpointedBlocks(start, limit) {
|
|
612
647
|
const checkpointCache = new Map();
|
|
613
648
|
for await (const [blockNumber, blockStorage] of this.getBlockStorages(start, limit)){
|
|
614
649
|
const block = await this.getBlockFromBlockStorage(blockNumber, blockStorage);
|
|
@@ -641,7 +676,10 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
641
676
|
* @param start - Number of the first block to return (inclusive).
|
|
642
677
|
* @param limit - The number of blocks to return.
|
|
643
678
|
* @returns The requested L2 blocks
|
|
644
|
-
*/
|
|
679
|
+
*/ getBlocks(start, limit) {
|
|
680
|
+
return toArray(this.iterateBlocks(start, limit));
|
|
681
|
+
}
|
|
682
|
+
/** Async iterator variant of {@link getBlocks}. */ async *iterateBlocks(start, limit) {
|
|
645
683
|
for await (const [blockNumber, blockStorage] of this.getBlockStorages(start, limit)){
|
|
646
684
|
const block = await this.getBlockFromBlockStorage(blockNumber, blockStorage);
|
|
647
685
|
if (block) {
|
|
@@ -661,6 +699,37 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
661
699
|
return this.getBlockDataFromBlockStorage(blockStorage);
|
|
662
700
|
}
|
|
663
701
|
/**
|
|
702
|
+
* Gets block metadata plus checkpoint-derived context (L1 publish info, attestations) without
|
|
703
|
+
* deserializing tx bodies. When the block's containing checkpoint has not yet been L1-confirmed,
|
|
704
|
+
* `checkpoint` and `l1` are `undefined` and `attestations` is empty.
|
|
705
|
+
*/ async getBlockDataWithCheckpointContext(blockNumber) {
|
|
706
|
+
const blockStorage = await this.#blocks.getAsync(blockNumber);
|
|
707
|
+
if (!blockStorage || !blockStorage.header) {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
const data = this.getBlockDataFromBlockStorage(blockStorage);
|
|
711
|
+
const checkpointStorage = await this.#checkpoints.getAsync(blockStorage.checkpointNumber);
|
|
712
|
+
if (!checkpointStorage) {
|
|
713
|
+
return {
|
|
714
|
+
data,
|
|
715
|
+
checkpoint: undefined,
|
|
716
|
+
l1: undefined,
|
|
717
|
+
attestations: []
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
const checkpoint = this.checkpointDataFromCheckpointStorage(checkpointStorage);
|
|
721
|
+
return {
|
|
722
|
+
data,
|
|
723
|
+
checkpoint,
|
|
724
|
+
l1: checkpoint.l1,
|
|
725
|
+
attestations: checkpoint.attestations
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
/** Returns the checkpoint number that contains the given slot (or undefined if not found). */ async getCheckpointNumberBySlot(slot) {
|
|
729
|
+
const checkpointNumber = await this.#slotToCheckpoint.getAsync(slot);
|
|
730
|
+
return checkpointNumber === undefined ? undefined : CheckpointNumber(checkpointNumber);
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
664
733
|
* Gets block metadata (without tx data) by archive root.
|
|
665
734
|
* @param archive - The archive root of the block to return.
|
|
666
735
|
* @returns The requested block data.
|
|
@@ -739,7 +808,10 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
739
808
|
* @param start - Number of the first block to return (inclusive).
|
|
740
809
|
* @param limit - The number of blocks to return.
|
|
741
810
|
* @returns The requested L2 block headers
|
|
742
|
-
*/
|
|
811
|
+
*/ getBlockHeaders(start, limit) {
|
|
812
|
+
return toArray(this.iterateBlockHeaders(start, limit));
|
|
813
|
+
}
|
|
814
|
+
/** Async iterator variant of {@link getBlockHeaders}. */ async *iterateBlockHeaders(start, limit) {
|
|
743
815
|
for await (const [blockNumber, blockStorage] of this.getBlockStorages(start, limit)){
|
|
744
816
|
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
745
817
|
if (header.getBlockNumber() !== blockNumber) {
|
|
@@ -887,18 +959,23 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
887
959
|
setSynchedL1BlockNumber(l1BlockNumber) {
|
|
888
960
|
return this.#lastSynchedL1Block.set(l1BlockNumber);
|
|
889
961
|
}
|
|
890
|
-
/**
|
|
891
|
-
*
|
|
962
|
+
/**
|
|
963
|
+
* Adds a proposed checkpoint to the pending queue.
|
|
964
|
+
* Accepts proposed.checkpointNumber === latestTip + 1, where latestTip is the highest of
|
|
965
|
+
* confirmed and the highest pending checkpoint number.
|
|
966
|
+
* Computes archive and checkpointOutHash from the stored blocks.
|
|
967
|
+
*/ async addProposedCheckpoint(proposed) {
|
|
892
968
|
return await this.db.transactionAsync(async ()=>{
|
|
893
|
-
const current = await this.getProposedCheckpointNumber();
|
|
894
|
-
if (proposed.checkpointNumber <= current) {
|
|
895
|
-
throw new ProposedCheckpointStaleError(proposed.checkpointNumber, current);
|
|
896
|
-
}
|
|
897
969
|
const confirmed = await this.getLatestCheckpointNumber();
|
|
898
|
-
|
|
899
|
-
|
|
970
|
+
const [latestPendingKey] = await toArray(this.#proposedCheckpoints.keysAsync({
|
|
971
|
+
reverse: true,
|
|
972
|
+
limit: 1
|
|
973
|
+
}));
|
|
974
|
+
const latestTip = CheckpointNumber(latestPendingKey !== undefined ? Math.max(latestPendingKey, confirmed) : confirmed);
|
|
975
|
+
if (proposed.checkpointNumber !== latestTip + 1) {
|
|
976
|
+
throw new ProposedCheckpointNotSequentialError(proposed.checkpointNumber, latestTip);
|
|
900
977
|
}
|
|
901
|
-
// Ensure the
|
|
978
|
+
// Ensure the predecessor block (from pending or confirmed chain) exists
|
|
902
979
|
const previousBlock = await this.getPreviousCheckpointBlock(proposed.checkpointNumber);
|
|
903
980
|
const blocks = [];
|
|
904
981
|
for(let i = 0; i < proposed.blockCount; i++){
|
|
@@ -911,7 +988,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
911
988
|
this.validateCheckpointBlocks(blocks, previousBlock);
|
|
912
989
|
const archive = blocks[blocks.length - 1].archive;
|
|
913
990
|
const checkpointOutHash = Checkpoint.getCheckpointOutHash(blocks);
|
|
914
|
-
await this.#
|
|
991
|
+
await this.#proposedCheckpoints.set(proposed.checkpointNumber, {
|
|
915
992
|
header: proposed.header.toBuffer(),
|
|
916
993
|
archive: archive.toBuffer(),
|
|
917
994
|
checkpointOutHash: checkpointOutHash.toBuffer(),
|