Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fcarreiro committed May 3, 2024
1 parent 00ca1e9 commit 569386b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
12 changes: 0 additions & 12 deletions yarn-project/end-to-end/src/e2e_avm_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

Expand Down
4 changes: 0 additions & 4 deletions yarn-project/simulator/src/avm/journal/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,4 @@ export class AvmPersistableStateManager {
sideEffectCounter: this.trace.accessCounter,
};
}

public async commitToDBs() {
await this.publicStorage.commitToDB();
}
}
3 changes: 3 additions & 0 deletions yarn-project/simulator/src/avm/journal/public_storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/simulator/src/public/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 569386b

Please sign in to comment.