@aztec/world-state 0.0.1-commit.d3ec352c → 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 +21 -50
- 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 +18 -9
- package/dest/native/merkle_trees_facade.d.ts.map +1 -1
- package/dest/native/merkle_trees_facade.js +90 -113
- package/dest/native/message.d.ts +15 -222
- package/dest/native/message.d.ts.map +1 -1
- package/dest/native/message.js +1 -43
- package/dest/native/native_world_state.d.ts +26 -12
- package/dest/native/native_world_state.d.ts.map +1 -1
- package/dest/native/native_world_state.js +126 -62
- 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 +16 -10
- package/dest/synchronizer/server_world_state_synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/server_world_state_synchronizer.js +170 -57
- package/dest/test/utils.d.ts +11 -17
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +49 -81
- package/dest/testing.d.ts +5 -4
- package/dest/testing.d.ts.map +1 -1
- package/dest/testing.js +15 -8
- package/dest/world-state-db/merkle_tree_db.d.ts +7 -18
- package/dest/world-state-db/merkle_tree_db.d.ts.map +1 -1
- package/package.json +14 -12
- package/src/index.ts +1 -0
- package/src/instrumentation/instrumentation.ts +23 -59
- 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 +119 -106
- package/src/native/message.ts +14 -287
- package/src/native/native_world_state.ts +159 -99
- 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 +203 -78
- package/src/test/utils.ts +79 -128
- package/src/testing.ts +13 -11
- package/src/world-state-db/merkle_tree_db.ts +10 -22
- 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/dest/synchronizer/utils.d.ts +0 -11
- package/dest/synchronizer/utils.d.ts.map +0 -1
- package/dest/synchronizer/utils.js +0 -59
- package/src/native/world_state_ops_queue.ts +0 -190
- package/src/synchronizer/utils.ts +0 -83
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
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>;
|
|
@@ -33,17 +35,24 @@ export declare class MerkleTreesFacade implements MerkleTreeReadOperations {
|
|
|
33
35
|
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(treeId: ID, leafIndices: bigint[]): Promise<(BlockNumber | undefined)[]>;
|
|
34
36
|
}
|
|
35
37
|
export declare class MerkleTreesForkFacade extends MerkleTreesFacade implements MerkleTreeWriteOperations {
|
|
36
|
-
|
|
38
|
+
private opts;
|
|
39
|
+
private log;
|
|
40
|
+
private closePromise;
|
|
41
|
+
constructor(instance: NativeWorldStateInstance, initialHeader: BlockHeader, revision: WorldStateRevision, opts: {
|
|
42
|
+
closeDelayMs?: number;
|
|
43
|
+
});
|
|
37
44
|
updateArchive(header: BlockHeader): Promise<void>;
|
|
38
45
|
appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void>;
|
|
39
46
|
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(treeId: ID, rawLeaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
|
|
40
47
|
sequentialInsert<TreeHeight extends number, ID extends IndexedTreeId>(treeId: ID, rawLeaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
|
|
41
48
|
close(): Promise<void>;
|
|
42
|
-
|
|
49
|
+
private doClose;
|
|
50
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
51
|
+
createCheckpoint(): Promise<number>;
|
|
43
52
|
commitCheckpoint(): Promise<void>;
|
|
44
53
|
revertCheckpoint(): Promise<void>;
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
commitAllCheckpointsTo(depth: number): Promise<void>;
|
|
55
|
+
revertAllCheckpointsTo(depth: number): Promise<void>;
|
|
47
56
|
}
|
|
48
|
-
export declare function serializeLeaf(leaf: Fr | NullifierLeaf | PublicDataTreeLeaf): SerializedLeafValue;
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
57
|
+
export declare function serializeLeaf(leaf: Fr | BlockHash | NullifierLeaf | PublicDataTreeLeaf): SerializedLeafValue;
|
|
58
|
+
//# sour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EQ7SUFFTSxLQUFLLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQVE1QjtZQUVhLE9BQU87SUFtQmYsQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQVUzQztJQUVZLGdCQUFnQixJQUFJLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FHL0M7SUFFWSxnQkFBZ0IsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLENBRzdDO0lBRVksZ0JBQWdCLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUc3QztJQUVZLHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdoRTtJQUVZLHNCQUFzQixDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdoRTtDQUNGO0FBZ0JELHdCQUFnQixhQUFhLENBQUMsSUFBSSxFQUFFLEVBQUUsR0FBRyxTQUFTLEdBQUcsYUFBYSxHQUFHLGtCQUFrQixHQUFHLG1CQUFtQixDQVU1RyJ9
|
|
@@ -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,
|
|
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,EAAE,SAAS,EAAE,MAAM,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AAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhE;CACF;AAgBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,EAAE,GAAG,SAAS,GAAG,aAAa,GAAG,kBAAkB,GAAG,mBAAmB,CAU5G"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
var _computedKey;
|
|
1
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
5
|
import { serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
|
+
import { sleep } from '@aztec/foundation/sleep';
|
|
4
7
|
import { SiblingPath } from '@aztec/foundation/trees';
|
|
8
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
5
9
|
import { MerkleTreeId, NullifierLeaf, NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
6
10
|
import { PartialStateReference, StateReference } from '@aztec/stdlib/tx';
|
|
7
|
-
import { WorldStateRevisionWithHandle } from '@aztec/stdlib/world-state';
|
|
8
11
|
import assert from 'assert';
|
|
9
|
-
import {
|
|
12
|
+
import { blockStateReference, treeStateReferenceToSnapshot } from './message.js';
|
|
10
13
|
export class MerkleTreesFacade {
|
|
11
14
|
instance;
|
|
12
15
|
initialHeader;
|
|
@@ -20,18 +23,17 @@ export class MerkleTreesFacade {
|
|
|
20
23
|
return this.initialHeader;
|
|
21
24
|
}
|
|
22
25
|
getRevision() {
|
|
23
|
-
return
|
|
26
|
+
return this.revision;
|
|
27
|
+
}
|
|
28
|
+
getIpcPath() {
|
|
29
|
+
return this.instance.getIpcPath();
|
|
24
30
|
}
|
|
25
31
|
findLeafIndices(treeId, values) {
|
|
26
32
|
return this.findLeafIndicesAfter(treeId, values, 0n);
|
|
27
33
|
}
|
|
28
34
|
async findSiblingPaths(treeId, values) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
revision: this.revision,
|
|
32
|
-
treeId
|
|
33
|
-
});
|
|
34
|
-
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)=>{
|
|
35
37
|
if (!path) {
|
|
36
38
|
return undefined;
|
|
37
39
|
}
|
|
@@ -42,13 +44,8 @@ export class MerkleTreesFacade {
|
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
async findLeafIndicesAfter(treeId, leaves, startIndex) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
revision: this.revision,
|
|
48
|
-
treeId,
|
|
49
|
-
startIndex
|
|
50
|
-
});
|
|
51
|
-
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)=>{
|
|
52
49
|
if (typeof index === 'number' || typeof index === 'bigint') {
|
|
53
50
|
return BigInt(index);
|
|
54
51
|
} else {
|
|
@@ -57,114 +54,72 @@ export class MerkleTreesFacade {
|
|
|
57
54
|
});
|
|
58
55
|
}
|
|
59
56
|
async getLeafPreimage(treeId, leafIndex) {
|
|
60
|
-
const resp = await this.instance.
|
|
61
|
-
leafIndex,
|
|
62
|
-
revision: this.revision,
|
|
63
|
-
treeId
|
|
64
|
-
});
|
|
57
|
+
const resp = await this.instance.getLeafPreimage(treeId, this.revision, leafIndex);
|
|
65
58
|
return resp ? deserializeIndexedLeaf(resp) : undefined;
|
|
66
59
|
}
|
|
67
60
|
async getLeafValue(treeId, leafIndex) {
|
|
68
|
-
const resp = await this.instance.
|
|
69
|
-
leafIndex,
|
|
70
|
-
revision: this.revision,
|
|
71
|
-
treeId
|
|
72
|
-
});
|
|
61
|
+
const resp = await this.instance.getLeafValue(treeId, this.revision, leafIndex);
|
|
73
62
|
if (!resp) {
|
|
74
63
|
return undefined;
|
|
75
64
|
}
|
|
76
65
|
const leaf = deserializeLeafValue(resp);
|
|
77
66
|
if (leaf instanceof Fr) {
|
|
78
|
-
return leaf;
|
|
67
|
+
return treeId === MerkleTreeId.ARCHIVE ? new BlockHash(leaf) : leaf;
|
|
79
68
|
} else {
|
|
80
69
|
return leaf.toBuffer();
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
72
|
async getPreviousValueIndex(treeId, value) {
|
|
84
|
-
const resp = await this.instance.
|
|
85
|
-
key: new Fr(value),
|
|
86
|
-
revision: this.revision,
|
|
87
|
-
treeId
|
|
88
|
-
});
|
|
73
|
+
const resp = await this.instance.findLowLeaf(treeId, this.revision, new Fr(value));
|
|
89
74
|
return {
|
|
90
75
|
alreadyPresent: resp.alreadyPresent,
|
|
91
76
|
index: BigInt(resp.index)
|
|
92
77
|
};
|
|
93
78
|
}
|
|
94
79
|
async getSiblingPath(treeId, leafIndex) {
|
|
95
|
-
const siblingPath = await this.instance.
|
|
96
|
-
leafIndex,
|
|
97
|
-
revision: this.revision,
|
|
98
|
-
treeId
|
|
99
|
-
});
|
|
80
|
+
const siblingPath = await this.instance.getSiblingPath(treeId, this.revision, leafIndex);
|
|
100
81
|
return new SiblingPath(siblingPath.length, siblingPath);
|
|
101
82
|
}
|
|
102
83
|
async getStateReference() {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
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])));
|
|
107
86
|
}
|
|
108
87
|
async getInitialStateReference() {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
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])));
|
|
113
90
|
}
|
|
114
91
|
async getTreeInfo(treeId) {
|
|
115
|
-
|
|
116
|
-
treeId: treeId,
|
|
117
|
-
revision: this.revision
|
|
118
|
-
});
|
|
119
|
-
return {
|
|
120
|
-
depth: resp.depth,
|
|
121
|
-
root: resp.root,
|
|
122
|
-
size: BigInt(resp.size),
|
|
123
|
-
treeId
|
|
124
|
-
};
|
|
92
|
+
return await this.instance.getTreeInfo(treeId, this.revision);
|
|
125
93
|
}
|
|
126
94
|
async getBlockNumbersForLeafIndices(treeId, leafIndices) {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
revision: this.revision,
|
|
130
|
-
leafIndices
|
|
131
|
-
});
|
|
132
|
-
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)));
|
|
133
97
|
}
|
|
134
98
|
}
|
|
99
|
+
_computedKey = Symbol.asyncDispose;
|
|
135
100
|
export class MerkleTreesForkFacade extends MerkleTreesFacade {
|
|
136
|
-
|
|
101
|
+
opts;
|
|
102
|
+
log;
|
|
103
|
+
closePromise;
|
|
104
|
+
constructor(instance, initialHeader, revision, opts){
|
|
137
105
|
assert.notEqual(revision.forkId, 0, 'Fork ID must be set');
|
|
138
106
|
assert.equal(revision.includeUncommitted, true, 'Fork must include uncommitted data');
|
|
139
|
-
super(instance, initialHeader, revision);
|
|
107
|
+
super(instance, initialHeader, revision), this.opts = opts, this.log = createLogger('world-state:merkle-trees-fork-facade');
|
|
140
108
|
}
|
|
141
109
|
async updateArchive(header) {
|
|
142
|
-
await this.instance.
|
|
143
|
-
forkId: this.revision.forkId,
|
|
144
|
-
blockHeaderHash: (await header.hash()).toBuffer(),
|
|
145
|
-
blockStateRef: blockStateReference(header.state)
|
|
146
|
-
});
|
|
110
|
+
await this.instance.updateArchive(this.revision.forkId, blockStateReference(header.state), (await header.hash()).toBuffer());
|
|
147
111
|
}
|
|
148
112
|
async appendLeaves(treeId, leaves) {
|
|
149
|
-
await this.instance.
|
|
150
|
-
leaves: leaves.map((leaf)=>leaf),
|
|
151
|
-
forkId: this.revision.forkId,
|
|
152
|
-
treeId
|
|
153
|
-
});
|
|
113
|
+
await this.instance.appendLeaves(treeId, this.revision.forkId, leaves.map((leaf)=>serializeLeaf(hydrateLeaf(treeId, leaf))));
|
|
154
114
|
}
|
|
155
115
|
async batchInsert(treeId, rawLeaves, subtreeHeight) {
|
|
156
116
|
const leaves = rawLeaves.map((leaf)=>hydrateLeaf(treeId, leaf)).map(serializeLeaf);
|
|
157
|
-
const resp = await this.instance.
|
|
158
|
-
leaves,
|
|
159
|
-
treeId,
|
|
160
|
-
forkId: this.revision.forkId,
|
|
161
|
-
subtreeDepth: subtreeHeight
|
|
162
|
-
});
|
|
117
|
+
const resp = await this.instance.batchInsert(treeId, this.revision.forkId, leaves, subtreeHeight);
|
|
163
118
|
return {
|
|
164
|
-
newSubtreeSiblingPath: new SiblingPath(resp.
|
|
165
|
-
sortedNewLeaves: resp.
|
|
166
|
-
sortedNewLeavesIndexes: resp.
|
|
167
|
-
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)=>({
|
|
168
123
|
index: BigInt(data.index),
|
|
169
124
|
leafPreimage: deserializeIndexedLeaf(data.leaf),
|
|
170
125
|
siblingPath: new SiblingPath(data.path.length, data.path)
|
|
@@ -173,64 +128,84 @@ export class MerkleTreesForkFacade extends MerkleTreesFacade {
|
|
|
173
128
|
}
|
|
174
129
|
async sequentialInsert(treeId, rawLeaves) {
|
|
175
130
|
const leaves = rawLeaves.map((leaf)=>hydrateLeaf(treeId, leaf)).map(serializeLeaf);
|
|
176
|
-
const resp = await this.instance.
|
|
177
|
-
leaves,
|
|
178
|
-
treeId,
|
|
179
|
-
forkId: this.revision.forkId
|
|
180
|
-
});
|
|
131
|
+
const resp = await this.instance.sequentialInsert(treeId, this.revision.forkId, leaves);
|
|
181
132
|
return {
|
|
182
|
-
lowLeavesWitnessData: resp.
|
|
133
|
+
lowLeavesWitnessData: resp.lowLeafWitnessData.map((data)=>({
|
|
183
134
|
index: BigInt(data.index),
|
|
184
135
|
leafPreimage: deserializeIndexedLeaf(data.leaf),
|
|
185
136
|
siblingPath: new SiblingPath(data.path.length, data.path)
|
|
186
137
|
})),
|
|
187
|
-
insertionWitnessData: resp.
|
|
138
|
+
insertionWitnessData: resp.insertionWitnessData.map((data)=>({
|
|
188
139
|
index: BigInt(data.index),
|
|
189
140
|
leafPreimage: deserializeIndexedLeaf(data.leaf),
|
|
190
141
|
siblingPath: new SiblingPath(data.path.length, data.path)
|
|
191
142
|
}))
|
|
192
143
|
};
|
|
193
144
|
}
|
|
194
|
-
|
|
145
|
+
close() {
|
|
195
146
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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() {
|
|
155
|
+
try {
|
|
156
|
+
await this.instance.deleteFork(this.revision.forkId);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
// Ignore errors due to native instance being closed during shutdown.
|
|
159
|
+
// This can happen when validators are still processing block proposals while the node is stopping.
|
|
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') {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
throw err;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async [_computedKey]() {
|
|
173
|
+
if (this.opts.closeDelayMs) {
|
|
174
|
+
void sleep(this.opts.closeDelayMs).then(()=>this.close()).catch((err)=>{
|
|
175
|
+
this.log.warn('Error closing MerkleTreesForkFacade after delay', {
|
|
176
|
+
err
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
await this.close();
|
|
181
|
+
}
|
|
199
182
|
}
|
|
200
183
|
async createCheckpoint() {
|
|
201
184
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
202
|
-
await this.instance.
|
|
203
|
-
forkId: this.revision.forkId
|
|
204
|
-
});
|
|
185
|
+
return await this.instance.createCheckpoint(this.revision.forkId);
|
|
205
186
|
}
|
|
206
187
|
async commitCheckpoint() {
|
|
207
188
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
208
|
-
await this.instance.
|
|
209
|
-
forkId: this.revision.forkId
|
|
210
|
-
});
|
|
189
|
+
await this.instance.commitCheckpoint(this.revision.forkId);
|
|
211
190
|
}
|
|
212
191
|
async revertCheckpoint() {
|
|
213
192
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
214
|
-
await this.instance.
|
|
215
|
-
forkId: this.revision.forkId
|
|
216
|
-
});
|
|
193
|
+
await this.instance.revertCheckpoint(this.revision.forkId);
|
|
217
194
|
}
|
|
218
|
-
async
|
|
195
|
+
async commitAllCheckpointsTo(depth) {
|
|
219
196
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
220
|
-
await this.instance.
|
|
221
|
-
forkId: this.revision.forkId
|
|
222
|
-
});
|
|
197
|
+
await this.instance.commitAllCheckpoints(this.revision.forkId, depth);
|
|
223
198
|
}
|
|
224
|
-
async
|
|
199
|
+
async revertAllCheckpointsTo(depth) {
|
|
225
200
|
assert.notEqual(this.revision.forkId, 0, 'Fork ID must be set');
|
|
226
|
-
await this.instance.
|
|
227
|
-
forkId: this.revision.forkId
|
|
228
|
-
});
|
|
201
|
+
await this.instance.revertAllCheckpoints(this.revision.forkId, depth);
|
|
229
202
|
}
|
|
230
203
|
}
|
|
231
204
|
function hydrateLeaf(treeId, leaf) {
|
|
232
205
|
if (leaf instanceof Fr) {
|
|
233
206
|
return leaf;
|
|
207
|
+
} else if (leaf instanceof BlockHash) {
|
|
208
|
+
return leaf.toFr();
|
|
234
209
|
} else if (treeId === MerkleTreeId.NULLIFIER_TREE) {
|
|
235
210
|
return NullifierLeaf.fromBuffer(leaf);
|
|
236
211
|
} else if (treeId === MerkleTreeId.PUBLIC_DATA_TREE) {
|
|
@@ -240,7 +215,9 @@ function hydrateLeaf(treeId, leaf) {
|
|
|
240
215
|
}
|
|
241
216
|
}
|
|
242
217
|
export function serializeLeaf(leaf) {
|
|
243
|
-
if (leaf instanceof
|
|
218
|
+
if (leaf instanceof BlockHash) {
|
|
219
|
+
return leaf.toBuffer();
|
|
220
|
+
} else if (leaf instanceof Fr) {
|
|
244
221
|
return leaf.toBuffer();
|
|
245
222
|
} else if (leaf instanceof NullifierLeaf) {
|
|
246
223
|
return {
|