@aztec/kv-store 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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 +21 -7
- package/dest/indexeddb/index.d.ts +2 -2
- 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/array.js +4 -2
- package/dest/lmdb/index.d.ts +2 -2
- package/dest/lmdb/index.d.ts.map +1 -1
- package/dest/lmdb/index.js +3 -3
- package/dest/lmdb-v2/array.d.ts +2 -2
- package/dest/lmdb-v2/array.d.ts.map +1 -1
- package/dest/lmdb-v2/array.js +4 -3
- package/dest/lmdb-v2/factory.d.ts +6 -6
- package/dest/lmdb-v2/factory.d.ts.map +1 -1
- package/dest/lmdb-v2/factory.js +14 -10
- package/dest/lmdb-v2/map.d.ts +2 -2
- package/dest/lmdb-v2/map.d.ts.map +1 -1
- package/dest/lmdb-v2/map.js +1 -2
- package/dest/lmdb-v2/multi_map.d.ts +2 -2
- package/dest/lmdb-v2/multi_map.d.ts.map +1 -1
- package/dest/lmdb-v2/multi_map.js +1 -2
- package/dest/lmdb-v2/singleton.d.ts +2 -2
- package/dest/lmdb-v2/singleton.d.ts.map +1 -1
- package/dest/lmdb-v2/singleton.js +1 -2
- package/dest/lmdb-v2/store.d.ts +4 -5
- package/dest/lmdb-v2/store.d.ts.map +1 -1
- package/dest/lmdb-v2/store.js +3 -25
- package/dest/lmdb-v2/tx-helpers.d.ts +6 -0
- package/dest/lmdb-v2/tx-helpers.d.ts.map +1 -0
- package/dest/lmdb-v2/tx-helpers.js +21 -0
- package/dest/stores/l2_tips_store.d.ts +24 -10
- package/dest/stores/l2_tips_store.d.ts.map +1 -1
- package/dest/stores/l2_tips_store.js +61 -54
- 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 -13
- package/src/indexeddb/array.ts +4 -4
- package/src/indexeddb/index.ts +8 -6
- 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 +8 -3
- package/src/lmdb-v2/array.ts +2 -2
- package/src/lmdb-v2/factory.ts +15 -11
- package/src/lmdb-v2/map.ts +2 -2
- package/src/lmdb-v2/multi_map.ts +2 -2
- package/src/lmdb-v2/singleton.ts +2 -2
- package/src/lmdb-v2/store.ts +5 -31
- package/src/lmdb-v2/tx-helpers.ts +29 -0
- package/src/stores/l2_tips_store.ts +63 -56
- package/src/utils.ts +79 -21
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
|
|
|
@@ -13,9 +13,7 @@ import type { AztecAsyncMultiMap } from '../interfaces/multi_map.js';
|
|
|
13
13
|
import type { AztecAsyncSet } from '../interfaces/set.js';
|
|
14
14
|
import type { AztecAsyncSingleton } from '../interfaces/singleton.js';
|
|
15
15
|
import type { AztecAsyncKVStore } from '../interfaces/store.js';
|
|
16
|
-
// eslint-disable-next-line import/no-cycle
|
|
17
16
|
import { LMDBArray } from './array.js';
|
|
18
|
-
// eslint-disable-next-line import/no-cycle
|
|
19
17
|
import { LMDBMap } from './map.js';
|
|
20
18
|
import {
|
|
21
19
|
Database,
|
|
@@ -27,10 +25,11 @@ import {
|
|
|
27
25
|
import { LMDBMultiMap } from './multi_map.js';
|
|
28
26
|
import { ReadTransaction } from './read_transaction.js';
|
|
29
27
|
import { LMDBSet } from './set.js';
|
|
30
|
-
// eslint-disable-next-line import/no-cycle
|
|
31
28
|
import { LMDBSingleValue } from './singleton.js';
|
|
32
29
|
import { WriteTransaction } from './write_transaction.js';
|
|
33
30
|
|
|
31
|
+
export { execInReadTx, execInWriteTx } from './tx-helpers.js';
|
|
32
|
+
|
|
34
33
|
export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel {
|
|
35
34
|
private open = false;
|
|
36
35
|
private channel: MsgpackChannel<LMDBMessageType, LMDBRequestBody, LMDBResponseBody>;
|
|
@@ -76,8 +75,9 @@ export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel {
|
|
|
76
75
|
dbMapSizeKb: number = 10 * 1024 * 1024,
|
|
77
76
|
maxReaders: number = 16,
|
|
78
77
|
cleanup?: () => Promise<void>,
|
|
79
|
-
|
|
78
|
+
bindings?: LoggerBindings,
|
|
80
79
|
) {
|
|
80
|
+
const log = createLogger('kv-store:lmdb-v2', bindings);
|
|
81
81
|
const db = new AztecLMDBStoreV2(dataDir, dbMapSizeKb, maxReaders, log, cleanup);
|
|
82
82
|
await db.start();
|
|
83
83
|
return db;
|
|
@@ -217,29 +217,3 @@ export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel {
|
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
|
|
221
|
-
export function execInWriteTx<T>(store: AztecLMDBStoreV2, fn: (tx: WriteTransaction) => Promise<T>): Promise<T> {
|
|
222
|
-
const currentWrite = store.getCurrentWriteTx();
|
|
223
|
-
if (currentWrite) {
|
|
224
|
-
return fn(currentWrite);
|
|
225
|
-
} else {
|
|
226
|
-
return store.transactionAsync(fn);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export async function execInReadTx<T>(
|
|
231
|
-
store: AztecLMDBStoreV2,
|
|
232
|
-
fn: (tx: ReadTransaction) => T | Promise<T>,
|
|
233
|
-
): Promise<T> {
|
|
234
|
-
const currentWrite = store.getCurrentWriteTx();
|
|
235
|
-
if (currentWrite) {
|
|
236
|
-
return await fn(currentWrite);
|
|
237
|
-
} else {
|
|
238
|
-
const tx = store.getReadTx();
|
|
239
|
-
try {
|
|
240
|
-
return await fn(tx);
|
|
241
|
-
} finally {
|
|
242
|
-
tx.close();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReadTransaction } from './read_transaction.js';
|
|
2
|
+
import type { AztecLMDBStoreV2 } from './store.js';
|
|
3
|
+
import type { WriteTransaction } from './write_transaction.js';
|
|
4
|
+
|
|
5
|
+
export function execInWriteTx<T>(store: AztecLMDBStoreV2, fn: (tx: WriteTransaction) => Promise<T>): Promise<T> {
|
|
6
|
+
const currentWrite = store.getCurrentWriteTx();
|
|
7
|
+
if (currentWrite) {
|
|
8
|
+
return fn(currentWrite);
|
|
9
|
+
} else {
|
|
10
|
+
return store.transactionAsync(fn);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function execInReadTx<T>(
|
|
15
|
+
store: AztecLMDBStoreV2,
|
|
16
|
+
fn: (tx: ReadTransaction) => T | Promise<T>,
|
|
17
|
+
): Promise<T> {
|
|
18
|
+
const currentWrite = store.getCurrentWriteTx();
|
|
19
|
+
if (currentWrite) {
|
|
20
|
+
return await fn(currentWrite);
|
|
21
|
+
} else {
|
|
22
|
+
const tx = store.getReadTx();
|
|
23
|
+
try {
|
|
24
|
+
return await fn(tx);
|
|
25
|
+
} finally {
|
|
26
|
+
tx.close();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,81 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
L2BlockId,
|
|
5
|
-
L2BlockStreamEvent,
|
|
6
|
-
L2BlockStreamEventHandler,
|
|
7
|
-
L2BlockStreamLocalDataProvider,
|
|
8
|
-
L2BlockTag,
|
|
9
|
-
L2Tips,
|
|
10
|
-
} from '@aztec/stdlib/block';
|
|
1
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { type L2BlockTag, L2TipsStoreBase } from '@aztec/stdlib/block';
|
|
3
|
+
import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
11
4
|
|
|
12
5
|
import type { AztecAsyncMap } from '../interfaces/map.js';
|
|
13
6
|
import type { AztecAsyncKVStore } from '../interfaces/store.js';
|
|
14
7
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Persistent implementation of L2 tips store backed by a KV store.
|
|
10
|
+
* Used by nodes that need to persist chain state across restarts.
|
|
11
|
+
*/
|
|
12
|
+
export class L2TipsKVStore extends L2TipsStoreBase {
|
|
17
13
|
private readonly l2TipsStore: AztecAsyncMap<L2BlockTag, BlockNumber>;
|
|
18
14
|
private readonly l2BlockHashesStore: AztecAsyncMap<BlockNumber, string>;
|
|
15
|
+
private readonly l2BlockNumberToCheckpointNumberStore: AztecAsyncMap<BlockNumber, CheckpointNumber>;
|
|
16
|
+
private readonly l2CheckpointStore: AztecAsyncMap<CheckpointNumber, Buffer>;
|
|
19
17
|
|
|
20
|
-
constructor(
|
|
18
|
+
constructor(
|
|
19
|
+
private store: AztecAsyncKVStore,
|
|
20
|
+
namespace: string,
|
|
21
|
+
) {
|
|
22
|
+
super();
|
|
21
23
|
this.l2TipsStore = store.openMap([namespace, 'l2_tips'].join('_'));
|
|
22
24
|
this.l2BlockHashesStore = store.openMap([namespace, 'l2_block_hashes'].join('_'));
|
|
25
|
+
this.l2BlockNumberToCheckpointNumberStore = store.openMap(
|
|
26
|
+
[namespace, 'l2_block_number_to_checkpoint_number'].join('_'),
|
|
27
|
+
);
|
|
28
|
+
this.l2CheckpointStore = store.openMap([namespace, 'l2_checkpoint_store'].join('_'));
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
return this.
|
|
31
|
+
protected getTip(tag: L2BlockTag): Promise<BlockNumber | undefined> {
|
|
32
|
+
return this.l2TipsStore.getAsync(tag);
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
latest: await this.getL2Tip('latest'),
|
|
32
|
-
finalized: await this.getL2Tip('finalized'),
|
|
33
|
-
proven: await this.getL2Tip('proven'),
|
|
34
|
-
};
|
|
35
|
+
protected setTip(tag: L2BlockTag, blockNumber: BlockNumber): Promise<void> {
|
|
36
|
+
return this.l2TipsStore.set(tag, blockNumber);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
protected getStoredBlockHash(blockNumber: BlockNumber): Promise<string | undefined> {
|
|
40
|
+
return this.l2BlockHashesStore.getAsync(blockNumber);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected setBlockHash(blockNumber: BlockNumber, hash: string): Promise<void> {
|
|
44
|
+
return this.l2BlockHashesStore.set(blockNumber, hash);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected async deleteBlockHashesBefore(blockNumber: BlockNumber): Promise<void> {
|
|
48
|
+
for await (const key of this.l2BlockHashesStore.keysAsync({ end: blockNumber })) {
|
|
49
|
+
await this.l2BlockHashesStore.delete(key);
|
|
45
50
|
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected getCheckpointNumberForBlock(blockNumber: BlockNumber): Promise<CheckpointNumber | undefined> {
|
|
54
|
+
return this.l2BlockNumberToCheckpointNumberStore.getAsync(blockNumber);
|
|
55
|
+
}
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
protected setCheckpointNumberForBlock(blockNumber: BlockNumber, checkpointNumber: CheckpointNumber): Promise<void> {
|
|
58
|
+
return this.l2BlockNumberToCheckpointNumberStore.set(blockNumber, checkpointNumber);
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const blocks = event.blocks.map(b => b.block);
|
|
54
|
-
for (const block of blocks) {
|
|
55
|
-
await this.l2BlockHashesStore.set(block.number, (await block.hash()).toString());
|
|
56
|
-
}
|
|
57
|
-
await this.l2TipsStore.set('latest', blocks.at(-1)!.number);
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case 'chain-pruned':
|
|
61
|
-
await this.saveTag('latest', event.block);
|
|
62
|
-
break;
|
|
63
|
-
case 'chain-proven':
|
|
64
|
-
await this.saveTag('proven', event.block);
|
|
65
|
-
break;
|
|
66
|
-
case 'chain-finalized':
|
|
67
|
-
await this.saveTag('finalized', event.block);
|
|
68
|
-
for await (const key of this.l2BlockHashesStore.keysAsync({ end: event.block.number })) {
|
|
69
|
-
await this.l2BlockHashesStore.delete(key);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
61
|
+
protected async deleteBlockToCheckpointBefore(blockNumber: BlockNumber): Promise<void> {
|
|
62
|
+
for await (const key of this.l2BlockNumberToCheckpointNumberStore.keysAsync({ end: blockNumber })) {
|
|
63
|
+
await this.l2BlockNumberToCheckpointNumberStore.delete(key);
|
|
72
64
|
}
|
|
73
65
|
}
|
|
74
66
|
|
|
75
|
-
|
|
76
|
-
await this.
|
|
77
|
-
if (
|
|
78
|
-
|
|
67
|
+
protected async getCheckpoint(checkpointNumber: CheckpointNumber): Promise<PublishedCheckpoint | undefined> {
|
|
68
|
+
const buffer = await this.l2CheckpointStore.getAsync(checkpointNumber);
|
|
69
|
+
if (!buffer) {
|
|
70
|
+
return undefined;
|
|
79
71
|
}
|
|
72
|
+
return PublishedCheckpoint.fromBuffer(buffer);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected saveCheckpointData(checkpoint: PublishedCheckpoint): Promise<void> {
|
|
76
|
+
return this.l2CheckpointStore.set(checkpoint.checkpoint.number, checkpoint.toBuffer());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected async deleteCheckpointsBefore(checkpointNumber: CheckpointNumber): Promise<void> {
|
|
80
|
+
for await (const key of this.l2CheckpointStore.keysAsync({ end: checkpointNumber })) {
|
|
81
|
+
await this.l2CheckpointStore.delete(key);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected runInTransaction<T>(fn: () => Promise<T>): Promise<T> {
|
|
86
|
+
return this.store.transactionAsync(fn);
|
|
80
87
|
}
|
|
81
88
|
}
|
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
|
+
}
|