Skip to content

Commit 65a9f33

Browse files
dbanks12dbanks12
andauthored
fix: no exports of simulator should depend on jest-mock-extended (#13694)
Fixes #13655 Other components (tests in `bb-prover`, `prover-client`) use `SimpleContractDataSource` and `PublicTxSimulationTester`. These are NOT meant to depend on `jest-mock-extended`, but `SimpleContractDataSource` imported `avm/fixtures/index.ts` for `getFunctionSelector`. And that `index.ts` imported `jest-mock-extended`. Instead of having a bunch of utilities into `avm/fixtures/index.ts`, I moved them into `initializers.ts` (needs jest) and `utils.ts` (pure utils, doesn't need jest). And then `SimpleContractDataSource` imports `utils.ts` and has no dependency on `jest-mock-extended`. Other components that depend on `SimpleContractDataSource` or `PublicTxSimulationTester` now explicitly import them from `simulator/public/fixtures` since they're no longer in `simulator/server`. Removed dependency of `ivc-integration/src/witgen.ts` on `PublicTxSimulationTester` at the cost of small code-duplication. --------- Co-authored-by: dbanks12 <[email protected]>
1 parent d4d503a commit 65a9f33

File tree

12 files changed

+364
-355
lines changed

12 files changed

+364
-355
lines changed

yarn-project/bb-prover/src/avm_proving_tests/avm_proving_tester.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { PublicTxSimulationTester, type TestEnqueuedCall } from '@aztec/simulator/public/fixtures';
2-
import { SimpleContractDataSource } from '@aztec/simulator/server';
1+
import {
2+
PublicTxSimulationTester,
3+
SimpleContractDataSource,
4+
type TestEnqueuedCall,
5+
} from '@aztec/simulator/public/fixtures';
36
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
47
import { AztecAddress } from '@aztec/stdlib/aztec-address';
58
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';

yarn-project/ivc-integration/src/avm_integration.test.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BB_RESULT, verifyClientIvcProof, writeClientIVCProofToOutputDirectory } from '@aztec/bb-prover';
22
import { ROLLUP_HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, TUBE_PROOF_LENGTH } from '@aztec/constants';
3+
import { Fr } from '@aztec/foundation/fields';
34
import { createLogger } from '@aztec/foundation/log';
45
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js/AvmTest';
56
import { PublicTxSimulationTester } from '@aztec/simulator/public/fixtures';
@@ -20,7 +21,6 @@ import {
2021
mapAvmVerificationKeyToNoir,
2122
mapRecursiveProofToNoir,
2223
mapVerificationKeyToNoir,
23-
simulateAvmBulkTesting,
2424
witnessGenMockPublicBaseCircuit,
2525
} from './index.js';
2626
import { proveAvm, proveClientIVC, proveRollupHonk, proveTube } from './prove_native.js';
@@ -77,7 +77,23 @@ describe('AVM Integration', () => {
7777
// for it to use as "expected" values when testing contract instance retrieval.
7878
const expectContractInstance = avmTestContractInstance;
7979

80-
const simRes = await simulateAvmBulkTesting(simTester, expectContractInstance);
80+
const argsField = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
81+
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
82+
const args = [
83+
argsField,
84+
argsU8,
85+
/*getInstanceForAddress=*/ expectContractInstance.address.toField(),
86+
/*expectedDeployer=*/ expectContractInstance.deployer.toField(),
87+
/*expectedClassId=*/ expectContractInstance.currentContractClassId.toField(),
88+
/*expectedInitializationHash=*/ expectContractInstance.initializationHash.toField(),
89+
];
90+
91+
const simRes = await simTester.simulateTx(
92+
/*sender=*/ AztecAddress.fromNumber(42),
93+
/*setupCalls=*/ [],
94+
/*appCalls=*/ [{ address: expectContractInstance.address, fnName: 'bulk_testing', args }],
95+
/*teardownCall=*/ undefined,
96+
);
8197

8298
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
8399
const { vk, proof, publicInputs } = await proveAvm(avmCircuitInputs, bbWorkingDirectory, logger);

yarn-project/ivc-integration/src/rollup_ivc_integration.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { BB_RESULT, verifyClientIvcProof, writeClientIVCProofToOutputDirectory } from '@aztec/bb-prover';
22
import { ROLLUP_HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS, TUBE_PROOF_LENGTH } from '@aztec/constants';
3-
import type { Fr } from '@aztec/foundation/fields';
3+
import { Fr } from '@aztec/foundation/fields';
44
import { createLogger } from '@aztec/foundation/log';
55
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js/AvmTest';
6-
import { PublicTxSimulationTester } from '@aztec/simulator/server';
6+
import { PublicTxSimulationTester } from '@aztec/simulator/public/fixtures';
77
import type { AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
88
import { AztecAddress } from '@aztec/stdlib/aztec-address';
99
import type { ProofAndVerificationKey } from '@aztec/stdlib/interfaces/server';
@@ -23,7 +23,6 @@ import {
2323
mapAvmVerificationKeyToNoir,
2424
mapRecursiveProofToNoir,
2525
mapVerificationKeyToNoir,
26-
simulateAvmBulkTesting,
2726
witnessGenMockPublicBaseCircuit,
2827
witnessGenMockRollupBasePrivateCircuit,
2928
witnessGenMockRollupMergeCircuit,
@@ -77,7 +76,24 @@ describe('Rollup IVC Integration', () => {
7776
/*deployer=*/ AztecAddress.fromNumber(420),
7877
AvmTestContractArtifact,
7978
);
80-
const avmSimulationResult = await simulateAvmBulkTesting(simTester, avmTestContractInstance);
79+
const argsField = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
80+
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
81+
const args = [
82+
argsField,
83+
argsU8,
84+
/*getInstanceForAddress=*/ avmTestContractInstance.address.toField(),
85+
/*expectedDeployer=*/ avmTestContractInstance.deployer.toField(),
86+
/*expectedClassId=*/ avmTestContractInstance.currentContractClassId.toField(),
87+
/*expectedInitializationHash=*/ avmTestContractInstance.initializationHash.toField(),
88+
];
89+
90+
const avmSimulationResult = await simTester.simulateTx(
91+
/*sender=*/ AztecAddress.fromNumber(42),
92+
/*setupCalls=*/ [],
93+
/*appCalls=*/ [{ address: avmTestContractInstance.address, fnName: 'bulk_testing', args }],
94+
/*teardownCall=*/ undefined,
95+
);
96+
8197
const avmCircuitInputs = avmSimulationResult.avmProvingRequest.inputs;
8298

8399
({

yarn-project/ivc-integration/src/witgen.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import {
66
} from '@aztec/constants';
77
import { Fr } from '@aztec/foundation/fields';
88
import { type ForeignCallOutput, Noir } from '@aztec/noir-noir_js';
9-
import type { PublicTxSimulationTester } from '@aztec/simulator/server';
109
import type { AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
11-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
12-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
1310
import type { RecursiveProof } from '@aztec/stdlib/proofs';
1411
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
1512

@@ -348,26 +345,3 @@ export function mapAvmPublicInputsToNoir(
348345
}
349346
return serialized.map(x => x.toString()) as FixedLengthArray<string, typeof AVM_V2_PUBLIC_INPUTS_FLATTENED_SIZE>;
350347
}
351-
352-
export async function simulateAvmBulkTesting(
353-
simTester: PublicTxSimulationTester,
354-
contractInstance: ContractInstanceWithAddress,
355-
) {
356-
const argsField = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
357-
const argsU8 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(x => new Fr(x));
358-
const args = [
359-
argsField,
360-
argsU8,
361-
/*getInstanceForAddress=*/ contractInstance.address.toField(),
362-
/*expectedDeployer=*/ contractInstance.deployer.toField(),
363-
/*expectedClassId=*/ contractInstance.currentContractClassId.toField(),
364-
/*expectedInitializationHash=*/ contractInstance.initializationHash.toField(),
365-
];
366-
367-
return await simTester.simulateTx(
368-
/*sender=*/ AztecAddress.fromNumber(42),
369-
/*setupCalls=*/ [],
370-
/*appCalls=*/ [{ address: contractInstance.address, fnName: 'bulk_testing', args }],
371-
/*teardownCall=*/ undefined,
372-
);
373-
}

yarn-project/prover-client/src/mocks/test_context.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ import { TestDateProvider } from '@aztec/foundation/timer';
66
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
77
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
88
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
9-
import {
10-
PublicProcessor,
11-
PublicProcessorFactory,
12-
PublicTxSimulationTester,
13-
SimpleContractDataSource,
14-
} from '@aztec/simulator/server';
9+
import { PublicTxSimulationTester, SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
10+
import { PublicProcessor, PublicProcessorFactory } from '@aztec/simulator/server';
1511
import { PublicDataWrite } from '@aztec/stdlib/avm';
1612
import { AztecAddress } from '@aztec/stdlib/aztec-address';
1713
import type { L2Block } from '@aztec/stdlib/block';

0 commit comments

Comments
 (0)