@aztec/archiver 0.80.0 → 0.82.0
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/archiver/archiver.d.ts +8 -20
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +72 -102
- package/dest/archiver/archiver_store.d.ts +5 -19
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +105 -142
- package/dest/archiver/config.d.ts +2 -0
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +5 -0
- package/dest/archiver/data_retrieval.d.ts +3 -4
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +8 -3
- package/dest/archiver/index.d.ts +1 -2
- package/dest/archiver/index.d.ts.map +1 -1
- package/dest/archiver/index.js +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +6 -6
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +24 -21
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +6 -14
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +2 -19
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +11 -42
- package/dest/archiver/structs/published.d.ts +1 -10
- package/dest/archiver/structs/published.d.ts.map +1 -1
- package/dest/archiver/structs/published.js +1 -1
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -24
- package/dest/test/mock_l2_block_source.d.ts +10 -0
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +16 -0
- package/package.json +12 -13
- package/src/archiver/archiver.ts +86 -124
- package/src/archiver/archiver_store.ts +5 -21
- package/src/archiver/archiver_store_test_suite.ts +116 -147
- package/src/archiver/config.ts +8 -0
- package/src/archiver/data_retrieval.ts +12 -11
- package/src/archiver/index.ts +1 -2
- package/src/archiver/kv_archiver_store/block_store.ts +28 -27
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +6 -27
- package/src/archiver/kv_archiver_store/log_store.ts +12 -59
- package/src/archiver/structs/published.ts +1 -11
- package/src/factory.ts +3 -28
- package/src/test/mock_l2_block_source.ts +18 -0
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts +0 -12
- package/dest/archiver/kv_archiver_store/nullifier_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/nullifier_store.js +0 -73
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +0 -175
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +0 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +0 -636
- package/src/archiver/kv_archiver_store/nullifier_store.ts +0 -97
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +0 -801
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { MAX_NULLIFIERS_PER_TX } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
|
-
import type { InBlock, L2Block } from '@aztec/stdlib/block';
|
|
6
|
-
|
|
7
|
-
export class NullifierStore {
|
|
8
|
-
#nullifiersToBlockNumber: AztecAsyncMap<string, number>;
|
|
9
|
-
#nullifiersToBlockHash: AztecAsyncMap<string, string>;
|
|
10
|
-
#nullifiersToIndex: AztecAsyncMap<string, number>;
|
|
11
|
-
#log = createLogger('archiver:log_store');
|
|
12
|
-
|
|
13
|
-
constructor(private db: AztecAsyncKVStore) {
|
|
14
|
-
this.#nullifiersToBlockNumber = db.openMap('archiver_nullifiers_to_block_number');
|
|
15
|
-
this.#nullifiersToBlockHash = db.openMap('archiver_nullifiers_to_block_hash');
|
|
16
|
-
this.#nullifiersToIndex = db.openMap('archiver_nullifiers_to_index');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async addNullifiers(blocks: L2Block[]): Promise<boolean> {
|
|
20
|
-
const blockHashes = await Promise.all(blocks.map(block => block.hash()));
|
|
21
|
-
await this.db.transactionAsync(async () => {
|
|
22
|
-
await Promise.all(
|
|
23
|
-
blocks.map((block, i) => {
|
|
24
|
-
const dataStartIndexForBlock =
|
|
25
|
-
block.header.state.partial.nullifierTree.nextAvailableLeafIndex -
|
|
26
|
-
block.body.txEffects.length * MAX_NULLIFIERS_PER_TX;
|
|
27
|
-
return Promise.all(
|
|
28
|
-
block.body.txEffects.map((txEffects, txIndex) => {
|
|
29
|
-
const dataStartIndexForTx = dataStartIndexForBlock + txIndex * MAX_NULLIFIERS_PER_TX;
|
|
30
|
-
return Promise.all(
|
|
31
|
-
txEffects.nullifiers.map(async (nullifier, nullifierIndex) => {
|
|
32
|
-
await this.#nullifiersToBlockNumber.set(nullifier.toString(), block.number);
|
|
33
|
-
await this.#nullifiersToBlockHash.set(nullifier.toString(), blockHashes[i].toString());
|
|
34
|
-
await this.#nullifiersToIndex.set(nullifier.toString(), dataStartIndexForTx + nullifierIndex);
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
37
|
-
}),
|
|
38
|
-
);
|
|
39
|
-
}),
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async deleteNullifiers(blocks: L2Block[]): Promise<boolean> {
|
|
46
|
-
await this.db.transactionAsync(async () => {
|
|
47
|
-
for (const block of blocks) {
|
|
48
|
-
for (const nullifier of block.body.txEffects.flatMap(tx => tx.nullifiers)) {
|
|
49
|
-
await Promise.all([
|
|
50
|
-
this.#nullifiersToBlockNumber.delete(nullifier.toString()),
|
|
51
|
-
this.#nullifiersToBlockHash.delete(nullifier.toString()),
|
|
52
|
-
this.#nullifiersToIndex.delete(nullifier.toString()),
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async findNullifiersIndexesWithBlock(
|
|
61
|
-
blockNumber: number,
|
|
62
|
-
nullifiers: Fr[],
|
|
63
|
-
): Promise<(InBlock<bigint> | undefined)[]> {
|
|
64
|
-
const asStrings = nullifiers.map(x => x.toString());
|
|
65
|
-
|
|
66
|
-
const maybeNullifiers = await Promise.all(
|
|
67
|
-
asStrings.map(async nullifier => {
|
|
68
|
-
const [data, l2BlockNumber, l2BlockHash] = await Promise.all([
|
|
69
|
-
this.#nullifiersToIndex.getAsync(nullifier),
|
|
70
|
-
this.#nullifiersToBlockNumber.getAsync(nullifier),
|
|
71
|
-
this.#nullifiersToBlockHash.getAsync(nullifier),
|
|
72
|
-
]);
|
|
73
|
-
return {
|
|
74
|
-
data,
|
|
75
|
-
l2BlockNumber,
|
|
76
|
-
l2BlockHash,
|
|
77
|
-
};
|
|
78
|
-
}),
|
|
79
|
-
);
|
|
80
|
-
return maybeNullifiers.map(({ data, l2BlockNumber, l2BlockHash }) => {
|
|
81
|
-
if (
|
|
82
|
-
data === undefined ||
|
|
83
|
-
l2BlockNumber === undefined ||
|
|
84
|
-
l2BlockHash === undefined ||
|
|
85
|
-
l2BlockNumber > blockNumber
|
|
86
|
-
) {
|
|
87
|
-
return undefined;
|
|
88
|
-
} else {
|
|
89
|
-
return {
|
|
90
|
-
data: BigInt(data),
|
|
91
|
-
l2BlockNumber,
|
|
92
|
-
l2BlockHash,
|
|
93
|
-
} as InBlock<bigint>;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|