@aztec/world-state 0.0.1-commit.2f68f620 → 0.0.1-commit.3100065
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 +3 -4
- package/dest/instrumentation/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation/instrumentation.js +9 -4
- package/dest/native/ipc_world_state_instance.d.ts +22 -59
- package/dest/native/ipc_world_state_instance.d.ts.map +1 -1
- package/dest/native/ipc_world_state_instance.js +495 -520
- package/dest/native/merkle_trees_facade.d.ts +3 -4
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +109 -37
- package/dest/native/message.d.ts +233 -14
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +42 -0
- package/dest/native/native_world_state.d.ts +28 -14
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +102 -101
- package/dest/native/native_world_state_instance.d.ts +42 -58
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +222 -5
- package/dest/native/world_state_ops_queue.d.ts +19 -0
- package/dest/native/world_state_ops_queue.d.ts.map +1 -0
- package/dest/native/world_state_ops_queue.js +146 -0
- package/dest/synchronizer/errors.d.ts +8 -1
- package/dest/synchronizer/errors.d.ts.map +1 -1
- package/dest/synchronizer/errors.js +8 -1
- package/dest/synchronizer/factory.d.ts +1 -1
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +1 -1
- package/dest/synchronizer/index.d.ts +2 -1
- package/dest/synchronizer/index.d.ts.map +1 -1
- package/dest/synchronizer/index.js +1 -0
- package/dest/synchronizer/server_world_state_synchronizer.d.ts +11 -6
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +55 -43
- package/dest/test/utils.d.ts +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +6 -1
- package/dest/testing.d.ts +2 -2
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +15 -4
- package/package.json +10 -12
- package/src/instrumentation/instrumentation.ts +18 -6
- package/src/native/ipc_world_state_instance.ts +503 -608
- package/src/native/merkle_trees_facade.ts +104 -59
- package/src/native/message.ts +300 -13
- package/src/native/native_world_state.ts +156 -121
- package/src/native/native_world_state_instance.ts +307 -96
- package/src/native/world_state_ops_queue.ts +190 -0
- package/src/synchronizer/errors.ts +8 -0
- package/src/synchronizer/factory.ts +1 -0
- package/src/synchronizer/index.ts +1 -0
- package/src/synchronizer/server_world_state_synchronizer.ts +63 -30
- package/src/test/utils.ts +10 -1
- package/src/testing.ts +14 -4
- package/dest/native/world_state_operation.d.ts +0 -7
- package/dest/native/world_state_operation.d.ts.map +0 -1
- package/dest/native/world_state_operation.js +0 -5
- package/src/native/world_state_operation.ts +0 -33
|
@@ -1,66 +1,50 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type
|
|
6
|
-
|
|
1
|
+
import { type Logger, type LoggerBindings } from '@aztec/foundation/log';
|
|
2
|
+
import { type GenesisData } from '@aztec/stdlib/world-state';
|
|
3
|
+
import type { WorldStateInstrumentation } from '../instrumentation/instrumentation.js';
|
|
4
|
+
import type { WorldStateTreeMapSizes } from '../synchronizer/factory.js';
|
|
5
|
+
import { WorldStateMessageType, type WorldStateRequest, type WorldStateRequestCategories, type WorldStateResponse } from './message.js';
|
|
6
|
+
export interface NativeWorldStateInstance {
|
|
7
|
+
call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories): Promise<WorldStateResponse[T]>;
|
|
8
|
+
getHandle(): any;
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* The legacy in-process NAPI implementation has been removed; the C++ AVM (NAPI) now connects to
|
|
11
|
-
* the same aztec-wsdb process using the IPC path returned by {@link getIpcPath}.
|
|
11
|
+
* Strongly-typed interface to access the WorldState class in the native world_state_napi module.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
paddedNoteHashes: readonly SerializedLeafValue[];
|
|
36
|
-
paddedL1ToL2Messages: readonly SerializedLeafValue[];
|
|
37
|
-
paddedNullifiers: readonly SerializedLeafValue[];
|
|
38
|
-
publicDataWrites: readonly SerializedLeafValue[];
|
|
39
|
-
}): Promise<WorldStateStatusFull>;
|
|
40
|
-
createFork(input: {
|
|
41
|
-
latest: boolean;
|
|
42
|
-
blockNumber: BlockNumber;
|
|
43
|
-
}): Promise<number>;
|
|
44
|
-
deleteFork(forkId: number): Promise<void>;
|
|
45
|
-
finalizeBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusSummary>;
|
|
46
|
-
unwindBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
|
|
47
|
-
removeHistoricalBlocks(toBlockNumber: BlockNumber): Promise<WorldStateStatusFull>;
|
|
48
|
-
getStatus(): Promise<WorldStateStatusSummary>;
|
|
49
|
-
createCheckpoint(forkId: number): Promise<number>;
|
|
50
|
-
commitCheckpoint(forkId: number): Promise<void>;
|
|
51
|
-
revertCheckpoint(forkId: number): Promise<void>;
|
|
52
|
-
commitAllCheckpoints(forkId: number, depth: number): Promise<void>;
|
|
53
|
-
revertAllCheckpoints(forkId: number, depth: number): Promise<void>;
|
|
54
|
-
copyStores(dstPath: string, compact: boolean): Promise<void>;
|
|
13
|
+
export declare class NativeWorldState implements NativeWorldStateInstance {
|
|
14
|
+
private readonly dataDir;
|
|
15
|
+
private readonly wsTreeMapSizes;
|
|
16
|
+
private readonly genesis;
|
|
17
|
+
private readonly instrumentation;
|
|
18
|
+
private readonly log;
|
|
19
|
+
private readonly ephemeral;
|
|
20
|
+
private open;
|
|
21
|
+
private queues;
|
|
22
|
+
private instance;
|
|
23
|
+
/** Creates a new native WorldState instance */
|
|
24
|
+
constructor(dataDir: string, wsTreeMapSizes: WorldStateTreeMapSizes, genesis: GenesisData | undefined, instrumentation: WorldStateInstrumentation, bindings?: LoggerBindings, log?: Logger, ephemeral?: boolean);
|
|
25
|
+
getDataDir(): string;
|
|
26
|
+
clone(): NativeWorldState;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the native WorldState handle from the underlying native instance.
|
|
29
|
+
* We call the getHandle() method on the native WorldState to get a NAPI External
|
|
30
|
+
* that wraps the underlying C++ WorldState pointer.
|
|
31
|
+
* @returns The NAPI External handle to the native WorldState instance,since
|
|
32
|
+
* the NAPI external type is opaque, we return any (we could also use an opaque symbol type)
|
|
33
|
+
*/
|
|
34
|
+
getHandle(): any;
|
|
55
35
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
36
|
+
* Sends a message to the native instance and returns the response.
|
|
37
|
+
* @param messageType - The type of message to send
|
|
38
|
+
* @param body - The message body
|
|
39
|
+
* @param responseHandler - A callback accepting the response, executed on the job queue
|
|
40
|
+
* @param errorHandler - A callback called on request error, executed on the job queue
|
|
41
|
+
* @returns The response to the message
|
|
58
42
|
*/
|
|
59
|
-
|
|
43
|
+
call<T extends WorldStateMessageType>(messageType: T, body: WorldStateRequest[T] & WorldStateRequestCategories, responseHandler?: (response: WorldStateResponse[T]) => WorldStateResponse[T], errorHandler?: (_: string) => void): Promise<WorldStateResponse[T]>;
|
|
60
44
|
/**
|
|
61
|
-
*
|
|
62
|
-
* terminates the underlying aztec-wsdb process. Idempotent.
|
|
45
|
+
* Stops the native instance.
|
|
63
46
|
*/
|
|
64
47
|
close(): Promise<void>;
|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Vk7Q0E4RDNCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native_world_state_instance.d.ts","sourceRoot":"","sources":["../../src/native/native_world_state_instance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native_world_state_instance.d.ts","sourceRoot":"","sources":["../../src/native/native_world_state_instance.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAKjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EAIxB,MAAM,cAAc,CAAC;AAKtB,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAClC,WAAW,EAAE,CAAC,EACd,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,2BAA2B,GACvD,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAElC,SAAS,IAAI,GAAG,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,wBAAwB;IAU7D,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAEhC,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAf5B,OAAO,CAAC,IAAI,CAAQ;IAGpB,OAAO,CAAC,MAAM,CAAyC;IAEvD,OAAO,CAAC,QAAQ,CAA+E;IAE/F,+CAA+C;IAC/C,YACmB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,sBAAsB,EACtC,OAAO,yBAAkC,EACzC,eAAe,EAAE,yBAAyB,EAC3D,QAAQ,CAAC,EAAE,cAAc,EACR,GAAG,GAAE,MAAuD,EAC5D,SAAS,GAAE,OAAe,EAsD5C;IAEM,UAAU,WAEhB;IAEM,KAAK,qBAUX;IAED;;;;;;OAMG;IACI,SAAS,IAAI,GAAG,CAiBtB;IAED;;;;;;;OAOG;IACU,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAC/C,WAAW,EAAE,CAAC,EACd,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,2BAA2B,EAExD,eAAe,6DAAuE,EACtF,YAAY,sBAAoB,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CA4DhC;IAED;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAelC;YAEa,YAAY;CA8D3B"}
|
|
@@ -1,6 +1,223 @@
|
|
|
1
|
+
import { ARCHIVE_HEIGHT, DomainSeparator, L1_TO_L2_MSG_TREE_HEIGHT, MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { NativeWorldState as BaseNativeWorldState, MsgpackChannel } from '@aztec/native';
|
|
4
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
|
+
import { EMPTY_GENESIS_DATA } from '@aztec/stdlib/world-state';
|
|
6
|
+
import assert from 'assert';
|
|
7
|
+
import { cpus } from 'os';
|
|
8
|
+
import { WorldStateMessageType, isWithCanonical, isWithForkId, isWithRevision } from './message.js';
|
|
9
|
+
import { WorldStateOpsQueue } from './world_state_ops_queue.js';
|
|
10
|
+
const MAX_WORLD_STATE_THREADS = +(process.env.HARDWARE_CONCURRENCY || '16');
|
|
1
11
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
* Strongly-typed interface to access the WorldState class in the native world_state_napi module.
|
|
13
|
+
*/ export class NativeWorldState {
|
|
14
|
+
dataDir;
|
|
15
|
+
wsTreeMapSizes;
|
|
16
|
+
genesis;
|
|
17
|
+
instrumentation;
|
|
18
|
+
log;
|
|
19
|
+
ephemeral;
|
|
20
|
+
open;
|
|
21
|
+
// We maintain a map of queue to fork
|
|
22
|
+
queues;
|
|
23
|
+
instance;
|
|
24
|
+
/** Creates a new native WorldState instance */ constructor(dataDir, wsTreeMapSizes, genesis = EMPTY_GENESIS_DATA, instrumentation, bindings, log = createLogger('world-state:database', bindings), ephemeral = false){
|
|
25
|
+
this.dataDir = dataDir;
|
|
26
|
+
this.wsTreeMapSizes = wsTreeMapSizes;
|
|
27
|
+
this.genesis = genesis;
|
|
28
|
+
this.instrumentation = instrumentation;
|
|
29
|
+
this.log = log;
|
|
30
|
+
this.ephemeral = ephemeral;
|
|
31
|
+
this.open = true;
|
|
32
|
+
this.queues = new Map();
|
|
33
|
+
const threads = Math.min(cpus().length, MAX_WORLD_STATE_THREADS);
|
|
34
|
+
log.info(`Creating world state data store at directory ${dataDir} with map sizes ${JSON.stringify(wsTreeMapSizes)} and ${threads} threads (ephemeral=${ephemeral}).`);
|
|
35
|
+
const prefilledPublicDataBufferArray = genesis.prefilledPublicData.map((d)=>[
|
|
36
|
+
d.slot.toBuffer(),
|
|
37
|
+
d.value.toBuffer()
|
|
38
|
+
]);
|
|
39
|
+
// Nullifiers to pre-insert into the genesis nullifier tree (empty by default, so production genesis roots are
|
|
40
|
+
// unchanged). The native indexed nullifier tree requires its prefilled leaves to be unique and strictly
|
|
41
|
+
// increasing, so we enforce that here before handing them over rather than failing deep inside the C++ tree
|
|
42
|
+
// construction.
|
|
43
|
+
const prefilledNullifiers = genesis.prefilledNullifiers ?? [];
|
|
44
|
+
for(let i = 1; i < prefilledNullifiers.length; i++){
|
|
45
|
+
assert(prefilledNullifiers[i].toBigInt() > prefilledNullifiers[i - 1].toBigInt(), 'Prefilled genesis nullifiers must be unique and strictly increasing');
|
|
46
|
+
}
|
|
47
|
+
const prefilledNullifiersBufferArray = prefilledNullifiers.map((n)=>n.toBuffer());
|
|
48
|
+
const ws = new BaseNativeWorldState(dataDir, {
|
|
49
|
+
[MerkleTreeId.NULLIFIER_TREE]: NULLIFIER_TREE_HEIGHT,
|
|
50
|
+
[MerkleTreeId.NOTE_HASH_TREE]: NOTE_HASH_TREE_HEIGHT,
|
|
51
|
+
[MerkleTreeId.PUBLIC_DATA_TREE]: PUBLIC_DATA_TREE_HEIGHT,
|
|
52
|
+
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: L1_TO_L2_MSG_TREE_HEIGHT,
|
|
53
|
+
[MerkleTreeId.ARCHIVE]: ARCHIVE_HEIGHT
|
|
54
|
+
}, {
|
|
55
|
+
[MerkleTreeId.NULLIFIER_TREE]: 2 * MAX_NULLIFIERS_PER_TX,
|
|
56
|
+
[MerkleTreeId.PUBLIC_DATA_TREE]: 2 * MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX
|
|
57
|
+
}, prefilledPublicDataBufferArray, prefilledNullifiersBufferArray, DomainSeparator.BLOCK_HEADER_HASH, Number(genesis.genesisTimestamp), {
|
|
58
|
+
[MerkleTreeId.NULLIFIER_TREE]: wsTreeMapSizes.nullifierTreeMapSizeKb,
|
|
59
|
+
[MerkleTreeId.NOTE_HASH_TREE]: wsTreeMapSizes.noteHashTreeMapSizeKb,
|
|
60
|
+
[MerkleTreeId.PUBLIC_DATA_TREE]: wsTreeMapSizes.publicDataTreeMapSizeKb,
|
|
61
|
+
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: wsTreeMapSizes.messageTreeMapSizeKb,
|
|
62
|
+
[MerkleTreeId.ARCHIVE]: wsTreeMapSizes.archiveTreeMapSizeKb
|
|
63
|
+
}, threads, ephemeral);
|
|
64
|
+
this.instance = new MsgpackChannel(ws);
|
|
65
|
+
// Manually create the queue for the canonical fork
|
|
66
|
+
this.queues.set(0, new WorldStateOpsQueue());
|
|
67
|
+
}
|
|
68
|
+
getDataDir() {
|
|
69
|
+
return this.dataDir;
|
|
70
|
+
}
|
|
71
|
+
clone() {
|
|
72
|
+
return new NativeWorldState(this.dataDir, this.wsTreeMapSizes, this.genesis, this.instrumentation, this.log.getBindings(), this.log, this.ephemeral);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets the native WorldState handle from the underlying native instance.
|
|
76
|
+
* We call the getHandle() method on the native WorldState to get a NAPI External
|
|
77
|
+
* that wraps the underlying C++ WorldState pointer.
|
|
78
|
+
* @returns The NAPI External handle to the native WorldState instance,since
|
|
79
|
+
* the NAPI external type is opaque, we return any (we could also use an opaque symbol type)
|
|
80
|
+
*/ getHandle() {
|
|
81
|
+
const worldStateWrapper = this.instance.dest;
|
|
82
|
+
if (!worldStateWrapper) {
|
|
83
|
+
throw new Error('No WorldStateWrapper found');
|
|
84
|
+
}
|
|
85
|
+
if (typeof worldStateWrapper.getHandle !== 'function') {
|
|
86
|
+
throw new Error('WorldStateWrapper does not have getHandle method');
|
|
87
|
+
}
|
|
88
|
+
// Call getHandle() to get the NAPI External
|
|
89
|
+
try {
|
|
90
|
+
return worldStateWrapper.getHandle();
|
|
91
|
+
} catch (error) {
|
|
92
|
+
this.log.error('Failed to get native WorldState handle', error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sends a message to the native instance and returns the response.
|
|
97
|
+
* @param messageType - The type of message to send
|
|
98
|
+
* @param body - The message body
|
|
99
|
+
* @param responseHandler - A callback accepting the response, executed on the job queue
|
|
100
|
+
* @param errorHandler - A callback called on request error, executed on the job queue
|
|
101
|
+
* @returns The response to the message
|
|
102
|
+
*/ async call(messageType, body, // allows for the pre-processing of responses on the job queue before being passed back
|
|
103
|
+
responseHandler = (response)=>response, errorHandler = (_)=>{}) {
|
|
104
|
+
// Here we determine which fork the request is being executed against and whether it requires uncommitted data
|
|
105
|
+
// We use the fork Id to select the appropriate request queue and the uncommitted data flag to pass to the queue
|
|
106
|
+
let forkId = -1;
|
|
107
|
+
// We assume it includes uncommitted unless explicitly told otherwise
|
|
108
|
+
let committedOnly = false;
|
|
109
|
+
// Canonical requests ALWAYS go against the canonical fork
|
|
110
|
+
// These include things like block syncs/unwinds etc
|
|
111
|
+
// These requests don't contain a fork ID
|
|
112
|
+
if (isWithCanonical(body)) {
|
|
113
|
+
forkId = 0;
|
|
114
|
+
} else if (isWithForkId(body)) {
|
|
115
|
+
forkId = body.forkId;
|
|
116
|
+
} else if (isWithRevision(body)) {
|
|
117
|
+
forkId = body.revision.forkId;
|
|
118
|
+
committedOnly = body.revision.includeUncommitted === false;
|
|
119
|
+
} else {
|
|
120
|
+
const _ = body;
|
|
121
|
+
throw new Error(`Unable to determine forkId for message=${WorldStateMessageType[messageType]}`);
|
|
122
|
+
}
|
|
123
|
+
// Get the queue or create a new one
|
|
124
|
+
let requestQueue = this.queues.get(forkId);
|
|
125
|
+
if (requestQueue === undefined) {
|
|
126
|
+
requestQueue = new WorldStateOpsQueue();
|
|
127
|
+
this.queues.set(forkId, requestQueue);
|
|
128
|
+
}
|
|
129
|
+
// Enqueue the request and wait for the response. The per-fork queue is cleaned up in `finally` even on
|
|
130
|
+
// error, so the JS-side queues map cannot outlive the native fork (e.g. when the native fork was already
|
|
131
|
+
// destroyed by an unwind/historical-prune and DELETE_FORK rejects with "Fork not found").
|
|
132
|
+
let shouldDeleteForkQueue = false;
|
|
133
|
+
try {
|
|
134
|
+
const response = await requestQueue.execute(async ()=>{
|
|
135
|
+
assert.notEqual(messageType, WorldStateMessageType.CLOSE, 'Use close() to close the native instance');
|
|
136
|
+
assert.equal(this.open, true, 'Native instance is closed');
|
|
137
|
+
let response;
|
|
138
|
+
try {
|
|
139
|
+
response = await this._sendMessage(messageType, body);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
errorHandler(error.message);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
return responseHandler(response);
|
|
145
|
+
}, messageType, committedOnly);
|
|
146
|
+
return response;
|
|
147
|
+
} catch (err) {
|
|
148
|
+
shouldDeleteForkQueue = forkId !== 0 && err?.message === 'Fork not found';
|
|
149
|
+
throw err;
|
|
150
|
+
} finally{
|
|
151
|
+
if (messageType === WorldStateMessageType.DELETE_FORK || shouldDeleteForkQueue) {
|
|
152
|
+
await requestQueue.stop();
|
|
153
|
+
this.queues.delete(forkId);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Stops the native instance.
|
|
159
|
+
*/ async close() {
|
|
160
|
+
if (!this.open) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.open = false;
|
|
164
|
+
const queue = this.queues.get(0);
|
|
165
|
+
await queue.execute(async ()=>{
|
|
166
|
+
await this._sendMessage(WorldStateMessageType.CLOSE, {
|
|
167
|
+
canonical: true
|
|
168
|
+
});
|
|
169
|
+
}, WorldStateMessageType.CLOSE, false);
|
|
170
|
+
await queue.stop();
|
|
171
|
+
}
|
|
172
|
+
async _sendMessage(messageType, body) {
|
|
173
|
+
let logMetadata = {};
|
|
174
|
+
if (body) {
|
|
175
|
+
if ('treeId' in body) {
|
|
176
|
+
logMetadata['treeId'] = MerkleTreeId[body.treeId];
|
|
177
|
+
}
|
|
178
|
+
if ('revision' in body) {
|
|
179
|
+
logMetadata = {
|
|
180
|
+
...logMetadata,
|
|
181
|
+
...body.revision
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if ('forkId' in body) {
|
|
185
|
+
logMetadata['forkId'] = body.forkId;
|
|
186
|
+
}
|
|
187
|
+
if ('blockNumber' in body) {
|
|
188
|
+
logMetadata['blockNumber'] = body.blockNumber;
|
|
189
|
+
}
|
|
190
|
+
if ('toBlockNumber' in body) {
|
|
191
|
+
logMetadata['toBlockNumber'] = body.toBlockNumber;
|
|
192
|
+
}
|
|
193
|
+
if ('leafIndex' in body) {
|
|
194
|
+
logMetadata['leafIndex'] = body.leafIndex;
|
|
195
|
+
}
|
|
196
|
+
if ('blockHeaderHash' in body) {
|
|
197
|
+
logMetadata['blockHeaderHash'] = '0x' + body.blockHeaderHash.toString('hex');
|
|
198
|
+
}
|
|
199
|
+
if ('leaves' in body) {
|
|
200
|
+
logMetadata['leavesCount'] = body.leaves.length;
|
|
201
|
+
}
|
|
202
|
+
// sync operation
|
|
203
|
+
if ('paddedNoteHashes' in body) {
|
|
204
|
+
logMetadata['notesCount'] = body.paddedNoteHashes.length;
|
|
205
|
+
logMetadata['nullifiersCount'] = body.paddedNullifiers.length;
|
|
206
|
+
logMetadata['l1ToL2MessagesCount'] = body.paddedL1ToL2Messages.length;
|
|
207
|
+
logMetadata['publicDataWritesCount'] = body.publicDataWrites.length;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
const { duration, response } = await this.instance.sendMessage(messageType, body);
|
|
212
|
+
this.log.trace(`Call ${WorldStateMessageType[messageType]} took (ms)`, {
|
|
213
|
+
duration,
|
|
214
|
+
...logMetadata
|
|
215
|
+
});
|
|
216
|
+
this.instrumentation.recordRoundTrip(duration.totalUs, messageType);
|
|
217
|
+
return response;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
this.log.error(`Call ${WorldStateMessageType[messageType]} failed: ${error}`, error, logMetadata);
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WorldStateMessageType } from './message.js';
|
|
2
|
+
export declare const MUTATING_MSG_TYPES: Set<WorldStateMessageType>;
|
|
3
|
+
export declare class WorldStateOpsQueue {
|
|
4
|
+
private requests;
|
|
5
|
+
private inFlightMutatingCount;
|
|
6
|
+
private inFlightCount;
|
|
7
|
+
private stopPromise?;
|
|
8
|
+
private stopResolve?;
|
|
9
|
+
private requestId;
|
|
10
|
+
private ops;
|
|
11
|
+
execute(request: () => Promise<any>, messageType: WorldStateMessageType, committedOnly: boolean): Promise<any>;
|
|
12
|
+
private executeMutating;
|
|
13
|
+
private executeNonMutatingUncommitted;
|
|
14
|
+
private executeNonMutatingCommitted;
|
|
15
|
+
private checkAndEnqueue;
|
|
16
|
+
private sendEnqueuedRequest;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid29ybGRfc3RhdGVfb3BzX3F1ZXVlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbmF0aXZlL3dvcmxkX3N0YXRlX29wc19xdWV1ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxjQUFjLENBQUM7QUF5QnJELGVBQU8sTUFBTSxrQkFBa0IsNEJBZ0I3QixDQUFDO0FBR0gscUJBQWEsa0JBQWtCO0lBQzdCLE9BQU8sQ0FBQyxRQUFRLENBQXNCO0lBQ3RDLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBSztJQUNsQyxPQUFPLENBQUMsYUFBYSxDQUFLO0lBQzFCLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBZ0I7SUFDcEMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFhO0lBQ2pDLE9BQU8sQ0FBQyxTQUFTLENBQUs7SUFDdEIsT0FBTyxDQUFDLEdBQUcsQ0FBd0M7SUFJNUMsT0FBTyxDQUFDLE9BQU8sRUFBRSxNQUFNLE9BQU8sQ0FBQyxHQUFHLENBQUMsRUFBRSxXQUFXLEVBQUUscUJBQXFCLEVBQUUsYUFBYSxFQUFFLE9BQU8sZ0JBc0JyRztJQUdELE9BQU8sQ0FBQyxlQUFlO0lBV3ZCLE9BQU8sQ0FBQyw2QkFBNkI7SUFZckMsT0FBTyxDQUFDLDJCQUEyQjtJQVVuQyxPQUFPLENBQUMsZUFBZTtJQXlDdkIsT0FBTyxDQUFDLG1CQUFtQjtJQWdCcEIsSUFBSSxrQkFnQlY7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world_state_ops_queue.d.ts","sourceRoot":"","sources":["../../src/native/world_state_ops_queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAyBrD,eAAO,MAAM,kBAAkB,4BAgB7B,CAAC;AAGH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,WAAW,CAAC,CAAa;IACjC,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,GAAG,CAAwC;IAI5C,OAAO,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,aAAa,EAAE,OAAO,gBAsBrG;IAGD,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,6BAA6B;IAYrC,OAAO,CAAC,2BAA2B;IAUnC,OAAO,CAAC,eAAe;IAyCvB,OAAO,CAAC,mBAAmB;IAgBpB,IAAI,kBAgBV;CACF"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
2
|
+
import { WorldStateMessageType } from './message.js';
|
|
3
|
+
// These are the set of message types that implement mutating operations
|
|
4
|
+
// Messages of these types require exclusive access to their given forks
|
|
5
|
+
export const MUTATING_MSG_TYPES = new Set([
|
|
6
|
+
WorldStateMessageType.APPEND_LEAVES,
|
|
7
|
+
WorldStateMessageType.BATCH_INSERT,
|
|
8
|
+
WorldStateMessageType.SEQUENTIAL_INSERT,
|
|
9
|
+
WorldStateMessageType.UPDATE_ARCHIVE,
|
|
10
|
+
WorldStateMessageType.COMMIT,
|
|
11
|
+
WorldStateMessageType.ROLLBACK,
|
|
12
|
+
WorldStateMessageType.SYNC_BLOCK,
|
|
13
|
+
WorldStateMessageType.CREATE_FORK,
|
|
14
|
+
WorldStateMessageType.DELETE_FORK,
|
|
15
|
+
WorldStateMessageType.FINALIZE_BLOCKS,
|
|
16
|
+
WorldStateMessageType.UNWIND_BLOCKS,
|
|
17
|
+
WorldStateMessageType.REMOVE_HISTORICAL_BLOCKS,
|
|
18
|
+
WorldStateMessageType.CREATE_CHECKPOINT,
|
|
19
|
+
WorldStateMessageType.COMMIT_CHECKPOINT,
|
|
20
|
+
WorldStateMessageType.REVERT_CHECKPOINT
|
|
21
|
+
]);
|
|
22
|
+
// This class implements the per-fork operation queue
|
|
23
|
+
export class WorldStateOpsQueue {
|
|
24
|
+
requests = [];
|
|
25
|
+
inFlightMutatingCount = 0;
|
|
26
|
+
inFlightCount = 0;
|
|
27
|
+
stopPromise;
|
|
28
|
+
stopResolve;
|
|
29
|
+
requestId = 0;
|
|
30
|
+
ops = new Map();
|
|
31
|
+
// The primary public api, this is where an operation is queued
|
|
32
|
+
// We return a promise that will ultimately be resolved/rejected with the response/error generated by the 'request' argument
|
|
33
|
+
execute(request, messageType, committedOnly) {
|
|
34
|
+
if (this.stopResolve !== undefined) {
|
|
35
|
+
throw new Error('Unable to send request to world state, queue already stopped');
|
|
36
|
+
}
|
|
37
|
+
const op = {
|
|
38
|
+
requestId: this.requestId++,
|
|
39
|
+
mutating: MUTATING_MSG_TYPES.has(messageType),
|
|
40
|
+
request,
|
|
41
|
+
promise: promiseWithResolvers()
|
|
42
|
+
};
|
|
43
|
+
this.ops.set(op.requestId, op);
|
|
44
|
+
// Perform the appropriate action based upon the queueing rules
|
|
45
|
+
if (op.mutating) {
|
|
46
|
+
this.executeMutating(op);
|
|
47
|
+
} else if (committedOnly === false) {
|
|
48
|
+
this.executeNonMutatingUncommitted(op);
|
|
49
|
+
} else {
|
|
50
|
+
this.executeNonMutatingCommitted(op);
|
|
51
|
+
}
|
|
52
|
+
return op.promise.promise;
|
|
53
|
+
}
|
|
54
|
+
// Mutating requests need exclusive access
|
|
55
|
+
executeMutating(op) {
|
|
56
|
+
// If nothing is in flight then we send the request immediately
|
|
57
|
+
// Otherwise add to the queue
|
|
58
|
+
if (this.inFlightCount === 0) {
|
|
59
|
+
this.sendEnqueuedRequest(op);
|
|
60
|
+
} else {
|
|
61
|
+
this.requests.push(op);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Non mutating requests including uncommitted state
|
|
65
|
+
executeNonMutatingUncommitted(op) {
|
|
66
|
+
// If there are no mutating requests in flight and there is nothing queued
|
|
67
|
+
// then send the request immediately
|
|
68
|
+
// If a mutating request is in flight then we must wait
|
|
69
|
+
// If a mutating request is not in flight but something is queued then it must be a mutating request
|
|
70
|
+
if (this.inFlightMutatingCount === 0 && this.requests.length === 0) {
|
|
71
|
+
this.sendEnqueuedRequest(op);
|
|
72
|
+
} else {
|
|
73
|
+
this.requests.push(op);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
executeNonMutatingCommitted(op) {
|
|
77
|
+
// This is a non-mutating request for committed data
|
|
78
|
+
// It can always be sent
|
|
79
|
+
op.request().then(op.promise.resolve, op.promise.reject).finally(()=>{
|
|
80
|
+
this.ops.delete(op.requestId);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
checkAndEnqueue(completedOp) {
|
|
84
|
+
// As request has completed
|
|
85
|
+
// First we decrements the relevant in flight counters
|
|
86
|
+
if (completedOp.mutating) {
|
|
87
|
+
--this.inFlightMutatingCount;
|
|
88
|
+
}
|
|
89
|
+
--this.inFlightCount;
|
|
90
|
+
// If there are still requests in flight then do nothing further
|
|
91
|
+
if (this.inFlightCount !== 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// No requests in flight, send next queued requests
|
|
95
|
+
// We loop and send:
|
|
96
|
+
// 1 mutating request if it is next in the queue
|
|
97
|
+
// As many non-mutating requests as we encounter until
|
|
98
|
+
// we exhaust the queue or we reach a mutating request
|
|
99
|
+
while(this.requests.length > 0){
|
|
100
|
+
const next = this.requests[0];
|
|
101
|
+
if (next.mutating) {
|
|
102
|
+
if (this.inFlightCount === 0) {
|
|
103
|
+
// send the mutating request
|
|
104
|
+
this.requests.shift();
|
|
105
|
+
this.sendEnqueuedRequest(next);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
} else {
|
|
109
|
+
// not mutating, send and go round again
|
|
110
|
+
this.requests.shift();
|
|
111
|
+
this.sendEnqueuedRequest(next);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// If the queue is empty, there is nothing in flight and we have been told to stop, then resolve the stop promise
|
|
115
|
+
if (this.inFlightCount === 0 && this.stopResolve !== undefined) {
|
|
116
|
+
this.stopResolve();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
sendEnqueuedRequest(op) {
|
|
120
|
+
// Here we increment the in flight counts before sending
|
|
121
|
+
++this.inFlightCount;
|
|
122
|
+
if (op.mutating) {
|
|
123
|
+
++this.inFlightMutatingCount;
|
|
124
|
+
}
|
|
125
|
+
// Make the request and pass the response/error through to the stored promise
|
|
126
|
+
op.request().then(op.promise.resolve, op.promise.reject).finally(()=>{
|
|
127
|
+
this.checkAndEnqueue(op);
|
|
128
|
+
this.ops.delete(op.requestId);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
stop() {
|
|
132
|
+
// If there is already a stop promise then return it
|
|
133
|
+
if (this.stopPromise) {
|
|
134
|
+
return this.stopPromise;
|
|
135
|
+
}
|
|
136
|
+
// Otherwise create a new one and capture the resolve method
|
|
137
|
+
this.stopPromise = new Promise((resolve)=>{
|
|
138
|
+
this.stopResolve = resolve;
|
|
139
|
+
});
|
|
140
|
+
// If no outstanding requests then immediately resolve the promise
|
|
141
|
+
if (this.requests.length === 0 && this.inFlightCount === 0 && this.stopResolve !== undefined) {
|
|
142
|
+
this.stopResolve();
|
|
143
|
+
}
|
|
144
|
+
return this.stopPromise;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by {@link ServerWorldStateSynchronizer.syncImmediate} when world state cannot be synced to the requested
|
|
3
|
+
* target: either the block is not available from the block source (`block_not_available`, e.g. it was pruned away)
|
|
4
|
+
* or the synced block does not match the requested hash (`block_hash_mismatch`, i.e. a reorg). Both causes are
|
|
5
|
+
* transient from the caller's perspective: re-resolving the query against the current chain and retrying may succeed
|
|
6
|
+
* or produce a more precise error.
|
|
7
|
+
*/
|
|
1
8
|
export declare class WorldStateSynchronizerError extends Error {
|
|
2
9
|
constructor(message: string, options?: ErrorOptions);
|
|
3
10
|
}
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc3luY2hyb25pemVyL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxxQkFBYSwyQkFBNEIsU0FBUSxLQUFLO0lBQ3BELFlBQVksT0FBTyxFQUFFLE1BQU0sRUFBRSxPQUFPLENBQUMsRUFBRSxZQUFZLEVBR2xEO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/synchronizer/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/synchronizer/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACF"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by {@link ServerWorldStateSynchronizer.syncImmediate} when world state cannot be synced to the requested
|
|
3
|
+
* target: either the block is not available from the block source (`block_not_available`, e.g. it was pruned away)
|
|
4
|
+
* or the synced block does not match the requested hash (`block_hash_mismatch`, i.e. a reorg). Both causes are
|
|
5
|
+
* transient from the caller's perspective: re-resolving the query against the current chain and retrying may succeed
|
|
6
|
+
* or produce a more precise error.
|
|
7
|
+
*/ export class WorldStateSynchronizerError extends Error {
|
|
2
8
|
constructor(message, options){
|
|
3
9
|
super(message, options);
|
|
10
|
+
this.name = 'WorldStateSynchronizerError';
|
|
4
11
|
}
|
|
5
12
|
}
|
|
@@ -17,4 +17,4 @@ export interface WorldStateTreeMapSizes {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function createWorldStateSynchronizer(config: WorldStateConfig & DataStoreConfig, l2BlockSource: L2BlockSource & L1ToL2MessageSource, genesisOrNativeWorldState: GenesisData | NativeWorldStateService, client?: TelemetryClient, bindings?: LoggerBindings): Promise<ServerWorldStateSynchronizer>;
|
|
19
19
|
export declare function createWorldState(config: Pick<WorldStateConfig, 'worldStateDataDirectory' | 'worldStateDbMapSizeKb' | 'archiveTreeMapSizeKb' | 'nullifierTreeMapSizeKb' | 'noteHashTreeMapSizeKb' | 'messageTreeMapSizeKb' | 'publicDataTreeMapSizeKb'> & Pick<DataStoreConfig, 'dataDirectory' | 'dataStoreMapSizeKb' | 'rollupAddress'>, genesis?: GenesisData, instrumentation?: WorldStateInstrumentation, bindings?: LoggerBindings): Promise<NativeWorldStateService>;
|
|
20
|
-
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yB,CAAC;AACnE,OAAO,EAAsB,KAAK,WAAW,EAAiB,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAEnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEpF,MAAM,WAAW,sBAAsB;IACrC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;CACjC;AAED,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,gBAAgB,GAAG,eAAe,EAC1C,aAAa,EAAE,aAAa,GAAG,mBAAmB,EAClD,yBAAyB,EAAE,WAAW,GAAG,uBAAuB,EAChE,MAAM,GAAE,eAAsC,EAC9C,QAAQ,CAAC,EAAE,cAAc,yCAO1B;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,IAAI,CACV,gBAAgB,EACd,yBAAyB,GACzB,uBAAuB,GACvB,sBAAsB,GACtB,wBAAwB,GACxB,uBAAuB,GACvB,sBAAsB,GACtB,yBAAyB,CAC5B,GACC,IAAI,CAAC,eAAe,EAAE,eAAe,GAAG,oBAAoB,GAAG,eAAe,CAAC,EACjF,OAAO,GAAE,WAAgC,EACzC,eAAe,GAAE,yBAA+E,EAChG,QAAQ,CAAC,EAAE,cAAc,oCAmC1B"}
|
|
@@ -22,7 +22,7 @@ export async function createWorldState(config, genesis = EMPTY_GENESIS_DATA, ins
|
|
|
22
22
|
throw new Error('Rollup address is required to create a world state synchronizer.');
|
|
23
23
|
}
|
|
24
24
|
// If a data directory is provided in config, then create a persistent store.
|
|
25
|
-
const merkleTrees = dataDirectory ? await NativeWorldStateService.new(config.rollupAddress, dataDirectory, wsTreeMapSizes, genesis, instrumentation, bindings) : await NativeWorldStateService.tmp(![
|
|
25
|
+
const merkleTrees = dataDirectory ? await NativeWorldStateService.new(config.rollupAddress, dataDirectory, wsTreeMapSizes, genesis, instrumentation, bindings) : await NativeWorldStateService.tmp(config.rollupAddress, ![
|
|
26
26
|
'true',
|
|
27
27
|
'1'
|
|
28
28
|
].includes(process.env.DEBUG_WORLD_STATE), genesis, instrumentation, bindings);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './server_world_state_synchronizer.js';
|
|
2
2
|
export * from './factory.js';
|
|
3
|
-
|
|
3
|
+
export * from './errors.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zeW5jaHJvbml6ZXIvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxzQ0FBc0MsQ0FBQztBQUNyRCxjQUFjLGNBQWMsQ0FBQztBQUM3QixjQUFjLGFBQWEsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/synchronizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/synchronizer/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|