@aztec/world-state 0.0.1-commit.d431d1c → 0.0.1-commit.d58ff9d0
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 +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/instrumentation/instrumentation.d.ts +4 -3
- package/dest/instrumentation/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation/instrumentation.js +13 -11
- 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 +2 -1
- package/dest/native/index.d.ts.map +1 -1
- package/dest/native/index.js +1 -0
- package/dest/native/ipc_world_state_instance.d.ts +89 -0
- package/dest/native/ipc_world_state_instance.d.ts.map +1 -0
- package/dest/native/ipc_world_state_instance.js +661 -0
- package/dest/native/merkle_trees_facade.d.ts +12 -8
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +63 -115
- package/dest/native/message.d.ts +14 -221
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +0 -42
- package/dest/native/native_world_state.d.ts +22 -10
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +122 -59
- package/dest/native/native_world_state_instance.d.ts +56 -42
- package/dest/native/native_world_state_instance.d.ts.map +1 -1
- package/dest/native/native_world_state_instance.js +1 -203
- package/dest/native/world_state_operation.d.ts +7 -0
- package/dest/native/world_state_operation.d.ts.map +1 -0
- package/dest/native/world_state_operation.js +5 -0
- package/dest/synchronizer/config.d.ts +3 -5
- package/dest/synchronizer/config.d.ts.map +1 -1
- package/dest/synchronizer/config.js +15 -18
- 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 +6 -5
- package/dest/synchronizer/factory.d.ts.map +1 -1
- package/dest/synchronizer/factory.js +7 -6
- 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 +13 -8
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +134 -49
- package/dest/test/utils.d.ts +6 -6
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +9 -4
- package/dest/testing.d.ts +4 -3
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +14 -7
- package/dest/world-state-db/merkle_tree_db.d.ts +3 -12
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/package.json +13 -11
- package/src/index.ts +1 -0
- package/src/instrumentation/instrumentation.ts +15 -19
- package/src/native/fork_checkpoint.ts +19 -3
- package/src/native/index.ts +1 -0
- package/src/native/ipc_world_state_instance.ts +834 -0
- package/src/native/merkle_trees_facade.ts +89 -109
- package/src/native/message.ts +13 -286
- package/src/native/native_world_state.ts +152 -93
- package/src/native/native_world_state_instance.ts +94 -279
- package/src/native/world_state_operation.ts +33 -0
- package/src/synchronizer/config.ts +16 -23
- package/src/synchronizer/errors.ts +8 -0
- package/src/synchronizer/factory.ts +18 -11
- package/src/synchronizer/index.ts +1 -0
- package/src/synchronizer/server_world_state_synchronizer.ts +156 -51
- package/src/test/utils.ts +14 -5
- package/src/testing.ts +12 -10
- package/src/world-state-db/merkle_tree_db.ts +2 -12
- package/dest/native/world_state_ops_queue.d.ts +0 -19
- package/dest/native/world_state_ops_queue.d.ts.map +0 -1
- package/dest/native/world_state_ops_queue.js +0 -146
- package/src/native/world_state_ops_queue.ts +0 -190
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
4
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
4
5
|
import type { BatchInsertionResult, IndexedTreeId, MerkleTreeLeafType, MerkleTreeReadOperations, MerkleTreeWriteOperations, SequentialInsertionResult, TreeInfo } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
6
7
|
import { type BlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
7
|
-
import {
|
|
8
|
+
import type { WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
8
9
|
import { type SerializedLeafValue } from './message.js';
|
|
9
10
|
import type { NativeWorldStateInstance } from './native_world_state_instance.js';
|
|
10
11
|
export declare class MerkleTreesFacade implements MerkleTreeReadOperations {
|
|
@@ -13,7 +14,8 @@ export declare class MerkleTreesFacade implements MerkleTreeReadOperations {
|
|
|
13
14
|
protected readonly revision: WorldStateRevision;
|
|
14
15
|
constructor(instance: NativeWorldStateInstance, initialHeader: BlockHeader, revision: WorldStateRevision);
|
|
15
16
|
getInitialHeader(): BlockHeader;
|
|
16
|
-
getRevision():
|
|
17
|
+
getRevision(): WorldStateRevision;
|
|
18
|
+
getIpcPath(): string;
|
|
17
19
|
findLeafIndices(treeId: MerkleTreeId, values: MerkleTreeLeafType<MerkleTreeId>[]): Promise<(bigint | undefined)[]>;
|
|
18
20
|
findSiblingPaths<N extends number>(treeId: MerkleTreeId, values: MerkleTreeLeafType<MerkleTreeId>[]): Promise<({
|
|
19
21
|
path: SiblingPath<N>;
|
|
@@ -35,6 +37,7 @@ export declare class MerkleTreesFacade implements MerkleTreeReadOperations {
|
|
|
35
37
|
export declare class MerkleTreesForkFacade extends MerkleTreesFacade implements MerkleTreeWriteOperations {
|
|
36
38
|
private opts;
|
|
37
39
|
private log;
|
|
40
|
+
private closePromise;
|
|
38
41
|
constructor(instance: NativeWorldStateInstance, initialHeader: BlockHeader, revision: WorldStateRevision, opts: {
|
|
39
42
|
closeDelayMs?: number;
|
|
40
43
|
});
|
|
@@ -43,12 +46,13 @@ export declare class MerkleTreesForkFacade extends MerkleTreesFacade implements
|
|
|
43
46
|
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(treeId: ID, rawLeaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
|
|
44
47
|
sequentialInsert<TreeHeight extends number, ID extends IndexedTreeId>(treeId: ID, rawLeaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
|
|
45
48
|
close(): Promise<void>;
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
private doClose;
|
|
50
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
51
|
+
createCheckpoint(): Promise<number>;
|
|
48
52
|
commitCheckpoint(): Promise<void>;
|
|
49
53
|
revertCheckpoint(): Promise<void>;
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
commitAllCheckpointsTo(depth: number): Promise<void>;
|
|
55
|
+
revertAllCheckpointsTo(depth: number): Promise<void>;
|
|
52
56
|
}
|
|
53
|
-
export declare function serializeLeaf(leaf: Fr | NullifierLeaf | PublicDataTreeLeaf): SerializedLeafValue;
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
57
|
+
export declare function serializeLeaf(leaf: Fr | BlockHash | NullifierLeaf | PublicDataTreeLeaf): SerializedLeafValue;
|
|
58
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVya2xlX3RyZWVzX2ZhY2FkZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL25hdGl2ZS9tZXJrbGVfdHJlZXNfZmFjYWRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RCxPQ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ksZ0JBQWdCLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUc3QztJQUVZLHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdoRTtJQUVZLHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdoRTtDQUNGO0FBZ0JELHdCQUFnQixhQUFhLENBQUMsSUFBSSxFQUFFLEVBQUUsR0FBRyxTQUFTLEdBQUcsYUFBYSxHQUFHLGtCQUFrQixHQUFHLG1CQUFtQixDQVU1RyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merkle_trees_facade.d.ts","sourceRoot":"","sources":["../../src/native/merkle_trees_facade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD,OAAO,EAAE,KAAK,uBAAuB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,QAAQ,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,aAAa,EAEb,kBAAkB,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,WAAW,EAAyB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,
|
|
1
|
+
{"version":3,"file":"merkle_trees_facade.d.ts","sourceRoot":"","sources":["../../src/native/merkle_trees_facade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAIpD,OAAO,EAAE,KAAK,uBAAuB,EAAE,W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M,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE;IAEY,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE;CACF;AAgBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,SAAS,GAAG,aAAa,GAAG,kBAAkB,GAAG,mBAAmB,CAU5G"}
|
|
@@ -5,11 +5,11 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
5
5
|
import { serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
6
|
import { sleep } from '@aztec/foundation/sleep';
|
|
7
7
|
import { SiblingPath } from '@aztec/foundation/trees';
|
|
8
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
8
9
|
import { MerkleTreeId, NullifierLeaf, NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
9
10
|
import { PartialStateReference, StateReference } from '@aztec/stdlib/tx';
|
|
10
|
-
import { WorldStateRevisionWithHandle } from '@aztec/stdlib/world-state';
|
|
11
11
|
import assert from 'assert';
|
|
12
|
-
import {
|
|
12
|
+
import { blockStateReference, treeStateReferenceToSnapshot } from './message.js';
|
|
13
13
|
export class MerkleTreesFacade {
|
|
14
14
|
instance;
|
|
15
15
|
initialHeader;
|
|
@@ -23,18 +23,17 @@ export class MerkleTreesFacade {
|
|
|
23
23
|
return this.initialHeader;
|
|
24
24
|
}
|
|
25
25
|
getRevision() {
|
|
26
|
-
return
|
|
26
|
+
return this.revision;
|
|
27
|
+
}
|
|
28
|
+
getIpcPath() {
|
|
29
|
+
return this.instance.getIpcPath();
|
|
27
30
|
}
|
|
28
31
|
findLeafIndices(treeId, values) {
|
|
29
32
|
return this.findLeafIndicesAfter(treeId, values, 0n);
|
|
30
33
|
}
|
|
31
34
|
async findSiblingPaths(treeId, values) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
revision: this.revision,
|
|
35
|
-
treeId
|
|
36
|
-
});
|
|
37
|
-
return response.paths.map((path)=>{
|
|
35
|
+
const paths = await this.instance.findSiblingPaths(treeId, this.revision, values.map((leaf)=>serializeLeaf(hydrateLeaf(treeId, leaf))));
|
|
36
|
+
return paths.map((path)=>{
|
|
38
37
|
if (!path) {
|
|
39
38
|
return undefined;
|
|
40
39
|
}
|
|
@@ -45,13 +44,8 @@ export class MerkleTreesFacade {
|
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
async findLeafIndicesAfter(treeId, leaves, startIndex) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
revision: this.revision,
|
|
51
|
-
treeId,
|
|
52
|
-
startIndex
|
|
53
|
-
});
|
|
54
|
-
return response.indices.map((index)=>{
|
|
47
|
+
const indices = await this.instance.findLeafIndices(treeId, this.revision, leaves.map((leaf)=>serializeLeaf(hydrateLeaf(treeId, leaf))), startIndex);
|
|
48
|
+
return indices.map((index)=>{
|
|
55
49
|
if (typeof index === 'number' || typeof index === 'bigint') {
|
|
56
50
|
return BigInt(index);
|
|
57
51
|
} else {
|
|
@@ -60,117 +54,72 @@ export class MerkleTreesFacade {
|
|
|
60
54
|
});
|
|
61
55
|
}
|
|
62
56
|
async getLeafPreimage(treeId, leafIndex) {
|
|
63
|
-
const resp = await this.instance.
|
|
64
|
-
leafIndex,
|
|
65
|
-
revision: this.revision,
|
|
66
|
-
treeId
|
|
67
|
-
});
|
|
57
|
+
const resp = await this.instance.getLeafPreimage(treeId, this.revision, leafIndex);
|
|
68
58
|
return resp ? deserializeIndexedLeaf(resp) : undefined;
|
|
69
59
|
}
|
|
70
60
|
async getLeafValue(treeId, leafIndex) {
|
|
71
|
-
const resp = await this.instance.
|
|
72
|
-
leafIndex,
|
|
73
|
-
revision: this.revision,
|
|
74
|
-
treeId
|
|
75
|
-
});
|
|
61
|
+
const resp = await this.instance.getLeafValue(treeId, this.revision, leafIndex);
|
|
76
62
|
if (!resp) {
|
|
77
63
|
return undefined;
|
|
78
64
|
}
|
|
79
65
|
const leaf = deserializeLeafValue(resp);
|
|
80
66
|
if (leaf instanceof Fr) {
|
|
81
|
-
return leaf;
|
|
67
|
+
return treeId === MerkleTreeId.ARCHIVE ? new BlockHash(leaf) : leaf;
|
|
82
68
|
} else {
|
|
83
69
|
return leaf.toBuffer();
|
|
84
70
|
}
|
|
85
71
|
}
|
|
86
72
|
async getPreviousValueIndex(treeId, value) {
|
|
87
|
-
const resp = await this.instance.
|
|
88
|
-
key: new Fr(value),
|
|
89
|
-
revision: this.revision,
|
|
90
|
-
treeId
|
|
91
|
-
});
|
|
73
|
+
const resp = await this.instance.findLowLeaf(treeId, this.revision, new Fr(value));
|
|
92
74
|
return {
|
|
93
75
|
alreadyPresent: resp.alreadyPresent,
|
|
94
76
|
index: BigInt(resp.index)
|
|
95
77
|
};
|
|
96
78
|
}
|
|
97
79
|
async getSiblingPath(treeId, leafIndex) {
|
|
98
|
-
const siblingPath = await this.instance.
|
|
99
|
-
leafIndex,
|
|
100
|
-
revision: this.revision,
|
|
101
|
-
treeId
|
|
102
|
-
});
|
|
80
|
+
const siblingPath = await this.instance.getSiblingPath(treeId, this.revision, leafIndex);
|
|
103
81
|
return new SiblingPath(siblingPath.length, siblingPath);
|
|
104
82
|
}
|
|
105
83
|
async getStateReference() {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
return new StateReference(treeStateReferenceToSnapshot(resp.state[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]), new PartialStateReference(treeStateReferenceToSnapshot(resp.state[MerkleTreeId.NOTE_HASH_TREE]), treeStateReferenceToSnapshot(resp.state[MerkleTreeId.NULLIFIER_TREE]), treeStateReferenceToSnapshot(resp.state[MerkleTreeId.PUBLIC_DATA_TREE])));
|
|
84
|
+
const state = await this.instance.getStateReference(this.revision);
|
|
85
|
+
return new StateReference(treeStateReferenceToSnapshot(state[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]), new PartialStateReference(treeStateReferenceToSnapshot(state[MerkleTreeId.NOTE_HASH_TREE]), treeStateReferenceToSnapshot(state[MerkleTreeId.NULLIFIER_TREE]), treeStateReferenceToSnapshot(state[MerkleTreeId.PUBLIC_DATA_TREE])));
|
|
110
86
|
}
|
|
111
87
|
async getInitialStateReference() {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
return new StateReference(treeStateReferenceToSnapshot(resp.state[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]), new PartialStateReference(treeStateReferenceToSnapshot(resp.state[MerkleTreeId.NOTE_HASH_TREE]), treeStateReferenceToSnapshot(resp.state[MerkleTreeId.NULLIFIER_TREE]), treeStateReferenceToSnapshot(resp.state[MerkleTreeId.PUBLIC_DATA_TREE])));
|
|
88
|
+
const state = await this.instance.getInitialStateReference();
|
|
89
|
+
return new StateReference(treeStateReferenceToSnapshot(state[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]), new PartialStateReference(treeStateReferenceToSnapshot(state[MerkleTreeId.NOTE_HASH_TREE]), treeStateReferenceToSnapshot(state[MerkleTreeId.NULLIFIER_TREE]), treeStateReferenceToSnapshot(state[MerkleTreeId.PUBLIC_DATA_TREE])));
|
|
116
90
|
}
|
|
117
91
|
async getTreeInfo(treeId) {
|
|
118
|
-
|
|
119
|
-
treeId: treeId,
|
|
120
|
-
revision: this.revision
|
|
121
|
-
});
|
|
122
|
-
return {
|
|
123
|
-
depth: resp.depth,
|
|
124
|
-
root: resp.root,
|
|
125
|
-
size: BigInt(resp.size),
|
|
126
|
-
treeId
|
|
127
|
-
};
|
|
92
|
+
return await this.instance.getTreeInfo(treeId, this.revision);
|
|
128
93
|
}
|
|
129
94
|
async getBlockNumbersForLeafIndices(treeId, leafIndices) {
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
revision: this.revision,
|
|
133
|
-
leafIndices
|
|
134
|
-
});
|
|
135
|
-
return response.blockNumbers.map((x)=>x === undefined || x === null ? undefined : BlockNumber(Number(x)));
|
|
95
|
+
const blockNumbers = await this.instance.getBlockNumbersForLeafIndices(treeId, this.revision, leafIndices);
|
|
96
|
+
return blockNumbers.map((x)=>x === undefined || x === null ? undefined : BlockNumber(Number(x)));
|
|
136
97
|
}
|
|
137
98
|
}
|
|
138
|
-
_computedKey = Symbol.
|
|
99
|
+
_computedKey = Symbol.asyncDispose;
|
|
139
100
|
export class MerkleTreesForkFacade extends MerkleTreesFacade {
|
|
140
101
|
opts;
|
|
141
102
|
log;
|
|
103
|
+
closePromise;
|
|
142
104
|
constructor(instance, initialHeader, revision, opts){
|
|
143
105
|
assert.notEqual(revision.forkId, 0, 'Fork ID must be set');
|
|
144
106
|
assert.equal(revision.includeUncommitted, true, 'Fork must include uncommitted data');
|
|
145
107
|
super(instance, initialHeader, revision), this.opts = opts, this.log = createLogger('world-state:merkle-trees-fork-facade');
|
|
146
108
|
}
|
|
147
109
|
async updateArchive(header) {
|
|
148
|
-
await this.instance.
|
|
149
|
-
forkId: this.revision.forkId,
|
|
150
|
-
blockHeaderHash: (await header.hash()).toBuffer(),
|
|
151
|
-
blockStateRef: blockStateReference(header.state)
|
|
152
|
-
});
|
|
110
|
+
await this.instance.updateArchive(this.revision.forkId, blockStateReference(header.state), (await header.hash()).toBuffer());
|
|
153
111
|
}
|
|
154
112
|
async appendLeaves(treeId, leaves) {
|
|
155
|
-
await this.instance.
|
|
156
|
-
leaves: leaves.map((leaf)=>leaf),
|
|
157
|
-
forkId: this.revision.forkId,
|
|
158
|
-
treeId
|
|
159
|
-
});
|
|
113
|
+
await this.instance.appendLeaves(treeId, this.revision.forkId, leaves.map((leaf)=>serializeLeaf(hydrateLeaf(treeId, leaf))));
|
|
160
114
|
}
|
|
161
115
|
async batchInsert(treeId, rawLeaves, subtreeHeight) {
|
|
162
116
|
const leaves = rawLeaves.map((leaf)=>hydrateLeaf(treeId, leaf)).map(serializeLeaf);
|
|
163
|
-
const resp = await this.instance.
|
|
164
|
-
leaves,
|
|
165
|
-
treeId,
|
|
166
|
-
forkId: this.revision.forkId,
|
|
167
|
-
subtreeDepth: subtreeHeight
|
|
168
|
-
});
|
|
117
|
+
const resp = await this.instance.batchInsert(treeId, this.revision.forkId, leaves, subtreeHeight);
|
|
169
118
|
return {
|
|
170
|
-
newSubtreeSiblingPath: new SiblingPath(resp.
|
|
171
|
-
sortedNewLeaves: resp.
|
|
172
|
-
sortedNewLeavesIndexes: resp.
|
|
173
|
-
lowLeavesWitnessData: resp.
|
|
119
|
+
newSubtreeSiblingPath: new SiblingPath(resp.subtreePath.length, resp.subtreePath),
|
|
120
|
+
sortedNewLeaves: resp.sortedLeaves.map(([leaf])=>leaf).map(deserializeLeafValue).map(serializeToBuffer),
|
|
121
|
+
sortedNewLeavesIndexes: resp.sortedLeaves.map(([, index])=>index),
|
|
122
|
+
lowLeavesWitnessData: resp.lowLeafWitnessData.map((data)=>({
|
|
174
123
|
index: BigInt(data.index),
|
|
175
124
|
leafPreimage: deserializeIndexedLeaf(data.leaf),
|
|
176
125
|
siblingPath: new SiblingPath(data.path.length, data.path)
|
|
@@ -179,34 +128,42 @@ export class MerkleTreesForkFacade extends MerkleTreesFacade {
|
|
|
179
128
|
}
|
|
180
129
|
async sequentialInsert(treeId, rawLeaves) {
|
|
181
130
|
const leaves = rawLeaves.map((leaf)=>hydrateLeaf(treeId, leaf)).map(serializeLeaf);
|
|
182
|
-
const resp = await this.instance.
|
|
183
|
-
leaves,
|
|
184
|
-
treeId,
|
|
185
|
-
forkId: this.revision.forkId
|
|
186
|
-
});
|
|
131
|
+
const resp = await this.instance.sequentialInsert(treeId, this.revision.forkId, leaves);
|
|
187
132
|
return {
|
|
188
|
-
lowLeavesWitnessData: resp.
|
|
133
|
+
lowLeavesWitnessData: resp.lowLeafWitnessData.map((data)=>({
|
|
189
134
|
index: BigInt(data.index),
|
|
190
135
|
leafPreimage: deserializeIndexedLeaf(data.leaf),
|
|
191
136
|
siblingPath: new SiblingPath(data.path.length, data.path)
|
|
192
137
|
})),
|
|
193
|
-
insertionWitnessData: resp.
|
|
138
|
+
insertionWitnessData: resp.insertionWitnessData.map((data)=>({
|
|
194
139
|
index: BigInt(data.index),
|
|
195
140
|
leafPreimage: deserializeIndexedLeaf(data.leaf),
|
|
196
141
|
siblingPath: new SiblingPath(data.path.length, data.path)
|
|
197
142
|
}))
|
|
198
143
|
};
|
|
199
144
|
}
|
|
200
|
-
|
|
145
|
+
close() {
|
|
201
146
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
147
|
+
// Share the in-flight close promise across duplicate dispose calls so DELETE_FORK is sent at most once.
|
|
148
|
+
if (this.closePromise) {
|
|
149
|
+
return this.closePromise;
|
|
150
|
+
}
|
|
151
|
+
this.closePromise = this.doClose();
|
|
152
|
+
return this.closePromise;
|
|
153
|
+
}
|
|
154
|
+
async doClose() {
|
|
202
155
|
try {
|
|
203
|
-
await this.instance.
|
|
204
|
-
forkId: this.revision.forkId
|
|
205
|
-
});
|
|
156
|
+
await this.instance.deleteFork(this.revision.forkId);
|
|
206
157
|
} catch (err) {
|
|
207
158
|
// Ignore errors due to native instance being closed during shutdown.
|
|
208
159
|
// This can happen when validators are still processing block proposals while the node is stopping.
|
|
209
|
-
if (err?.message === 'Native instance is closed') {
|
|
160
|
+
if (err?.message === 'Native instance is closed' || err?.message === 'IPC instance is closed') {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// Ignore "Fork not found": the native fork was already destroyed by a pending-chain unwind or a
|
|
164
|
+
// historical prune (both call C++ remove_forks_for_block). Fork IDs are monotonic and never reused,
|
|
165
|
+
// so swallowing this on close cannot mask a deletion of a different fork.
|
|
166
|
+
if (err?.message === 'Fork not found') {
|
|
210
167
|
return;
|
|
211
168
|
}
|
|
212
169
|
throw err;
|
|
@@ -215,9 +172,6 @@ export class MerkleTreesForkFacade extends MerkleTreesFacade {
|
|
|
215
172
|
async [_computedKey]() {
|
|
216
173
|
if (this.opts.closeDelayMs) {
|
|
217
174
|
void sleep(this.opts.closeDelayMs).then(()=>this.close()).catch((err)=>{
|
|
218
|
-
if (err && 'message' in err && err.message === 'Native instance is closed') {
|
|
219
|
-
return; // Ignore errors due to native instance being closed
|
|
220
|
-
}
|
|
221
175
|
this.log.warn('Error closing MerkleTreesForkFacade after delay', {
|
|
222
176
|
err
|
|
223
177
|
});
|
|
@@ -228,38 +182,30 @@ export class MerkleTreesForkFacade extends MerkleTreesFacade {
|
|
|
228
182
|
}
|
|
229
183
|
async createCheckpoint() {
|
|
230
184
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
231
|
-
await this.instance.
|
|
232
|
-
forkId: this.revision.forkId
|
|
233
|
-
});
|
|
185
|
+
return await this.instance.createCheckpoint(this.revision.forkId);
|
|
234
186
|
}
|
|
235
187
|
async commitCheckpoint() {
|
|
236
188
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
237
|
-
await this.instance.
|
|
238
|
-
forkId: this.revision.forkId
|
|
239
|
-
});
|
|
189
|
+
await this.instance.commitCheckpoint(this.revision.forkId);
|
|
240
190
|
}
|
|
241
191
|
async revertCheckpoint() {
|
|
242
192
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
243
|
-
await this.instance.
|
|
244
|
-
forkId: this.revision.forkId
|
|
245
|
-
});
|
|
193
|
+
await this.instance.revertCheckpoint(this.revision.forkId);
|
|
246
194
|
}
|
|
247
|
-
async
|
|
195
|
+
async commitAllCheckpointsTo(depth) {
|
|
248
196
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
249
|
-
await this.instance.
|
|
250
|
-
forkId: this.revision.forkId
|
|
251
|
-
});
|
|
197
|
+
await this.instance.commitAllCheckpoints(this.revision.forkId, depth);
|
|
252
198
|
}
|
|
253
|
-
async
|
|
199
|
+
async revertAllCheckpointsTo(depth) {
|
|
254
200
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
255
|
-
await this.instance.
|
|
256
|
-
forkId: this.revision.forkId
|
|
257
|
-
});
|
|
201
|
+
await this.instance.revertAllCheckpoints(this.revision.forkId, depth);
|
|
258
202
|
}
|
|
259
203
|
}
|
|
260
204
|
function hydrateLeaf(treeId, leaf) {
|
|
261
205
|
if (leaf instanceof Fr) {
|
|
262
206
|
return leaf;
|
|
207
|
+
} else if (leaf instanceof BlockHash) {
|
|
208
|
+
return leaf.toFr();
|
|
263
209
|
} else if (treeId === MerkleTreeId.NULLIFIER_TREE) {
|
|
264
210
|
return NullifierLeaf.fromBuffer(leaf);
|
|
265
211
|
} else if (treeId === MerkleTreeId.PUBLIC_DATA_TREE) {
|
|
@@ -269,7 +215,9 @@ function hydrateLeaf(treeId, leaf) {
|
|
|
269
215
|
}
|
|
270
216
|
}
|
|
271
217
|
export function serializeLeaf(leaf) {
|
|
272
|
-
if (leaf instanceof
|
|
218
|
+
if (leaf instanceof BlockHash) {
|
|
219
|
+
return leaf.toBuffer();
|
|
220
|
+
} else if (leaf instanceof Fr) {
|
|
273
221
|
return leaf.toBuffer();
|
|
274
222
|
} else if (leaf instanceof NullifierLeaf) {
|
|
275
223
|
return {
|