@aztec/world-state 0.0.1-commit.9b94fc1 → 0.0.1-commit.a072138
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 +1 -1
- package/dest/instrumentation/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation/instrumentation.js +17 -41
- package/dest/native/merkle_trees_facade.d.ts +10 -4
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +37 -7
- package/dest/native/message.d.ts +14 -12
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +14 -13
- package/dest/native/native_world_state.d.ts +16 -13
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +22 -17
- package/dest/native/native_world_state_instance.d.ts +3 -3
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +3 -3
- package/dest/synchronizer/config.d.ts +1 -3
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +1 -6
- package/dest/synchronizer/factory.d.ts +4 -3
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +5 -5
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +10 -16
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +84 -72
- package/dest/test/utils.d.ts +12 -5
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +54 -50
- package/dest/testing.d.ts +2 -2
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +1 -1
- package/dest/world-state-db/merkle_tree_db.d.ts +10 -11
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/instrumentation/instrumentation.ts +17 -41
- package/src/native/merkle_trees_facade.ts +39 -5
- package/src/native/message.ts +25 -23
- package/src/native/native_world_state.ts +52 -28
- package/src/native/native_world_state_instance.ts +5 -3
- package/src/synchronizer/config.ts +1 -14
- package/src/synchronizer/factory.ts +7 -1
- package/src/synchronizer/server_world_state_synchronizer.ts +98 -98
- package/src/test/utils.ts +86 -91
- package/src/testing.ts +1 -1
- package/src/world-state-db/merkle_tree_db.ts +13 -14
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH, INITIAL_L2_BLOCK_NUM, INITIAL_L2_CHECKPOINT_NUM } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
5
5
|
import { elapsed } from '@aztec/foundation/timer';
|
|
6
|
-
import {
|
|
6
|
+
import { GENESIS_CHECKPOINT_HEADER_HASH, L2BlockStream } from '@aztec/stdlib/block';
|
|
7
7
|
import { WorldStateRunningState } from '@aztec/stdlib/interfaces/server';
|
|
8
8
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
9
|
-
import {
|
|
9
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
10
10
|
import { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
|
|
11
11
|
import { WorldStateSynchronizerError } from './errors.js';
|
|
12
12
|
/**
|
|
@@ -23,7 +23,6 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
23
23
|
latestBlockNumberAtStart;
|
|
24
24
|
historyToKeep;
|
|
25
25
|
currentState;
|
|
26
|
-
latestBlockHashQuery;
|
|
27
26
|
syncPromise;
|
|
28
27
|
blockStream;
|
|
29
28
|
// WorldState doesn't track the proven block number, it only tracks the latest tips of the pending chain and the finalized chain
|
|
@@ -35,9 +34,8 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
35
34
|
this.config = config;
|
|
36
35
|
this.instrumentation = instrumentation;
|
|
37
36
|
this.log = log;
|
|
38
|
-
this.latestBlockNumberAtStart =
|
|
37
|
+
this.latestBlockNumberAtStart = BlockNumber.ZERO;
|
|
39
38
|
this.currentState = WorldStateRunningState.IDLE;
|
|
40
|
-
this.latestBlockHashQuery = undefined;
|
|
41
39
|
this.syncPromise = promiseWithResolvers();
|
|
42
40
|
this.merkleTreeCommitted = this.merkleTreeDb.getCommitted();
|
|
43
41
|
this.historyToKeep = config.worldStateBlockHistory < 1 ? undefined : config.worldStateBlockHistory;
|
|
@@ -49,8 +47,8 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
49
47
|
getSnapshot(blockNumber) {
|
|
50
48
|
return this.merkleTreeDb.getSnapshot(blockNumber);
|
|
51
49
|
}
|
|
52
|
-
fork(blockNumber) {
|
|
53
|
-
return this.merkleTreeDb.fork(blockNumber);
|
|
50
|
+
fork(blockNumber, opts) {
|
|
51
|
+
return this.merkleTreeDb.fork(blockNumber, opts);
|
|
54
52
|
}
|
|
55
53
|
backupTo(dstPath, compact) {
|
|
56
54
|
return this.merkleTreeDb.backupTo(dstPath, compact);
|
|
@@ -66,7 +64,7 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
66
64
|
return this.syncPromise;
|
|
67
65
|
}
|
|
68
66
|
// Get the current latest block number
|
|
69
|
-
this.latestBlockNumberAtStart = await
|
|
67
|
+
this.latestBlockNumberAtStart = BlockNumber(await this.l2BlockSource.getBlockNumber());
|
|
70
68
|
const blockToDownloadFrom = await this.getLatestBlockNumber() + 1;
|
|
71
69
|
if (blockToDownloadFrom <= this.latestBlockNumberAtStart) {
|
|
72
70
|
// If there are blocks to be retrieved, go to a synching state
|
|
@@ -84,12 +82,11 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
84
82
|
return this.syncPromise.promise;
|
|
85
83
|
}
|
|
86
84
|
createBlockStream() {
|
|
87
|
-
const tracer = this.instrumentation.telemetry.getTracer('WorldStateL2BlockStream');
|
|
88
85
|
const logger = createLogger('world-state:block_stream');
|
|
89
|
-
return new
|
|
90
|
-
proven: this.config.worldStateProvenBlocksOnly,
|
|
86
|
+
return new L2BlockStream(this.l2BlockSource, this, this, logger, {
|
|
91
87
|
pollIntervalMS: this.config.worldStateBlockCheckIntervalMS,
|
|
92
|
-
batchSize: this.config.worldStateBlockRequestBatchSize
|
|
88
|
+
batchSize: this.config.worldStateBlockRequestBatchSize,
|
|
89
|
+
ignoreCheckpoints: true
|
|
93
90
|
});
|
|
94
91
|
}
|
|
95
92
|
async stop() {
|
|
@@ -103,10 +100,10 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
103
100
|
async status() {
|
|
104
101
|
const summary = await this.merkleTreeDb.getStatusSummary();
|
|
105
102
|
const status = {
|
|
106
|
-
latestBlockNumber:
|
|
107
|
-
latestBlockHash: await this.getL2BlockHash(
|
|
108
|
-
finalizedBlockNumber:
|
|
109
|
-
oldestHistoricBlockNumber:
|
|
103
|
+
latestBlockNumber: summary.unfinalizedBlockNumber,
|
|
104
|
+
latestBlockHash: await this.getL2BlockHash(summary.unfinalizedBlockNumber) ?? '',
|
|
105
|
+
finalizedBlockNumber: summary.finalizedBlockNumber,
|
|
106
|
+
oldestHistoricBlockNumber: summary.oldestHistoricalBlock,
|
|
110
107
|
treesAreSynched: summary.treesAreSynched
|
|
111
108
|
};
|
|
112
109
|
return {
|
|
@@ -115,7 +112,7 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
115
112
|
};
|
|
116
113
|
}
|
|
117
114
|
async getLatestBlockNumber() {
|
|
118
|
-
return (await this.getL2Tips()).
|
|
115
|
+
return (await this.getL2Tips()).proposed.number;
|
|
119
116
|
}
|
|
120
117
|
async stopSync() {
|
|
121
118
|
this.log.debug('Stopping sync...');
|
|
@@ -150,7 +147,7 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
150
147
|
this.log.debug(`World State at ${currentBlockNumber} told to sync to ${targetBlockNumber ?? 'latest'}`);
|
|
151
148
|
// If the archiver is behind the target block, force an archiver sync
|
|
152
149
|
if (targetBlockNumber) {
|
|
153
|
-
const archiverLatestBlock = await this.l2BlockSource.getBlockNumber();
|
|
150
|
+
const archiverLatestBlock = BlockNumber(await this.l2BlockSource.getBlockNumber());
|
|
154
151
|
if (archiverLatestBlock < targetBlockNumber) {
|
|
155
152
|
this.log.debug(`Archiver is at ${archiverLatestBlock} behind target block ${targetBlockNumber}.`);
|
|
156
153
|
await this.l2BlockSource.syncImmediate();
|
|
@@ -173,40 +170,68 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
173
170
|
return updatedBlockNumber;
|
|
174
171
|
}
|
|
175
172
|
/** Returns the L2 block hash for a given number. Used by the L2BlockStream for detecting reorgs. */ async getL2BlockHash(number) {
|
|
176
|
-
if (number ===
|
|
173
|
+
if (number === BlockNumber.ZERO) {
|
|
177
174
|
return (await this.merkleTreeCommitted.getInitialHeader().hash()).toString();
|
|
178
175
|
}
|
|
179
|
-
|
|
180
|
-
this.latestBlockHashQuery = {
|
|
181
|
-
hash: await this.merkleTreeCommitted.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(number)).then((leaf)=>leaf?.toString()),
|
|
182
|
-
blockNumber: number
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
return this.latestBlockHashQuery.hash;
|
|
176
|
+
return this.merkleTreeCommitted.getLeafValue(MerkleTreeId.ARCHIVE, BigInt(number)).then((leaf)=>leaf?.toString());
|
|
186
177
|
}
|
|
187
178
|
/** Returns the latest L2 block number for each tip of the chain (latest, proven, finalized). */ async getL2Tips() {
|
|
188
179
|
const status = await this.merkleTreeDb.getStatusSummary();
|
|
189
|
-
const
|
|
180
|
+
const unfinalizedBlockHashPromise = this.getL2BlockHash(status.unfinalizedBlockNumber);
|
|
181
|
+
const finalizedBlockHashPromise = this.getL2BlockHash(status.finalizedBlockNumber);
|
|
182
|
+
const provenBlockNumber = this.provenBlockNumber ?? status.finalizedBlockNumber;
|
|
183
|
+
const provenBlockHashPromise = this.provenBlockNumber === undefined ? finalizedBlockHashPromise : this.getL2BlockHash(this.provenBlockNumber);
|
|
184
|
+
const [unfinalizedBlockHash, finalizedBlockHash, provenBlockHash] = await Promise.all([
|
|
185
|
+
unfinalizedBlockHashPromise,
|
|
186
|
+
finalizedBlockHashPromise,
|
|
187
|
+
provenBlockHashPromise
|
|
188
|
+
]);
|
|
190
189
|
const latestBlockId = {
|
|
191
|
-
number:
|
|
190
|
+
number: status.unfinalizedBlockNumber,
|
|
192
191
|
hash: unfinalizedBlockHash
|
|
193
192
|
};
|
|
193
|
+
// World state doesn't track checkpointed blocks or checkpoints themselves.
|
|
194
|
+
// but we use a block stream so we need to provide 'local' L2Tips.
|
|
195
|
+
// We configure the block stream to ignore checkpoints and set checkpoint values to genesis here.
|
|
196
|
+
const genesisCheckpointHeaderHash = GENESIS_CHECKPOINT_HEADER_HASH.toString();
|
|
194
197
|
return {
|
|
195
|
-
|
|
198
|
+
proposed: latestBlockId,
|
|
199
|
+
checkpointed: {
|
|
200
|
+
block: {
|
|
201
|
+
number: INITIAL_L2_BLOCK_NUM,
|
|
202
|
+
hash: GENESIS_BLOCK_HEADER_HASH.toString()
|
|
203
|
+
},
|
|
204
|
+
checkpoint: {
|
|
205
|
+
number: INITIAL_L2_CHECKPOINT_NUM,
|
|
206
|
+
hash: genesisCheckpointHeaderHash
|
|
207
|
+
}
|
|
208
|
+
},
|
|
196
209
|
finalized: {
|
|
197
|
-
|
|
198
|
-
|
|
210
|
+
block: {
|
|
211
|
+
number: status.finalizedBlockNumber,
|
|
212
|
+
hash: finalizedBlockHash ?? ''
|
|
213
|
+
},
|
|
214
|
+
checkpoint: {
|
|
215
|
+
number: INITIAL_L2_CHECKPOINT_NUM,
|
|
216
|
+
hash: genesisCheckpointHeaderHash
|
|
217
|
+
}
|
|
199
218
|
},
|
|
200
219
|
proven: {
|
|
201
|
-
|
|
202
|
-
|
|
220
|
+
block: {
|
|
221
|
+
number: provenBlockNumber,
|
|
222
|
+
hash: provenBlockHash ?? ''
|
|
223
|
+
},
|
|
224
|
+
checkpoint: {
|
|
225
|
+
number: INITIAL_L2_CHECKPOINT_NUM,
|
|
226
|
+
hash: genesisCheckpointHeaderHash
|
|
227
|
+
}
|
|
203
228
|
}
|
|
204
229
|
};
|
|
205
230
|
}
|
|
206
231
|
/** Handles an event emitted by the block stream. */ async handleBlockStreamEvent(event) {
|
|
207
232
|
switch(event.type){
|
|
208
233
|
case 'blocks-added':
|
|
209
|
-
await this.handleL2Blocks(event.blocks
|
|
234
|
+
await this.handleL2Blocks(event.blocks);
|
|
210
235
|
break;
|
|
211
236
|
case 'chain-pruned':
|
|
212
237
|
await this.handleChainPruned(event.block.number);
|
|
@@ -224,19 +249,23 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
224
249
|
* @param l2Blocks - The L2 blocks to handle.
|
|
225
250
|
* @returns Whether the block handled was produced by this same node.
|
|
226
251
|
*/ async handleL2Blocks(l2Blocks) {
|
|
227
|
-
this.log.
|
|
228
|
-
|
|
229
|
-
const
|
|
252
|
+
this.log.debug(`Handling L2 blocks ${l2Blocks[0].number} to ${l2Blocks.at(-1).number}`);
|
|
253
|
+
// Fetch the L1->L2 messages for the first block in a checkpoint.
|
|
254
|
+
const messagesForBlocks = new Map();
|
|
255
|
+
await Promise.all(l2Blocks.filter((b)=>b.indexWithinCheckpoint === 0).map(async (block)=>{
|
|
256
|
+
const l1ToL2Messages = await this.l2BlockSource.getL1ToL2Messages(block.checkpointNumber);
|
|
257
|
+
messagesForBlocks.set(block.number, l1ToL2Messages);
|
|
258
|
+
}));
|
|
230
259
|
let updateStatus = undefined;
|
|
231
|
-
for(
|
|
232
|
-
const [duration, result] = await elapsed(()=>this.handleL2Block(
|
|
233
|
-
this.log.info(`World state updated with L2 block ${
|
|
260
|
+
for (const block of l2Blocks){
|
|
261
|
+
const [duration, result] = await elapsed(()=>this.handleL2Block(block, messagesForBlocks.get(block.number) ?? []));
|
|
262
|
+
this.log.info(`World state updated with L2 block ${block.number}`, {
|
|
234
263
|
eventName: 'l2-block-handled',
|
|
235
264
|
duration,
|
|
236
|
-
unfinalizedBlockNumber: result.summary.unfinalizedBlockNumber,
|
|
237
|
-
finalizedBlockNumber: result.summary.finalizedBlockNumber,
|
|
238
|
-
oldestHistoricBlock: result.summary.oldestHistoricalBlock,
|
|
239
|
-
...
|
|
265
|
+
unfinalizedBlockNumber: BigInt(result.summary.unfinalizedBlockNumber),
|
|
266
|
+
finalizedBlockNumber: BigInt(result.summary.finalizedBlockNumber),
|
|
267
|
+
oldestHistoricBlock: BigInt(result.summary.oldestHistoricalBlock),
|
|
268
|
+
...block.getStats()
|
|
240
269
|
});
|
|
241
270
|
updateStatus = result;
|
|
242
271
|
}
|
|
@@ -251,16 +280,12 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
251
280
|
* @param l1ToL2Messages - The L1 to L2 messages for the block.
|
|
252
281
|
* @returns Whether the block handled was produced by this same node.
|
|
253
282
|
*/ async handleL2Block(l2Block, l1ToL2Messages) {
|
|
254
|
-
|
|
255
|
-
// Note that we cannot optimize this check by checking the root of the subtree after inserting the messages
|
|
256
|
-
// to the real L1_TO_L2_MESSAGE_TREE (like we do in merkleTreeDb.handleL2BlockAndMessages(...)) because that
|
|
257
|
-
// tree uses pedersen and we don't have access to the converted root.
|
|
258
|
-
await this.verifyMessagesHashToInHash(l1ToL2Messages, l2Block.header.contentCommitment.inHash);
|
|
259
|
-
// If the above check succeeds, we can proceed to handle the block.
|
|
260
|
-
this.log.trace(`Pushing L2 block ${l2Block.number} to merkle tree db `, {
|
|
283
|
+
this.log.debug(`Pushing L2 block ${l2Block.number} to merkle tree db `, {
|
|
261
284
|
blockNumber: l2Block.number,
|
|
262
285
|
blockHash: await l2Block.hash().then((h)=>h.toString()),
|
|
263
|
-
l1ToL2Messages: l1ToL2Messages.map((msg)=>msg.toString())
|
|
286
|
+
l1ToL2Messages: l1ToL2Messages.map((msg)=>msg.toString()),
|
|
287
|
+
blockHeader: l2Block.header.toInspect(),
|
|
288
|
+
blockStats: l2Block.getStats()
|
|
264
289
|
});
|
|
265
290
|
const result = await this.merkleTreeDb.handleL2BlockAndMessages(l2Block, l1ToL2Messages);
|
|
266
291
|
if (this.currentState === WorldStateRunningState.SYNCHING && l2Block.number >= this.latestBlockNumberAtStart) {
|
|
@@ -271,27 +296,26 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
271
296
|
}
|
|
272
297
|
async handleChainFinalized(blockNumber) {
|
|
273
298
|
this.log.verbose(`Finalized chain is now at block ${blockNumber}`);
|
|
274
|
-
const summary = await this.merkleTreeDb.setFinalized(
|
|
299
|
+
const summary = await this.merkleTreeDb.setFinalized(blockNumber);
|
|
275
300
|
if (this.historyToKeep === undefined) {
|
|
276
301
|
return;
|
|
277
302
|
}
|
|
278
|
-
const newHistoricBlock = summary.finalizedBlockNumber -
|
|
303
|
+
const newHistoricBlock = summary.finalizedBlockNumber - this.historyToKeep + 1;
|
|
279
304
|
if (newHistoricBlock <= 1) {
|
|
280
305
|
return;
|
|
281
306
|
}
|
|
282
307
|
this.log.verbose(`Pruning historic blocks to ${newHistoricBlock}`);
|
|
283
|
-
const status = await this.merkleTreeDb.removeHistoricalBlocks(newHistoricBlock);
|
|
308
|
+
const status = await this.merkleTreeDb.removeHistoricalBlocks(BlockNumber(newHistoricBlock));
|
|
284
309
|
this.log.debug(`World state summary `, status.summary);
|
|
285
310
|
}
|
|
286
311
|
handleChainProven(blockNumber) {
|
|
287
|
-
this.provenBlockNumber =
|
|
312
|
+
this.provenBlockNumber = blockNumber;
|
|
288
313
|
this.log.debug(`Proven chain is now at block ${blockNumber}`);
|
|
289
314
|
return Promise.resolve();
|
|
290
315
|
}
|
|
291
316
|
async handleChainPruned(blockNumber) {
|
|
292
317
|
this.log.warn(`Chain pruned to block ${blockNumber}`);
|
|
293
|
-
const status = await this.merkleTreeDb.unwindBlocks(
|
|
294
|
-
this.latestBlockHashQuery = undefined;
|
|
318
|
+
const status = await this.merkleTreeDb.unwindBlocks(blockNumber);
|
|
295
319
|
this.provenBlockNumber = undefined;
|
|
296
320
|
this.instrumentation.updateWorldStateMetrics(status);
|
|
297
321
|
}
|
|
@@ -302,16 +326,4 @@ import { WorldStateSynchronizerError } from './errors.js';
|
|
|
302
326
|
this.currentState = newState;
|
|
303
327
|
this.log.debug(`Moved to state ${WorldStateRunningState[this.currentState]}`);
|
|
304
328
|
}
|
|
305
|
-
/**
|
|
306
|
-
* Verifies that the L1 to L2 messages hash to the block inHash.
|
|
307
|
-
* @param l1ToL2Messages - The L1 to L2 messages for the block.
|
|
308
|
-
* @param inHash - The inHash of the block.
|
|
309
|
-
* @throws If the L1 to L2 messages do not hash to the block inHash.
|
|
310
|
-
*/ async verifyMessagesHashToInHash(l1ToL2Messages, inHash) {
|
|
311
|
-
const treeCalculator = await MerkleTreeCalculator.create(L1_TO_L2_MSG_SUBTREE_HEIGHT, Buffer.alloc(32), (lhs, rhs)=>Promise.resolve(new SHA256Trunc().hash(lhs, rhs)));
|
|
312
|
-
const root = await treeCalculator.computeTreeRoot(l1ToL2Messages.map((msg)=>msg.toBuffer()));
|
|
313
|
-
if (!root.equals(inHash.toBuffer())) {
|
|
314
|
-
throw new Error('Obtained L1 to L2 messages failed to be hashed to the block inHash');
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
329
|
}
|
package/dest/test/utils.d.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber, type CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { L2Block } from '@aztec/stdlib/block';
|
|
3
4
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
import { mockCheckpointAndMessages } from '@aztec/stdlib/testing';
|
|
4
6
|
import type { NativeWorldStateService } from '../native/native_world_state.js';
|
|
5
|
-
export declare function
|
|
7
|
+
export declare function updateBlockState(block: L2Block, l1ToL2Messages: Fr[], fork: MerkleTreeWriteOperations): Promise<void>;
|
|
8
|
+
export declare function mockBlock(blockNum: BlockNumber, size: number, fork: MerkleTreeWriteOperations, maxEffects?: number | undefined, numL1ToL2Messages?: number, isFirstBlockInCheckpoint?: boolean): Promise<{
|
|
6
9
|
block: L2Block;
|
|
7
10
|
messages: Fr[];
|
|
8
11
|
}>;
|
|
9
|
-
export declare function mockEmptyBlock(blockNum:
|
|
12
|
+
export declare function mockEmptyBlock(blockNum: BlockNumber, fork: MerkleTreeWriteOperations): Promise<{
|
|
10
13
|
block: L2Block;
|
|
11
14
|
messages: Fr[];
|
|
12
15
|
}>;
|
|
13
|
-
export declare function mockBlocks(from:
|
|
16
|
+
export declare function mockBlocks(from: BlockNumber, count: number, numTxs: number, worldState: NativeWorldStateService): Promise<{
|
|
14
17
|
blocks: L2Block[];
|
|
15
18
|
messages: Fr[][];
|
|
16
19
|
}>;
|
|
20
|
+
export declare function mockCheckpoint(checkpointNumber: CheckpointNumber, fork: MerkleTreeWriteOperations, options?: Partial<Parameters<typeof mockCheckpointAndMessages>[1]>): Promise<{
|
|
21
|
+
checkpoint: import("@aztec/stdlib/checkpoint").Checkpoint;
|
|
22
|
+
messages: Fr[];
|
|
23
|
+
}>;
|
|
17
24
|
export declare function assertSameState(forkA: MerkleTreeReadOperations, forkB: MerkleTreeReadOperations): Promise<void>;
|
|
18
25
|
export declare function compareChains(left: MerkleTreeReadOperations, right: MerkleTreeReadOperations): Promise<void>;
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
26
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sRUFBRSxXQUFXLEVBQUUsS0FBSyxnQkFBZ0IsRUFBeUIsTUFBTSxpQ0FBaUMs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xDQUFDLFVBQVUsQ0FBQyxPQUFPLHlCQUF5QixDQUFDLENBQUMsQ0FBQyxDQUFDLENBQU07OztHQU92RTtBQUVELHdCQUFzQixlQUFlLENBQUMsS0FBSyxFQUFFLHdCQUF3QixFQUFFLEtBQUssRUFBRSx3QkFBd0IsaUJBUXJHO0FBRUQsd0JBQXNCLGFBQWEsQ0FBQyxJQUFJLEVBQUUsd0JBQXdCLEVBQUUsS0FBSyxFQUFFLHdCQUF3QixpQkFZbEcifQ==
|
package/dest/test/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAyB,MAAM,iCAAiC,CAAC;AAE5G,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAEV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAsB,MAAM,uBAAuB,CAAC;AAItF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE/E,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,yBAAyB,iBA8C3G;AAED,wBAAsB,SAAS,CAC7B,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,yBAAyB,EAC/B,UAAU,GAAE,MAAM,GAAG,SAAgB,EACrC,iBAAiB,GAAE,MAA4C,EAC/D,wBAAwB,GAAE,OAAc;;;GAezC;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,yBAAyB;;;GAY1F;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,uBAAuB;;;GAepC;AAED,wBAAsB,cAAc,CAClC,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,yBAAyB,EAC/B,OAAO,GAAE,OAAO,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAM;;;GAOvE;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,wBAAwB,iBAQrG;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,wBAAwB,iBAYlG"}
|
package/dest/test/utils.js
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { asyncMap } from '@aztec/foundation/async-map';
|
|
3
|
+
import { BlockNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
2
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
6
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
|
+
import { mockCheckpointAndMessages, mockL1ToL2Messages } from '@aztec/stdlib/testing';
|
|
5
8
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
messageInsert
|
|
26
|
-
]);
|
|
27
|
-
}
|
|
9
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
10
|
+
export async function updateBlockState(block, l1ToL2Messages, fork) {
|
|
11
|
+
const insertData = async (treeId, data, subTreeHeight, fork)=>{
|
|
12
|
+
for (const dataBatch of data){
|
|
13
|
+
await fork.batchInsert(treeId, dataBatch, subTreeHeight);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const publicDataInsert = insertData(MerkleTreeId.PUBLIC_DATA_TREE, block.body.txEffects.map((txEffect)=>txEffect.publicDataWrites.map((write)=>write.toBuffer())), 0, fork);
|
|
17
|
+
const nullifierInsert = insertData(MerkleTreeId.NULLIFIER_TREE, block.body.txEffects.map((txEffect)=>padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((nullifier)=>nullifier.toBuffer())), NULLIFIER_SUBTREE_HEIGHT, fork);
|
|
18
|
+
const noteHashesPadded = block.body.txEffects.flatMap((txEffect)=>padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
|
|
19
|
+
const l1ToL2MessagesPadded = block.indexWithinCheckpoint === 0 ? padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) : l1ToL2Messages;
|
|
20
|
+
const noteHashInsert = fork.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, noteHashesPadded);
|
|
21
|
+
const messageInsert = fork.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
|
|
22
|
+
await Promise.all([
|
|
23
|
+
publicDataInsert,
|
|
24
|
+
nullifierInsert,
|
|
25
|
+
noteHashInsert,
|
|
26
|
+
messageInsert
|
|
27
|
+
]);
|
|
28
28
|
const state = await fork.getStateReference();
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
block.header = BlockHeader.from({
|
|
30
|
+
...block.header,
|
|
31
|
+
state
|
|
32
|
+
});
|
|
33
|
+
await fork.updateArchive(block.header);
|
|
31
34
|
const archiveState = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
32
|
-
|
|
35
|
+
block.archive = new AppendOnlyTreeSnapshot(Fr.fromBuffer(archiveState.root), Number(archiveState.size));
|
|
36
|
+
}
|
|
37
|
+
export async function mockBlock(blockNum, size, fork, maxEffects = 1000, numL1ToL2Messages = NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, isFirstBlockInCheckpoint = true) {
|
|
38
|
+
const block = await L2Block.random(blockNum, {
|
|
39
|
+
indexWithinCheckpoint: isFirstBlockInCheckpoint ? IndexWithinCheckpoint(0) : IndexWithinCheckpoint(1),
|
|
40
|
+
txsPerBlock: size,
|
|
41
|
+
txOptions: {
|
|
42
|
+
maxEffects
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const l1ToL2Messages = mockL1ToL2Messages(numL1ToL2Messages);
|
|
46
|
+
await updateBlockState(block, l1ToL2Messages, fork);
|
|
33
47
|
return {
|
|
34
|
-
block
|
|
48
|
+
block,
|
|
35
49
|
messages: l1ToL2Messages
|
|
36
50
|
};
|
|
37
51
|
}
|
|
@@ -39,38 +53,18 @@ export async function mockEmptyBlock(blockNum, fork) {
|
|
|
39
53
|
const l2Block = L2Block.empty();
|
|
40
54
|
const l1ToL2Messages = Array(16).fill(0).map(Fr.zero);
|
|
41
55
|
l2Block.header.globalVariables.blockNumber = blockNum;
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
const noteHashesPadded = l2Block.body.txEffects.flatMap((txEffect)=>padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
|
|
45
|
-
await fork.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, noteHashesPadded);
|
|
46
|
-
const l1ToL2MessagesPadded = padArrayEnd(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
47
|
-
await fork.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2MessagesPadded);
|
|
48
|
-
}
|
|
49
|
-
// Sync the indexed trees
|
|
50
|
-
{
|
|
51
|
-
// We insert the public data tree leaves with one batch per tx to avoid updating the same key twice
|
|
52
|
-
for (const txEffect of l2Block.body.txEffects){
|
|
53
|
-
await fork.batchInsert(MerkleTreeId.PUBLIC_DATA_TREE, txEffect.publicDataWrites.map((write)=>write.toBuffer()), 0);
|
|
54
|
-
const nullifiersPadded = padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX);
|
|
55
|
-
await fork.batchInsert(MerkleTreeId.NULLIFIER_TREE, nullifiersPadded.map((nullifier)=>nullifier.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const state = await fork.getStateReference();
|
|
59
|
-
l2Block.header.state = state;
|
|
60
|
-
await fork.updateArchive(l2Block.getBlockHeader());
|
|
61
|
-
const archiveState = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
62
|
-
l2Block.archive = new AppendOnlyTreeSnapshot(Fr.fromBuffer(archiveState.root), Number(archiveState.size));
|
|
56
|
+
await updateBlockState(l2Block, l1ToL2Messages, fork);
|
|
63
57
|
return {
|
|
64
58
|
block: l2Block,
|
|
65
59
|
messages: l1ToL2Messages
|
|
66
60
|
};
|
|
67
61
|
}
|
|
68
62
|
export async function mockBlocks(from, count, numTxs, worldState) {
|
|
69
|
-
const tempFork = await worldState.fork(from - 1);
|
|
63
|
+
const tempFork = await worldState.fork(BlockNumber(from - 1));
|
|
70
64
|
const blocks = [];
|
|
71
65
|
const messagesArray = [];
|
|
72
66
|
for(let blockNumber = from; blockNumber < from + count; blockNumber++){
|
|
73
|
-
const { block, messages } = await mockBlock(blockNumber, numTxs, tempFork);
|
|
67
|
+
const { block, messages } = await mockBlock(BlockNumber(blockNumber), numTxs, tempFork);
|
|
74
68
|
blocks.push(block);
|
|
75
69
|
messagesArray.push(messages);
|
|
76
70
|
}
|
|
@@ -80,6 +74,16 @@ export async function mockBlocks(from, count, numTxs, worldState) {
|
|
|
80
74
|
messages: messagesArray
|
|
81
75
|
};
|
|
82
76
|
}
|
|
77
|
+
export async function mockCheckpoint(checkpointNumber, fork, options = {}) {
|
|
78
|
+
const { checkpoint, messages } = await mockCheckpointAndMessages(checkpointNumber, options);
|
|
79
|
+
await asyncMap(checkpoint.blocks, async (block, i)=>{
|
|
80
|
+
await updateBlockState(block, i === 0 ? messages : [], fork);
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
checkpoint,
|
|
84
|
+
messages
|
|
85
|
+
};
|
|
86
|
+
}
|
|
83
87
|
export async function assertSameState(forkA, forkB) {
|
|
84
88
|
const nativeStateRef = await forkA.getStateReference();
|
|
85
89
|
const nativeArchive = await forkA.getTreeInfo(MerkleTreeId.ARCHIVE);
|
package/dest/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
4
4
|
export declare const defaultInitialAccountFeeJuice: Fr;
|
|
@@ -7,4 +7,4 @@ export declare function getGenesisValues(initialAccounts: AztecAddress[], initia
|
|
|
7
7
|
prefilledPublicData: PublicDataTreeLeaf[];
|
|
8
8
|
fundingNeeded: bigint;
|
|
9
9
|
}>;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Rlc3RpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sRUFBZ0Isa0JBQWtCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQXlCdkUsZUFBTyxNQUFNLDZCQUE2QixJQUFxQixDQUFDO0FBRWhFLHdCQUFzQixnQkFBZ0IsQ0FDcEMsZUFBZSxFQUFFLFlBQVksRUFBRSxFQUMvQixzQkFBc0IsS0FBZ0MsRUFDdEQsaUJBQWlCLEdBQUUsa0JBQWtCLEVBQU87Ozs7R0FxQjdDIn0=
|
package/dest/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAgB,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAyBvE,eAAO,MAAM,6BAA6B,IAAqB,CAAC;AAEhE,wBAAsB,gBAAgB,CACpC,eAAe,EAAE,YAAY,EAAE,EAC/B,sBAAsB,KAAgC,EACtD,iBAAiB,GAAE,kBAAkB,EAAO;;;;GAqB7C"}
|
package/dest/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
4
4
|
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
5
5
|
import { NativeWorldStateService } from './native/index.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import type { IndexedTreeSnapshot, TreeSnapshot } from '@aztec/merkle-tree';
|
|
3
|
-
import type { L2Block
|
|
4
|
-
import type { ForkMerkleTreeOperations, MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
|
+
import type { ForkMerkleTreeOperations, MerkleTreeReadOperations, ReadonlyWorldStateAccess } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
import type { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
7
|
import type { WorldStateStatusFull, WorldStateStatusSummary } from '../native/message.js';
|
|
7
8
|
/**
|
|
@@ -28,15 +29,13 @@ export type TreeSnapshots = {
|
|
|
28
29
|
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: TreeSnapshot<Fr>;
|
|
29
30
|
[MerkleTreeId.ARCHIVE]: TreeSnapshot<Fr>;
|
|
30
31
|
};
|
|
31
|
-
export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
|
|
32
|
+
export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations, ReadonlyWorldStateAccess {
|
|
32
33
|
/**
|
|
33
34
|
* Handles a single L2 block (i.e. Inserts the new note hashes into the merkle tree).
|
|
34
35
|
* @param block - The L2 block to handle.
|
|
35
36
|
* @param l1ToL2Messages - The L1 to L2 messages for the block.
|
|
36
|
-
* @param isFirstBlock - Whether the block is the first block in a checkpoint. Temporary hack to only insert l1 to l2
|
|
37
|
-
* messages for the first block in a checkpoint. TODO(#17027) Remove this.
|
|
38
37
|
*/
|
|
39
|
-
handleL2BlockAndMessages(block: L2Block
|
|
38
|
+
handleL2BlockAndMessages(block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull>;
|
|
40
39
|
/**
|
|
41
40
|
* Gets a handle that allows reading the latest committed state
|
|
42
41
|
*/
|
|
@@ -46,19 +45,19 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
|
|
|
46
45
|
* @param toBlockNumber The block number of the new oldest historical block
|
|
47
46
|
* @returns The new WorldStateStatus
|
|
48
47
|
*/
|
|
49
|
-
removeHistoricalBlocks(toBlockNumber:
|
|
48
|
+
removeHistoricalBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
|
|
50
49
|
/**
|
|
51
50
|
* Removes all pending blocks down to but not including the given block number
|
|
52
51
|
* @param toBlockNumber The block number of the new tip of the pending chain,
|
|
53
52
|
* @returns The new WorldStateStatus
|
|
54
53
|
*/
|
|
55
|
-
unwindBlocks(toBlockNumber:
|
|
54
|
+
unwindBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
|
|
56
55
|
/**
|
|
57
56
|
* Advances the finalized block number to be the number provided
|
|
58
57
|
* @param toBlockNumber The block number that is now the tip of the finalized chain
|
|
59
58
|
* @returns The new WorldStateStatus
|
|
60
59
|
*/
|
|
61
|
-
setFinalized(toBlockNumber:
|
|
60
|
+
setFinalized(toBlockNumber: BlockNumber): Promise<WorldStateStatusSummary>;
|
|
62
61
|
/**
|
|
63
62
|
* Gets the current status summary of the database.
|
|
64
63
|
* @returns The current WorldStateStatus.
|
|
@@ -69,4 +68,4 @@ export interface MerkleTreeAdminDatabase extends ForkMerkleTreeOperations {
|
|
|
69
68
|
/** Deletes the db. */
|
|
70
69
|
clear(): Promise<void>;
|
|
71
70
|
}
|
|
72
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
71
|
+
//# sourceM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version":3,"file":"merkle_tree_db.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_db.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"merkle_tree_db.d.ts","sourceRoot":"","sources":["../../src/world-state-db/merkle_tree_db.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE1F;;;;;;;;;;;;;;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,EAAE,wBAAwB;IACjG;;;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