@aztec/world-state 0.73.0 → 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2
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/index.js +0 -1
- package/dest/instrumentation/instrumentation.js +29 -20
- package/dest/native/index.js +0 -1
- package/dest/native/merkle_trees_facade.js +69 -72
- package/dest/native/message.js +31 -17
- package/dest/native/native_world_state.js +78 -53
- package/dest/native/native_world_state_instance.js +37 -38
- package/dest/native/world_state_ops_queue.js +18 -29
- package/dest/native/world_state_version.js +7 -8
- package/dest/synchronizer/config.js +12 -14
- package/dest/synchronizer/factory.js +5 -5
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +66 -61
- package/dest/test/index.js +1 -0
- package/dest/test/utils.js +14 -12
- package/dest/world-state-db/index.js +0 -4
- package/dest/world-state-db/merkle_tree_db.js +1 -3
- package/package.json +11 -10
- package/src/test/index.ts +1 -0
- package/src/world-state-db/index.ts +1 -4
- package/dest/index.d.ts +0 -5
- package/dest/index.d.ts.map +0 -1
- package/dest/instrumentation/instrumentation.d.ts +0 -20
- package/dest/instrumentation/instrumentation.d.ts.map +0 -1
- package/dest/native/index.d.ts +0 -2
- package/dest/native/index.d.ts.map +0 -1
- package/dest/native/merkle_trees_facade.d.ts +0 -37
- package/dest/native/merkle_trees_facade.d.ts.map +0 -1
- package/dest/native/message.d.ts +0 -320
- package/dest/native/message.d.ts.map +0 -1
- package/dest/native/native_world_state.d.ts +0 -54
- package/dest/native/native_world_state.d.ts.map +0 -1
- package/dest/native/native_world_state_instance.d.ts +0 -32
- package/dest/native/native_world_state_instance.d.ts.map +0 -1
- 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_version.d.ts +0 -24
- package/dest/native/world_state_version.d.ts.map +0 -1
- package/dest/synchronizer/config.d.ts +0 -23
- package/dest/synchronizer/config.d.ts.map +0 -1
- package/dest/synchronizer/factory.d.ts +0 -10
- package/dest/synchronizer/factory.d.ts.map +0 -1
- package/dest/synchronizer/index.d.ts +0 -3
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +0 -76
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +0 -1
- package/dest/test/utils.d.ts +0 -14
- package/dest/test/utils.d.ts.map +0 -1
- package/dest/world-state-db/index.d.ts +0 -6
- package/dest/world-state-db/index.d.ts.map +0 -1
- package/dest/world-state-db/merkle_tree_db.d.ts +0 -67
- package/dest/world-state-db/merkle_tree_db.d.ts.map +0 -1
- package/dest/world-state-db/merkle_tree_map.d.ts +0 -11
- package/dest/world-state-db/merkle_tree_map.d.ts.map +0 -1
- package/dest/world-state-db/merkle_tree_map.js +0 -2
- package/dest/world-state-db/merkle_tree_operations_facade.d.ts +0 -116
- package/dest/world-state-db/merkle_tree_operations_facade.d.ts.map +0 -1
- package/dest/world-state-db/merkle_tree_operations_facade.js +0 -133
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.d.ts +0 -32
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.d.ts.map +0 -1
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.js +0 -76
- package/dest/world-state-db/merkle_trees.d.ts +0 -174
- package/dest/world-state-db/merkle_trees.d.ts.map +0 -1
- package/dest/world-state-db/merkle_trees.js +0 -461
- package/dest/world-state-db/metrics.d.ts +0 -14
- package/dest/world-state-db/metrics.d.ts.map +0 -1
- package/dest/world-state-db/metrics.js +0 -44
- package/src/world-state-db/merkle_tree_map.ts +0 -11
- package/src/world-state-db/merkle_tree_operations_facade.ts +0 -199
- package/src/world-state-db/merkle_tree_snapshot_operations_facade.ts +0 -151
- package/src/world-state-db/merkle_trees.ts +0 -727
- package/src/world-state-db/metrics.ts +0 -64
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './merkle_trees.js';
|
|
2
|
-
export * from './merkle_tree_db.js';
|
|
3
|
-
export * from './merkle_tree_operations_facade.js';
|
|
4
|
-
export * from './merkle_tree_snapshot_operations_facade.js';
|
|
5
|
-
export { MerkleTreeReadOperations } from '@aztec/circuit-types/interfaces';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/world-state-db/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,6CAA6C,CAAC;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { type L2Block, type MerkleTreeId } from '@aztec/circuit-types';
|
|
2
|
-
import { type ForkMerkleTreeOperations, type MerkleTreeReadOperations } from '@aztec/circuit-types/interfaces';
|
|
3
|
-
import { type Fr } from '@aztec/circuits.js';
|
|
4
|
-
import { type IndexedTreeSnapshot, type TreeSnapshot } from '@aztec/merkle-tree';
|
|
5
|
-
import { type WorldStateStatusFull, type WorldStateStatusSummary } from '../native/message.js';
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @remarks Short explanation:
|
|
9
|
-
* The nullifier tree must be initially padded as the pre-populated 0 index prevents efficient subtree insertion.
|
|
10
|
-
* Padding with some values solves this issue.
|
|
11
|
-
*
|
|
12
|
-
* @remarks Thorough explanation:
|
|
13
|
-
* There needs to be an initial (0,0,0) leaf in the tree, so that when we insert the first 'proper' leaf, we can
|
|
14
|
-
* prove that any value greater than 0 doesn't exist in the tree yet. We prefill/pad the tree with "the number of
|
|
15
|
-
* leaves that are added by one block" so that the first 'proper' block can insert a full subtree.
|
|
16
|
-
*
|
|
17
|
-
* Without this padding, there would be a leaf (0,0,0) at leaf index 0, making it really difficult to insert e.g.
|
|
18
|
-
* 1024 leaves for the first block, because there's only neat space for 1023 leaves after 0. By padding with 1023
|
|
19
|
-
* more leaves, we can then insert the first block of 1024 leaves into indices 1024:2047.
|
|
20
|
-
*/
|
|
21
|
-
export declare const INITIAL_NULLIFIER_TREE_SIZE: number;
|
|
22
|
-
export declare const INITIAL_PUBLIC_DATA_TREE_SIZE: number;
|
|
23
|
-
export type TreeSnapshots = {
|
|
24
|
-
[MerkleTreeId.NULLIFIER_TREE]: IndexedTreeSnapshot;
|
|
25
|
-
[MerkleTreeId.NOTE_HASH_TREE]: TreeSnapshot<Fr>;
|
|
26
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: IndexedTreeSnapshot;
|
|
27
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: TreeSnapshot<Fr>;
|
|
28
|
-
[MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
|
|
29
|
-
};
|
|
30
|
-
export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
|
|
31
|
-
/**
|
|
32
|
-
* Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
|
|
33
|
-
* @param block - The L2 block to handle.
|
|
34
|
-
* @param l1ToL2Messages - The L1 to L2 messages for the block.
|
|
35
|
-
*/
|
|
36
|
-
handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
|
|
37
|
-
/**
|
|
38
|
-
* Gets a handle that allows reading the latest committed state
|
|
39
|
-
*/
|
|
40
|
-
getCommitted(): MerkleTreeReadOperations;
|
|
41
|
-
/**
|
|
42
|
-
* Removes all historical snapshots up to but not including the given block number
|
|
43
|
-
* @param toBlockNumber The block number of the new oldest historical block
|
|
44
|
-
* @returns The new WorldStateStatus
|
|
45
|
-
*/
|
|
46
|
-
removeHistoricalBlocks(toBlockNumber: bigint): Promise<WorldStateStatusFull>;
|
|
47
|
-
/**
|
|
48
|
-
* Removes all pending blocks down to but not including the given block number
|
|
49
|
-
* @param toBlockNumber The block number of the new tip of the pending chain,
|
|
50
|
-
* @returns The new WorldStateStatus
|
|
51
|
-
*/
|
|
52
|
-
unwindBlocks(toBlockNumber: bigint): Promise<WorldStateStatusFull>;
|
|
53
|
-
/**
|
|
54
|
-
* Advances the finalised block number to be the number provided
|
|
55
|
-
* @param toBlockNumber The block number that is now the tip of the finalised chain
|
|
56
|
-
* @returns The new WorldStateStatus
|
|
57
|
-
*/
|
|
58
|
-
setFinalised(toBlockNumber: bigint): Promise<WorldStateStatusSummary>;
|
|
59
|
-
/**
|
|
60
|
-
* Gets the current status summary of the database.
|
|
61
|
-
* @returns The current WorldStateStatus.
|
|
62
|
-
*/
|
|
63
|
-
getStatusSummary(): Promise<WorldStateStatusSummary>;
|
|
64
|
-
/** Stops the database */
|
|
65
|
-
close(): Promise<void>;
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=merkle_tree_db.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_tree_db.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC/G,OAAO,EAAE,KAAK,EAAE,EAAuE,MAAM,oBAAoB,CAAC;AAClH,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,QAA4B,CAAC;AAErE,eAAO,MAAM,6BAA6B,QAAmD,CAAC;AAE9F,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACnD,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IACrD,CAAC,YAAY,CAAC,qBAAqB,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE;;;;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,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE7E;;;;OAIG;IACH,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEnE;;;;OAIG;IACH,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAEtE;;;OAGG;IACH,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAErD,yBAAyB;IACzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type MerkleTreeId } from '@aztec/circuit-types';
|
|
2
|
-
import { type Fr } from '@aztec/circuits.js';
|
|
3
|
-
import { type AppendOnlyTree, type IndexedTree } from '@aztec/merkle-tree';
|
|
4
|
-
export type MerkleTreeMap = {
|
|
5
|
-
[MerkleTreeId.NULLIFIER_TREE]: IndexedTree;
|
|
6
|
-
[MerkleTreeId.NOTE_HASH_TREE]: AppendOnlyTree<Fr>;
|
|
7
|
-
[MerkleTreeId.PUBLIC_DATA_TREE]: IndexedTree;
|
|
8
|
-
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: AppendOnlyTree<Fr>;
|
|
9
|
-
[MerkleTreeId.ARCHIVE]: AppendOnlyTree<Fr>;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=merkle_tree_map.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_tree_map.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,WAAW,CAAC;IAC3C,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAC7C,CAAC,YAAY,CAAC,qBAAqB,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;CAC5C,CAAC"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import { type BatchInsertionResult, type MerkleTreeId, type SiblingPath } from '@aztec/circuit-types';
|
|
4
|
-
import { type IndexedTreeId, type MerkleTreeLeafType, type MerkleTreeWriteOperations, type SequentialInsertionResult, type TreeInfo } from '@aztec/circuit-types/interfaces';
|
|
5
|
-
import { type BlockHeader, type StateReference } from '@aztec/circuits.js';
|
|
6
|
-
import { type IndexedTreeLeafPreimage } from '@aztec/foundation/trees';
|
|
7
|
-
import { type MerkleTrees } from './merkle_trees.js';
|
|
8
|
-
/**
|
|
9
|
-
* Wraps a MerkleTreeDbOperations to call all functions with a preset includeUncommitted flag.
|
|
10
|
-
*/
|
|
11
|
-
export declare class MerkleTreeReadOperationsFacade implements MerkleTreeWriteOperations {
|
|
12
|
-
protected trees: MerkleTrees;
|
|
13
|
-
protected includeUncommitted: boolean;
|
|
14
|
-
constructor(trees: MerkleTrees, includeUncommitted: boolean);
|
|
15
|
-
/**
|
|
16
|
-
* Returns the tree info for the specified tree id.
|
|
17
|
-
* @param treeId - Id of the tree to get information from.
|
|
18
|
-
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
19
|
-
* @returns The tree info for the specified tree.
|
|
20
|
-
*/
|
|
21
|
-
getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo>;
|
|
22
|
-
/**
|
|
23
|
-
* Get the current state reference.
|
|
24
|
-
* @returns The current state reference.
|
|
25
|
-
*/
|
|
26
|
-
getStateReference(): Promise<StateReference>;
|
|
27
|
-
/**
|
|
28
|
-
* Returns the initial header for the chain before the first block.
|
|
29
|
-
* @returns The initial header.
|
|
30
|
-
*/
|
|
31
|
-
getInitialHeader(): BlockHeader;
|
|
32
|
-
/**
|
|
33
|
-
* Appends a set of leaf values to the tree.
|
|
34
|
-
* @param treeId - Id of the tree to append leaves to.
|
|
35
|
-
* @param leaves - The set of leaves to be appended.
|
|
36
|
-
* @returns The tree info of the specified tree.
|
|
37
|
-
*/
|
|
38
|
-
appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Returns the sibling path for a requested leaf index.
|
|
41
|
-
* @param treeId - Id of the tree to get the sibling path from.
|
|
42
|
-
* @param index - The index of the leaf for which a sibling path is required.
|
|
43
|
-
* @returns A promise with the sibling path of the specified leaf index.
|
|
44
|
-
*/
|
|
45
|
-
getSiblingPath<N extends number>(treeId: MerkleTreeId, index: bigint): Promise<SiblingPath<N>>;
|
|
46
|
-
/**
|
|
47
|
-
* Finds the index of the largest leaf whose value is less than or equal to the provided value.
|
|
48
|
-
* @param treeId - The ID of the tree to search.
|
|
49
|
-
* @param value - The value to be inserted into the tree.
|
|
50
|
-
* @param includeUncommitted - If true, the uncommitted changes are included in the search.
|
|
51
|
-
* @returns The found leaf index and a flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
52
|
-
*/
|
|
53
|
-
getPreviousValueIndex<ID extends IndexedTreeId>(treeId: ID, value: bigint): Promise<{
|
|
54
|
-
/**
|
|
55
|
-
* The index of the found leaf.
|
|
56
|
-
*/
|
|
57
|
-
index: bigint;
|
|
58
|
-
/**
|
|
59
|
-
* A flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
60
|
-
*/
|
|
61
|
-
alreadyPresent: boolean;
|
|
62
|
-
} | undefined>;
|
|
63
|
-
/**
|
|
64
|
-
* Gets the leaf data at a given index and tree.
|
|
65
|
-
* @param treeId - The ID of the tree get the leaf from.
|
|
66
|
-
* @param index - The index of the leaf to get.
|
|
67
|
-
* @returns Leaf preimage.
|
|
68
|
-
*/
|
|
69
|
-
getLeafPreimage<ID extends IndexedTreeId>(treeId: ID, index: bigint): Promise<IndexedTreeLeafPreimage | undefined>;
|
|
70
|
-
/**
|
|
71
|
-
* Returns the index of a leaf given its value, or undefined if no leaf with that value is found.
|
|
72
|
-
* @param treeId - The ID of the tree.
|
|
73
|
-
* @param value - The leaf value to look for.
|
|
74
|
-
* @returns The index of the first leaf found with a given value (undefined if not found).
|
|
75
|
-
*/
|
|
76
|
-
findLeafIndices<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<(bigint | undefined)[]>;
|
|
77
|
-
/**
|
|
78
|
-
* Returns the first index containing a leaf value after `startIndex`.
|
|
79
|
-
* @param treeId - The tree for which the index should be returned.
|
|
80
|
-
* @param value - The value to search for in the tree.
|
|
81
|
-
* @param startIndex - The index to start searching from (used when skipping nullified messages)
|
|
82
|
-
*/
|
|
83
|
-
findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Gets the value at the given index.
|
|
86
|
-
* @param treeId - The ID of the tree to get the leaf value from.
|
|
87
|
-
* @param index - The index of the leaf.
|
|
88
|
-
* @param includeUncommitted - Indicates whether to include uncommitted changes.
|
|
89
|
-
* @returns Leaf value at the given index (undefined if not found).
|
|
90
|
-
*/
|
|
91
|
-
getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
|
|
92
|
-
/**
|
|
93
|
-
* Inserts the new block hash into the archive.
|
|
94
|
-
* This includes all of the current roots of all of the data trees and the current blocks global vars.
|
|
95
|
-
* @param header - The header to insert into the archive.
|
|
96
|
-
*/
|
|
97
|
-
updateArchive(header: BlockHeader): Promise<void>;
|
|
98
|
-
/**
|
|
99
|
-
* Batch insert multiple leaves into the tree.
|
|
100
|
-
* @param treeId - The ID of the tree.
|
|
101
|
-
* @param leaves - Leaves to insert into the tree.
|
|
102
|
-
* @param subtreeHeight - Height of the subtree.
|
|
103
|
-
* @returns The data for the leaves to be updated when inserting the new ones.
|
|
104
|
-
*/
|
|
105
|
-
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number>(treeId: IndexedTreeId, leaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
|
|
106
|
-
/**
|
|
107
|
-
* Sequentially inserts multiple leaves into the tree.
|
|
108
|
-
* @param treeId - The ID of the tree.
|
|
109
|
-
* @param leaves - Leaves to insert into the tree.
|
|
110
|
-
* @returns Witnesses for the operations performed.
|
|
111
|
-
*/
|
|
112
|
-
sequentialInsert<TreeHeight extends number>(_treeId: IndexedTreeId, _leaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
|
|
113
|
-
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(_treeId: ID, _leafIndices: bigint[]): Promise<(bigint | undefined)[]>;
|
|
114
|
-
close(): Promise<void>;
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=merkle_tree_operations_facade.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_tree_operations_facade.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_operations_facade.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,qBAAa,8BAA+B,YAAW,yBAAyB;IAClE,SAAS,CAAC,KAAK,EAAE,WAAW;IAAE,SAAS,CAAC,kBAAkB,EAAE,OAAO;gBAAzD,KAAK,EAAE,WAAW,EAAY,kBAAkB,EAAE,OAAO;IAE/E;;;;;OAKG;IACH,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIpD;;;OAGG;IACH,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IAI5C;;;OAGG;IACH,gBAAgB,IAAI,WAAW;IAI/B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,kB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IAIxD;;;;;;OAMG;IACI,WAAW,CAAC,UAAU,SAAS,MAAM,EAAE,wBAAwB,SAAS,MAAM,EACnF,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC;IAItE;;;;;OAKG;IACI,gBAAgB,CAAC,UAAU,SAAS,MAAM,EAC/C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC;IAIjD,6BAA6B,CAAC,EAAE,SAAS,YAAY,EACnD,OAAO,EAAE,EAAE,EACX,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGvB"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wraps a MerkleTreeDbOperations to call all functions with a preset includeUncommitted flag.
|
|
3
|
-
*/
|
|
4
|
-
export class MerkleTreeReadOperationsFacade {
|
|
5
|
-
constructor(trees, includeUncommitted) {
|
|
6
|
-
this.trees = trees;
|
|
7
|
-
this.includeUncommitted = includeUncommitted;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Returns the tree info for the specified tree id.
|
|
11
|
-
* @param treeId - Id of the tree to get information from.
|
|
12
|
-
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
13
|
-
* @returns The tree info for the specified tree.
|
|
14
|
-
*/
|
|
15
|
-
getTreeInfo(treeId) {
|
|
16
|
-
return this.trees.getTreeInfo(treeId, this.includeUncommitted);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get the current state reference.
|
|
20
|
-
* @returns The current state reference.
|
|
21
|
-
*/
|
|
22
|
-
getStateReference() {
|
|
23
|
-
return this.trees.getStateReference(this.includeUncommitted);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Returns the initial header for the chain before the first block.
|
|
27
|
-
* @returns The initial header.
|
|
28
|
-
*/
|
|
29
|
-
getInitialHeader() {
|
|
30
|
-
return this.trees.getInitialHeader();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Appends a set of leaf values to the tree.
|
|
34
|
-
* @param treeId - Id of the tree to append leaves to.
|
|
35
|
-
* @param leaves - The set of leaves to be appended.
|
|
36
|
-
* @returns The tree info of the specified tree.
|
|
37
|
-
*/
|
|
38
|
-
appendLeaves(treeId, leaves) {
|
|
39
|
-
return this.trees.appendLeaves(treeId, leaves);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Returns the sibling path for a requested leaf index.
|
|
43
|
-
* @param treeId - Id of the tree to get the sibling path from.
|
|
44
|
-
* @param index - The index of the leaf for which a sibling path is required.
|
|
45
|
-
* @returns A promise with the sibling path of the specified leaf index.
|
|
46
|
-
*/
|
|
47
|
-
async getSiblingPath(treeId, index) {
|
|
48
|
-
const path = await this.trees.getSiblingPath(treeId, index, this.includeUncommitted);
|
|
49
|
-
return path;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Finds the index of the largest leaf whose value is less than or equal to the provided value.
|
|
53
|
-
* @param treeId - The ID of the tree to search.
|
|
54
|
-
* @param value - The value to be inserted into the tree.
|
|
55
|
-
* @param includeUncommitted - If true, the uncommitted changes are included in the search.
|
|
56
|
-
* @returns The found leaf index and a flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
57
|
-
*/
|
|
58
|
-
getPreviousValueIndex(treeId, value) {
|
|
59
|
-
return this.trees.getPreviousValueIndex(treeId, value, this.includeUncommitted);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Gets the leaf data at a given index and tree.
|
|
63
|
-
* @param treeId - The ID of the tree get the leaf from.
|
|
64
|
-
* @param index - The index of the leaf to get.
|
|
65
|
-
* @returns Leaf preimage.
|
|
66
|
-
*/
|
|
67
|
-
async getLeafPreimage(treeId, index) {
|
|
68
|
-
const preimage = await this.trees.getLeafPreimage(treeId, index, this.includeUncommitted);
|
|
69
|
-
return preimage;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Returns the index of a leaf given its value, or undefined if no leaf with that value is found.
|
|
73
|
-
* @param treeId - The ID of the tree.
|
|
74
|
-
* @param value - The leaf value to look for.
|
|
75
|
-
* @returns The index of the first leaf found with a given value (undefined if not found).
|
|
76
|
-
*/
|
|
77
|
-
findLeafIndices(treeId, values) {
|
|
78
|
-
return Promise.all(values.map(leaf => this.trees.findLeafIndex(treeId, leaf, this.includeUncommitted)));
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns the first index containing a leaf value after `startIndex`.
|
|
82
|
-
* @param treeId - The tree for which the index should be returned.
|
|
83
|
-
* @param value - The value to search for in the tree.
|
|
84
|
-
* @param startIndex - The index to start searching from (used when skipping nullified messages)
|
|
85
|
-
*/
|
|
86
|
-
findLeafIndicesAfter(treeId, values, startIndex) {
|
|
87
|
-
return Promise.all(values.map(leaf => this.trees.findLeafIndexAfter(treeId, leaf, startIndex, this.includeUncommitted)));
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Gets the value at the given index.
|
|
91
|
-
* @param treeId - The ID of the tree to get the leaf value from.
|
|
92
|
-
* @param index - The index of the leaf.
|
|
93
|
-
* @param includeUncommitted - Indicates whether to include uncommitted changes.
|
|
94
|
-
* @returns Leaf value at the given index (undefined if not found).
|
|
95
|
-
*/
|
|
96
|
-
getLeafValue(treeId, index) {
|
|
97
|
-
return this.trees.getLeafValue(treeId, index, this.includeUncommitted);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Inserts the new block hash into the archive.
|
|
101
|
-
* This includes all of the current roots of all of the data trees and the current blocks global vars.
|
|
102
|
-
* @param header - The header to insert into the archive.
|
|
103
|
-
*/
|
|
104
|
-
updateArchive(header) {
|
|
105
|
-
return this.trees.updateArchive(header);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Batch insert multiple leaves into the tree.
|
|
109
|
-
* @param treeId - The ID of the tree.
|
|
110
|
-
* @param leaves - Leaves to insert into the tree.
|
|
111
|
-
* @param subtreeHeight - Height of the subtree.
|
|
112
|
-
* @returns The data for the leaves to be updated when inserting the new ones.
|
|
113
|
-
*/
|
|
114
|
-
batchInsert(treeId, leaves, subtreeHeight) {
|
|
115
|
-
return this.trees.batchInsert(treeId, leaves, subtreeHeight);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Sequentially inserts multiple leaves into the tree.
|
|
119
|
-
* @param treeId - The ID of the tree.
|
|
120
|
-
* @param leaves - Leaves to insert into the tree.
|
|
121
|
-
* @returns Witnesses for the operations performed.
|
|
122
|
-
*/
|
|
123
|
-
sequentialInsert(_treeId, _leaves) {
|
|
124
|
-
throw new Error('Method not implemented in legacy merkle tree');
|
|
125
|
-
}
|
|
126
|
-
getBlockNumbersForLeafIndices(_treeId, _leafIndices) {
|
|
127
|
-
throw new Error('Method not implemented in legacy merkle tree');
|
|
128
|
-
}
|
|
129
|
-
close() {
|
|
130
|
-
return Promise.resolve();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVya2xlX3RyZWVfb3BlcmF0aW9uc19mYWNhZGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd29ybGQtc3RhdGUtZGIvbWVya2xlX3RyZWVfb3BlcmF0aW9uc19mYWNhZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBYUE7O0dBRUc7QUFDSCxNQUFNLE9BQU8sOEJBQThCO0lBQ3pDLFlBQXNCLEtBQWtCLEVBQVksa0JBQTJCO1FBQXpELFVBQUssR0FBTCxLQUFLLENBQWE7UUFBWSx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ENBRXBFLENBQUM7SUFDSixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNJLGFBQWEsQ0FBQyxNQUFtQjtRQUN0QyxPQUFPLElBQUksQ0FBQyxLQUFLLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQzFDLENBQUM7SUFFRDs7Ozs7O09BTUc7SUFDSSxXQUFXLENBQ2hCLE1BQXFCLEVBQ3JCLE1BQWdCLEVBQ2hCLGFBQXFCO1FBRXJCLE9BQU8sSUFBSSxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxhQUFhLENBQUMsQ0FBQztJQUMvRCxDQUFDO0lBRUQ7Ozs7O09BS0c7SUFDSSxnQkFBZ0IsQ0FDckIsT0FBc0IsRUFDdEIsT0FBaUI7UUFFakIsTUFBTSxJQUFJLEtBQUssQ0FBQyw4Q0FBOEMsQ0FBQyxDQUFDO0lBQ2xFLENBQUM7SUFFRCw2QkFBNkIsQ0FDM0IsT0FBVyxFQUNYLFlBQXNCO1FBRXRCLE1BQU0sSUFBSSxLQUFLLENBQUMsOENBQThDLENBQUMsQ0FBQztJQUNsRSxDQUFDO0lBRUQsS0FBSztRQUNILE9BQU8sT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQzNCLENBQUM7Q0FDRiJ9
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { MerkleTreeId, type SiblingPath } from '@aztec/circuit-types';
|
|
2
|
-
import { type IndexedTreeId, type MerkleTreeLeafType, type MerkleTreeReadOperations, type TreeInfo } from '@aztec/circuit-types/interfaces';
|
|
3
|
-
import { type BlockHeader, StateReference } from '@aztec/circuits.js';
|
|
4
|
-
import { type IndexedTreeLeafPreimage } from '@aztec/foundation/trees';
|
|
5
|
-
import { type MerkleTrees } from './merkle_trees.js';
|
|
6
|
-
/**
|
|
7
|
-
* Merkle tree operations on readonly tree snapshots.
|
|
8
|
-
*/
|
|
9
|
-
export declare class MerkleTreeSnapshotOperationsFacade implements MerkleTreeReadOperations {
|
|
10
|
-
#private;
|
|
11
|
-
constructor(trees: MerkleTrees, blockNumber: number);
|
|
12
|
-
findLeafIndices<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<(bigint | undefined)[]>;
|
|
13
|
-
findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: MerkleTreeId, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
|
|
14
|
-
getLeafPreimage<ID extends IndexedTreeId>(treeId: ID, index: bigint): Promise<IndexedTreeLeafPreimage | undefined>;
|
|
15
|
-
getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
|
|
16
|
-
getPreviousValueIndex(treeId: IndexedTreeId, value: bigint): Promise<{
|
|
17
|
-
/**
|
|
18
|
-
* The index of the found leaf.
|
|
19
|
-
*/
|
|
20
|
-
index: bigint;
|
|
21
|
-
/**
|
|
22
|
-
* A flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
23
|
-
*/
|
|
24
|
-
alreadyPresent: boolean;
|
|
25
|
-
} | undefined>;
|
|
26
|
-
getSiblingPath<N extends number>(treeId: MerkleTreeId, index: bigint): Promise<SiblingPath<N>>;
|
|
27
|
-
getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo>;
|
|
28
|
-
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(_a: ID, _b: bigint[]): Promise<(bigint | undefined)[]>;
|
|
29
|
-
getStateReference(): Promise<StateReference>;
|
|
30
|
-
getInitialHeader(): BlockHeader;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=merkle_tree_snapshot_operations_facade.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_tree_snapshot_operations_facade.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_snapshot_operations_facade.ts"],"names":[],"mappings":"A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,MAAM,CAAC;QACd;;WAEG;QACH,cAAc,EAAE,OAAO,CAAC;KACzB,GACD,SAAS,CACZ;IAKK,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAK9F,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU1D,6BAA6B,CAAC,EAAE,SAAS,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAIvG,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IA+BlD,gBAAgB,IAAI,WAAW;CAGhC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var _MerkleTreeSnapshotOperationsFacade_instances, _MerkleTreeSnapshotOperationsFacade_treesDb, _MerkleTreeSnapshotOperationsFacade_blockNumber, _MerkleTreeSnapshotOperationsFacade_treeSnapshots, _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot;
|
|
2
|
-
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import { MerkleTreeId } from '@aztec/circuit-types';
|
|
4
|
-
import { AppendOnlyTreeSnapshot, Fr, PartialStateReference, StateReference, } from '@aztec/circuits.js';
|
|
5
|
-
/**
|
|
6
|
-
* Merkle tree operations on readonly tree snapshots.
|
|
7
|
-
*/
|
|
8
|
-
export class MerkleTreeSnapshotOperationsFacade {
|
|
9
|
-
constructor(trees, blockNumber) {
|
|
10
|
-
_MerkleTreeSnapshotOperationsFacade_instances.add(this);
|
|
11
|
-
_MerkleTreeSnapshotOperationsFacade_treesDb.set(this, void 0);
|
|
12
|
-
_MerkleTreeSnapshotOperationsFacade_blockNumber.set(this, void 0);
|
|
13
|
-
_MerkleTreeSnapshotOperationsFacade_treeSnapshots.set(this, {});
|
|
14
|
-
__classPrivateFieldSet(this, _MerkleTreeSnapshotOperationsFacade_treesDb, trees, "f");
|
|
15
|
-
__classPrivateFieldSet(this, _MerkleTreeSnapshotOperationsFacade_blockNumber, blockNumber, "f");
|
|
16
|
-
}
|
|
17
|
-
async findLeafIndices(treeId, values) {
|
|
18
|
-
const tree = await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId);
|
|
19
|
-
// TODO #5448 fix "as any"
|
|
20
|
-
return values.map(leaf => tree.findLeafIndex(leaf));
|
|
21
|
-
}
|
|
22
|
-
async findLeafIndicesAfter(treeId, values, startIndex) {
|
|
23
|
-
const tree = await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId);
|
|
24
|
-
// TODO #5448 fix "as any"
|
|
25
|
-
return values.map(leaf => tree.findLeafIndexAfter(leaf, startIndex));
|
|
26
|
-
}
|
|
27
|
-
async getLeafPreimage(treeId, index) {
|
|
28
|
-
const snapshot = (await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId));
|
|
29
|
-
return snapshot.getLatestLeafPreimageCopy(BigInt(index));
|
|
30
|
-
}
|
|
31
|
-
async getLeafValue(treeId, index) {
|
|
32
|
-
const snapshot = await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId);
|
|
33
|
-
return snapshot.getLeafValue(BigInt(index));
|
|
34
|
-
}
|
|
35
|
-
async getPreviousValueIndex(treeId, value) {
|
|
36
|
-
const snapshot = (await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId));
|
|
37
|
-
return snapshot.findIndexOfPreviousKey(value);
|
|
38
|
-
}
|
|
39
|
-
async getSiblingPath(treeId, index) {
|
|
40
|
-
const snapshot = await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId);
|
|
41
|
-
return snapshot.getSiblingPath(index);
|
|
42
|
-
}
|
|
43
|
-
async getTreeInfo(treeId) {
|
|
44
|
-
const snapshot = await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, treeId);
|
|
45
|
-
return {
|
|
46
|
-
depth: snapshot.getDepth(),
|
|
47
|
-
root: snapshot.getRoot(),
|
|
48
|
-
size: snapshot.getNumLeaves(),
|
|
49
|
-
treeId,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
getBlockNumbersForLeafIndices(_a, _b) {
|
|
53
|
-
throw new Error('Not implemented');
|
|
54
|
-
}
|
|
55
|
-
async getStateReference() {
|
|
56
|
-
const snapshots = await Promise.all([
|
|
57
|
-
__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, MerkleTreeId.NULLIFIER_TREE),
|
|
58
|
-
__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, MerkleTreeId.NOTE_HASH_TREE),
|
|
59
|
-
__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, MerkleTreeId.PUBLIC_DATA_TREE),
|
|
60
|
-
__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, MerkleTreeId.L1_TO_L2_MESSAGE_TREE),
|
|
61
|
-
__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_instances, "m", _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot).call(this, MerkleTreeId.ARCHIVE),
|
|
62
|
-
]);
|
|
63
|
-
return new StateReference(new AppendOnlyTreeSnapshot(Fr.fromBuffer(snapshots[MerkleTreeId.L1_TO_L2_MESSAGE_TREE].getRoot()), Number(snapshots[MerkleTreeId.L1_TO_L2_MESSAGE_TREE].getNumLeaves())), new PartialStateReference(new AppendOnlyTreeSnapshot(Fr.fromBuffer(snapshots[MerkleTreeId.NOTE_HASH_TREE].getRoot()), Number(snapshots[MerkleTreeId.NOTE_HASH_TREE].getNumLeaves())), new AppendOnlyTreeSnapshot(Fr.fromBuffer(snapshots[MerkleTreeId.NULLIFIER_TREE].getRoot()), Number(snapshots[MerkleTreeId.NULLIFIER_TREE].getNumLeaves())), new AppendOnlyTreeSnapshot(Fr.fromBuffer(snapshots[MerkleTreeId.PUBLIC_DATA_TREE].getRoot()), Number(snapshots[MerkleTreeId.PUBLIC_DATA_TREE].getNumLeaves()))));
|
|
64
|
-
}
|
|
65
|
-
getInitialHeader() {
|
|
66
|
-
throw new Error('Getting initial header not supported on snapshot.');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
_MerkleTreeSnapshotOperationsFacade_treesDb = new WeakMap(), _MerkleTreeSnapshotOperationsFacade_blockNumber = new WeakMap(), _MerkleTreeSnapshotOperationsFacade_treeSnapshots = new WeakMap(), _MerkleTreeSnapshotOperationsFacade_instances = new WeakSet(), _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot = async function _MerkleTreeSnapshotOperationsFacade_getTreeSnapshot(treeId) {
|
|
70
|
-
if (__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_treeSnapshots, "f")[treeId]) {
|
|
71
|
-
return __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_treeSnapshots, "f")[treeId];
|
|
72
|
-
}
|
|
73
|
-
__classPrivateFieldSet(this, _MerkleTreeSnapshotOperationsFacade_treeSnapshots, await __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_treesDb, "f").getTreeSnapshots(__classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_blockNumber, "f")), "f");
|
|
74
|
-
return __classPrivateFieldGet(this, _MerkleTreeSnapshotOperationsFacade_treeSnapshots, "f")[treeId];
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVya2xlX3RyZWVfc25hcHNob3Rfb3BlcmF0aW9uc19mYWNhZGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd29ybGQtc3RhdGUtZGIvbWVya2xlX3RyZWVfc25hcHNob3Rfb3BlcmF0aW9uc19mYWNhZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxPQUFPLEVBQUUsWUFBWSxFQUFvQixNQUFNLHNCQUFzQixDQUFDO0FBT3RFLE9BQU8sRUFDTCxzQkFBc0IsRUFFdEIsRUFBRSxFQUNGLHFCQUFxQixFQUNyQixjQUFjLEdBQ2YsTUFBTSxvQkFBb0IsQ0FBQztBQU81Qjs7R0FFRztBQUNILE1BQU0sT0FBTyxrQ0FBa0M7SUFLN0MsWUFBWSxLQUFrQixFQUFFLFdBQW1COztRQUpuRCw4REFBc0I7UUFDdEIsa0VBQXFCO1FBQ3JCLDREQUFnQyxFQUFTLEVBQUM7UUFHeEMsdUJBQUEsSUFBSSwrQ0FBWSxLQUFLLE1BQUEsQ0FBQztRQUN0Qix1QkFBQSxJQUFJLG1EQUFnQixXQUFXLE1BQUEsQ0FBQztJQUNsQyxDQUFDO0lBV0QsS0FBSyxDQUFDLGVBQWUsQ0FDbkIsTUFBVSxFQUNWLE1BQWdDO1FBRWhDLE1BQU0sSUFBSSxHQUFHLE1BQU0sdUJBQUEsSUFBSSwwR0FBaUIsTUFBckIsSUFBSSxFQUFrQixNQUF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