From 04ede966379569033440c6efe365e4ecb210b09d Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Wed, 14 Aug 2024 16:08:17 -0300 Subject: [PATCH 1/3] fix: Forking world state in prover-node Attempt to fix the `Error in prover node work: Error No such file or directory` error in prover-node when forking. Tested by connecting to the container, modifying the js, and running prover-node manually. --- yarn-project/kv-store/src/lmdb/store.test.ts | 2 +- yarn-project/kv-store/src/lmdb/store.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/kv-store/src/lmdb/store.test.ts b/yarn-project/kv-store/src/lmdb/store.test.ts index dc6f5f67755c..7d0bc653abac 100644 --- a/yarn-project/kv-store/src/lmdb/store.test.ts +++ b/yarn-project/kv-store/src/lmdb/store.test.ts @@ -20,7 +20,7 @@ describe('AztecLmdbStore', () => { }; it('forks a persistent store', async () => { - const path = join(await mkdtemp(join(tmpdir(), 'aztec-store-test-')), 'main.mdb'); + const path = await mkdtemp(join(tmpdir(), 'aztec-store-test-')); const store = AztecLmdbStore.open(path, false); await itForks(store); }); diff --git a/yarn-project/kv-store/src/lmdb/store.ts b/yarn-project/kv-store/src/lmdb/store.ts index f23ca16338c5..86965b6003d9 100644 --- a/yarn-project/kv-store/src/lmdb/store.ts +++ b/yarn-project/kv-store/src/lmdb/store.ts @@ -72,7 +72,7 @@ export class AztecLmdbStore implements AztecKVStore { async fork() { const baseDir = this.path ? dirname(this.path) : tmpdir(); this.#log.debug(`Forking store with basedir ${baseDir}`); - const forkPath = join(await mkdtemp(join(baseDir, 'aztec-store-fork-')), 'root.mdb'); + const forkPath = (await mkdtemp(join(baseDir, 'aztec-store-fork-'))) + (this.isEphemeral ? '/data.mdb' : ''); this.#log.verbose(`Forking store to ${forkPath}`); await this.#rootDb.backup(forkPath, false); const forkDb = open(forkPath, { noSync: this.isEphemeral }); From d5875cb73de8dd13b7bfab30b3adebce24a10e06 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Thu, 15 Aug 2024 10:18:25 +0000 Subject: [PATCH 2/3] Hopefully fixed forking --- yarn-project/kv-store/src/lmdb/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/kv-store/src/lmdb/store.ts b/yarn-project/kv-store/src/lmdb/store.ts index 86965b6003d9..9ae5afd1f582 100644 --- a/yarn-project/kv-store/src/lmdb/store.ts +++ b/yarn-project/kv-store/src/lmdb/store.ts @@ -72,7 +72,7 @@ export class AztecLmdbStore implements AztecKVStore { async fork() { const baseDir = this.path ? dirname(this.path) : tmpdir(); this.#log.debug(`Forking store with basedir ${baseDir}`); - const forkPath = (await mkdtemp(join(baseDir, 'aztec-store-fork-'))) + (this.isEphemeral ? '/data.mdb' : ''); + const forkPath = (await mkdtemp(join(baseDir, 'aztec-store-fork-'))) + '/data.mdb'; this.#log.verbose(`Forking store to ${forkPath}`); await this.#rootDb.backup(forkPath, false); const forkDb = open(forkPath, { noSync: this.isEphemeral }); From b9fb72539c56a7bb707212c972476d2742460de1 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Thu, 15 Aug 2024 11:09:14 +0000 Subject: [PATCH 3/3] Fixes --- yarn-project/kv-store/src/lmdb/store.test.ts | 5 +++++ yarn-project/kv-store/src/lmdb/store.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/yarn-project/kv-store/src/lmdb/store.test.ts b/yarn-project/kv-store/src/lmdb/store.test.ts index 7d0bc653abac..b443b630528c 100644 --- a/yarn-project/kv-store/src/lmdb/store.test.ts +++ b/yarn-project/kv-store/src/lmdb/store.test.ts @@ -25,6 +25,11 @@ describe('AztecLmdbStore', () => { await itForks(store); }); + it('forks a persistent store with no path', async () => { + const store = AztecLmdbStore.open(undefined, false); + await itForks(store); + }); + it('forks an ephemeral store', async () => { const store = AztecLmdbStore.open(undefined, true); await itForks(store); diff --git a/yarn-project/kv-store/src/lmdb/store.ts b/yarn-project/kv-store/src/lmdb/store.ts index 9ae5afd1f582..bbcf341859da 100644 --- a/yarn-project/kv-store/src/lmdb/store.ts +++ b/yarn-project/kv-store/src/lmdb/store.ts @@ -72,7 +72,8 @@ export class AztecLmdbStore implements AztecKVStore { async fork() { const baseDir = this.path ? dirname(this.path) : tmpdir(); this.#log.debug(`Forking store with basedir ${baseDir}`); - const forkPath = (await mkdtemp(join(baseDir, 'aztec-store-fork-'))) + '/data.mdb'; + const forkPath = + (await mkdtemp(join(baseDir, 'aztec-store-fork-'))) + (this.isEphemeral || !this.path ? '/data.mdb' : ''); this.#log.verbose(`Forking store to ${forkPath}`); await this.#rootDb.backup(forkPath, false); const forkDb = open(forkPath, { noSync: this.isEphemeral });