-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
231 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
yarn-project/end-to-end/src/benchmarks/bench_proving.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { getSchnorrAccount } from '@aztec/accounts/schnorr'; | ||
import { BatchCall, EthAddress, Fq, Fr, TxStatus, type Wallet } from '@aztec/aztec.js'; | ||
import { TestContract } from '@aztec/noir-contracts.js'; | ||
|
||
import { jest } from '@jest/globals'; | ||
|
||
import { getACVMConfig } from '../fixtures/get_acvm_config.js'; | ||
import { getBBConfig } from '../fixtures/get_bb_config.js'; | ||
import { type EndToEndContext, setupNoL2Deploy } from '../fixtures/utils.js'; | ||
|
||
jest.setTimeout(1_000_000); | ||
|
||
// seconds! | ||
const txTimeoutSec = 200; | ||
|
||
describe('benchmarks/proving', () => { | ||
let ctx: Omit<EndToEndContext, 'wallet'>; | ||
let wallet: Wallet; | ||
let testContract: TestContract; | ||
let acvmCleanup: () => Promise<void>; | ||
let bbCleanup: () => Promise<void>; | ||
|
||
// setup the environment | ||
beforeAll(async () => { | ||
const [acvmConfig, bbConfig] = await Promise.all([getACVMConfig(ctx.logger), getBBConfig(ctx.logger)]); | ||
if (!acvmConfig || !bbConfig) { | ||
throw new Error('Missing ACVM or BB config'); | ||
} | ||
|
||
ctx = await setupNoL2Deploy({ | ||
acvmBinaryPath: acvmConfig.acvmBinaryPath, | ||
acvmWorkingDirectory: acvmConfig.acvmWorkingDirectory, | ||
bbBinaryPath: bbConfig.bbBinaryPath, | ||
bbWorkingDirectory: bbConfig.bbWorkingDirectory, | ||
proverAgents: 4, | ||
proverAgentPollInterval: 10, | ||
}); | ||
|
||
acvmCleanup = acvmConfig.cleanup; | ||
bbCleanup = bbConfig.cleanup; | ||
|
||
wallet = await getSchnorrAccount(ctx.pxe, Fr.random(), Fq.random()).deploy().getWallet({ | ||
timeout: txTimeoutSec, | ||
}); | ||
testContract = await TestContract.deploy(wallet).send().deployed({ | ||
timeout: txTimeoutSec, | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
await ctx.teardown(); | ||
|
||
await acvmCleanup(); | ||
await bbCleanup(); | ||
}); | ||
|
||
it('executes a batch call', async () => { | ||
const call = new BatchCall(wallet, [ | ||
testContract.methods.emit_nullifier(42).request(), | ||
testContract.methods.call_create_note(43, wallet.getAddress(), 44).request(), | ||
testContract.methods.create_l2_to_l1_message_public(45, 46, EthAddress.random()).request(), | ||
testContract.methods.emit_unencrypted(47).request(), | ||
]); | ||
|
||
const receipt = await call.send().wait({ | ||
timeout: txTimeoutSec, | ||
}); | ||
expect(receipt.status).toBe(TxStatus.MINED); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { type DebugLogger, fileURLToPath } from '@aztec/aztec.js'; | ||
|
||
import fs from 'node:fs/promises'; | ||
import { tmpdir } from 'node:os'; | ||
import path from 'path'; | ||
|
||
const { | ||
BB_RELEASE_DIR = 'barretenberg/cpp/build/bin', | ||
BB_BINARY_PATH, | ||
TEMP_DIR = tmpdir(), | ||
BB_WORKING_DIRECTORY = '', | ||
} = process.env; | ||
|
||
export const getBBConfig = async ( | ||
logger: DebugLogger, | ||
): Promise<{ bbBinaryPath: string; bbWorkingDirectory: string; cleanup: () => Promise<void> } | undefined> => { | ||
try { | ||
const bbBinaryPath = | ||
BB_BINARY_PATH ?? | ||
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb'); | ||
await fs.access(bbBinaryPath, fs.constants.R_OK); | ||
|
||
let bbWorkingDirectory: string; | ||
let directoryToCleanup: string | undefined; | ||
|
||
if (BB_WORKING_DIRECTORY) { | ||
bbWorkingDirectory = BB_WORKING_DIRECTORY; | ||
} else { | ||
bbWorkingDirectory = await fs.mkdtemp(path.join(TEMP_DIR, 'bb-')); | ||
directoryToCleanup = bbWorkingDirectory; | ||
} | ||
|
||
await fs.mkdir(bbWorkingDirectory, { recursive: true }); | ||
|
||
const cleanup = async () => { | ||
if (directoryToCleanup) { | ||
await fs.rm(directoryToCleanup, { recursive: true, force: true }); | ||
} | ||
}; | ||
|
||
return { bbBinaryPath, bbWorkingDirectory, cleanup }; | ||
} catch (err) { | ||
logger.error(`Native BB not available, error: ${err}`); | ||
return undefined; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.