@aztec/kv-store 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec7ac5448
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/indexeddb/array.js +18 -6
- package/dest/indexeddb/index.d.ts +3 -3
- package/dest/indexeddb/index.d.ts.map +1 -1
- package/dest/indexeddb/index.js +3 -6
- package/dest/indexeddb/map.d.ts +8 -2
- package/dest/indexeddb/map.d.ts.map +1 -1
- package/dest/indexeddb/map.js +23 -13
- package/dest/indexeddb/multi_map.d.ts +2 -1
- package/dest/indexeddb/multi_map.d.ts.map +1 -1
- package/dest/indexeddb/multi_map.js +16 -1
- package/dest/indexeddb/singleton.js +3 -1
- package/dest/indexeddb/store.d.ts +3 -3
- package/dest/indexeddb/store.d.ts.map +1 -1
- package/dest/indexeddb/store.js +6 -4
- 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 +48 -2
- 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 +25 -0
- package/dest/interfaces/utils.d.ts +2 -1
- package/dest/interfaces/utils.d.ts.map +1 -1
- package/dest/interfaces/utils.js +2 -1
- package/dest/lmdb/index.d.ts +3 -3
- package/dest/lmdb/index.d.ts.map +1 -1
- package/dest/lmdb/index.js +3 -3
- package/dest/lmdb/store.d.ts +3 -3
- package/dest/lmdb/store.d.ts.map +1 -1
- package/dest/lmdb/store.js +12 -8
- package/dest/lmdb-v2/factory.d.ts +7 -7
- package/dest/lmdb-v2/factory.d.ts.map +1 -1
- package/dest/lmdb-v2/factory.js +14 -10
- package/dest/lmdb-v2/store.d.ts +3 -3
- package/dest/lmdb-v2/store.d.ts.map +1 -1
- package/dest/lmdb-v2/store.js +2 -1
- package/dest/utils.d.ts +9 -6
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +51 -16
- package/package.json +15 -14
- package/src/indexeddb/array.ts +4 -4
- package/src/indexeddb/index.ts +9 -7
- package/src/indexeddb/map.ts +24 -11
- package/src/indexeddb/multi_map.ts +15 -1
- package/src/indexeddb/singleton.ts +1 -1
- package/src/indexeddb/store.ts +13 -6
- package/src/interfaces/map_test_suite.ts +30 -2
- package/src/interfaces/multi_map_test_suite.ts +32 -0
- package/src/interfaces/utils.ts +1 -0
- package/src/lmdb/index.ts +9 -4
- package/src/lmdb/store.ts +12 -8
- package/src/lmdb-v2/factory.ts +16 -12
- package/src/lmdb-v2/store.ts +3 -2
- package/src/utils.ts +79 -21
- package/dest/config.d.ts +0 -17
- package/dest/config.d.ts.map +0 -1
- package/dest/config.js +0 -26
- package/src/config.ts +0 -36
|
@@ -107,6 +107,33 @@ export function describeAztecMap(
|
|
|
107
107
|
expect(await size()).to.equal(1);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
it('returns 0 for empty map size', async () => {
|
|
111
|
+
expect(await size()).to.equal(0);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('calculates size correctly across multiple operations', async () => {
|
|
115
|
+
expect(await size()).to.equal(0);
|
|
116
|
+
|
|
117
|
+
// Add items
|
|
118
|
+
await map.set('a', 'value1');
|
|
119
|
+
await map.set('b', 'value2');
|
|
120
|
+
await map.set('c', 'value3');
|
|
121
|
+
expect(await size()).to.equal(3);
|
|
122
|
+
|
|
123
|
+
// Update existing (size should not change)
|
|
124
|
+
await map.set('b', 'updated');
|
|
125
|
+
expect(await size()).to.equal(3);
|
|
126
|
+
|
|
127
|
+
// Delete some
|
|
128
|
+
await map.delete('a');
|
|
129
|
+
expect(await size()).to.equal(2);
|
|
130
|
+
|
|
131
|
+
// Delete all
|
|
132
|
+
await map.delete('b');
|
|
133
|
+
await map.delete('c');
|
|
134
|
+
expect(await size()).to.equal(0);
|
|
135
|
+
});
|
|
136
|
+
|
|
110
137
|
it('should be able to iterate over entries when there are no keys', async () => {
|
|
111
138
|
expect(await entries()).to.deep.equal([]);
|
|
112
139
|
});
|
|
@@ -145,10 +172,11 @@ export function describeAztecMap(
|
|
|
145
172
|
for (const [name, data] of [
|
|
146
173
|
['chars', ['a', 'b', 'c', 'd']],
|
|
147
174
|
['numbers', [1, 2, 3, 4]],
|
|
148
|
-
|
|
149
|
-
// ['negative numbers', [-4, -3, -2, -1]],
|
|
175
|
+
['negative numbers', [-4, -3, -2, -1]],
|
|
150
176
|
['strings', ['aaa', 'bbb', 'ccc', 'ddd']],
|
|
151
177
|
['zero-based numbers', [0, 1, 2, 3]],
|
|
178
|
+
['large numbers', [100, 999, 1000, 1001]],
|
|
179
|
+
['mixed negative and positive', [-1000, -1, 1, 1000]],
|
|
152
180
|
]) {
|
|
153
181
|
it(`supports range queries over ${name} keys`, async () => {
|
|
154
182
|
const [a, b, c, d] = data;
|
|
@@ -104,6 +104,38 @@ export function describeAztecMultiMap(
|
|
|
104
104
|
expect(await size()).to.equal(1);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
+
it('returns 0 for empty multimap size', async () => {
|
|
108
|
+
expect(await size()).to.equal(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('calculates size correctly with multiple values per key', async () => {
|
|
112
|
+
expect(await size()).to.equal(0);
|
|
113
|
+
|
|
114
|
+
// Add multiple values for same key
|
|
115
|
+
await multiMap.set('key1', 'value1');
|
|
116
|
+
expect(await size()).to.equal(1);
|
|
117
|
+
await multiMap.set('key1', 'value2');
|
|
118
|
+
expect(await size()).to.equal(2);
|
|
119
|
+
await multiMap.set('key1', 'value3');
|
|
120
|
+
expect(await size()).to.equal(3);
|
|
121
|
+
|
|
122
|
+
// Add values for different key
|
|
123
|
+
await multiMap.set('key2', 'value4');
|
|
124
|
+
expect(await size()).to.equal(4);
|
|
125
|
+
|
|
126
|
+
// Delete one value from key1
|
|
127
|
+
await multiMap.deleteValue('key1', 'value2');
|
|
128
|
+
expect(await size()).to.equal(3);
|
|
129
|
+
|
|
130
|
+
// Delete entire key
|
|
131
|
+
await multiMap.delete('key1');
|
|
132
|
+
expect(await size()).to.equal(1);
|
|
133
|
+
|
|
134
|
+
// Delete last key
|
|
135
|
+
await multiMap.delete('key2');
|
|
136
|
+
expect(await size()).to.equal(0);
|
|
137
|
+
});
|
|
138
|
+
|
|
107
139
|
it('should be able to iterate over entries when there are no keys', async () => {
|
|
108
140
|
expect(await entries()).to.deep.equal([]);
|
|
109
141
|
});
|
package/src/interfaces/utils.ts
CHANGED
package/src/lmdb/index.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
2
3
|
|
|
3
4
|
import { join } from 'path';
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
-
import { initStoreForRollup } from '../utils.js';
|
|
6
|
+
import { initStoreForRollupAndSchemaVersion } from '../utils.js';
|
|
7
7
|
import { AztecLmdbStore } from './store.js';
|
|
8
8
|
|
|
9
9
|
export { AztecLmdbStore } from './store.js';
|
|
10
10
|
|
|
11
|
-
export function createStore(
|
|
11
|
+
export function createStore(
|
|
12
|
+
name: string,
|
|
13
|
+
config: DataStoreConfig,
|
|
14
|
+
schemaVersion: number | undefined = undefined,
|
|
15
|
+
log: Logger = createLogger('kv-store'),
|
|
16
|
+
) {
|
|
12
17
|
let { dataDirectory } = config;
|
|
13
18
|
if (typeof dataDirectory !== 'undefined') {
|
|
14
19
|
dataDirectory = join(dataDirectory, name);
|
|
@@ -22,7 +27,7 @@ export function createStore(name: string, config: DataStoreConfig, log: Logger =
|
|
|
22
27
|
|
|
23
28
|
const store = AztecLmdbStore.open(dataDirectory, config.dataStoreMapSizeKb, false);
|
|
24
29
|
if (config.l1Contracts?.rollupAddress) {
|
|
25
|
-
return
|
|
30
|
+
return initStoreForRollupAndSchemaVersion(store, schemaVersion, config.l1Contracts.rollupAddress, log);
|
|
26
31
|
}
|
|
27
32
|
return store;
|
|
28
33
|
}
|
package/src/lmdb/store.ts
CHANGED
|
@@ -147,21 +147,25 @@ export class AztecLmdbStore implements AztecKVStore, AztecAsyncKVStore {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* Clears all entries in the store & sub DBs.
|
|
150
|
+
* Clears all entries in the store & sub DBs atomically within a single transaction.
|
|
151
151
|
*/
|
|
152
152
|
async clear() {
|
|
153
|
-
await this.#
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
await this.#rootDb.transaction(async () => {
|
|
154
|
+
await this.#data.clearAsync();
|
|
155
|
+
await this.#multiMapData.clearAsync();
|
|
156
|
+
await this.#rootDb.clearAsync();
|
|
157
|
+
});
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
/**
|
|
159
|
-
* Drops the database & sub DBs.
|
|
161
|
+
* Drops the database & sub DBs atomically within a single transaction.
|
|
160
162
|
*/
|
|
161
163
|
async drop() {
|
|
162
|
-
await this.#
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
await this.#rootDb.transaction(async () => {
|
|
165
|
+
await this.#data.drop();
|
|
166
|
+
await this.#multiMapData.drop();
|
|
167
|
+
await this.#rootDb.drop();
|
|
168
|
+
});
|
|
165
169
|
}
|
|
166
170
|
|
|
167
171
|
/**
|
package/src/lmdb-v2/factory.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { type
|
|
3
|
-
import { DatabaseVersionManager } from '@aztec/stdlib/database-version';
|
|
2
|
+
import { type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { DatabaseVersionManager } from '@aztec/stdlib/database-version/manager';
|
|
4
|
+
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
|
|
4
5
|
|
|
5
6
|
import { mkdir, mkdtemp, rm } from 'fs/promises';
|
|
6
7
|
import { tmpdir } from 'os';
|
|
7
8
|
import { join } from 'path';
|
|
8
9
|
|
|
9
|
-
import type { DataStoreConfig } from '../config.js';
|
|
10
10
|
import { AztecLMDBStoreV2 } from './store.js';
|
|
11
11
|
|
|
12
12
|
const MAX_READERS = 16;
|
|
@@ -15,8 +15,9 @@ export async function createStore(
|
|
|
15
15
|
name: string,
|
|
16
16
|
schemaVersion: number,
|
|
17
17
|
config: DataStoreConfig,
|
|
18
|
-
|
|
18
|
+
bindings?: LoggerBindings,
|
|
19
19
|
): Promise<AztecLMDBStoreV2> {
|
|
20
|
+
const log = createLogger('kv-store:lmdb-v2:' + name, bindings);
|
|
20
21
|
const { dataDirectory, l1Contracts } = config;
|
|
21
22
|
|
|
22
23
|
let store: AztecLMDBStoreV2;
|
|
@@ -33,7 +34,7 @@ export async function createStore(
|
|
|
33
34
|
rollupAddress,
|
|
34
35
|
dataDirectory: subDir,
|
|
35
36
|
onOpen: dbDirectory =>
|
|
36
|
-
AztecLMDBStoreV2.new(dbDirectory, config.dataStoreMapSizeKb, MAX_READERS, () => Promise.resolve(),
|
|
37
|
+
AztecLMDBStoreV2.new(dbDirectory, config.dataStoreMapSizeKb, MAX_READERS, () => Promise.resolve(), bindings),
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
log.info(
|
|
@@ -41,7 +42,7 @@ export async function createStore(
|
|
|
41
42
|
);
|
|
42
43
|
[store] = await versionManager.open();
|
|
43
44
|
} else {
|
|
44
|
-
store = await openTmpStore(name, true, config.dataStoreMapSizeKb, MAX_READERS,
|
|
45
|
+
store = await openTmpStore(name, true, config.dataStoreMapSizeKb, MAX_READERS, bindings);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
return store;
|
|
@@ -52,8 +53,9 @@ export async function openTmpStore(
|
|
|
52
53
|
ephemeral: boolean = true,
|
|
53
54
|
dbMapSizeKb = 10 * 1_024 * 1_024, // 10GB
|
|
54
55
|
maxReaders = MAX_READERS,
|
|
55
|
-
|
|
56
|
+
bindings?: LoggerBindings,
|
|
56
57
|
): Promise<AztecLMDBStoreV2> {
|
|
58
|
+
const log = createLogger('kv-store:lmdb-v2:' + name, bindings);
|
|
57
59
|
const dataDir = await mkdtemp(join(tmpdir(), name + '-'));
|
|
58
60
|
log.debug(`Created temporary data store at: ${dataDir} with size: ${dbMapSizeKb} KB (LMDB v2)`);
|
|
59
61
|
|
|
@@ -73,17 +75,18 @@ export async function openTmpStore(
|
|
|
73
75
|
|
|
74
76
|
// For temporary stores, we don't need to worry about versioning
|
|
75
77
|
// as they are ephemeral and get cleaned up after use
|
|
76
|
-
return AztecLMDBStoreV2.new(dataDir, dbMapSizeKb, maxReaders, cleanup,
|
|
78
|
+
return AztecLMDBStoreV2.new(dataDir, dbMapSizeKb, maxReaders, cleanup, bindings);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
export async function openStoreAt(
|
|
80
82
|
dataDir: string,
|
|
81
83
|
dbMapSizeKb = 10 * 1_024 * 1_024, // 10GB
|
|
82
84
|
maxReaders = MAX_READERS,
|
|
83
|
-
|
|
85
|
+
bindings?: LoggerBindings,
|
|
84
86
|
): Promise<AztecLMDBStoreV2> {
|
|
87
|
+
const log = createLogger('kv-store:lmdb-v2', bindings);
|
|
85
88
|
log.debug(`Opening data store at: ${dataDir} with size: ${dbMapSizeKb} KB (LMDB v2)`);
|
|
86
|
-
return await AztecLMDBStoreV2.new(dataDir, dbMapSizeKb, maxReaders, undefined,
|
|
89
|
+
return await AztecLMDBStoreV2.new(dataDir, dbMapSizeKb, maxReaders, undefined, bindings);
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
export async function openVersionedStoreAt(
|
|
@@ -92,14 +95,15 @@ export async function openVersionedStoreAt(
|
|
|
92
95
|
rollupAddress: EthAddress,
|
|
93
96
|
dbMapSizeKb = 10 * 1_024 * 1_024, // 10GB
|
|
94
97
|
maxReaders = MAX_READERS,
|
|
95
|
-
|
|
98
|
+
bindings?: LoggerBindings,
|
|
96
99
|
): Promise<AztecLMDBStoreV2> {
|
|
100
|
+
const log = createLogger('kv-store:lmdb-v2', bindings);
|
|
97
101
|
log.debug(`Opening data store at: ${dataDirectory} with size: ${dbMapSizeKb} KB (LMDB v2)`);
|
|
98
102
|
const [store] = await new DatabaseVersionManager({
|
|
99
103
|
schemaVersion,
|
|
100
104
|
rollupAddress,
|
|
101
105
|
dataDirectory,
|
|
102
|
-
onOpen: dataDir => AztecLMDBStoreV2.new(dataDir, dbMapSizeKb, maxReaders, undefined,
|
|
106
|
+
onOpen: dataDir => AztecLMDBStoreV2.new(dataDir, dbMapSizeKb, maxReaders, undefined, bindings),
|
|
103
107
|
}).open();
|
|
104
108
|
return store;
|
|
105
109
|
}
|
package/src/lmdb-v2/store.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { Semaphore, SerialQueue } from '@aztec/foundation/queue';
|
|
3
3
|
import { MsgpackChannel, NativeLMDBStore } from '@aztec/native';
|
|
4
4
|
|
|
@@ -75,8 +75,9 @@ export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel {
|
|
|
75
75
|
dbMapSizeKb: number = 10 * 1024 * 1024,
|
|
76
76
|
maxReaders: number = 16,
|
|
77
77
|
cleanup?: () => Promise<void>,
|
|
78
|
-
|
|
78
|
+
bindings?: LoggerBindings,
|
|
79
79
|
) {
|
|
80
|
+
const log = createLogger('kv-store:lmdb-v2', bindings);
|
|
80
81
|
const db = new AztecLMDBStoreV2(dataDir, dbMapSizeKb, maxReaders, log, cleanup);
|
|
81
82
|
await db.start();
|
|
82
83
|
return db;
|
package/src/utils.ts
CHANGED
|
@@ -1,40 +1,98 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import { DatabaseVersion } from '@aztec/stdlib/database-version/version';
|
|
3
4
|
|
|
4
5
|
import type { AztecAsyncSingleton, AztecSingleton } from './interfaces/singleton.js';
|
|
5
6
|
import type { AztecAsyncKVStore, AztecKVStore } from './interfaces/store.js';
|
|
6
7
|
import { isSyncStore } from './interfaces/utils.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* Clears the store if the rollup address does not match the one stored in the database.
|
|
10
|
-
*
|
|
10
|
+
* Clears the store if the schema version or rollup address does not match the one stored in the database.
|
|
11
|
+
* Also clears if migrating from an older store format that didn't track schema version.
|
|
12
|
+
* This is to prevent data from being accidentally mixed up between different rollup instances or schema versions.
|
|
11
13
|
* @param store - The store to check
|
|
14
|
+
* @param targetSchemaVersion - The current schema version
|
|
12
15
|
* @param rollupAddress - The ETH address of the rollup contract
|
|
13
|
-
* @
|
|
16
|
+
* @param log - Optional logger
|
|
17
|
+
* @returns The store (cleared if necessary)
|
|
14
18
|
*/
|
|
15
|
-
export async function
|
|
19
|
+
export async function initStoreForRollupAndSchemaVersion<T extends AztecKVStore | AztecAsyncKVStore>(
|
|
16
20
|
store: T,
|
|
17
|
-
|
|
21
|
+
schemaVersion: number | undefined,
|
|
22
|
+
rollupAddress: EthAddress | undefined,
|
|
18
23
|
log?: Logger,
|
|
19
24
|
): Promise<T> {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const targetSchemaVersion = schemaVersion ?? 0;
|
|
26
|
+
const targetRollupAddress = rollupAddress ?? EthAddress.ZERO;
|
|
27
|
+
const targetDatabaseVersion = new DatabaseVersion(targetSchemaVersion, targetRollupAddress);
|
|
28
|
+
|
|
29
|
+
// DB version: database schema version + rollup address combined)
|
|
30
|
+
const dbVersion = store.openSingleton<string>('dbVersion');
|
|
31
|
+
|
|
32
|
+
const storedDatabaseVersion = isSyncStore(store)
|
|
33
|
+
? (dbVersion as AztecSingleton<string>).get()
|
|
34
|
+
: await (dbVersion as AztecAsyncSingleton<string>).getAsync();
|
|
35
|
+
|
|
36
|
+
// Check if this is an old format store (has rollupAddress singleton but no dbVersion)
|
|
37
|
+
const oldRollupSingleton = store.openSingleton<string>('rollupAddress');
|
|
38
|
+
const hasOldFormat = isSyncStore(store)
|
|
39
|
+
? !storedDatabaseVersion && !!(oldRollupSingleton as AztecSingleton<string>).get()
|
|
40
|
+
: !storedDatabaseVersion && !!(await (oldRollupSingleton as AztecAsyncSingleton<string>).getAsync());
|
|
34
41
|
|
|
42
|
+
if (
|
|
43
|
+
hasOldFormat ||
|
|
44
|
+
doesStoreNeedToBeCleared(
|
|
45
|
+
targetDatabaseVersion,
|
|
46
|
+
storedDatabaseVersion,
|
|
47
|
+
targetSchemaVersion,
|
|
48
|
+
targetRollupAddress,
|
|
49
|
+
log,
|
|
50
|
+
)
|
|
51
|
+
) {
|
|
52
|
+
if (hasOldFormat) {
|
|
53
|
+
log?.warn('Detected old store format without dbVersion, clearing database');
|
|
54
|
+
}
|
|
35
55
|
await store.clear();
|
|
36
56
|
}
|
|
37
57
|
|
|
38
|
-
await
|
|
58
|
+
await dbVersion.set(targetDatabaseVersion.toBuffer().toString('utf-8'));
|
|
59
|
+
|
|
39
60
|
return store;
|
|
40
61
|
}
|
|
62
|
+
|
|
63
|
+
function doesStoreNeedToBeCleared(
|
|
64
|
+
targetDatabaseVersion: DatabaseVersion,
|
|
65
|
+
storedDatabaseVersion: string | undefined,
|
|
66
|
+
targetSchemaVersion: number,
|
|
67
|
+
targetRollupAddress: EthAddress,
|
|
68
|
+
log?: Logger,
|
|
69
|
+
) {
|
|
70
|
+
if (storedDatabaseVersion) {
|
|
71
|
+
try {
|
|
72
|
+
const storedVersion = DatabaseVersion.fromBuffer(Buffer.from(storedDatabaseVersion, 'utf-8'));
|
|
73
|
+
const cmp = storedVersion.cmp(targetDatabaseVersion);
|
|
74
|
+
|
|
75
|
+
if (cmp === undefined) {
|
|
76
|
+
log?.warn('Rollup address changed, clearing database', {
|
|
77
|
+
stored: storedVersion.rollupAddress.toString(),
|
|
78
|
+
current: targetRollupAddress.toString(),
|
|
79
|
+
});
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (cmp !== 0) {
|
|
84
|
+
log?.warn('Schema version changed, clearing database', {
|
|
85
|
+
stored: storedVersion.schemaVersion,
|
|
86
|
+
current: targetSchemaVersion,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
} catch (err) {
|
|
92
|
+
log?.warn('Failed to parse stored version, clearing database', { err });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return false;
|
|
98
|
+
}
|
package/dest/config.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
export type DataStoreConfig = {
|
|
4
|
-
dataDirectory: string | undefined;
|
|
5
|
-
dataStoreMapSizeKb: number;
|
|
6
|
-
l1Contracts?: {
|
|
7
|
-
rollupAddress: EthAddress;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare const dataConfigMappings: ConfigMappingsType<DataStoreConfig>;
|
|
11
|
-
/**
|
|
12
|
-
* Returns the archiver configuration from the environment variables.
|
|
13
|
-
* Note: If an environment variable is not set, the default value is used.
|
|
14
|
-
* @returns The archiver configuration.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getDataConfigFromEnv(): DataStoreConfig;
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxLQUFLLGtCQUFrQixFQUE2QyxNQUFNLDBCQUEwQixDQUFDO0FBQzlHLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRWhFLE1BQU0sTUFBTSxlQUFlLEdBQUc7SUFDNUIsYUFBYSxFQUFFLE1BQU0sR0FBRyxTQUFTLENBQUM7SUFDbEMsa0JBQWtCLEVBQUUsTUFBTSxDQUFDO0lBQzNCLFdBQVcsQ0FBQyxFQUFFO1FBQUUsYUFBYSxFQUFFLFVBQVUsQ0FBQTtLQUFFLENBQUM7Q0FDN0MsQ0FBQztBQUVGLGVBQU8sTUFBTSxrQkFBa0IsRUFBRSxrQkFBa0IsQ0FBQyxlQUFlLENBZ0JsRSxDQUFDO0FBRUY7Ozs7R0FJRztBQUNILHdCQUFnQixvQkFBb0IsSUFBSSxlQUFlLENBRXREIn0=
|
package/dest/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAA6C,MAAM,0BAA0B,CAAC;AAC9G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,eAAe,CAgBlE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAEtD"}
|
package/dest/config.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
2
|
-
import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
3
|
-
export const dataConfigMappings = {
|
|
4
|
-
dataDirectory: {
|
|
5
|
-
env: 'DATA_DIRECTORY',
|
|
6
|
-
description: 'Optional dir to store data. If omitted will store in memory.'
|
|
7
|
-
},
|
|
8
|
-
dataStoreMapSizeKb: {
|
|
9
|
-
env: 'DATA_STORE_MAP_SIZE_KB',
|
|
10
|
-
description: 'The maximum possible size of a data store DB in KB. Can be overridden by component-specific options.',
|
|
11
|
-
...numberConfigHelper(128 * 1_024 * 1_024)
|
|
12
|
-
},
|
|
13
|
-
l1Contracts: {
|
|
14
|
-
description: 'The deployed L1 contract addresses',
|
|
15
|
-
nested: {
|
|
16
|
-
rollupAddress: l1ContractAddressesMapping.rollupAddress
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Returns the archiver configuration from the environment variables.
|
|
22
|
-
* Note: If an environment variable is not set, the default value is used.
|
|
23
|
-
* @returns The archiver configuration.
|
|
24
|
-
*/ export function getDataConfigFromEnv() {
|
|
25
|
-
return getConfigFromMappings(dataConfigMappings);
|
|
26
|
-
}
|
package/src/config.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
2
|
-
import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
3
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
|
|
5
|
-
export type DataStoreConfig = {
|
|
6
|
-
dataDirectory: string | undefined;
|
|
7
|
-
dataStoreMapSizeKb: number;
|
|
8
|
-
l1Contracts?: { rollupAddress: EthAddress };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const dataConfigMappings: ConfigMappingsType<DataStoreConfig> = {
|
|
12
|
-
dataDirectory: {
|
|
13
|
-
env: 'DATA_DIRECTORY',
|
|
14
|
-
description: 'Optional dir to store data. If omitted will store in memory.',
|
|
15
|
-
},
|
|
16
|
-
dataStoreMapSizeKb: {
|
|
17
|
-
env: 'DATA_STORE_MAP_SIZE_KB',
|
|
18
|
-
description: 'The maximum possible size of a data store DB in KB. Can be overridden by component-specific options.',
|
|
19
|
-
...numberConfigHelper(128 * 1_024 * 1_024), // Defaulted to 128 GB
|
|
20
|
-
},
|
|
21
|
-
l1Contracts: {
|
|
22
|
-
description: 'The deployed L1 contract addresses',
|
|
23
|
-
nested: {
|
|
24
|
-
rollupAddress: l1ContractAddressesMapping.rollupAddress,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns the archiver configuration from the environment variables.
|
|
31
|
-
* Note: If an environment variable is not set, the default value is used.
|
|
32
|
-
* @returns The archiver configuration.
|
|
33
|
-
*/
|
|
34
|
-
export function getDataConfigFromEnv(): DataStoreConfig {
|
|
35
|
-
return getConfigFromMappings<DataStoreConfig>(dataConfigMappings);
|
|
36
|
-
}
|