From 4a51862127ee82c32e3a727576ae971326981d06 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Mon, 12 Aug 2024 16:47:18 +0000 Subject: [PATCH] feat: enable UltraHonk verifier Fix #7373 --- yarn-project/bb-prover/src/bb/execute.ts | 2 +- .../src/e2e_prover/e2e_prover_test.ts | 109 +++++++++--------- 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/yarn-project/bb-prover/src/bb/execute.ts b/yarn-project/bb-prover/src/bb/execute.ts index 4021001da963..a26a31ba5df4 100644 --- a/yarn-project/bb-prover/src/bb/execute.ts +++ b/yarn-project/bb-prover/src/bb/execute.ts @@ -811,7 +811,7 @@ export async function generateContractForVerificationKey( try { const args = ['-k', vkFilePath, '-o', contractPath, '-v']; const timer = new Timer(); - const result = await executeBB(pathToBB, 'contract', args, log); + const result = await executeBB(pathToBB, 'contract_ultra_honk', args, log); const duration = timer.ms(); if (result.status == BB_RESULT.SUCCESS) { return { status: BB_RESULT.SUCCESS, durationMs: duration, contractPath }; diff --git a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts index b98823ebe956..8dd6605f7645 100644 --- a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts @@ -11,18 +11,19 @@ import { type PXE, type TxHash, computeSecretHash, - createDebugLogger, // TODO(#7373): Deploy honk solidity verifier - // deployL1Contract, + createDebugLogger, + deployL1Contract, } from '@aztec/aztec.js'; import { BBCircuitVerifier } from '@aztec/bb-prover'; -// import { RollupAbi } from '@aztec/l1-artifacts'; +import { RollupAbi } from '@aztec/l1-artifacts'; import { TokenContract } from '@aztec/noir-contracts.js'; import { type PXEService } from '@aztec/pxe'; // TODO(#7373): Deploy honk solidity verifier -// // @ts-expect-error solc-js doesn't publish its types https://github.com/ethereum/solc-js/issues/689 -// import solc from 'solc'; -// import { getContract } from 'viem'; +// @ts-expect-error solc-js doesn't publish its types https://github.com/ethereum/solc-js/issues/689 +import solc from 'solc'; +import { getContract } from 'viem'; + import { waitRegisteredAccountSynced } from '../benchmarks/utils.js'; import { getACVMConfig } from '../fixtures/get_acvm_config.js'; import { getBBConfig } from '../fixtures/get_bb_config.js'; @@ -287,58 +288,56 @@ export class FullProverTest { ); } - deployVerifier() { + async deployVerifier() { if (!this.circuitProofVerifier) { throw new Error('No verifier'); } - // TODO(#7373): Deploy honk solidity verifier - return Promise.resolve(); - // const { walletClient, publicClient, l1ContractAddresses } = this.context.deployL1ContractsValues; - - // const contract = await this.circuitProofVerifier.generateSolidityContract( - // 'RootRollupArtifact', - // 'UltraVerifier.sol', - // ); - - // const input = { - // language: 'Solidity', - // sources: { - // 'UltraVerifier.sol': { - // content: contract, - // }, - // }, - // settings: { - // // we require the optimizer - // optimizer: { - // enabled: true, - // runs: 200, - // }, - // evmVersion: 'paris', - // outputSelection: { - // '*': { - // '*': ['evm.bytecode.object', 'abi'], - // }, - // }, - // }, - // }; - - // const output = JSON.parse(solc.compile(JSON.stringify(input))); - - // const abi = output.contracts['UltraVerifier.sol']['UltraVerifier'].abi; - // const bytecode: string = output.contracts['UltraVerifier.sol']['UltraVerifier'].evm.bytecode.object; - - // const verifierAddress = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`); - - // this.logger.info(`Deployed Real verifier at ${verifierAddress}`); - - // const rollup = getContract({ - // abi: RollupAbi, - // address: l1ContractAddresses.rollupAddress.toString(), - // client: walletClient, - // }); - - // await rollup.write.setVerifier([verifierAddress.toString()]); - // this.logger.info('Rollup only accepts valid proofs now'); + const { walletClient, publicClient, l1ContractAddresses } = this.context.deployL1ContractsValues; + + const contract = await this.circuitProofVerifier.generateSolidityContract( + 'RootRollupArtifact', + 'UltraHonkVerifier.sol', + ); + + const input = { + language: 'Solidity', + sources: { + 'UltraHonkVerifier.sol': { + content: contract, + }, + }, + settings: { + // we require the optimizer + optimizer: { + enabled: true, + runs: 200, + }, + evmVersion: 'paris', + outputSelection: { + '*': { + '*': ['evm.bytecode.object', 'abi'], + }, + }, + }, + }; + + const output = JSON.parse(solc.compile(JSON.stringify(input))); + + const abi = output.contracts['UltraVerifier.sol']['UltraVerifier'].abi; + const bytecode: string = output.contracts['UltraVerifier.sol']['UltraVerifier'].evm.bytecode.object; + + const verifierAddress = await deployL1Contract(walletClient, publicClient, abi, `0x${bytecode}`); + + this.logger.info(`Deployed Real verifier at ${verifierAddress}`); + + const rollup = getContract({ + abi: RollupAbi, + address: l1ContractAddresses.rollupAddress.toString(), + client: walletClient, + }); + + await rollup.write.setVerifier([verifierAddress.toString()]); + this.logger.info('Rollup only accepts valid proofs now'); } }