Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use native acvm when available on orchestrator tests #11560

Merged
merged 1 commit into from
Feb 18, 2025
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
6 changes: 3 additions & 3 deletions yarn-project/prover-client/src/mocks/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ export const getEnvironmentConfig = async (logger: Logger) => {
const tempWorkingDirectory = `${TEMP_DIR}/${randomBytes(4).toString('hex')}`;
const bbWorkingDirectory = BB_WORKING_DIRECTORY ? BB_WORKING_DIRECTORY : `${tempWorkingDirectory}/bb`;
await fs.mkdir(bbWorkingDirectory, { recursive: true });
logger.verbose(`Using native BB binary at ${expectedBBPath} with working directory ${bbWorkingDirectory}`);
logger.info(`Found native BB binary at ${expectedBBPath} with working directory ${bbWorkingDirectory}`);

const expectedAcvmPath = ACVM_BINARY_PATH
? ACVM_BINARY_PATH
: `${path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../noir/', NOIR_RELEASE_DIR)}/acvm`;
await fs.access(expectedAcvmPath, fs.constants.R_OK);
const acvmWorkingDirectory = ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : `${tempWorkingDirectory}/acvm`;
await fs.mkdir(acvmWorkingDirectory, { recursive: true });
logger.verbose(`Using native ACVM binary at ${expectedAcvmPath} with working directory ${acvmWorkingDirectory}`);
logger.info(`Found native ACVM binary at ${expectedAcvmPath} with working directory ${acvmWorkingDirectory}`);

const bbSkipCleanup = ['1', 'true'].includes(BB_SKIP_CLEANUP);
bbSkipCleanup && logger.verbose(`Not going to clean up BB working directory ${bbWorkingDirectory} after run`);
Expand All @@ -61,7 +61,7 @@ export const getEnvironmentConfig = async (logger: Logger) => {
bbSkipCleanup,
};
} catch (err) {
logger.verbose(`Native BB not available, error: ${err}`);
logger.info(`Native BB not available: ${err}`);
return undefined;
}
};
Expand Down
20 changes: 4 additions & 16 deletions yarn-project/prover-client/src/mocks/test_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ import { TestDateProvider } from '@aztec/foundation/timer';
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice';
import {
PublicProcessor,
PublicTxSimulator,
type SimulationProvider,
WASMSimulatorWithBlobs,
type WorldStateDB,
} from '@aztec/simulator/server';
import { PublicProcessor, PublicTxSimulator, type WorldStateDB } from '@aztec/simulator/server';
import { type MerkleTreeAdminDatabase } from '@aztec/world-state';
import { NativeWorldStateService } from '@aztec/world-state/native';

Expand All @@ -55,7 +49,6 @@ export class TestContext {
public publicTxSimulator: PublicTxSimulator,
public worldState: MerkleTreeAdminDatabase,
public publicProcessor: PublicProcessor,
public simulationProvider: SimulationProvider,
public globalVariables: GlobalVariables,
public prover: ServerCircuitProver,
public broker: TestBroker,
Expand All @@ -77,8 +70,8 @@ export class TestContext {
static async new(
logger: Logger,
proverCount = 4,
createProver: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver> = _ =>
Promise.resolve(new TestCircuitProver(new WASMSimulatorWithBlobs())),
createProver: (bbConfig: BBProverConfig) => Promise<ServerCircuitProver> = async (bbConfig: BBProverConfig) =>
new TestCircuitProver(await getSimulationProvider(bbConfig, logger)),
blockNumber = 1,
) {
const directoriesToCleanup: string[] = [];
Expand Down Expand Up @@ -112,12 +105,8 @@ export class TestContext {

let localProver: ServerCircuitProver;
const config = await getEnvironmentConfig(logger);
const simulationProvider = await getSimulationProvider({
acvmWorkingDirectory: config?.acvmWorkingDirectory,
acvmBinaryPath: config?.expectedAcvmPath,
});
if (!config) {
localProver = new TestCircuitProver(simulationProvider);
localProver = new TestCircuitProver();
} else {
const bbConfig: BBProverConfig = {
acvmBinaryPath: config.expectedAcvmPath,
Expand All @@ -144,7 +133,6 @@ export class TestContext {
publicTxSimulator,
ws,
processor,
simulationProvider,
globalVariables,
localProver,
broker,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { TestCircuitProver } from '@aztec/bb-prover';
import { type ServerCircuitProver } from '@aztec/circuit-types';
import { timesAsync } from '@aztec/foundation/collection';
import { createLogger } from '@aztec/foundation/log';
import { WASMSimulatorWithBlobs } from '@aztec/simulator/server';

import { jest } from '@jest/globals';

import { TestContext } from '../mocks/test_context.js';
import { ProvingOrchestrator } from './orchestrator.js';
import { type ProvingOrchestrator } from './orchestrator.js';

const logger = createLogger('prover-client:test:orchestrator-failures');
const LONG_TIMEOUT = 600_000;

describe('prover/orchestrator/failures', () => {
let context: TestContext;
let orchestrator: ProvingOrchestrator;
let prover: ServerCircuitProver;

beforeEach(async () => {
context = await TestContext.new(logger);
Expand All @@ -25,11 +24,8 @@ describe('prover/orchestrator/failures', () => {
});

describe('error handling', () => {
let mockProver: ServerCircuitProver;

beforeEach(() => {
mockProver = new TestCircuitProver(new WASMSimulatorWithBlobs());
orchestrator = new ProvingOrchestrator(context.worldState, mockProver);
({ prover, orchestrator } = context);
});

const run = async (message: string) => {
Expand Down Expand Up @@ -80,24 +76,24 @@ describe('prover/orchestrator/failures', () => {
it.each([
[
'Private Base Rollup Failed',
(msg: string) => jest.spyOn(mockProver, 'getPrivateBaseRollupProof').mockRejectedValue(msg),
(msg: string) => jest.spyOn(prover, 'getPrivateBaseRollupProof').mockRejectedValue(msg),
],
[
'Public Base Rollup Failed',
(msg: string) => jest.spyOn(mockProver, 'getPublicBaseRollupProof').mockRejectedValue(msg),
(msg: string) => jest.spyOn(prover, 'getPublicBaseRollupProof').mockRejectedValue(msg),
],
['Merge Rollup Failed', (msg: string) => jest.spyOn(mockProver, 'getMergeRollupProof').mockRejectedValue(msg)],
['Merge Rollup Failed', (msg: string) => jest.spyOn(prover, 'getMergeRollupProof').mockRejectedValue(msg)],
[
'Block Root Rollup Failed',
(msg: string) => jest.spyOn(mockProver, 'getBlockRootRollupProof').mockRejectedValue(msg),
(msg: string) => jest.spyOn(prover, 'getBlockRootRollupProof').mockRejectedValue(msg),
],
[
'Block Merge Rollup Failed',
(msg: string) => jest.spyOn(mockProver, 'getBlockMergeRollupProof').mockRejectedValue(msg),
(msg: string) => jest.spyOn(prover, 'getBlockMergeRollupProof').mockRejectedValue(msg),
],
['Root Rollup Failed', (msg: string) => jest.spyOn(mockProver, 'getRootRollupProof').mockRejectedValue(msg)],
['Base Parity Failed', (msg: string) => jest.spyOn(mockProver, 'getBaseParityProof').mockRejectedValue(msg)],
['Root Parity Failed', (msg: string) => jest.spyOn(mockProver, 'getRootParityProof').mockRejectedValue(msg)],
['Root Rollup Failed', (msg: string) => jest.spyOn(prover, 'getRootRollupProof').mockRejectedValue(msg)],
['Base Parity Failed', (msg: string) => jest.spyOn(prover, 'getBaseParityProof').mockRejectedValue(msg)],
['Root Parity Failed', (msg: string) => jest.spyOn(prover, 'getRootParityProof').mockRejectedValue(msg)],
] as const)(
'handles a %s error',
async (message: string, makeFailedProof: (msg: string) => void) => {
Expand Down