@aztec/world-state 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d240
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/instrumentation/instrumentation.d.ts +1 -1
- package/dest/instrumentation/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation/instrumentation.js +9 -2
- package/dest/native/fork_checkpoint.d.ts +7 -1
- package/dest/native/fork_checkpoint.d.ts.map +1 -1
- package/dest/native/fork_checkpoint.js +15 -3
- package/dest/native/ipc_world_state_instance.d.ts +50 -0
- package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
- package/dest/native/ipc_world_state_instance.js +628 -0
- package/dest/native/merkle_trees_facade.d.ts +9 -6
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +45 -16
- package/dest/native/message.d.ts +13 -5
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/native_world_state.d.ts +34 -8
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +81 -27
- package/dest/native/native_world_state_instance.d.ts +6 -5
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +33 -26
- package/dest/native/world_state_ops_queue.js +5 -5
- package/dest/synchronizer/config.d.ts +3 -5
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +15 -18
- package/dest/synchronizer/factory.d.ts +6 -5
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +7 -6
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +4 -5
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +109 -37
- package/dest/test/utils.d.ts +7 -7
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +5 -5
- package/dest/testing.d.ts +4 -3
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +10 -6
- package/dest/world-state-db/merkle_tree_db.d.ts +3 -12
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/package.json +13 -12
- package/src/instrumentation/instrumentation.ts +9 -1
- package/src/native/fork_checkpoint.ts +19 -3
- package/src/native/ipc_world_state_instance.ts +717 -0
- package/src/native/merkle_trees_facade.ts +51 -17
- package/src/native/message.ts +14 -4
- package/src/native/native_world_state.ts +108 -32
- package/src/native/native_world_state_instance.ts +44 -32
- package/src/native/world_state_ops_queue.ts +5 -5
- package/src/synchronizer/config.ts +16 -23
- package/src/synchronizer/factory.ts +19 -11
- package/src/synchronizer/server_world_state_synchronizer.ts +119 -46
- package/src/test/utils.ts +6 -6
- package/src/testing.ts +8 -9
- package/src/world-state-db/merkle_tree_db.ts +2 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { INITIAL_CHECKPOINT_NUMBER } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
5
5
|
import { elapsed } from '@aztec/foundation/timer';
|
|
@@ -23,7 +23,6 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
23
23
|
latestBlockNumberAtStart;
|
|
24
24
|
historyToKeep;
|
|
25
25
|
currentState;
|
|
26
|
-
latestBlockHashQuery;
|
|
27
26
|
syncPromise;
|
|
28
27
|
blockStream;
|
|
29
28
|
// WorldState doesn't track the proven block number, it only tracks the latest tips of the pending chain and the finalized chain
|
|
@@ -37,10 +36,9 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
37
36
|
this.log = log;
|
|
38
37
|
this.latestBlockNumberAtStart = BlockNumber.ZERO;
|
|
39
38
|
this.currentState = WorldStateRunningState.IDLE;
|
|
40
|
-
this.latestBlockHashQuery = undefined;
|
|
41
39
|
this.syncPromise = promiseWithResolvers();
|
|
42
40
|
this.merkleTreeCommitted = this.merkleTreeDb.getCommitted();
|
|
43
|
-
this.historyToKeep = config.
|
|
41
|
+
this.historyToKeep = config.worldStateCheckpointHistory < 1 ? undefined : config.worldStateCheckpointHistory;
|
|
44
42
|
this.log.info(`Created world state synchroniser with block history of ${this.historyToKeep === undefined ? 'infinity' : this.historyToKeep}`);
|
|
45
43
|
}
|
|
46
44
|
getCommitted() {
|
|
@@ -66,7 +64,7 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
66
64
|
return this.syncPromise;
|
|
67
65
|
}
|
|
68
66
|
// Get the current latest block number
|
|
69
|
-
this.latestBlockNumberAtStart = BlockNumber(await
|
|
67
|
+
this.latestBlockNumberAtStart = BlockNumber(await this.l2BlockSource.getBlockNumber());
|
|
70
68
|
const blockToDownloadFrom = await this.getLatestBlockNumber() + 1;
|
|
71
69
|
if (blockToDownloadFrom <= this.latestBlockNumberAtStart) {
|
|
72
70
|
// If there are blocks to be retrieved, go to a synching state
|
|
@@ -86,7 +84,6 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
86
84
|
createBlockStream() {
|
|
87
85
|
const logger = createLogger('world-state:block_stream');
|
|
88
86
|
return new L2BlockStream(this.l2BlockSource, this, this, logger, {
|
|
89
|
-
proven: this.config.worldStateProvenBlocksOnly,
|
|
90
87
|
pollIntervalMS: this.config.worldStateBlockCheckIntervalMS,
|
|
91
88
|
batchSize: this.config.worldStateBlockRequestBatchSize,
|
|
92
89
|
ignoreCheckpoints: true
|
|
@@ -133,9 +130,9 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
133
130
|
/**
|
|
134
131
|
* Forces an immediate sync.
|
|
135
132
|
* @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
|
|
136
|
-
* @param
|
|
133
|
+
* @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash. On mismatch, triggers a resync (reorg detection).
|
|
137
134
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
138
|
-
*/ async syncImmediate(targetBlockNumber,
|
|
135
|
+
*/ async syncImmediate(targetBlockNumber, blockHash) {
|
|
139
136
|
if (this.currentState !== WorldStateRunningState.RUNNING) {
|
|
140
137
|
throw new Error(`World State is not running. Unable to perform sync.`);
|
|
141
138
|
}
|
|
@@ -145,7 +142,16 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
145
142
|
// If we have been given a block number to sync to and we have reached that number then return
|
|
146
143
|
const currentBlockNumber = await this.getLatestBlockNumber();
|
|
147
144
|
if (targetBlockNumber !== undefined && targetBlockNumber <= currentBlockNumber) {
|
|
148
|
-
|
|
145
|
+
if (blockHash === undefined) {
|
|
146
|
+
return currentBlockNumber;
|
|
147
|
+
}
|
|
148
|
+
// If a block hash was provided, verify we're on the expected fork
|
|
149
|
+
const currentHash = await this.getL2BlockHash(targetBlockNumber);
|
|
150
|
+
if (currentHash === blockHash.toString()) {
|
|
151
|
+
return currentBlockNumber;
|
|
152
|
+
}
|
|
153
|
+
// Hash mismatch: a reorg may have occurred, fall through to trigger sync
|
|
154
|
+
this.log.debug(`World state block hash mismatch at ${targetBlockNumber} (expected ${blockHash}, got ${currentHash}). Triggering resync.`);
|
|
149
155
|
}
|
|
150
156
|
this.log.debug(`World State at ${currentBlockNumber} told to sync to ${targetBlockNumber ?? 'latest'}`);
|
|
151
157
|
// If the archiver is behind the target block, force an archiver sync
|
|
@@ -160,7 +166,7 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
160
166
|
await this.blockStream.sync();
|
|
161
167
|
// If we have been given a block number to sync to and we have not reached that number then fail
|
|
162
168
|
const updatedBlockNumber = await this.getLatestBlockNumber();
|
|
163
|
-
if (
|
|
169
|
+
if (targetBlockNumber !== undefined && targetBlockNumber > updatedBlockNumber) {
|
|
164
170
|
throw new WorldStateSynchronizerError(`Unable to sync to block number ${targetBlockNumber} (last synced is ${updatedBlockNumber})`, {
|
|
165
171
|
cause: {
|
|
166
172
|
reason: 'block_not_available',
|
|
@@ -170,23 +176,39 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
170
176
|
}
|
|
171
177
|
});
|
|
172
178
|
}
|
|
179
|
+
// If a block hash was provided, verify we're on the expected fork after syncing, throw otherwise
|
|
180
|
+
if (blockHash !== undefined && targetBlockNumber !== undefined) {
|
|
181
|
+
const updatedHash = await this.getL2BlockHash(targetBlockNumber);
|
|
182
|
+
if (updatedHash !== blockHash.toString()) {
|
|
183
|
+
throw new WorldStateSynchronizerError(`Block hash mismatch at block ${targetBlockNumber} (expected ${blockHash} but got ${updatedHash})`, {
|
|
184
|
+
cause: {
|
|
185
|
+
reason: 'block_hash_mismatch',
|
|
186
|
+
targetBlockNumber,
|
|
187
|
+
expectedHash: blockHash.toString(),
|
|
188
|
+
actualHash: updatedHash
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
173
193
|
return updatedBlockNumber;
|
|
174
194
|
}
|
|
175
195
|
/** Returns the L2 block hash for a given number. Used by the L2BlockStream for detecting reorgs. */ async getL2BlockHash(number) {
|
|
176
196
|
if (number === BlockNumber.ZERO) {
|
|
177
197
|
return (await this.merkleTreeCommitted.getInitialHeader().hash()).toString();
|
|
178
198
|
}
|
|
179
|
-
|
|
180
|
-
this.latestBlockHashQuery = {
|
|
181
|
-
hash: await this.merkleTreeCommitted.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(number)).then((leaf)=>leaf?.toString()),
|
|
182
|
-
blockNumber: number
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
return this.latestBlockHashQuery.hash;
|
|
199
|
+
return this.merkleTreeCommitted.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(number)).then((leaf)=>leaf?.toString());
|
|
186
200
|
}
|
|
187
201
|
/** Returns the latest L2 block number for each tip of the chain (latest, proven, finalized). */ async getL2Tips() {
|
|
188
202
|
const status = await this.merkleTreeDb.getStatusSummary();
|
|
189
|
-
const
|
|
203
|
+
const unfinalizedBlockHashPromise = this.getL2BlockHash(status.unfinalizedBlockNumber);
|
|
204
|
+
const finalizedBlockHashPromise = this.getL2BlockHash(status.finalizedBlockNumber);
|
|
205
|
+
const provenBlockNumber = this.provenBlockNumber ?? status.finalizedBlockNumber;
|
|
206
|
+
const provenBlockHashPromise = this.provenBlockNumber === undefined ? finalizedBlockHashPromise : this.getL2BlockHash(this.provenBlockNumber);
|
|
207
|
+
const [unfinalizedBlockHash, finalizedBlockHash, provenBlockHash] = await Promise.all([
|
|
208
|
+
unfinalizedBlockHashPromise,
|
|
209
|
+
finalizedBlockHashPromise,
|
|
210
|
+
provenBlockHashPromise
|
|
211
|
+
]);
|
|
190
212
|
const latestBlockId = {
|
|
191
213
|
number: status.unfinalizedBlockNumber,
|
|
192
214
|
hash: unfinalizedBlockHash
|
|
@@ -195,35 +217,46 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
195
217
|
// but we use a block stream so we need to provide 'local' L2Tips.
|
|
196
218
|
// We configure the block stream to ignore checkpoints and set checkpoint values to genesis here.
|
|
197
219
|
const genesisCheckpointHeaderHash = GENESIS_CHECKPOINT_HEADER_HASH.toString();
|
|
220
|
+
const initialBlockHash = (await this.merkleTreeCommitted.getInitialHeader().hash()).toString();
|
|
198
221
|
return {
|
|
199
222
|
proposed: latestBlockId,
|
|
200
223
|
checkpointed: {
|
|
201
224
|
block: {
|
|
202
|
-
number:
|
|
203
|
-
hash:
|
|
225
|
+
number: BlockNumber.ZERO,
|
|
226
|
+
hash: initialBlockHash
|
|
227
|
+
},
|
|
228
|
+
checkpoint: {
|
|
229
|
+
number: INITIAL_CHECKPOINT_NUMBER,
|
|
230
|
+
hash: genesisCheckpointHeaderHash
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
proposedCheckpoint: {
|
|
234
|
+
block: {
|
|
235
|
+
number: BlockNumber.ZERO,
|
|
236
|
+
hash: initialBlockHash
|
|
204
237
|
},
|
|
205
238
|
checkpoint: {
|
|
206
|
-
number:
|
|
239
|
+
number: INITIAL_CHECKPOINT_NUMBER,
|
|
207
240
|
hash: genesisCheckpointHeaderHash
|
|
208
241
|
}
|
|
209
242
|
},
|
|
210
243
|
finalized: {
|
|
211
244
|
block: {
|
|
212
245
|
number: status.finalizedBlockNumber,
|
|
213
|
-
hash: ''
|
|
246
|
+
hash: finalizedBlockHash ?? ''
|
|
214
247
|
},
|
|
215
248
|
checkpoint: {
|
|
216
|
-
number:
|
|
249
|
+
number: INITIAL_CHECKPOINT_NUMBER,
|
|
217
250
|
hash: genesisCheckpointHeaderHash
|
|
218
251
|
}
|
|
219
252
|
},
|
|
220
253
|
proven: {
|
|
221
254
|
block: {
|
|
222
|
-
number:
|
|
223
|
-
hash: ''
|
|
255
|
+
number: provenBlockNumber,
|
|
256
|
+
hash: provenBlockHash ?? ''
|
|
224
257
|
},
|
|
225
258
|
checkpoint: {
|
|
226
|
-
number:
|
|
259
|
+
number: INITIAL_CHECKPOINT_NUMBER,
|
|
227
260
|
hash: genesisCheckpointHeaderHash
|
|
228
261
|
}
|
|
229
262
|
}
|
|
@@ -250,7 +283,7 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
250
283
|
* @param l2Blocks - The L2 blocks to handle.
|
|
251
284
|
* @returns Whether the block handled was produced by this same node.
|
|
252
285
|
*/ async handleL2Blocks(l2Blocks) {
|
|
253
|
-
this.log.
|
|
286
|
+
this.log.debug(`Handling L2 blocks ${l2Blocks[0].number} to ${l2Blocks.at(-1).number}`);
|
|
254
287
|
// Fetch the L1->L2 messages for the first block in a checkpoint.
|
|
255
288
|
const messagesForBlocks = new Map();
|
|
256
289
|
await Promise.all(l2Blocks.filter((b)=>b.indexWithinCheckpoint === 0).map(async (block)=>{
|
|
@@ -281,10 +314,12 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
281
314
|
* @param l1ToL2Messages - The L1 to L2 messages for the block.
|
|
282
315
|
* @returns Whether the block handled was produced by this same node.
|
|
283
316
|
*/ async handleL2Block(l2Block, l1ToL2Messages) {
|
|
284
|
-
this.log.
|
|
317
|
+
this.log.debug(`Pushing L2 block ${l2Block.number} to merkle tree db `, {
|
|
285
318
|
blockNumber: l2Block.number,
|
|
286
319
|
blockHash: await l2Block.hash().then((h)=>h.toString()),
|
|
287
|
-
l1ToL2Messages: l1ToL2Messages.map((msg)=>msg.toString())
|
|
320
|
+
l1ToL2Messages: l1ToL2Messages.map((msg)=>msg.toString()),
|
|
321
|
+
blockHeader: l2Block.header.toInspect(),
|
|
322
|
+
blockStats: l2Block.getStats()
|
|
288
323
|
});
|
|
289
324
|
const result = await this.merkleTreeDb.handleL2BlockAndMessages(l2Block, l1ToL2Messages);
|
|
290
325
|
if (this.currentState === WorldStateRunningState.SYNCHING && l2Block.number >= this.latestBlockNumberAtStart) {
|
|
@@ -295,16 +330,52 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
295
330
|
}
|
|
296
331
|
async handleChainFinalized(blockNumber) {
|
|
297
332
|
this.log.verbose(`Finalized chain is now at block ${blockNumber}`);
|
|
333
|
+
// If the finalized block number is older than the oldest available block in world state,
|
|
334
|
+
// skip entirely. The finalized block number can jump backwards (e.g. when the finalization
|
|
335
|
+
// heuristic changes) and try to read block data that has already been pruned. When this
|
|
336
|
+
// happens, there is nothing useful to do — the native world state is already finalized
|
|
337
|
+
// past this point and pruning has already happened.
|
|
338
|
+
const currentSummary = await this.merkleTreeDb.getStatusSummary();
|
|
339
|
+
if (blockNumber < currentSummary.oldestHistoricalBlock || blockNumber < 1) {
|
|
340
|
+
this.log.trace(`Finalized block ${blockNumber} is older than the oldest available block ${currentSummary.oldestHistoricalBlock}. Skipping.`);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
298
343
|
const summary = await this.merkleTreeDb.setFinalized(blockNumber);
|
|
299
344
|
if (this.historyToKeep === undefined) {
|
|
300
345
|
return;
|
|
301
346
|
}
|
|
302
|
-
const
|
|
303
|
-
|
|
347
|
+
const finalisedBlockData = await this.l2BlockSource.getBlockData({
|
|
348
|
+
number: summary.finalizedBlockNumber
|
|
349
|
+
});
|
|
350
|
+
if (finalisedBlockData === undefined) {
|
|
351
|
+
this.log.warn(`Failed to retrieve checkpointed block for finalized block number: ${summary.finalizedBlockNumber}`);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
// Compute the required historic checkpoint number
|
|
355
|
+
const newHistoricCheckpointNumber = finalisedBlockData.checkpointNumber - this.historyToKeep + 1;
|
|
356
|
+
if (newHistoricCheckpointNumber <= 1) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
// Retrieve the historic checkpoint
|
|
360
|
+
const historicCheckpoint = await this.l2BlockSource.getCheckpoint({
|
|
361
|
+
number: CheckpointNumber(newHistoricCheckpointNumber)
|
|
362
|
+
});
|
|
363
|
+
if (!historicCheckpoint) {
|
|
364
|
+
this.log.warn(`Failed to retrieve checkpoint number ${newHistoricCheckpointNumber} from Archiver`);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (historicCheckpoint.checkpoint.blocks.length === 0 || historicCheckpoint.checkpoint.blocks[0] === undefined) {
|
|
368
|
+
this.log.warn(`Retrieved checkpoint number ${newHistoricCheckpointNumber} has no blocks!`);
|
|
304
369
|
return;
|
|
305
370
|
}
|
|
306
|
-
|
|
307
|
-
const
|
|
371
|
+
// Find the block at the start of the checkpoint and remove blocks up to this one
|
|
372
|
+
const newHistoricBlock = historicCheckpoint.checkpoint.blocks[0];
|
|
373
|
+
if (newHistoricBlock.number <= currentSummary.oldestHistoricalBlock) {
|
|
374
|
+
this.log.debug(`Historic block ${newHistoricBlock.number} is not newer than oldest available ${currentSummary.oldestHistoricalBlock}. Skipping prune.`);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
this.log.verbose(`Pruning historic blocks to ${newHistoricBlock.number}`);
|
|
378
|
+
const status = await this.merkleTreeDb.removeHistoricalBlocks(BlockNumber(newHistoricBlock.number));
|
|
308
379
|
this.log.debug(`World state summary `, status.summary);
|
|
309
380
|
}
|
|
310
381
|
handleChainProven(blockNumber) {
|
|
@@ -313,10 +384,11 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
313
384
|
return Promise.resolve();
|
|
314
385
|
}
|
|
315
386
|
async handleChainPruned(blockNumber) {
|
|
316
|
-
this.log.
|
|
387
|
+
this.log.info(`Chain pruned to block ${blockNumber}`);
|
|
317
388
|
const status = await this.merkleTreeDb.unwindBlocks(blockNumber);
|
|
318
|
-
this.
|
|
319
|
-
|
|
389
|
+
if (this.provenBlockNumber !== undefined && this.provenBlockNumber > blockNumber) {
|
|
390
|
+
this.provenBlockNumber = undefined;
|
|
391
|
+
}
|
|
320
392
|
this.instrumentation.updateWorldStateMetrics(status);
|
|
321
393
|
}
|
|
322
394
|
/**
|
package/dest/test/utils.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { BlockNumber, type CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import {
|
|
3
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
4
4
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import { mockCheckpointAndMessages } from '@aztec/stdlib/testing';
|
|
6
6
|
import type { NativeWorldStateService } from '../native/native_world_state.js';
|
|
7
|
-
export declare function updateBlockState(block:
|
|
7
|
+
export declare function updateBlockState(block: L2Block, l1ToL2Messages: Fr[], fork: MerkleTreeWriteOperations): Promise<void>;
|
|
8
8
|
export declare function mockBlock(blockNum: BlockNumber, size: number, fork: MerkleTreeWriteOperations, maxEffects?: number | undefined, numL1ToL2Messages?: number, isFirstBlockInCheckpoint?: boolean): Promise<{
|
|
9
|
-
block:
|
|
9
|
+
block: L2Block;
|
|
10
10
|
messages: Fr[];
|
|
11
11
|
}>;
|
|
12
12
|
export declare function mockEmptyBlock(blockNum: BlockNumber, fork: MerkleTreeWriteOperations): Promise<{
|
|
13
|
-
block:
|
|
13
|
+
block: L2Block;
|
|
14
14
|
messages: Fr[];
|
|
15
15
|
}>;
|
|
16
16
|
export declare function mockBlocks(from: BlockNumber, count: number, numTxs: number, worldState: NativeWorldStateService): Promise<{
|
|
17
|
-
blocks:
|
|
17
|
+
blocks: L2Block[];
|
|
18
18
|
messages: Fr[][];
|
|
19
19
|
}>;
|
|
20
20
|
export declare function mockCheckpoint(checkpointNumber: CheckpointNumber, fork: MerkleTreeWriteOperations, options?: Partial<Parameters<typeof mockCheckpointAndMessages>[1]>): Promise<{
|
|
21
|
-
checkpoint: import("
|
|
21
|
+
checkpoint: import("@aztec/stdlib/checkpoint").Checkpoint;
|
|
22
22
|
messages: Fr[];
|
|
23
23
|
}>;
|
|
24
24
|
export declare function assertSameState(forkA: MerkleTreeReadOperations, forkB: MerkleTreeReadOperations): Promise<void>;
|
|
25
25
|
export declare function compareChains(left: MerkleTreeReadOperations, right: MerkleTreeReadOperations): Promise<void>;
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sRUFBRSxXQUFXLEVBQUUsS0FBSyxnQkFBZ0IsRUFBeUIsTUFBTSxpQ0FBaUMsQ0FBQztBQUU1RyxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQzlDLE9BQU8sS0FBSyxFQUVWLHdCQUF3QixFQUN4Qix5QkFBeUIsRUFDMUIsTUFBTSxpQ0FBaUMsQ0FBQztBQUN6QyxPQUFPLEVBQUUseUJBQXlCLEVBQXNCLE1BQU0sdUJBQXVCLENBQUM7QUFJdEYsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUUvRSx3QkFBc0IsZ0JBQWdCLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxjQUFjLEVBQUUsRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLHlCQUF5QixpQkE4QzNHO0FBRUQsd0JBQXNCLFNBQVMsQ0FDN0IsUUFBUSxFQUFFLFdBQVcsRUFDckIsSUFBSSxFQUFFLE1BQU0sRUFDWixJQUFJLEVBQUUseUJBQXlCLEVBQy9CLFVBQVUsR0FBRSxNQUFNLEdBQUcsU0FBZ0IsRUFDckMsaUJBQWlCLEdBQUUsTUFBNEMsRUFDL0Qsd0JBQXdCLEdBQUUsT0FBYzs7O0dBZXpDO0FBRUQsd0JBQXNCLGNBQWMsQ0FBQyxRQUFRLEVBQUUsV0FBVyxFQUFFLElBQUksRUFBRSx5QkFBeUI7OztHQVkxRjtBQUVELHdCQUFzQixVQUFVLENBQzlCLElBQUksRUFBRSxXQUFXLEVBQ2pCLEtBQUssRUFBRSxNQUFNLEVBQ2IsTUFBTSxFQUFFLE1BQU0sRUFDZCxVQUFVLEVBQUUsdUJBQXVCOzs7R0FlcEM7QUFFRCx3QkFBc0IsY0FBYyxDQUNsQyxnQkFBZ0IsRUFBRSxnQkFBZ0IsRUFDbEMsSUFBSSxFQUFFLHlCQUF5QixFQUMvQixPQUFPLEdBQUUsT0FBTyxDQUFDLFVBQVUsQ0FBQyxPQUFPLHlCQUF5QixDQUFDLENBQUMsQ0FBQyxDQUFDLENBQU07OztHQU92RTtBQUVELHdCQUFzQixlQUFlLENBQUMsS0FBSyxFQUFFLHdCQUF3QixFQUFFLEtBQUssRUFBRSx3QkFBd0IsaUJBUXJHO0FBRUQsd0JBQXNCLGFBQWEsQ0FBQyxJQUFJLEVBQUUsd0JBQXdCLEVBQUUsS0FBSyxFQUFFLHdCQUF3QixpQkFZbEcifQ==
|
package/dest/test/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAE5G,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAEV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAsB,MAAM,uBAAuB,CAAC;AAItF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,yBAAyB,iBA8C3G;AAED,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,yBAAyB,EAC/B,UAAU,GAAE,MAAM,GAAG,SAAgB,EACrC,iBAAiB,GAAE,MAA4C,EAC/D,wBAAwB,GAAE,OAAc;;;GAezC;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,yBAAyB;;;GAY1F;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,uBAAuB;;;GAepC;AAED,wBAAsB,cAAc,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,yBAAyB,EAC/B,OAAO,GAAE,OAAO,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAM;;;GAOvE;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,wBAAwB,iBAQrG;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,wBAAwB,iBAYlG"}
|
package/dest/test/utils.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
3
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { BlockNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
-
import {
|
|
6
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import { mockCheckpointAndMessages, mockL1ToL2Messages } from '@aztec/stdlib/testing';
|
|
8
8
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
9
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
@@ -35,8 +35,8 @@ export async function updateBlockState(block, l1ToL2Messages, fork) {
|
|
|
35
35
|
block.archive = new AppendOnlyTreeSnapshot(Fr.fromBuffer(archiveState.root), Number(archiveState.size));
|
|
36
36
|
}
|
|
37
37
|
export async function mockBlock(blockNum, size, fork, maxEffects = 1000, numL1ToL2Messages = NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, isFirstBlockInCheckpoint = true) {
|
|
38
|
-
const block = await
|
|
39
|
-
indexWithinCheckpoint: isFirstBlockInCheckpoint ? 0 : 1,
|
|
38
|
+
const block = await L2Block.random(blockNum, {
|
|
39
|
+
indexWithinCheckpoint: isFirstBlockInCheckpoint ? IndexWithinCheckpoint(0) : IndexWithinCheckpoint(1),
|
|
40
40
|
txsPerBlock: size,
|
|
41
41
|
txOptions: {
|
|
42
42
|
maxEffects
|
|
@@ -50,7 +50,7 @@ export async function mockBlock(blockNum, size, fork, maxEffects = 1000, numL1To
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
export async function mockEmptyBlock(blockNum, fork) {
|
|
53
|
-
const l2Block =
|
|
53
|
+
const l2Block = L2Block.empty();
|
|
54
54
|
const l1ToL2Messages = Array(16).fill(0).map(Fr.zero);
|
|
55
55
|
l2Block.header.globalVariables.blockNumber = blockNum;
|
|
56
56
|
await updateBlockState(l2Block, l1ToL2Messages, fork);
|
package/dest/testing.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
4
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
4
5
|
export declare const defaultInitialAccountFeeJuice: Fr;
|
|
5
|
-
export declare function getGenesisValues(initialAccounts: AztecAddress[], initialAccountFeeJuice?: Fr, genesisPublicData?: PublicDataTreeLeaf[]): Promise<{
|
|
6
|
+
export declare function getGenesisValues(initialAccounts: AztecAddress[], initialAccountFeeJuice?: Fr, genesisPublicData?: PublicDataTreeLeaf[], genesisTimestamp?: bigint): Promise<{
|
|
6
7
|
genesisArchiveRoot: Fr;
|
|
7
|
-
|
|
8
|
+
genesis: GenesisData;
|
|
8
9
|
fundingNeeded: bigint;
|
|
9
10
|
}>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBZ0Isa0JBQWtCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQXFCN0QsZUFBTyxNQUFNLDZCQUE2QixJQUFxQixDQUFDO0FBRWhFLHdCQUFzQixnQkFBZ0IsQ0FDcEMsZUFBZSxFQUFFLFlBQVksRUFBRSxFQUMvQixzQkFBc0IsS0FBZ0MsRUFDdEQsaUJBQWlCLEdBQUUsa0JBQWtCLEVBQU8sRUFDNUMsZ0JBQWdCLEdBQUUsTUFBVzs7OztHQXNCOUIifQ==
|
package/dest/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAgB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAgB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAqB7D,eAAO,MAAM,6BAA6B,IAAqB,CAAC;AAEhE,wBAAsB,gBAAgB,CACpC,eAAe,EAAE,YAAY,EAAE,EAC/B,sBAAsB,KAAgC,EACtD,iBAAiB,GAAE,kBAAkB,EAAO,EAC5C,gBAAgB,GAAE,MAAW;;;;GAsB9B"}
|
package/dest/testing.js
CHANGED
|
@@ -3,14 +3,14 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
4
|
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
5
5
|
import { NativeWorldStateService } from './native/index.js';
|
|
6
|
-
async function generateGenesisValues(
|
|
7
|
-
if (!prefilledPublicData.length) {
|
|
6
|
+
async function generateGenesisValues(genesis) {
|
|
7
|
+
if (!genesis.prefilledPublicData.length && genesis.genesisTimestamp === 0n) {
|
|
8
8
|
return {
|
|
9
9
|
genesisArchiveRoot: new Fr(GENESIS_ARCHIVE_ROOT)
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
// Create a temporary world state to compute the genesis values.
|
|
13
|
-
const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */ , true,
|
|
13
|
+
const ws = await NativeWorldStateService.tmp(undefined /* rollupAddress */ , true, genesis);
|
|
14
14
|
const genesisArchiveRoot = new Fr((await ws.getCommitted().getTreeInfo(MerkleTreeId.ARCHIVE)).root);
|
|
15
15
|
await ws.close();
|
|
16
16
|
return {
|
|
@@ -18,16 +18,20 @@ async function generateGenesisValues(prefilledPublicData) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export const defaultInitialAccountFeeJuice = new Fr(10n ** 22n);
|
|
21
|
-
export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = []) {
|
|
21
|
+
export async function getGenesisValues(initialAccounts, initialAccountFeeJuice = defaultInitialAccountFeeJuice, genesisPublicData = [], genesisTimestamp = 0n) {
|
|
22
22
|
// Top up the accounts with fee juice.
|
|
23
23
|
let prefilledPublicData = await Promise.all(initialAccounts.map(async (address)=>new PublicDataTreeLeaf(await computeFeePayerBalanceLeafSlot(address), initialAccountFeeJuice)));
|
|
24
24
|
// Add user-defined public data
|
|
25
25
|
prefilledPublicData = prefilledPublicData.concat(genesisPublicData);
|
|
26
26
|
prefilledPublicData.sort((a, b)=>b.slot.lt(a.slot) ? 1 : -1);
|
|
27
|
-
const
|
|
27
|
+
const genesis = {
|
|
28
|
+
prefilledPublicData,
|
|
29
|
+
genesisTimestamp
|
|
30
|
+
};
|
|
31
|
+
const { genesisArchiveRoot } = await generateGenesisValues(genesis);
|
|
28
32
|
return {
|
|
29
33
|
genesisArchiveRoot,
|
|
30
|
-
|
|
34
|
+
genesis,
|
|
31
35
|
fundingNeeded: BigInt(initialAccounts.length) * initialAccountFeeJuice.toBigInt()
|
|
32
36
|
};
|
|
33
37
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type {
|
|
4
|
-
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
3
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
4
|
import type { ForkMerkleTreeOperations, MerkleTreeReadOperations, ReadonlyWorldStateAccess } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import type { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
5
|
import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
|
|
8
6
|
/**
|
|
9
7
|
*
|
|
@@ -22,20 +20,13 @@ import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/me
|
|
|
22
20
|
*/
|
|
23
21
|
export declare const INITIAL_NULLIFIER_TREE_SIZE: number;
|
|
24
22
|
export declare const INITIAL_PUBLIC_DATA_TREE_SIZE: number;
|
|
25
|
-
export type TreeSnapshots = {
|
|
26
|
-
[MerkleTreeId.NULLIFIER_TREE]: IndexedTreeSnapshot;
|
|
27
|
-
[MerkleTreeId.NOTE_HASH_TREE]: TreeSnapshot<Fr>;
|
|
28
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: IndexedTreeSnapshot;
|
|
29
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: TreeSnapshot<Fr>;
|
|
30
|
-
[MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
|
|
31
|
-
};
|
|
32
23
|
export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, ReadonlyWorldStateAccess {
|
|
33
24
|
/**
|
|
34
25
|
* Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
|
|
35
26
|
* @param block - The L2 block to handle.
|
|
36
27
|
* @param l1ToL2Messages - The L1 to L2 messages for the block.
|
|
37
28
|
*/
|
|
38
|
-
handleL2BlockAndMessages(block:
|
|
29
|
+
handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
|
|
39
30
|
/**
|
|
40
31
|
* Gets a handle that allows reading the latest committed state
|
|
41
32
|
*/
|
|
@@ -68,4 +59,4 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, Reado
|
|
|
68
59
|
/** Deletes the db. */
|
|
69
60
|
clear(): Promise<void>;
|
|
70
61
|
}
|
|
71
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
62
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVya2xlX3RyZWVfZGIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93b3JsZC1zdGF0ZS1kYi9tZXJrbGVfdHJlZV9kYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssRUFDVix3QkFBd0IsRUFDeEIsd0JBQXdCLEVBQ3hCLHdCQUF3QixFQUN6QixNQUFNLGlDQUFpQyxDQUFDO0FBRXpDLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLHVCQUF1QixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFFMUY7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFDSCxlQUFPLE1BQU0sMkJBQTJCLFFBQTRCLENBQUM7QUFFckUsZUFBTyxNQUFNLDZCQUE2QixRQUFtRCxDQUFDO0FBRTlGLE1BQU0sV0FBVyx1QkFBd0IsU0FBUSx3QkFBd0IsRUFBRSx3QkFBd0I7SUFDakc7Ozs7T0FJRztJQUNILHdCQUF3QixDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsY0FBYyxFQUFFLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO0lBRTlGOztPQUVHO0lBQ0gsWUFBWSxJQUFJLHdCQUF3QixDQUFDO0lBRXpDOzs7O09BSUc7SUFDSCxzQkFBc0IsQ0FBQyxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO0lBRWxGOzs7O09BSUc7SUFDSCxZQUFZLENBQUMsYUFBYSxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsb0JBQW9CLENBQUMsQ0FBQztJQUV4RTs7OztPQUlHO0lBQ0gsWUFBWSxDQUFDLGFBQWEsRUFBRSxXQUFXLEdBQUcsT0FBTyxDQUFDLHVCQUF1QixDQUFDLENBQUM7SUFFM0U7OztPQUdHO0lBQ0gsZ0JBQWdCLElBQUksT0FBTyxDQUFDLHVCQUF1QixDQUFDLENBQUM7SUFFckQseUJBQXlCO0lBQ3pCLEtBQUssSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7SUFFdkIsc0JBQXNCO0lBQ3RCLEtBQUssSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7Q0FDeEIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_tree_db.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_db.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"merkle_tree_db.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_db.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE1F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,QAA4B,CAAC;AAErE,eAAO,MAAM,6BAA6B,QAAmD,CAAC;AAE9F,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB,EAAE,wBAAwB;IACjG;;;;OAIG;IACH,wBAAwB,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE9F;;OAEG;IACH,YAAY,IAAI,wBAAwB,CAAC;IAEzC;;;;OAIG;IACH,sBAAsB,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAElF;;;;OAIG;IACH,YAAY,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAExE;;;;OAIG;IACH,YAAY,CAAC,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE3E;;;OAGG;IACH,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAErD,yBAAyB;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,sBAAsB;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/world-state",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.993d240",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -64,23 +64,24 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/
|
|
68
|
-
"@aztec/
|
|
69
|
-
"@aztec/
|
|
70
|
-
"@aztec/
|
|
71
|
-
"@aztec/native": "0.0.1-commit.
|
|
72
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
73
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
74
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
67
|
+
"@aztec/bb.js": "0.0.1-commit.993d240",
|
|
68
|
+
"@aztec/constants": "0.0.1-commit.993d240",
|
|
69
|
+
"@aztec/foundation": "0.0.1-commit.993d240",
|
|
70
|
+
"@aztec/kv-store": "0.0.1-commit.993d240",
|
|
71
|
+
"@aztec/native": "0.0.1-commit.993d240",
|
|
72
|
+
"@aztec/protocol-contracts": "0.0.1-commit.993d240",
|
|
73
|
+
"@aztec/stdlib": "0.0.1-commit.993d240",
|
|
74
|
+
"@aztec/telemetry-client": "0.0.1-commit.993d240",
|
|
75
|
+
"msgpackr": "^1.11.2",
|
|
75
76
|
"tslib": "^2.4.0",
|
|
76
|
-
"zod": "^
|
|
77
|
+
"zod": "^4"
|
|
77
78
|
},
|
|
78
79
|
"devDependencies": {
|
|
79
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
80
|
+
"@aztec/archiver": "0.0.1-commit.993d240",
|
|
80
81
|
"@jest/globals": "^30.0.0",
|
|
81
82
|
"@types/jest": "^30.0.0",
|
|
82
83
|
"@types/node": "^22.15.17",
|
|
83
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
84
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
84
85
|
"jest": "^30.0.0",
|
|
85
86
|
"jest-mock-extended": "^4.0.0",
|
|
86
87
|
"ts-node": "^10.9.1",
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type UpDownCounter,
|
|
10
|
+
createUpDownCounterWithDefault,
|
|
10
11
|
} from '@aztec/telemetry-client';
|
|
11
12
|
|
|
12
13
|
import {
|
|
@@ -63,7 +64,14 @@ export class WorldStateInstrumentation {
|
|
|
63
64
|
|
|
64
65
|
this.requestHistogram = meter.createHistogram(Metrics.WORLD_STATE_REQUEST_TIME);
|
|
65
66
|
|
|
66
|
-
this.criticalErrors = meter
|
|
67
|
+
this.criticalErrors = createUpDownCounterWithDefault(meter, Metrics.WORLD_STATE_CRITICAL_ERROR_COUNT, {
|
|
68
|
+
[Attributes.ERROR_TYPE]: [
|
|
69
|
+
'synch_pending_block',
|
|
70
|
+
'finalize_block',
|
|
71
|
+
'prune_pending_block',
|
|
72
|
+
'prune_historical_block',
|
|
73
|
+
],
|
|
74
|
+
});
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
private updateTreeStats(treeDbStats: TreeDBStats, treeMeta: TreeMeta, tree: MerkleTreeId) {
|
|
@@ -3,11 +3,14 @@ import type { MerkleTreeCheckpointOperations } from '@aztec/stdlib/interfaces/se
|
|
|
3
3
|
export class ForkCheckpoint {
|
|
4
4
|
private completed = false;
|
|
5
5
|
|
|
6
|
-
private constructor(
|
|
6
|
+
private constructor(
|
|
7
|
+
private readonly fork: MerkleTreeCheckpointOperations,
|
|
8
|
+
public readonly depth: number,
|
|
9
|
+
) {}
|
|
7
10
|
|
|
8
11
|
static async new(fork: MerkleTreeCheckpointOperations): Promise<ForkCheckpoint> {
|
|
9
|
-
await fork.createCheckpoint();
|
|
10
|
-
return new ForkCheckpoint(fork);
|
|
12
|
+
const depth = await fork.createCheckpoint();
|
|
13
|
+
return new ForkCheckpoint(fork, depth);
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
async commit(): Promise<void> {
|
|
@@ -27,4 +30,17 @@ export class ForkCheckpoint {
|
|
|
27
30
|
await this.fork.revertCheckpoint();
|
|
28
31
|
this.completed = true;
|
|
29
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Reverts this checkpoint and any nested checkpoints created on top of it,
|
|
36
|
+
* leaving the checkpoint depth at the level it was before this checkpoint was created.
|
|
37
|
+
*/
|
|
38
|
+
async revertToCheckpoint(): Promise<void> {
|
|
39
|
+
if (this.completed) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await this.fork.revertAllCheckpointsTo(this.depth - 1);
|
|
44
|
+
this.completed = true;
|
|
45
|
+
}
|
|
30
46
|
}
|