From 569386b8ed0f556e96403cf59592f5e0ac166cce Mon Sep 17 00:00:00 2001 From: fcarreiro Date: Fri, 3 May 2024 14:05:05 +0000 Subject: [PATCH] minor changes --- .../end-to-end/src/e2e_avm_simulator.test.ts | 12 ------------ yarn-project/simulator/src/avm/journal/journal.ts | 4 ---- .../simulator/src/avm/journal/public_storage.ts | 3 +++ yarn-project/simulator/src/public/executor.ts | 5 +++-- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts index ddb2255da12f..e502f13f86d5 100644 --- a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts +++ b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts @@ -98,18 +98,6 @@ describe('e2e_avm_simulator', () => { tx = await avmContract.methods.assert_nullifier_exists(nullifier).send().wait(); expect(tx.status).toEqual(TxStatus.MINED); }); - - it.skip('Emit and check in separate enqueued calls but same tx', async () => { - const nullifier = new Fr(123456); - - // This will create 1 tx with 2 public calls in it. - await new BatchCall(wallet, [ - avmContract.methods.new_nullifier(nullifier).request(), - avmContract.methods.assert_nullifier_exists(nullifier).request(), - ]) - .send() - .wait(); - }); }); }); diff --git a/yarn-project/simulator/src/avm/journal/journal.ts b/yarn-project/simulator/src/avm/journal/journal.ts index 781612b7ed2b..2b58e8618f8d 100644 --- a/yarn-project/simulator/src/avm/journal/journal.ts +++ b/yarn-project/simulator/src/avm/journal/journal.ts @@ -249,8 +249,4 @@ export class AvmPersistableStateManager { sideEffectCounter: this.trace.accessCounter, }; } - - public async commitToDBs() { - await this.publicStorage.commitToDB(); - } } diff --git a/yarn-project/simulator/src/avm/journal/public_storage.ts b/yarn-project/simulator/src/avm/journal/public_storage.ts index 526e012f92ac..30c59e421b31 100644 --- a/yarn-project/simulator/src/avm/journal/public_storage.ts +++ b/yarn-project/simulator/src/avm/journal/public_storage.ts @@ -86,6 +86,9 @@ export class PublicStorage { this.cache.acceptAndMerge(incomingPublicStorage.cache); } + /** + * Commits ALL staged writes to the host's state. + */ public async commitToDB() { for (const [storageAddress, cacheAtContract] of this.cache.cachePerContract) { for (const [slot, value] of cacheAtContract) { diff --git a/yarn-project/simulator/src/public/executor.ts b/yarn-project/simulator/src/public/executor.ts index 38a35d0eae82..29dfce2a3615 100644 --- a/yarn-project/simulator/src/public/executor.ts +++ b/yarn-project/simulator/src/public/executor.ts @@ -89,8 +89,9 @@ async function executePublicFunctionAvm( if (!nested) { // Commit the journals state to the DBs if this is the top-level execution. - await context.persistableState.commitToDBs(); - // TODO: Nullifiers, etc. + // Observe that this will write all the state changes to the DBs, not only the latest for each slot. + // However, the underlying DB keep a cache and will only write the latest state to disk. + await context.persistableState.publicStorage.commitToDB(); } log.verbose(