Skip to content

Commit

Permalink
chore!: split base rollup and remove public kernel proving (#9434)
Browse files Browse the repository at this point in the history
- Remove base rollup and create two rollups:
  - Private base rollup: takes the tube data from private kernel tail.
- Public base rollup: takes the tube data from private kernel
tail-to-public and the avm proof data.
- Stop proving public kernel inner, public kernel merge and public
kernel tail.
- Orchestrator will create a tube proof, an avm proof (if the tx
contains public functions), and then create either a private or public
base rollup.
- The simulated version of the public kernels are used for simulation.
- These public kernels can be completely removed after the logic is
moved into the avm simulator.
  • Loading branch information
LeilaWang authored Oct 28, 2024
1 parent d33c988 commit 4316242
Show file tree
Hide file tree
Showing 116 changed files with 1,826 additions and 2,420 deletions.
18 changes: 8 additions & 10 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ library Constants {
uint256 internal constant PRIVATE_KERNEL_INNER_INDEX = 3;
uint256 internal constant PRIVATE_KERNEL_TAIL_INDEX = 4;
uint256 internal constant PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX = 5;
uint256 internal constant PUBLIC_KERNEL_MERGE_INDEX = 6;
uint256 internal constant PUBLIC_KERNEL_TAIL_INDEX = 7;
uint256 internal constant PUBLIC_KERNEL_INNER_INDEX = 8;
uint256 internal constant TUBE_VK_INDEX = 6;
uint256 internal constant PRIVATE_BASE_ROLLUP_VK_INDEX = 8;
uint256 internal constant PUBLIC_BASE_ROLLUP_VK_INDEX = 9;
uint256 internal constant BASE_PARITY_INDEX = 10;
uint256 internal constant ROOT_PARITY_INDEX = 11;
uint256 internal constant BASE_ROLLUP_INDEX = 12;
uint256 internal constant MERGE_ROLLUP_INDEX = 13;
uint256 internal constant BLOCK_ROOT_ROLLUP_INDEX = 14;
uint256 internal constant BLOCK_MERGE_ROLLUP_INDEX = 15;
uint256 internal constant ROOT_ROLLUP_INDEX = 16;
uint256 internal constant BLOCK_ROOT_ROLLUP_EMPTY_INDEX = 17;
uint256 internal constant TUBE_INDEX = 18;
uint256 internal constant MERGE_ROLLUP_INDEX = 12;
uint256 internal constant BLOCK_ROOT_ROLLUP_INDEX = 13;
uint256 internal constant BLOCK_MERGE_ROLLUP_INDEX = 14;
uint256 internal constant ROOT_ROLLUP_INDEX = 15;
uint256 internal constant BLOCK_ROOT_ROLLUP_EMPTY_INDEX = 16;
uint256 internal constant PRIVATE_KERNEL_RESET_INDEX = 20;
uint256 internal constant FUNCTION_SELECTOR_NUM_BYTES = 4;
uint256 internal constant INITIALIZATION_SLOT_SEPARATOR = 1000000000;
Expand Down
9 changes: 4 additions & 5 deletions noir-projects/noir-protocol-circuits/Nargo.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ members = [
"crates/empty-nested",
"crates/empty-nested-simulated",
"crates/public-kernel-lib",
"crates/public-kernel-inner",
"crates/public-kernel-inner-simulated",
"crates/public-kernel-merge",
"crates/public-kernel-merge-simulated",
"crates/public-kernel-tail",
"crates/public-kernel-tail-simulated",
"crates/reset-kernel-lib",
"crates/rollup-lib",
"crates/rollup-merge",
"crates/rollup-base",
"crates/rollup-base-simulated",
"crates/rollup-base-private",
"crates/rollup-base-private-simulated",
"crates/rollup-base-public",
"crates/rollup-base-public-simulated",
"crates/rollup-block-merge",
"crates/rollup-block-root",
"crates/rollup-block-root-empty",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::parity_public_inputs::ParityPublicInputs;
use dep::types::{
constants::{BASE_PARITY_INDEX, VK_TREE_HEIGHT},
merkle_tree::membership::assert_check_membership,
recursion::{
proof::RecursiveProof,
proof::{
recursive_proof::RecursiveProof,
traits::Verifiable,
verification_key::{HonkVerificationKey, VerificationKey},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod tests {
root::{root_parity_input::RootParityInput, root_parity_inputs::RootParityInputs},
};
use dep::types::constants::BASE_PARITY_INDEX;
use dep::types::recursion::{proof::RecursiveProof, verification_key::VerificationKey};
use dep::types::proof::{recursive_proof::RecursiveProof, verification_key::VerificationKey};
use dep::types::tests::fixtures;

use super::NUM_BASE_PARITY_PER_ROOT_PARITY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::parity_public_inputs::ParityPublicInputs;
use dep::types::{
constants::{ROOT_PARITY_INDEX, VK_TREE_HEIGHT},
merkle_tree::membership::assert_check_membership,
recursion::{
proof::NestedRecursiveProof,
proof::{
recursive_proof::NestedRecursiveProof,
traits::Verifiable,
verification_key::{HonkVerificationKey, VerificationKey},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use dep::types::{
header::Header,
KernelCircuitPublicInputs,
recursion::{
proof::RecursiveProof,
proof::{
recursive_proof::RecursiveProof,
traits::Verifiable,
verification_key::{HonkVerificationKey, VerificationKey},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod tests {
};
use dep::types::{
abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs,
constants::{BASE_ROLLUP_INDEX, PRIVATE_KERNEL_INIT_INDEX},
constants::{EMPTY_NESTED_INDEX, PRIVATE_KERNEL_INIT_INDEX},
tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq},
};

Expand Down Expand Up @@ -170,7 +170,7 @@ mod tests {
#[test(should_fail_with = "Invalid vk index")]
fn invalid_previous_kernel() {
let mut builder = PrivateKernelInnerInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX);
builder.previous_kernel = builder.previous_kernel.in_vk_tree(EMPTY_NESTED_INDEX);
let _res = builder.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ mod tests {
utils::arrays::find_index_hint,
};
use dep::types::constants::{
BASE_ROLLUP_INDEX, GENERATOR_INDEX__OVSK_M, MAX_KEY_VALIDATION_REQUESTS_PER_TX,
EMPTY_NESTED_INDEX, GENERATOR_INDEX__OVSK_M, MAX_KEY_VALIDATION_REQUESTS_PER_TX,
MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, PRIVATE_KERNEL_INNER_INDEX,
};

Expand Down Expand Up @@ -672,7 +672,7 @@ mod tests {
#[test(should_fail_with = "Invalid vk index")]
fn invalid_previous_kernel() {
let mut builder = PrivateKernelResetInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX);
builder.previous_kernel = builder.previous_kernel.in_vk_tree(EMPTY_NESTED_INDEX);
let _res = builder.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod tests {
traits::is_empty,
};
use dep::types::constants::{
BASE_ROLLUP_INDEX, DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, GENERATOR_INDEX__IVSK_M,
DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, EMPTY_NESTED_INDEX, GENERATOR_INDEX__IVSK_M,
L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NULLIFIER, PRIVATE_KERNEL_INNER_INDEX,
};

Expand Down Expand Up @@ -333,7 +333,7 @@ mod tests {
#[test(should_fail_with = "Invalid vk index")]
fn invalid_previous_kernel() {
let mut builder = PrivateKernelTailInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX);
builder.previous_kernel = builder.previous_kernel.in_vk_tree(EMPTY_NESTED_INDEX);
let _res = builder.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ mod tests {
nullifier::{Nullifier, ScopedNullifier},
},
address::{AztecAddress, EthAddress},
constants::PRIVATE_KERNEL_INNER_INDEX,
point::Point,
tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq},
};
use dep::types::constants::{
DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, FIXED_AVM_STARTUP_L2_GAS, GENERATOR_INDEX__TSK_M,
L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER,
DA_BYTES_PER_FIELD, DA_GAS_PER_BYTE, EMPTY_NESTED_INDEX, FIXED_AVM_STARTUP_L2_GAS,
GENERATOR_INDEX__TSK_M, L2_GAS_PER_LOG_BYTE, L2_GAS_PER_NOTE_HASH, L2_GAS_PER_NULLIFIER,
PRIVATE_KERNEL_INNER_INDEX,
};

// TODO: Reduce the duplicated code/tests for PrivateKernelTailToPublicInputs and PrivateKernelTailInputs.
Expand Down Expand Up @@ -420,10 +420,11 @@ mod tests {
let _res = builder.execute();
}
}
// #[test(should_fail_with = "Invalid vk index")]
// fn invalid_previous_kernel() {
// let mut builder = PrivateKernelTailToPublicInputsBuilder::new();
// builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX);
// let _res = builder.execute();
// }

#[test(should_fail_with = "Invalid vk index")]
fn invalid_previous_kernel() {
let mut builder = PrivateKernelTailToPublicInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(EMPTY_NESTED_INDEX);
let _res = builder.execute();
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ use crate::{
},
public_kernel_phase::PublicKernelPhase,
};
use dep::types::{
abis::{
enqueued_call_data::EnqueuedCallData,
kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs,
public_kernel_data::PublicKernelData,
},
constants::{PUBLIC_KERNEL_MERGE_INDEX, TUBE_INDEX},
use dep::types::abis::{
enqueued_call_data::EnqueuedCallData,
kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs,
public_kernel_data::PublicKernelData,
};

global ALLOWED_PREVIOUS_CIRCUITS = [TUBE_INDEX, PUBLIC_KERNEL_MERGE_INDEX];
global ALLOWED_PREVIOUS_CIRCUITS = [];

pub struct PublicKernelMergeCircuitPrivateInputs {
previous_kernel: PublicKernelData,
Expand Down Expand Up @@ -61,12 +58,11 @@ impl PublicKernelMergeCircuitPrivateInputs {
phase,
);

let previous_kernel_validator = PreviousKernelValidator::new(self.previous_kernel);
previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS);

// let previous_kernel_validator = PreviousKernelValidator::new(self.previous_kernel);
// previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS);
let enqueued_call_data_validator =
EnqueuedCallDataValidator::new(self.enqueued_call, phase);
enqueued_call_data_validator.validate_proof();
// enqueued_call_data_validator.validate_proof();
enqueued_call_data_validator.validate_against_previous_kernel(
self.previous_kernel.public_inputs,
output_validator.previous_validation_request_array_lengths,
Expand All @@ -92,7 +88,6 @@ mod tests {
max_block_number::MaxBlockNumber,
validation_requests::PublicValidationRequestArrayLengths,
},
constants::{BASE_ROLLUP_INDEX, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX},
tests::{fixture_builder::FixtureBuilder, utils::assert_array_eq},
};

Expand All @@ -105,9 +100,7 @@ mod tests {

impl PublicKernelMergeCircuitPrivateInputsBuilder {
pub fn new() -> Self {
let previous_kernel = FixtureBuilder::new().as_parent_contract().in_vk_tree(
PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX,
);
let previous_kernel = FixtureBuilder::new().as_parent_contract();
let mut previous_revertible = FixtureBuilder::new();
let mut enqueued_call = FixtureBuilder::new().is_public_function();
// Add an offset so that the mock data won't be the same as the values in previous_kernel.
Expand Down Expand Up @@ -253,21 +246,4 @@ mod tests {
assert_eq(output.end_non_revertible.gas_used, Gas::new(200, 200));
assert_eq(output.end.gas_used, Gas::new(350, 350));
}

#[test]
fn valid_previous_kernel() {
for i in 0..ALLOWED_PREVIOUS_CIRCUITS.len() {
let mut builder = PublicKernelMergeCircuitPrivateInputsBuilder::new();
builder.previous_kernel =
builder.previous_kernel.in_vk_tree(ALLOWED_PREVIOUS_CIRCUITS[i]);
builder.succeeded();
}
}

#[test(should_fail_with = "Invalid vk index")]
fn invalid_previous_kernel() {
let mut builder = PublicKernelMergeCircuitPrivateInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX);
let _res = builder.execute();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ use dep::types::{
L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX,
MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX,
MAX_PUBLIC_DATA_HINTS, MAX_PUBLIC_DATA_READS_PER_TX, NOTE_HASH_TREE_HEIGHT,
PUBLIC_KERNEL_MERGE_INDEX,
},
data::PublicDataLeafHint,
partial_state_reference::PartialStateReference,
};

global ALLOWED_PREVIOUS_CIRCUITS = [PUBLIC_KERNEL_MERGE_INDEX];
global ALLOWED_PREVIOUS_CIRCUITS = [];

pub struct PublicKernelTailCircuitPrivateInputs {
previous_kernel: PublicKernelData,
Expand Down Expand Up @@ -65,8 +64,7 @@ impl PublicKernelTailCircuitPrivateInputs {
pub fn execute(self) -> KernelCircuitPublicInputs {
let previous_kernel_validator = PreviousKernelValidator::new(self.previous_kernel);
previous_kernel_validator.validate_phase(PublicKernelPhase.TAIL);
previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS);

// previous_kernel_validator.validate_proof(ALLOWED_PREVIOUS_CIRCUITS);
let (output, output_hints, public_data_read_request_hints) =
unsafe { self.generate_output_and_hints() };

Expand Down Expand Up @@ -114,14 +112,14 @@ mod tests {
},
address::AztecAddress,
constants::{
BASE_ROLLUP_INDEX, L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX,
L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX,
MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX,
MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_HINTS,
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT,
NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NOTE_HASH_TREE_HEIGHT, NULLIFIER_SUBTREE_HEIGHT,
NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT,
PUBLIC_DATA_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH,
PUBLIC_DATA_TREE_HEIGHT, PUBLIC_KERNEL_MERGE_INDEX,
PUBLIC_DATA_TREE_HEIGHT,
},
data::{PublicDataLeafHint, PublicDataTreeLeafPreimage},
hash::{compute_siloed_nullifier, silo_note_hash},
Expand Down Expand Up @@ -191,7 +189,7 @@ mod tests {

impl PublicKernelTailCircuitPrivateInputsBuilder {
pub fn new() -> PublicKernelTailCircuitPrivateInputsBuilder {
let previous_kernel = FixtureBuilder::new().in_vk_tree(PUBLIC_KERNEL_MERGE_INDEX);
let previous_kernel = FixtureBuilder::new();
let previous_revertible = FixtureBuilder::new();
let nullifier_non_existent_read_request_hints_builder =
NullifierNonExistentReadRequestHintsBuilder::new();
Expand Down Expand Up @@ -703,19 +701,4 @@ mod tests {
.map(|n: ScopedNullifier| n.nullifier.value);
assert_array_eq(public_inputs.end.nullifiers, expected);
}

#[test]
fn valid_previous_kernel_merge() {
let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(PUBLIC_KERNEL_MERGE_INDEX);

let _res = builder.execute();
}

#[test(should_fail_with = "Invalid vk index")]
fn invalid_previous_kernel() {
let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new();
builder.previous_kernel = builder.previous_kernel.in_vk_tree(BASE_ROLLUP_INDEX);
let _res = builder.execute();
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "public_kernel_tail"
name = "rollup_base_private_simulated"
type = "bin"
authors = [""]
compiler_version = ">=0.18.0"

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

#[recursive]
unconstrained fn main(inputs: PrivateBaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
inputs.execute()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rollup_base_simulated"
name = "rollup_base_private"
type = "bin"
authors = [""]
compiler_version = ">=0.18.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use dep::rollup_lib::base::{BaseOrMergeRollupPublicInputs, PrivateBaseRollupInputs};

#[recursive]
fn main(inputs: PrivateBaseRollupInputs) -> pub BaseOrMergeRollupPublicInputs {
inputs.execute()
}
Loading

0 comments on commit 4316242

Please sign in to comment.