@aztec/kv-store 0.76.4-devnet-test-rc3 → 0.77.0-testnet-ignition.17

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.
Files changed (142) hide show
  1. package/dest/config.d.ts +1 -1
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +5 -7
  4. package/dest/indexeddb/array.d.ts +3 -3
  5. package/dest/indexeddb/array.d.ts.map +1 -1
  6. package/dest/indexeddb/array.js +44 -36
  7. package/dest/indexeddb/index.d.ts +1 -1
  8. package/dest/indexeddb/index.d.ts.map +1 -1
  9. package/dest/indexeddb/index.js +1 -4
  10. package/dest/indexeddb/map.d.ts +4 -4
  11. package/dest/indexeddb/map.d.ts.map +1 -1
  12. package/dest/indexeddb/map.js +72 -43
  13. package/dest/indexeddb/set.d.ts +4 -4
  14. package/dest/indexeddb/set.d.ts.map +1 -1
  15. package/dest/indexeddb/set.js +3 -4
  16. package/dest/indexeddb/singleton.d.ts +3 -3
  17. package/dest/indexeddb/singleton.d.ts.map +1 -1
  18. package/dest/indexeddb/singleton.js +17 -22
  19. package/dest/indexeddb/store.d.ts +8 -8
  20. package/dest/indexeddb/store.d.ts.map +1 -1
  21. package/dest/indexeddb/store.js +97 -93
  22. package/dest/interfaces/array.js +3 -2
  23. package/dest/interfaces/array_test_suite.d.ts +1 -1
  24. package/dest/interfaces/array_test_suite.d.ts.map +1 -1
  25. package/dest/interfaces/array_test_suite.js +29 -25
  26. package/dest/interfaces/common.d.ts +1 -1
  27. package/dest/interfaces/common.d.ts.map +1 -1
  28. package/dest/interfaces/common.js +3 -2
  29. package/dest/interfaces/counter.d.ts +1 -1
  30. package/dest/interfaces/counter.d.ts.map +1 -1
  31. package/dest/interfaces/counter.js +1 -2
  32. package/dest/interfaces/index.d.ts +1 -1
  33. package/dest/interfaces/index.d.ts.map +1 -1
  34. package/dest/interfaces/index.js +0 -1
  35. package/dest/interfaces/map.d.ts +1 -1
  36. package/dest/interfaces/map.d.ts.map +1 -1
  37. package/dest/interfaces/map.js +3 -2
  38. package/dest/interfaces/map_test_suite.d.ts +1 -1
  39. package/dest/interfaces/map_test_suite.d.ts.map +1 -1
  40. package/dest/interfaces/map_test_suite.js +87 -42
  41. package/dest/interfaces/set.d.ts +1 -1
  42. package/dest/interfaces/set.d.ts.map +1 -1
  43. package/dest/interfaces/set.js +1 -2
  44. package/dest/interfaces/set_test_suite.d.ts +1 -1
  45. package/dest/interfaces/set_test_suite.d.ts.map +1 -1
  46. package/dest/interfaces/set_test_suite.js +59 -22
  47. package/dest/interfaces/singleton.js +4 -2
  48. package/dest/interfaces/singleton_test_suite.d.ts +1 -1
  49. package/dest/interfaces/singleton_test_suite.d.ts.map +1 -1
  50. package/dest/interfaces/singleton_test_suite.js +7 -10
  51. package/dest/interfaces/store.d.ts +6 -6
  52. package/dest/interfaces/store.d.ts.map +1 -1
  53. package/dest/interfaces/store.js +1 -2
  54. package/dest/interfaces/store_test_suite.d.ts +1 -1
  55. package/dest/interfaces/store_test_suite.d.ts.map +1 -1
  56. package/dest/interfaces/store_test_suite.js +6 -9
  57. package/dest/interfaces/utils.d.ts +1 -1
  58. package/dest/interfaces/utils.d.ts.map +1 -1
  59. package/dest/interfaces/utils.js +12 -15
  60. package/dest/lmdb/array.d.ts +2 -2
  61. package/dest/lmdb/array.d.ts.map +1 -1
  62. package/dest/lmdb/array.js +46 -41
  63. package/dest/lmdb/counter.d.ts +3 -3
  64. package/dest/lmdb/counter.d.ts.map +1 -1
  65. package/dest/lmdb/counter.js +18 -24
  66. package/dest/lmdb/index.d.ts +1 -1
  67. package/dest/lmdb/index.d.ts.map +1 -1
  68. package/dest/lmdb/index.js +2 -6
  69. package/dest/lmdb/map.d.ts +3 -3
  70. package/dest/lmdb/map.d.ts.map +1 -1
  71. package/dest/lmdb/map.js +90 -68
  72. package/dest/lmdb/set.d.ts +3 -3
  73. package/dest/lmdb/set.d.ts.map +1 -1
  74. package/dest/lmdb/set.js +4 -5
  75. package/dest/lmdb/singleton.d.ts +2 -2
  76. package/dest/lmdb/singleton.d.ts.map +1 -1
  77. package/dest/lmdb/singleton.js +13 -14
  78. package/dest/lmdb/store.d.ts +7 -7
  79. package/dest/lmdb/store.d.ts.map +1 -1
  80. package/dest/lmdb/store.js +125 -134
  81. package/dest/lmdb-v2/array.d.ts +18 -0
  82. package/dest/lmdb-v2/array.d.ts.map +1 -0
  83. package/dest/lmdb-v2/array.js +101 -0
  84. package/dest/lmdb-v2/factory.d.ts +1 -1
  85. package/dest/lmdb-v2/factory.d.ts.map +1 -1
  86. package/dest/lmdb-v2/factory.js +30 -21
  87. package/dest/lmdb-v2/index.js +0 -1
  88. package/dest/lmdb-v2/map.js +82 -85
  89. package/dest/lmdb-v2/message.js +6 -7
  90. package/dest/lmdb-v2/read_transaction.js +65 -53
  91. package/dest/lmdb-v2/singleton.d.ts +1 -1
  92. package/dest/lmdb-v2/singleton.d.ts.map +1 -1
  93. package/dest/lmdb-v2/singleton.js +7 -5
  94. package/dest/lmdb-v2/store.d.ts +1 -1
  95. package/dest/lmdb-v2/store.d.ts.map +1 -1
  96. package/dest/lmdb-v2/store.js +31 -28
  97. package/dest/lmdb-v2/utils.d.ts +1 -1
  98. package/dest/lmdb-v2/utils.d.ts.map +1 -1
  99. package/dest/lmdb-v2/utils.js +30 -30
  100. package/dest/lmdb-v2/write_transaction.js +130 -110
  101. package/dest/stores/index.js +0 -1
  102. package/dest/stores/l2_tips_store.d.ts +2 -2
  103. package/dest/stores/l2_tips_store.d.ts.map +1 -1
  104. package/dest/stores/l2_tips_store.js +26 -12
  105. package/dest/utils.d.ts +3 -3
  106. package/dest/utils.d.ts.map +1 -1
  107. package/dest/utils.js +3 -7
  108. package/package.json +8 -11
  109. package/src/config.ts +1 -1
  110. package/src/indexeddb/array.ts +3 -3
  111. package/src/indexeddb/index.ts +1 -1
  112. package/src/indexeddb/map.ts +4 -4
  113. package/src/indexeddb/set.ts +4 -4
  114. package/src/indexeddb/singleton.ts +3 -3
  115. package/src/indexeddb/store.ts +8 -8
  116. package/src/interfaces/array_test_suite.ts +2 -2
  117. package/src/interfaces/common.ts +1 -1
  118. package/src/interfaces/counter.ts +1 -1
  119. package/src/interfaces/index.ts +1 -1
  120. package/src/interfaces/map.ts +1 -1
  121. package/src/interfaces/map_test_suite.ts +3 -3
  122. package/src/interfaces/set.ts +1 -1
  123. package/src/interfaces/set_test_suite.ts +3 -3
  124. package/src/interfaces/singleton_test_suite.ts +2 -2
  125. package/src/interfaces/store.ts +12 -12
  126. package/src/interfaces/store_test_suite.ts +2 -2
  127. package/src/interfaces/utils.ts +1 -1
  128. package/src/lmdb/array.ts +2 -2
  129. package/src/lmdb/counter.ts +3 -3
  130. package/src/lmdb/index.ts +1 -1
  131. package/src/lmdb/map.ts +3 -3
  132. package/src/lmdb/set.ts +3 -3
  133. package/src/lmdb/singleton.ts +2 -2
  134. package/src/lmdb/store.ts +14 -14
  135. package/src/lmdb-v2/array.ts +115 -0
  136. package/src/lmdb-v2/factory.ts +9 -5
  137. package/src/lmdb-v2/map.ts +1 -1
  138. package/src/lmdb-v2/singleton.ts +1 -1
  139. package/src/lmdb-v2/store.ts +4 -3
  140. package/src/lmdb-v2/utils.ts +1 -1
  141. package/src/stores/l2_tips_store.ts +10 -10
  142. package/src/utils.ts +4 -4
@@ -2,8 +2,8 @@ import { toArray } from '@aztec/foundation/iterable';
2
2
 
3
3
  import { expect } from 'chai';
4
4
 
5
- import { type AztecArray, type AztecAsyncArray } from './array.js';
6
- import { type AztecAsyncKVStore, type AztecKVStore } from './store.js';
5
+ import type { AztecArray, AztecAsyncArray } from './array.js';
6
+ import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
7
7
  import { isSyncStore } from './utils.js';
8
8
 
9
9
  export function describeAztecArray(
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The key type for use with the kv-store
3
3
  */
4
- export type Key = string | number;
4
+ export type Key = string | number | Array<string | number>;
5
5
 
6
6
  /**
7
7
  * A range of keys to iterate over.
@@ -1,4 +1,4 @@
1
- import { type Key, type Range } from './common.js';
1
+ import type { Key, Range } from './common.js';
2
2
 
3
3
  /**
4
4
  * A map that counts how many times it sees a key. Once 0 is reached, that key is removed from the map.
@@ -4,4 +4,4 @@ export * from './counter.js';
4
4
  export * from './singleton.js';
5
5
  export * from './store.js';
6
6
  export * from './set.js';
7
- export { Range, StoreSize } from './common.js';
7
+ export type { Range, StoreSize } from './common.js';
@@ -1,4 +1,4 @@
1
- import { type Key, type Range } from './common.js';
1
+ import type { Key, Range } from './common.js';
2
2
 
3
3
  /**
4
4
  * A map backed by a persistent store.
@@ -2,9 +2,9 @@ import { toArray } from '@aztec/foundation/iterable';
2
2
 
3
3
  import { expect } from 'chai';
4
4
 
5
- import { type Key, type Range } from './common.js';
6
- import { type AztecAsyncMap, type AztecAsyncMultiMap, type AztecMap, type AztecMultiMap } from './map.js';
7
- import { type AztecAsyncKVStore, type AztecKVStore } from './store.js';
5
+ import type { Key, Range } from './common.js';
6
+ import type { AztecAsyncMap, AztecAsyncMultiMap, AztecMap, AztecMultiMap } from './map.js';
7
+ import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
8
8
  import { isSyncStore } from './utils.js';
9
9
 
10
10
  export function describeAztecMap(
@@ -1,4 +1,4 @@
1
- import { type Key, type Range } from './common.js';
1
+ import type { Key, Range } from './common.js';
2
2
 
3
3
  /**
4
4
  * A set backed by a persistent store.
@@ -2,9 +2,9 @@ import { toArray } from '@aztec/foundation/iterable';
2
2
 
3
3
  import { expect } from 'chai';
4
4
 
5
- import { type Range } from './common.js';
6
- import { type AztecAsyncSet, type AztecSet } from './set.js';
7
- import { type AztecAsyncKVStore, type AztecKVStore } from './store.js';
5
+ import type { Range } from './common.js';
6
+ import type { AztecAsyncSet, AztecSet } from './set.js';
7
+ import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
8
8
  import { isSyncStore } from './utils.js';
9
9
 
10
10
  export function describeAztecSet(
@@ -1,7 +1,7 @@
1
1
  import { expect } from 'chai';
2
2
 
3
- import { type AztecAsyncSingleton, type AztecSingleton } from './singleton.js';
4
- import { type AztecAsyncKVStore, type AztecKVStore } from './store.js';
3
+ import type { AztecAsyncSingleton, AztecSingleton } from './singleton.js';
4
+ import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
5
5
  import { isSyncStore } from './utils.js';
6
6
 
7
7
  export function describeAztecSingleton(
@@ -1,16 +1,16 @@
1
- import { type AztecArray, type AztecAsyncArray } from './array.js';
2
- import { type Key, type StoreSize } from './common.js';
3
- import { type AztecAsyncCounter, type AztecCounter } from './counter.js';
4
- import {
5
- type AztecAsyncMap,
6
- type AztecAsyncMultiMap,
7
- type AztecMap,
8
- type AztecMapWithSize,
9
- type AztecMultiMap,
10
- type AztecMultiMapWithSize,
1
+ import type { AztecArray, AztecAsyncArray } from './array.js';
2
+ import type { Key, StoreSize } from './common.js';
3
+ import type { AztecAsyncCounter, AztecCounter } from './counter.js';
4
+ import type {
5
+ AztecAsyncMap,
6
+ AztecAsyncMultiMap,
7
+ AztecMap,
8
+ AztecMapWithSize,
9
+ AztecMultiMap,
10
+ AztecMultiMapWithSize,
11
11
  } from './map.js';
12
- import { type AztecAsyncSet, type AztecSet } from './set.js';
13
- import { type AztecAsyncSingleton, type AztecSingleton } from './singleton.js';
12
+ import type { AztecAsyncSet, AztecSet } from './set.js';
13
+ import type { AztecAsyncSingleton, AztecSingleton } from './singleton.js';
14
14
 
15
15
  /** A key-value store */
16
16
  export interface AztecKVStore {
@@ -1,7 +1,7 @@
1
1
  import { expect } from 'chai';
2
2
 
3
- import { type AztecAsyncSingleton, type AztecSingleton } from './singleton.js';
4
- import { type AztecAsyncKVStore, type AztecKVStore } from './store.js';
3
+ import type { AztecAsyncSingleton, AztecSingleton } from './singleton.js';
4
+ import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
5
5
  import { isSyncStore } from './utils.js';
6
6
 
7
7
  export function describeAztecStore(
@@ -1,4 +1,4 @@
1
- import { type AztecAsyncKVStore, type AztecKVStore } from './store.js';
1
+ import type { AztecAsyncKVStore, AztecKVStore } from './store.js';
2
2
 
3
3
  /* eslint-disable no-console */
4
4
  export const mockLogger = {
package/src/lmdb/array.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { type Database, type Key } from 'lmdb';
1
+ import type { Database, Key } from 'lmdb';
2
2
 
3
- import { type AztecArray, type AztecAsyncArray } from '../interfaces/array.js';
3
+ import type { AztecArray, AztecAsyncArray } from '../interfaces/array.js';
4
4
  import { LmdbAztecSingleton } from './singleton.js';
5
5
 
6
6
  /** The shape of a key that stores a value in an array */
@@ -1,7 +1,7 @@
1
- import { type Key as BaseKey, type Database } from 'lmdb';
1
+ import type { Key as BaseKey, Database } from 'lmdb';
2
2
 
3
- import { type Key, type Range } from '../interfaces/common.js';
4
- import { type AztecAsyncCounter, type AztecCounter } from '../interfaces/counter.js';
3
+ import type { Key, Range } from '../interfaces/common.js';
4
+ import type { AztecAsyncCounter, AztecCounter } from '../interfaces/counter.js';
5
5
  import { LmdbAztecMap } from './map.js';
6
6
 
7
7
  /**
package/src/lmdb/index.ts CHANGED
@@ -2,7 +2,7 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
2
2
 
3
3
  import { join } from 'path';
4
4
 
5
- import { type DataStoreConfig } from '../config.js';
5
+ import type { DataStoreConfig } from '../config.js';
6
6
  import { initStoreForRollup } from '../utils.js';
7
7
  import { AztecLmdbStore } from './store.js';
8
8
 
package/src/lmdb/map.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { type Database, type RangeOptions } from 'lmdb';
1
+ import type { Database, RangeOptions } from 'lmdb';
2
2
 
3
- import { type Key, type Range } from '../interfaces/common.js';
4
- import { type AztecAsyncMultiMap, type AztecMapWithSize, type AztecMultiMap } from '../interfaces/map.js';
3
+ import type { Key, Range } from '../interfaces/common.js';
4
+ import type { AztecAsyncMultiMap, AztecMapWithSize, AztecMultiMap } from '../interfaces/map.js';
5
5
 
6
6
  /** The slot where a key-value entry would be stored */
7
7
  type MapValueSlot<K extends Key | Buffer> = ['map', string, 'slot', K];
package/src/lmdb/set.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { type Database } from 'lmdb';
1
+ import type { Database } from 'lmdb';
2
2
 
3
- import { type Key, type Range } from '../interfaces/common.js';
4
- import { type AztecAsyncSet, type AztecSet } from '../interfaces/set.js';
3
+ import type { Key, Range } from '../interfaces/common.js';
4
+ import type { AztecAsyncSet, AztecSet } from '../interfaces/set.js';
5
5
  import { LmdbAztecMap } from './map.js';
6
6
 
7
7
  /**
@@ -1,6 +1,6 @@
1
- import { type Database, type Key } from 'lmdb';
1
+ import type { Database, Key } from 'lmdb';
2
2
 
3
- import { type AztecAsyncSingleton, type AztecSingleton } from '../interfaces/singleton.js';
3
+ import type { AztecAsyncSingleton, AztecSingleton } from '../interfaces/singleton.js';
4
4
 
5
5
  /** The slot where this singleton will store its value */
6
6
  type ValueSlot = ['singleton', string, 'value'];
package/src/lmdb/store.ts CHANGED
@@ -6,20 +6,20 @@ import { type Database, type RootDatabase, open } from 'lmdb';
6
6
  import { tmpdir } from 'os';
7
7
  import { join } from 'path';
8
8
 
9
- import { type AztecArray, type AztecAsyncArray } from '../interfaces/array.js';
10
- import { type Key, type StoreSize } from '../interfaces/common.js';
11
- import { type AztecAsyncCounter, type AztecCounter } from '../interfaces/counter.js';
12
- import {
13
- type AztecAsyncMap,
14
- type AztecAsyncMultiMap,
15
- type AztecMap,
16
- type AztecMapWithSize,
17
- type AztecMultiMap,
18
- type AztecMultiMapWithSize,
9
+ import type { AztecArray, AztecAsyncArray } from '../interfaces/array.js';
10
+ import type { Key, StoreSize } from '../interfaces/common.js';
11
+ import type { AztecAsyncCounter, AztecCounter } from '../interfaces/counter.js';
12
+ import type {
13
+ AztecAsyncMap,
14
+ AztecAsyncMultiMap,
15
+ AztecMap,
16
+ AztecMapWithSize,
17
+ AztecMultiMap,
18
+ AztecMultiMapWithSize,
19
19
  } from '../interfaces/map.js';
20
- import { type AztecAsyncSet, type AztecSet } from '../interfaces/set.js';
21
- import { type AztecAsyncSingleton, type AztecSingleton } from '../interfaces/singleton.js';
22
- import { type AztecAsyncKVStore, type AztecKVStore } from '../interfaces/store.js';
20
+ import type { AztecAsyncSet, AztecSet } from '../interfaces/set.js';
21
+ import type { AztecAsyncSingleton, AztecSingleton } from '../interfaces/singleton.js';
22
+ import type { AztecAsyncKVStore, AztecKVStore } from '../interfaces/store.js';
23
23
  import { LmdbAztecArray } from './array.js';
24
24
  import { LmdbAztecCounter } from './counter.js';
25
25
  import { LmdbAztecMap, LmdbAztecMapWithSize } from './map.js';
@@ -211,7 +211,7 @@ export class AztecLmdbStore implements AztecKVStore, AztecAsyncKVStore {
211
211
  await this.drop();
212
212
  await this.close();
213
213
  if (this.path) {
214
- await fs.rm(this.path, { recursive: true, force: true });
214
+ await fs.rm(this.path, { recursive: true, force: true, maxRetries: 3 });
215
215
  this.#log.verbose(`Deleted database files at ${this.path}`);
216
216
  }
217
217
  }
@@ -0,0 +1,115 @@
1
+ import { Encoder } from 'msgpackr/pack';
2
+
3
+ import type { AztecAsyncArray } from '../interfaces/array.js';
4
+ import type { AztecAsyncSingleton } from '../interfaces/singleton.js';
5
+ import type { ReadTransaction } from './read_transaction.js';
6
+ import { AztecLMDBStoreV2, execInReadTx, execInWriteTx } from './store.js';
7
+ import { deserializeKey, serializeKey } from './utils.js';
8
+
9
+ export class LMDBArray<T> implements AztecAsyncArray<T> {
10
+ private length: AztecAsyncSingleton<number>;
11
+ private encoder = new Encoder();
12
+ private prefix: string;
13
+
14
+ constructor(private store: AztecLMDBStoreV2, name: string) {
15
+ this.length = store.openSingleton(name + ':length');
16
+ this.prefix = `array:${name}`;
17
+ }
18
+
19
+ pop(): Promise<T | undefined> {
20
+ return execInWriteTx(this.store, async tx => {
21
+ const length = await this.lengthAsync();
22
+ if (length === 0) {
23
+ return;
24
+ }
25
+
26
+ const val = await tx.get(serializeKey(this.prefix, length - 1));
27
+ await tx.remove(serializeKey(this.prefix, length - 1));
28
+
29
+ await this.length.set(length - 1);
30
+
31
+ return val ? this.encoder.unpack(val) : undefined;
32
+ });
33
+ }
34
+
35
+ push(...vals: T[]): Promise<number> {
36
+ return execInWriteTx(this.store, async tx => {
37
+ let length = await this.lengthAsync();
38
+ for (const val of vals) {
39
+ await tx.set(serializeKey(this.prefix, length++), this.encoder.pack(val));
40
+ }
41
+ await this.length.set(length);
42
+ return length;
43
+ });
44
+ }
45
+
46
+ setAt(index: number, val: T): Promise<boolean> {
47
+ return execInWriteTx(this.store, async tx => {
48
+ const length = await this.lengthAsync();
49
+ if (index < 0) {
50
+ index += length;
51
+ }
52
+ if (index < 0 || index >= length) {
53
+ return false;
54
+ }
55
+ await tx.set(serializeKey(this.prefix, index), this.encoder.pack(val));
56
+ return true;
57
+ });
58
+ }
59
+
60
+ atAsync(index: number): Promise<T | undefined> {
61
+ return execInReadTx(this.store, async tx => {
62
+ const length = await this.lengthAsync();
63
+ if (index < 0) {
64
+ index += length;
65
+ }
66
+ if (index < 0 || index >= length) {
67
+ return undefined;
68
+ }
69
+
70
+ const val = await tx.get(serializeKey(this.prefix, index));
71
+ return val ? this.encoder.unpack(val) : undefined;
72
+ });
73
+ }
74
+
75
+ async lengthAsync(): Promise<number> {
76
+ return (await this.length.getAsync()) ?? 0;
77
+ }
78
+
79
+ async *entriesAsync(): AsyncIterableIterator<[number, T]> {
80
+ // pin array length so that pushes don't affect iteration
81
+ const length = await this.lengthAsync();
82
+ if (length === 0) {
83
+ return;
84
+ }
85
+
86
+ let tx: ReadTransaction | undefined = this.store.getCurrentWriteTx();
87
+ const shouldClose = !tx;
88
+ tx ??= this.store.getReadTx();
89
+
90
+ try {
91
+ for await (const [key, val] of tx.iterate(serializeKey(this.prefix, 0), undefined, false, length)) {
92
+ const deserializedKey = deserializeKey<number>(this.prefix, key);
93
+ // if pops happened while iterating we may have read too much. Terminate early
94
+ if (deserializedKey === false) {
95
+ break;
96
+ }
97
+ yield [deserializedKey, this.encoder.unpack(val)];
98
+ }
99
+ } finally {
100
+ if (shouldClose) {
101
+ tx.close();
102
+ }
103
+ }
104
+ }
105
+
106
+ async *valuesAsync(): AsyncIterableIterator<T> {
107
+ for await (const [_, value] of this.entriesAsync()) {
108
+ yield value;
109
+ }
110
+ }
111
+
112
+ [Symbol.asyncIterator](): AsyncIterableIterator<T> {
113
+ return this.valuesAsync();
114
+ }
115
+ }
@@ -1,11 +1,11 @@
1
- import { EthAddress } from '@aztec/circuits.js';
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
3
 
4
4
  import { mkdir, mkdtemp, readFile, rm, writeFile } from 'fs/promises';
5
5
  import { tmpdir } from 'os';
6
6
  import { join } from 'path';
7
7
 
8
- import { type DataStoreConfig } from '../config.js';
8
+ import type { DataStoreConfig } from '../config.js';
9
9
  import { AztecLMDBStoreV2 } from './store.js';
10
10
 
11
11
  const ROLLUP_ADDRESS_FILE = 'rollup_address';
@@ -36,7 +36,7 @@ export async function createStore(
36
36
  found: localRollupAddress,
37
37
  });
38
38
 
39
- await rm(subDir, { recursive: true, force: true });
39
+ await rm(subDir, { recursive: true, force: true, maxRetries: 3 });
40
40
  await mkdir(subDir, { recursive: true });
41
41
  }
42
42
 
@@ -68,8 +68,12 @@ export async function openTmpStore(
68
68
  // pass a cleanup callback because process.on('beforeExit', cleanup) does not work under Jest
69
69
  const cleanup = async () => {
70
70
  if (ephemeral) {
71
- await rm(dataDir, { recursive: true, force: true });
72
- log.debug(`Deleted temporary data store: ${dataDir}`);
71
+ try {
72
+ await rm(dataDir, { recursive: true, force: true, maxRetries: 3 });
73
+ log.debug(`Deleted temporary data store: ${dataDir}`);
74
+ } catch (err) {
75
+ log.warn(`Failed to delete temporary data directory (LMDB v2) ${dataDir}: ${err}`);
76
+ }
73
77
  } else {
74
78
  log.debug(`Leaving temporary data store: ${dataDir}`);
75
79
  }
@@ -2,7 +2,7 @@ import { Encoder } from 'msgpackr';
2
2
 
3
3
  import type { Key, Range } from '../interfaces/common.js';
4
4
  import type { AztecAsyncMap, AztecAsyncMultiMap } from '../interfaces/map.js';
5
- import { type ReadTransaction } from './read_transaction.js';
5
+ import type { ReadTransaction } from './read_transaction.js';
6
6
  import { type AztecLMDBStoreV2, execInReadTx, execInWriteTx } from './store.js';
7
7
  import { deserializeKey, maxKey, minKey, serializeKey } from './utils.js';
8
8
 
@@ -1,6 +1,6 @@
1
1
  import { Encoder } from 'msgpackr';
2
2
 
3
- import { type AztecAsyncSingleton } from '../interfaces/singleton.js';
3
+ import type { AztecAsyncSingleton } from '../interfaces/singleton.js';
4
4
  import { type AztecLMDBStoreV2, execInReadTx, execInWriteTx } from './store.js';
5
5
  import { serializeKey } from './utils.js';
6
6
 
@@ -12,6 +12,7 @@ import type { AztecAsyncMap, AztecAsyncMultiMap } from '../interfaces/map.js';
12
12
  import type { AztecAsyncSet } from '../interfaces/set.js';
13
13
  import type { AztecAsyncSingleton } from '../interfaces/singleton.js';
14
14
  import type { AztecAsyncKVStore } from '../interfaces/store.js';
15
+ import { LMDBArray } from './array.js';
15
16
  import { LMDBMap, LMDBMultiMap } from './map.js';
16
17
  import {
17
18
  Database,
@@ -103,8 +104,8 @@ export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel {
103
104
  return new LMDBSingleValue(this, name);
104
105
  }
105
106
 
106
- openArray<T>(_name: string): AztecAsyncArray<T> {
107
- throw new Error('Not implemented');
107
+ openArray<T>(name: string): AztecAsyncArray<T> {
108
+ return new LMDBArray(this, name);
108
109
  }
109
110
 
110
111
  openSet<K extends Key>(_name: string): AztecAsyncSet<K> {
@@ -155,7 +156,7 @@ export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel {
155
156
 
156
157
  async delete(): Promise<void> {
157
158
  await this.close();
158
- await rm(this.dataDir, { recursive: true, force: true });
159
+ await rm(this.dataDir, { recursive: true, force: true, maxRetries: 3 });
159
160
  this.log.verbose(`Deleted database files at ${this.dataDir}`);
160
161
  await this.cleanup?.();
161
162
  }
@@ -1,6 +1,6 @@
1
1
  import { MAXIMUM_KEY, fromBufferKey, toBufferKey } from 'ordered-binary';
2
2
 
3
- import { type Key } from '../interfaces/common.js';
3
+ import type { Key } from '../interfaces/common.js';
4
4
 
5
5
  type Cmp<T> = (a: T, b: T) => -1 | 0 | 1;
6
6
 
@@ -1,14 +1,14 @@
1
- import {
2
- type L2BlockId,
3
- type L2BlockStreamEvent,
4
- type L2BlockStreamEventHandler,
5
- type L2BlockStreamLocalDataProvider,
6
- type L2BlockTag,
7
- type L2Tips,
8
- } from '@aztec/circuit-types';
1
+ import type {
2
+ L2BlockId,
3
+ L2BlockStreamEvent,
4
+ L2BlockStreamEventHandler,
5
+ L2BlockStreamLocalDataProvider,
6
+ L2BlockTag,
7
+ L2Tips,
8
+ } from '@aztec/stdlib/block';
9
9
 
10
- import { type AztecAsyncMap } from '../interfaces/map.js';
11
- import { type AztecAsyncKVStore } from '../interfaces/store.js';
10
+ import type { AztecAsyncMap } from '../interfaces/map.js';
11
+ import type { AztecAsyncKVStore } from '../interfaces/store.js';
12
12
 
13
13
  /** Stores currently synced L2 tips and unfinalized block hashes. */
14
14
  export class L2TipsStore implements L2BlockStreamEventHandler, L2BlockStreamLocalDataProvider {
package/src/utils.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { type EthAddress } from '@aztec/foundation/eth-address';
2
- import { type Logger } from '@aztec/foundation/log';
1
+ import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { Logger } from '@aztec/foundation/log';
3
3
 
4
- import { type AztecAsyncSingleton, type AztecSingleton } from './interfaces/singleton.js';
5
- import { type AztecAsyncKVStore, type AztecKVStore } from './interfaces/store.js';
4
+ import type { AztecAsyncSingleton, AztecSingleton } from './interfaces/singleton.js';
5
+ import type { AztecAsyncKVStore, AztecKVStore } from './interfaces/store.js';
6
6
  import { isSyncStore } from './interfaces/utils.js';
7
7
 
8
8
  /**