From 9a29456c109f05cd18dbe4c32597c8855e7e1335 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 3 Apr 2025 09:32:08 +0200 Subject: [PATCH 1/5] fix --- boxes/boxes/vite/playwright.config.ts | 2 +- yarn-project/kv-store/package.json | 1 + yarn-project/kv-store/src/indexeddb/array.ts | 6 ++- yarn-project/kv-store/src/indexeddb/map.ts | 6 ++- .../kv-store/src/indexeddb/multi_map.ts | 40 ++++++++++++------- .../kv-store/src/indexeddb/singleton.ts | 5 ++- yarn-project/kv-store/src/indexeddb/store.ts | 23 +++++++---- yarn-project/kv-store/src/interfaces/array.ts | 8 ++-- .../kv-store/src/interfaces/common.ts | 4 ++ yarn-project/kv-store/src/interfaces/map.ts | 8 ++-- .../kv-store/src/interfaces/multi_map.ts | 6 +-- .../src/interfaces/multi_map_test_suite.ts | 7 ++++ yarn-project/kv-store/src/interfaces/store.ts | 18 ++++----- yarn-project/kv-store/src/lmdb-v2/array.ts | 3 +- yarn-project/kv-store/src/lmdb-v2/map.ts | 4 +- .../kv-store/src/lmdb-v2/multi_map.ts | 4 +- yarn-project/kv-store/src/lmdb-v2/store.ts | 10 ++--- yarn-project/kv-store/src/lmdb/array.ts | 3 +- yarn-project/kv-store/src/lmdb/map.ts | 4 +- yarn-project/kv-store/src/lmdb/multi_map.ts | 4 +- yarn-project/kv-store/src/lmdb/store.ts | 8 ++-- .../pxe_oracle_interface.ts | 7 ++-- yarn-project/yarn.lock | 24 +++++++++++ 23 files changed, 138 insertions(+), 67 deletions(-) diff --git a/boxes/boxes/vite/playwright.config.ts b/boxes/boxes/vite/playwright.config.ts index e6ee606db1e8..3d318d3b4f19 100644 --- a/boxes/boxes/vite/playwright.config.ts +++ b/boxes/boxes/vite/playwright.config.ts @@ -6,7 +6,7 @@ export default defineConfig({ fullyParallel: true, retries: 3, workers: 1, - reporter: "list", + reporter: [["list", { console: true }]], use: { baseURL: "http://127.0.0.1:5173", trace: "on-first-retry", diff --git a/yarn-project/kv-store/package.json b/yarn-project/kv-store/package.json index a404c0ca1707..7964d6565685 100644 --- a/yarn-project/kv-store/package.json +++ b/yarn-project/kv-store/package.json @@ -32,6 +32,7 @@ "idb": "^8.0.0", "lmdb": "^3.2.0", "msgpackr": "^1.11.2", + "ohash": "^2.0.11", "ordered-binary": "^1.5.3" }, "devDependencies": { diff --git a/yarn-project/kv-store/src/indexeddb/array.ts b/yarn-project/kv-store/src/indexeddb/array.ts index ac9af264e587..19b2c71465b9 100644 --- a/yarn-project/kv-store/src/indexeddb/array.ts +++ b/yarn-project/kv-store/src/indexeddb/array.ts @@ -1,12 +1,14 @@ import type { IDBPDatabase, IDBPObjectStore } from 'idb'; +import { hash } from 'ohash'; import type { AztecAsyncArray } from '../interfaces/array.js'; +import type { Value } from '../interfaces/common.js'; import type { AztecIDBSchema } from './store.js'; /** * A persistent array backed by IndexedDB. */ -export class IndexedDBAztecArray implements AztecAsyncArray { +export class IndexedDBAztecArray implements AztecAsyncArray { #_db?: IDBPObjectStore; #rootDB: IDBPDatabase; #container: string; @@ -39,6 +41,7 @@ export class IndexedDBAztecArray implements AztecAsyncArray { for (const val of vals) { await this.db.put({ value: val, + hash: hash(val), container: this.#container, key: this.#name, keyCount: length + 1, @@ -86,6 +89,7 @@ export class IndexedDBAztecArray implements AztecAsyncArray { await this.db.put({ value: val, + hash: hash(val), container: this.#container, key: this.#name, keyCount: index + 1, diff --git a/yarn-project/kv-store/src/indexeddb/map.ts b/yarn-project/kv-store/src/indexeddb/map.ts index 41d0fb7fe7b9..25b1d766d5a2 100644 --- a/yarn-project/kv-store/src/indexeddb/map.ts +++ b/yarn-project/kv-store/src/indexeddb/map.ts @@ -1,13 +1,14 @@ import type { IDBPDatabase, IDBPObjectStore } from 'idb'; +import { hash } from 'ohash'; -import type { Key, Range } from '../interfaces/common.js'; +import type { Key, Range, Value } from '../interfaces/common.js'; import type { AztecAsyncMap } from '../interfaces/map.js'; import type { AztecIDBSchema } from './store.js'; /** * A map backed by IndexedDB. */ -export class IndexedDBAztecMap implements AztecAsyncMap { +export class IndexedDBAztecMap implements AztecAsyncMap { protected name: string; protected container: string; @@ -41,6 +42,7 @@ export class IndexedDBAztecMap implements AztecAsyncMap async set(key: K, val: V): Promise { await this.db.put({ value: val, + hash: hash(val), container: this.container, key: this.normalizeKey(key), keyCount: 1, diff --git a/yarn-project/kv-store/src/indexeddb/multi_map.ts b/yarn-project/kv-store/src/indexeddb/multi_map.ts index de7829671a6d..3b8325cc7c95 100644 --- a/yarn-project/kv-store/src/indexeddb/multi_map.ts +++ b/yarn-project/kv-store/src/indexeddb/multi_map.ts @@ -1,20 +1,34 @@ -import type { Key } from '../interfaces/common.js'; +import { hash } from 'ohash'; + +import type { Key, Value } from '../interfaces/common.js'; import type { AztecAsyncMultiMap } from '../interfaces/multi_map.js'; import { IndexedDBAztecMap } from './map.js'; /** * A multi map backed by IndexedDB. */ -export class IndexedDBAztecMultiMap +export class IndexedDBAztecMultiMap extends IndexedDBAztecMap implements AztecAsyncMultiMap { override async set(key: K, val: V): Promise { + const exists = !!(await this.db + .index('hash') + .get( + IDBKeyRange.bound( + [this.container, this.normalizeKey(key), hash(val)], + [this.container, this.normalizeKey(key), hash(val)], + ), + )); + if (exists) { + return; + } const count = await this.db .index('key') .count(IDBKeyRange.bound([this.container, this.normalizeKey(key)], [this.container, this.normalizeKey(key)])); await this.db.put({ value: val, + hash: hash(val), container: this.container, key: this.normalizeKey(key), keyCount: count + 1, @@ -36,18 +50,16 @@ export class IndexedDBAztecMultiMap } async deleteValue(key: K, val: V): Promise { - const index = this.db.index('keyCount'); - const rangeQuery = IDBKeyRange.bound( - [this.container, this.normalizeKey(key), 0], - [this.container, this.normalizeKey(key), Number.MAX_SAFE_INTEGER], - false, - false, - ); - for await (const cursor of index.iterate(rangeQuery)) { - if (JSON.stringify(cursor.value.value) === JSON.stringify(val)) { - await cursor.delete(); - return; - } + const fullKey = await this.db + .index('hash') + .getKey( + IDBKeyRange.bound( + [this.container, this.normalizeKey(key), hash(val)], + [this.container, this.normalizeKey(key), hash(val)], + ), + ); + if (fullKey) { + await this.db.delete(fullKey); } } } diff --git a/yarn-project/kv-store/src/indexeddb/singleton.ts b/yarn-project/kv-store/src/indexeddb/singleton.ts index b0e3d45aa7b3..1cf2fd2fb32d 100644 --- a/yarn-project/kv-store/src/indexeddb/singleton.ts +++ b/yarn-project/kv-store/src/indexeddb/singleton.ts @@ -1,12 +1,14 @@ import type { IDBPDatabase, IDBPObjectStore } from 'idb'; +import { hash } from 'ohash'; +import type { Value } from '../interfaces/common.js'; import type { AztecAsyncSingleton } from '../interfaces/singleton.js'; import type { AztecIDBSchema } from './store.js'; /** * Stores a single value in IndexedDB. */ -export class IndexedDBAztecSingleton implements AztecAsyncSingleton { +export class IndexedDBAztecSingleton implements AztecAsyncSingleton { #_db?: IDBPObjectStore; #rootDB: IDBPDatabase; #container: string; @@ -38,6 +40,7 @@ export class IndexedDBAztecSingleton implements AztecAsyncSingleton { key: this.#slot, keyCount: 1, value: val, + hash: hash(val), }); return result !== undefined; } diff --git a/yarn-project/kv-store/src/indexeddb/store.ts b/yarn-project/kv-store/src/indexeddb/store.ts index d4a8f50dfc8d..a5fcdc05941f 100644 --- a/yarn-project/kv-store/src/indexeddb/store.ts +++ b/yarn-project/kv-store/src/indexeddb/store.ts @@ -1,9 +1,10 @@ import type { Logger } from '@aztec/foundation/log'; import { type DBSchema, type IDBPDatabase, deleteDB, openDB } from 'idb'; +import type { NotUndefined } from 'object-hash'; import type { AztecAsyncArray } from '../interfaces/array.js'; -import type { Key, StoreSize } from '../interfaces/common.js'; +import type { Key, StoreSize, Value } from '../interfaces/common.js'; import type { AztecAsyncCounter } from '../interfaces/counter.js'; import type { AztecAsyncMap } from '../interfaces/map.js'; import type { AztecAsyncMultiMap } from '../interfaces/multi_map.js'; @@ -16,13 +17,20 @@ import { IndexedDBAztecMultiMap } from './multi_map.js'; import { IndexedDBAztecSet } from './set.js'; import { IndexedDBAztecSingleton } from './singleton.js'; -export type StoredData = { value: V; container: string; key: string; keyCount: number; slot: string }; +export type StoredData = { + value: V; + container: string; + key: string; + keyCount: number; + slot: string; + hash: string; +}; export interface AztecIDBSchema extends DBSchema { data: { value: StoredData; key: string; - indexes: { container: string; key: string; keyCount: number }; + indexes: { container: string; key: string; keyCount: number; hash: string }; }; } @@ -67,6 +75,7 @@ export class AztecIndexedDBStore implements AztecAsyncKVStore { objectStore.createIndex('key', ['container', 'key'], { unique: false }); objectStore.createIndex('keyCount', ['container', 'key', 'keyCount'], { unique: false }); + objectStore.createIndex('hash', ['container', 'key', 'hash'], { unique: true }); }, }); @@ -79,7 +88,7 @@ export class AztecIndexedDBStore implements AztecAsyncKVStore { * @param name - Name of the map * @returns A new AztecMap */ - openMap(name: string): AztecAsyncMap { + openMap(name: string): AztecAsyncMap { const map = new IndexedDBAztecMap(this.#rootDB, name); this.#containers.add(map); return map; @@ -101,7 +110,7 @@ export class AztecIndexedDBStore implements AztecAsyncKVStore { * @param name - Name of the map * @returns A new AztecMultiMap */ - openMultiMap(name: string): AztecAsyncMultiMap { + openMultiMap(name: string): AztecAsyncMultiMap { const multimap = new IndexedDBAztecMultiMap(this.#rootDB, name); this.#containers.add(multimap); return multimap; @@ -116,7 +125,7 @@ export class AztecIndexedDBStore implements AztecAsyncKVStore { * @param name - Name of the array * @returns A new AztecArray */ - openArray(name: string): AztecAsyncArray { + openArray(name: string): AztecAsyncArray { const array = new IndexedDBAztecArray(this.#rootDB, name); this.#containers.add(array); return array; @@ -127,7 +136,7 @@ export class AztecIndexedDBStore implements AztecAsyncKVStore { * @param name - Name of the singleton * @returns A new AztecSingleton */ - openSingleton(name: string): AztecAsyncSingleton { + openSingleton(name: string): AztecAsyncSingleton { const singleton = new IndexedDBAztecSingleton(this.#rootDB, name); this.#containers.add(singleton); return singleton; diff --git a/yarn-project/kv-store/src/interfaces/array.ts b/yarn-project/kv-store/src/interfaces/array.ts index 70e98a24c3e9..7b0647bef608 100644 --- a/yarn-project/kv-store/src/interfaces/array.ts +++ b/yarn-project/kv-store/src/interfaces/array.ts @@ -1,7 +1,9 @@ +import type { Value } from './common.js'; + /** * An array backed by a persistent store. Can not have any holes in it. */ -interface BaseAztecArray { +interface BaseAztecArray { /** * Pushes values to the end of the array * @param vals - The values to push to the end of the array @@ -27,7 +29,7 @@ interface BaseAztecArray { /** * An array backed by a persistent store. Can not have any holes in it. */ -export interface AztecAsyncArray extends BaseAztecArray { +export interface AztecAsyncArray extends BaseAztecArray { /** * The size of the array */ @@ -58,7 +60,7 @@ export interface AztecAsyncArray extends BaseAztecArray { [Symbol.asyncIterator](): AsyncIterableIterator; } -export interface AztecArray extends BaseAztecArray { +export interface AztecArray extends BaseAztecArray { /** * The size of the array */ diff --git a/yarn-project/kv-store/src/interfaces/common.ts b/yarn-project/kv-store/src/interfaces/common.ts index f7123038f839..1bf2ef1d0273 100644 --- a/yarn-project/kv-store/src/interfaces/common.ts +++ b/yarn-project/kv-store/src/interfaces/common.ts @@ -1,8 +1,12 @@ +import type { NotUndefined } from 'object-hash'; + /** * The key type for use with the kv-store */ export type Key = string | number | Array; +export type Value = NonNullable; + /** * A range of keys to iterate over. */ diff --git a/yarn-project/kv-store/src/interfaces/map.ts b/yarn-project/kv-store/src/interfaces/map.ts index e498185df0ea..2cec186697f4 100644 --- a/yarn-project/kv-store/src/interfaces/map.ts +++ b/yarn-project/kv-store/src/interfaces/map.ts @@ -1,9 +1,9 @@ -import type { Key, Range } from './common.js'; +import type { Key, Range, Value } from './common.js'; /** * A map backed by a persistent store. */ -interface AztecBaseMap { +interface AztecBaseMap { /** * Sets the value at the given key. * @param key - The key to set the value at @@ -24,7 +24,7 @@ interface AztecBaseMap { */ delete(key: K): Promise; } -export interface AztecMap extends AztecBaseMap { +export interface AztecMap extends AztecBaseMap { /** * Gets the value at the given key. * @param key - The key to get the value from @@ -65,7 +65,7 @@ export interface AztecMap extends AztecBaseMap { /** * A map backed by a persistent store. */ -export interface AztecAsyncMap extends AztecBaseMap { +export interface AztecAsyncMap extends AztecBaseMap { /** * Gets the value at the given key. * @param key - The key to get the value from diff --git a/yarn-project/kv-store/src/interfaces/multi_map.ts b/yarn-project/kv-store/src/interfaces/multi_map.ts index 4e3d7e922c7f..b54b773b4bd3 100644 --- a/yarn-project/kv-store/src/interfaces/multi_map.ts +++ b/yarn-project/kv-store/src/interfaces/multi_map.ts @@ -1,10 +1,10 @@ -import type { Key } from './common.js'; +import type { Key, Value } from './common.js'; import type { AztecAsyncMap, AztecMap } from './map.js'; /** * A map backed by a persistent store that can have multiple values for a single key. */ -export interface AztecMultiMap extends AztecMap { +export interface AztecMultiMap extends AztecMap { /** * Gets all the values at the given key. * @param key - The key to get the values from @@ -22,7 +22,7 @@ export interface AztecMultiMap extends AztecMap { /** * A map backed by a persistent store that can have multiple values for a single key. */ -export interface AztecAsyncMultiMap extends AztecAsyncMap { +export interface AztecAsyncMultiMap extends AztecAsyncMap { /** * Gets all the values at the given key. * @param key - The key to get the values from diff --git a/yarn-project/kv-store/src/interfaces/multi_map_test_suite.ts b/yarn-project/kv-store/src/interfaces/multi_map_test_suite.ts index 8e23a11d4eb7..37a2ee6c4cf8 100644 --- a/yarn-project/kv-store/src/interfaces/multi_map_test_suite.ts +++ b/yarn-project/kv-store/src/interfaces/multi_map_test_suite.ts @@ -116,6 +116,13 @@ export function describeAztecMultiMap( expect(await getValues('foo')).to.deep.equal(['bar', 'baz']); }); + it('should ignore multiple identical values', async () => { + await multiMap.set('foo', 'bar'); + await multiMap.set('foo', 'bar'); + + expect(await getValues('foo')).to.deep.equal(['bar']); + }); + it('should be able to delete individual values for a single key', async () => { await multiMap.set('foo', 'bar'); await multiMap.set('foo', 'baz'); diff --git a/yarn-project/kv-store/src/interfaces/store.ts b/yarn-project/kv-store/src/interfaces/store.ts index 0733b48f01e5..4bc41a391c98 100644 --- a/yarn-project/kv-store/src/interfaces/store.ts +++ b/yarn-project/kv-store/src/interfaces/store.ts @@ -1,5 +1,5 @@ import type { AztecArray, AztecAsyncArray } from './array.js'; -import type { Key, StoreSize } from './common.js'; +import type { Key, StoreSize, Value } from './common.js'; import type { AztecAsyncCounter, AztecCounter } from './counter.js'; import type { AztecAsyncMap, AztecMap } from './map.js'; import type { AztecAsyncMultiMap, AztecMultiMap } from './multi_map.js'; @@ -14,7 +14,7 @@ export interface AztecKVStore { * @param name - The name of the map * @returns The map */ - openMap(name: string): AztecMap; + openMap(name: string): AztecMap; /** * Creates a new set. @@ -28,21 +28,21 @@ export interface AztecKVStore { * @param name - The name of the multi-map * @returns The multi-map */ - openMultiMap(name: string): AztecMultiMap; + openMultiMap(name: string): AztecMultiMap; /** * Creates a new array. * @param name - The name of the array * @returns The array */ - openArray(name: string): AztecArray; + openArray(name: string): AztecArray; /** * Creates a new singleton. * @param name - The name of the singleton * @returns The singleton */ - openSingleton(name: string): AztecSingleton; + openSingleton(name: string): AztecSingleton; /** * Creates a new count map. @@ -83,7 +83,7 @@ export interface AztecAsyncKVStore { * @param name - The name of the map * @returns The map */ - openMap(name: string): AztecAsyncMap; + openMap(name: string): AztecAsyncMap; /** * Creates a new set. @@ -97,21 +97,21 @@ export interface AztecAsyncKVStore { * @param name - The name of the multi-map * @returns The multi-map */ - openMultiMap(name: string): AztecAsyncMultiMap; + openMultiMap(name: string): AztecAsyncMultiMap; /** * Creates a new array. * @param name - The name of the array * @returns The array */ - openArray(name: string): AztecAsyncArray; + openArray(name: string): AztecAsyncArray; /** * Creates a new singleton. * @param name - The name of the singleton * @returns The singleton */ - openSingleton(name: string): AztecAsyncSingleton; + openSingleton(name: string): AztecAsyncSingleton; /** * Creates a new count map. diff --git a/yarn-project/kv-store/src/lmdb-v2/array.ts b/yarn-project/kv-store/src/lmdb-v2/array.ts index b1362f34f7fb..8ce6da0cf076 100644 --- a/yarn-project/kv-store/src/lmdb-v2/array.ts +++ b/yarn-project/kv-store/src/lmdb-v2/array.ts @@ -1,13 +1,14 @@ import { Encoder } from 'msgpackr/pack'; import type { AztecAsyncArray } from '../interfaces/array.js'; +import type { Value } from '../interfaces/common.js'; import type { AztecAsyncSingleton } from '../interfaces/singleton.js'; import type { ReadTransaction } from './read_transaction.js'; // eslint-disable-next-line import/no-cycle import { AztecLMDBStoreV2, execInReadTx, execInWriteTx } from './store.js'; import { deserializeKey, serializeKey } from './utils.js'; -export class LMDBArray implements AztecAsyncArray { +export class LMDBArray implements AztecAsyncArray { private length: AztecAsyncSingleton; private encoder = new Encoder(); private prefix: string; diff --git a/yarn-project/kv-store/src/lmdb-v2/map.ts b/yarn-project/kv-store/src/lmdb-v2/map.ts index 36d8f39e3e87..9e29e0c28d48 100644 --- a/yarn-project/kv-store/src/lmdb-v2/map.ts +++ b/yarn-project/kv-store/src/lmdb-v2/map.ts @@ -1,13 +1,13 @@ import { Encoder } from 'msgpackr'; -import type { Key, Range } from '../interfaces/common.js'; +import type { Key, Range, Value } from '../interfaces/common.js'; import type { AztecAsyncMap } from '../interfaces/map.js'; import type { ReadTransaction } from './read_transaction.js'; // eslint-disable-next-line import/no-cycle import { type AztecLMDBStoreV2, execInReadTx, execInWriteTx } from './store.js'; import { deserializeKey, maxKey, minKey, serializeKey } from './utils.js'; -export class LMDBMap implements AztecAsyncMap { +export class LMDBMap implements AztecAsyncMap { private prefix: string; private encoder = new Encoder(); diff --git a/yarn-project/kv-store/src/lmdb-v2/multi_map.ts b/yarn-project/kv-store/src/lmdb-v2/multi_map.ts index b6d863929e73..a680b80a1664 100644 --- a/yarn-project/kv-store/src/lmdb-v2/multi_map.ts +++ b/yarn-project/kv-store/src/lmdb-v2/multi_map.ts @@ -1,12 +1,12 @@ import { Encoder } from 'msgpackr/pack'; -import type { Key, Range } from '../interfaces/common.js'; +import type { Key, Range, Value } from '../interfaces/common.js'; import type { AztecAsyncMultiMap } from '../interfaces/multi_map.js'; import type { ReadTransaction } from './read_transaction.js'; import { type AztecLMDBStoreV2, execInReadTx, execInWriteTx } from './store.js'; import { deserializeKey, maxKey, minKey, serializeKey } from './utils.js'; -export class LMDBMultiMap implements AztecAsyncMultiMap { +export class LMDBMultiMap implements AztecAsyncMultiMap { private prefix: string; private encoder = new Encoder(); constructor(private store: AztecLMDBStoreV2, name: string) { diff --git a/yarn-project/kv-store/src/lmdb-v2/store.ts b/yarn-project/kv-store/src/lmdb-v2/store.ts index 3b2c7030c418..07123a25595f 100644 --- a/yarn-project/kv-store/src/lmdb-v2/store.ts +++ b/yarn-project/kv-store/src/lmdb-v2/store.ts @@ -6,7 +6,7 @@ import { AsyncLocalStorage } from 'async_hooks'; import { mkdir, rm } from 'fs/promises'; import type { AztecAsyncArray } from '../interfaces/array.js'; -import type { Key, StoreSize } from '../interfaces/common.js'; +import type { Key, StoreSize, Value } from '../interfaces/common.js'; import type { AztecAsyncCounter } from '../interfaces/counter.js'; import type { AztecAsyncMap } from '../interfaces/map.js'; import type { AztecAsyncMultiMap } from '../interfaces/multi_map.js'; @@ -102,19 +102,19 @@ export class AztecLMDBStoreV2 implements AztecAsyncKVStore, LMDBMessageChannel { return currentWrite; } - openMap(name: string): AztecAsyncMap { + openMap(name: string): AztecAsyncMap { return new LMDBMap(this, name); } - openMultiMap(name: string): AztecAsyncMultiMap { + openMultiMap(name: string): AztecAsyncMultiMap { return new LMDBMultiMap(this, name); } - openSingleton(name: string): AztecAsyncSingleton { + openSingleton(name: string): AztecAsyncSingleton { return new LMDBSingleValue(this, name); } - openArray(name: string): AztecAsyncArray { + openArray(name: string): AztecAsyncArray { return new LMDBArray(this, name); } diff --git a/yarn-project/kv-store/src/lmdb/array.ts b/yarn-project/kv-store/src/lmdb/array.ts index 5734e4d6ecb0..0f6bf03a8059 100644 --- a/yarn-project/kv-store/src/lmdb/array.ts +++ b/yarn-project/kv-store/src/lmdb/array.ts @@ -1,6 +1,7 @@ import type { Database, Key } from 'lmdb'; import type { AztecArray, AztecAsyncArray } from '../interfaces/array.js'; +import type { Value } from '../interfaces/common.js'; import { LmdbAztecSingleton } from './singleton.js'; /** The shape of a key that stores a value in an array */ @@ -9,7 +10,7 @@ type ArrayIndexSlot = ['array', string, 'slot', number]; /** * An persistent array backed by LMDB. */ -export class LmdbAztecArray implements AztecArray, AztecAsyncArray { +export class LmdbAztecArray implements AztecArray, AztecAsyncArray { #db: Database; #name: string; #length: LmdbAztecSingleton; diff --git a/yarn-project/kv-store/src/lmdb/map.ts b/yarn-project/kv-store/src/lmdb/map.ts index 148d91361557..d80974903393 100644 --- a/yarn-project/kv-store/src/lmdb/map.ts +++ b/yarn-project/kv-store/src/lmdb/map.ts @@ -1,6 +1,6 @@ import type { Database, RangeOptions } from 'lmdb'; -import type { Key, Range } from '../interfaces/common.js'; +import type { Key, Range, Value } from '../interfaces/common.js'; import type { AztecAsyncMap, AztecMap } from '../interfaces/map.js'; /** The slot where a key-value entry would be stored */ @@ -9,7 +9,7 @@ type MapValueSlot = ['map', string, 'slot', K]; /** * A map backed by LMDB. */ -export class LmdbAztecMap implements AztecMap, AztecAsyncMap { +export class LmdbAztecMap implements AztecMap, AztecAsyncMap { protected db: Database<[K, V], MapValueSlot>; protected name: string; diff --git a/yarn-project/kv-store/src/lmdb/multi_map.ts b/yarn-project/kv-store/src/lmdb/multi_map.ts index fad497032028..4b0ecceb9e22 100644 --- a/yarn-project/kv-store/src/lmdb/multi_map.ts +++ b/yarn-project/kv-store/src/lmdb/multi_map.ts @@ -1,11 +1,11 @@ -import type { Key } from '../interfaces/common.js'; +import type { Key, Value } from '../interfaces/common.js'; import type { AztecAsyncMultiMap, AztecMultiMap } from '../interfaces/multi_map.js'; import { LmdbAztecMap } from './map.js'; /** * A map backed by LMDB. */ -export class LmdbAztecMultiMap +export class LmdbAztecMultiMap extends LmdbAztecMap implements AztecMultiMap, AztecAsyncMultiMap { diff --git a/yarn-project/kv-store/src/lmdb/store.ts b/yarn-project/kv-store/src/lmdb/store.ts index fc83245f4640..39084657c716 100644 --- a/yarn-project/kv-store/src/lmdb/store.ts +++ b/yarn-project/kv-store/src/lmdb/store.ts @@ -7,7 +7,7 @@ import { tmpdir } from 'os'; import { join } from 'path'; import type { AztecArray, AztecAsyncArray } from '../interfaces/array.js'; -import type { Key, StoreSize } from '../interfaces/common.js'; +import type { Key, StoreSize, Value } from '../interfaces/common.js'; import type { AztecAsyncCounter, AztecCounter } from '../interfaces/counter.js'; import type { AztecAsyncMap, AztecMap } from '../interfaces/map.js'; import type { AztecAsyncMultiMap, AztecMultiMap } from '../interfaces/multi_map.js'; @@ -80,7 +80,7 @@ export class AztecLmdbStore implements AztecKVStore, AztecAsyncKVStore { * @param name - Name of the map * @returns A new AztecMap */ - openMap(name: string): AztecMap & AztecAsyncMap { + openMap(name: string): AztecMap & AztecAsyncMap { return new LmdbAztecMap(this.#data, name); } @@ -98,7 +98,7 @@ export class AztecLmdbStore implements AztecKVStore, AztecAsyncKVStore { * @param name - Name of the map * @returns A new AztecMultiMap */ - openMultiMap(name: string): AztecMultiMap & AztecAsyncMultiMap { + openMultiMap(name: string): AztecMultiMap & AztecAsyncMultiMap { return new LmdbAztecMultiMap(this.#multiMapData, name); } @@ -111,7 +111,7 @@ export class AztecLmdbStore implements AztecKVStore, AztecAsyncKVStore { * @param name - Name of the array * @returns A new AztecArray */ - openArray(name: string): AztecArray & AztecAsyncArray { + openArray(name: string): AztecArray & AztecAsyncArray { return new LmdbAztecArray(this.#data, name); } diff --git a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts index 865de15be689..69f306143399 100644 --- a/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts +++ b/yarn-project/pxe/src/pxe_oracle_interface/pxe_oracle_interface.ts @@ -675,9 +675,10 @@ export class PXEOracleInterface implements ExecutionDataProvider { await this.noteDataProvider.addNotes([noteDao], recipient); this.log.verbose('Added note', { - contract: noteDao.contractAddress, - slot: noteDao.storageSlot, - noteHash: noteDao.noteHash, + index: noteDao.index, + contract: noteDao.contractAddress.toString(), + slot: noteDao.storageSlot.toString(), + noteHash: noteDao.noteHash.toString(), nullifier: noteDao.siloedNullifier.toString(), }); diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 031ed6b9cded..1d0330a375e2 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -865,6 +865,7 @@ __metadata: "@types/mocha": "npm:^10.0.10" "@types/mocha-each": "npm:^2.0.4" "@types/node": "npm:^18.7.23" + "@types/object-hash": "npm:^3" "@types/sinon": "npm:^17.0.3" "@web/dev-server-esbuild": "npm:^1.0.3" "@web/test-runner": "npm:^0.19.0" @@ -877,6 +878,8 @@ __metadata: mocha: "npm:^10.8.2" mocha-each: "npm:^2.0.1" msgpackr: "npm:^1.11.2" + object-hash: "npm:^3.0.0" + ohash: "npm:^2.0.11" ordered-binary: "npm:^1.5.3" sinon: "npm:^19.0.2" ts-node: "npm:^10.9.1" @@ -6297,6 +6300,13 @@ __metadata: languageName: node linkType: hard +"@types/object-hash@npm:^3": + version: 3.0.6 + resolution: "@types/object-hash@npm:3.0.6" + checksum: 10/2c7979d4e540af817b99c09fb4c2fed1c0b0e14342df474d8dcde4165a82c440b038341fd66fe998d9f86acdd5cccc65ba8092315e39e7c2114f945fa70aaa56 + languageName: node + linkType: hard + "@types/pako@npm:^2.0.0, @types/pako@npm:^2.0.3": version: 2.0.3 resolution: "@types/pako@npm:2.0.3" @@ -17273,6 +17283,13 @@ __metadata: languageName: node linkType: hard +"object-hash@npm:^3.0.0": + version: 3.0.0 + resolution: "object-hash@npm:3.0.0" + checksum: 10/f498d456a20512ba7be500cef4cf7b3c183cc72c65372a549c9a0e6dd78ce26f375e9b1315c07592d3fde8f10d5019986eba35970570d477ed9a2a702514432a + languageName: node + linkType: hard + "object-inspect@npm:^1.13.1": version: 1.13.1 resolution: "object-inspect@npm:1.13.1" @@ -17347,6 +17364,13 @@ __metadata: languageName: node linkType: hard +"ohash@npm:^2.0.11": + version: 2.0.11 + resolution: "ohash@npm:2.0.11" + checksum: 10/6b0423f42cc95c3d643f390a88364aac824178b7788dccb4e8c64e2124463d0069e60d4d90bad88ed9823808368d051e088aa27058ca4722b1397a201ffbfa4b + languageName: node + linkType: hard + "on-exit-leak-free@npm:^2.1.0": version: 2.1.2 resolution: "on-exit-leak-free@npm:2.1.2" From 05d9ca0c865d77d0e2def68a9ce3394f6c5b19d8 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 3 Apr 2025 09:34:40 +0200 Subject: [PATCH 2/5] fmt --- yarn-project/kv-store/src/interfaces/common.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/yarn-project/kv-store/src/interfaces/common.ts b/yarn-project/kv-store/src/interfaces/common.ts index 1bf2ef1d0273..a8d6b28f9459 100644 --- a/yarn-project/kv-store/src/interfaces/common.ts +++ b/yarn-project/kv-store/src/interfaces/common.ts @@ -1,5 +1,3 @@ -import type { NotUndefined } from 'object-hash'; - /** * The key type for use with the kv-store */ From 2d5741b4313d897f5ebb7d3a3c269a8f2392a591 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 3 Apr 2025 09:42:40 +0200 Subject: [PATCH 3/5] fixes --- boxes/boxes/vite/playwright.config.ts | 2 +- yarn-project/yarn.lock | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/boxes/boxes/vite/playwright.config.ts b/boxes/boxes/vite/playwright.config.ts index 3d318d3b4f19..e6ee606db1e8 100644 --- a/boxes/boxes/vite/playwright.config.ts +++ b/boxes/boxes/vite/playwright.config.ts @@ -6,7 +6,7 @@ export default defineConfig({ fullyParallel: true, retries: 3, workers: 1, - reporter: [["list", { console: true }]], + reporter: "list", use: { baseURL: "http://127.0.0.1:5173", trace: "on-first-retry", diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 1d0330a375e2..4a6cf09d3de5 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -865,7 +865,6 @@ __metadata: "@types/mocha": "npm:^10.0.10" "@types/mocha-each": "npm:^2.0.4" "@types/node": "npm:^18.7.23" - "@types/object-hash": "npm:^3" "@types/sinon": "npm:^17.0.3" "@web/dev-server-esbuild": "npm:^1.0.3" "@web/test-runner": "npm:^0.19.0" @@ -878,7 +877,6 @@ __metadata: mocha: "npm:^10.8.2" mocha-each: "npm:^2.0.1" msgpackr: "npm:^1.11.2" - object-hash: "npm:^3.0.0" ohash: "npm:^2.0.11" ordered-binary: "npm:^1.5.3" sinon: "npm:^19.0.2" @@ -6300,13 +6298,6 @@ __metadata: languageName: node linkType: hard -"@types/object-hash@npm:^3": - version: 3.0.6 - resolution: "@types/object-hash@npm:3.0.6" - checksum: 10/2c7979d4e540af817b99c09fb4c2fed1c0b0e14342df474d8dcde4165a82c440b038341fd66fe998d9f86acdd5cccc65ba8092315e39e7c2114f945fa70aaa56 - languageName: node - linkType: hard - "@types/pako@npm:^2.0.0, @types/pako@npm:^2.0.3": version: 2.0.3 resolution: "@types/pako@npm:2.0.3" @@ -17283,13 +17274,6 @@ __metadata: languageName: node linkType: hard -"object-hash@npm:^3.0.0": - version: 3.0.0 - resolution: "object-hash@npm:3.0.0" - checksum: 10/f498d456a20512ba7be500cef4cf7b3c183cc72c65372a549c9a0e6dd78ce26f375e9b1315c07592d3fde8f10d5019986eba35970570d477ed9a2a702514432a - languageName: node - linkType: hard - "object-inspect@npm:^1.13.1": version: 1.13.1 resolution: "object-inspect@npm:1.13.1" From 85c8411838c688cf84f55c21556a5e1ed8242440 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 3 Apr 2025 07:53:47 +0000 Subject: [PATCH 4/5] fix --- yarn-project/kv-store/src/indexeddb/store.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/yarn-project/kv-store/src/indexeddb/store.ts b/yarn-project/kv-store/src/indexeddb/store.ts index a5fcdc05941f..aa4365114647 100644 --- a/yarn-project/kv-store/src/indexeddb/store.ts +++ b/yarn-project/kv-store/src/indexeddb/store.ts @@ -1,7 +1,6 @@ import type { Logger } from '@aztec/foundation/log'; import { type DBSchema, type IDBPDatabase, deleteDB, openDB } from 'idb'; -import type { NotUndefined } from 'object-hash'; import type { AztecAsyncArray } from '../interfaces/array.js'; import type { Key, StoreSize, Value } from '../interfaces/common.js'; @@ -17,7 +16,7 @@ import { IndexedDBAztecMultiMap } from './multi_map.js'; import { IndexedDBAztecSet } from './set.js'; import { IndexedDBAztecSingleton } from './singleton.js'; -export type StoredData = { +export type StoredData = { value: V; container: string; key: string; From 09ed7c2a78535944da3529225ffa65e0e36c9269 Mon Sep 17 00:00:00 2001 From: thunkar Date: Thu, 3 Apr 2025 09:19:23 +0000 Subject: [PATCH 5/5] added flake --- .test_patterns.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.test_patterns.yml b/.test_patterns.yml index a055f2dfc353..2c2bf0ed6209 100644 --- a/.test_patterns.yml +++ b/.test_patterns.yml @@ -104,6 +104,10 @@ tests: error_regex: "TimeoutError: Timeout awaiting blocks mined" owners: - *palla + - regex: "simple e2e_p2p/reqresp" + error_regex: "TimeoutError: Timeout awaiting isMined" + owners: + - *palla - regex: "simple e2e_fees/private_payments" owners: - *phil