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