Skip to content

Commit

Permalink
chore: Use random tmp directory and cleanup afterwards (#5368)
Browse files Browse the repository at this point in the history
End to end tests fail to run due to conflicts on `/tmp/acvm/`. This PR
introduces a random directory to use instead and cleans it up after the
test finishes.
  • Loading branch information
PhilWindle authored Mar 21, 2024
1 parent 59ca2ac commit 5c0e15d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions yarn-project/end-to-end/src/fixtures/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
waitForPXE,
} from '@aztec/aztec.js';
import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
import { randomBytes } from '@aztec/foundation/crypto';
import {
AvailabilityOracleAbi,
AvailabilityOracleBytecode,
Expand Down Expand Up @@ -88,10 +89,15 @@ const getACVMConfig = async (logger: DebugLogger) => {
? 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 : `${TEMP_DIR}/acvm`;
const tempWorkingDirectory = `${TEMP_DIR}/${randomBytes(4).toString('hex')}`;
const acvmWorkingDirectory = ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : `${tempWorkingDirectory}/acvm`;
await fs.mkdir(acvmWorkingDirectory, { recursive: true });
logger(`Using native ACVM binary at ${expectedAcvmPath} with working directory ${acvmWorkingDirectory}`);
return { acvmWorkingDirectory, expectedAcvmPath };
return {
acvmWorkingDirectory,
expectedAcvmPath,
directoryToCleanup: ACVM_WORKING_DIRECTORY ? undefined : tempWorkingDirectory,
};
} catch (err) {
logger(`Native ACVM not available, error: ${err}`);
return undefined;
Expand Down Expand Up @@ -378,6 +384,12 @@ export async function setup(
if (pxe instanceof PXEService) {
await pxe?.stop();
}

if (acvmConfig?.directoryToCleanup) {
// remove the temp directory created for the acvm
logger(`Cleaning up ACVM temp directory ${acvmConfig.directoryToCleanup}`);
await fs.rm(acvmConfig.directoryToCleanup, { recursive: true, force: true });
}
};

return {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/sequencer-client/src/simulator/acvm_native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function parseIntoWitnessMap(outputString: string) {
/**
*
* @param inputWitness - The circuit's input witness
* @param bytecode - The circuit buytecode
* @param bytecode - The circuit bytecode
* @param workingDirectory - A directory to use for temporary files by the ACVM
* @param pathToAcvm - The path to the ACVm binary
* @returns The completed partial witness outputted from the circuit
Expand Down

0 comments on commit 5c0e15d

Please sign in to comment.