@aztec/world-state 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891
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.d.ts +1 -1
- 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/bench_metrics.d.ts +1 -1
- package/dest/native/bench_metrics.d.ts.map +1 -1
- package/dest/native/fork_checkpoint.d.ts +7 -1
- package/dest/native/fork_checkpoint.d.ts.map +1 -1
- package/dest/native/fork_checkpoint.js +15 -3
- package/dest/native/index.d.ts +1 -1
- package/dest/native/merkle_trees_facade.d.ts +15 -9
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +47 -13
- package/dest/native/message.d.ts +25 -15
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +14 -13
- package/dest/native/native_world_state.d.ts +15 -12
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +23 -18
- package/dest/native/native_world_state_instance.d.ts +12 -3
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +25 -4
- package/dest/native/world_state_ops_queue.d.ts +1 -1
- package/dest/native/world_state_ops_queue.d.ts.map +1 -1
- package/dest/synchronizer/config.d.ts +3 -5
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +7 -9
- package/dest/synchronizer/errors.d.ts +1 -1
- package/dest/synchronizer/errors.d.ts.map +1 -1
- package/dest/synchronizer/factory.d.ts +5 -4
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +5 -5
- package/dest/synchronizer/index.d.ts +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +11 -28
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +149 -80
- package/dest/test/index.d.ts +1 -1
- 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/index.d.ts +1 -1
- package/dest/world-state-db/merkle_tree_db.d.ts +9 -19
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/instrumentation/instrumentation.ts +17 -41
- package/src/native/fork_checkpoint.ts +19 -3
- package/src/native/merkle_trees_facade.ts +55 -14
- package/src/native/message.ts +38 -26
- package/src/native/native_world_state.ts +52 -28
- package/src/native/native_world_state_instance.ts +34 -4
- package/src/synchronizer/config.ts +8 -19
- package/src/synchronizer/factory.ts +8 -2
- package/src/synchronizer/server_world_state_synchronizer.ts +176 -105
- package/src/test/utils.ts +87 -92
- package/src/testing.ts +1 -1
- package/src/world-state-db/merkle_tree_db.ts +12 -19
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { fromEntries, padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
6
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
7
8
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
8
|
-
import { DatabaseVersionManager } from '@aztec/stdlib/database-version';
|
|
9
|
+
import { DatabaseVersionManager } from '@aztec/stdlib/database-version/manager';
|
|
9
10
|
import type {
|
|
10
11
|
IndexedTreeId,
|
|
11
12
|
MerkleTreeReadOperations,
|
|
@@ -51,7 +52,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
51
52
|
protected constructor(
|
|
52
53
|
protected instance: NativeWorldState,
|
|
53
54
|
protected readonly worldStateInstrumentation: WorldStateInstrumentation,
|
|
54
|
-
protected readonly log: Logger
|
|
55
|
+
protected readonly log: Logger,
|
|
55
56
|
private readonly cleanup = () => Promise.resolve(),
|
|
56
57
|
) {}
|
|
57
58
|
|
|
@@ -61,9 +62,10 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
61
62
|
wsTreeMapSizes: WorldStateTreeMapSizes,
|
|
62
63
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
63
64
|
instrumentation = new WorldStateInstrumentation(getTelemetryClient()),
|
|
64
|
-
|
|
65
|
+
bindings?: LoggerBindings,
|
|
65
66
|
cleanup = () => Promise.resolve(),
|
|
66
67
|
): Promise<NativeWorldStateService> {
|
|
68
|
+
const log = createLogger('world-state:database', bindings);
|
|
67
69
|
const worldStateDirectory = join(dataDir, WORLD_STATE_DIR);
|
|
68
70
|
// Create a version manager to handle versioning
|
|
69
71
|
const versionManager = new DatabaseVersionManager({
|
|
@@ -71,7 +73,9 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
71
73
|
rollupAddress,
|
|
72
74
|
dataDirectory: worldStateDirectory,
|
|
73
75
|
onOpen: (dir: string) => {
|
|
74
|
-
return Promise.resolve(
|
|
76
|
+
return Promise.resolve(
|
|
77
|
+
new NativeWorldState(dir, wsTreeMapSizes, prefilledPublicData, instrumentation, bindings),
|
|
78
|
+
);
|
|
75
79
|
},
|
|
76
80
|
});
|
|
77
81
|
|
|
@@ -92,8 +96,9 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
92
96
|
cleanupTmpDir = true,
|
|
93
97
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
94
98
|
instrumentation = new WorldStateInstrumentation(getTelemetryClient()),
|
|
99
|
+
bindings?: LoggerBindings,
|
|
95
100
|
): Promise<NativeWorldStateService> {
|
|
96
|
-
const log = createLogger('world-state:database');
|
|
101
|
+
const log = createLogger('world-state:database', bindings);
|
|
97
102
|
const dataDir = await mkdtemp(join(tmpdir(), 'aztec-world-state-'));
|
|
98
103
|
const dbMapSizeKb = 10 * 1024 * 1024;
|
|
99
104
|
const worldStateTreeMapSizes: WorldStateTreeMapSizes = {
|
|
@@ -115,7 +120,15 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
115
120
|
}
|
|
116
121
|
};
|
|
117
122
|
|
|
118
|
-
return this.new(
|
|
123
|
+
return this.new(
|
|
124
|
+
rollupAddress,
|
|
125
|
+
dataDir,
|
|
126
|
+
worldStateTreeMapSizes,
|
|
127
|
+
prefilledPublicData,
|
|
128
|
+
instrumentation,
|
|
129
|
+
bindings,
|
|
130
|
+
cleanup,
|
|
131
|
+
);
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
protected async init() {
|
|
@@ -134,7 +147,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
134
147
|
|
|
135
148
|
// the initial header _must_ be the first element in the archive tree
|
|
136
149
|
// if this assertion fails, check that the hashing done in Header in yarn-project matches the initial header hash done in world_state.cpp
|
|
137
|
-
const indices = await committed.findLeafIndices(MerkleTreeId.ARCHIVE, [await this.initialHeader.hash()]);
|
|
150
|
+
const indices = await committed.findLeafIndices(MerkleTreeId.ARCHIVE, [(await this.initialHeader.hash()).toFr()]);
|
|
138
151
|
const initialHeaderIndex = indices[0];
|
|
139
152
|
assert.strictEqual(initialHeaderIndex, 0n, 'Invalid initial archive state');
|
|
140
153
|
}
|
|
@@ -150,7 +163,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
150
163
|
return new MerkleTreesFacade(this.instance, this.initialHeader!, WorldStateRevision.empty());
|
|
151
164
|
}
|
|
152
165
|
|
|
153
|
-
public getSnapshot(blockNumber:
|
|
166
|
+
public getSnapshot(blockNumber: BlockNumber): MerkleTreeReadOperations {
|
|
154
167
|
return new MerkleTreesFacade(
|
|
155
168
|
this.instance,
|
|
156
169
|
this.initialHeader!,
|
|
@@ -158,16 +171,24 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
158
171
|
);
|
|
159
172
|
}
|
|
160
173
|
|
|
161
|
-
public async fork(
|
|
174
|
+
public async fork(
|
|
175
|
+
blockNumber?: BlockNumber,
|
|
176
|
+
opts: { closeDelayMs?: number } = {},
|
|
177
|
+
): Promise<MerkleTreeWriteOperations> {
|
|
162
178
|
const resp = await this.instance.call(WorldStateMessageType.CREATE_FORK, {
|
|
163
179
|
latest: blockNumber === undefined,
|
|
164
|
-
blockNumber: blockNumber ??
|
|
180
|
+
blockNumber: blockNumber ?? BlockNumber.ZERO,
|
|
165
181
|
canonical: true,
|
|
166
182
|
});
|
|
167
183
|
return new MerkleTreesForkFacade(
|
|
168
184
|
this.instance,
|
|
169
185
|
this.initialHeader!,
|
|
170
|
-
new WorldStateRevision(
|
|
186
|
+
new WorldStateRevision(
|
|
187
|
+
/*forkId=*/ resp.forkId,
|
|
188
|
+
/* blockNumber=*/ BlockNumber.ZERO,
|
|
189
|
+
/* includeUncommitted=*/ true,
|
|
190
|
+
),
|
|
191
|
+
opts,
|
|
171
192
|
);
|
|
172
193
|
}
|
|
173
194
|
|
|
@@ -175,21 +196,24 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
175
196
|
return this.initialHeader!;
|
|
176
197
|
}
|
|
177
198
|
|
|
178
|
-
public async handleL2BlockAndMessages(
|
|
179
|
-
l2Block
|
|
180
|
-
l1ToL2Messages
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
);
|
|
199
|
+
public async handleL2BlockAndMessages(l2Block: L2Block, l1ToL2Messages: Fr[]): Promise<WorldStateStatusFull> {
|
|
200
|
+
const isFirstBlock = l2Block.indexWithinCheckpoint === 0;
|
|
201
|
+
if (!isFirstBlock && l1ToL2Messages.length > 0) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
`L1 to L2 messages must be empty for non-first blocks, but got ${l1ToL2Messages.length} messages for block ${l2Block.number}.`,
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// We have to pad the given l1 to l2 messages, and the note hashes and nullifiers within tx effects, because that's
|
|
208
|
+
// how the trees are built by circuits.
|
|
189
209
|
const paddedL1ToL2Messages = isFirstBlock
|
|
190
210
|
? padArrayEnd<Fr, number>(l1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)
|
|
191
211
|
: [];
|
|
192
212
|
|
|
213
|
+
const paddedNoteHashes = l2Block.body.txEffects.flatMap(txEffect =>
|
|
214
|
+
padArrayEnd(txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
|
|
215
|
+
);
|
|
216
|
+
|
|
193
217
|
const paddedNullifiers = l2Block.body.txEffects
|
|
194
218
|
.flatMap(txEffect => padArrayEnd(txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX))
|
|
195
219
|
.map(nullifier => new NullifierLeaf(nullifier));
|
|
@@ -208,7 +232,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
208
232
|
WorldStateMessageType.SYNC_BLOCK,
|
|
209
233
|
{
|
|
210
234
|
blockNumber: l2Block.number,
|
|
211
|
-
blockHeaderHash: await l2Block.
|
|
235
|
+
blockHeaderHash: await l2Block.hash(),
|
|
212
236
|
paddedL1ToL2Messages: paddedL1ToL2Messages.map(serializeLeaf),
|
|
213
237
|
paddedNoteHashes: paddedNoteHashes.map(serializeLeaf),
|
|
214
238
|
paddedNullifiers: paddedNullifiers.map(serializeLeaf),
|
|
@@ -256,7 +280,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
256
280
|
* @param toBlockNumber The block number that is now the tip of the finalized chain
|
|
257
281
|
* @returns The new WorldStateStatus
|
|
258
282
|
*/
|
|
259
|
-
public async setFinalized(toBlockNumber:
|
|
283
|
+
public async setFinalized(toBlockNumber: BlockNumber) {
|
|
260
284
|
try {
|
|
261
285
|
await this.instance.call(
|
|
262
286
|
WorldStateMessageType.FINALIZE_BLOCKS,
|
|
@@ -279,7 +303,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
279
303
|
* @param toBlockNumber The block number of the new oldest historical block
|
|
280
304
|
* @returns The new WorldStateStatus
|
|
281
305
|
*/
|
|
282
|
-
public async removeHistoricalBlocks(toBlockNumber:
|
|
306
|
+
public async removeHistoricalBlocks(toBlockNumber: BlockNumber) {
|
|
283
307
|
try {
|
|
284
308
|
return await this.instance.call(
|
|
285
309
|
WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS,
|
|
@@ -301,7 +325,7 @@ export class NativeWorldStateService implements MerkleTreeDatabase {
|
|
|
301
325
|
* @param toBlockNumber The block number of the new tip of the pending chain,
|
|
302
326
|
* @returns The new WorldStateStatus
|
|
303
327
|
*/
|
|
304
|
-
public async unwindBlocks(toBlockNumber:
|
|
328
|
+
public async unwindBlocks(toBlockNumber: BlockNumber) {
|
|
305
329
|
try {
|
|
306
330
|
return await this.instance.call(
|
|
307
331
|
WorldStateMessageType.UNWIND_BLOCKS,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARCHIVE_HEIGHT,
|
|
3
|
-
|
|
3
|
+
DomainSeparator,
|
|
4
4
|
L1_TO_L2_MSG_TREE_HEIGHT,
|
|
5
5
|
MAX_NULLIFIERS_PER_TX,
|
|
6
6
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
NULLIFIER_TREE_HEIGHT,
|
|
9
9
|
PUBLIC_DATA_TREE_HEIGHT,
|
|
10
10
|
} from '@aztec/constants';
|
|
11
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
11
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
12
12
|
import { NativeWorldState as BaseNativeWorldState, MsgpackChannel } from '@aztec/native';
|
|
13
13
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
14
14
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
@@ -36,6 +36,8 @@ export interface NativeWorldStateInstance {
|
|
|
36
36
|
messageType: T,
|
|
37
37
|
body: WorldStateRequest[T] & WorldStateRequestCategories,
|
|
38
38
|
): Promise<WorldStateResponse[T]>;
|
|
39
|
+
// TODO(dbanks12): this returns any type, but we should strongly type it
|
|
40
|
+
getHandle(): any;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
@@ -55,7 +57,8 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
55
57
|
private readonly wsTreeMapSizes: WorldStateTreeMapSizes,
|
|
56
58
|
private readonly prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
57
59
|
private readonly instrumentation: WorldStateInstrumentation,
|
|
58
|
-
|
|
60
|
+
bindings?: LoggerBindings,
|
|
61
|
+
private readonly log: Logger = createLogger('world-state:database', bindings),
|
|
59
62
|
) {
|
|
60
63
|
const threads = Math.min(cpus().length, MAX_WORLD_STATE_THREADS);
|
|
61
64
|
log.info(
|
|
@@ -78,7 +81,7 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
78
81
|
[MerkleTreeId.PUBLIC_DATA_TREE]: 2 * MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
79
82
|
},
|
|
80
83
|
prefilledPublicDataBufferArray,
|
|
81
|
-
|
|
84
|
+
DomainSeparator.BLOCK_HEADER_HASH,
|
|
82
85
|
{
|
|
83
86
|
[MerkleTreeId.NULLIFIER_TREE]: wsTreeMapSizes.nullifierTreeMapSizeKb,
|
|
84
87
|
[MerkleTreeId.NOTE_HASH_TREE]: wsTreeMapSizes.noteHashTreeMapSizeKb,
|
|
@@ -103,10 +106,37 @@ export class NativeWorldState implements NativeWorldStateInstance {
|
|
|
103
106
|
this.wsTreeMapSizes,
|
|
104
107
|
this.prefilledPublicData,
|
|
105
108
|
this.instrumentation,
|
|
109
|
+
this.log.getBindings(),
|
|
106
110
|
this.log,
|
|
107
111
|
);
|
|
108
112
|
}
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Gets the native WorldState handle from the underlying native instance.
|
|
116
|
+
* We call the getHandle() method on the native WorldState to get a NAPI External
|
|
117
|
+
* that wraps the underlying C++ WorldState pointer.
|
|
118
|
+
* @returns The NAPI External handle to the native WorldState instance,since
|
|
119
|
+
* the NAPI external type is opaque, we return any (we could also use an opaque symbol type)
|
|
120
|
+
*/
|
|
121
|
+
public getHandle(): any {
|
|
122
|
+
const worldStateWrapper = (this.instance as any).dest;
|
|
123
|
+
|
|
124
|
+
if (!worldStateWrapper) {
|
|
125
|
+
throw new Error('No WorldStateWrapper found');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (typeof worldStateWrapper.getHandle !== 'function') {
|
|
129
|
+
throw new Error('WorldStateWrapper does not have getHandle method');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Call getHandle() to get the NAPI External
|
|
133
|
+
try {
|
|
134
|
+
return worldStateWrapper.getHandle();
|
|
135
|
+
} catch (error) {
|
|
136
|
+
this.log.error('Failed to get native WorldState handle', error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
110
140
|
/**
|
|
111
141
|
* Sends a message to the native instance and returns the response.
|
|
112
142
|
* @param messageType - The type of message to send
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ConfigMappingsType,
|
|
3
|
-
booleanConfigHelper,
|
|
4
|
-
getConfigFromMappings,
|
|
5
|
-
numberConfigHelper,
|
|
6
|
-
} from '@aztec/foundation/config';
|
|
1
|
+
import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
7
2
|
|
|
8
3
|
/** World State synchronizer configuration values. */
|
|
9
4
|
export interface WorldStateConfig {
|
|
10
5
|
/** The frequency in which to check. */
|
|
11
6
|
worldStateBlockCheckIntervalMS: number;
|
|
12
7
|
|
|
13
|
-
/** Whether to follow only the proven chain. */
|
|
14
|
-
worldStateProvenBlocksOnly: boolean;
|
|
15
|
-
|
|
16
8
|
/** Size of the batch for each get-blocks request from the synchronizer to the archiver. */
|
|
17
9
|
worldStateBlockRequestBatchSize?: number;
|
|
18
10
|
|
|
@@ -37,8 +29,8 @@ export interface WorldStateConfig {
|
|
|
37
29
|
/** Optional directory for the world state DB, if unspecified will default to the general data directory */
|
|
38
30
|
worldStateDataDirectory?: string;
|
|
39
31
|
|
|
40
|
-
/** The number of historic blocks to maintain */
|
|
41
|
-
|
|
32
|
+
/** The number of historic checkpoints worth of blocks to maintain */
|
|
33
|
+
worldStateCheckpointHistory: number;
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
export const worldStateConfigMappings: ConfigMappingsType<WorldStateConfig> = {
|
|
@@ -48,11 +40,6 @@ export const worldStateConfigMappings: ConfigMappingsType<WorldStateConfig> = {
|
|
|
48
40
|
defaultValue: 100,
|
|
49
41
|
description: 'The frequency in which to check.',
|
|
50
42
|
},
|
|
51
|
-
worldStateProvenBlocksOnly: {
|
|
52
|
-
env: 'WS_PROVEN_BLOCKS_ONLY',
|
|
53
|
-
description: 'Whether to follow only the proven chain.',
|
|
54
|
-
...booleanConfigHelper(),
|
|
55
|
-
},
|
|
56
43
|
worldStateBlockRequestBatchSize: {
|
|
57
44
|
env: 'WS_BLOCK_REQUEST_BATCH_SIZE',
|
|
58
45
|
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
@@ -97,9 +84,11 @@ export const worldStateConfigMappings: ConfigMappingsType<WorldStateConfig> = {
|
|
|
97
84
|
env: 'WS_DATA_DIRECTORY',
|
|
98
85
|
description: 'Optional directory for the world state database',
|
|
99
86
|
},
|
|
100
|
-
|
|
101
|
-
env: '
|
|
102
|
-
description:
|
|
87
|
+
worldStateCheckpointHistory: {
|
|
88
|
+
env: 'WS_NUM_HISTORIC_CHECKPOINTS',
|
|
89
|
+
description:
|
|
90
|
+
'The number of historic checkpoints worth of blocks to maintain. Values less than 1 mean all history is maintained',
|
|
91
|
+
fallback: ['WS_NUM_HISTORIC_BLOCKS'],
|
|
103
92
|
...numberConfigHelper(64),
|
|
104
93
|
},
|
|
105
94
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
2
2
|
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
3
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
3
4
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
4
5
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
5
6
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -22,9 +23,10 @@ export async function createWorldStateSynchronizer(
|
|
|
22
23
|
l2BlockSource: L2BlockSource & L1ToL2MessageSource,
|
|
23
24
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
24
25
|
client: TelemetryClient = getTelemetryClient(),
|
|
26
|
+
bindings?: LoggerBindings,
|
|
25
27
|
) {
|
|
26
28
|
const instrumentation = new WorldStateInstrumentation(client);
|
|
27
|
-
const merkleTrees = await createWorldState(config, prefilledPublicData, instrumentation);
|
|
29
|
+
const merkleTrees = await createWorldState(config, prefilledPublicData, instrumentation, bindings);
|
|
28
30
|
return new ServerWorldStateSynchronizer(merkleTrees, l2BlockSource, config, instrumentation);
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -42,6 +44,7 @@ export async function createWorldState(
|
|
|
42
44
|
Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb' | 'l1Contracts'>,
|
|
43
45
|
prefilledPublicData: PublicDataTreeLeaf[] = [],
|
|
44
46
|
instrumentation: WorldStateInstrumentation = new WorldStateInstrumentation(getTelemetryClient()),
|
|
47
|
+
bindings?: LoggerBindings,
|
|
45
48
|
) {
|
|
46
49
|
const dataDirectory = config.worldStateDataDirectory ?? config.dataDirectory;
|
|
47
50
|
const dataStoreMapSizeKb = config.worldStateDbMapSizeKb ?? config.dataStoreMapSizeKb;
|
|
@@ -65,11 +68,14 @@ export async function createWorldState(
|
|
|
65
68
|
wsTreeMapSizes,
|
|
66
69
|
prefilledPublicData,
|
|
67
70
|
instrumentation,
|
|
71
|
+
bindings,
|
|
68
72
|
)
|
|
69
73
|
: await NativeWorldStateService.tmp(
|
|
70
74
|
config.l1Contracts.rollupAddress,
|
|
71
75
|
!['true', '1'].includes(process.env.DEBUG_WORLD_STATE!),
|
|
72
76
|
prefilledPublicData,
|
|
77
|
+
instrumentation,
|
|
78
|
+
bindings,
|
|
73
79
|
);
|
|
74
80
|
|
|
75
81
|
return merkleTrees;
|