@aztec/world-state 0.20.0 → 0.22.0
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/synchronizer/server_world_state_synchronizer.d.ts +4 -8
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +8 -38
- package/dest/world-state-db/merkle_tree_operations.d.ts +11 -35
- package/dest/world-state-db/merkle_tree_operations.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_operations.js +1 -1
- package/dest/world-state-db/merkle_tree_operations_facade.d.ts +13 -19
- package/dest/world-state-db/merkle_tree_operations_facade.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_operations_facade.js +15 -21
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.d.ts +5 -7
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.js +7 -16
- package/dest/world-state-db/merkle_trees.d.ts +17 -92
- package/dest/world-state-db/merkle_trees.d.ts.map +1 -1
- package/dest/world-state-db/merkle_trees.js +193 -253
- package/package.json +7 -8
|
@@ -1,42 +1,29 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { L2Block, MerkleTreeId } from '@aztec/circuit-types';
|
|
3
|
-
import {
|
|
2
|
+
import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/circuit-types';
|
|
3
|
+
import { Header, StateReference } from '@aztec/circuits.js';
|
|
4
|
+
import { DebugLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { IndexedTreeLeafPreimage } from '@aztec/foundation/trees';
|
|
6
|
+
import { AztecKVStore } from '@aztec/kv-store';
|
|
5
7
|
import { BatchInsertionResult } from '@aztec/merkle-tree';
|
|
6
|
-
import { SiblingPath } from '@aztec/types/membership';
|
|
7
|
-
import { default as levelup } from 'levelup';
|
|
8
8
|
import { MerkleTreeDb } from './merkle_tree_db.js';
|
|
9
|
-
import {
|
|
10
|
-
/**
|
|
11
|
-
* Data necessary to reinitialize the merkle trees from Db.
|
|
12
|
-
*/
|
|
13
|
-
interface FromDbOptions {
|
|
14
|
-
/**
|
|
15
|
-
* The global variables hash from the last block.
|
|
16
|
-
*/
|
|
17
|
-
globalVariablesHash: Fr;
|
|
18
|
-
}
|
|
9
|
+
import { HandleL2BlockResult, IndexedTreeId, MerkleTreeOperations, TreeInfo } from './merkle_tree_operations.js';
|
|
19
10
|
/**
|
|
20
11
|
* A convenience class for managing multiple merkle trees.
|
|
21
12
|
*/
|
|
22
13
|
export declare class MerkleTrees implements MerkleTreeDb {
|
|
23
|
-
private
|
|
14
|
+
#private;
|
|
15
|
+
private store;
|
|
24
16
|
private log;
|
|
25
17
|
private trees;
|
|
26
|
-
private latestGlobalVariablesHash;
|
|
27
18
|
private jobQueue;
|
|
28
|
-
constructor(
|
|
29
|
-
/**
|
|
30
|
-
* initializes the collection of Merkle Trees.
|
|
31
|
-
* @param fromDbOptions - Options to initialize the trees from the database.
|
|
32
|
-
*/
|
|
33
|
-
init(fromDbOptions?: FromDbOptions): Promise<void>;
|
|
19
|
+
private constructor();
|
|
34
20
|
/**
|
|
35
21
|
* Method to asynchronously create and initialize a MerkleTrees instance.
|
|
36
|
-
* @param
|
|
22
|
+
* @param store - The db instance to use for data persistance.
|
|
37
23
|
* @returns - A fully initialized MerkleTrees instance.
|
|
38
24
|
*/
|
|
39
|
-
static new(
|
|
25
|
+
static new(store: AztecKVStore, log?: DebugLogger): Promise<MerkleTrees>;
|
|
26
|
+
buildInitialHeader(includeUncommitted: boolean): Promise<Header>;
|
|
40
27
|
/**
|
|
41
28
|
* Stops the job queue (waits for all jobs to finish).
|
|
42
29
|
*/
|
|
@@ -52,22 +39,11 @@ export declare class MerkleTrees implements MerkleTreeDb {
|
|
|
52
39
|
*/
|
|
53
40
|
asCommitted(): MerkleTreeOperations;
|
|
54
41
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param globalsHash - The current global variables hash.
|
|
58
|
-
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
59
|
-
*/
|
|
60
|
-
updateArchive(globalsHash: Fr, includeUncommitted: boolean): Promise<void>;
|
|
61
|
-
/**
|
|
62
|
-
* Updates the latest global variables hash
|
|
63
|
-
* @param globalVariablesHash - The latest global variables hash
|
|
64
|
-
*/
|
|
65
|
-
updateLatestGlobalVariablesHash(globalVariablesHash: Fr): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Gets the global variables hash from the previous block
|
|
42
|
+
* Updates the archive with the new block/header hash.
|
|
43
|
+
* @param header - The header whose hash to insert into the archive.
|
|
68
44
|
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
69
45
|
*/
|
|
70
|
-
|
|
46
|
+
updateArchive(header: Header, includeUncommitted: boolean): Promise<void>;
|
|
71
47
|
/**
|
|
72
48
|
* Gets the tree info for the specified tree.
|
|
73
49
|
* @param treeId - Id of the tree to get information from.
|
|
@@ -76,13 +52,11 @@ export declare class MerkleTrees implements MerkleTreeDb {
|
|
|
76
52
|
*/
|
|
77
53
|
getTreeInfo(treeId: MerkleTreeId, includeUncommitted: boolean): Promise<TreeInfo>;
|
|
78
54
|
/**
|
|
79
|
-
* Get the current
|
|
55
|
+
* Get the current state reference
|
|
80
56
|
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
81
|
-
* @returns The current
|
|
57
|
+
* @returns The current state reference
|
|
82
58
|
*/
|
|
83
|
-
|
|
84
|
-
private _getCurrentBlockHash;
|
|
85
|
-
private _getAllTreeRoots;
|
|
59
|
+
getStateReference(includeUncommitted: boolean): Promise<StateReference>;
|
|
86
60
|
/**
|
|
87
61
|
* Gets the value at the given index.
|
|
88
62
|
* @param treeId - The ID of the tree to get the leaf value from.
|
|
@@ -177,55 +151,6 @@ export declare class MerkleTrees implements MerkleTreeDb {
|
|
|
177
151
|
* @returns Promise containing the result of the function.
|
|
178
152
|
*/
|
|
179
153
|
private synchronize;
|
|
180
|
-
private _updateLatestGlobalVariablesHash;
|
|
181
|
-
private _getGlobalVariablesHash;
|
|
182
|
-
private _updateArchive;
|
|
183
|
-
/**
|
|
184
|
-
* Returns the tree info for the specified tree id.
|
|
185
|
-
* @param treeId - Id of the tree to get information from.
|
|
186
|
-
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
187
|
-
* @returns The tree info for the specified tree.
|
|
188
|
-
*/
|
|
189
|
-
private _getTreeInfo;
|
|
190
|
-
/**
|
|
191
|
-
* Returns an instance of an indexed tree.
|
|
192
|
-
* @param treeId - Id of the tree to get an instance of.
|
|
193
|
-
* @returns The indexed tree for the specified tree id.
|
|
194
|
-
*/
|
|
195
|
-
private _getIndexedTree;
|
|
196
|
-
/**
|
|
197
|
-
* Returns the sibling path for a leaf in a tree.
|
|
198
|
-
* @param treeId - Id of the tree to get the sibling path from.
|
|
199
|
-
* @param index - Index of the leaf to get the sibling path for.
|
|
200
|
-
* @param includeUncommitted - Indicates whether to include uncommitted updates in the sibling path.
|
|
201
|
-
* @returns Promise containing the sibling path for the leaf.
|
|
202
|
-
*/
|
|
203
|
-
private _getSiblingPath;
|
|
204
|
-
/**
|
|
205
|
-
* Appends leaves to a tree.
|
|
206
|
-
* @param treeId - Id of the tree to append leaves to.
|
|
207
|
-
* @param leaves - Leaves to append.
|
|
208
|
-
* @returns Empty promise.
|
|
209
|
-
*/
|
|
210
|
-
private _appendLeaves;
|
|
211
|
-
private _updateLeaf;
|
|
212
|
-
/**
|
|
213
|
-
* Commits all pending updates.
|
|
214
|
-
* @returns Empty promise.
|
|
215
|
-
*/
|
|
216
|
-
private _commit;
|
|
217
|
-
/**
|
|
218
|
-
* Rolls back all pending updates.
|
|
219
|
-
* @returns Empty promise.
|
|
220
|
-
*/
|
|
221
|
-
private _rollback;
|
|
222
154
|
getSnapshot(blockNumber: number): Promise<import("@aztec/merkle-tree").TreeSnapshot[]>;
|
|
223
|
-
private _snapshot;
|
|
224
|
-
/**
|
|
225
|
-
* Handles a single L2 block (i.e. Inserts the new commitments into the merkle tree).
|
|
226
|
-
* @param l2Block - The L2 block to handle.
|
|
227
|
-
*/
|
|
228
|
-
private _handleL2Block;
|
|
229
155
|
}
|
|
230
|
-
export {};
|
|
231
156
|
//# sourceMappingURL=merkle_trees.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_trees.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_trees.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"merkle_trees.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_trees.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAML,MAAM,EAaN,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAEL,oBAAoB,EASrB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAA8D,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAqBjH;;GAEG;AACH,qBAAa,WAAY,YAAW,YAAY;;IAI1B,OAAO,CAAC,KAAK;IAAgB,OAAO,CAAC,GAAG;IAH5D,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,QAAQ,CAAqB;IAErC,OAAO;IAEP;;;;OAIG;WACiB,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,cAA0C;IAwE7E,kBAAkB,CAAC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