@aztec/kv-store 0.0.1-commit.b6e433891 → 0.0.1-commit.b9865e97
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/README.md +8 -1
- package/dest/bench/shared_map_bench.d.ts +19 -0
- package/dest/bench/shared_map_bench.d.ts.map +1 -0
- package/dest/bench/shared_map_bench.js +91 -0
- package/dest/indexeddb/index.js +1 -1
- package/dest/interfaces/array_test_suite.d.ts +1 -1
- package/dest/interfaces/array_test_suite.d.ts.map +1 -1
- package/dest/interfaces/array_test_suite.js +33 -34
- package/dest/interfaces/index.d.ts +2 -2
- package/dest/interfaces/index.d.ts.map +1 -1
- package/dest/interfaces/map_test_suite.d.ts +1 -1
- package/dest/interfaces/map_test_suite.d.ts.map +1 -1
- package/dest/interfaces/map_test_suite.js +32 -33
- package/dest/interfaces/multi_map_test_suite.d.ts +1 -1
- package/dest/interfaces/multi_map_test_suite.d.ts.map +1 -1
- package/dest/interfaces/multi_map_test_suite.js +68 -69
- package/dest/interfaces/set_test_suite.d.ts +1 -1
- package/dest/interfaces/set_test_suite.d.ts.map +1 -1
- package/dest/interfaces/set_test_suite.js +13 -14
- package/dest/interfaces/singleton_test_suite.d.ts +1 -1
- package/dest/interfaces/singleton_test_suite.d.ts.map +1 -1
- package/dest/interfaces/singleton_test_suite.js +6 -7
- package/dest/lmdb/index.js +2 -2
- package/dest/lmdb-v2/factory.d.ts +28 -3
- package/dest/lmdb-v2/factory.d.ts.map +1 -1
- package/dest/lmdb-v2/factory.js +61 -10
- package/dest/lmdb-v2/read_transaction.js +21 -19
- package/dest/lmdb-v2/store.d.ts +2 -2
- package/dest/lmdb-v2/store.d.ts.map +1 -1
- package/dest/lmdb-v2/store.js +4 -4
- package/dest/sqlite-opfs/array.d.ts +21 -0
- package/dest/sqlite-opfs/array.d.ts.map +1 -0
- package/dest/sqlite-opfs/array.js +128 -0
- package/dest/sqlite-opfs/errors.d.ts +27 -0
- package/dest/sqlite-opfs/errors.d.ts.map +1 -0
- package/dest/sqlite-opfs/errors.js +34 -0
- package/dest/sqlite-opfs/index.d.ts +16 -0
- package/dest/sqlite-opfs/index.d.ts.map +1 -0
- package/dest/sqlite-opfs/index.js +22 -0
- package/dest/sqlite-opfs/internal/ordered-binary-browser.d.ts +32 -0
- package/dest/sqlite-opfs/internal/ordered-binary-browser.d.ts.map +1 -0
- package/dest/sqlite-opfs/internal/ordered-binary-browser.js +448 -0
- package/dest/sqlite-opfs/map.d.ts +35 -0
- package/dest/sqlite-opfs/map.d.ts.map +1 -0
- package/dest/sqlite-opfs/map.js +163 -0
- package/dest/sqlite-opfs/messages.d.ts +66 -0
- package/dest/sqlite-opfs/messages.d.ts.map +1 -0
- package/dest/sqlite-opfs/messages.js +5 -0
- package/dest/sqlite-opfs/multi_map.d.ts +16 -0
- package/dest/sqlite-opfs/multi_map.d.ts.map +1 -0
- package/dest/sqlite-opfs/multi_map.js +67 -0
- package/dest/sqlite-opfs/set.d.ts +13 -0
- package/dest/sqlite-opfs/set.d.ts.map +1 -0
- package/dest/sqlite-opfs/set.js +19 -0
- package/dest/sqlite-opfs/singleton.d.ts +13 -0
- package/dest/sqlite-opfs/singleton.d.ts.map +1 -0
- package/dest/sqlite-opfs/singleton.js +48 -0
- package/dest/sqlite-opfs/store.d.ts +79 -0
- package/dest/sqlite-opfs/store.d.ts.map +1 -0
- package/dest/sqlite-opfs/store.js +281 -0
- package/dest/sqlite-opfs/worker.d.ts +2 -0
- package/dest/sqlite-opfs/worker.d.ts.map +1 -0
- package/dest/sqlite-opfs/worker.js +249 -0
- package/dest/stores/l2_tips_store.d.ts +3 -3
- package/dest/stores/l2_tips_store.d.ts.map +1 -1
- package/dest/stores/l2_tips_store.js +2 -2
- package/package.json +22 -19
- package/src/bench/shared_map_bench.ts +111 -0
- package/src/indexeddb/index.ts +1 -1
- package/src/interfaces/array_test_suite.ts +33 -35
- package/src/interfaces/index.ts +1 -1
- package/src/interfaces/map_test_suite.ts +32 -34
- package/src/interfaces/multi_map_test_suite.ts +65 -67
- package/src/interfaces/set_test_suite.ts +13 -15
- package/src/interfaces/singleton_test_suite.ts +6 -8
- package/src/lmdb/index.ts +2 -2
- package/src/lmdb-v2/factory.ts +79 -9
- package/src/lmdb-v2/read_transaction.ts +23 -23
- package/src/lmdb-v2/store.ts +4 -2
- package/src/sqlite-opfs/array.ts +124 -0
- package/src/sqlite-opfs/errors.ts +44 -0
- package/src/sqlite-opfs/index.ts +39 -0
- package/src/sqlite-opfs/internal/ordered-binary-browser.js +465 -0
- package/src/sqlite-opfs/map.ts +163 -0
- package/src/sqlite-opfs/messages.ts +39 -0
- package/src/sqlite-opfs/multi_map.ts +74 -0
- package/src/sqlite-opfs/set.ts +29 -0
- package/src/sqlite-opfs/singleton.ts +48 -0
- package/src/sqlite-opfs/store.ts +296 -0
- package/src/sqlite-opfs/worker.ts +231 -0
- package/src/stores/l2_tips_store.ts +3 -2
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
2
|
+
import sqlite3InitModule from '@aztec/sqlite3mc-wasm';
|
|
3
|
+
import { SqliteEncryptionError, isDecryptFailureMessage } from './errors.js';
|
|
4
|
+
const SCHEMA_SQL = `
|
|
5
|
+
CREATE TABLE IF NOT EXISTS data (
|
|
6
|
+
slot TEXT NOT NULL PRIMARY KEY,
|
|
7
|
+
container TEXT NOT NULL,
|
|
8
|
+
key BLOB NOT NULL,
|
|
9
|
+
key_count INTEGER NOT NULL,
|
|
10
|
+
hash TEXT NOT NULL,
|
|
11
|
+
value BLOB
|
|
12
|
+
) WITHOUT ROWID;
|
|
13
|
+
|
|
14
|
+
CREATE INDEX IF NOT EXISTS idx_container_key ON data(container, key);
|
|
15
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_container_key_count ON data(container, key, key_count);
|
|
16
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_container_key_hash ON data(container, key, hash);
|
|
17
|
+
`;
|
|
18
|
+
const DEFAULT_SAH_POOL_DIRECTORY = '.aztec-kv';
|
|
19
|
+
const SAH_POOL_VFS_NAME = 'aztec-kv-opfs';
|
|
20
|
+
const MC_SAH_POOL_VFS_NAME = `multipleciphers-${SAH_POOL_VFS_NAME}`;
|
|
21
|
+
let sqlite3;
|
|
22
|
+
let pool;
|
|
23
|
+
let db;
|
|
24
|
+
let dbPath;
|
|
25
|
+
async function ensurePool(directory) {
|
|
26
|
+
sqlite3 ??= await sqlite3InitModule();
|
|
27
|
+
const s = sqlite3;
|
|
28
|
+
if (!pool) {
|
|
29
|
+
pool = await s.installOpfsSAHPoolVfs({
|
|
30
|
+
name: SAH_POOL_VFS_NAME,
|
|
31
|
+
directory,
|
|
32
|
+
initialCapacity: 8
|
|
33
|
+
});
|
|
34
|
+
// Register a sqlite3mc-wrapped VFS pointing at our SAH Pool VFS.
|
|
35
|
+
// Encrypted DBs must be opened through this wrapper so sqlite3mc can
|
|
36
|
+
// intercept file I/O; plain DBs continue using the SAH Pool VFS directly.
|
|
37
|
+
// The wrapper name is `multipleciphers-<underlying>`.
|
|
38
|
+
s.capi.sqlite3mc_vfs_create(SAH_POOL_VFS_NAME, 0);
|
|
39
|
+
}
|
|
40
|
+
return pool;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Applies sqlite3mc's ChaCha20 page cipher using a pre-derived 32-byte key.
|
|
44
|
+
* The PRAGMAs must run before any schema DDL so sqlite3mc can decrypt existing
|
|
45
|
+
* pages and encrypt new ones. Zeroes the caller-held key array after the PRAGMA
|
|
46
|
+
* completes to minimize residency of the raw key bytes outside sqlite3mc's heap.
|
|
47
|
+
*/ function applyEncryptionKey(conn, key) {
|
|
48
|
+
const hex = Array.from(key, (b)=>b.toString(16).padStart(2, '0')).join('');
|
|
49
|
+
conn.exec(`PRAGMA cipher = 'chacha20'`);
|
|
50
|
+
conn.exec(`PRAGMA key = "x'${hex}'"`);
|
|
51
|
+
key.fill(0);
|
|
52
|
+
}
|
|
53
|
+
async function handleInit(dbName, ephemeral, directory, encryptionKey) {
|
|
54
|
+
sqlite3 ??= await sqlite3InitModule();
|
|
55
|
+
const s = sqlite3;
|
|
56
|
+
if (encryptionKey !== undefined && ephemeral) {
|
|
57
|
+
throw new SqliteEncryptionError('encryption_not_supported_for_ephemeral', 'encryptionKey is not supported for ephemeral (:memory:) stores');
|
|
58
|
+
}
|
|
59
|
+
if (ephemeral) {
|
|
60
|
+
db = new s.oo1.DB(':memory:', 'c');
|
|
61
|
+
} else {
|
|
62
|
+
await ensurePool(directory ?? DEFAULT_SAH_POOL_DIRECTORY);
|
|
63
|
+
dbPath = normalizeDbPath(dbName);
|
|
64
|
+
if (encryptionKey !== undefined) {
|
|
65
|
+
db = new s.oo1.DB({
|
|
66
|
+
filename: dbPath,
|
|
67
|
+
flags: 'c',
|
|
68
|
+
vfs: MC_SAH_POOL_VFS_NAME
|
|
69
|
+
});
|
|
70
|
+
applyEncryptionKey(db, encryptionKey);
|
|
71
|
+
} else {
|
|
72
|
+
db = new pool.OpfsSAHPoolDb(dbPath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
runSql(SCHEMA_SQL);
|
|
76
|
+
}
|
|
77
|
+
function handleClose() {
|
|
78
|
+
db?.close();
|
|
79
|
+
db = undefined;
|
|
80
|
+
dbPath = undefined;
|
|
81
|
+
}
|
|
82
|
+
async function handleExport() {
|
|
83
|
+
if (!db || !dbPath) {
|
|
84
|
+
throw new Error('SQLite worker: no database open to export');
|
|
85
|
+
}
|
|
86
|
+
if (!pool) {
|
|
87
|
+
throw new Error('SQLite worker: no SAH Pool available (ephemeral DBs cannot be exported)');
|
|
88
|
+
}
|
|
89
|
+
return await pool.exportFile(dbPath);
|
|
90
|
+
}
|
|
91
|
+
function handleDeleteDb(dbName) {
|
|
92
|
+
const path = normalizeDbPath(dbName);
|
|
93
|
+
if (db && dbPath === path) {
|
|
94
|
+
db.close();
|
|
95
|
+
db = undefined;
|
|
96
|
+
dbPath = undefined;
|
|
97
|
+
}
|
|
98
|
+
// Ephemeral :memory: DBs never back a file — skip installing a pool just to unlink
|
|
99
|
+
// nothing. installOpfsSAHPoolVfs acquires an exclusive lock on the OPFS SAH
|
|
100
|
+
// directory, and under heavy test churn that can contend with workers from
|
|
101
|
+
// previous tests whose OPFS handles Chromium hasn't yet released, hanging the RPC
|
|
102
|
+
// and then the whole test run.
|
|
103
|
+
if (!pool) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
pool.unlink(path);
|
|
108
|
+
} catch {
|
|
109
|
+
// File may not exist; ignore.
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function requireDb() {
|
|
113
|
+
if (!db) {
|
|
114
|
+
throw new Error('SQLite worker: no database open');
|
|
115
|
+
}
|
|
116
|
+
return db;
|
|
117
|
+
}
|
|
118
|
+
function runSql(sql, bind) {
|
|
119
|
+
const conn = requireDb();
|
|
120
|
+
conn.exec({
|
|
121
|
+
sql,
|
|
122
|
+
bind
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
changes: conn.changes()
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function selectAll(sql, bind) {
|
|
129
|
+
const conn = requireDb();
|
|
130
|
+
const rows = [];
|
|
131
|
+
conn.exec({
|
|
132
|
+
sql,
|
|
133
|
+
bind,
|
|
134
|
+
rowMode: 'array',
|
|
135
|
+
resultRows: rows
|
|
136
|
+
});
|
|
137
|
+
return rows;
|
|
138
|
+
}
|
|
139
|
+
function normalizeDbPath(dbName) {
|
|
140
|
+
return dbName.startsWith('/') ? dbName : `/${dbName}`;
|
|
141
|
+
}
|
|
142
|
+
function respond(msg) {
|
|
143
|
+
self.postMessage(msg);
|
|
144
|
+
}
|
|
145
|
+
self.onmessage = async (ev)=>{
|
|
146
|
+
const req = ev.data;
|
|
147
|
+
try {
|
|
148
|
+
switch(req.type){
|
|
149
|
+
case 'init':
|
|
150
|
+
await handleInit(req.dbName, req.ephemeral, req.poolDirectory, req.encryptionKey);
|
|
151
|
+
return respond({
|
|
152
|
+
type: 'ok',
|
|
153
|
+
id: req.id
|
|
154
|
+
});
|
|
155
|
+
case 'close':
|
|
156
|
+
handleClose();
|
|
157
|
+
return respond({
|
|
158
|
+
type: 'ok',
|
|
159
|
+
id: req.id
|
|
160
|
+
});
|
|
161
|
+
case 'deleteDb':
|
|
162
|
+
handleDeleteDb(req.dbName);
|
|
163
|
+
return respond({
|
|
164
|
+
type: 'ok',
|
|
165
|
+
id: req.id
|
|
166
|
+
});
|
|
167
|
+
case 'run':
|
|
168
|
+
{
|
|
169
|
+
const { changes } = runSql(req.sql, req.bind);
|
|
170
|
+
return respond({
|
|
171
|
+
type: 'ok',
|
|
172
|
+
id: req.id,
|
|
173
|
+
changes
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
case 'all':
|
|
177
|
+
{
|
|
178
|
+
const rows = selectAll(req.sql, req.bind);
|
|
179
|
+
return respond({
|
|
180
|
+
type: 'ok',
|
|
181
|
+
id: req.id,
|
|
182
|
+
rows
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
case 'export':
|
|
186
|
+
{
|
|
187
|
+
const bytes = await handleExport();
|
|
188
|
+
return respond({
|
|
189
|
+
type: 'ok',
|
|
190
|
+
id: req.id,
|
|
191
|
+
bytes
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
case 'begin':
|
|
195
|
+
runSql('BEGIN');
|
|
196
|
+
return respond({
|
|
197
|
+
type: 'ok',
|
|
198
|
+
id: req.id
|
|
199
|
+
});
|
|
200
|
+
case 'commit':
|
|
201
|
+
runSql('COMMIT');
|
|
202
|
+
return respond({
|
|
203
|
+
type: 'ok',
|
|
204
|
+
id: req.id
|
|
205
|
+
});
|
|
206
|
+
case 'rollback':
|
|
207
|
+
runSql('ROLLBACK');
|
|
208
|
+
return respond({
|
|
209
|
+
type: 'ok',
|
|
210
|
+
id: req.id
|
|
211
|
+
});
|
|
212
|
+
default:
|
|
213
|
+
{
|
|
214
|
+
const _exhaustive = req;
|
|
215
|
+
throw new Error(`Unknown request: ${JSON.stringify(_exhaustive)}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} catch (err) {
|
|
219
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
220
|
+
respond({
|
|
221
|
+
type: 'err',
|
|
222
|
+
id: req.id,
|
|
223
|
+
message,
|
|
224
|
+
encryptionCode: detectEncryptionCode(req, err, message)
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Maps a thrown error during request handling to a typed encryption code, so the
|
|
230
|
+
* main thread can re-hydrate it as a {@link SqliteEncryptionError}. Returns
|
|
231
|
+
* `undefined` for non-encryption errors (preserves the existing untyped path).
|
|
232
|
+
*
|
|
233
|
+
* Two sources:
|
|
234
|
+
* - The error was already a `SqliteEncryptionError` (pre-flight throws inside
|
|
235
|
+
* this worker — e.g. ephemeral + encryptionKey). Forward its code as-is.
|
|
236
|
+
* - The error came from SQLite/sqlite3mc with a known decrypt-failure message
|
|
237
|
+
* during an `init` request. Both "wrong key supplied" and "no key supplied
|
|
238
|
+
* to an encrypted DB" surface as SQLITE_NOTADB ("file is not a database") —
|
|
239
|
+
* we don't constrain on `req.encryptionKey` because the no-key-on-encrypted-DB
|
|
240
|
+
* case is exactly when the caller most needs the typed signal.
|
|
241
|
+
*/ function detectEncryptionCode(req, err, message) {
|
|
242
|
+
if (err instanceof SqliteEncryptionError) {
|
|
243
|
+
return err.code;
|
|
244
|
+
}
|
|
245
|
+
if (req.type === 'init' && isDecryptFailureMessage(message)) {
|
|
246
|
+
return 'decrypt_failed';
|
|
247
|
+
}
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { type L2BlockTag, L2TipsStoreBase } from '@aztec/stdlib/block';
|
|
2
|
+
import { type BlockHash, type L2BlockTag, L2TipsStoreBase } from '@aztec/stdlib/block';
|
|
3
3
|
import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
4
4
|
import type { AztecAsyncKVStore } from '../interfaces/store.js';
|
|
5
5
|
/**
|
|
@@ -12,7 +12,7 @@ export declare class L2TipsKVStore extends L2TipsStoreBase {
|
|
|
12
12
|
private readonly l2BlockHashesStore;
|
|
13
13
|
private readonly l2BlockNumberToCheckpointNumberStore;
|
|
14
14
|
private readonly l2CheckpointStore;
|
|
15
|
-
constructor(store: AztecAsyncKVStore, namespace: string);
|
|
15
|
+
constructor(store: AztecAsyncKVStore, namespace: string, initialBlockHash: BlockHash);
|
|
16
16
|
protected getTip(tag: L2BlockTag): Promise<BlockNumber | undefined>;
|
|
17
17
|
protected setTip(tag: L2BlockTag, blockNumber: BlockNumber): Promise<void>;
|
|
18
18
|
protected getStoredBlockHash(blockNumber: BlockNumber): Promise<string | undefined>;
|
|
@@ -26,4 +26,4 @@ export declare class L2TipsKVStore extends L2TipsStoreBase {
|
|
|
26
26
|
protected deleteCheckpointsBefore(checkpointNumber: CheckpointNumber): Promise<void>;
|
|
27
27
|
protected runInTransaction<T>(fn: () => Promise<T>): Promise<T>;
|
|
28
28
|
}
|
|
29
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfdGlwc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3N0b3Jlcy9sMl90aXBzX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNoRixPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQUUsS0FBSyxVQUFVLEVBQUUsZUFBZSxFQUFFLE1BQU0scUJBQX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W,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAErG;IAED,SAAS,CAAC,2BAA2B,CAAC,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjH;IAED,UAAgB,6BAA6B,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrF;IAED,UAAgB,aAAa,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAM1G;IAED,SAAS,CAAC,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;IAED,UAAgB,uBAAuB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAIzF;IAED,SAAS,CAAC,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE9D;CACF"}
|
|
@@ -9,8 +9,8 @@ import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
|
9
9
|
l2BlockHashesStore;
|
|
10
10
|
l2BlockNumberToCheckpointNumberStore;
|
|
11
11
|
l2CheckpointStore;
|
|
12
|
-
constructor(store, namespace){
|
|
13
|
-
super(), this.store = store;
|
|
12
|
+
constructor(store, namespace, initialBlockHash){
|
|
13
|
+
super(initialBlockHash), this.store = store;
|
|
14
14
|
this.l2TipsStore = store.openMap([
|
|
15
15
|
namespace,
|
|
16
16
|
'l2_tips'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/kv-store",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.b9865e97",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/interfaces/index.js",
|
|
@@ -8,15 +8,27 @@
|
|
|
8
8
|
"./lmdb": "./dest/lmdb/index.js",
|
|
9
9
|
"./lmdb-v2": "./dest/lmdb-v2/index.js",
|
|
10
10
|
"./indexeddb": "./dest/indexeddb/index.js",
|
|
11
|
+
"./sqlite-opfs": "./dest/sqlite-opfs/index.js",
|
|
11
12
|
"./stores": "./dest/stores/index.js"
|
|
12
13
|
},
|
|
14
|
+
"imports": {
|
|
15
|
+
"#msgpackr": {
|
|
16
|
+
"browser": "msgpackr/index-no-eval",
|
|
17
|
+
"default": "msgpackr"
|
|
18
|
+
},
|
|
19
|
+
"#ordered-binary": {
|
|
20
|
+
"browser": "./dest/sqlite-opfs/internal/ordered-binary-browser.js",
|
|
21
|
+
"default": "ordered-binary"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
13
24
|
"scripts": {
|
|
14
25
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
15
26
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
16
27
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
17
|
-
"test:node": "
|
|
18
|
-
"test:browser": "
|
|
19
|
-
"
|
|
28
|
+
"test:node": "vitest run --project node",
|
|
29
|
+
"test:browser": "bash scripts/run-browser-tests.sh",
|
|
30
|
+
"bench:browser": "VITE_BENCH=1 vitest run --project browser src/bench",
|
|
31
|
+
"test": "vitest run",
|
|
20
32
|
"test:jest": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
21
33
|
},
|
|
22
34
|
"inherits": [
|
|
@@ -24,11 +36,12 @@
|
|
|
24
36
|
"./package.local.json"
|
|
25
37
|
],
|
|
26
38
|
"dependencies": {
|
|
27
|
-
"@aztec/constants": "0.0.1-commit.
|
|
28
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
29
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
30
|
-
"@aztec/native": "0.0.1-commit.
|
|
31
|
-
"@aztec/
|
|
39
|
+
"@aztec/constants": "0.0.1-commit.b9865e97",
|
|
40
|
+
"@aztec/ethereum": "0.0.1-commit.b9865e97",
|
|
41
|
+
"@aztec/foundation": "0.0.1-commit.b9865e97",
|
|
42
|
+
"@aztec/native": "0.0.1-commit.b9865e97",
|
|
43
|
+
"@aztec/sqlite3mc-wasm": "0.0.1-commit.b9865e97",
|
|
44
|
+
"@aztec/stdlib": "0.0.1-commit.b9865e97",
|
|
32
45
|
"idb": "^8.0.0",
|
|
33
46
|
"lmdb": "^3.2.0",
|
|
34
47
|
"msgpackr": "^1.11.2",
|
|
@@ -37,23 +50,13 @@
|
|
|
37
50
|
},
|
|
38
51
|
"devDependencies": {
|
|
39
52
|
"@jest/globals": "^30.0.0",
|
|
40
|
-
"@types/chai": "^5.0.1",
|
|
41
|
-
"@types/chai-as-promised": "^8.0.1",
|
|
42
53
|
"@types/jest": "^30.0.0",
|
|
43
|
-
"@types/mocha": "^10.0.10",
|
|
44
|
-
"@types/mocha-each": "^2.0.4",
|
|
45
54
|
"@types/node": "^22.15.17",
|
|
46
|
-
"@types/sinon": "^17.0.3",
|
|
47
55
|
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
48
56
|
"@vitest/browser-playwright": "^4.0.0",
|
|
49
57
|
"buffer": "^6.0.3",
|
|
50
|
-
"chai": "^5.1.2",
|
|
51
|
-
"chai-as-promised": "^8.0.1",
|
|
52
58
|
"jest": "^30.0.0",
|
|
53
|
-
"mocha": "^10.8.2",
|
|
54
|
-
"mocha-each": "^2.0.1",
|
|
55
59
|
"playwright": "1.49.0",
|
|
56
|
-
"sinon": "^19.0.2",
|
|
57
60
|
"ts-node": "^10.9.1",
|
|
58
61
|
"typescript": "^5.3.3",
|
|
59
62
|
"util": "^0.12.5",
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
+
|
|
4
|
+
import type { Key } from '../interfaces/common.js';
|
|
5
|
+
import type { AztecAsyncMap } from '../interfaces/map.js';
|
|
6
|
+
import type { AztecAsyncKVStore } from '../interfaces/store.js';
|
|
7
|
+
|
|
8
|
+
/** One benchmark measurement. */
|
|
9
|
+
export type BenchResult = {
|
|
10
|
+
/** Benchmark name (includes the backend prefix for disambiguation). */
|
|
11
|
+
name: string;
|
|
12
|
+
value: number;
|
|
13
|
+
unit: 'ms' | 'us';
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type BenchReporter = (results: BenchResult[]) => void | Promise<void>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Runs the standard Map benchmark suite against any `AztecAsyncKVStore` backend,
|
|
20
|
+
* populates `results`, and calls `reporter` in `afterAll`.
|
|
21
|
+
*
|
|
22
|
+
* Kept free of Node-only deps (`fs`, `path`) so the same runner works under
|
|
23
|
+
* vitest-browser for IndexedDB and SQLite-OPFS.
|
|
24
|
+
*/
|
|
25
|
+
export function describeAztecMapBench(
|
|
26
|
+
backendPrefix: string,
|
|
27
|
+
getStore: () => Promise<AztecAsyncKVStore>,
|
|
28
|
+
logger: Logger,
|
|
29
|
+
reporter: BenchReporter,
|
|
30
|
+
) {
|
|
31
|
+
describe(`${backendPrefix} Map benchmarks`, () => {
|
|
32
|
+
let store: AztecAsyncKVStore;
|
|
33
|
+
let map: AztecAsyncMap<Key, string>;
|
|
34
|
+
|
|
35
|
+
const results: BenchResult[] = [];
|
|
36
|
+
|
|
37
|
+
const generateKeyValuePairs = (count: number, offset = 0) => {
|
|
38
|
+
const keys = Array.from({ length: count }, (_, i) => `key-${i + offset}`);
|
|
39
|
+
const values = Array.from({ length: count }, (_, i) => `value-${i + offset}`);
|
|
40
|
+
return keys.map((key, i) => ({ key, value: values[i] }));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const record = (name: string, value: number, unit: BenchResult['unit']) => {
|
|
44
|
+
results.push({ name: `${backendPrefix}/Map/${name}`, value, unit });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
beforeEach(async () => {
|
|
48
|
+
store = await getStore();
|
|
49
|
+
map = store.openMap<Key, string>('test');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
afterEach(async () => {
|
|
53
|
+
await store.delete();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterAll(async () => {
|
|
57
|
+
const pretty = results.map(r => `${r.name}: ${r.value.toFixed(2)} ${r.unit}`).join('\n');
|
|
58
|
+
logger.info(`\n${pretty}\n`);
|
|
59
|
+
await reporter(results);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('adds individual values', async () => {
|
|
63
|
+
const pairs = generateKeyValuePairs(1000);
|
|
64
|
+
const timer = new Timer();
|
|
65
|
+
for (const pair of pairs) {
|
|
66
|
+
await map.set(pair.key, pair.value);
|
|
67
|
+
}
|
|
68
|
+
record('Individual insertion', timer.ms() / pairs.length, 'ms');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('adds batched values', async () => {
|
|
72
|
+
const batches = Array.from({ length: 100 }, (_, i) => generateKeyValuePairs(1000, i * 1000));
|
|
73
|
+
const timer = new Timer();
|
|
74
|
+
for (const batch of batches) {
|
|
75
|
+
await map.setMany(batch);
|
|
76
|
+
}
|
|
77
|
+
record(`Batch insertion of ${batches[0].length} items`, timer.ms() / batches.length, 'ms');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('reads individual values', async () => {
|
|
81
|
+
const pairs = generateKeyValuePairs(10000);
|
|
82
|
+
await map.setMany(pairs);
|
|
83
|
+
const timer = new Timer();
|
|
84
|
+
for (const pair of pairs) {
|
|
85
|
+
await map.getAsync(pair.key);
|
|
86
|
+
}
|
|
87
|
+
record('Individual read', (timer.ms() * 1000) / pairs.length, 'us');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('reads via a cursor', async () => {
|
|
91
|
+
const pairs = generateKeyValuePairs(10000);
|
|
92
|
+
await map.setMany(pairs);
|
|
93
|
+
const timer = new Timer();
|
|
94
|
+
for await (const _ of map.entriesAsync()) {
|
|
95
|
+
// consume
|
|
96
|
+
}
|
|
97
|
+
record(`Iterator per item read of ${pairs.length} items`, (timer.ms() * 1000) / pairs.length, 'us');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('reads the size of the map', async () => {
|
|
101
|
+
const numIterations = 1000;
|
|
102
|
+
const pairs = generateKeyValuePairs(10000);
|
|
103
|
+
await map.setMany(pairs);
|
|
104
|
+
const timer = new Timer();
|
|
105
|
+
for (let i = 0; i < numIterations; i++) {
|
|
106
|
+
await map.sizeAsync();
|
|
107
|
+
}
|
|
108
|
+
record(`Read size of ${pairs.length} items`, (timer.ms() * 1000) / numIterations, 'us');
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
package/src/indexeddb/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ export async function createStore(
|
|
|
23
23
|
: `Creating ${name} ephemeral data store with map size ${config.dataStoreMapSizeKb} KB`,
|
|
24
24
|
);
|
|
25
25
|
const store = await AztecIndexedDBStore.open(createLogger('kv-store:indexeddb'), dataDirectory ?? '', false);
|
|
26
|
-
return initStoreForRollupAndSchemaVersion(store, schemaVersion, config.
|
|
26
|
+
return initStoreForRollupAndSchemaVersion(store, schemaVersion, config.rollupAddress, log);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export function openTmpStore(ephemeral: boolean = false): Promise<AztecIndexedDBStore> {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { toArray } from '@aztec/foundation/iterable';
|
|
2
2
|
|
|
3
|
-
import { expect } from 'chai';
|
|
4
|
-
|
|
5
3
|
import type { AztecArray, AztecAsyncArray } from './array.js';
|
|
6
4
|
import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
|
|
7
5
|
import { isSyncStore } from './utils.js';
|
|
@@ -53,12 +51,12 @@ export function describeAztecArray(
|
|
|
53
51
|
await arr.push(2);
|
|
54
52
|
await arr.push(3);
|
|
55
53
|
|
|
56
|
-
expect(await length()).
|
|
54
|
+
expect(await length()).toBe(3);
|
|
57
55
|
|
|
58
|
-
expect(await arr.pop()).
|
|
59
|
-
expect(await arr.pop()).
|
|
60
|
-
expect(await arr.pop()).
|
|
61
|
-
expect(await arr.pop()).
|
|
56
|
+
expect(await arr.pop()).toBe(3);
|
|
57
|
+
expect(await arr.pop()).toBe(2);
|
|
58
|
+
expect(await arr.pop()).toBe(1);
|
|
59
|
+
expect(await arr.pop()).toBe(undefined);
|
|
62
60
|
});
|
|
63
61
|
|
|
64
62
|
it('should be able to get values by index', async () => {
|
|
@@ -66,14 +64,14 @@ export function describeAztecArray(
|
|
|
66
64
|
await arr.push(2);
|
|
67
65
|
await arr.push(3);
|
|
68
66
|
|
|
69
|
-
expect(await at(0)).
|
|
70
|
-
expect(await at(1)).
|
|
71
|
-
expect(await at(2)).
|
|
72
|
-
expect(await at(3)).
|
|
73
|
-
expect(await at(-1)).
|
|
74
|
-
expect(await at(-2)).
|
|
75
|
-
expect(await at(-3)).
|
|
76
|
-
expect(await at(-4)).
|
|
67
|
+
expect(await at(0)).toBe(1);
|
|
68
|
+
expect(await at(1)).toBe(2);
|
|
69
|
+
expect(await at(2)).toBe(3);
|
|
70
|
+
expect(await at(3)).toBe(undefined);
|
|
71
|
+
expect(await at(-1)).toBe(3);
|
|
72
|
+
expect(await at(-2)).toBe(2);
|
|
73
|
+
expect(await at(-3)).toBe(1);
|
|
74
|
+
expect(await at(-4)).toBe(undefined);
|
|
77
75
|
});
|
|
78
76
|
|
|
79
77
|
it('should be able to set values by index', async () => {
|
|
@@ -81,27 +79,27 @@ export function describeAztecArray(
|
|
|
81
79
|
await arr.push(2);
|
|
82
80
|
await arr.push(3);
|
|
83
81
|
|
|
84
|
-
expect(await arr.setAt(0, 4)).
|
|
85
|
-
expect(await arr.setAt(1, 5)).
|
|
86
|
-
expect(await arr.setAt(2, 6)).
|
|
82
|
+
expect(await arr.setAt(0, 4)).toBe(true);
|
|
83
|
+
expect(await arr.setAt(1, 5)).toBe(true);
|
|
84
|
+
expect(await arr.setAt(2, 6)).toBe(true);
|
|
87
85
|
|
|
88
|
-
expect(await arr.setAt(3, 7)).
|
|
86
|
+
expect(await arr.setAt(3, 7)).toBe(false);
|
|
89
87
|
|
|
90
|
-
expect(await at(0)).
|
|
91
|
-
expect(await at(1)).
|
|
92
|
-
expect(await at(2)).
|
|
93
|
-
expect(await at(3)).
|
|
88
|
+
expect(await at(0)).toBe(4);
|
|
89
|
+
expect(await at(1)).toBe(5);
|
|
90
|
+
expect(await at(2)).toBe(6);
|
|
91
|
+
expect(await at(3)).toBe(undefined);
|
|
94
92
|
|
|
95
|
-
expect(await arr.setAt(-1, 8)).
|
|
96
|
-
expect(await arr.setAt(-2, 9)).
|
|
97
|
-
expect(await arr.setAt(-3, 10)).
|
|
93
|
+
expect(await arr.setAt(-1, 8)).toBe(true);
|
|
94
|
+
expect(await arr.setAt(-2, 9)).toBe(true);
|
|
95
|
+
expect(await arr.setAt(-3, 10)).toBe(true);
|
|
98
96
|
|
|
99
|
-
expect(await arr.setAt(-4, 11)).
|
|
97
|
+
expect(await arr.setAt(-4, 11)).toBe(false);
|
|
100
98
|
|
|
101
|
-
expect(await at(-1)).
|
|
102
|
-
expect(await at(-2)).
|
|
103
|
-
expect(await at(-3)).
|
|
104
|
-
expect(await at(-4)).
|
|
99
|
+
expect(await at(-1)).toBe(8);
|
|
100
|
+
expect(await at(-2)).toBe(9);
|
|
101
|
+
expect(await at(-3)).toBe(10);
|
|
102
|
+
expect(await at(-4)).toBe(undefined);
|
|
105
103
|
});
|
|
106
104
|
|
|
107
105
|
it('should be able to iterate over values', async () => {
|
|
@@ -109,8 +107,8 @@ export function describeAztecArray(
|
|
|
109
107
|
await arr.push(2);
|
|
110
108
|
await arr.push(3);
|
|
111
109
|
|
|
112
|
-
expect(await values()).
|
|
113
|
-
expect(await entries()).
|
|
110
|
+
expect(await values()).toEqual([1, 2, 3]);
|
|
111
|
+
expect(await entries()).toEqual([
|
|
114
112
|
[0, 1],
|
|
115
113
|
[1, 2],
|
|
116
114
|
[2, 3],
|
|
@@ -123,8 +121,8 @@ export function describeAztecArray(
|
|
|
123
121
|
await arr.push(3);
|
|
124
122
|
|
|
125
123
|
const arr2 = store.openArray<number>('test');
|
|
126
|
-
expect(await length(arr2)).
|
|
127
|
-
expect(await values(arr2)).
|
|
124
|
+
expect(await length(arr2)).toBe(3);
|
|
125
|
+
expect(await values(arr2)).toEqual(await values());
|
|
128
126
|
});
|
|
129
127
|
});
|
|
130
128
|
}
|
package/src/interfaces/index.ts
CHANGED