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

chore: Validate outputs in kernel circuits #7706

Merged
merged 2 commits into from
Aug 1, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl TailToPublicOutputValidator {
// unencrypted_logs_hashes
assert_split_sorted_transformed_value_arrays_asc(
prev_data.unencrypted_logs_hashes,
prev_data.unencrypted_logs_hashes,
prev_data.unencrypted_logs_hashes.map(|log: ScopedLogHash| log.expose_to_public()),
split_counter,
output_non_revertible.unencrypted_logs_hashes,
output_revertible.unencrypted_logs_hashes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl PrivateKernelInitCircuitPrivateInputs {
private_call_data_validator.validate(output.end.note_hashes);

// Validate output.
if !std::runtime::is_unconstrained() {
if dep::types::validate::should_validate_output() {
PrivateKernelCircuitOutputValidator::new(output).validate_as_first_call(
self.tx_request,
self.private_call.call_stack_item.public_inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl PrivateKernelInnerCircuitPrivateInputs {
}

// Validate output.
if !std::runtime::is_unconstrained() {
if dep::types::validate::should_validate_output() {
PrivateKernelCircuitOutputValidator::new(output).validate_as_inner_call(
self.previous_kernel.public_inputs,
previous_kernel_array_lengths,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<NH_RR_PENDING, NH_RR_SETTLED, NLL_RR_PENDING, NLL_RR_SETTLED, KEY_VALIDATIO
}.validate();

// Validate output.
if !dep::std::runtime::is_unconstrained() {
if dep::types::validate::should_validate_output() {
let transient_or_propagated_note_hash_indexes_for_logs = get_transient_or_propagated_note_hash_indexes_for_logs(
previous_public_inputs.end.note_encrypted_logs_hashes,
previous_public_inputs.end.note_hashes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl PrivateKernelTailCircuitPrivateInputs {
}

// Validate output.
if !std::runtime::is_unconstrained() {
if dep::types::validate::should_validate_output() {
TailOutputValidator::new(
output,
self.previous_kernel.public_inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl PrivateKernelTailToPublicCircuitPrivateInputs {
}

// Validate output.
if !dep::std::runtime::is_unconstrained() {
if dep::types::validate::should_validate_output() {
TailToPublicOutputValidator::new(
output,
self.previous_kernel.public_inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ use abis::kernel_circuit_public_inputs::{KernelCircuitPublicInputs, PrivateKerne
mod recursion;
mod data;
mod storage;
mod validate;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Returns whether to validate the output of the circuit. Eventually we'll want to change this
// to `!dep::std::runtime::is_unconstrained`, so we skip unneeded validations when we
// do not need to generate a proof. But for now, we always validate to make sure we catch
// errors earlier, as most of our tests run with real proofs disabled, which means validation
// checks get skipped.
pub fn should_validate_output() -> bool {
true
}
Loading