Skip to content

Commit 5118d44

Browse files
authored
feat: compile base rollup as a circuit (AztecProtocol#3739)
This PR adds a variant of the base rollup that is a circuit. This makes sure that PRs don't break compilation as a circuit of the base rollup and tracks its constraint count. After the last noir pull, thanks to @TomAFrench compilation is now much faster, allowing to compile the base rollup as a circuit in a reasonable time (prev. it took 5 minutes, now some seconds)
1 parent 143271c commit 5118d44

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

yarn-project/noir-protocol-circuits/src/Nargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ members = [
1616
"crates/rollup-lib",
1717
"crates/rollup-merge",
1818
"crates/rollup-base",
19+
"crates/rollup-base-simulated",
1920
"crates/rollup-root",
2021
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "rollup_base_simulated"
3+
type = "bin"
4+
authors = [""]
5+
compiler_version = ">=0.18.0"
6+
7+
[dependencies]
8+
rollup_lib = { path = "../rollup-lib" }
9+
types = { path = "../types" }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use dep::rollup_lib::base::{BaseRollupInputs,BaseOrMergeRollupPublicInputs};
2+
3+
unconstrained fn main(inputs: BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
4+
inputs.base_rollup_circuit()
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use dep::rollup_lib::base::{BaseRollupInputs,BaseOrMergeRollupPublicInputs};
22

3-
//TODO add a circuit variant
4-
unconstrained fn main(inputs : BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
3+
fn main(inputs: BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
54
inputs.base_rollup_circuit()
6-
}
5+
}

yarn-project/noir-protocol-circuits/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import PublicKernelPrivatePreviousJson from './target/public_kernel_private_prev
2626
import PublicKernelPrivatePreviousSimulatedJson from './target/public_kernel_private_previous_simulated.json' assert { type: 'json' };
2727
import PublicKernelPublicPreviousJson from './target/public_kernel_public_previous.json' assert { type: 'json' };
2828
import PublicKernelPublicPreviousSimulatedJson from './target/public_kernel_public_previous_simulated.json' assert { type: 'json' };
29-
import BaseRollupJson from './target/rollup_base.json' assert { type: 'json' };
29+
import BaseRollupSimulatedJson from './target/rollup_base_simulated.json' assert { type: 'json' };
3030
import MergeRollupJson from './target/rollup_merge.json' assert { type: 'json' };
3131
import RootRollupJson from './target/rollup_root.json' assert { type: 'json' };
3232
import {
@@ -416,12 +416,12 @@ async function executeMergeRollupWithACVM(input: MergeRollupInputType): Promise<
416416
* Executes the base rollup with the given inputs using the acvm.
417417
*/
418418
async function executeBaseRollupWithACVM(input: BaseRollupInputType): Promise<BaseRollupReturnType> {
419-
const initialWitnessMap = abiEncode(BaseRollupJson.abi as Abi, input as any);
419+
const initialWitnessMap = abiEncode(BaseRollupSimulatedJson.abi as Abi, input as any);
420420

421421
// Execute the circuit on those initial witness values
422422
//
423423
// Decode the bytecode from base64 since the acvm does not know about base64 encoding
424-
const decodedBytecode = Buffer.from(BaseRollupJson.bytecode, 'base64');
424+
const decodedBytecode = Buffer.from(BaseRollupSimulatedJson.bytecode, 'base64');
425425
//
426426
// Execute the circuit
427427
const _witnessMap = await executeCircuitWithBlackBoxSolver(
@@ -434,7 +434,7 @@ async function executeBaseRollupWithACVM(input: BaseRollupInputType): Promise<Ba
434434
);
435435

436436
// Decode the witness map into two fields, the return values and the inputs
437-
const decodedInputs: DecodedInputs = abiDecode(BaseRollupJson.abi as Abi, _witnessMap);
437+
const decodedInputs: DecodedInputs = abiDecode(BaseRollupSimulatedJson.abi as Abi, _witnessMap);
438438

439439
// Cast the inputs as the return type
440440
return decodedInputs.return_value as BaseRollupReturnType;

0 commit comments

Comments
 (0)