Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { type MerkleTreeWriteOperations } from '@aztec/circuit-types';
import { type AvmCircuitInputs, AztecAddress, VerificationKeyData } from '@aztec/circuits.js';
import { openTmpStore } from '@aztec/kv-store/lmdb';
import { PublicTxSimulationTester, type TestEnqueuedCall } from '@aztec/simulator/public/fixtures';
import { MerkleTrees } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state';

import fs from 'node:fs/promises';
import { tmpdir } from 'node:os';
Expand Down Expand Up @@ -37,7 +36,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));

const contractDataSource = new SimpleContractDataSource();
const merkleTrees = await (await MerkleTrees.new(openTmpStore())).fork();
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
return new AvmProvingTester(
bbWorkingDirectory,
checkCircuitOnly,
Expand Down Expand Up @@ -122,7 +121,7 @@ export class AvmProvingTesterV2 extends PublicTxSimulationTester {
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));

const contractDataSource = new SimpleContractDataSource();
const merkleTrees = await (await MerkleTrees.new(openTmpStore())).fork();
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
return new AvmProvingTesterV2(bbWorkingDirectory, contractDataSource, merkleTrees, skipContractDeployments);
}

Expand Down
8 changes: 2 additions & 6 deletions yarn-project/simulator/src/avm/avm_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import { AztecAddress } from '@aztec/foundation/aztec-address';
import { keccak256, keccakf1600, pedersenCommit, pedersenHash, poseidon2Hash, sha256 } from '@aztec/foundation/crypto';
import { Fq, Fr, Point } from '@aztec/foundation/fields';
import { type Fieldable } from '@aztec/foundation/serialize';
import { openTmpStore } from '@aztec/kv-store/lmdb';
import { getTelemetryClient } from '@aztec/telemetry-client';
import { MerkleTrees } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state';

import { randomInt } from 'crypto';
import { mock } from 'jest-mock-extended';
Expand Down Expand Up @@ -1101,9 +1099,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
trace = mock<PublicSideEffectTraceInterface>();

worldStateDB = mock<WorldStateDB>();
const tmp = openTmpStore();
const telemetryClient = getTelemetryClient();
merkleTrees = await (await MerkleTrees.new(tmp, telemetryClient)).fork();
merkleTrees = await (await NativeWorldStateService.tmp()).fork();
(worldStateDB as jest.Mocked<WorldStateDB>).getMerkleInterface.mockReturnValue(merkleTrees);
ephemeralForest = await AvmEphemeralForest.create(worldStateDB.getMerkleInterface());

Expand Down
12 changes: 5 additions & 7 deletions yarn-project/simulator/src/avm/avm_tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import {
import { poseidon2Hash } from '@aztec/foundation/crypto';
import { Fr } from '@aztec/foundation/fields';
import { type IndexedTreeLeafPreimage } from '@aztec/foundation/trees';
import { openTmpStore } from '@aztec/kv-store/lmdb';
import { getTelemetryClient } from '@aztec/telemetry-client';
import { MerkleTrees, NativeWorldStateService } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state';

import {
AvmEphemeralForest,
Expand Down Expand Up @@ -531,8 +529,7 @@ describe('Checking forking and merging', () => {
*/
describe('AVM Ephemeral Tree Sanity Test', () => {
it('Should calculate the frontier correctly', async () => {
const store = openTmpStore(true);
const worldStateTrees = await MerkleTrees.new(store, getTelemetryClient());
const worldStateTrees = await NativeWorldStateService.tmp();
const leaves = [];
const numLeaves = 6;
for (let i = 0; i < numLeaves; i++) {
Expand All @@ -557,8 +554,9 @@ describe('AVM Ephemeral Tree Sanity Test', () => {
const expectedFrontier = [expectedFrontier0, exepctedFrontier1, expectedFrontier2];
expect(tree.frontier).toEqual(expectedFrontier);
// Check root
await worldStateTrees.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, leaves);
const treeInfo = await worldStateTrees.getTreeInfo(MerkleTreeId.NOTE_HASH_TREE, true);
const fork = await worldStateTrees.fork();
await fork.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, leaves);
const treeInfo = await fork.getTreeInfo(MerkleTreeId.NOTE_HASH_TREE);
const localRoot = await tree.getRoot();
expect(localRoot.toBuffer()).toEqual(treeInfo.root);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { GasFees, GlobalVariables } from '@aztec/circuits.js';
import { encodeArguments } from '@aztec/foundation/abi';
import { type AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';
import { openTmpStore } from '@aztec/kv-store/lmdb';
import { MerkleTrees } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state';

import { type AvmContractCallResult } from '../../avm/avm_contract_call_result.js';
import {
Expand Down Expand Up @@ -40,7 +39,7 @@ export class AvmSimulationTester extends BaseAvmSimulationTester {

static async create(skipContractDeployments = false): Promise<AvmSimulationTester> {
const contractDataSource = new SimpleContractDataSource();
const merkleTrees = await (await MerkleTrees.new(openTmpStore())).fork();
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
const trace = new SideEffectTrace();
const firstNullifier = new Fr(420000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { type ContractArtifact, encodeArguments } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { padArrayEnd } from '@aztec/foundation/collection';
import { Fr } from '@aztec/foundation/fields';
import { openTmpStore } from '@aztec/kv-store/lmdb';
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js/AvmTest';
import { MerkleTrees } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state';

import { BaseAvmSimulationTester } from '../../avm/fixtures/base_avm_simulation_tester.js';
import { getContractFunctionArtifact, getFunctionSelector } from '../../avm/fixtures/index.js';
Expand Down Expand Up @@ -46,7 +45,7 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {

public static async create(skipContractDeployments = false): Promise<PublicTxSimulationTester> {
const contractDataSource = new SimpleContractDataSource();
const merkleTrees = await (await MerkleTrees.new(openTmpStore())).fork();
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
return new PublicTxSimulationTester(contractDataSource, merkleTrees, skipContractDeployments);
}

Expand Down
5 changes: 2 additions & 3 deletions yarn-project/simulator/src/public/public_tx_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { type AztecKVStore } from '@aztec/kv-store';
import { openTmpStore } from '@aztec/kv-store/lmdb';
import { type AppendOnlyTree, Poseidon, StandardTree, newTree } from '@aztec/merkle-tree';
import { ProtocolContractAddress, REGISTERER_CONTRACT_CLASS_REGISTERED_TAG } from '@aztec/protocol-contracts';
import { MerkleTrees } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state';

import { jest } from '@jest/globals';
import { mock } from 'jest-mock-extended';
Expand Down Expand Up @@ -283,8 +283,7 @@ describe('public_tx_simulator', () => {
};

beforeEach(async () => {
const tmp = openTmpStore();
db = await (await MerkleTrees.new(tmp)).fork();
db = await (await NativeWorldStateService.tmp()).fork();
worldStateDB = new WorldStateDB(db, mock<ContractDataSource>());

treeStore = openTmpStore();
Expand Down
1 change: 1 addition & 0 deletions yarn-project/world-state/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"exports": {
".": "./dest/index.js",
"./native": "./dest/native/index.js",
"./test": "./dest/test/index.js",
"./config": "./dest/synchronizer/config.js"
},
"typedocOptions": {
Expand Down
Loading
Loading