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

feat: compile base rollup as a circuit #3739

Merged
merged 1 commit into from
Dec 19, 2023
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
1 change: 1 addition & 0 deletions yarn-project/noir-protocol-circuits/src/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ members = [
"crates/rollup-lib",
"crates/rollup-merge",
"crates/rollup-base",
"crates/rollup-base-simulated",
"crates/rollup-root",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "rollup_base_simulated"
type = "bin"
authors = [""]
compiler_version = ">=0.18.0"

[dependencies]
rollup_lib = { path = "../rollup-lib" }
types = { path = "../types" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use dep::rollup_lib::base::{BaseRollupInputs,BaseOrMergeRollupPublicInputs};

unconstrained fn main(inputs: BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
inputs.base_rollup_circuit()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dep::rollup_lib::base::{BaseRollupInputs,BaseOrMergeRollupPublicInputs};

//TODO add a circuit variant
unconstrained fn main(inputs : BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
fn main(inputs: BaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
inputs.base_rollup_circuit()
}
}
8 changes: 4 additions & 4 deletions yarn-project/noir-protocol-circuits/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import PublicKernelPrivatePreviousJson from './target/public_kernel_private_prev
import PublicKernelPrivatePreviousSimulatedJson from './target/public_kernel_private_previous_simulated.json' assert { type: 'json' };
import PublicKernelPublicPreviousJson from './target/public_kernel_public_previous.json' assert { type: 'json' };
import PublicKernelPublicPreviousSimulatedJson from './target/public_kernel_public_previous_simulated.json' assert { type: 'json' };
import BaseRollupJson from './target/rollup_base.json' assert { type: 'json' };
import BaseRollupSimulatedJson from './target/rollup_base_simulated.json' assert { type: 'json' };
import MergeRollupJson from './target/rollup_merge.json' assert { type: 'json' };
import RootRollupJson from './target/rollup_root.json' assert { type: 'json' };
import {
Expand Down Expand Up @@ -416,12 +416,12 @@ async function executeMergeRollupWithACVM(input: MergeRollupInputType): Promise<
* Executes the base rollup with the given inputs using the acvm.
*/
async function executeBaseRollupWithACVM(input: BaseRollupInputType): Promise<BaseRollupReturnType> {
const initialWitnessMap = abiEncode(BaseRollupJson.abi as Abi, input as any);
const initialWitnessMap = abiEncode(BaseRollupSimulatedJson.abi as Abi, input as any);

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

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

// Cast the inputs as the return type
return decodedInputs.return_value as BaseRollupReturnType;
Expand Down