@aztec/world-state 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620
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 +4 -3
- package/dest/instrumentation/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation/instrumentation.js +13 -11
- 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 +87 -0
- package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
- package/dest/native/ipc_world_state_instance.js +660 -0
- package/dest/native/merkle_trees_facade.d.ts +12 -8
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +63 -115
- package/dest/native/message.d.ts +14 -221
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +0 -42
- package/dest/native/native_world_state.d.ts +20 -8
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +116 -60
- package/dest/native/native_world_state_instance.d.ts +58 -41
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +5 -202
- package/dest/native/world_state_operation.d.ts +7 -0
- package/dest/native/world_state_operation.d.ts.map +1 -0
- package/dest/native/world_state_operation.js +5 -0
- package/dest/synchronizer/config.d.ts +3 -3
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +15 -13
- 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 -4
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +95 -21
- 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 +1 -10
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/package.json +14 -11
- package/src/instrumentation/instrumentation.ts +15 -19
- package/src/native/fork_checkpoint.ts +19 -3
- package/src/native/ipc_world_state_instance.ts +830 -0
- package/src/native/merkle_trees_facade.ts +89 -109
- package/src/native/message.ts +13 -286
- package/src/native/native_world_state.ts +136 -94
- package/src/native/native_world_state_instance.ts +96 -278
- package/src/native/world_state_operation.ts +33 -0
- package/src/synchronizer/config.ts +21 -15
- package/src/synchronizer/factory.ts +18 -11
- package/src/synchronizer/server_world_state_synchronizer.ts +99 -22
- package/src/testing.ts +8 -9
- package/src/world-state-db/merkle_tree_db.ts +0 -10
- package/dest/native/world_state_ops_queue.d.ts +0 -19
- package/dest/native/world_state_ops_queue.d.ts.map +0 -1
- package/dest/native/world_state_ops_queue.js +0 -146
- package/src/native/world_state_ops_queue.ts +0 -190
package/src/native/message.ts
CHANGED
|
@@ -1,59 +1,7 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
4
3
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
4
|
import type { StateReference } from '@aztec/stdlib/tx';
|
|
6
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
7
|
-
import type { WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
8
|
-
|
|
9
|
-
export enum WorldStateMessageType {
|
|
10
|
-
GET_TREE_INFO = 100,
|
|
11
|
-
GET_STATE_REFERENCE,
|
|
12
|
-
GET_INITIAL_STATE_REFERENCE,
|
|
13
|
-
|
|
14
|
-
GET_LEAF_VALUE,
|
|
15
|
-
GET_LEAF_PREIMAGE,
|
|
16
|
-
GET_SIBLING_PATH,
|
|
17
|
-
GET_BLOCK_NUMBERS_FOR_LEAF_INDICES,
|
|
18
|
-
|
|
19
|
-
FIND_LEAF_INDICES,
|
|
20
|
-
FIND_LOW_LEAF,
|
|
21
|
-
FIND_SIBLING_PATHS,
|
|
22
|
-
|
|
23
|
-
APPEND_LEAVES,
|
|
24
|
-
BATCH_INSERT,
|
|
25
|
-
SEQUENTIAL_INSERT,
|
|
26
|
-
|
|
27
|
-
UPDATE_ARCHIVE,
|
|
28
|
-
|
|
29
|
-
COMMIT,
|
|
30
|
-
ROLLBACK,
|
|
31
|
-
|
|
32
|
-
SYNC_BLOCK,
|
|
33
|
-
|
|
34
|
-
CREATE_FORK,
|
|
35
|
-
DELETE_FORK,
|
|
36
|
-
|
|
37
|
-
FINALIZE_BLOCKS,
|
|
38
|
-
UNWIND_BLOCKS,
|
|
39
|
-
REMOVE_HISTORICAL_BLOCKS,
|
|
40
|
-
|
|
41
|
-
GET_STATUS,
|
|
42
|
-
|
|
43
|
-
CREATE_CHECKPOINT,
|
|
44
|
-
COMMIT_CHECKPOINT,
|
|
45
|
-
REVERT_CHECKPOINT,
|
|
46
|
-
COMMIT_ALL_CHECKPOINTS,
|
|
47
|
-
REVERT_ALL_CHECKPOINTS,
|
|
48
|
-
|
|
49
|
-
COPY_STORES,
|
|
50
|
-
|
|
51
|
-
CLOSE = 999,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface WithTreeId {
|
|
55
|
-
treeId: MerkleTreeId;
|
|
56
|
-
}
|
|
57
5
|
|
|
58
6
|
export interface WorldStateStatusSummary {
|
|
59
7
|
/** Last block number that can still be unwound. */
|
|
@@ -279,22 +227,6 @@ export function sanitizeFullStatus(status: WorldStateStatusFull) {
|
|
|
279
227
|
return status;
|
|
280
228
|
}
|
|
281
229
|
|
|
282
|
-
interface WithForkId {
|
|
283
|
-
forkId: number;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
interface WithWorldStateRevision {
|
|
287
|
-
revision: WorldStateRevision;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
interface WithCanonicalForkId {
|
|
291
|
-
canonical: true;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
interface WithLeafIndex {
|
|
295
|
-
leafIndex: bigint;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
230
|
export type SerializedLeafValue =
|
|
299
231
|
| Buffer // Fr
|
|
300
232
|
| { nullifier: Buffer } // NullifierLeaf
|
|
@@ -306,241 +238,36 @@ export type SerializedIndexedLeaf = {
|
|
|
306
238
|
nextKey: Buffer; // Fr
|
|
307
239
|
};
|
|
308
240
|
|
|
309
|
-
interface
|
|
310
|
-
leaves: SerializedLeafValue[];
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
interface BlockShiftRequest extends WithCanonicalForkId {
|
|
314
|
-
toBlockNumber: BlockNumber;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
interface WithLeaves {
|
|
318
|
-
leaves: SerializedLeafValue[];
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
interface GetTreeInfoRequest extends WithTreeId, WithWorldStateRevision {}
|
|
322
|
-
interface GetTreeInfoResponse {
|
|
323
|
-
treeId: MerkleTreeId;
|
|
324
|
-
depth: UInt32;
|
|
325
|
-
size: bigint | number;
|
|
326
|
-
root: Buffer;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
interface GetBlockNumbersForLeafIndicesRequest extends WithTreeId, WithWorldStateRevision {
|
|
330
|
-
leafIndices: bigint[];
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
interface GetBlockNumbersForLeafIndicesResponse {
|
|
334
|
-
blockNumbers: bigint[];
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
interface GetSiblingPathRequest extends WithTreeId, WithLeafIndex, WithWorldStateRevision {}
|
|
338
|
-
type GetSiblingPathResponse = Buffer[];
|
|
339
|
-
|
|
340
|
-
interface GetStateReferenceRequest extends WithWorldStateRevision {}
|
|
341
|
-
interface GetStateReferenceResponse {
|
|
342
|
-
state: Record<MerkleTreeId, TreeStateReference>;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
interface GetLeafRequest extends WithTreeId, WithWorldStateRevision, WithLeafIndex {}
|
|
346
|
-
type GetLeafResponse = SerializedLeafValue | undefined;
|
|
347
|
-
|
|
348
|
-
interface GetLeafPreImageRequest extends WithTreeId, WithLeafIndex, WithWorldStateRevision {}
|
|
349
|
-
type GetLeafPreImageResponse = SerializedIndexedLeaf | undefined;
|
|
350
|
-
|
|
351
|
-
interface FindLeafIndicesRequest extends WithTreeId, WithLeafValues, WithWorldStateRevision {
|
|
352
|
-
startIndex: bigint;
|
|
353
|
-
}
|
|
354
|
-
interface FindLeafIndicesResponse {
|
|
355
|
-
indices: bigint[];
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
interface FindSiblingPathsRequest extends WithTreeId, WithLeafValues, WithWorldStateRevision {}
|
|
359
|
-
|
|
360
|
-
interface SiblingPathAndIndex {
|
|
241
|
+
export interface SerializedSiblingPathAndIndex {
|
|
361
242
|
index: bigint;
|
|
362
243
|
path: Buffer[];
|
|
363
244
|
}
|
|
364
|
-
interface FindSiblingPathsResponse {
|
|
365
|
-
paths: (SiblingPathAndIndex | undefined)[];
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
interface FindLowLeafRequest extends WithTreeId, WithWorldStateRevision {
|
|
369
|
-
key: Fr;
|
|
370
|
-
}
|
|
371
|
-
interface FindLowLeafResponse {
|
|
372
|
-
index: bigint | number;
|
|
373
|
-
alreadyPresent: boolean;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
interface AppendLeavesRequest extends WithTreeId, WithForkId, WithLeaves {}
|
|
377
245
|
|
|
378
|
-
interface
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
interface BatchInsertResponse {
|
|
383
|
-
low_leaf_witness_data: ReadonlyArray<{
|
|
246
|
+
export interface SerializedBatchInsertionResult {
|
|
247
|
+
lowLeafWitnessData: ReadonlyArray<{
|
|
384
248
|
leaf: SerializedIndexedLeaf;
|
|
385
249
|
index: bigint | number;
|
|
386
|
-
path:
|
|
250
|
+
path: Buffer[];
|
|
387
251
|
}>;
|
|
388
|
-
|
|
389
|
-
|
|
252
|
+
sortedLeaves: ReadonlyArray<readonly [SerializedLeafValue, number]>;
|
|
253
|
+
subtreePath: Buffer[];
|
|
390
254
|
}
|
|
391
255
|
|
|
392
|
-
interface
|
|
393
|
-
|
|
394
|
-
interface SequentialInsertResponse {
|
|
395
|
-
low_leaf_witness_data: ReadonlyArray<{
|
|
256
|
+
export interface SerializedSequentialInsertionResult {
|
|
257
|
+
lowLeafWitnessData: ReadonlyArray<{
|
|
396
258
|
leaf: SerializedIndexedLeaf;
|
|
397
259
|
index: bigint | number;
|
|
398
|
-
path:
|
|
260
|
+
path: Buffer[];
|
|
399
261
|
}>;
|
|
400
|
-
|
|
262
|
+
insertionWitnessData: ReadonlyArray<{
|
|
401
263
|
leaf: SerializedIndexedLeaf;
|
|
402
264
|
index: bigint | number;
|
|
403
|
-
path:
|
|
265
|
+
path: Buffer[];
|
|
404
266
|
}>;
|
|
405
267
|
}
|
|
406
268
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
blockHeaderHash: Buffer;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
interface SyncBlockRequest extends WithCanonicalForkId {
|
|
413
|
-
blockNumber: BlockNumber;
|
|
414
|
-
blockStateRef: BlockStateReference;
|
|
415
|
-
blockHeaderHash: Fr;
|
|
416
|
-
paddedNoteHashes: readonly SerializedLeafValue[];
|
|
417
|
-
paddedL1ToL2Messages: readonly SerializedLeafValue[];
|
|
418
|
-
paddedNullifiers: readonly SerializedLeafValue[];
|
|
419
|
-
publicDataWrites: readonly SerializedLeafValue[];
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
interface CreateForkRequest extends WithCanonicalForkId {
|
|
423
|
-
latest: boolean;
|
|
424
|
-
blockNumber: BlockNumber;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
interface CreateForkResponse {
|
|
428
|
-
forkId: number;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
interface DeleteForkRequest extends WithForkId {}
|
|
432
|
-
|
|
433
|
-
interface CopyStoresRequest extends WithCanonicalForkId {
|
|
434
|
-
dstPath: string;
|
|
435
|
-
compact: boolean;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
export type WorldStateRequestCategories = WithForkId | WithWorldStateRevision | WithCanonicalForkId;
|
|
439
|
-
|
|
440
|
-
export function isWithForkId(body: WorldStateRequestCategories): body is WithForkId {
|
|
441
|
-
return body && 'forkId' in body;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
export function isWithRevision(body: WorldStateRequestCategories): body is WithWorldStateRevision {
|
|
445
|
-
return body && 'revision' in body;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
export function isWithCanonical(body: WorldStateRequestCategories): body is WithCanonicalForkId {
|
|
449
|
-
return body && 'canonical' in body;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export type WorldStateRequest = {
|
|
453
|
-
[WorldStateMessageType.GET_TREE_INFO]: GetTreeInfoRequest;
|
|
454
|
-
[WorldStateMessageType.GET_STATE_REFERENCE]: GetStateReferenceRequest;
|
|
455
|
-
[WorldStateMessageType.GET_INITIAL_STATE_REFERENCE]: WithCanonicalForkId;
|
|
456
|
-
|
|
457
|
-
[WorldStateMessageType.GET_LEAF_VALUE]: GetLeafRequest;
|
|
458
|
-
[WorldStateMessageType.GET_LEAF_PREIMAGE]: GetLeafPreImageRequest;
|
|
459
|
-
[WorldStateMessageType.GET_SIBLING_PATH]: GetSiblingPathRequest;
|
|
460
|
-
[WorldStateMessageType.GET_BLOCK_NUMBERS_FOR_LEAF_INDICES]: GetBlockNumbersForLeafIndicesRequest;
|
|
461
|
-
|
|
462
|
-
[WorldStateMessageType.FIND_LEAF_INDICES]: FindLeafIndicesRequest;
|
|
463
|
-
[WorldStateMessageType.FIND_LOW_LEAF]: FindLowLeafRequest;
|
|
464
|
-
[WorldStateMessageType.FIND_SIBLING_PATHS]: FindSiblingPathsRequest;
|
|
465
|
-
|
|
466
|
-
[WorldStateMessageType.APPEND_LEAVES]: AppendLeavesRequest;
|
|
467
|
-
[WorldStateMessageType.BATCH_INSERT]: BatchInsertRequest;
|
|
468
|
-
[WorldStateMessageType.SEQUENTIAL_INSERT]: SequentialInsertRequest;
|
|
469
|
-
|
|
470
|
-
[WorldStateMessageType.UPDATE_ARCHIVE]: UpdateArchiveRequest;
|
|
471
|
-
|
|
472
|
-
[WorldStateMessageType.COMMIT]: WithCanonicalForkId;
|
|
473
|
-
[WorldStateMessageType.ROLLBACK]: WithCanonicalForkId;
|
|
474
|
-
|
|
475
|
-
[WorldStateMessageType.SYNC_BLOCK]: SyncBlockRequest;
|
|
476
|
-
|
|
477
|
-
[WorldStateMessageType.CREATE_FORK]: CreateForkRequest;
|
|
478
|
-
[WorldStateMessageType.DELETE_FORK]: DeleteForkRequest;
|
|
479
|
-
|
|
480
|
-
[WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS]: BlockShiftRequest;
|
|
481
|
-
[WorldStateMessageType.UNWIND_BLOCKS]: BlockShiftRequest;
|
|
482
|
-
[WorldStateMessageType.FINALIZE_BLOCKS]: BlockShiftRequest;
|
|
483
|
-
|
|
484
|
-
[WorldStateMessageType.GET_STATUS]: WithCanonicalForkId;
|
|
485
|
-
|
|
486
|
-
[WorldStateMessageType.CREATE_CHECKPOINT]: WithForkId;
|
|
487
|
-
[WorldStateMessageType.COMMIT_CHECKPOINT]: WithForkId;
|
|
488
|
-
[WorldStateMessageType.REVERT_CHECKPOINT]: WithForkId;
|
|
489
|
-
[WorldStateMessageType.COMMIT_ALL_CHECKPOINTS]: WithForkId;
|
|
490
|
-
[WorldStateMessageType.REVERT_ALL_CHECKPOINTS]: WithForkId;
|
|
491
|
-
|
|
492
|
-
[WorldStateMessageType.COPY_STORES]: CopyStoresRequest;
|
|
493
|
-
|
|
494
|
-
[WorldStateMessageType.CLOSE]: WithCanonicalForkId;
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
export type WorldStateResponse = {
|
|
498
|
-
[WorldStateMessageType.GET_TREE_INFO]: GetTreeInfoResponse;
|
|
499
|
-
[WorldStateMessageType.GET_STATE_REFERENCE]: GetStateReferenceResponse;
|
|
500
|
-
[WorldStateMessageType.GET_INITIAL_STATE_REFERENCE]: GetStateReferenceResponse;
|
|
501
|
-
|
|
502
|
-
[WorldStateMessageType.GET_LEAF_VALUE]: GetLeafResponse;
|
|
503
|
-
[WorldStateMessageType.GET_LEAF_PREIMAGE]: GetLeafPreImageResponse;
|
|
504
|
-
[WorldStateMessageType.GET_SIBLING_PATH]: GetSiblingPathResponse;
|
|
505
|
-
[WorldStateMessageType.GET_BLOCK_NUMBERS_FOR_LEAF_INDICES]: GetBlockNumbersForLeafIndicesResponse;
|
|
506
|
-
|
|
507
|
-
[WorldStateMessageType.FIND_LEAF_INDICES]: FindLeafIndicesResponse;
|
|
508
|
-
[WorldStateMessageType.FIND_LOW_LEAF]: FindLowLeafResponse;
|
|
509
|
-
[WorldStateMessageType.FIND_SIBLING_PATHS]: FindSiblingPathsResponse;
|
|
510
|
-
|
|
511
|
-
[WorldStateMessageType.APPEND_LEAVES]: void;
|
|
512
|
-
[WorldStateMessageType.BATCH_INSERT]: BatchInsertResponse;
|
|
513
|
-
[WorldStateMessageType.SEQUENTIAL_INSERT]: SequentialInsertResponse;
|
|
514
|
-
|
|
515
|
-
[WorldStateMessageType.UPDATE_ARCHIVE]: void;
|
|
516
|
-
|
|
517
|
-
[WorldStateMessageType.COMMIT]: void;
|
|
518
|
-
[WorldStateMessageType.ROLLBACK]: void;
|
|
519
|
-
|
|
520
|
-
[WorldStateMessageType.SYNC_BLOCK]: WorldStateStatusFull;
|
|
521
|
-
|
|
522
|
-
[WorldStateMessageType.CREATE_FORK]: CreateForkResponse;
|
|
523
|
-
[WorldStateMessageType.DELETE_FORK]: void;
|
|
524
|
-
|
|
525
|
-
[WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS]: WorldStateStatusFull;
|
|
526
|
-
[WorldStateMessageType.UNWIND_BLOCKS]: WorldStateStatusFull;
|
|
527
|
-
[WorldStateMessageType.FINALIZE_BLOCKS]: WorldStateStatusSummary;
|
|
528
|
-
|
|
529
|
-
[WorldStateMessageType.GET_STATUS]: WorldStateStatusSummary;
|
|
530
|
-
|
|
531
|
-
[WorldStateMessageType.CREATE_CHECKPOINT]: void;
|
|
532
|
-
[WorldStateMessageType.COMMIT_CHECKPOINT]: void;
|
|
533
|
-
[WorldStateMessageType.REVERT_CHECKPOINT]: void;
|
|
534
|
-
[WorldStateMessageType.COMMIT_ALL_CHECKPOINTS]: void;
|
|
535
|
-
[WorldStateMessageType.REVERT_ALL_CHECKPOINTS]: void;
|
|
536
|
-
|
|
537
|
-
[WorldStateMessageType.COPY_STORES]: void;
|
|
538
|
-
|
|
539
|
-
[WorldStateMessageType.CLOSE]: void;
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
type TreeStateReference = readonly [Buffer, number | bigint];
|
|
543
|
-
type BlockStateReference = Map<Exclude<MerkleTreeId, MerkleTreeId.ARCHIVE>, TreeStateReference>;
|
|
269
|
+
export type TreeStateReference = readonly [Buffer, number | bigint];
|
|
270
|
+
export type BlockStateReference = Map<Exclude<MerkleTreeId, MerkleTreeId.ARCHIVE>, TreeStateReference>;
|
|
544
271
|
|
|
545
272
|
export function treeStateReferenceToSnapshot([root, size]: TreeStateReference): AppendOnlyTreeSnapshot {
|
|
546
273
|
return new AppendOnlyTreeSnapshot(Fr.fromBuffer(root), Number(size));
|