Skip to content

Commit

Permalink
separating kernel circuit public inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 21, 2024
1 parent d11c4ad commit 6ee3fda
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -1,119 +1,17 @@
use crate::abis::{
accumulated_data::{
combined_accumulated_data::CombinedAccumulatedData,
private_accumulated_revertible_data::PrivateAccumulatedRevertibleData,
private_accumulated_non_revertible_data::PrivateAccumulatedNonRevertibleData,
combined_accumulated_data_builder::CombinedAccumulatedDataBuilder,
public_accumulated_non_revertible_data::PublicAccumulatedNonRevertibleData,
public_accumulated_revertible_data::PublicAccumulatedRevertibleData,
accumulated_non_revertible_data_builder::AccumulatedNonRevertibleDataBuilder,
accumulated_revertible_data_builder::AccumulatedRevertibleDataBuilder
},
combined_constant_data::CombinedConstantData
mod private_kernel_circuit_public_inputs_builder;
mod private_kernel_inner_circuit_public_inputs;
mod private_kernel_tail_circuit_public_inputs;
mod public_kernel_circuit_public_inputs;
mod public_kernel_circuit_public_inputs_builder;
mod rollup_kernel_circuit_public_inputs;
mod rollup_kernel_circuit_public_inputs_builder;

use crate::abis::kernel_circuit_public_inputs::{
private_kernel_circuit_public_inputs_builder::PrivateKernelCircuitPublicInputsBuilder,
private_kernel_inner_circuit_public_inputs::PrivateKernelInnerCircuitPublicInputs,
private_kernel_tail_circuit_public_inputs::PrivateKernelTailCircuitPublicInputs,
public_kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs,
public_kernel_circuit_public_inputs_builder::PublicKernelCircuitPublicInputsBuilder,
rollup_kernel_circuit_public_inputs::RollupKernelCircuitPublicInputs,
rollup_kernel_circuit_public_inputs_builder::RollupKernelCircuitPublicInputsBuilder
};
use dep::std::{unsafe};
use crate::constants::{MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX};

use crate::mocked::AggregationObject;

struct PrivateKernelInnerCircuitPublicInputs {
aggregation_object: AggregationObject,
min_revertible_side_effect_counter: u32,
end: CombinedAccumulatedData,
constants: CombinedConstantData,
is_private: bool, // TODO can we remove this?
}

struct PrivateKernelTailCircuitPublicInputs {
aggregation_object: AggregationObject,
end_non_revertible: PrivateAccumulatedNonRevertibleData,
end: PrivateAccumulatedRevertibleData,
constants: CombinedConstantData,
needs_setup: bool,
needs_app_logic: bool,
needs_teardown: bool,
}

struct PublicKernelCircuitPublicInputs {
aggregation_object: AggregationObject,
end_non_revertible: PublicAccumulatedNonRevertibleData,
end: PublicAccumulatedRevertibleData,
constants: CombinedConstantData,
needs_setup: bool,
needs_app_logic: bool,
needs_teardown: bool,
}

struct RollupKernelCircuitPublicInputs {
aggregation_object: AggregationObject,
end: CombinedAccumulatedData,
constants: CombinedConstantData,
}

struct RollupKernelCircuitPublicInputsBuilder {
aggregation_object: AggregationObject,
end: CombinedAccumulatedDataBuilder,
constants: CombinedConstantData,
}

impl RollupKernelCircuitPublicInputsBuilder {
pub fn finish(self) -> RollupKernelCircuitPublicInputs {
RollupKernelCircuitPublicInputs { aggregation_object: self.aggregation_object, end: self.end.finish(), constants: self.constants }
}
}

struct PrivateKernelCircuitPublicInputsBuilder {
aggregation_object: AggregationObject,
min_revertible_side_effect_counter: u32,
end: CombinedAccumulatedDataBuilder,
constants: CombinedConstantData,
is_private: bool,
}

impl PrivateKernelCircuitPublicInputsBuilder {
pub fn to_inner(self) -> PrivateKernelInnerCircuitPublicInputs {
PrivateKernelInnerCircuitPublicInputs {
aggregation_object: self.aggregation_object,
min_revertible_side_effect_counter: self.min_revertible_side_effect_counter,
end: self.end.finish(),
constants: self.constants,
is_private: self.is_private
}
}

pub fn to_tail(self) -> PrivateKernelTailCircuitPublicInputs {
let (end_non_revertible, end) = self.end.split(self.min_revertible_side_effect_counter);
PrivateKernelTailCircuitPublicInputs {
aggregation_object: self.aggregation_object,
end_non_revertible,
end,
constants: self.constants,
needs_setup: end_non_revertible.needs_setup(),
needs_app_logic: end.needs_app_logic(),
needs_teardown: end_non_revertible.needs_teardown()
}
}
}

struct PublicKernelCircuitPublicInputsBuilder {
aggregation_object: AggregationObject,
end_non_revertible: AccumulatedNonRevertibleDataBuilder,
end: AccumulatedRevertibleDataBuilder,
constants: CombinedConstantData,
}

impl PublicKernelCircuitPublicInputsBuilder {
pub fn to_inner(self) -> PublicKernelCircuitPublicInputs {
let end_non_revertible = self.end_non_revertible.to_public();
let end = self.end.to_public();
PublicKernelCircuitPublicInputs {
aggregation_object: self.aggregation_object,
end_non_revertible,
end,
constants: self.constants,
needs_setup: end_non_revertible.needs_setup(),
needs_app_logic: end.needs_app_logic(),
needs_teardown: end_non_revertible.needs_teardown()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use crate::abis::{
accumulated_data::CombinedAccumulatedDataBuilder, combined_constant_data::CombinedConstantData,
kernel_circuit_public_inputs::{
private_kernel_inner_circuit_public_inputs::PrivateKernelInnerCircuitPublicInputs,
private_kernel_tail_circuit_public_inputs::PrivateKernelTailCircuitPublicInputs
}
};

use crate::mocked::AggregationObject;

struct PrivateKernelCircuitPublicInputsBuilder {
aggregation_object: AggregationObject,
min_revertible_side_effect_counter: u32,
end: CombinedAccumulatedDataBuilder,
constants: CombinedConstantData,
is_private: bool,
}

impl PrivateKernelCircuitPublicInputsBuilder {
pub fn to_inner(self) -> PrivateKernelInnerCircuitPublicInputs {
PrivateKernelInnerCircuitPublicInputs {
aggregation_object: self.aggregation_object,
min_revertible_side_effect_counter: self.min_revertible_side_effect_counter,
end: self.end.finish(),
constants: self.constants,
is_private: self.is_private
}
}

pub fn to_tail(self) -> PrivateKernelTailCircuitPublicInputs {
let (end_non_revertible, end) = self.end.split(self.min_revertible_side_effect_counter);
PrivateKernelTailCircuitPublicInputs {
aggregation_object: self.aggregation_object,
end_non_revertible,
end,
constants: self.constants,
needs_setup: end_non_revertible.needs_setup(),
needs_app_logic: end.needs_app_logic(),
needs_teardown: end_non_revertible.needs_teardown()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::abis::{accumulated_data::CombinedAccumulatedData, combined_constant_data::CombinedConstantData};

use crate::mocked::AggregationObject;

struct PrivateKernelInnerCircuitPublicInputs {
aggregation_object: AggregationObject,
min_revertible_side_effect_counter: u32,
end: CombinedAccumulatedData,
constants: CombinedConstantData,
is_private: bool, // TODO can we remove this?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::abis::{
accumulated_data::{PrivateAccumulatedNonRevertibleData, PrivateAccumulatedRevertibleData},
combined_constant_data::CombinedConstantData
};

use crate::mocked::AggregationObject;

struct PrivateKernelTailCircuitPublicInputs {
aggregation_object: AggregationObject,
end_non_revertible: PrivateAccumulatedNonRevertibleData,
end: PrivateAccumulatedRevertibleData,
constants: CombinedConstantData,
needs_setup: bool,
needs_app_logic: bool,
needs_teardown: bool,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::abis::{
accumulated_data::{PublicAccumulatedNonRevertibleData, PublicAccumulatedRevertibleData},
combined_constant_data::CombinedConstantData
};

use crate::mocked::AggregationObject;

struct PublicKernelCircuitPublicInputs {
aggregation_object: AggregationObject,
end_non_revertible: PublicAccumulatedNonRevertibleData,
end: PublicAccumulatedRevertibleData,
constants: CombinedConstantData,
needs_setup: bool,
needs_app_logic: bool,
needs_teardown: bool,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use crate::abis::{
accumulated_data::{AccumulatedNonRevertibleDataBuilder, AccumulatedRevertibleDataBuilder},
combined_constant_data::CombinedConstantData,
kernel_circuit_public_inputs::public_kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs
};

use crate::mocked::AggregationObject;

struct PublicKernelCircuitPublicInputsBuilder {
aggregation_object: AggregationObject,
end_non_revertible: AccumulatedNonRevertibleDataBuilder,
end: AccumulatedRevertibleDataBuilder,
constants: CombinedConstantData,
}

impl PublicKernelCircuitPublicInputsBuilder {
pub fn to_inner(self) -> PublicKernelCircuitPublicInputs {
let end_non_revertible = self.end_non_revertible.to_public();
let end = self.end.to_public();
PublicKernelCircuitPublicInputs {
aggregation_object: self.aggregation_object,
end_non_revertible,
end,
constants: self.constants,
needs_setup: end_non_revertible.needs_setup(),
needs_app_logic: end.needs_app_logic(),
needs_teardown: end_non_revertible.needs_teardown()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::abis::{accumulated_data::CombinedAccumulatedData, combined_constant_data::CombinedConstantData};

use crate::mocked::AggregationObject;

struct RollupKernelCircuitPublicInputs {
aggregation_object: AggregationObject,
end: CombinedAccumulatedData,
constants: CombinedConstantData,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::abis::{
accumulated_data::CombinedAccumulatedDataBuilder, combined_constant_data::CombinedConstantData,
kernel_circuit_public_inputs::rollup_kernel_circuit_public_inputs::RollupKernelCircuitPublicInputs
};

use crate::mocked::AggregationObject;

struct RollupKernelCircuitPublicInputsBuilder {
aggregation_object: AggregationObject,
end: CombinedAccumulatedDataBuilder,
constants: CombinedConstantData,
}

impl RollupKernelCircuitPublicInputsBuilder {
pub fn finish(self) -> RollupKernelCircuitPublicInputs {
RollupKernelCircuitPublicInputs { aggregation_object: self.aggregation_object, end: self.end.finish(), constants: self.constants }
}
}

0 comments on commit 6ee3fda

Please sign in to comment.