@aztec/world-state 0.7.2 → 0.7.3
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/.tsbuildinfo +1 -0
- package/dest/index.d.ts +5 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +5 -0
- package/dest/merkle-tree/merkle_tree_operations_facade.d.ts +127 -0
- package/dest/merkle-tree/merkle_tree_operations_facade.d.ts.map +1 -0
- package/dest/merkle-tree/merkle_tree_operations_facade.js +147 -0
- package/dest/synchroniser/config.d.ts +19 -0
- package/dest/synchroniser/config.d.ts.map +1 -0
- package/dest/synchroniser/config.js +13 -0
- package/dest/synchroniser/index.d.ts +3 -0
- package/dest/synchroniser/index.d.ts.map +1 -0
- package/dest/synchroniser/index.js +3 -0
- package/dest/synchroniser/server_world_state_synchroniser.d.ts +55 -0
- package/dest/synchroniser/server_world_state_synchroniser.d.ts.map +1 -0
- package/dest/synchroniser/server_world_state_synchroniser.js +163 -0
- package/dest/synchroniser/server_world_state_synchroniser.test.d.ts +2 -0
- package/dest/synchroniser/server_world_state_synchroniser.test.d.ts.map +1 -0
- package/dest/synchroniser/server_world_state_synchroniser.test.js +317 -0
- package/dest/synchroniser/world_state_synchroniser.d.ts +59 -0
- package/dest/synchroniser/world_state_synchroniser.d.ts.map +1 -0
- package/dest/synchroniser/world_state_synchroniser.js +11 -0
- package/dest/utils.d.ts +18 -0
- package/dest/utils.d.ts.map +1 -0
- package/dest/utils.js +23 -0
- package/dest/world-state-db/index.d.ts +189 -0
- package/dest/world-state-db/index.d.ts.map +1 -0
- package/dest/world-state-db/index.js +31 -0
- package/dest/world-state-db/merkle_trees.d.ts +228 -0
- package/dest/world-state-db/merkle_trees.d.ts.map +1 -0
- package/dest/world-state-db/merkle_trees.js +407 -0
- package/package.json +5 -5
- package/Dockerfile +0 -18
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the possible states of the world state synchroniser.
|
|
3
|
+
*/
|
|
4
|
+
export var WorldStateRunningState;
|
|
5
|
+
(function (WorldStateRunningState) {
|
|
6
|
+
WorldStateRunningState[WorldStateRunningState["IDLE"] = 0] = "IDLE";
|
|
7
|
+
WorldStateRunningState[WorldStateRunningState["SYNCHING"] = 1] = "SYNCHING";
|
|
8
|
+
WorldStateRunningState[WorldStateRunningState["RUNNING"] = 2] = "RUNNING";
|
|
9
|
+
WorldStateRunningState[WorldStateRunningState["STOPPED"] = 3] = "STOPPED";
|
|
10
|
+
})(WorldStateRunningState || (WorldStateRunningState = {}));
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ybGRfc3RhdGVfc3luY2hyb25pc2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N5bmNocm9uaXNlci93b3JsZF9zdGF0ZV9zeW5jaHJvbmlzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUE7O0dBRUc7QUFDSCxNQUFNLENBQU4sSUFBWSxzQkFLWDtBQUxELFdBQVksc0JBQXNCO0lBQ2hDLG1FQUFJLENBQUE7SUFDSiwyRUFBUSxDQUFBO0lBQ1IseUVBQU8sQ0FBQTtJQUNQLHlFQUFPLENBQUE7QUFDVCxDQUFDLEVBTFcsc0JBQXNCLEtBQXRCLHNCQUFzQixRQUtqQyJ9
|
package/dest/utils.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GlobalVariables } from '@aztec/circuits.js';
|
|
2
|
+
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { IWasmModule } from '@aztec/foundation/wasm';
|
|
5
|
+
/**
|
|
6
|
+
* Computes the index in the public data tree for a given contract and storage slot.
|
|
7
|
+
* @param contract - Address of the contract who owns the storage.
|
|
8
|
+
* @param slot - Slot within the contract storage.
|
|
9
|
+
* @param bbWasm - Wasm module for computing the hash.
|
|
10
|
+
* @returns The leaf index of the public data tree that maps to this storage slot.
|
|
11
|
+
*/
|
|
12
|
+
export declare function computePublicDataTreeLeafIndex(contract: AztecAddress, slot: Fr, wasm: IWasmModule): bigint;
|
|
13
|
+
/**
|
|
14
|
+
* Computes the hash of the global variables.
|
|
15
|
+
* @returns The hash of the global variables.
|
|
16
|
+
*/
|
|
17
|
+
export declare function computeGlobalVariablesHash(globalVariables?: GlobalVariables): Promise<Fr>;
|
|
18
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGnF,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,CAQ1G;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,eAAe,GAAE,eAAyC,GACzD,OAAO,CAAC,EAAE,CAAC,CAGb"}
|
package/dest/utils.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CircuitsWasm, GeneratorIndex, GlobalVariables } from '@aztec/circuits.js';
|
|
2
|
+
import { computeGlobalsHash } from '@aztec/circuits.js/abis';
|
|
3
|
+
import { pedersenCompressWithHashIndex } from '@aztec/circuits.js/barretenberg';
|
|
4
|
+
import { toBigInt } from '@aztec/foundation/serialize';
|
|
5
|
+
/**
|
|
6
|
+
* Computes the index in the public data tree for a given contract and storage slot.
|
|
7
|
+
* @param contract - Address of the contract who owns the storage.
|
|
8
|
+
* @param slot - Slot within the contract storage.
|
|
9
|
+
* @param bbWasm - Wasm module for computing the hash.
|
|
10
|
+
* @returns The leaf index of the public data tree that maps to this storage slot.
|
|
11
|
+
*/
|
|
12
|
+
export function computePublicDataTreeLeafIndex(contract, slot, wasm) {
|
|
13
|
+
return toBigInt(pedersenCompressWithHashIndex(wasm, [contract, slot].map(f => f.toBuffer()), GeneratorIndex.PUBLIC_LEAF_INDEX));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Computes the hash of the global variables.
|
|
17
|
+
* @returns The hash of the global variables.
|
|
18
|
+
*/
|
|
19
|
+
export async function computeGlobalVariablesHash(globalVariables = GlobalVariables.empty()) {
|
|
20
|
+
const wasm = await CircuitsWasm.get();
|
|
21
|
+
return computeGlobalsHash(wasm, globalVariables);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxjQUFjLEVBQUUsZUFBZSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDbkYsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDN0QsT0FBTyxFQUFFLDZCQUE2QixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFHaEYsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBR3ZEOzs7Ozs7R0FNRztBQUNILE1BQU0sVUFBVSw4QkFBOEIsQ0FBQyxRQUFzQixFQUFFLElBQVEsRUFBRSxJQUFpQjtJQUNoRyxPQUFPLFFBQVEsQ0FDYiw2QkFBNkIsQ0FDM0IsSUFBSSxFQUNKLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxFQUN2QyxjQUFjLENBQUMsaUJBQWlCLENBQ2pDLENBQ0YsQ0FBQztBQUNKLENBQUM7QUFFRDs7O0dBR0c7QUFDSCxNQUFNLENBQUMsS0FBSyxVQUFVLDBCQUEwQixDQUM5QyxrQkFBbUMsZUFBZSxDQUFDLEtBQUssRUFBRTtJQUUxRCxNQUFNLElBQUksR0FBRyxNQUFNLFlBQVksQ0FBQyxHQUFHLEVBQUUsQ0FBQztJQUN0QyxPQUFPLGtCQUFrQixDQUFDLElBQUksRUFBRSxlQUFlLENBQUMsQ0FBQztBQUNuRCxDQUFDIn0=
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { LeafData, LowLeafWitnessData } from '@aztec/merkle-tree';
|
|
4
|
+
import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/types';
|
|
5
|
+
export * from './merkle_trees.js';
|
|
6
|
+
export { LeafData } from '@aztec/merkle-tree';
|
|
7
|
+
/**
|
|
8
|
+
* Type alias for the nullifier tree ID.
|
|
9
|
+
*/
|
|
10
|
+
export type IndexedTreeId = MerkleTreeId.NULLIFIER_TREE;
|
|
11
|
+
/**
|
|
12
|
+
* Type alias for the public data tree ID.
|
|
13
|
+
*/
|
|
14
|
+
export type PublicTreeId = MerkleTreeId.PUBLIC_DATA_TREE;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @remarks Short explanation:
|
|
18
|
+
* The nullifier tree must be initially padded as the pre-populated 0 index prevents efficient subtree insertion.
|
|
19
|
+
* Padding with some values solves this issue.
|
|
20
|
+
*
|
|
21
|
+
* @remarks Thorough explanation:
|
|
22
|
+
* There needs to be an initial (0,0,0) leaf in the tree, so that when we insert the first 'proper' leaf, we can
|
|
23
|
+
* prove that any value greater than 0 doesn't exist in the tree yet. We prefill/pad the tree with "the number of
|
|
24
|
+
* leaves that are added by one block" so that the first 'proper' block can insert a full subtree.
|
|
25
|
+
*
|
|
26
|
+
* Without this padding, there would be a leaf (0,0,0) at leaf index 0, making it really difficult to insert e.g.
|
|
27
|
+
* 1024 leaves for the first block, because there's only neat space for 1023 leaves after 0. By padding with 1023
|
|
28
|
+
* more leaves, we can then insert the first block of 1024 leaves into indices 1024:2047.
|
|
29
|
+
*/
|
|
30
|
+
export declare const INITIAL_NULLIFIER_TREE_SIZE: number;
|
|
31
|
+
/**
|
|
32
|
+
* Defines tree information.
|
|
33
|
+
*/
|
|
34
|
+
export interface TreeInfo {
|
|
35
|
+
/**
|
|
36
|
+
* The tree ID.
|
|
37
|
+
*/
|
|
38
|
+
treeId: MerkleTreeId;
|
|
39
|
+
/**
|
|
40
|
+
* The tree root.
|
|
41
|
+
*/
|
|
42
|
+
root: Buffer;
|
|
43
|
+
/**
|
|
44
|
+
* The number of leaves in the tree.
|
|
45
|
+
*/
|
|
46
|
+
size: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* The depth of the tree.
|
|
49
|
+
*/
|
|
50
|
+
depth: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Adds a last boolean flag in each function on the type.
|
|
54
|
+
*/
|
|
55
|
+
type WithIncludeUncommitted<F> = F extends (...args: [...infer Rest]) => infer Return ? (...args: [...Rest, boolean]) => Return : F;
|
|
56
|
+
/**
|
|
57
|
+
* The current roots of the commitment trees
|
|
58
|
+
*/
|
|
59
|
+
export type CurrentTreeRoots = {
|
|
60
|
+
/** Private data tree root. */
|
|
61
|
+
privateDataTreeRoot: Buffer;
|
|
62
|
+
/** Contract data tree root. */
|
|
63
|
+
contractDataTreeRoot: Buffer;
|
|
64
|
+
/** L1 to L2 Messages data tree root. */
|
|
65
|
+
l1Tol2MessagesTreeRoot: Buffer;
|
|
66
|
+
/** Nullifier data tree root. */
|
|
67
|
+
nullifierTreeRoot: Buffer;
|
|
68
|
+
/** Blocks tree root. */
|
|
69
|
+
blocksTreeRoot: Buffer;
|
|
70
|
+
/** Public data tree root */
|
|
71
|
+
publicDataTreeRoot: Buffer;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Defines the names of the setters on Merkle Trees.
|
|
75
|
+
*/
|
|
76
|
+
type MerkleTreeSetters = 'appendLeaves' | 'updateLeaf' | 'commit' | 'rollback' | 'handleL2Block' | 'batchInsert';
|
|
77
|
+
/**
|
|
78
|
+
* Defines the interface for operations on a set of Merkle Trees configuring whether to return committed or uncommitted data.
|
|
79
|
+
*/
|
|
80
|
+
export type MerkleTreeDb = {
|
|
81
|
+
[Property in keyof MerkleTreeOperations as Exclude<Property, MerkleTreeSetters>]: WithIncludeUncommitted<MerkleTreeOperations[Property]>;
|
|
82
|
+
} & Pick<MerkleTreeOperations, MerkleTreeSetters>;
|
|
83
|
+
/**
|
|
84
|
+
* Defines the interface for operations on a set of Merkle Trees.
|
|
85
|
+
*/
|
|
86
|
+
export interface MerkleTreeOperations {
|
|
87
|
+
/**
|
|
88
|
+
* Appends leaves to a given tree.
|
|
89
|
+
* @param treeId - The tree to be updated.
|
|
90
|
+
* @param leaves - The set of leaves to be appended.
|
|
91
|
+
*/
|
|
92
|
+
appendLeaves(treeId: MerkleTreeId, leaves: Buffer[]): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Returns information about the given tree.
|
|
95
|
+
* @param treeId - The tree to be queried.
|
|
96
|
+
*/
|
|
97
|
+
getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo>;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the current roots of the commitment trees.
|
|
100
|
+
*/
|
|
101
|
+
getTreeRoots(): Promise<CurrentTreeRoots>;
|
|
102
|
+
/**
|
|
103
|
+
* Gets sibling path for a leaf.
|
|
104
|
+
* @param treeId - The tree to be queried for a sibling path.
|
|
105
|
+
* @param index - The index of the leaf for which a sibling path should be returned.
|
|
106
|
+
*/
|
|
107
|
+
getSiblingPath<N extends number>(treeId: MerkleTreeId, index: bigint): Promise<SiblingPath<N>>;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the previous index for a given value in an indexed tree.
|
|
110
|
+
* @param treeId - The tree for which the previous value index is required.
|
|
111
|
+
* @param value - The value to be queried.
|
|
112
|
+
*/
|
|
113
|
+
getPreviousValueIndex(treeId: IndexedTreeId, value: bigint): Promise<{
|
|
114
|
+
/**
|
|
115
|
+
* The index of the found leaf.
|
|
116
|
+
*/
|
|
117
|
+
index: number;
|
|
118
|
+
/**
|
|
119
|
+
* A flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
120
|
+
*/
|
|
121
|
+
alreadyPresent: boolean;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the data at a specific leaf.
|
|
125
|
+
* @param treeId - The tree for which leaf data should be returned.
|
|
126
|
+
* @param index - The index of the leaf required.
|
|
127
|
+
*/
|
|
128
|
+
getLeafData(treeId: IndexedTreeId, index: number): Promise<LeafData | undefined>;
|
|
129
|
+
/**
|
|
130
|
+
* Update the leaf data at the given index.
|
|
131
|
+
* @param treeId - The tree for which leaf data should be edited.
|
|
132
|
+
* @param leaf - The updated leaf value.
|
|
133
|
+
* @param index - The index of the leaf to be updated.
|
|
134
|
+
*/
|
|
135
|
+
updateLeaf(treeId: IndexedTreeId | PublicTreeId, leaf: LeafData | Buffer, index: bigint): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the index containing a leaf value.
|
|
138
|
+
* @param treeId - The tree for which the index should be returned.
|
|
139
|
+
* @param value - The value to search for in the tree.
|
|
140
|
+
*/
|
|
141
|
+
findLeafIndex(treeId: MerkleTreeId, value: Buffer): Promise<bigint | undefined>;
|
|
142
|
+
/**
|
|
143
|
+
* Gets the value for a leaf in the tree.
|
|
144
|
+
* @param treeId - The tree for which the index should be returned.
|
|
145
|
+
* @param index - The index of the leaf.
|
|
146
|
+
*/
|
|
147
|
+
getLeafValue(treeId: MerkleTreeId, index: bigint): Promise<Buffer | undefined>;
|
|
148
|
+
/**
|
|
149
|
+
* Inserts the new block hash into the new block hashes tree.
|
|
150
|
+
* This includes all of the current roots of all of the data trees and the current blocks global vars.
|
|
151
|
+
* @param globalVariablesHash - The global variables hash to insert into the block hash.
|
|
152
|
+
*/
|
|
153
|
+
updateHistoricBlocksTree(globalVariablesHash: Fr): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Updates the latest global variables hash
|
|
156
|
+
* @param globalVariablesHash - The latest global variables hash
|
|
157
|
+
*/
|
|
158
|
+
updateLatestGlobalVariablesHash(globalVariablesHash: Fr): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Gets the global variables hash from the previous block
|
|
161
|
+
*/
|
|
162
|
+
getLatestGlobalVariablesHash(): Promise<Fr>;
|
|
163
|
+
/**
|
|
164
|
+
* Batch insert multiple leaves into the tree.
|
|
165
|
+
* @param leaves - Leaves to insert into the tree.
|
|
166
|
+
* @param treeId - The tree on which to insert.
|
|
167
|
+
* @param subtreeHeight - Height of the subtree.
|
|
168
|
+
* @returns The witness data for the leaves to be updated when inserting the new ones.
|
|
169
|
+
*/
|
|
170
|
+
batchInsert(treeId: MerkleTreeId, leaves: Buffer[], subtreeHeight: number): Promise<[LowLeafWitnessData<number>[], SiblingPath<number>] | [undefined, SiblingPath<number>]>;
|
|
171
|
+
/**
|
|
172
|
+
* Handles a single L2 block (i.e. Inserts the new commitments into the merkle tree).
|
|
173
|
+
* @param block - The L2 block to handle.
|
|
174
|
+
*/
|
|
175
|
+
handleL2Block(block: L2Block): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Commits pending changes to the underlying store.
|
|
178
|
+
*/
|
|
179
|
+
commit(): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Rolls back pending changes.
|
|
182
|
+
*/
|
|
183
|
+
rollback(): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Outputs a tree leaves using for debugging purposes.
|
|
187
|
+
*/
|
|
188
|
+
export declare function inspectTree(db: MerkleTreeOperations, treeId: MerkleTreeId, log?: import("@aztec/foundation/log").DebugLogger): Promise<void>;
|
|
189
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/world-state-db/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAElE,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC,cAAc,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC;AAEzD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,2BAA2B,QAAgC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IACrB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,MAAM,MAAM,GACjF,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,MAAM,GACvC,CAAC,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,8BAA8B;IAC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AI,CAAC,CAAC;IAExB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,EAAE,EAAE,oBAAoB,EACxB,MAAM,EAAE,YAAY,EACpB,GAAG,8CAA0C,iBAU9C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MAX_NEW_NULLIFIERS_PER_TX } from '@aztec/circuits.js';
|
|
2
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
|
+
export * from './merkle_trees.js';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @remarks Short explanation:
|
|
7
|
+
* The nullifier tree must be initially padded as the pre-populated 0 index prevents efficient subtree insertion.
|
|
8
|
+
* Padding with some values solves this issue.
|
|
9
|
+
*
|
|
10
|
+
* @remarks Thorough explanation:
|
|
11
|
+
* There needs to be an initial (0,0,0) leaf in the tree, so that when we insert the first 'proper' leaf, we can
|
|
12
|
+
* prove that any value greater than 0 doesn't exist in the tree yet. We prefill/pad the tree with "the number of
|
|
13
|
+
* leaves that are added by one block" so that the first 'proper' block can insert a full subtree.
|
|
14
|
+
*
|
|
15
|
+
* Without this padding, there would be a leaf (0,0,0) at leaf index 0, making it really difficult to insert e.g.
|
|
16
|
+
* 1024 leaves for the first block, because there's only neat space for 1023 leaves after 0. By padding with 1023
|
|
17
|
+
* more leaves, we can then insert the first block of 1024 leaves into indices 1024:2047.
|
|
18
|
+
*/
|
|
19
|
+
export const INITIAL_NULLIFIER_TREE_SIZE = 2 * MAX_NEW_NULLIFIERS_PER_TX;
|
|
20
|
+
/**
|
|
21
|
+
* Outputs a tree leaves using for debugging purposes.
|
|
22
|
+
*/
|
|
23
|
+
export async function inspectTree(db, treeId, log = createDebugLogger('aztec:inspect-tree')) {
|
|
24
|
+
const info = await db.getTreeInfo(treeId);
|
|
25
|
+
const output = [`Tree id=${treeId} size=${info.size} root=0x${info.root.toString('hex')}`];
|
|
26
|
+
for (let i = 0; i < info.size; i++) {
|
|
27
|
+
output.push(` Leaf ${i}: ${await db.getLeafValue(treeId, BigInt(i)).then(x => x?.toString('hex') ?? '[undefined]')}`);
|
|
28
|
+
}
|
|
29
|
+
log(output.join('\n'));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd29ybGQtc3RhdGUtZGIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFL0QsT0FBTyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFJMUQsY0FBYyxtQkFBbUIsQ0FBQztBQWFsQzs7Ozs7Ozs7Ozs7Ozs7R0FjRztBQUNILE1BQU0sQ0FBQyxNQUFNLDJCQUEyQixHQUFHLENBQUMsR0FBRyx5QkFBeUIsQ0FBQztBQTZMekU7O0dBRUc7QUFDSCxNQUFNLENBQUMsS0FBSyxVQUFVLFdBQVcsQ0FDL0IsRUFBd0IsRUFDeEIsTUFBb0IsRUFDcEIsR0FBRyxHQUFHLGlCQUFpQixDQUFDLG9CQUFvQixDQUFDO0lBRTdDLE1BQU0sSUFBSSxHQUFHLE1BQU0sRUFBRSxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUMxQyxNQUFNLE1BQU0sR0FBRyxDQUFDLFdBQVcsTUFBTSxTQUFTLElBQUksQ0FBQyxJQUFJLFdBQVcsSUFBSSxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQyxDQUFDO0lBQzNGLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsR0FBRyxJQUFJLENBQUMsSUFBSSxFQUFFLENBQUMsRUFBRSxFQUFFO1FBQ2xDLE1BQU0sQ0FBQyxJQUFJLENBQ1QsU0FBUyxDQUFDLEtBQUssTUFBTSxFQUFFLENBQUMsWUFBWSxDQUFDLE1BQU0sRUFBRSxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsUUFBUSxDQUFDLEtBQUssQ0FBQyxJQUFJLGFBQWEsQ0FBQyxFQUFFLENBQ3pHLENBQUM7S0FDSDtJQUNELEdBQUcsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUM7QUFDekIsQ0FBQyJ9
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { Fr, GlobalVariables } from '@aztec/circuits.js';
|
|
3
|
+
import { IWasmModule } from '@aztec/foundation/wasm';
|
|
4
|
+
import { LeafData, LowLeafWitnessData } from '@aztec/merkle-tree';
|
|
5
|
+
import { L2Block, MerkleTreeId, SiblingPath } from '@aztec/types';
|
|
6
|
+
import { default as levelup } from 'levelup';
|
|
7
|
+
import { CurrentTreeRoots, IndexedTreeId, MerkleTreeDb, MerkleTreeOperations, PublicTreeId, TreeInfo } from './index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Data necessary to reinitialise the merkle trees from Db.
|
|
10
|
+
*/
|
|
11
|
+
interface FromDbOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The global variables from the last block.
|
|
14
|
+
*/
|
|
15
|
+
globalVariables: GlobalVariables;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A convenience class for managing multiple merkle trees.
|
|
19
|
+
*/
|
|
20
|
+
export declare class MerkleTrees implements MerkleTreeDb {
|
|
21
|
+
private db;
|
|
22
|
+
private log;
|
|
23
|
+
private trees;
|
|
24
|
+
private latestGlobalVariablesHash;
|
|
25
|
+
private jobQueue;
|
|
26
|
+
constructor(db: levelup.LevelUp, log?: import("@aztec/foundation/log").DebugLogger);
|
|
27
|
+
/**
|
|
28
|
+
* Initialises the collection of Merkle Trees.
|
|
29
|
+
* @param optionalWasm - WASM instance to use for hashing (if not provided PrimitivesWasm will be used).
|
|
30
|
+
* @param fromDbOptions - Options to initialise the trees from the database.
|
|
31
|
+
*/
|
|
32
|
+
init(optionalWasm?: IWasmModule, fromDbOptions?: FromDbOptions): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Method to asynchronously create and initialise a MerkleTrees instance.
|
|
35
|
+
* @param db - The db instance to use for data persistance.
|
|
36
|
+
* @param wasm - WASM instance to use for hashing (if not provided PrimitivesWasm will be used).
|
|
37
|
+
* @returns - A fully initialised MerkleTrees instance.
|
|
38
|
+
*/
|
|
39
|
+
static new(db: levelup.LevelUp, wasm?: IWasmModule): Promise<MerkleTrees>;
|
|
40
|
+
/**
|
|
41
|
+
* Stops the job queue (waits for all jobs to finish).
|
|
42
|
+
*/
|
|
43
|
+
stop(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Gets a view of this db that returns uncommitted data.
|
|
46
|
+
* @returns - A facade for this instance.
|
|
47
|
+
*/
|
|
48
|
+
asLatest(): MerkleTreeOperations;
|
|
49
|
+
/**
|
|
50
|
+
* Gets a view of this db that returns committed data only.
|
|
51
|
+
* @returns - A facade for this instance.
|
|
52
|
+
*/
|
|
53
|
+
asCommitted(): MerkleTreeOperations;
|
|
54
|
+
/**
|
|
55
|
+
* Inserts into the roots trees (CONTRACT_TREE_ROOTS_TREE, PRIVATE_DATA_TREE_ROOTS_TREE, L1_TO_L2_MESSAGES_TREE_ROOTS_TREE)
|
|
56
|
+
* the current roots of the corresponding trees (CONTRACT_TREE, PRIVATE_DATA_TREE, L1_TO_L2_MESSAGES_TREE).
|
|
57
|
+
* @param globalsHash - The current global variables hash.
|
|
58
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
59
|
+
*/
|
|
60
|
+
updateHistoricBlocksTree(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
|
|
68
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
69
|
+
*/
|
|
70
|
+
getLatestGlobalVariablesHash(includeUncommitted: boolean): Promise<Fr>;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the tree info for the specified tree.
|
|
73
|
+
* @param treeId - Id of the tree to get information from.
|
|
74
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
75
|
+
* @returns The tree info for the specified tree.
|
|
76
|
+
*/
|
|
77
|
+
getTreeInfo(treeId: MerkleTreeId, includeUncommitted: boolean): Promise<TreeInfo>;
|
|
78
|
+
/**
|
|
79
|
+
* Get the current roots of the commitment trees.
|
|
80
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
81
|
+
* @returns The current roots of the trees.
|
|
82
|
+
*/
|
|
83
|
+
getTreeRoots(includeUncommitted: boolean): Promise<CurrentTreeRoots>;
|
|
84
|
+
private _getCurrentBlockHash;
|
|
85
|
+
private _getAllTreeRoots;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the value at the given index.
|
|
88
|
+
* @param treeId - The ID of the tree to get the leaf value from.
|
|
89
|
+
* @param index - The index of the leaf.
|
|
90
|
+
* @param includeUncommitted - Indicates whether to include uncommitted changes.
|
|
91
|
+
* @returns Leaf value at the given index (undefined if not found).
|
|
92
|
+
*/
|
|
93
|
+
getLeafValue(treeId: MerkleTreeId, index: bigint, includeUncommitted: boolean): Promise<Buffer | undefined>;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the sibling path for a leaf in a tree.
|
|
96
|
+
* @param treeId - The ID of the tree.
|
|
97
|
+
* @param index - The index of the leaf.
|
|
98
|
+
* @param includeUncommitted - Indicates whether the sibling path should incro include uncommitted data.
|
|
99
|
+
* @returns The sibling path for the leaf.
|
|
100
|
+
*/
|
|
101
|
+
getSiblingPath<N extends number>(treeId: MerkleTreeId, index: bigint, includeUncommitted: boolean): Promise<SiblingPath<N>>;
|
|
102
|
+
/**
|
|
103
|
+
* Appends leaves to a tree.
|
|
104
|
+
* @param treeId - The ID of the tree.
|
|
105
|
+
* @param leaves - The leaves to append.
|
|
106
|
+
* @returns Empty promise.
|
|
107
|
+
*/
|
|
108
|
+
appendLeaves(treeId: MerkleTreeId, leaves: Buffer[]): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Commits all pending updates.
|
|
111
|
+
* @returns Empty promise.
|
|
112
|
+
*/
|
|
113
|
+
commit(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Rolls back all pending updates.
|
|
116
|
+
* @returns Empty promise.
|
|
117
|
+
*/
|
|
118
|
+
rollback(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Finds the index of the largest leaf whose value is less than or equal to the provided value.
|
|
121
|
+
* @param treeId - The ID of the tree to search.
|
|
122
|
+
* @param value - The value to be inserted into the tree.
|
|
123
|
+
* @param includeUncommitted - If true, the uncommitted changes are included in the search.
|
|
124
|
+
* @returns The found leaf index and a flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
125
|
+
*/
|
|
126
|
+
getPreviousValueIndex(treeId: IndexedTreeId, value: bigint, includeUncommitted: boolean): Promise<{
|
|
127
|
+
/**
|
|
128
|
+
* The index of the found leaf.
|
|
129
|
+
*/
|
|
130
|
+
index: number;
|
|
131
|
+
/**
|
|
132
|
+
* A flag indicating if the corresponding leaf's value is equal to `newValue`.
|
|
133
|
+
*/
|
|
134
|
+
alreadyPresent: boolean;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Gets the leaf data at a given index and tree.
|
|
138
|
+
* @param treeId - The ID of the tree get the leaf from.
|
|
139
|
+
* @param index - The index of the leaf to get.
|
|
140
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
141
|
+
* @returns Leaf data.
|
|
142
|
+
*/
|
|
143
|
+
getLeafData(treeId: IndexedTreeId, index: number, includeUncommitted: boolean): Promise<LeafData | undefined>;
|
|
144
|
+
/**
|
|
145
|
+
* Returns the index of a leaf given its value, or undefined if no leaf with that value is found.
|
|
146
|
+
* @param treeId - The ID of the tree.
|
|
147
|
+
* @param value - The leaf value to look for.
|
|
148
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
149
|
+
* @returns The index of the first leaf found with a given value (undefined if not found).
|
|
150
|
+
*/
|
|
151
|
+
findLeafIndex(treeId: MerkleTreeId, value: Buffer, includeUncommitted: boolean): Promise<bigint | undefined>;
|
|
152
|
+
/**
|
|
153
|
+
* Updates a leaf in a tree at a given index.
|
|
154
|
+
* @param treeId - The ID of the tree.
|
|
155
|
+
* @param leaf - The new leaf value.
|
|
156
|
+
* @param index - The index to insert into.
|
|
157
|
+
* @returns Empty promise.
|
|
158
|
+
*/
|
|
159
|
+
updateLeaf(treeId: IndexedTreeId | PublicTreeId, leaf: LeafData | Buffer, index: bigint): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Handles a single L2 block (i.e. Inserts the new commitments into the merkle tree).
|
|
162
|
+
* @param block - The L2 block to handle.
|
|
163
|
+
*/
|
|
164
|
+
handleL2Block(block: L2Block): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Batch insert multiple leaves into the tree.
|
|
167
|
+
* @param treeId - The ID of the tree.
|
|
168
|
+
* @param leaves - Leaves to insert into the tree.
|
|
169
|
+
* @param subtreeHeight - Height of the subtree.
|
|
170
|
+
* @returns The data for the leaves to be updated when inserting the new ones.
|
|
171
|
+
*/
|
|
172
|
+
batchInsert<TreeHeight extends number, SubtreeHeight extends number, SubtreeSiblingPathHeight extends number>(treeId: MerkleTreeId, leaves: Buffer[], subtreeHeight: SubtreeHeight): Promise<[LowLeafWitnessData<TreeHeight>[], SiblingPath<SubtreeSiblingPathHeight>] | [undefined, SiblingPath<SubtreeSiblingPathHeight>]>;
|
|
173
|
+
/**
|
|
174
|
+
* Waits for all jobs to finish before executing the given function.
|
|
175
|
+
* @param fn - The function to execute.
|
|
176
|
+
* @returns Promise containing the result of the function.
|
|
177
|
+
*/
|
|
178
|
+
private synchronise;
|
|
179
|
+
private _updateLatestGlobalVariablesHash;
|
|
180
|
+
private _getGlobalVariablesHash;
|
|
181
|
+
private _updateHistoricBlocksTree;
|
|
182
|
+
/**
|
|
183
|
+
* Returns the tree info for the specified tree id.
|
|
184
|
+
* @param treeId - Id of the tree to get information from.
|
|
185
|
+
* @param includeUncommitted - Indicates whether to include uncommitted data.
|
|
186
|
+
* @returns The tree info for the specified tree.
|
|
187
|
+
*/
|
|
188
|
+
private _getTreeInfo;
|
|
189
|
+
/**
|
|
190
|
+
* Returns an instance of an indexed tree.
|
|
191
|
+
* @param treeId - Id of the tree to get an instance of.
|
|
192
|
+
* @returns The indexed tree for the specified tree id.
|
|
193
|
+
*/
|
|
194
|
+
private _getIndexedTree;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the sibling path for a leaf in a tree.
|
|
197
|
+
* @param treeId - Id of the tree to get the sibling path from.
|
|
198
|
+
* @param index - Index of the leaf to get the sibling path for.
|
|
199
|
+
* @param includeUncommitted - Indicates whether to include uncommitted updates in the sibling path.
|
|
200
|
+
* @returns Promise containing the sibling path for the leaf.
|
|
201
|
+
*/
|
|
202
|
+
private _getSiblingPath;
|
|
203
|
+
/**
|
|
204
|
+
* Appends leaves to a tree.
|
|
205
|
+
* @param treeId - Id of the tree to append leaves to.
|
|
206
|
+
* @param leaves - Leaves to append.
|
|
207
|
+
* @returns Empty promise.
|
|
208
|
+
*/
|
|
209
|
+
private _appendLeaves;
|
|
210
|
+
private _updateLeaf;
|
|
211
|
+
/**
|
|
212
|
+
* Commits all pending updates.
|
|
213
|
+
* @returns Empty promise.
|
|
214
|
+
*/
|
|
215
|
+
private _commit;
|
|
216
|
+
/**
|
|
217
|
+
* Rolls back all pending updates.
|
|
218
|
+
* @returns Empty promise.
|
|
219
|
+
*/
|
|
220
|
+
private _rollback;
|
|
221
|
+
/**
|
|
222
|
+
* Handles a single L2 block (i.e. Inserts the new commitments into the merkle tree).
|
|
223
|
+
* @param l2Block - The L2 block to handle.
|
|
224
|
+
*/
|
|
225
|
+
private _handleL2Block;
|
|
226
|
+
}
|
|
227
|
+
export {};
|
|
228
|
+
//# sourceMappingURL=merkle_trees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merkle_trees.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_trees.ts"],"names":[],"mappings":";AAAA,OAAO,EAGL,EAAE,EACF,eAAe,EAOhB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAGL,QAAQ,EACR,kBAAkB,EAQnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAC;AAEjF,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AAI7C,OAAO,EACL,gBAAgB,EAEhB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EACT,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,UAAU,aAAa;IACrB;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,YAAY;IAKlC,OAAO,CAAC,EAAE;IAAmB,OAAO,CAAC,GAAG;IAJpD,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,yBAAyB,CAAkB;IACnD,OAAO,CAAC,QAAQ,CAAqB;gBAEjB,EAAE,EAAE,OAAO,CAAC,OAAO,EAA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