@aztec/world-state 0.57.0 → 0.59.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/README.md +1 -1
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- package/dest/native/merkle_trees_facade.d.ts +34 -0
- package/dest/native/merkle_trees_facade.d.ts.map +1 -0
- package/dest/native/merkle_trees_facade.js +193 -0
- package/dest/native/message.d.ts +78 -19
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +27 -26
- package/dest/native/native_world_state.d.ts +39 -38
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +108 -254
- package/dest/native/native_world_state_instance.d.ts +40 -0
- package/dest/native/native_world_state_instance.d.ts.map +1 -0
- package/dest/native/native_world_state_instance.js +183 -0
- package/dest/synchronizer/config.d.ts +2 -2
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +6 -7
- package/dest/synchronizer/factory.d.ts +3 -0
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +13 -4
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +41 -41
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +126 -151
- package/dest/test/utils.d.ts +14 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +67 -0
- package/dest/world-state-db/index.d.ts +1 -1
- package/dest/world-state-db/index.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_db.d.ts +42 -32
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_db.js +1 -1
- package/dest/world-state-db/merkle_tree_operations_facade.d.ts +8 -37
- package/dest/world-state-db/merkle_tree_operations_facade.d.ts.map +1 -1
- package/dest/world-state-db/merkle_tree_operations_facade.js +6 -45
- package/dest/world-state-db/merkle_tree_snapshot_operations_facade.d.ts +4 -13
- 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 +2 -29
- package/dest/world-state-db/merkle_trees.d.ts +17 -19
- package/dest/world-state-db/merkle_trees.d.ts.map +1 -1
- package/dest/world-state-db/merkle_trees.js +39 -36
- package/package.json +15 -12
- package/src/index.ts +1 -0
- package/src/native/merkle_trees_facade.ts +279 -0
- package/src/native/message.ts +97 -20
- package/src/native/native_world_state.ts +125 -346
- package/src/native/native_world_state_instance.ts +262 -0
- package/src/synchronizer/config.ts +8 -9
- package/src/synchronizer/factory.ts +20 -3
- package/src/synchronizer/server_world_state_synchronizer.ts +149 -178
- package/src/test/utils.ts +123 -0
- package/src/world-state-db/index.ts +1 -1
- package/src/world-state-db/merkle_tree_db.ts +55 -49
- package/src/world-state-db/merkle_tree_operations_facade.ts +10 -55
- package/src/world-state-db/merkle_tree_snapshot_operations_facade.ts +7 -46
- package/src/world-state-db/merkle_trees.ts +50 -45
package/src/native/message.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MerkleTreeId } from '@aztec/circuit-types';
|
|
2
|
-
import { AppendOnlyTreeSnapshot, Fr,
|
|
2
|
+
import { AppendOnlyTreeSnapshot, Fr, type StateReference, type UInt32 } from '@aztec/circuits.js';
|
|
3
3
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
4
4
|
|
|
5
5
|
export type MessageHeaderInit = {
|
|
@@ -49,6 +49,7 @@ export class TypedMessage<T, B> {
|
|
|
49
49
|
export enum WorldStateMessageType {
|
|
50
50
|
GET_TREE_INFO = 100,
|
|
51
51
|
GET_STATE_REFERENCE,
|
|
52
|
+
GET_INITIAL_STATE_REFERENCE,
|
|
52
53
|
|
|
53
54
|
GET_LEAF_VALUE,
|
|
54
55
|
GET_LEAF_PREIMAGE,
|
|
@@ -66,12 +67,36 @@ export enum WorldStateMessageType {
|
|
|
66
67
|
ROLLBACK,
|
|
67
68
|
|
|
68
69
|
SYNC_BLOCK,
|
|
70
|
+
|
|
71
|
+
CREATE_FORK,
|
|
72
|
+
DELETE_FORK,
|
|
73
|
+
|
|
74
|
+
FINALISE_BLOCKS,
|
|
75
|
+
UNWIND_BLOCKS,
|
|
76
|
+
REMOVE_HISTORICAL_BLOCKS,
|
|
77
|
+
|
|
78
|
+
GET_STATUS,
|
|
79
|
+
|
|
80
|
+
CLOSE = 999,
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
interface WithTreeId {
|
|
72
84
|
treeId: MerkleTreeId;
|
|
73
85
|
}
|
|
74
86
|
|
|
87
|
+
export interface WorldStateStatus {
|
|
88
|
+
/** Last block number that can still be unwound. */
|
|
89
|
+
unfinalisedBlockNumber: bigint;
|
|
90
|
+
/** Last block number that is finalised and cannot be unwound. */
|
|
91
|
+
finalisedBlockNumber: bigint;
|
|
92
|
+
/** Oldest block still available for historical queries and forks. */
|
|
93
|
+
oldestHistoricalBlock: bigint;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface WithForkId {
|
|
97
|
+
forkId: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
75
100
|
interface WithWorldStateRevision {
|
|
76
101
|
revision: WorldStateRevision;
|
|
77
102
|
}
|
|
@@ -95,6 +120,10 @@ interface WithLeafValue {
|
|
|
95
120
|
leaf: SerializedLeafValue;
|
|
96
121
|
}
|
|
97
122
|
|
|
123
|
+
interface BlockShiftRequest {
|
|
124
|
+
toBlockNumber: bigint;
|
|
125
|
+
}
|
|
126
|
+
|
|
98
127
|
interface WithLeaves {
|
|
99
128
|
leaves: SerializedLeafValue[];
|
|
100
129
|
}
|
|
@@ -134,9 +163,9 @@ interface FindLowLeafResponse {
|
|
|
134
163
|
alreadyPresent: boolean;
|
|
135
164
|
}
|
|
136
165
|
|
|
137
|
-
interface AppendLeavesRequest extends WithTreeId, WithLeaves {}
|
|
166
|
+
interface AppendLeavesRequest extends WithTreeId, WithForkId, WithLeaves {}
|
|
138
167
|
|
|
139
|
-
interface BatchInsertRequest extends WithTreeId, WithLeaves {
|
|
168
|
+
interface BatchInsertRequest extends WithTreeId, WithForkId, WithLeaves {
|
|
140
169
|
subtreeDepth: number;
|
|
141
170
|
}
|
|
142
171
|
interface BatchInsertResponse {
|
|
@@ -149,14 +178,15 @@ interface BatchInsertResponse {
|
|
|
149
178
|
subtree_path: Tuple<Buffer, number>;
|
|
150
179
|
}
|
|
151
180
|
|
|
152
|
-
interface UpdateArchiveRequest {
|
|
181
|
+
interface UpdateArchiveRequest extends WithForkId {
|
|
153
182
|
blockStateRef: BlockStateReference;
|
|
154
|
-
|
|
183
|
+
blockHeaderHash: Buffer;
|
|
155
184
|
}
|
|
156
185
|
|
|
157
186
|
interface SyncBlockRequest {
|
|
187
|
+
blockNumber: number;
|
|
158
188
|
blockStateRef: BlockStateReference;
|
|
159
|
-
|
|
189
|
+
blockHeaderHash: Fr;
|
|
160
190
|
paddedNoteHashes: readonly SerializedLeafValue[];
|
|
161
191
|
paddedL1ToL2Messages: readonly SerializedLeafValue[];
|
|
162
192
|
paddedNullifiers: readonly SerializedLeafValue[];
|
|
@@ -164,12 +194,34 @@ interface SyncBlockRequest {
|
|
|
164
194
|
}
|
|
165
195
|
|
|
166
196
|
interface SyncBlockResponse {
|
|
167
|
-
|
|
197
|
+
status: WorldStateStatus;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
interface CreateForkRequest {
|
|
201
|
+
latest: boolean;
|
|
202
|
+
blockNumber: number;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
interface CreateForkResponse {
|
|
206
|
+
forkId: number;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
interface DeleteForkRequest {
|
|
210
|
+
forkId: number;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
interface CreateForkResponse {
|
|
214
|
+
forkId: number;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
interface DeleteForkRequest {
|
|
218
|
+
forkId: number;
|
|
168
219
|
}
|
|
169
220
|
|
|
170
221
|
export type WorldStateRequest = {
|
|
171
222
|
[WorldStateMessageType.GET_TREE_INFO]: GetTreeInfoRequest;
|
|
172
223
|
[WorldStateMessageType.GET_STATE_REFERENCE]: GetStateReferenceRequest;
|
|
224
|
+
[WorldStateMessageType.GET_INITIAL_STATE_REFERENCE]: void;
|
|
173
225
|
|
|
174
226
|
[WorldStateMessageType.GET_LEAF_VALUE]: GetLeafRequest;
|
|
175
227
|
[WorldStateMessageType.GET_LEAF_PREIMAGE]: GetLeafPreImageRequest;
|
|
@@ -187,11 +239,23 @@ export type WorldStateRequest = {
|
|
|
187
239
|
[WorldStateMessageType.ROLLBACK]: void;
|
|
188
240
|
|
|
189
241
|
[WorldStateMessageType.SYNC_BLOCK]: SyncBlockRequest;
|
|
242
|
+
|
|
243
|
+
[WorldStateMessageType.CREATE_FORK]: CreateForkRequest;
|
|
244
|
+
[WorldStateMessageType.DELETE_FORK]: DeleteForkRequest;
|
|
245
|
+
|
|
246
|
+
[WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS]: BlockShiftRequest;
|
|
247
|
+
[WorldStateMessageType.UNWIND_BLOCKS]: BlockShiftRequest;
|
|
248
|
+
[WorldStateMessageType.FINALISE_BLOCKS]: BlockShiftRequest;
|
|
249
|
+
|
|
250
|
+
[WorldStateMessageType.GET_STATUS]: void;
|
|
251
|
+
|
|
252
|
+
[WorldStateMessageType.CLOSE]: void;
|
|
190
253
|
};
|
|
191
254
|
|
|
192
255
|
export type WorldStateResponse = {
|
|
193
256
|
[WorldStateMessageType.GET_TREE_INFO]: GetTreeInfoResponse;
|
|
194
257
|
[WorldStateMessageType.GET_STATE_REFERENCE]: GetStateReferenceResponse;
|
|
258
|
+
[WorldStateMessageType.GET_INITIAL_STATE_REFERENCE]: GetStateReferenceResponse;
|
|
195
259
|
|
|
196
260
|
[WorldStateMessageType.GET_LEAF_VALUE]: GetLeafResponse;
|
|
197
261
|
[WorldStateMessageType.GET_LEAF_PREIMAGE]: GetLeafPreImageResponse;
|
|
@@ -209,21 +273,34 @@ export type WorldStateResponse = {
|
|
|
209
273
|
[WorldStateMessageType.ROLLBACK]: void;
|
|
210
274
|
|
|
211
275
|
[WorldStateMessageType.SYNC_BLOCK]: SyncBlockResponse;
|
|
276
|
+
|
|
277
|
+
[WorldStateMessageType.CREATE_FORK]: CreateForkResponse;
|
|
278
|
+
[WorldStateMessageType.DELETE_FORK]: void;
|
|
279
|
+
|
|
280
|
+
[WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS]: WorldStateStatus;
|
|
281
|
+
[WorldStateMessageType.UNWIND_BLOCKS]: WorldStateStatus;
|
|
282
|
+
[WorldStateMessageType.FINALISE_BLOCKS]: WorldStateStatus;
|
|
283
|
+
|
|
284
|
+
[WorldStateMessageType.GET_STATUS]: WorldStateStatus;
|
|
285
|
+
|
|
286
|
+
[WorldStateMessageType.CLOSE]: void;
|
|
212
287
|
};
|
|
213
288
|
|
|
214
|
-
export type WorldStateRevision =
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
289
|
+
export type WorldStateRevision = {
|
|
290
|
+
forkId: number;
|
|
291
|
+
blockNumber: number;
|
|
292
|
+
includeUncommitted: boolean;
|
|
293
|
+
};
|
|
294
|
+
export function worldStateRevision(
|
|
295
|
+
includeUncommitted: boolean,
|
|
296
|
+
forkId: number | undefined,
|
|
297
|
+
blockNumber: number | undefined,
|
|
298
|
+
): WorldStateRevision {
|
|
299
|
+
return {
|
|
300
|
+
forkId: forkId ?? 0,
|
|
301
|
+
blockNumber: blockNumber ?? 0,
|
|
302
|
+
includeUncommitted,
|
|
303
|
+
};
|
|
227
304
|
}
|
|
228
305
|
|
|
229
306
|
type TreeStateReference = readonly [Buffer, number | bigint];
|