From 552cbb801b2402cc9c641b6c8249e03b82e00573 Mon Sep 17 00:00:00 2001 From: Leila Wang Date: Thu, 22 Aug 2024 16:54:57 +0000 Subject: [PATCH 1/5] Verify note hash and l1tol2 msg read requests in public. --- .../public_kernel_output_composer.nr | 20 ++++- .../src/public_kernel_tail.nr | 85 +++++++++++++++---- .../crates/reset-kernel-lib/src/lib.nr | 3 +- .../public_validation_request_processor.nr | 52 +++++++++--- .../crates/reset-kernel-lib/src/reset/mod.nr | 1 + .../src/reset/tree_leaf_read_request.nr | 27 ++++++ .../crates/types/src/abis/mod.nr | 1 + .../src/abis/public_circuit_public_inputs.nr | 18 ++-- .../types/src/abis/tree_leaf_read_request.nr | 44 ++++++++++ .../public_validation_requests.nr | 24 +++++- .../public_validation_requests_builder.nr | 14 ++- .../crates/types/src/constants.nr | 5 +- .../crates/types/src/tests/fixture_builder.nr | 28 +++++- .../bb-prover/src/avm_proving.test.ts | 5 +- .../src/sibling_path/sibling_path.ts | 2 +- yarn-project/circuits.js/src/structs/index.ts | 2 + ...blic_kernel_tail_circuit_private_inputs.ts | 26 +++++- .../structs/public_circuit_public_inputs.ts | 17 ++-- .../src/structs/public_validation_requests.ts | 23 +++++ .../src/structs/tree_leaf_read_request.ts | 32 +++++++ .../structs/tree_leaf_read_request_hint.ts | 38 +++++++++ .../circuits.js/src/tests/factories.ts | 53 ++++++++++-- .../src/type_conversion.ts | 49 ++++++++++- .../hints/build_private_kernel_reset_hints.ts | 6 +- .../src/public/abstract_phase_manager.ts | 5 +- .../simulator/src/public/execution.ts | 5 +- .../simulator/src/public/hints_builder.ts | 50 ++++++++++- .../simulator/src/public/side_effect_trace.ts | 13 +-- .../src/public/tail_phase_manager.ts | 10 +++ 29 files changed, 571 insertions(+), 87 deletions(-) create mode 100644 noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/tree_leaf_read_request.nr create mode 100644 noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr create mode 100644 yarn-project/circuits.js/src/structs/tree_leaf_read_request.ts create mode 100644 yarn-project/circuits.js/src/structs/tree_leaf_read_request_hint.ts diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr index a690bc819d9..6f45d5b3c3d 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_kernel_output_composer.nr @@ -81,6 +81,14 @@ impl PublicKernelOutputComposer { let storage_contract_address = public_call.call_context.storage_contract_address; + let note_hash_read_requests = public_call.note_hash_read_requests; + for i in 0..note_hash_read_requests.len() { + let request = note_hash_read_requests[i]; + if !is_empty(request) { + self.output_builder.validation_requests.note_hash_read_requests.push(request); + } + } + let nullifier_read_requests = public_call.nullifier_read_requests; for i in 0..nullifier_read_requests.len() { let request = nullifier_read_requests[i]; @@ -97,6 +105,14 @@ impl PublicKernelOutputComposer { } } + let l1_to_l2_msg_read_requests = public_call.l1_to_l2_msg_read_requests; + for i in 0..l1_to_l2_msg_read_requests.len() { + let request = l1_to_l2_msg_read_requests[i]; + if !is_empty(request) { + self.output_builder.validation_requests.l1_to_l2_msg_read_requests.push(request); + } + } + let read_requests = public_call.contract_storage_reads; for i in 0..read_requests.len() { let read_request = read_requests[i]; @@ -117,8 +133,8 @@ impl PublicKernelOutputComposer { self.output_builder.end = propagate_accumulated_data(&mut self.output_builder.end, public_call); } - // TODO: Should keep the data even when reverts. - // The data is required for verifying validation requests in the tail circuit, which will then discard the + // TODO: Should keep the data even when reverts. + // The data is required for verifying validation requests in the tail circuit, which will then discard the // revertible data. if revert_in_phase { self.output_builder.end = PublicAccumulatedDataBuilder::empty(); diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr index 3c95ad18bad..68c39dbf448 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/public_kernel_tail.nr @@ -8,13 +8,14 @@ use crate::{ }; use dep::reset_kernel_lib::{ NullifierReadRequestHints, NullifierNonExistentReadRequestHints, PublicDataReadRequestHints, - PublicValidationRequestProcessor + PublicValidationRequestProcessor, TreeLeafReadRequestHint }; use dep::types::{ abis::{kernel_circuit_public_inputs::KernelCircuitPublicInputs, public_kernel_data::PublicKernelData}, constants::{ - MAX_PUBLIC_DATA_HINTS, MAX_NULLIFIER_READ_REQUESTS_PER_TX, PUBLIC_KERNEL_SETUP_INDEX, - PUBLIC_KERNEL_APP_LOGIC_INDEX, PUBLIC_KERNEL_TEARDOWN_INDEX + L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_HINTS, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, NOTE_HASH_TREE_HEIGHT, + PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_APP_LOGIC_INDEX, PUBLIC_KERNEL_TEARDOWN_INDEX }, data::public_data_hint::PublicDataHint, partial_state_reference::PartialStateReference }; @@ -27,8 +28,10 @@ global ALLOWED_PREVIOUS_CIRCUITS = [ struct PublicKernelTailCircuitPrivateInputs { previous_kernel: PublicKernelData, + note_hash_read_request_hints: [TreeLeafReadRequestHint; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_request_hints: NullifierReadRequestHints, nullifier_non_existent_read_request_hints: NullifierNonExistentReadRequestHints, + l1_to_l2_msg_read_request_hints: [TreeLeafReadRequestHint; MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX], public_data_hints: [PublicDataHint; MAX_PUBLIC_DATA_HINTS], public_data_read_request_hints: PublicDataReadRequestHints, start_state: PartialStateReference, @@ -47,12 +50,13 @@ impl PublicKernelTailCircuitPrivateInputs { let previous_public_inputs = self.previous_kernel.public_inputs; PublicValidationRequestProcessor::new( previous_public_inputs, + self.start_state, + self.note_hash_read_request_hints, self.nullifier_read_request_hints, self.nullifier_non_existent_read_request_hints, - self.start_state.nullifier_tree.root, + self.l1_to_l2_msg_read_request_hints, self.public_data_read_request_hints, - self.public_data_hints, - self.start_state.public_data_tree.root + self.public_data_hints ).validate(); let output = self.generate_output(); @@ -71,7 +75,8 @@ mod tests { nullifier_read_request_hints_builder::NullifierReadRequestHintsBuilder, public_data_read_request_hints_builder::PublicDataReadRequestHintsBuilder }, - PublicDataHint, reset::read_request::{PendingReadHint, ReadRequestState, ReadRequestStatus} + PublicDataHint, reset::read_request::{PendingReadHint, ReadRequestState, ReadRequestStatus}, + TreeLeafReadRequestHint }; use dep::types::{ abis::{ @@ -80,25 +85,36 @@ mod tests { }, address::AztecAddress, constants::{ - MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_HINTS, - MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NULLIFIER_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, + MAX_PUBLIC_DATA_HINTS, MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + NOTE_HASH_SUBTREE_HEIGHT, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH, PUBLIC_DATA_TREE_HEIGHT, MAX_ENCRYPTED_LOGS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - PUBLIC_KERNEL_APP_LOGIC_INDEX, BASE_ROLLUP_INDEX, PUBLIC_KERNEL_SETUP_INDEX, - PUBLIC_KERNEL_TEARDOWN_INDEX + NOTE_HASH_TREE_HEIGHT, PUBLIC_KERNEL_APP_LOGIC_INDEX, BASE_ROLLUP_INDEX, + PUBLIC_KERNEL_SETUP_INDEX, PUBLIC_KERNEL_TEARDOWN_INDEX }, hash::{compute_siloed_nullifier, silo_note_hash}, public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, tests::{ fixture_builder::FixtureBuilder, merkle_tree_utils::NonEmptyMerkleTree, - utils::{assert_array_eq, swap_items} + utils::{assert_array_eq, pad_end, swap_items} }, traits::is_empty, partial_state_reference::PartialStateReference, utils::arrays::{array_length, array_merge}, merkle_tree::MembershipWitness }; - fn build_nullifier_tree() -> NonEmptyMerkleTree { + fn build_note_hash_tree(pre_existing_note_hashes: [Field; N]) -> NonEmptyMerkleTree { + NonEmptyMerkleTree::new( + pad_end(pre_existing_note_hashes, 0), + [0; NOTE_HASH_TREE_HEIGHT], + [0; NOTE_HASH_TREE_HEIGHT - NOTE_HASH_SUBTREE_HEIGHT], + [0; NOTE_HASH_SUBTREE_HEIGHT] + ) + } + + fn build_nullifier_tree() -> NonEmptyMerkleTree { let mut pre_existing_nullifiers = [NullifierLeafPreimage::empty(); MAX_NULLIFIERS_PER_TX]; pre_existing_nullifiers[0] = NullifierLeafPreimage { nullifier: 0, next_nullifier: 100, next_index: 1 }; pre_existing_nullifiers[1] = NullifierLeafPreimage { nullifier: 100, next_nullifier: 0, next_index: 0 }; @@ -118,7 +134,7 @@ mod tests { settled_public_data_leaves } - fn build_public_data_tree() -> NonEmptyMerkleTree { + fn build_public_data_tree() -> NonEmptyMerkleTree { let settled_public_data_leaves = get_settled_public_data_leaves(); NonEmptyMerkleTree::new( settled_public_data_leaves.map(|preimage: PublicDataTreeLeafPreimage| preimage.hash()), @@ -131,12 +147,16 @@ mod tests { struct PublicKernelTailCircuitPrivateInputsBuilder { previous_kernel: FixtureBuilder, previous_revertible: FixtureBuilder, + note_hash_read_request_hints: BoundedVec, MAX_NOTE_HASH_READ_REQUESTS_PER_TX>, nullifier_read_request_hints_builder: NullifierReadRequestHintsBuilder, nullifier_non_existent_read_request_hints_builder: NullifierNonExistentReadRequestHintsBuilder, public_data_read_request_hints_builder: PublicDataReadRequestHintsBuilder, public_data_hints: BoundedVec, public_data_tree: NonEmptyMerkleTree, + l1_to_l2_msg_read_request_hints: BoundedVec, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX>, start_state: PartialStateReference, + note_hash_tree: NonEmptyMerkleTree, + pre_existing_note_hashes: [Field; 2], } impl PublicKernelTailCircuitPrivateInputsBuilder { @@ -148,21 +168,31 @@ mod tests { PublicKernelTailCircuitPrivateInputsBuilder { previous_kernel, previous_revertible, + note_hash_read_request_hints: BoundedVec::new(), nullifier_read_request_hints_builder: NullifierReadRequestHintsBuilder::new(), nullifier_non_existent_read_request_hints_builder, public_data_read_request_hints_builder: PublicDataReadRequestHintsBuilder::new(MAX_PUBLIC_DATA_READS_PER_TX), public_data_hints: BoundedVec::new(), public_data_tree: NonEmptyMerkleTree::empty(), - start_state: PartialStateReference::empty() + l1_to_l2_msg_read_request_hints: BoundedVec::new(), + start_state: PartialStateReference::empty(), + note_hash_tree: NonEmptyMerkleTree::empty(), + pre_existing_note_hashes: [598589, 714714] } } + pub fn with_note_hash_tree(&mut self) -> Self { + self.note_hash_tree = build_note_hash_tree(self.pre_existing_note_hashes); + self.start_state.note_hash_tree.root = self.note_hash_tree.get_root(); + self.previous_kernel.historical_header.state.partial.note_hash_tree.root = 11111; + *self + } + pub fn with_nullifier_tree(&mut self) -> Self { let nullifier_tree = build_nullifier_tree(); self.nullifier_non_existent_read_request_hints_builder.set_nullifier_tree(nullifier_tree); - let tree_root = nullifier_tree.get_root(); - self.start_state.nullifier_tree.root = tree_root; - self.previous_kernel.historical_header.state.partial.nullifier_tree.root = tree_root; + self.start_state.nullifier_tree.root = nullifier_tree.get_root(); + self.previous_kernel.historical_header.state.partial.nullifier_tree.root = 22222; *self } @@ -173,6 +203,15 @@ mod tests { *self } + pub fn add_note_hash_read_request(&mut self, pre_existing_note_hash_index: u32) { + self.previous_kernel.add_note_hash_tree_leaf_read_requests( + self.pre_existing_note_hashes[pre_existing_note_hash_index], + pre_existing_note_hash_index as Field + ); + let sibling_path = self.note_hash_tree.get_sibling_path(pre_existing_note_hash_index); + self.note_hash_read_request_hints.push(TreeLeafReadRequestHint { sibling_path }); + } + pub fn add_nullifier(&mut self, unsiloed_nullifier: Field) { self.previous_kernel.add_siloed_nullifier(unsiloed_nullifier); self.sync_counters(); @@ -281,6 +320,8 @@ mod tests { nullifier_non_existent_read_request_hints: self.nullifier_non_existent_read_request_hints_builder.to_hints(), public_data_hints: self.public_data_hints.storage, public_data_read_request_hints: self.public_data_read_request_hints_builder.to_hints(), + note_hash_read_request_hints: self.note_hash_read_request_hints.storage, + l1_to_l2_msg_read_request_hints: self.l1_to_l2_msg_read_request_hints.storage, start_state: self.start_state }; @@ -334,6 +375,14 @@ mod tests { } #[test] + unconstrained fn verify_note_hash_read_requests_succeeds() { + let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new().with_note_hash_tree(); + + builder.add_note_hash_read_request(1); + + builder.succeeded(); + } + unconstrained fn one_pending_nullifier_read_request() { let mut builder = PublicKernelTailCircuitPrivateInputsBuilder::new(); diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/lib.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/lib.nr index c67fa479d22..319f2100ddd 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/lib.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/lib.nr @@ -6,7 +6,8 @@ use public_data_read_request_reset::PublicDataReadRequestHints; use public_validation_request_processor::PublicValidationRequestProcessor; use reset::{ key_validation_hint::KeyValidationHint, - transient_data::{TransientDataIndexHint, verify_squashed_transient_data} + transient_data::{TransientDataIndexHint, verify_squashed_transient_data}, + tree_leaf_read_request::TreeLeafReadRequestHint }; use dep::types::data::public_data_hint::PublicDataHint; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr index 0e069fdd86f..01fb966217d 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_validation_request_processor.nr @@ -2,7 +2,8 @@ use crate::{ reset::{ non_existent_read_request::reset_non_existent_read_requests, mutable_data_read_request::reset_mutable_data_read_requests, - read_request::verify_reset_read_requests + read_request::verify_reset_read_requests, + tree_leaf_read_request::{TreeLeafReadRequestHint, validate_tree_leaf_read_requests} }, nullifier_read_request_reset::NullifierReadRequestHints, nullifier_non_existent_read_request_reset::NullifierNonExistentReadRequestHints, @@ -15,18 +16,26 @@ use dep::types::{ validation_requests::PublicValidationRequests }, data::public_data_hint::PublicDataHint, - constants::{MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX}, - hash::compute_siloed_nullifier, traits::is_empty, + constants::{ + L1_TO_L2_MSG_TREE_HEIGHT, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + NOTE_HASH_TREE_HEIGHT +}, + hash::compute_siloed_nullifier, partial_state_reference::PartialStateReference, traits::is_empty, utils::arrays::{array_merge, array_to_bounded_vec, assert_sorted_array} }; struct PublicValidationRequestProcessor { validation_requests: PublicValidationRequests, + note_hash_read_request_hints: [TreeLeafReadRequestHint; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], + note_hash_tree_root: Field, pending_nullifiers: [Nullifier; MAX_NULLIFIERS_PER_TX], - pending_public_data_writes: [PublicDataUpdateRequest; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], nullifier_read_request_hints: NullifierReadRequestHints, nullifier_non_existent_read_request_hints: NullifierNonExistentReadRequestHints, nullifier_tree_root: Field, + l1_to_l2_msg_read_request_hints: [TreeLeafReadRequestHint; MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX], + l1_to_l2_msg_tree_root: Field, + pending_public_data_writes: [PublicDataUpdateRequest; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], public_data_read_request_hints: PublicDataReadRequestHints, public_data_hints: [PublicDataHint; NUM_PUBLIC_DATA_HINTS], public_data_tree_root: Field, @@ -35,12 +44,13 @@ struct PublicValidationRequestProcessor { impl PublicValidationRequestProcessor { pub fn new( public_inputs: PublicKernelCircuitPublicInputs, + start_state: PartialStateReference, + note_hash_read_request_hints: [TreeLeafReadRequestHint; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_request_hints: NullifierReadRequestHints, nullifier_non_existent_read_request_hints: NullifierNonExistentReadRequestHints, - nullifier_tree_root: Field, + l1_to_l2_msg_read_request_hints: [TreeLeafReadRequestHint; MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX], public_data_read_request_hints: PublicDataReadRequestHints, - public_data_hints: [PublicDataHint; NUM_PUBLIC_DATA_HINTS], - public_data_tree_root: Field + public_data_hints: [PublicDataHint; NUM_PUBLIC_DATA_HINTS] ) -> Self { let end_non_revertible = public_inputs.end_non_revertible; let end = public_inputs.end; @@ -55,22 +65,36 @@ impl PublicValidationRequestProcessor PublicValidationRequestProcessor { + sibling_path: [Field; N] +} + +pub fn validate_tree_leaf_read_requests( + read_requests: [TreeLeafReadRequest; READ_REQUEST_LEN], + hints: [TreeLeafReadRequestHint; READ_REQUEST_LEN], + tree_root: Field +) { + for i in 0..READ_REQUEST_LEN { + let read_request = read_requests[i]; + if !is_empty(read_request) { + assert_check_membership( + read_request.value, + read_request.leaf_index, + hints[i].sibling_path, + tree_root + ); + } + } +} + diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/mod.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/mod.nr index 3c2e588deff..72738cbdf81 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/mod.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/mod.nr @@ -14,6 +14,7 @@ mod combined_constant_data; mod side_effect; mod read_request; +mod tree_leaf_read_request; mod log_hash; mod note_hash; mod nullifier; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr index 09673e94af0..b70557d9cda 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/public_circuit_public_inputs.nr @@ -1,8 +1,8 @@ use crate::{ abis::{ call_context::CallContext, note_hash::NoteHash, nullifier::Nullifier, read_request::ReadRequest, - gas::Gas, global_variables::GlobalVariables, log_hash::LogHash, - public_call_request::PublicCallRequest + tree_leaf_read_request::TreeLeafReadRequest, gas::Gas, global_variables::GlobalVariables, + log_hash::LogHash, public_call_request::PublicCallRequest }, address::AztecAddress, constants::{ @@ -24,10 +24,10 @@ struct PublicCircuitPublicInputs { args_hash: Field, returns_hash: Field, - note_hash_read_requests: [ReadRequest; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], + note_hash_read_requests: [TreeLeafReadRequest; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], nullifier_read_requests: [ReadRequest; MAX_NULLIFIER_READ_REQUESTS_PER_CALL], nullifier_non_existent_read_requests: [ReadRequest; MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL], - l1_to_l2_msg_read_requests: [ReadRequest; MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL], + l1_to_l2_msg_read_requests: [TreeLeafReadRequest; MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL], contract_storage_update_requests: [StorageUpdateRequest; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL], contract_storage_reads: [StorageRead; MAX_PUBLIC_DATA_READS_PER_CALL], @@ -52,7 +52,7 @@ struct PublicCircuitPublicInputs { prover_address: AztecAddress, revert_code: u8, - + start_gas_left: Gas, end_gas_left: Gas, transaction_fee: Field, @@ -126,10 +126,10 @@ impl Deserialize for PublicCircuitPublicInp call_context: reader.read_struct(CallContext::deserialize), args_hash: reader.read(), returns_hash: reader.read(), - note_hash_read_requests: reader.read_struct_array(ReadRequest::deserialize, [ReadRequest::empty(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]), + note_hash_read_requests: reader.read_struct_array(TreeLeafReadRequest::deserialize, [TreeLeafReadRequest::empty(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL]), nullifier_read_requests: reader.read_struct_array(ReadRequest::deserialize, [ReadRequest::empty(); MAX_NULLIFIER_READ_REQUESTS_PER_CALL]), nullifier_non_existent_read_requests: reader.read_struct_array(ReadRequest::deserialize, [ReadRequest::empty(); MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL]), - l1_to_l2_msg_read_requests: reader.read_struct_array(ReadRequest::deserialize, [ReadRequest::empty(); MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL]), + l1_to_l2_msg_read_requests: reader.read_struct_array(TreeLeafReadRequest::deserialize, [TreeLeafReadRequest::empty(); MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL]), contract_storage_update_requests: reader.read_struct_array(StorageUpdateRequest::deserialize, [StorageUpdateRequest::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL]), contract_storage_reads: reader.read_struct_array(StorageRead::deserialize, [StorageRead::empty(); MAX_PUBLIC_DATA_READS_PER_CALL]), public_call_requests: reader.read_struct_array(PublicCallRequest::deserialize, [PublicCallRequest::empty(); MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL]), @@ -159,10 +159,10 @@ impl Empty for PublicCircuitPublicInputs { call_context: CallContext::empty(), args_hash: 0, returns_hash: 0, - note_hash_read_requests: [ReadRequest::empty(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], + note_hash_read_requests: [TreeLeafReadRequest::empty(); MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], nullifier_read_requests: [ReadRequest::empty(); MAX_NULLIFIER_READ_REQUESTS_PER_CALL], nullifier_non_existent_read_requests: [ReadRequest::empty(); MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL], - l1_to_l2_msg_read_requests: [ReadRequest::empty(); MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL], + l1_to_l2_msg_read_requests: [TreeLeafReadRequest::empty(); MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL], contract_storage_update_requests: [StorageUpdateRequest::empty(); MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL], contract_storage_reads: [StorageRead::empty(); MAX_PUBLIC_DATA_READS_PER_CALL], public_call_requests: [PublicCallRequest::empty(); MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL], diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr new file mode 100644 index 00000000000..69dee4db52d --- /dev/null +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_leaf_read_request.nr @@ -0,0 +1,44 @@ +use crate::{traits::{Empty, Serialize, Deserialize}, constants::TREE_LEAF_READ_REQUEST_LENGTH}; + +struct TreeLeafReadRequest { + value: Field, + leaf_index: Field, +} + +impl Eq for TreeLeafReadRequest { + fn eq(self, other: TreeLeafReadRequest) -> bool { + (self.value == other.value) & (self.leaf_index == other.leaf_index) + } +} + +impl Empty for TreeLeafReadRequest { + fn empty() -> Self { + TreeLeafReadRequest { + value: 0, + leaf_index: 0, + } + } +} + +impl Serialize for TreeLeafReadRequest { + fn serialize(self) -> [Field; TREE_LEAF_READ_REQUEST_LENGTH] { + [self.value, self.leaf_index] + } +} + +impl Deserialize for TreeLeafReadRequest { + fn deserialize(values: [Field; TREE_LEAF_READ_REQUEST_LENGTH]) -> Self { + Self { + value: values[0], + leaf_index: values[1], + } + } +} + +#[test] +fn serialization_of_empty_read() { + let item = TreeLeafReadRequest::empty(); + let serialized = item.serialize(); + let deserialized = TreeLeafReadRequest::deserialize(serialized); + assert(item.eq(deserialized)); +} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr index 4def172e8ec..e9853592622 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests.nr @@ -1,9 +1,11 @@ use crate::{ abis::{ public_data_read::PublicDataRead, read_request::ScopedReadRequest, + tree_leaf_read_request::TreeLeafReadRequest, validation_requests::{rollup_validation_requests::RollupValidationRequests} }, constants::{ + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, PUBLIC_VALIDATION_REQUESTS_LENGTH }, @@ -12,8 +14,10 @@ use crate::{ struct PublicValidationRequests { for_rollup: RollupValidationRequests, + note_hash_read_requests: [TreeLeafReadRequest; MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_requests: [ScopedReadRequest; MAX_NULLIFIER_READ_REQUESTS_PER_TX], nullifier_non_existent_read_requests: [ScopedReadRequest; MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX], + l1_to_l2_msg_read_requests: [TreeLeafReadRequest; MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX], public_data_reads: [PublicDataRead; MAX_PUBLIC_DATA_READS_PER_TX], } @@ -23,15 +27,23 @@ impl Serialize for PublicValidationRequests { fields.extend_from_array(self.for_rollup.serialize()); - for i in 0..MAX_NULLIFIER_READ_REQUESTS_PER_TX { + for i in 0..self.note_hash_read_requests.len() { + fields.extend_from_array(self.note_hash_read_requests[i].serialize()); + } + + for i in 0..self.nullifier_read_requests.len() { fields.extend_from_array(self.nullifier_read_requests[i].serialize()); } - for i in 0..MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX { + for i in 0..self.nullifier_non_existent_read_requests.len() { fields.extend_from_array(self.nullifier_non_existent_read_requests[i].serialize()); } - for i in 0..MAX_PUBLIC_DATA_READS_PER_TX { + for i in 0..self.l1_to_l2_msg_read_requests.len() { + fields.extend_from_array(self.l1_to_l2_msg_read_requests[i].serialize()); + } + + for i in 0..self.public_data_reads.len() { fields.extend_from_array(self.public_data_reads[i].serialize()); } @@ -47,8 +59,10 @@ impl Deserialize for PublicValidationRequests let mut reader = Reader::new(serialized); let item = Self { for_rollup: reader.read_struct(RollupValidationRequests::deserialize), + note_hash_read_requests: reader.read_struct_array(TreeLeafReadRequest::deserialize, [TreeLeafReadRequest::empty(); MAX_NOTE_HASH_READ_REQUESTS_PER_TX]), nullifier_read_requests: reader.read_struct_array(ScopedReadRequest::deserialize, [ScopedReadRequest::empty(); MAX_NULLIFIER_READ_REQUESTS_PER_TX]), nullifier_non_existent_read_requests: reader.read_struct_array(ScopedReadRequest::deserialize, [ScopedReadRequest::empty(); MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX]), + l1_to_l2_msg_read_requests: reader.read_struct_array(TreeLeafReadRequest::deserialize, [TreeLeafReadRequest::empty(); MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX]), public_data_reads: reader.read_struct_array(PublicDataRead::deserialize, [PublicDataRead::empty(); MAX_PUBLIC_DATA_READS_PER_TX]), }; @@ -61,8 +75,10 @@ impl Empty for PublicValidationRequests { fn empty() -> Self { PublicValidationRequests { for_rollup: RollupValidationRequests::empty(), + note_hash_read_requests: [TreeLeafReadRequest::empty(); MAX_NOTE_HASH_READ_REQUESTS_PER_TX], nullifier_read_requests: [ScopedReadRequest::empty(); MAX_NULLIFIER_READ_REQUESTS_PER_TX], nullifier_non_existent_read_requests: [ScopedReadRequest::empty(); MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX], + l1_to_l2_msg_read_requests: [TreeLeafReadRequest::empty(); MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX], public_data_reads: [PublicDataRead::empty(); MAX_PUBLIC_DATA_READS_PER_TX], } } @@ -71,8 +87,10 @@ impl Empty for PublicValidationRequests { impl Eq for PublicValidationRequests { fn eq(self, other: Self) -> bool { (self.for_rollup.eq(other.for_rollup)) & + (self.note_hash_read_requests == other.note_hash_read_requests) & (self.nullifier_read_requests == other.nullifier_read_requests) & (self.nullifier_non_existent_read_requests == other.nullifier_non_existent_read_requests) & + (self.l1_to_l2_msg_read_requests == other.l1_to_l2_msg_read_requests) & (self.public_data_reads == other.public_data_reads) } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr index cde568a6152..4a14f852f0c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/validation_requests/public_validation_requests_builder.nr @@ -1,12 +1,14 @@ use crate::{ abis::{ max_block_number::MaxBlockNumber, public_data_read::PublicDataRead, read_request::ScopedReadRequest, + tree_leaf_read_request::TreeLeafReadRequest, validation_requests::{ public_validation_requests::PublicValidationRequests, rollup_validation_requests::RollupValidationRequests } }, constants::{ + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX }, @@ -15,27 +17,33 @@ use crate::{ struct PublicValidationRequestsBuilder { max_block_number: MaxBlockNumber, + note_hash_read_requests: BoundedVec, nullifier_read_requests: BoundedVec, nullifier_non_existent_read_requests: BoundedVec, public_data_reads: BoundedVec, + l1_to_l2_msg_read_requests: BoundedVec, } impl PublicValidationRequestsBuilder { pub fn new(requests: PublicValidationRequests) -> Self { PublicValidationRequestsBuilder { max_block_number: requests.for_rollup.max_block_number, + note_hash_read_requests: array_to_bounded_vec(requests.note_hash_read_requests), nullifier_read_requests: array_to_bounded_vec(requests.nullifier_read_requests), nullifier_non_existent_read_requests: array_to_bounded_vec(requests.nullifier_non_existent_read_requests), - public_data_reads: array_to_bounded_vec(requests.public_data_reads) + public_data_reads: array_to_bounded_vec(requests.public_data_reads), + l1_to_l2_msg_read_requests: array_to_bounded_vec(requests.l1_to_l2_msg_read_requests) } } pub fn finish(self) -> PublicValidationRequests { PublicValidationRequests { for_rollup: self.for_rollup(), + note_hash_read_requests: self.note_hash_read_requests.storage, nullifier_read_requests: self.nullifier_read_requests.storage, nullifier_non_existent_read_requests: self.nullifier_non_existent_read_requests.storage, - public_data_reads: self.public_data_reads.storage + public_data_reads: self.public_data_reads.storage, + l1_to_l2_msg_read_requests: self.l1_to_l2_msg_read_requests.storage } } @@ -48,9 +56,11 @@ impl Empty for PublicValidationRequestsBuilder { fn empty() -> Self { PublicValidationRequestsBuilder { max_block_number: MaxBlockNumber::empty(), + note_hash_read_requests: BoundedVec::new(), nullifier_read_requests: BoundedVec::new(), nullifier_non_existent_read_requests: BoundedVec::new(), public_data_reads: BoundedVec::new(), + l1_to_l2_msg_read_requests: BoundedVec::new(), } } } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 8c567281c1f..c1d825e01dd 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -215,6 +215,7 @@ global KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH = KEY_VALIDATION_REQUEST_LENG global SCOPED_KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH = KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH + 1; global PARTIAL_STATE_REFERENCE_LENGTH: u32 = 6; global READ_REQUEST_LENGTH = 2; +global TREE_LEAF_READ_REQUEST_LENGTH = 2; global LOG_HASH_LENGTH = 3; global SCOPED_LOG_HASH_LENGTH = LOG_HASH_LENGTH + 1; global ENCRYPTED_LOG_HASH_LENGTH = 4; @@ -234,7 +235,7 @@ global TX_REQUEST_LENGTH: u32 = 2 + TX_CONTEXT_LENGTH + FUNCTION_DATA_LENGTH; global TOTAL_FEES_LENGTH = 1; global HEADER_LENGTH: u32 = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + CONTENT_COMMITMENT_LENGTH + STATE_REFERENCE_LENGTH + GLOBAL_VARIABLES_LENGTH + TOTAL_FEES_LENGTH; global PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = CALL_CONTEXT_LENGTH + 4 + MAX_BLOCK_NUMBER_LENGTH + (READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) + (KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH * MAX_KEY_VALIDATION_REQUESTS_PER_CALL) + (NOTE_HASH_LENGTH * MAX_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NULLIFIERS_PER_CALL) + (PRIVATE_CALL_REQUEST_LENGTH * MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL) + (PUBLIC_CALL_REQUEST_LENGTH * MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) + PUBLIC_CALL_REQUEST_LENGTH + (L2_TO_L1_MESSAGE_LENGTH * MAX_L2_TO_L1_MSGS_PER_CALL) + 2 + (NOTE_LOG_HASH_LENGTH * MAX_NOTE_ENCRYPTED_LOGS_PER_CALL) + (ENCRYPTED_LOG_HASH_LENGTH * MAX_ENCRYPTED_LOGS_PER_CALL) + (LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + HEADER_LENGTH + TX_CONTEXT_LENGTH; -global PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = CALL_CONTEXT_LENGTH + /*argsHash + returnsHash*/ 2 + (READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL) + (CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL) + (CONTRACT_STORAGE_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_CALL) + (PUBLIC_CALL_REQUEST_LENGTH * MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) + (NOTE_HASH_LENGTH * MAX_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NULLIFIERS_PER_CALL) + (L2_TO_L1_MESSAGE_LENGTH * MAX_L2_TO_L1_MSGS_PER_CALL) + 2 + (LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + AZTEC_ADDRESS_LENGTH + /* revert_code */ 1 + 2 * GAS_LENGTH + /* transaction_fee */ 1; +global PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH: u32 = CALL_CONTEXT_LENGTH + /*argsHash + returnsHash*/ 2 + (TREE_LEAF_READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_NULLIFIER_READ_REQUESTS_PER_CALL) + (READ_REQUEST_LENGTH * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL) + (TREE_LEAF_READ_REQUEST_LENGTH * MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL) + (CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL) + (CONTRACT_STORAGE_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_CALL) + (PUBLIC_CALL_REQUEST_LENGTH * MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) + (NOTE_HASH_LENGTH * MAX_NOTE_HASHES_PER_CALL) + (NULLIFIER_LENGTH * MAX_NULLIFIERS_PER_CALL) + (L2_TO_L1_MESSAGE_LENGTH * MAX_L2_TO_L1_MSGS_PER_CALL) + 2 + (LOG_HASH_LENGTH * MAX_UNENCRYPTED_LOGS_PER_CALL) + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + AZTEC_ADDRESS_LENGTH + /* revert_code */ 1 + 2 * GAS_LENGTH + /* transaction_fee */ 1; global PRIVATE_CALL_STACK_ITEM_LENGTH: u32 = AZTEC_ADDRESS_LENGTH + FUNCTION_DATA_LENGTH + PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH; global PUBLIC_CONTEXT_INPUTS_LENGTH: u32 = CALL_CONTEXT_LENGTH + HEADER_LENGTH + GLOBAL_VARIABLES_LENGTH + GAS_LENGTH + 2; @@ -243,7 +244,7 @@ global AGGREGATION_OBJECT_LENGTH: u32 = 16; global SCOPED_READ_REQUEST_LEN = READ_REQUEST_LENGTH + 1; global PUBLIC_DATA_READ_LENGTH = 2; global PRIVATE_VALIDATION_REQUESTS_LENGTH = ROLLUP_VALIDATION_REQUESTS_LENGTH + (SCOPED_READ_REQUEST_LEN * MAX_NOTE_HASH_READ_REQUESTS_PER_TX) + (SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_READ_REQUESTS_PER_TX) + (SCOPED_KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH * MAX_KEY_VALIDATION_REQUESTS_PER_TX) + 2; -global PUBLIC_VALIDATION_REQUESTS_LENGTH = ROLLUP_VALIDATION_REQUESTS_LENGTH + (SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_READ_REQUESTS_PER_TX) + (SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX) + (PUBLIC_DATA_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_TX); +global PUBLIC_VALIDATION_REQUESTS_LENGTH = ROLLUP_VALIDATION_REQUESTS_LENGTH + (TREE_LEAF_READ_REQUEST_LENGTH * MAX_NOTE_HASH_READ_REQUESTS_PER_TX) + (SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_READ_REQUESTS_PER_TX) + (SCOPED_READ_REQUEST_LEN * MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX) + (PUBLIC_DATA_READ_LENGTH * MAX_PUBLIC_DATA_READS_PER_TX) + (TREE_LEAF_READ_REQUEST_LENGTH * MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX); global PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; global COMBINED_ACCUMULATED_DATA_LENGTH = MAX_NOTE_HASHES_PER_TX + MAX_NULLIFIERS_PER_TX + (MAX_L2_TO_L1_MSGS_PER_TX * SCOPED_L2_TO_L1_MESSAGE_LENGTH) + (LOG_HASH_LENGTH * MAX_NOTE_ENCRYPTED_LOGS_PER_TX) + (SCOPED_LOG_HASH_LENGTH * MAX_ENCRYPTED_LOGS_PER_TX) + 3 + (MAX_UNENCRYPTED_LOGS_PER_TX * SCOPED_LOG_HASH_LENGTH) + (MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * PUBLIC_DATA_UPDATE_REQUEST_LENGTH) + GAS_LENGTH; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr index 0427e00154a..9a2c9100fa5 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/tests/fixture_builder.nr @@ -18,6 +18,7 @@ use crate::{ public_call_stack_item_compressed::PublicCallStackItemCompressed, public_circuit_public_inputs::PublicCircuitPublicInputs, public_data_read::PublicDataRead, public_data_update_request::PublicDataUpdateRequest, read_request::{ReadRequest, ScopedReadRequest}, + tree_leaf_read_request::TreeLeafReadRequest, log_hash::{LogHash, NoteLogHash, ScopedLogHash, EncryptedLogHash, ScopedEncryptedLogHash}, validation_requests::{ KeyValidationRequest, KeyValidationRequestAndGenerator, PrivateValidationRequests, @@ -112,9 +113,10 @@ struct FixtureBuilder { // Validation requests. max_block_number: MaxBlockNumber, note_hash_read_requests: BoundedVec, + note_hash_tree_leaf_read_requests: BoundedVec, nullifier_read_requests: BoundedVec, nullifier_non_existent_read_requests: BoundedVec, - l1_to_l2_msg_read_requests: BoundedVec, + l1_to_l2_msg_read_requests: BoundedVec, scoped_key_validation_requests_and_generators: BoundedVec, public_data_reads: BoundedVec, contract_storage_reads: BoundedVec, @@ -433,12 +435,12 @@ impl FixtureBuilder { call_context: self.build_call_context(), args_hash: self.args_hash, returns_hash: self.returns_hash, - note_hash_read_requests: subarray(self.note_hash_read_requests.storage.map(|r: ScopedReadRequest| r.read_request)), + note_hash_read_requests: subarray(self.note_hash_tree_leaf_read_requests.storage), nullifier_read_requests: subarray(self.nullifier_read_requests.storage.map(|r: ScopedReadRequest| r.read_request)), nullifier_non_existent_read_requests: subarray( self.nullifier_non_existent_read_requests.storage.map(|r: ScopedReadRequest| r.read_request) ), - l1_to_l2_msg_read_requests: subarray(self.l1_to_l2_msg_read_requests.storage.map(|r: ScopedReadRequest| r.read_request)), + l1_to_l2_msg_read_requests: subarray(self.l1_to_l2_msg_read_requests.storage), contract_storage_update_requests: subarray(self.contract_storage_update_requests.storage), contract_storage_reads: self.contract_storage_reads.storage, public_call_requests: subarray(self.public_call_requests.storage), @@ -474,9 +476,11 @@ impl FixtureBuilder { pub fn to_public_validation_requests(self) -> PublicValidationRequests { PublicValidationRequests { for_rollup: self.to_rollup_validation_requests(), + note_hash_read_requests: self.note_hash_tree_leaf_read_requests.storage, nullifier_read_requests: self.nullifier_read_requests.storage, nullifier_non_existent_read_requests: self.nullifier_non_existent_read_requests.storage, - public_data_reads: self.public_data_reads.storage + public_data_reads: self.public_data_reads.storage, + l1_to_l2_msg_read_requests: self.l1_to_l2_msg_read_requests.storage } } @@ -755,6 +759,21 @@ impl FixtureBuilder { } } + pub fn add_note_hash_tree_leaf_read_requests(&mut self, value: Field, leaf_index: Field) { + let read_request = TreeLeafReadRequest { value, leaf_index }; + self.note_hash_tree_leaf_read_requests.push(read_request); + } + + pub fn append_note_hash_tree_leaf_read_requests(&mut self, num_reads: u32) { + let index_offset = self.note_hash_tree_leaf_read_requests.len(); + for i in 0..self.note_hash_tree_leaf_read_requests.max_len() { + if i < num_reads { + let value = self.mock_note_hash_read_value(index_offset + i); + self.add_note_hash_tree_leaf_read_requests(value, (index_offset + i) as Field); + } + } + } + pub fn add_read_request_for_pending_nullifier(&mut self, nullifier_index: u32) -> u32 { let read_request_index = self.nullifier_read_requests.len(); let nullifier = self.mock_nullifier_value(nullifier_index); @@ -1170,6 +1189,7 @@ impl Empty for FixtureBuilder { public_call_requests: BoundedVec::new(), max_block_number: MaxBlockNumber::empty(), note_hash_read_requests: BoundedVec::new(), + note_hash_tree_leaf_read_requests: BoundedVec::new(), nullifier_read_requests: BoundedVec::new(), nullifier_non_existent_read_requests: BoundedVec::new(), l1_to_l2_msg_read_requests: BoundedVec::new(), diff --git a/yarn-project/bb-prover/src/avm_proving.test.ts b/yarn-project/bb-prover/src/avm_proving.test.ts index 28a5122618c..3d8f0049719 100644 --- a/yarn-project/bb-prover/src/avm_proving.test.ts +++ b/yarn-project/bb-prover/src/avm_proving.test.ts @@ -26,6 +26,7 @@ import { PublicCircuitPublicInputs, ReadRequest, RevertCode, + TreeLeafReadRequest, } from '@aztec/circuits.js'; import { computeVarArgsHash } from '@aztec/circuits.js/hash'; import { padArrayEnd } from '@aztec/foundation/collection'; @@ -312,7 +313,7 @@ const getPublicInputs = (result: PublicExecutionResult): PublicCircuitPublicInpu returnsHash: computeVarArgsHash(result.returnValues), noteHashReadRequests: padArrayEnd( result.noteHashReadRequests, - ReadRequest.empty(), + TreeLeafReadRequest.empty(), MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ), nullifierReadRequests: padArrayEnd( @@ -327,7 +328,7 @@ const getPublicInputs = (result: PublicExecutionResult): PublicCircuitPublicInpu ), l1ToL2MsgReadRequests: padArrayEnd( result.l1ToL2MsgReadRequests, - ReadRequest.empty(), + TreeLeafReadRequest.empty(), MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, ), contractStorageReads: padArrayEnd( diff --git a/yarn-project/circuit-types/src/sibling_path/sibling_path.ts b/yarn-project/circuit-types/src/sibling_path/sibling_path.ts index 086c57baf80..df22de9a56c 100644 --- a/yarn-project/circuit-types/src/sibling_path/sibling_path.ts +++ b/yarn-project/circuit-types/src/sibling_path/sibling_path.ts @@ -84,7 +84,7 @@ export class SiblingPath { * Convert Sibling Path object into a tuple of field elements. * @returns A tuple representation of the sibling path. */ - public toTuple(): Tuple { + public toTuple(): Tuple { const array = this.toFields(); return makeTuple(array.length as N, i => array[i], 0); } diff --git a/yarn-project/circuits.js/src/structs/index.ts b/yarn-project/circuits.js/src/structs/index.ts index e58f824e9f8..19cb59bdeec 100644 --- a/yarn-project/circuits.js/src/structs/index.ts +++ b/yarn-project/circuits.js/src/structs/index.ts @@ -84,6 +84,8 @@ export * from './scoped_key_validation_request_and_generator.js'; export * from './shared.js'; export * from './side_effects.js'; export * from './state_reference.js'; +export * from './tree_leaf_read_request.js'; +export * from './tree_leaf_read_request_hint.js'; export * from './trees/index.js'; export * from './tx_context.js'; export * from './tx_request.js'; diff --git a/yarn-project/circuits.js/src/structs/kernel/public_kernel_tail_circuit_private_inputs.ts b/yarn-project/circuits.js/src/structs/kernel/public_kernel_tail_circuit_private_inputs.ts index c6f22d4b536..7c2be1c3da5 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_kernel_tail_circuit_private_inputs.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_kernel_tail_circuit_private_inputs.ts @@ -1,6 +1,13 @@ import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; -import { MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_HINTS } from '../../constants.gen.js'; +import { + 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, + NOTE_HASH_TREE_HEIGHT, +} from '../../constants.gen.js'; import { type NullifierNonExistentReadRequestHints, nullifierNonExistentReadRequestHintsFromBuffer, @@ -9,6 +16,7 @@ import { PartialStateReference } from '../partial_state_reference.js'; import { PublicDataHint } from '../public_data_hint.js'; import { PublicDataReadRequestHints } from '../public_data_read_request_hints.js'; import { type NullifierReadRequestHints, nullifierReadRequestHintsFromBuffer } from '../read_request_hints/index.js'; +import { TreeLeafReadRequestHint } from '../tree_leaf_read_request_hint.js'; import { PublicKernelData } from './public_kernel_data.js'; export class PublicKernelTailCircuitPrivateInputs { @@ -17,6 +25,10 @@ export class PublicKernelTailCircuitPrivateInputs { * Kernels are recursive and this is the data from the previous kernel. */ public readonly previousKernel: PublicKernelData, + public readonly noteHashReadRequestHints: Tuple< + TreeLeafReadRequestHint, + typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX + >, /** * Contains hints for the nullifier read requests to locate corresponding pending or settled nullifiers. */ @@ -28,6 +40,10 @@ export class PublicKernelTailCircuitPrivateInputs { * Contains hints for the nullifier non existent read requests. */ public readonly nullifierNonExistentReadRequestHints: NullifierNonExistentReadRequestHints, + public readonly l1ToL2MsgReadRequestHints: Tuple< + TreeLeafReadRequestHint, + typeof MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX + >, public readonly publicDataHints: Tuple, public readonly publicDataReadRequestHints: PublicDataReadRequestHints, public readonly startState: PartialStateReference, @@ -36,8 +52,10 @@ export class PublicKernelTailCircuitPrivateInputs { toBuffer() { return serializeToBuffer( this.previousKernel, + this.noteHashReadRequestHints, this.nullifierReadRequestHints, this.nullifierNonExistentReadRequestHints, + this.l1ToL2MsgReadRequestHints, this.publicDataHints, this.publicDataReadRequestHints, this.startState, @@ -56,12 +74,18 @@ export class PublicKernelTailCircuitPrivateInputs { const reader = BufferReader.asReader(buffer); return new PublicKernelTailCircuitPrivateInputs( reader.readObject(PublicKernelData), + reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, { + fromBuffer: buf => TreeLeafReadRequestHint.fromBuffer(buf, NOTE_HASH_TREE_HEIGHT), + }), nullifierReadRequestHintsFromBuffer( reader, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, ), nullifierNonExistentReadRequestHintsFromBuffer(reader), + reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, { + fromBuffer: buf => TreeLeafReadRequestHint.fromBuffer(buf, L1_TO_L2_MSG_TREE_HEIGHT), + }), reader.readArray(MAX_PUBLIC_DATA_HINTS, PublicDataHint), reader.readObject(PublicDataReadRequestHints), reader.readObject(PartialStateReference), diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 44e0ee9bce0..bf4e7fe8259 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -38,6 +38,7 @@ import { Nullifier } from './nullifier.js'; import { PublicCallRequest } from './public_call_request.js'; import { ReadRequest } from './read_request.js'; import { RevertCode } from './revert_code.js'; +import { TreeLeafReadRequest } from './tree_leaf_read_request.js'; /** * Public inputs to a public circuit. @@ -59,7 +60,7 @@ export class PublicCircuitPublicInputs { /** * Note Hash tree read requests executed during the call. */ - public noteHashReadRequests: Tuple, + public noteHashReadRequests: Tuple, /** * Nullifier read requests executed during the call. */ @@ -74,7 +75,7 @@ export class PublicCircuitPublicInputs { /** * L1 to L2 Message Read Requests per call. */ - public l1ToL2MsgReadRequests: Tuple, + public l1ToL2MsgReadRequests: Tuple, /** * Contract storage update requests executed during the call. */ @@ -160,10 +161,10 @@ export class PublicCircuitPublicInputs { CallContext.empty(), Fr.ZERO, Fr.ZERO, - makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ReadRequest.empty), + makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, TreeLeafReadRequest.empty), makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, ReadRequest.empty), makeTuple(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, ReadRequest.empty), - makeTuple(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, ReadRequest.empty), + makeTuple(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, TreeLeafReadRequest.empty), makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, ContractStorageUpdateRequest.empty), makeTuple(MAX_PUBLIC_DATA_READS_PER_CALL, ContractStorageRead.empty), makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PublicCallRequest.empty), @@ -272,10 +273,10 @@ export class PublicCircuitPublicInputs { reader.readObject(CallContext), reader.readObject(Fr), reader.readObject(Fr), - reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ReadRequest), + reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, TreeLeafReadRequest), reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, ReadRequest), reader.readArray(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, ReadRequest), - reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, ReadRequest), + reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, TreeLeafReadRequest), reader.readArray(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, ContractStorageUpdateRequest), reader.readArray(MAX_PUBLIC_DATA_READS_PER_CALL, ContractStorageRead), reader.readArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PublicCallRequest), @@ -302,10 +303,10 @@ export class PublicCircuitPublicInputs { CallContext.fromFields(reader), reader.readField(), reader.readField(), - reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ReadRequest), + reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, TreeLeafReadRequest), reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, ReadRequest), reader.readArray(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, ReadRequest), - reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, ReadRequest), + reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, TreeLeafReadRequest), reader.readArray(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, ContractStorageUpdateRequest), reader.readArray(MAX_PUBLIC_DATA_READS_PER_CALL, ContractStorageRead), reader.readArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PublicCallRequest), diff --git a/yarn-project/circuits.js/src/structs/public_validation_requests.ts b/yarn-project/circuits.js/src/structs/public_validation_requests.ts index af29d553736..17e988c2f74 100644 --- a/yarn-project/circuits.js/src/structs/public_validation_requests.ts +++ b/yarn-project/circuits.js/src/structs/public_validation_requests.ts @@ -6,6 +6,8 @@ import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec import { inspect } from 'util'; import { + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PUBLIC_DATA_READS_PER_TX, @@ -13,6 +15,7 @@ import { import { PublicDataRead } from './public_data_read_request.js'; import { ScopedReadRequest } from './read_request.js'; import { RollupValidationRequests } from './rollup_validation_requests.js'; +import { TreeLeafReadRequest } from './tree_leaf_read_request.js'; /** * Validation requests accumulated during the execution of the transaction. @@ -24,6 +27,7 @@ export class PublicValidationRequests { * forwarded to the rollup for it to take care of them. */ public forRollup: RollupValidationRequests, + public noteHashReadRequests: Tuple, /** * All the nullifier read requests made in this transaction. */ @@ -35,6 +39,7 @@ export class PublicValidationRequests { ScopedReadRequest, typeof MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX >, + public l1ToL2MsgReadRequests: Tuple, /** * All the public data reads made in this transaction. */ @@ -44,8 +49,10 @@ export class PublicValidationRequests { getSize() { return ( this.forRollup.getSize() + + arraySerializedSizeOfNonEmpty(this.noteHashReadRequests) + arraySerializedSizeOfNonEmpty(this.nullifierReadRequests) + arraySerializedSizeOfNonEmpty(this.nullifierNonExistentReadRequests) + + arraySerializedSizeOfNonEmpty(this.l1ToL2MsgReadRequests) + arraySerializedSizeOfNonEmpty(this.publicDataReads) ); } @@ -53,8 +60,10 @@ export class PublicValidationRequests { toBuffer() { return serializeToBuffer( this.forRollup, + this.noteHashReadRequests, this.nullifierReadRequests, this.nullifierNonExistentReadRequests, + this.l1ToL2MsgReadRequests, this.publicDataReads, ); } @@ -67,8 +76,10 @@ export class PublicValidationRequests { const reader = FieldReader.asReader(fields); return new PublicValidationRequests( reader.readObject(RollupValidationRequests), + reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, TreeLeafReadRequest), reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest), reader.readArray(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, ScopedReadRequest), + reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, TreeLeafReadRequest), reader.readArray(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead), ); } @@ -82,8 +93,10 @@ export class PublicValidationRequests { const reader = BufferReader.asReader(buffer); return new PublicValidationRequests( reader.readObject(RollupValidationRequests), + reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, TreeLeafReadRequest), reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest), reader.readArray(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, ScopedReadRequest), + reader.readArray(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, TreeLeafReadRequest), reader.readArray(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead), ); } @@ -100,8 +113,10 @@ export class PublicValidationRequests { static empty() { return new PublicValidationRequests( RollupValidationRequests.empty(), + makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, TreeLeafReadRequest.empty), makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest.empty), makeTuple(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, ScopedReadRequest.empty), + makeTuple(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, TreeLeafReadRequest.empty), makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead.empty), ); } @@ -109,6 +124,10 @@ export class PublicValidationRequests { [inspect.custom]() { return `PublicValidationRequests { forRollup: ${inspect(this.forRollup)}, + noteHashReadRequests: [${this.noteHashReadRequests + .filter(x => !x.isEmpty()) + .map(h => inspect(h)) + .join(', ')}], nullifierReadRequests: [${this.nullifierReadRequests .filter(x => !x.isEmpty()) .map(h => inspect(h)) @@ -117,6 +136,10 @@ export class PublicValidationRequests { .filter(x => !x.isEmpty()) .map(h => inspect(h)) .join(', ')}], + l1ToL2MsgReadRequests: [${this.l1ToL2MsgReadRequests + .filter(x => !x.isEmpty()) + .map(h => inspect(h)) + .join(', ')}], publicDataReads: [${this.publicDataReads .filter(x => !x.isEmpty()) .map(h => inspect(h)) diff --git a/yarn-project/circuits.js/src/structs/tree_leaf_read_request.ts b/yarn-project/circuits.js/src/structs/tree_leaf_read_request.ts new file mode 100644 index 00000000000..e32a0068b40 --- /dev/null +++ b/yarn-project/circuits.js/src/structs/tree_leaf_read_request.ts @@ -0,0 +1,32 @@ +import { Fr } from '@aztec/foundation/fields'; +import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize'; + +export class TreeLeafReadRequest { + constructor(public value: Fr, public leafIndex: Fr) {} + + toBuffer(): Buffer { + return serializeToBuffer(this.value, this.leafIndex); + } + + static fromBuffer(buffer: Buffer | BufferReader) { + const reader = BufferReader.asReader(buffer); + return new TreeLeafReadRequest(Fr.fromBuffer(reader), Fr.fromBuffer(reader)); + } + + toFields(): Fr[] { + return [this.value, this.leafIndex]; + } + + static fromFields(fields: Fr[] | FieldReader) { + const reader = FieldReader.asReader(fields); + return new TreeLeafReadRequest(reader.readField(), reader.readField()); + } + + isEmpty() { + return this.value.isZero() && this.leafIndex.isZero(); + } + + static empty() { + return new TreeLeafReadRequest(Fr.zero(), Fr.zero()); + } +} diff --git a/yarn-project/circuits.js/src/structs/tree_leaf_read_request_hint.ts b/yarn-project/circuits.js/src/structs/tree_leaf_read_request_hint.ts new file mode 100644 index 00000000000..e6b64deb6cb --- /dev/null +++ b/yarn-project/circuits.js/src/structs/tree_leaf_read_request_hint.ts @@ -0,0 +1,38 @@ +import { assertMemberLength } from '@aztec/foundation/array'; +import { Fr } from '@aztec/foundation/fields'; +import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; + +/** + * Contains information which can be used to prove that a leaf is a member of a Merkle tree. + */ +export class TreeLeafReadRequestHint { + constructor( + /** + * Size of the sibling path (number of fields it contains). + */ + pathSize: N, + /** + * Sibling path of the leaf in the Merkle tree. + */ + public siblingPath: Tuple, + ) { + assertMemberLength(this, 'siblingPath', pathSize); + } + + toBuffer() { + return serializeToBuffer(this.siblingPath); + } + + public static empty(pathSize: N): TreeLeafReadRequestHint { + const arr = Array(pathSize) + .fill(0) + .map(() => Fr.ZERO) as Tuple; + return new TreeLeafReadRequestHint(pathSize, arr); + } + + static fromBuffer(buffer: Buffer | BufferReader, size: N): TreeLeafReadRequestHint { + const reader = BufferReader.asReader(buffer); + const siblingPath = reader.readArray(size, Fr); + return new TreeLeafReadRequestHint(size, siblingPath); + } +} diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index a9e06ab980e..192869a48cb 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -37,12 +37,14 @@ import { KeyValidationRequest, KeyValidationRequestAndGenerator, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, + L1_TO_L2_MSG_TREE_HEIGHT, L2ToL1Message, LogHash, MAX_ENCRYPTED_LOGS_PER_CALL, MAX_ENCRYPTED_LOGS_PER_TX, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_CALL, @@ -73,6 +75,7 @@ import { MergeRollupInputs, NESTED_RECURSIVE_PROOF_LENGTH, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, + NOTE_HASH_TREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, @@ -144,7 +147,13 @@ import { GasFees } from '../structs/gas_fees.js'; import { GasSettings } from '../structs/gas_settings.js'; import { GlobalVariables } from '../structs/global_variables.js'; import { Header } from '../structs/header.js'; -import { PublicValidationRequests, ScopedL2ToL1Message, ScopedNoteHash } from '../structs/index.js'; +import { + PublicValidationRequests, + ScopedL2ToL1Message, + ScopedNoteHash, + TreeLeafReadRequest, + TreeLeafReadRequestHint, +} from '../structs/index.js'; import { KernelCircuitPublicInputs } from '../structs/kernel/kernel_circuit_public_inputs.js'; import { KernelData } from '../structs/kernel/kernel_data.js'; import { BlockMergeRollupInputs } from '../structs/rollup/block_merge_rollup.js'; @@ -237,6 +246,14 @@ function makeScopedReadRequest(n: number): ScopedReadRequest { return new ScopedReadRequest(makeReadRequest(n), AztecAddress.fromBigInt(BigInt(n + 2))); } +function makeTreeLeafReadRequest(seed: number) { + return new TreeLeafReadRequest(new Fr(seed), new Fr(seed + 1)); +} + +function makeTreeLeafReadRequestHint(seed: number, size: N) { + return new TreeLeafReadRequestHint(size, makeSiblingPath(seed, size)); +} + /** * Creates arbitrary KeyValidationRequest from the given seed. * @param seed - The seed to use for generating the KeyValidationRequest. @@ -310,8 +327,10 @@ export function makeContractStorageRead(seed = 1): ContractStorageRead { function makePublicValidationRequests(seed = 1) { return new PublicValidationRequests( makeRollupValidationRequests(seed), - makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, makeScopedReadRequest, seed + 0x80), + makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, makeTreeLeafReadRequest, seed + 0x10), + makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX, makeScopedReadRequest, seed + 0x80), makeTuple(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, makeScopedReadRequest, seed + 0x95), + makeTuple(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, makeTreeLeafReadRequest, seed + 0x100), makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, seed + 0xe00), ); } @@ -421,10 +440,20 @@ export function makePublicCircuitPublicInputs( makeCallContext(seed, { storageContractAddress: storageContractAddress ?? makeAztecAddress(seed) }), fr(seed + 0x100), fr(seed + 0x200), - tupleGenerator(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, makeReadRequest, seed + 0x300, ReadRequest.empty), + tupleGenerator( + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, + makeTreeLeafReadRequest, + seed + 0x300, + TreeLeafReadRequest.empty, + ), tupleGenerator(MAX_NULLIFIER_READ_REQUESTS_PER_CALL, makeReadRequest, seed + 0x400, ReadRequest.empty), tupleGenerator(MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL, makeReadRequest, seed + 0x420, ReadRequest.empty), - tupleGenerator(MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, makeReadRequest, seed + 0x440, ReadRequest.empty), + tupleGenerator( + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, + makeTreeLeafReadRequest, + seed + 0x440, + TreeLeafReadRequest.empty, + ), tupleGenerator( MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, makeContractStorageUpdateRequest, @@ -518,6 +547,10 @@ export function makeKernelCircuitPublicInputs(seed = 1, fullAccumulatedData = tr ); } +function makeSiblingPath(seed: number, size: N) { + return makeTuple(size, fr, seed); +} + /** * Creates arbitrary/mocked membership witness where the sibling paths is an array of fields in an ascending order starting from `start`. * @param size - The size of the membership witness. @@ -525,7 +558,7 @@ export function makeKernelCircuitPublicInputs(seed = 1, fullAccumulatedData = tr * @returns A membership witness. */ export function makeMembershipWitness(size: N, start: number): MembershipWitness { - return new MembershipWitness(size, BigInt(start), makeTuple(size, fr, start)); + return new MembershipWitness(size, BigInt(start), makeSiblingPath(start, size)); } /** @@ -676,8 +709,18 @@ export function makePublicKernelCircuitPrivateInputs(seed = 1): PublicKernelCirc export function makePublicKernelTailCircuitPrivateInputs(seed = 1): PublicKernelTailCircuitPrivateInputs { return new PublicKernelTailCircuitPrivateInputs( makePublicKernelData(seed), + makeTuple( + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + s => makeTreeLeafReadRequestHint(s, NOTE_HASH_TREE_HEIGHT), + seed + 0x20, + ), NullifierReadRequestHintsBuilder.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX), NullifierNonExistentReadRequestHintsBuilder.empty(), + makeTuple( + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + s => makeTreeLeafReadRequestHint(s, L1_TO_L2_MSG_TREE_HEIGHT), + seed + 0x80, + ), makeTuple(MAX_PUBLIC_DATA_HINTS, PublicDataHint.empty, seed + 0x100), PublicDataReadRequestHintsBuilder.empty(), makePartialStateReference(seed + 0x200), diff --git a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts index 150396a60dd..e84b9efbc7f 100644 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts @@ -32,11 +32,13 @@ import { type KeyValidationHint, KeyValidationRequest, KeyValidationRequestAndGenerator, + type L1_TO_L2_MSG_TREE_HEIGHT, L2ToL1Message, type LeafDataReadHint, LogHash, MAX_ENCRYPTED_LOGS_PER_TX, MAX_KEY_VALIDATION_REQUESTS_PER_TX, + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_ENCRYPTED_LOGS_PER_TX, MAX_NOTE_HASHES_PER_TX, @@ -127,6 +129,8 @@ import { type StateDiffHints, StateReference, type TransientDataIndexHint, + TreeLeafReadRequest, + type TreeLeafReadRequestHint, TxContext, type TxRequest, type VerificationKeyAsFields, @@ -244,6 +248,8 @@ import type { StorageRead as StorageReadNoir, StorageUpdateRequest as StorageUpdateRequestNoir, TransientDataIndexHint as TransientDataIndexHintNoir, + TreeLeafReadRequestHint as TreeLeafReadRequestHintNoir, + TreeLeafReadRequest as TreeLeafReadRequestNoir, TxContext as TxContextNoir, TxRequest as TxRequestNoir, } from './types/index.js'; @@ -812,6 +818,17 @@ export function mapScopedReadRequestFromNoir(scoped: ScopedReadRequestNoir): Sco ); } +function mapTreeLeafReadRequestToNoir(readRequest: TreeLeafReadRequest): TreeLeafReadRequestNoir { + return { + value: mapFieldToNoir(readRequest.value), + leaf_index: mapFieldToNoir(readRequest.leafIndex), + }; +} + +function mapTreeLeafReadRequestFromNoir(readRequest: TreeLeafReadRequestNoir) { + return new TreeLeafReadRequest(mapFieldFromNoir(readRequest.value), mapFieldFromNoir(readRequest.leaf_index)); +} + /** * Maps a KeyValidationRequest to a noir KeyValidationRequest. * @param request - The KeyValidationRequest. @@ -1088,6 +1105,14 @@ function mapLeafDataReadHintToNoir(hint: LeafDataReadHint): LeafDataReadHintNoir }; } +function mapTreeLeafReadRequestHintToNoir( + hint: TreeLeafReadRequestHint, +): TreeLeafReadRequestHintNoir { + return { + sibling_path: mapTuple(hint.siblingPath, mapFieldToNoir) as FixedLengthArray, + }; +} + function mapNoteHashSettledReadHintToNoir( hint: SettledReadHint, ): NoteHashSettledReadHintNoir { @@ -1228,11 +1253,13 @@ function mapPrivateValidationRequestsFromNoir(requests: PrivateValidationRequest function mapPublicValidationRequestsToNoir(requests: PublicValidationRequests): PublicValidationRequestsNoir { return { for_rollup: mapRollupValidationRequestsToNoir(requests.forRollup), + note_hash_read_requests: mapTuple(requests.noteHashReadRequests, mapTreeLeafReadRequestToNoir), nullifier_read_requests: mapTuple(requests.nullifierReadRequests, mapScopedReadRequestToNoir), nullifier_non_existent_read_requests: mapTuple( requests.nullifierNonExistentReadRequests, mapScopedReadRequestToNoir, ), + l1_to_l2_msg_read_requests: mapTuple(requests.l1ToL2MsgReadRequests, mapTreeLeafReadRequestToNoir), public_data_reads: mapTuple(requests.publicDataReads, mapPublicDataReadToNoir), }; } @@ -1240,6 +1267,11 @@ function mapPublicValidationRequestsToNoir(requests: PublicValidationRequests): function mapPublicValidationRequestsFromNoir(requests: PublicValidationRequestsNoir): PublicValidationRequests { return new PublicValidationRequests( mapRollupValidationRequestsFromNoir(requests.for_rollup), + mapTupleFromNoir( + requests.note_hash_read_requests, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + mapTreeLeafReadRequestFromNoir, + ), mapTupleFromNoir( requests.nullifier_read_requests, MAX_NULLIFIER_READ_REQUESTS_PER_TX, @@ -1250,6 +1282,11 @@ function mapPublicValidationRequestsFromNoir(requests: PublicValidationRequestsN MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, mapScopedReadRequestFromNoir, ), + mapTupleFromNoir( + requests.l1_to_l2_msg_read_requests, + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + mapTreeLeafReadRequestFromNoir, + ), mapTupleFromNoir(requests.public_data_reads, MAX_PUBLIC_DATA_READS_PER_TX, mapPublicDataReadFromNoir), ); } @@ -1750,10 +1787,18 @@ export function mapPublicKernelTailCircuitPrivateInputsToNoir( ): PublicKernelTailCircuitPrivateInputsNoir { return { previous_kernel: mapPublicKernelDataToNoir(inputs.previousKernel), + note_hash_read_request_hints: mapTuple( + inputs.noteHashReadRequestHints, + (hint: TreeLeafReadRequestHint) => mapTreeLeafReadRequestHintToNoir(hint), + ), nullifier_read_request_hints: mapNullifierReadRequestHintsToNoir(inputs.nullifierReadRequestHints), nullifier_non_existent_read_request_hints: mapNullifierNonExistentReadRequestHintsToNoir( inputs.nullifierNonExistentReadRequestHints, ), + l1_to_l2_msg_read_request_hints: mapTuple( + inputs.l1ToL2MsgReadRequestHints, + (hint: TreeLeafReadRequestHint) => mapTreeLeafReadRequestHintToNoir(hint), + ), public_data_hints: mapTuple(inputs.publicDataHints, mapPublicDataHintToNoir), public_data_read_request_hints: mapPublicDataReadRequestHintsToNoir(inputs.publicDataReadRequestHints), start_state: mapPartialStateReferenceToNoir(inputs.startState), @@ -1887,10 +1932,10 @@ export function mapPublicCircuitPublicInputsToNoir( call_context: mapCallContextToNoir(publicInputs.callContext), args_hash: mapFieldToNoir(publicInputs.argsHash), returns_hash: mapFieldToNoir(publicInputs.returnsHash), - note_hash_read_requests: mapTuple(publicInputs.noteHashReadRequests, mapReadRequestToNoir), + note_hash_read_requests: mapTuple(publicInputs.noteHashReadRequests, mapTreeLeafReadRequestToNoir), nullifier_read_requests: mapTuple(publicInputs.nullifierReadRequests, mapReadRequestToNoir), nullifier_non_existent_read_requests: mapTuple(publicInputs.nullifierNonExistentReadRequests, mapReadRequestToNoir), - l1_to_l2_msg_read_requests: mapTuple(publicInputs.l1ToL2MsgReadRequests, mapReadRequestToNoir), + l1_to_l2_msg_read_requests: mapTuple(publicInputs.l1ToL2MsgReadRequests, mapTreeLeafReadRequestToNoir), contract_storage_update_requests: mapTuple( publicInputs.contractStorageUpdateRequests, mapStorageUpdateRequestToNoir, diff --git a/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_hints.ts b/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_hints.ts index 69d382edbfa..03123a74abf 100644 --- a/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_hints.ts +++ b/yarn-project/pxe/src/kernel_prover/hints/build_private_kernel_reset_hints.ts @@ -46,11 +46,7 @@ function getNullifierReadRequestHints(), - ), + membershipWitness: new MembershipWitness(NULLIFIER_TREE_HEIGHT, index, siblingPath.toTuple()), leafPreimage, }; }; diff --git a/yarn-project/simulator/src/public/abstract_phase_manager.ts b/yarn-project/simulator/src/public/abstract_phase_manager.ts index 965caab647e..054218ae5a2 100644 --- a/yarn-project/simulator/src/public/abstract_phase_manager.ts +++ b/yarn-project/simulator/src/public/abstract_phase_manager.ts @@ -47,6 +47,7 @@ import { PublicKernelData, ReadRequest, RevertCode, + TreeLeafReadRequest, makeEmptyProof, makeEmptyRecursiveProof, } from '@aztec/circuits.js'; @@ -412,7 +413,7 @@ export abstract class AbstractPhaseManager { returnsHash: computeVarArgsHash(result.returnValues), noteHashReadRequests: padArrayEnd( result.noteHashReadRequests, - ReadRequest.empty(), + TreeLeafReadRequest.empty(), MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, ), nullifierReadRequests: padArrayEnd( @@ -427,7 +428,7 @@ export abstract class AbstractPhaseManager { ), l1ToL2MsgReadRequests: padArrayEnd( result.l1ToL2MsgReadRequests, - ReadRequest.empty(), + TreeLeafReadRequest.empty(), MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL, ), contractStorageReads: padArrayEnd( diff --git a/yarn-project/simulator/src/public/execution.ts b/yarn-project/simulator/src/public/execution.ts index be5b4a51605..109fef0a3ea 100644 --- a/yarn-project/simulator/src/public/execution.ts +++ b/yarn-project/simulator/src/public/execution.ts @@ -17,6 +17,7 @@ import { PublicCallStackItemCompressed, type ReadRequest, RevertCode, + type TreeLeafReadRequest, } from '@aztec/circuits.js'; import { computeVarArgsHash } from '@aztec/circuits.js/hash'; @@ -62,13 +63,13 @@ export interface PublicExecutionResult { /** The new nullifiers to be inserted into the nullifier tree. */ nullifiers: Nullifier[]; /** The note hash read requests emitted in this call. */ - noteHashReadRequests: ReadRequest[]; + noteHashReadRequests: TreeLeafReadRequest[]; /** The nullifier read requests emitted in this call. */ nullifierReadRequests: ReadRequest[]; /** The nullifier non existent read requests emitted in this call. */ nullifierNonExistentReadRequests: ReadRequest[]; /** L1 to L2 message read requests emitted in this call. */ - l1ToL2MsgReadRequests: ReadRequest[]; + l1ToL2MsgReadRequests: TreeLeafReadRequest[]; /** * The hashed logs with side effect counter. * Note: required as we don't track the counter anywhere else. diff --git a/yarn-project/simulator/src/public/hints_builder.ts b/yarn-project/simulator/src/public/hints_builder.ts index 5b0ad19713e..0c11102ef9d 100644 --- a/yarn-project/simulator/src/public/hints_builder.ts +++ b/yarn-project/simulator/src/public/hints_builder.ts @@ -1,6 +1,9 @@ import { type IndexedTreeId, MerkleTreeId } from '@aztec/circuit-types'; import { type Fr, + L1_TO_L2_MSG_TREE_HEIGHT, + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, type MAX_NULLIFIERS_PER_TX, type MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, @@ -8,6 +11,7 @@ import { type MAX_PUBLIC_DATA_READS_PER_TX, type MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MembershipWitness, + NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, type Nullifier, PUBLIC_DATA_TREE_HEIGHT, @@ -16,18 +20,31 @@ import { type PublicDataTreeLeafPreimage, type PublicDataUpdateRequest, type ScopedReadRequest, + type TreeLeafReadRequest, + TreeLeafReadRequestHint, buildNullifierNonExistentReadRequestHints, buildPublicDataHint, buildPublicDataHints, buildPublicDataReadRequestHints, buildSiloedNullifierReadRequestHints, } from '@aztec/circuits.js'; +import { makeTuple } from '@aztec/foundation/array'; import { type Tuple } from '@aztec/foundation/serialize'; import { type MerkleTreeOperations } from '@aztec/world-state'; export class HintsBuilder { constructor(private db: MerkleTreeOperations) {} + async getNoteHashReadRequestsHints( + readRequests: Tuple, + ) { + return await this.getTreeLeafReadRequestsHints( + readRequests, + MAX_NOTE_HASH_READ_REQUESTS_PER_TX, + NOTE_HASH_TREE_HEIGHT, + ); + } + async getNullifierReadRequestHints( nullifierReadRequests: Tuple, pendingNullifiers: Tuple, @@ -50,6 +67,16 @@ export class HintsBuilder { return buildNullifierNonExistentReadRequestHints(this, nullifierNonExistentReadRequests, pendingNullifiers); } + async getL1ToL2MsgReadRequestsHints( + readRequests: Tuple, + ) { + return await this.getTreeLeafReadRequestsHints( + readRequests, + MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, + L1_TO_L2_MSG_TREE_HEIGHT, + ); + } + getPublicDataHints( publicDataReads: Tuple, publicDataUpdateRequests: Tuple, @@ -120,8 +147,8 @@ export class HintsBuilder { treeHeight: TREE_HEIGHT, index: bigint, ) { - const siblingPath = await this.db.getSiblingPath(treeId, index); - const membershipWitness = new MembershipWitness(treeHeight, index, siblingPath.toTuple()); + const siblingPath = await this.db.getSiblingPath(treeId, index); + const membershipWitness = new MembershipWitness(treeHeight, index, siblingPath.toTuple()); const leafPreimage = await this.db.getLeafPreimage(treeId, index); if (!leafPreimage) { @@ -130,4 +157,23 @@ export class HintsBuilder { return { membershipWitness, leafPreimage }; } + + private async getTreeLeafReadRequestsHints( + readRequests: Tuple, + size: N, + height: TREE_HEIGHT, + ): Promise, N>> { + const hints = makeTuple(size, () => TreeLeafReadRequestHint.empty(height)); + for (let i = 0; i < readRequests.length; i++) { + const request = readRequests[i]; + if (!request.isEmpty()) { + const siblingPath = await this.db.getSiblingPath( + MerkleTreeId.NOTE_HASH_TREE, + request.leafIndex.toBigInt(), + ); + hints[i] = new TreeLeafReadRequestHint(height, siblingPath.toTuple()); + } + } + return hints; + } } diff --git a/yarn-project/simulator/src/public/side_effect_trace.ts b/yarn-project/simulator/src/public/side_effect_trace.ts index dbbe1c8ac37..c26c5fdd53b 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.ts @@ -16,6 +16,7 @@ import { Nullifier, type PublicCallRequest, ReadRequest, + TreeLeafReadRequest, } from '@aztec/circuits.js'; import { Fr } from '@aztec/foundation/fields'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -38,14 +39,14 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { private contractStorageReads: ContractStorageRead[] = []; private contractStorageUpdateRequests: ContractStorageUpdateRequest[] = []; - private noteHashReadRequests: ReadRequest[] = []; + private noteHashReadRequests: TreeLeafReadRequest[] = []; private noteHashes: NoteHash[] = []; private nullifierReadRequests: ReadRequest[] = []; private nullifierNonExistentReadRequests: ReadRequest[] = []; private nullifiers: Nullifier[] = []; - private l1ToL2MsgReadRequests: ReadRequest[] = []; + private l1ToL2MsgReadRequests: TreeLeafReadRequest[] = []; private newL2ToL1Messages: L2ToL1Message[] = []; private unencryptedLogs: UnencryptedL2Log[] = []; @@ -104,12 +105,12 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { this.incrementSideEffectCounter(); } - public traceNoteHashCheck(_storageAddress: Fr, noteHash: Fr, _leafIndex: Fr, exists: boolean) { + public traceNoteHashCheck(_storageAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean) { // TODO(4805): check if some threshold is reached for max note hash checks // NOTE: storageAddress is unused but will be important when an AVM circuit processes an entire enqueued call // TODO(dbanks12): leafIndex is unused for now but later must be used by kernel to constrain that the kernel // is in fact checking the leaf indicated by the user - this.noteHashReadRequests.push(new ReadRequest(noteHash, this.sideEffectCounter)); + this.noteHashReadRequests.push(new TreeLeafReadRequest(noteHash, leafIndex)); this.avmCircuitHints.noteHashExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)), ); @@ -154,12 +155,12 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { this.incrementSideEffectCounter(); } - public traceL1ToL2MessageCheck(_contractAddress: Fr, msgHash: Fr, _msgLeafIndex: Fr, exists: boolean) { + public traceL1ToL2MessageCheck(_contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) { // TODO(4805): check if some threshold is reached for max message reads // NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call // TODO(dbanks12): leafIndex is unused for now but later must be used by kernel to constrain that the kernel // is in fact checking the leaf indicated by the user - this.l1ToL2MsgReadRequests.push(new ReadRequest(msgHash, this.sideEffectCounter)); + this.l1ToL2MsgReadRequests.push(new TreeLeafReadRequest(msgHash, msgLeafIndex)); this.avmCircuitHints.l1ToL2MessageExists.items.push( new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)), ); diff --git a/yarn-project/simulator/src/public/tail_phase_manager.ts b/yarn-project/simulator/src/public/tail_phase_manager.ts index 5b55af3e250..155a8fec14a 100644 --- a/yarn-project/simulator/src/public/tail_phase_manager.ts +++ b/yarn-project/simulator/src/public/tail_phase_manager.ts @@ -77,6 +77,10 @@ export class TailPhaseManager extends AbstractPhaseManager { const { validationRequests, endNonRevertibleData: nonRevertibleData, end: revertibleData } = previousOutput; + const noteHashReadRequestHints = await this.hintsBuilder.getNoteHashReadRequestsHints( + validationRequests.noteHashReadRequests, + ); + const pendingNullifiers = mergeAccumulatedData( nonRevertibleData.nullifiers, revertibleData.nullifiers, @@ -93,6 +97,10 @@ export class TailPhaseManager extends AbstractPhaseManager { pendingNullifiers, ); + const l1ToL2MsgReadRequestHints = await this.hintsBuilder.getL1ToL2MsgReadRequestsHints( + validationRequests.l1ToL2MsgReadRequests, + ); + const pendingPublicDataWrites = mergeAccumulatedData( nonRevertibleData.publicDataUpdateRequests, revertibleData.publicDataUpdateRequests, @@ -114,8 +122,10 @@ export class TailPhaseManager extends AbstractPhaseManager { return new PublicKernelTailCircuitPrivateInputs( previousKernel, + noteHashReadRequestHints, nullifierReadRequestHints, nullifierNonExistentReadRequestHints, + l1ToL2MsgReadRequestHints, publicDataHints, publicDataReadRequestHints, currentState.partial, From 8422cea576cec4fc4436ec2bbf844a083c334333 Mon Sep 17 00:00:00 2001 From: Leila Wang Date: Thu, 22 Aug 2024 17:23:47 +0000 Subject: [PATCH 2/5] Fix. --- yarn-project/simulator/src/public/hints_builder.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/yarn-project/simulator/src/public/hints_builder.ts b/yarn-project/simulator/src/public/hints_builder.ts index 0c11102ef9d..439aa7a5fa3 100644 --- a/yarn-project/simulator/src/public/hints_builder.ts +++ b/yarn-project/simulator/src/public/hints_builder.ts @@ -42,6 +42,7 @@ export class HintsBuilder { readRequests, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, NOTE_HASH_TREE_HEIGHT, + MerkleTreeId.NOTE_HASH_TREE, ); } @@ -74,6 +75,7 @@ export class HintsBuilder { readRequests, MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_TX, L1_TO_L2_MSG_TREE_HEIGHT, + MerkleTreeId.L1_TO_L2_MESSAGE_TREE, ); } @@ -161,17 +163,15 @@ export class HintsBuilder { private async getTreeLeafReadRequestsHints( readRequests: Tuple, size: N, - height: TREE_HEIGHT, + treeHeight: TREE_HEIGHT, + treeId: MerkleTreeId, ): Promise, N>> { - const hints = makeTuple(size, () => TreeLeafReadRequestHint.empty(height)); + const hints = makeTuple(size, () => TreeLeafReadRequestHint.empty(treeHeight)); for (let i = 0; i < readRequests.length; i++) { const request = readRequests[i]; if (!request.isEmpty()) { - const siblingPath = await this.db.getSiblingPath( - MerkleTreeId.NOTE_HASH_TREE, - request.leafIndex.toBigInt(), - ); - hints[i] = new TreeLeafReadRequestHint(height, siblingPath.toTuple()); + const siblingPath = await this.db.getSiblingPath(treeId, request.leafIndex.toBigInt()); + hints[i] = new TreeLeafReadRequestHint(treeHeight, siblingPath.toTuple()); } } return hints; From 0bd3f39308bf78eee513a2265c6ee5cbb1bcb075 Mon Sep 17 00:00:00 2001 From: Leila Wang Date: Fri, 23 Aug 2024 17:14:57 +0000 Subject: [PATCH 3/5] Update constants and tests. --- l1-contracts/src/core/libraries/ConstantsGen.sol | 5 +++-- yarn-project/circuits.js/src/constants.gen.ts | 5 +++-- yarn-project/simulator/src/public/side_effect_trace.test.ts | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index e5b0a08205f..8e874cc4772 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -162,6 +162,7 @@ library Constants { uint256 internal constant SCOPED_KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH = 6; uint256 internal constant PARTIAL_STATE_REFERENCE_LENGTH = 6; uint256 internal constant READ_REQUEST_LENGTH = 2; + uint256 internal constant TREE_LEAF_READ_REQUEST_LENGTH = 2; uint256 internal constant LOG_HASH_LENGTH = 3; uint256 internal constant SCOPED_LOG_HASH_LENGTH = 4; uint256 internal constant ENCRYPTED_LOG_HASH_LENGTH = 4; @@ -188,14 +189,14 @@ library Constants { uint256 internal constant SCOPED_READ_REQUEST_LEN = 3; uint256 internal constant PUBLIC_DATA_READ_LENGTH = 2; uint256 internal constant PRIVATE_VALIDATION_REQUESTS_LENGTH = 772; - uint256 internal constant PUBLIC_VALIDATION_REQUESTS_LENGTH = 514; + uint256 internal constant PUBLIC_VALIDATION_REQUESTS_LENGTH = 770; uint256 internal constant PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; uint256 internal constant COMBINED_ACCUMULATED_DATA_LENGTH = 610; uint256 internal constant COMBINED_CONSTANT_DATA_LENGTH = 43; uint256 internal constant PRIVATE_ACCUMULATED_DATA_LENGTH = 1336; uint256 internal constant PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2167; uint256 internal constant PUBLIC_ACCUMULATED_DATA_LENGTH = 1311; - uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3629; + uint256 internal constant PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3885; uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 663; uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 12; uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 29; diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 71ba8886eba..be173d699f8 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -146,6 +146,7 @@ export const KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH = 5; export const SCOPED_KEY_VALIDATION_REQUEST_AND_GENERATOR_LENGTH = 6; export const PARTIAL_STATE_REFERENCE_LENGTH = 6; export const READ_REQUEST_LENGTH = 2; +export const TREE_LEAF_READ_REQUEST_LENGTH = 2; export const LOG_HASH_LENGTH = 3; export const SCOPED_LOG_HASH_LENGTH = 4; export const ENCRYPTED_LOG_HASH_LENGTH = 4; @@ -172,14 +173,14 @@ export const AGGREGATION_OBJECT_LENGTH = 16; export const SCOPED_READ_REQUEST_LEN = 3; export const PUBLIC_DATA_READ_LENGTH = 2; export const PRIVATE_VALIDATION_REQUESTS_LENGTH = 772; -export const PUBLIC_VALIDATION_REQUESTS_LENGTH = 514; +export const PUBLIC_VALIDATION_REQUESTS_LENGTH = 770; export const PUBLIC_DATA_UPDATE_REQUEST_LENGTH = 3; export const COMBINED_ACCUMULATED_DATA_LENGTH = 610; export const COMBINED_CONSTANT_DATA_LENGTH = 43; export const PRIVATE_ACCUMULATED_DATA_LENGTH = 1336; export const PRIVATE_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2167; export const PUBLIC_ACCUMULATED_DATA_LENGTH = 1311; -export const PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3629; +export const PUBLIC_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 3885; export const KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 663; export const CONSTANT_ROLLUP_DATA_LENGTH = 12; export const BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 29; diff --git a/yarn-project/simulator/src/public/side_effect_trace.test.ts b/yarn-project/simulator/src/public/side_effect_trace.test.ts index 63224eafddf..8ea72de1493 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.test.ts @@ -102,8 +102,8 @@ describe('Side Effect Trace', () => { //storageAddress: contractAddress, value: utxo, //exists: exists, - counter: startCounter, - //leafIndex: leafIndex, + // counter: startCounter, + leafIndex, }, ]); expect(pxResult.avmCircuitHints.noteHashExists.items).toEqual([{ key: startCounterFr, value: new Fr(exists) }]); @@ -180,7 +180,7 @@ describe('Side Effect Trace', () => { expect(pxResult.l1ToL2MsgReadRequests).toEqual([ { value: utxo, - counter: startCounter, + leafIndex, }, ]); expect(pxResult.avmCircuitHints.l1ToL2MessageExists.items).toEqual([ From 62bd9dcd33daaca3a7644339c5faf176b61358f2 Mon Sep 17 00:00:00 2001 From: Ilyas Ridhuan Date: Tue, 3 Sep 2024 15:54:34 +0100 Subject: [PATCH 4/5] fix(avm): relax constraints for leaf_index kernel opcodes (#8288) Re-constraining this is being tracked in #8287 --- barretenberg/cpp/pil/avm/kernel.pil | 7 +- .../barretenberg/vm/avm/generated/flavor.cpp | 36 +++++------ .../barretenberg/vm/avm/generated/flavor.hpp | 8 +-- .../vm/avm/generated/relations/kernel.hpp | 19 ++---- .../relations/kernel_output_lookup.hpp | 10 +-- .../vm/avm/tests/execution.test.cpp | 13 ++-- .../barretenberg/vm/avm/tests/kernel.test.cpp | 9 ++- .../barretenberg/vm/avm/trace/execution.cpp | 6 +- .../vm/avm/trace/execution_hints.hpp | 11 +++- .../vm/avm/trace/kernel_trace.cpp | 22 ++++++- .../src/barretenberg/vm/avm/trace/trace.cpp | 64 ++++++++++++++++--- .../src/barretenberg/vm/avm/trace/trace.hpp | 13 +++- .../pxe/src/simulator_oracle/index.ts | 5 ++ .../simulator/src/avm/avm_simulator.test.ts | 10 ++- .../simulator/src/avm/journal/journal.test.ts | 4 +- .../simulator/src/avm/journal/journal.ts | 22 ++++--- .../src/avm/opcodes/accrued_substate.test.ts | 10 ++- yarn-project/simulator/src/avm/test_utils.ts | 11 +++- .../simulator/src/public/db_interfaces.ts | 7 ++ .../simulator/src/public/public_db_sources.ts | 11 ++++ .../src/public/side_effect_trace.test.ts | 8 +-- .../simulator/src/public/side_effect_trace.ts | 10 ++- 22 files changed, 212 insertions(+), 104 deletions(-) diff --git a/barretenberg/cpp/pil/avm/kernel.pil b/barretenberg/cpp/pil/avm/kernel.pil index 9763bcaaa42..d04a5fa13ff 100644 --- a/barretenberg/cpp/pil/avm/kernel.pil +++ b/barretenberg/cpp/pil/avm/kernel.pil @@ -164,8 +164,8 @@ namespace main(256); // When we encounter a state writing opcode // We increment the side effect counter by 1 - #[SIDE_EFFECT_COUNTER_INCREMENT] - KERNEL_OUTPUT_SELECTORS * (side_effect_counter' - (side_effect_counter + 1)) = 0; + //#[SIDE_EFFECT_COUNTER_INCREMENT] + //KERNEL_OUTPUT_SELECTORS * (side_effect_counter' - (side_effect_counter + 1)) = 0; //===== LOOKUPS INTO THE PUBLIC INPUTS =========================================== pol KERNEL_INPUT_SELECTORS = sel_op_address + sel_op_storage_address + sel_op_sender @@ -182,8 +182,9 @@ namespace main(256); #[KERNEL_OUTPUT_ACTIVE_CHECK] KERNEL_OUTPUT_SELECTORS * (1 - sel_q_kernel_output_lookup) = 0; + // TODO(#8287): Reintroduce constraints #[KERNEL_OUTPUT_LOOKUP] - sel_q_kernel_output_lookup {kernel_out_offset, ia, side_effect_counter, ib} in sel_kernel_out {clk, kernel_value_out, kernel_side_effect_out, kernel_metadata_out}; + sel_q_kernel_output_lookup {kernel_out_offset, /*ia,*/ /*side_effect_counter,*/ ib } in sel_kernel_out {clk, /*kernel_value_out,*/ /*kernel_side_effect_out,*/ kernel_metadata_out}; #[LOOKUP_INTO_KERNEL] sel_q_kernel_lookup { main.ia, kernel_in_offset } in sel_kernel_inputs { kernel_inputs, clk }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index 02c17d98dec..4f1bed50327 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -774,24 +774,23 @@ AvmFlavor::AllConstRefValues::AllConstRefValues( , main_nullifier_non_exists_write_offset_shift(il[766]) , main_pc_shift(il[767]) , main_sel_execution_row_shift(il[768]) - , main_side_effect_counter_shift(il[769]) - , main_sload_write_offset_shift(il[770]) - , main_sstore_write_offset_shift(il[771]) - , mem_glob_addr_shift(il[772]) - , mem_rw_shift(il[773]) - , mem_sel_mem_shift(il[774]) - , mem_tag_shift(il[775]) - , mem_tsp_shift(il[776]) - , mem_val_shift(il[777]) - , slice_addr_shift(il[778]) - , slice_clk_shift(il[779]) - , slice_cnt_shift(il[780]) - , slice_col_offset_shift(il[781]) - , slice_sel_cd_cpy_shift(il[782]) - , slice_sel_mem_active_shift(il[783]) - , slice_sel_return_shift(il[784]) - , slice_sel_start_shift(il[785]) - , slice_space_id_shift(il[786]) + , main_sload_write_offset_shift(il[769]) + , main_sstore_write_offset_shift(il[770]) + , mem_glob_addr_shift(il[771]) + , mem_rw_shift(il[772]) + , mem_sel_mem_shift(il[773]) + , mem_tag_shift(il[774]) + , mem_tsp_shift(il[775]) + , mem_val_shift(il[776]) + , slice_addr_shift(il[777]) + , slice_clk_shift(il[778]) + , slice_cnt_shift(il[779]) + , slice_col_offset_shift(il[780]) + , slice_sel_cd_cpy_shift(il[781]) + , slice_sel_mem_active_shift(il[782]) + , slice_sel_return_shift(il[783]) + , slice_sel_start_shift(il[784]) + , slice_space_id_shift(il[785]) {} AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) @@ -1577,7 +1576,6 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id main_nullifier_non_exists_write_offset_shift[row_idx], main_pc_shift[row_idx], main_sel_execution_row_shift[row_idx], - main_side_effect_counter_shift[row_idx], main_sload_write_offset_shift[row_idx], main_sstore_write_offset_shift[row_idx], mem_glob_addr_shift[row_idx], diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index da57edf4b8d..87bc3c0ee43 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -104,8 +104,8 @@ template using tuple_cat_t = decltype(std::tuple_cat(std:: #define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_first, main_zeroes, powers_power_of_2 #define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_borrow, alu_cf, alu_clk, alu_cmp_rng_ctr, alu_div_u16_r0, alu_div_u16_r1, alu_div_u16_r2, alu_div_u16_r3, alu_div_u16_r4, alu_div_u16_r5, alu_div_u16_r6, alu_div_u16_r7, alu_divisor_hi, alu_divisor_lo, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_op_add, alu_op_cast, alu_op_cast_prev, alu_op_div, alu_op_div_a_lt_b, alu_op_div_std, alu_op_eq, alu_op_eq_diff_inv, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_p_a_borrow, alu_p_b_borrow, alu_p_sub_a_hi, alu_p_sub_a_lo, alu_p_sub_b_hi, alu_p_sub_b_lo, alu_partial_prod_hi, alu_partial_prod_lo, alu_quotient_hi, alu_quotient_lo, alu_remainder, alu_res_hi, alu_res_lo, alu_sel_alu, alu_sel_cmp, alu_sel_div_rng_chk, alu_sel_rng_chk, alu_sel_rng_chk_lookup, alu_sel_shift_which, alu_shift_lt_bit_len, alu_t_sub_s_bits, alu_two_pow_s, alu_two_pow_t_sub_s, alu_u128_tag, alu_u16_r0, alu_u16_r1, alu_u16_r10, alu_u16_r11, alu_u16_r12, alu_u16_r13, alu_u16_r14, alu_u16_r2, alu_u16_r3, alu_u16_r4, alu_u16_r5, alu_u16_r6, alu_u16_r7, alu_u16_r8, alu_u16_r9, alu_u16_tag, alu_u32_tag, alu_u64_tag, alu_u8_r0, alu_u8_r1, alu_u8_tag, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, conversion_clk, conversion_input, conversion_num_limbs, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas_hi, main_abs_da_rem_gas_lo, main_abs_l2_rem_gas_hi, main_abs_l2_rem_gas_lo, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_last, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_cmov, main_sel_op_coinbase, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_pedersen, main_sel_op_pedersen_commit, main_sel_op_poseidon2, main_sel_op_radix_le, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_storage_address, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff_hi, mem_diff_lo, mem_diff_mid, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_cmov, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, pedersen_clk, pedersen_input, pedersen_output, pedersen_sel_pedersen, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_u8_0_counts, lookup_u8_1_counts, lookup_u16_0_counts, lookup_u16_1_counts, lookup_u16_2_counts, lookup_u16_3_counts, lookup_u16_4_counts, lookup_u16_5_counts, lookup_u16_6_counts, lookup_u16_7_counts, lookup_u16_8_counts, lookup_u16_9_counts, lookup_u16_10_counts, lookup_u16_11_counts, lookup_u16_12_counts, lookup_u16_13_counts, lookup_u16_14_counts, lookup_div_u16_0_counts, lookup_div_u16_1_counts, lookup_div_u16_2_counts, lookup_div_u16_3_counts, lookup_div_u16_4_counts, lookup_div_u16_5_counts, lookup_div_u16_6_counts, lookup_div_u16_7_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, range_check_l2_gas_hi_counts, range_check_l2_gas_lo_counts, range_check_da_gas_hi_counts, range_check_da_gas_lo_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_mem_rng_chk_lo_counts, lookup_mem_rng_chk_mid_counts, lookup_mem_rng_chk_hi_counts #define DERIVED_WITNESS_ENTITIES perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_slice_mem_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_pos2_perm_inv, perm_main_pedersen_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_u8_0_inv, lookup_u8_1_inv, lookup_u16_0_inv, lookup_u16_1_inv, lookup_u16_2_inv, lookup_u16_3_inv, lookup_u16_4_inv, lookup_u16_5_inv, lookup_u16_6_inv, lookup_u16_7_inv, lookup_u16_8_inv, lookup_u16_9_inv, lookup_u16_10_inv, lookup_u16_11_inv, lookup_u16_12_inv, lookup_u16_13_inv, lookup_u16_14_inv, lookup_div_u16_0_inv, lookup_div_u16_1_inv, lookup_div_u16_2_inv, lookup_div_u16_3_inv, lookup_div_u16_4_inv, lookup_div_u16_5_inv, lookup_div_u16_6_inv, lookup_div_u16_7_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, range_check_l2_gas_hi_inv, range_check_l2_gas_lo_inv, range_check_da_gas_hi_inv, range_check_da_gas_lo_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv, lookup_mem_rng_chk_lo_inv, lookup_mem_rng_chk_mid_inv, lookup_mem_rng_chk_hi_inv -#define SHIFTED_ENTITIES alu_a_hi_shift, alu_a_lo_shift, alu_b_hi_shift, alu_b_lo_shift, alu_cmp_rng_ctr_shift, alu_div_u16_r0_shift, alu_div_u16_r1_shift, alu_div_u16_r2_shift, alu_div_u16_r3_shift, alu_div_u16_r4_shift, alu_div_u16_r5_shift, alu_div_u16_r6_shift, alu_div_u16_r7_shift, alu_op_add_shift, alu_op_cast_shift, alu_op_cast_prev_shift, alu_op_div_shift, alu_op_mul_shift, alu_op_shl_shift, alu_op_shr_shift, alu_op_sub_shift, alu_p_sub_a_hi_shift, alu_p_sub_a_lo_shift, alu_p_sub_b_hi_shift, alu_p_sub_b_lo_shift, alu_sel_alu_shift, alu_sel_cmp_shift, alu_sel_div_rng_chk_shift, alu_sel_rng_chk_shift, alu_sel_rng_chk_lookup_shift, alu_u16_r0_shift, alu_u16_r1_shift, alu_u16_r2_shift, alu_u16_r3_shift, alu_u16_r4_shift, alu_u16_r5_shift, alu_u16_r6_shift, alu_u8_r0_shift, alu_u8_r1_shift, binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_row_shift, main_side_effect_counter_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift -#define TO_BE_SHIFTED(e) e.alu_a_hi, e.alu_a_lo, e.alu_b_hi, e.alu_b_lo, e.alu_cmp_rng_ctr, e.alu_div_u16_r0, e.alu_div_u16_r1, e.alu_div_u16_r2, e.alu_div_u16_r3, e.alu_div_u16_r4, e.alu_div_u16_r5, e.alu_div_u16_r6, e.alu_div_u16_r7, e.alu_op_add, e.alu_op_cast, e.alu_op_cast_prev, e.alu_op_div, e.alu_op_mul, e.alu_op_shl, e.alu_op_shr, e.alu_op_sub, e.alu_p_sub_a_hi, e.alu_p_sub_a_lo, e.alu_p_sub_b_hi, e.alu_p_sub_b_lo, e.alu_sel_alu, e.alu_sel_cmp, e.alu_sel_div_rng_chk, e.alu_sel_rng_chk, e.alu_sel_rng_chk_lookup, e.alu_u16_r0, e.alu_u16_r1, e.alu_u16_r2, e.alu_u16_r3, e.alu_u16_r4, e.alu_u16_r5, e.alu_u16_r6, e.alu_u8_r0, e.alu_u8_r1, e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_row, e.main_side_effect_counter, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id +#define SHIFTED_ENTITIES alu_a_hi_shift, alu_a_lo_shift, alu_b_hi_shift, alu_b_lo_shift, alu_cmp_rng_ctr_shift, alu_div_u16_r0_shift, alu_div_u16_r1_shift, alu_div_u16_r2_shift, alu_div_u16_r3_shift, alu_div_u16_r4_shift, alu_div_u16_r5_shift, alu_div_u16_r6_shift, alu_div_u16_r7_shift, alu_op_add_shift, alu_op_cast_shift, alu_op_cast_prev_shift, alu_op_div_shift, alu_op_mul_shift, alu_op_shl_shift, alu_op_shr_shift, alu_op_sub_shift, alu_p_sub_a_hi_shift, alu_p_sub_a_lo_shift, alu_p_sub_b_hi_shift, alu_p_sub_b_lo_shift, alu_sel_alu_shift, alu_sel_cmp_shift, alu_sel_div_rng_chk_shift, alu_sel_rng_chk_shift, alu_sel_rng_chk_lookup_shift, alu_u16_r0_shift, alu_u16_r1_shift, alu_u16_r2_shift, alu_u16_r3_shift, alu_u16_r4_shift, alu_u16_r5_shift, alu_u16_r6_shift, alu_u8_r0_shift, alu_u8_r1_shift, binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_row_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift +#define TO_BE_SHIFTED(e) e.alu_a_hi, e.alu_a_lo, e.alu_b_hi, e.alu_b_lo, e.alu_cmp_rng_ctr, e.alu_div_u16_r0, e.alu_div_u16_r1, e.alu_div_u16_r2, e.alu_div_u16_r3, e.alu_div_u16_r4, e.alu_div_u16_r5, e.alu_div_u16_r6, e.alu_div_u16_r7, e.alu_op_add, e.alu_op_cast, e.alu_op_cast_prev, e.alu_op_div, e.alu_op_mul, e.alu_op_shl, e.alu_op_shr, e.alu_op_sub, e.alu_p_sub_a_hi, e.alu_p_sub_a_lo, e.alu_p_sub_b_hi, e.alu_p_sub_b_lo, e.alu_sel_alu, e.alu_sel_cmp, e.alu_sel_div_rng_chk, e.alu_sel_rng_chk, e.alu_sel_rng_chk_lookup, e.alu_u16_r0, e.alu_u16_r1, e.alu_u16_r2, e.alu_u16_r3, e.alu_u16_r4, e.alu_u16_r5, e.alu_u16_r6, e.alu_u8_r0, e.alu_u8_r1, e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_row, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id #define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES // clang-format on @@ -132,11 +132,11 @@ class AvmFlavor { static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 16; static constexpr size_t NUM_WITNESS_ENTITIES = 696; - static constexpr size_t NUM_SHIFTED_ENTITIES = 75; + static constexpr size_t NUM_SHIFTED_ENTITIES = 74; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 787; + static constexpr size_t NUM_ALL_ENTITIES = 786; // The total number of witnesses including shifts and derived entities. static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel.hpp index 6fa15bbad85..4ac010e7171 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel.hpp @@ -10,9 +10,9 @@ template class kernelImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { 3, 3, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; template void static accumulate(ContainerOverSubrelations& evals, @@ -363,22 +363,15 @@ template class kernelImpl { } { using Accumulator = typename std::tuple_element_t<41, ContainerOverSubrelations>; - auto tmp = (main_KERNEL_OUTPUT_SELECTORS * - (new_term.main_side_effect_counter_shift - (new_term.main_side_effect_counter + FF(1)))); + auto tmp = (main_KERNEL_INPUT_SELECTORS * (FF(1) - new_term.main_sel_q_kernel_lookup)); tmp *= scaling_factor; std::get<41>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<42, ContainerOverSubrelations>; - auto tmp = (main_KERNEL_INPUT_SELECTORS * (FF(1) - new_term.main_sel_q_kernel_lookup)); - tmp *= scaling_factor; - std::get<42>(evals) += typename Accumulator::View(tmp); - } - { - using Accumulator = typename std::tuple_element_t<43, ContainerOverSubrelations>; auto tmp = (main_KERNEL_OUTPUT_SELECTORS * (FF(1) - new_term.main_sel_q_kernel_output_lookup)); tmp *= scaling_factor; - std::get<43>(evals) += typename Accumulator::View(tmp); + std::get<42>(evals) += typename Accumulator::View(tmp); } } }; @@ -453,10 +446,8 @@ template class kernel : public Relation> { case 39: return "SSTORE_KERNEL_OUTPUT"; case 41: - return "SIDE_EFFECT_COUNTER_INCREMENT"; - case 42: return "KERNEL_INPUT_ACTIVE_CHECK"; - case 43: + case 42: return "KERNEL_OUTPUT_ACTIVE_CHECK"; } return std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel_output_lookup.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel_output_lookup.hpp index 27ab2deb718..72a11d0e50f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel_output_lookup.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/kernel_output_lookup.hpp @@ -14,7 +14,7 @@ class kernel_output_lookup_lookup_settings { static constexpr size_t WRITE_TERMS = 1; static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; - static constexpr size_t LOOKUP_TUPLE_SIZE = 4; + static constexpr size_t LOOKUP_TUPLE_SIZE = 2; static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; static constexpr size_t READ_TERM_DEGREE = 0; static constexpr size_t WRITE_TERM_DEGREE = 0; @@ -40,12 +40,8 @@ class kernel_output_lookup_lookup_settings { in.main_sel_q_kernel_output_lookup, in.main_sel_kernel_out, in.main_kernel_out_offset, - in.main_ia, - in.main_side_effect_counter, in.main_ib, in.main_clk, - in.main_kernel_value_out, - in.main_kernel_side_effect_out, in.main_kernel_metadata_out); } @@ -56,12 +52,8 @@ class kernel_output_lookup_lookup_settings { in.main_sel_q_kernel_output_lookup, in.main_sel_kernel_out, in.main_kernel_out_offset, - in.main_ia, - in.main_side_effect_counter, in.main_ib, in.main_clk, - in.main_kernel_value_out, - in.main_kernel_side_effect_out, in.main_kernel_metadata_out); } }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp index 43f95355e80..558f05409c7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp @@ -1771,7 +1771,8 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) auto emit_note_hash_kernel_out_row = std::ranges::find_if( trace.begin(), trace.end(), [&](Row r) { return r.main_clk == emit_note_hash_out_offset; }); EXPECT_EQ(emit_note_hash_kernel_out_row->main_kernel_value_out, 1); - EXPECT_EQ(emit_note_hash_kernel_out_row->main_kernel_side_effect_out, 0); + // TODO(#8287) + // EXPECT_EQ(emit_note_hash_kernel_out_row->main_kernel_side_effect_out, 0); feed_output(emit_note_hash_out_offset, 1, 0, 0); // CHECK EMIT NULLIFIER @@ -2174,7 +2175,9 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) std::vector returndata = {}; // Generate Hint for hash exists operation - auto execution_hints = ExecutionHints().with_storage_value_hints({ { 0, 1 }, { 1, 1 }, { 2, 1 } }); + auto execution_hints = ExecutionHints() + .with_storage_value_hints({ { 0, 1 }, { 1, 1 }, { 2, 1 } }) + .with_note_hash_exists_hints({ { 0, 1 }, { 1, 1 }, { 2, 1 } }); auto trace = Execution::gen_trace(instructions, returndata, calldata, public_inputs_vec, execution_hints); @@ -2202,7 +2205,8 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) auto nullifier_out_row = std::ranges::find_if( trace.begin(), trace.end(), [&](Row r) { return r.main_clk == START_NULLIFIER_EXISTS_OFFSET; }); EXPECT_EQ(nullifier_out_row->main_kernel_value_out, 1); // value - EXPECT_EQ(nullifier_out_row->main_kernel_side_effect_out, 1); + // TODO(#8287) + // EXPECT_EQ(nullifier_out_row->main_kernel_side_effect_out, 1); EXPECT_EQ(nullifier_out_row->main_kernel_metadata_out, 1); // exists feed_output(START_NULLIFIER_EXISTS_OFFSET, 1, 1, 1); @@ -2216,7 +2220,8 @@ TEST_F(AvmExecutionTests, kernelOutputHashExistsOpcodes) auto msg_out_row = std::ranges::find_if( trace.begin(), trace.end(), [&](Row r) { return r.main_clk == START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET; }); EXPECT_EQ(msg_out_row->main_kernel_value_out, 1); // value - EXPECT_EQ(msg_out_row->main_kernel_side_effect_out, 2); + // TODO(#8287) + // EXPECT_EQ(msg_out_row->main_kernel_side_effect_out, 2); EXPECT_EQ(msg_out_row->main_kernel_metadata_out, 1); // exists feed_output(START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET, 1, 2, 1); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp index 15277be8c48..77cc1a5e59f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/kernel.test.cpp @@ -1217,14 +1217,16 @@ TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) auto direct_apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); - trace_builder.op_note_hash_exists(/*indirect*/ false, value_offset, metadata_offset); + // TODO(#8287): Leaf index isnt constrained properly so we just set it to 0 + trace_builder.op_note_hash_exists(/*indirect*/ false, value_offset, 0, metadata_offset); }; // TODO: fix auto indirect_apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); trace_builder.op_set(0, value_offset, indirect_value_offset, AvmMemoryTag::U32); trace_builder.op_set(0, metadata_offset, indirect_metadata_offset, AvmMemoryTag::U32); - trace_builder.op_note_hash_exists(/*indirect*/ 3, indirect_value_offset, indirect_metadata_offset); + // TODO(#8287): Leaf index isnt constrained properly so we just set it to 0 + trace_builder.op_note_hash_exists(/*indirect*/ 3, indirect_value_offset, 0, indirect_metadata_offset); }; auto checks = [=](bool indirect, const std::vector& trace) { auto row = std::ranges::find_if( @@ -1343,7 +1345,8 @@ TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); - trace_builder.op_l1_to_l2_msg_exists(/*indirect*/ false, value_offset, metadata_offset); + // TODO(#8287): Leaf index isnt constrained properly so we just set it to 0 + trace_builder.op_l1_to_l2_msg_exists(/*indirect*/ false, value_offset, 0, metadata_offset); }; auto checks = [=]([[maybe_unused]] bool indirect, const std::vector& trace) { auto row = std::ranges::find_if( diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp index 36e0aba65a3..abe7f8f40b2 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp @@ -650,8 +650,7 @@ std::vector Execution::gen_trace(std::vector const& instructio case OpCode::NOTEHASHEXISTS: trace_builder.op_note_hash_exists(std::get(inst.operands.at(0)), std::get(inst.operands.at(1)), - // TODO: leaf offset exists - // std::get(inst.operands.at(2)) + std::get(inst.operands.at(2)), std::get(inst.operands.at(3))); break; case OpCode::EMITNOTEHASH: @@ -673,8 +672,7 @@ std::vector Execution::gen_trace(std::vector const& instructio case OpCode::L1TOL2MSGEXISTS: trace_builder.op_l1_to_l2_msg_exists(std::get(inst.operands.at(0)), std::get(inst.operands.at(1)), - // TODO: leaf offset exists - // std::get(inst.operands.at(2)) + std::get(inst.operands.at(2)), std::get(inst.operands.at(3))); break; case OpCode::GETCONTRACTINSTANCE: diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp index df54b770f05..5bda7055d85 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution_hints.hpp @@ -105,8 +105,15 @@ struct ExecutionHints { { std::unordered_map hints_map; push_vec_into_map(hints_map, storage_value_hints); - push_vec_into_map(hints_map, note_hash_exists_hints); push_vec_into_map(hints_map, nullifier_exists_hints); + return hints_map; + } + + // Leaf index -> exists + std::unordered_map get_leaf_index_hints() const + { + std::unordered_map hints_map; + push_vec_into_map(hints_map, note_hash_exists_hints); push_vec_into_map(hints_map, l1_to_l2_message_exists_hints); return hints_map; } @@ -161,4 +168,4 @@ struct ExecutionHints { {} }; -} // namespace bb::avm_trace \ No newline at end of file +} // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp index 8564a7eed2b..f953f7b8489 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/kernel_trace.cpp @@ -173,7 +173,16 @@ void AvmKernelTraceBuilder::op_note_hash_exists(uint32_t clk, { uint32_t offset = START_NOTE_HASH_EXISTS_WRITE_OFFSET + note_hash_exists_offset; - perform_kernel_output_lookup(offset, side_effect_counter, note_hash, FF(result)); + // TODO(#8287)Lookups are heavily underconstrained atm + if (result == 1) { + perform_kernel_output_lookup(offset, side_effect_counter, note_hash, FF(result)); + } else { + // if the note_hash does NOT exist, the public inputs already contains the correct output value (i.e. the + // actual value at the index), so we don't try to overwrite the value + std::get(public_inputs)[offset] = side_effect_counter; + std::get(public_inputs)[offset] = FF(result); + kernel_output_selector_counter[offset]++; + } note_hash_exists_offset++; KernelTraceEntry entry = { @@ -245,7 +254,16 @@ void AvmKernelTraceBuilder::op_l1_to_l2_msg_exists(uint32_t clk, uint32_t result) { uint32_t offset = START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET + l1_to_l2_msg_exists_offset; - perform_kernel_output_lookup(offset, side_effect_counter, message, FF(result)); + // TODO(#8287)Lookups are heavily underconstrained atm + if (result == 1) { + perform_kernel_output_lookup(offset, side_effect_counter, message, FF(result)); + } else { + // if the l1_to_l2_msg_exists is false, the public inputs already contains the correct output value (i.e. the + // actual value at the index), so we don't try to overwrite the value + std::get(public_inputs)[offset] = side_effect_counter; + std::get(public_inputs)[offset] = FF(result); + kernel_output_selector_counter[offset]++; + } l1_to_l2_msg_exists_offset++; KernelTraceEntry entry = { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp index 006d06bf937..b3b345e3e93 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp @@ -2114,6 +2114,44 @@ Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output_from_h }; } +// Specifically for handling the L1TOL2MSGEXISTS and NOTEHASHEXISTS opcodes +Row AvmTraceBuilder::create_kernel_output_opcode_for_leaf_index( + uint8_t indirect, uint32_t clk, uint32_t data_offset, uint32_t metadata_offset, uint32_t leaf_index) +{ + // If doesnt exist, should not read_a, but instead get from public inputs + FF exists = execution_hints.get_leaf_index_hints().at(leaf_index); + + auto [resolved_data, resolved_metadata] = unpack_indirects<2>(indirect, { data_offset, metadata_offset }); + auto read_a = constrained_read_from_memory( + call_ptr, clk, resolved_data, AvmMemoryTag::FF, AvmMemoryTag::U8, IntermRegister::IA); + + auto write_b = constrained_write_to_memory( + call_ptr, clk, resolved_metadata, exists, AvmMemoryTag::FF, AvmMemoryTag::U8, IntermRegister::IB); + bool tag_match = read_a.tag_match && write_b.tag_match; + + return Row{ + .main_clk = clk, + .main_ia = read_a.val, + .main_ib = write_b.val, + .main_ind_addr_a = FF(read_a.indirect_address), + .main_ind_addr_b = FF(write_b.indirect_address), + .main_internal_return_ptr = internal_return_ptr, + .main_mem_addr_a = FF(read_a.direct_address), + .main_mem_addr_b = FF(write_b.direct_address), + .main_pc = pc++, + .main_r_in_tag = static_cast(AvmMemoryTag::FF), + .main_rwa = 0, + .main_rwb = 1, + .main_sel_mem_op_a = 1, + .main_sel_mem_op_b = 1, + .main_sel_q_kernel_output_lookup = 1, + .main_sel_resolve_ind_addr_a = FF(static_cast(read_a.is_indirect)), + .main_sel_resolve_ind_addr_b = FF(static_cast(write_b.is_indirect)), + .main_tag_err = static_cast(!tag_match), + .main_w_in_tag = static_cast(AvmMemoryTag::U8), + }; +} + /** * @brief Create a kernel output opcode with set metadata output object * @@ -2322,14 +2360,20 @@ void AvmTraceBuilder::op_sstore(uint8_t indirect, uint32_t src_offset, uint32_t op_jump(old_pc + 1); } -void AvmTraceBuilder::op_note_hash_exists(uint8_t indirect, uint32_t note_hash_offset, uint32_t dest_offset) +void AvmTraceBuilder::op_note_hash_exists(uint8_t indirect, + uint32_t note_hash_offset, + uint32_t leaf_index_offset, + uint32_t dest_offset) { auto const clk = static_cast(main_trace.size()) + 1; + auto leaf_index = unconstrained_read_from_memory(leaf_index_offset); Row row = - create_kernel_output_opcode_with_set_metadata_output_from_hint(indirect, clk, note_hash_offset, dest_offset); - kernel_trace_builder.op_note_hash_exists( - clk, side_effect_counter, row.main_ia, /*safe*/ static_cast(row.main_ib)); + create_kernel_output_opcode_for_leaf_index(indirect, clk, note_hash_offset, dest_offset, uint32_t(leaf_index)); + kernel_trace_builder.op_note_hash_exists(clk, + /*side_effect_counter*/ uint32_t(leaf_index), + row.main_ia, + /*safe*/ static_cast(row.main_ib)); row.main_sel_op_note_hash_exists = FF(1); // Constrain gas cost @@ -2338,7 +2382,6 @@ void AvmTraceBuilder::op_note_hash_exists(uint8_t indirect, uint32_t note_hash_o main_trace.push_back(row); debug("note_hash_exists side-effect cnt: ", side_effect_counter); - side_effect_counter++; } void AvmTraceBuilder::op_emit_note_hash(uint8_t indirect, uint32_t note_hash_offset) @@ -2394,13 +2437,17 @@ void AvmTraceBuilder::op_emit_nullifier(uint8_t indirect, uint32_t nullifier_off side_effect_counter++; } -void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint8_t indirect, uint32_t log_offset, uint32_t dest_offset) +void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint8_t indirect, + uint32_t log_offset, + uint32_t leaf_index_offset, + uint32_t dest_offset) { auto const clk = static_cast(main_trace.size()) + 1; - Row row = create_kernel_output_opcode_with_set_metadata_output_from_hint(indirect, clk, log_offset, dest_offset); + auto leaf_index = unconstrained_read_from_memory(leaf_index_offset); + Row row = create_kernel_output_opcode_for_leaf_index(indirect, clk, log_offset, dest_offset, uint32_t(leaf_index)); kernel_trace_builder.op_l1_to_l2_msg_exists( - clk, side_effect_counter, row.main_ia, /*safe*/ static_cast(row.main_ib)); + clk, uint32_t(leaf_index) /*side_effect_counter*/, row.main_ia, /*safe*/ static_cast(row.main_ib)); row.main_sel_op_l1_to_l2_msg_exists = FF(1); // Constrain gas cost @@ -2409,7 +2456,6 @@ void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint8_t indirect, uint32_t log_offs main_trace.push_back(row); debug("l1_to_l2_msg_exists side-effect cnt: ", side_effect_counter); - side_effect_counter++; } void AvmTraceBuilder::op_get_contract_instance(uint8_t indirect, uint32_t address_offset, uint32_t dst_offset) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp index 5e5c3fdec2e..22f446931d9 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp @@ -121,11 +121,17 @@ class AvmTraceBuilder { // World State void op_sload(uint8_t indirect, uint32_t slot_offset, uint32_t size, uint32_t dest_offset); void op_sstore(uint8_t indirect, uint32_t src_offset, uint32_t size, uint32_t slot_offset); - void op_note_hash_exists(uint8_t indirect, uint32_t note_hash_offset, uint32_t dest_offset); + void op_note_hash_exists(uint8_t indirect, + uint32_t note_hash_offset, + uint32_t leaf_index_offset, + uint32_t dest_offset); void op_emit_note_hash(uint8_t indirect, uint32_t note_hash_offset); void op_nullifier_exists(uint8_t indirect, uint32_t nullifier_offset, uint32_t dest_offset); void op_emit_nullifier(uint8_t indirect, uint32_t nullifier_offset); - void op_l1_to_l2_msg_exists(uint8_t indirect, uint32_t log_offset, uint32_t dest_offset); + void op_l1_to_l2_msg_exists(uint8_t indirect, + uint32_t log_offset, + uint32_t leaf_index_offset, + uint32_t dest_offset); void op_get_contract_instance(uint8_t indirect, uint32_t address_offset, uint32_t dst_offset); // Accrued Substate @@ -231,6 +237,9 @@ class AvmTraceBuilder { uint32_t data_offset, uint32_t metadata_offset); + Row create_kernel_output_opcode_for_leaf_index( + uint8_t indirect, uint32_t clk, uint32_t data_offset, uint32_t metadata_offset, uint32_t leaf_index); + Row create_kernel_output_opcode_with_set_value_from_hint(uint8_t indirect, uint32_t clk, uint32_t data_offset, diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 7e7dc09ab63..3e906aff1b6 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -151,6 +151,11 @@ export class SimulatorOracle implements DBOracle { return await this.aztecNode.findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, commitment); } + // We need this in public as part of the EXISTS calls - but isn't used in private + public getCommitmentValue(_leafIndex: bigint): Promise { + throw new Error('Unimplemented in private!'); + } + async getNullifierIndex(nullifier: Fr) { return await this.aztecNode.findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier); } diff --git a/yarn-project/simulator/src/avm/avm_simulator.test.ts b/yarn-project/simulator/src/avm/avm_simulator.test.ts index 7118684483d..48c658325a2 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.test.ts @@ -401,11 +401,11 @@ describe('AVM simulator: transpiled Noir contracts', () => { const results = await new AvmSimulator(context).executeBytecode(bytecode); expect(results.reverted).toBe(false); expect(results.output).toEqual([expectFound ? Fr.ONE : Fr.ZERO]); - + const expectedValue = results.output[0].toNumber() === 1 ? value0 : Fr.ZERO; expect(trace.traceNoteHashCheck).toHaveBeenCalledTimes(1); expect(trace.traceNoteHashCheck).toHaveBeenCalledWith( storageAddress, - /*noteHash=*/ value0, + /*noteHash=*/ expectedValue, leafIndex, /*exists=*/ expectFound, ); @@ -467,9 +467,13 @@ describe('AVM simulator: transpiled Noir contracts', () => { expect(results.output).toEqual([expectFound ? Fr.ONE : Fr.ZERO]); expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledTimes(1); + let expectedValue = results.output[0].toNumber() === 1 ? value0 : value1; + if (mockAtLeafIndex === undefined) { + expectedValue = Fr.ZERO; + } expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledWith( address, - /*msgHash=*/ value0, + /*msgHash=*/ expectedValue, leafIndex, /*exists=*/ expectFound, ); diff --git a/yarn-project/simulator/src/avm/journal/journal.test.ts b/yarn-project/simulator/src/avm/journal/journal.test.ts index 9818c42be4b..f3c18188d12 100644 --- a/yarn-project/simulator/src/avm/journal/journal.test.ts +++ b/yarn-project/simulator/src/avm/journal/journal.test.ts @@ -79,7 +79,7 @@ describe('journal', () => { const exists = await persistableState.checkNoteHashExists(address, utxo, leafIndex); expect(exists).toEqual(false); expect(trace.traceNoteHashCheck).toHaveBeenCalledTimes(1); - expect(trace.traceNoteHashCheck).toHaveBeenCalledWith(address, utxo, leafIndex, exists); + expect(trace.traceNoteHashCheck).toHaveBeenCalledWith(address, Fr.ZERO, leafIndex, exists); }); it('checkNoteHashExists works for existing note hashes', async () => { @@ -126,7 +126,7 @@ describe('journal', () => { const exists = await persistableState.checkL1ToL2MessageExists(address, utxo, leafIndex); expect(exists).toEqual(false); expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledTimes(1); - expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledWith(address, utxo, leafIndex, exists); + expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledWith(address, Fr.ZERO, leafIndex, exists); }); it('checkL1ToL2MessageExists works for existing message', async () => { diff --git a/yarn-project/simulator/src/avm/journal/journal.ts b/yarn-project/simulator/src/avm/journal/journal.ts index f34a2832edd..2f869c76a7b 100644 --- a/yarn-project/simulator/src/avm/journal/journal.ts +++ b/yarn-project/simulator/src/avm/journal/journal.ts @@ -1,5 +1,5 @@ import { AztecAddress, type FunctionSelector, type Gas } from '@aztec/circuits.js'; -import { type Fr } from '@aztec/foundation/fields'; +import { Fr } from '@aztec/foundation/fields'; import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log'; import { SerializableContractInstance } from '@aztec/types/contracts'; @@ -122,10 +122,14 @@ export class AvmPersistableStateManager { * @returns true if the note hash exists at the given leaf index, false otherwise */ public async checkNoteHashExists(storageAddress: Fr, noteHash: Fr, leafIndex: Fr): Promise { - const gotLeafIndex = await this.hostStorage.commitmentsDb.getCommitmentIndex(noteHash); - const exists = gotLeafIndex === leafIndex.toBigInt(); - this.log.debug(`noteHashes(${storageAddress})@${noteHash} ?? leafIndex: ${leafIndex}, exists: ${exists}.`); - this.trace.traceNoteHashCheck(storageAddress, noteHash, leafIndex, exists); + const gotLeafValue = (await this.hostStorage.commitmentsDb.getCommitmentValue(leafIndex.toBigInt())) ?? Fr.ZERO; + const exists = gotLeafValue.equals(noteHash); + this.log.debug( + `noteHashes(${storageAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`, + ); + // TODO(8287): We still return exists here, but we need to transmit both the requested noteHash and the gotLeafValue + // such that the VM can constrain the equality and decide on exists based on that. + this.trace.traceNoteHashCheck(storageAddress, gotLeafValue, leafIndex, exists); return Promise.resolve(exists); } @@ -173,12 +177,14 @@ export class AvmPersistableStateManager { * @returns exists - whether the message exists in the L1 to L2 Messages tree */ public async checkL1ToL2MessageExists(contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr): Promise { - const valueAtIndex = await this.hostStorage.commitmentsDb.getL1ToL2LeafValue(msgLeafIndex.toBigInt()); - const exists = valueAtIndex?.equals(msgHash) ?? false; + const valueAtIndex = (await this.hostStorage.commitmentsDb.getL1ToL2LeafValue(msgLeafIndex.toBigInt())) ?? Fr.ZERO; + const exists = valueAtIndex.equals(msgHash); this.log.debug( `l1ToL2Messages(@${msgLeafIndex}) ?? exists: ${exists}, expected: ${msgHash}, found: ${valueAtIndex}.`, ); - this.trace.traceL1ToL2MessageCheck(contractAddress, msgHash, msgLeafIndex, exists); + // TODO(8287): We still return exists here, but we need to transmit both the requested msgHash and the value + // such that the VM can constrain the equality and decide on exists based on that. + this.trace.traceL1ToL2MessageCheck(contractAddress, valueAtIndex, msgLeafIndex, exists); return Promise.resolve(exists); } diff --git a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts index dd1e638d6a4..aab2ae6efa6 100644 --- a/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/accrued_substate.test.ts @@ -98,10 +98,11 @@ describe('Accrued Substate', () => { const gotExists = context.machineState.memory.getAs(existsOffset); expect(gotExists).toEqual(new Uint8(expectFound ? 1 : 0)); + const expectedValue = gotExists.toNumber() === 1 ? value0 : Fr.ZERO; expect(trace.traceNoteHashCheck).toHaveBeenCalledTimes(1); expect(trace.traceNoteHashCheck).toHaveBeenCalledWith( storageAddress, - /*noteHash=*/ value0, + /*noteHash=*/ expectedValue, leafIndex, /*exists=*/ expectFound, ); @@ -290,9 +291,14 @@ describe('Accrued Substate', () => { expect(gotExists).toEqual(new Uint8(expectFound ? 1 : 0)); expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledTimes(1); + // The expected value to trace depends on a) if we found it and b) if it is undefined + let expectedValue = gotExists.toNumber() === 1 ? value0 : value1; + if (mockAtLeafIndex === undefined) { + expectedValue = Fr.ZERO; + } expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledWith( address, - /*msgHash=*/ value0, + /*msgHash=*/ expectedValue, leafIndex, /*exists=*/ expectFound, ); diff --git a/yarn-project/simulator/src/avm/test_utils.ts b/yarn-project/simulator/src/avm/test_utils.ts index ce65116d5b8..f7dda9f6593 100644 --- a/yarn-project/simulator/src/avm/test_utils.ts +++ b/yarn-project/simulator/src/avm/test_utils.ts @@ -28,8 +28,15 @@ export function mockStorageReadWithMap(hs: HostStorage, mockedStorage: Map).getCommitmentIndex.mockResolvedValue(leafIndex.toBigInt()); +export function mockNoteHashExists(hs: HostStorage, _leafIndex: Fr, value?: Fr) { + (hs.commitmentsDb as jest.Mocked).getCommitmentValue.mockImplementation((index: bigint) => { + if (index == _leafIndex.toBigInt()) { + return Promise.resolve(value); + } else { + // This is ok for now since the traceing functions handle it + return Promise.resolve(undefined); + } + }); } export function mockNullifierExists(hs: HostStorage, leafIndex: Fr, _value?: Fr) { diff --git a/yarn-project/simulator/src/public/db_interfaces.ts b/yarn-project/simulator/src/public/db_interfaces.ts index ca44044de82..dfa168b66bb 100644 --- a/yarn-project/simulator/src/public/db_interfaces.ts +++ b/yarn-project/simulator/src/public/db_interfaces.ts @@ -100,6 +100,13 @@ export interface CommitmentsDB { */ getCommitmentIndex(commitment: Fr): Promise; + /** + * Gets commitment in the note hash tree given a leaf index. + * @param leafIndex - the leaf to look up. + * @returns - The commitment at that index. Undefined if leaf index is not found. + */ + getCommitmentValue(leafIndex: bigint): Promise; + /** * Gets the index of a nullifier in the nullifier tree. * @param nullifier - The nullifier. diff --git a/yarn-project/simulator/src/public/public_db_sources.ts b/yarn-project/simulator/src/public/public_db_sources.ts index da99bb02d4e..662ccae10c3 100644 --- a/yarn-project/simulator/src/public/public_db_sources.ts +++ b/yarn-project/simulator/src/public/public_db_sources.ts @@ -308,6 +308,17 @@ export class WorldStateDB implements CommitmentsDB { return index; } + public async getCommitmentValue(leafIndex: bigint): Promise { + const timer = new Timer(); + const leafValue = await this.db.getLeafValue(MerkleTreeId.NOTE_HASH_TREE, leafIndex); + this.log.debug(`[DB] Fetched commitment leaf value`, { + eventName: 'public-db-access', + duration: timer.ms(), + operation: 'get-commitment-leaf-value', + } satisfies PublicDBAccessStats); + return leafValue; + } + public async getNullifierIndex(nullifier: Fr): Promise { const timer = new Timer(); const index = await this.db.findLeafIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBuffer()); diff --git a/yarn-project/simulator/src/public/side_effect_trace.test.ts b/yarn-project/simulator/src/public/side_effect_trace.test.ts index 8ea72de1493..5ee1469f161 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.test.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.test.ts @@ -94,7 +94,6 @@ describe('Side Effect Trace', () => { it('Should trace note hash checks', () => { const exists = true; trace.traceNoteHashCheck(address, utxo, leafIndex, exists); - expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); expect(pxResult.noteHashReadRequests).toEqual([ @@ -106,7 +105,7 @@ describe('Side Effect Trace', () => { leafIndex, }, ]); - expect(pxResult.avmCircuitHints.noteHashExists.items).toEqual([{ key: startCounterFr, value: new Fr(exists) }]); + expect(pxResult.avmCircuitHints.noteHashExists.items).toEqual([{ key: leafIndex, value: new Fr(exists) }]); }); it('Should trace note hashes', () => { @@ -174,7 +173,6 @@ describe('Side Effect Trace', () => { it('Should trace L1ToL2 Message checks', () => { const exists = true; trace.traceL1ToL2MessageCheck(address, utxo, leafIndex, exists); - expect(trace.getCounter()).toBe(startCounterPlus1); const pxResult = toPxResult(trace); expect(pxResult.l1ToL2MsgReadRequests).toEqual([ @@ -185,7 +183,7 @@ describe('Side Effect Trace', () => { ]); expect(pxResult.avmCircuitHints.l1ToL2MessageExists.items).toEqual([ { - key: startCounterFr, + key: leafIndex, value: new Fr(exists), }, ]); @@ -246,7 +244,6 @@ describe('Side Effect Trace', () => { nestedTrace.tracePublicStorageWrite(address, slot, value); testCounter++; nestedTrace.traceNoteHashCheck(address, utxo, leafIndex, existsDefault); - testCounter++; nestedTrace.traceNewNoteHash(address, utxo); testCounter++; nestedTrace.traceNullifierCheck(address, utxo, leafIndex, /*exists=*/ true, isPending); @@ -256,7 +253,6 @@ describe('Side Effect Trace', () => { nestedTrace.traceNewNullifier(address, utxo); testCounter++; nestedTrace.traceL1ToL2MessageCheck(address, utxo, leafIndex, existsDefault); - testCounter++; nestedTrace.traceNewL2ToL1Message(recipient, content); testCounter++; nestedTrace.traceUnencryptedLog(address, log); diff --git a/yarn-project/simulator/src/public/side_effect_trace.ts b/yarn-project/simulator/src/public/side_effect_trace.ts index c26c5fdd53b..5d7b0a33a70 100644 --- a/yarn-project/simulator/src/public/side_effect_trace.ts +++ b/yarn-project/simulator/src/public/side_effect_trace.ts @@ -105,6 +105,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { this.incrementSideEffectCounter(); } + // TODO(8287): _exists can be removed once we have the vm properly handling the equality check public traceNoteHashCheck(_storageAddress: Fr, noteHash: Fr, leafIndex: Fr, exists: boolean) { // TODO(4805): check if some threshold is reached for max note hash checks // NOTE: storageAddress is unused but will be important when an AVM circuit processes an entire enqueued call @@ -112,10 +113,8 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { // is in fact checking the leaf indicated by the user this.noteHashReadRequests.push(new TreeLeafReadRequest(noteHash, leafIndex)); this.avmCircuitHints.noteHashExists.items.push( - new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)), + new AvmKeyValueHint(/*key=*/ new Fr(leafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO), ); - this.logger.debug(`NOTE_HASH_CHECK cnt: ${this.sideEffectCounter}`); - this.incrementSideEffectCounter(); } public traceNewNoteHash(_storageAddress: Fr, noteHash: Fr) { @@ -155,6 +154,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { this.incrementSideEffectCounter(); } + // TODO(8287): _exists can be removed once we have the vm properly handling the equality check public traceL1ToL2MessageCheck(_contractAddress: Fr, msgHash: Fr, msgLeafIndex: Fr, exists: boolean) { // TODO(4805): check if some threshold is reached for max message reads // NOTE: contractAddress is unused but will be important when an AVM circuit processes an entire enqueued call @@ -162,10 +162,8 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface { // is in fact checking the leaf indicated by the user this.l1ToL2MsgReadRequests.push(new TreeLeafReadRequest(msgHash, msgLeafIndex)); this.avmCircuitHints.l1ToL2MessageExists.items.push( - new AvmKeyValueHint(/*key=*/ new Fr(this.sideEffectCounter), /*value=*/ new Fr(exists ? 1 : 0)), + new AvmKeyValueHint(/*key=*/ new Fr(msgLeafIndex), /*value=*/ exists ? Fr.ONE : Fr.ZERO), ); - this.logger.debug(`L1_TO_L2_MSG_CHECK cnt: ${this.sideEffectCounter}`); - this.incrementSideEffectCounter(); } public traceNewL2ToL1Message(recipient: Fr, content: Fr) { From 5bddcfb41e5c97d698b2b64201bfd9cb50f76f64 Mon Sep 17 00:00:00 2001 From: Leila Wang Date: Wed, 4 Sep 2024 11:55:45 +0000 Subject: [PATCH 5/5] Regenerate. --- .../barretenberg/vm/avm/generated/flavor.cpp | 1476 ++++++++--------- .../barretenberg/vm/avm/generated/flavor.hpp | 14 +- 2 files changed, 723 insertions(+), 767 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index b5ff35f8ff1..f54c2b41054 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -31,766 +31,722 @@ AvmFlavor::AllConstRefValues::AllConstRefValues( , alu_a_lo(il[23]) , alu_b_hi(il[24]) , alu_b_lo(il[25]) - , alu_borrow(il[26]) - , alu_cf(il[27]) - , alu_clk(il[28]) - , alu_cmp_rng_ctr(il[29]) - , alu_div_u16_r0(il[30]) - , alu_div_u16_r1(il[31]) - , alu_div_u16_r2(il[32]) - , alu_div_u16_r3(il[33]) - , alu_div_u16_r4(il[34]) - , alu_div_u16_r5(il[35]) - , alu_div_u16_r6(il[36]) - , alu_div_u16_r7(il[37]) - , alu_divisor_hi(il[38]) - , alu_divisor_lo(il[39]) - , alu_ff_tag(il[40]) - , alu_ia(il[41]) - , alu_ib(il[42]) - , alu_ic(il[43]) - , alu_in_tag(il[44]) - , alu_op_add(il[45]) - , alu_op_cast(il[46]) - , alu_op_cast_prev(il[47]) - , alu_op_div(il[48]) - , alu_op_div_a_lt_b(il[49]) - , alu_op_div_std(il[50]) - , alu_op_eq(il[51]) - , alu_op_eq_diff_inv(il[52]) - , alu_op_lt(il[53]) - , alu_op_lte(il[54]) - , alu_op_mul(il[55]) - , alu_op_not(il[56]) - , alu_op_shl(il[57]) - , alu_op_shr(il[58]) - , alu_op_sub(il[59]) - , alu_p_a_borrow(il[60]) - , alu_p_b_borrow(il[61]) - , alu_p_sub_a_hi(il[62]) - , alu_p_sub_a_lo(il[63]) - , alu_p_sub_b_hi(il[64]) - , alu_p_sub_b_lo(il[65]) - , alu_partial_prod_hi(il[66]) - , alu_partial_prod_lo(il[67]) - , alu_quotient_hi(il[68]) - , alu_quotient_lo(il[69]) - , alu_remainder(il[70]) - , alu_res_hi(il[71]) - , alu_res_lo(il[72]) - , alu_sel_alu(il[73]) - , alu_sel_cmp(il[74]) - , alu_sel_div_rng_chk(il[75]) - , alu_sel_rng_chk(il[76]) - , alu_sel_rng_chk_lookup(il[77]) - , alu_sel_shift_which(il[78]) - , alu_shift_lt_bit_len(il[79]) - , alu_t_sub_s_bits(il[80]) - , alu_two_pow_s(il[81]) - , alu_two_pow_t_sub_s(il[82]) - , alu_u128_tag(il[83]) - , alu_u16_r0(il[84]) - , alu_u16_r1(il[85]) - , alu_u16_r10(il[86]) - , alu_u16_r11(il[87]) - , alu_u16_r12(il[88]) - , alu_u16_r13(il[89]) - , alu_u16_r14(il[90]) - , alu_u16_r2(il[91]) - , alu_u16_r3(il[92]) - , alu_u16_r4(il[93]) - , alu_u16_r5(il[94]) - , alu_u16_r6(il[95]) - , alu_u16_r7(il[96]) - , alu_u16_r8(il[97]) - , alu_u16_r9(il[98]) - , alu_u16_tag(il[99]) - , alu_u32_tag(il[100]) - , alu_u64_tag(il[101]) - , alu_u8_r0(il[102]) - , alu_u8_r1(il[103]) - , alu_u8_tag(il[104]) - , binary_acc_ia(il[105]) - , binary_acc_ib(il[106]) - , binary_acc_ic(il[107]) - , binary_clk(il[108]) - , binary_ia_bytes(il[109]) - , binary_ib_bytes(il[110]) - , binary_ic_bytes(il[111]) - , binary_in_tag(il[112]) - , binary_mem_tag_ctr(il[113]) - , binary_mem_tag_ctr_inv(il[114]) - , binary_op_id(il[115]) - , binary_sel_bin(il[116]) - , binary_start(il[117]) - , conversion_clk(il[118]) - , conversion_input(il[119]) - , conversion_num_limbs(il[120]) - , conversion_radix(il[121]) - , conversion_sel_to_radix_le(il[122]) - , keccakf1600_clk(il[123]) - , keccakf1600_input(il[124]) - , keccakf1600_output(il[125]) - , keccakf1600_sel_keccakf1600(il[126]) - , main_abs_da_rem_gas_hi(il[127]) - , main_abs_da_rem_gas_lo(il[128]) - , main_abs_l2_rem_gas_hi(il[129]) - , main_abs_l2_rem_gas_lo(il[130]) - , main_alu_in_tag(il[131]) - , main_base_da_gas_op_cost(il[132]) - , main_base_l2_gas_op_cost(il[133]) - , main_bin_op_id(il[134]) - , main_call_ptr(il[135]) - , main_da_gas_remaining(il[136]) - , main_da_out_of_gas(il[137]) - , main_dyn_da_gas_op_cost(il[138]) - , main_dyn_gas_multiplier(il[139]) - , main_dyn_l2_gas_op_cost(il[140]) - , main_emit_l2_to_l1_msg_write_offset(il[141]) - , main_emit_note_hash_write_offset(il[142]) - , main_emit_nullifier_write_offset(il[143]) - , main_emit_unencrypted_log_write_offset(il[144]) - , main_ia(il[145]) - , main_ib(il[146]) - , main_ic(il[147]) - , main_id(il[148]) - , main_id_zero(il[149]) - , main_ind_addr_a(il[150]) - , main_ind_addr_b(il[151]) - , main_ind_addr_c(il[152]) - , main_ind_addr_d(il[153]) - , main_internal_return_ptr(il[154]) - , main_inv(il[155]) - , main_kernel_in_offset(il[156]) - , main_kernel_out_offset(il[157]) - , main_l1_to_l2_msg_exists_write_offset(il[158]) - , main_l2_gas_remaining(il[159]) - , main_l2_out_of_gas(il[160]) - , main_mem_addr_a(il[161]) - , main_mem_addr_b(il[162]) - , main_mem_addr_c(il[163]) - , main_mem_addr_d(il[164]) - , main_note_hash_exist_write_offset(il[165]) - , main_nullifier_exists_write_offset(il[166]) - , main_nullifier_non_exists_write_offset(il[167]) - , main_op_err(il[168]) - , main_opcode_val(il[169]) - , main_pc(il[170]) - , main_r_in_tag(il[171]) - , main_rwa(il[172]) - , main_rwb(il[173]) - , main_rwc(il[174]) - , main_rwd(il[175]) - , main_sel_alu(il[176]) - , main_sel_bin(il[177]) - , main_sel_calldata(il[178]) - , main_sel_execution_row(il[179]) - , main_sel_kernel_inputs(il[180]) - , main_sel_kernel_out(il[181]) - , main_sel_last(il[182]) - , main_sel_mem_op_a(il[183]) - , main_sel_mem_op_b(il[184]) - , main_sel_mem_op_c(il[185]) - , main_sel_mem_op_d(il[186]) - , main_sel_mov_ia_to_ic(il[187]) - , main_sel_mov_ib_to_ic(il[188]) - , main_sel_op_add(il[189]) - , main_sel_op_address(il[190]) - , main_sel_op_and(il[191]) - , main_sel_op_block_number(il[192]) - , main_sel_op_calldata_copy(il[193]) - , main_sel_op_cast(il[194]) - , main_sel_op_chain_id(il[195]) - , main_sel_op_cmov(il[196]) - , main_sel_op_coinbase(il[197]) - , main_sel_op_dagasleft(il[198]) - , main_sel_op_div(il[199]) - , main_sel_op_ecadd(il[200]) - , main_sel_op_emit_l2_to_l1_msg(il[201]) - , main_sel_op_emit_note_hash(il[202]) - , main_sel_op_emit_nullifier(il[203]) - , main_sel_op_emit_unencrypted_log(il[204]) - , main_sel_op_eq(il[205]) - , main_sel_op_external_call(il[206]) - , main_sel_op_external_return(il[207]) - , main_sel_op_external_revert(il[208]) - , main_sel_op_fdiv(il[209]) - , main_sel_op_fee_per_da_gas(il[210]) - , main_sel_op_fee_per_l2_gas(il[211]) - , main_sel_op_function_selector(il[212]) - , main_sel_op_get_contract_instance(il[213]) - , main_sel_op_internal_call(il[214]) - , main_sel_op_internal_return(il[215]) - , main_sel_op_jump(il[216]) - , main_sel_op_jumpi(il[217]) - , main_sel_op_keccak(il[218]) - , main_sel_op_l1_to_l2_msg_exists(il[219]) - , main_sel_op_l2gasleft(il[220]) - , main_sel_op_lt(il[221]) - , main_sel_op_lte(il[222]) - , main_sel_op_mov(il[223]) - , main_sel_op_msm(il[224]) - , main_sel_op_mul(il[225]) - , main_sel_op_not(il[226]) - , main_sel_op_note_hash_exists(il[227]) - , main_sel_op_nullifier_exists(il[228]) - , main_sel_op_or(il[229]) - , main_sel_op_pedersen(il[230]) - , main_sel_op_pedersen_commit(il[231]) - , main_sel_op_poseidon2(il[232]) - , main_sel_op_radix_le(il[233]) - , main_sel_op_sender(il[234]) - , main_sel_op_set(il[235]) - , main_sel_op_sha256(il[236]) - , main_sel_op_shl(il[237]) - , main_sel_op_shr(il[238]) - , main_sel_op_sload(il[239]) - , main_sel_op_sstore(il[240]) - , main_sel_op_storage_address(il[241]) - , main_sel_op_sub(il[242]) - , main_sel_op_timestamp(il[243]) - , main_sel_op_transaction_fee(il[244]) - , main_sel_op_version(il[245]) - , main_sel_op_xor(il[246]) - , main_sel_q_kernel_lookup(il[247]) - , main_sel_q_kernel_output_lookup(il[248]) - , main_sel_resolve_ind_addr_a(il[249]) - , main_sel_resolve_ind_addr_b(il[250]) - , main_sel_resolve_ind_addr_c(il[251]) - , main_sel_resolve_ind_addr_d(il[252]) - , main_sel_returndata(il[253]) - , main_sel_rng_16(il[254]) - , main_sel_rng_8(il[255]) - , main_sel_slice_gadget(il[256]) - , main_side_effect_counter(il[257]) - , main_sload_write_offset(il[258]) - , main_space_id(il[259]) - , main_sstore_write_offset(il[260]) - , main_tag_err(il[261]) - , main_w_in_tag(il[262]) - , mem_addr(il[263]) - , mem_clk(il[264]) - , mem_diff_hi(il[265]) - , mem_diff_lo(il[266]) - , mem_diff_mid(il[267]) - , mem_glob_addr(il[268]) - , mem_last(il[269]) - , mem_lastAccess(il[270]) - , mem_one_min_inv(il[271]) - , mem_r_in_tag(il[272]) - , mem_rw(il[273]) - , mem_sel_mem(il[274]) - , mem_sel_mov_ia_to_ic(il[275]) - , mem_sel_mov_ib_to_ic(il[276]) - , mem_sel_op_a(il[277]) - , mem_sel_op_b(il[278]) - , mem_sel_op_c(il[279]) - , mem_sel_op_cmov(il[280]) - , mem_sel_op_d(il[281]) - , mem_sel_op_poseidon_read_a(il[282]) - , mem_sel_op_poseidon_read_b(il[283]) - , mem_sel_op_poseidon_read_c(il[284]) - , mem_sel_op_poseidon_read_d(il[285]) - , mem_sel_op_poseidon_write_a(il[286]) - , mem_sel_op_poseidon_write_b(il[287]) - , mem_sel_op_poseidon_write_c(il[288]) - , mem_sel_op_poseidon_write_d(il[289]) - , mem_sel_op_slice(il[290]) - , mem_sel_resolve_ind_addr_a(il[291]) - , mem_sel_resolve_ind_addr_b(il[292]) - , mem_sel_resolve_ind_addr_c(il[293]) - , mem_sel_resolve_ind_addr_d(il[294]) - , mem_sel_rng_chk(il[295]) - , mem_skip_check_tag(il[296]) - , mem_space_id(il[297]) - , mem_tag(il[298]) - , mem_tag_err(il[299]) - , mem_tsp(il[300]) - , mem_val(il[301]) - , mem_w_in_tag(il[302]) - , pedersen_clk(il[303]) - , pedersen_input(il[304]) - , pedersen_output(il[305]) - , pedersen_sel_pedersen(il[306]) - , poseidon2_B_10_0(il[307]) - , poseidon2_B_10_1(il[308]) - , poseidon2_B_10_2(il[309]) - , poseidon2_B_10_3(il[310]) - , poseidon2_B_11_0(il[311]) - , poseidon2_B_11_1(il[312]) - , poseidon2_B_11_2(il[313]) - , poseidon2_B_11_3(il[314]) - , poseidon2_B_12_0(il[315]) - , poseidon2_B_12_1(il[316]) - , poseidon2_B_12_2(il[317]) - , poseidon2_B_12_3(il[318]) - , poseidon2_B_13_0(il[319]) - , poseidon2_B_13_1(il[320]) - , poseidon2_B_13_2(il[321]) - , poseidon2_B_13_3(il[322]) - , poseidon2_B_14_0(il[323]) - , poseidon2_B_14_1(il[324]) - , poseidon2_B_14_2(il[325]) - , poseidon2_B_14_3(il[326]) - , poseidon2_B_15_0(il[327]) - , poseidon2_B_15_1(il[328]) - , poseidon2_B_15_2(il[329]) - , poseidon2_B_15_3(il[330]) - , poseidon2_B_16_0(il[331]) - , poseidon2_B_16_1(il[332]) - , poseidon2_B_16_2(il[333]) - , poseidon2_B_16_3(il[334]) - , poseidon2_B_17_0(il[335]) - , poseidon2_B_17_1(il[336]) - , poseidon2_B_17_2(il[337]) - , poseidon2_B_17_3(il[338]) - , poseidon2_B_18_0(il[339]) - , poseidon2_B_18_1(il[340]) - , poseidon2_B_18_2(il[341]) - , poseidon2_B_18_3(il[342]) - , poseidon2_B_19_0(il[343]) - , poseidon2_B_19_1(il[344]) - , poseidon2_B_19_2(il[345]) - , poseidon2_B_19_3(il[346]) - , poseidon2_B_20_0(il[347]) - , poseidon2_B_20_1(il[348]) - , poseidon2_B_20_2(il[349]) - , poseidon2_B_20_3(il[350]) - , poseidon2_B_21_0(il[351]) - , poseidon2_B_21_1(il[352]) - , poseidon2_B_21_2(il[353]) - , poseidon2_B_21_3(il[354]) - , poseidon2_B_22_0(il[355]) - , poseidon2_B_22_1(il[356]) - , poseidon2_B_22_2(il[357]) - , poseidon2_B_22_3(il[358]) - , poseidon2_B_23_0(il[359]) - , poseidon2_B_23_1(il[360]) - , poseidon2_B_23_2(il[361]) - , poseidon2_B_23_3(il[362]) - , poseidon2_B_24_0(il[363]) - , poseidon2_B_24_1(il[364]) - , poseidon2_B_24_2(il[365]) - , poseidon2_B_24_3(il[366]) - , poseidon2_B_25_0(il[367]) - , poseidon2_B_25_1(il[368]) - , poseidon2_B_25_2(il[369]) - , poseidon2_B_25_3(il[370]) - , poseidon2_B_26_0(il[371]) - , poseidon2_B_26_1(il[372]) - , poseidon2_B_26_2(il[373]) - , poseidon2_B_26_3(il[374]) - , poseidon2_B_27_0(il[375]) - , poseidon2_B_27_1(il[376]) - , poseidon2_B_27_2(il[377]) - , poseidon2_B_27_3(il[378]) - , poseidon2_B_28_0(il[379]) - , poseidon2_B_28_1(il[380]) - , poseidon2_B_28_2(il[381]) - , poseidon2_B_28_3(il[382]) - , poseidon2_B_29_0(il[383]) - , poseidon2_B_29_1(il[384]) - , poseidon2_B_29_2(il[385]) - , poseidon2_B_29_3(il[386]) - , poseidon2_B_30_0(il[387]) - , poseidon2_B_30_1(il[388]) - , poseidon2_B_30_2(il[389]) - , poseidon2_B_30_3(il[390]) - , poseidon2_B_31_0(il[391]) - , poseidon2_B_31_1(il[392]) - , poseidon2_B_31_2(il[393]) - , poseidon2_B_31_3(il[394]) - , poseidon2_B_32_0(il[395]) - , poseidon2_B_32_1(il[396]) - , poseidon2_B_32_2(il[397]) - , poseidon2_B_32_3(il[398]) - , poseidon2_B_33_0(il[399]) - , poseidon2_B_33_1(il[400]) - , poseidon2_B_33_2(il[401]) - , poseidon2_B_33_3(il[402]) - , poseidon2_B_34_0(il[403]) - , poseidon2_B_34_1(il[404]) - , poseidon2_B_34_2(il[405]) - , poseidon2_B_34_3(il[406]) - , poseidon2_B_35_0(il[407]) - , poseidon2_B_35_1(il[408]) - , poseidon2_B_35_2(il[409]) - , poseidon2_B_35_3(il[410]) - , poseidon2_B_36_0(il[411]) - , poseidon2_B_36_1(il[412]) - , poseidon2_B_36_2(il[413]) - , poseidon2_B_36_3(il[414]) - , poseidon2_B_37_0(il[415]) - , poseidon2_B_37_1(il[416]) - , poseidon2_B_37_2(il[417]) - , poseidon2_B_37_3(il[418]) - , poseidon2_B_38_0(il[419]) - , poseidon2_B_38_1(il[420]) - , poseidon2_B_38_2(il[421]) - , poseidon2_B_38_3(il[422]) - , poseidon2_B_39_0(il[423]) - , poseidon2_B_39_1(il[424]) - , poseidon2_B_39_2(il[425]) - , poseidon2_B_39_3(il[426]) - , poseidon2_B_40_0(il[427]) - , poseidon2_B_40_1(il[428]) - , poseidon2_B_40_2(il[429]) - , poseidon2_B_40_3(il[430]) - , poseidon2_B_41_0(il[431]) - , poseidon2_B_41_1(il[432]) - , poseidon2_B_41_2(il[433]) - , poseidon2_B_41_3(il[434]) - , poseidon2_B_42_0(il[435]) - , poseidon2_B_42_1(il[436]) - , poseidon2_B_42_2(il[437]) - , poseidon2_B_42_3(il[438]) - , poseidon2_B_43_0(il[439]) - , poseidon2_B_43_1(il[440]) - , poseidon2_B_43_2(il[441]) - , poseidon2_B_43_3(il[442]) - , poseidon2_B_44_0(il[443]) - , poseidon2_B_44_1(il[444]) - , poseidon2_B_44_2(il[445]) - , poseidon2_B_44_3(il[446]) - , poseidon2_B_45_0(il[447]) - , poseidon2_B_45_1(il[448]) - , poseidon2_B_45_2(il[449]) - , poseidon2_B_45_3(il[450]) - , poseidon2_B_46_0(il[451]) - , poseidon2_B_46_1(il[452]) - , poseidon2_B_46_2(il[453]) - , poseidon2_B_46_3(il[454]) - , poseidon2_B_47_0(il[455]) - , poseidon2_B_47_1(il[456]) - , poseidon2_B_47_2(il[457]) - , poseidon2_B_47_3(il[458]) - , poseidon2_B_48_0(il[459]) - , poseidon2_B_48_1(il[460]) - , poseidon2_B_48_2(il[461]) - , poseidon2_B_48_3(il[462]) - , poseidon2_B_49_0(il[463]) - , poseidon2_B_49_1(il[464]) - , poseidon2_B_49_2(il[465]) - , poseidon2_B_49_3(il[466]) - , poseidon2_B_4_0(il[467]) - , poseidon2_B_4_1(il[468]) - , poseidon2_B_4_2(il[469]) - , poseidon2_B_4_3(il[470]) - , poseidon2_B_50_0(il[471]) - , poseidon2_B_50_1(il[472]) - , poseidon2_B_50_2(il[473]) - , poseidon2_B_50_3(il[474]) - , poseidon2_B_51_0(il[475]) - , poseidon2_B_51_1(il[476]) - , poseidon2_B_51_2(il[477]) - , poseidon2_B_51_3(il[478]) - , poseidon2_B_52_0(il[479]) - , poseidon2_B_52_1(il[480]) - , poseidon2_B_52_2(il[481]) - , poseidon2_B_52_3(il[482]) - , poseidon2_B_53_0(il[483]) - , poseidon2_B_53_1(il[484]) - , poseidon2_B_53_2(il[485]) - , poseidon2_B_53_3(il[486]) - , poseidon2_B_54_0(il[487]) - , poseidon2_B_54_1(il[488]) - , poseidon2_B_54_2(il[489]) - , poseidon2_B_54_3(il[490]) - , poseidon2_B_55_0(il[491]) - , poseidon2_B_55_1(il[492]) - , poseidon2_B_55_2(il[493]) - , poseidon2_B_55_3(il[494]) - , poseidon2_B_56_0(il[495]) - , poseidon2_B_56_1(il[496]) - , poseidon2_B_56_2(il[497]) - , poseidon2_B_56_3(il[498]) - , poseidon2_B_57_0(il[499]) - , poseidon2_B_57_1(il[500]) - , poseidon2_B_57_2(il[501]) - , poseidon2_B_57_3(il[502]) - , poseidon2_B_58_0(il[503]) - , poseidon2_B_58_1(il[504]) - , poseidon2_B_58_2(il[505]) - , poseidon2_B_58_3(il[506]) - , poseidon2_B_59_0(il[507]) - , poseidon2_B_59_1(il[508]) - , poseidon2_B_59_2(il[509]) - , poseidon2_B_59_3(il[510]) - , poseidon2_B_5_0(il[511]) - , poseidon2_B_5_1(il[512]) - , poseidon2_B_5_2(il[513]) - , poseidon2_B_5_3(il[514]) - , poseidon2_B_6_0(il[515]) - , poseidon2_B_6_1(il[516]) - , poseidon2_B_6_2(il[517]) - , poseidon2_B_6_3(il[518]) - , poseidon2_B_7_0(il[519]) - , poseidon2_B_7_1(il[520]) - , poseidon2_B_7_2(il[521]) - , poseidon2_B_7_3(il[522]) - , poseidon2_B_8_0(il[523]) - , poseidon2_B_8_1(il[524]) - , poseidon2_B_8_2(il[525]) - , poseidon2_B_8_3(il[526]) - , poseidon2_B_9_0(il[527]) - , poseidon2_B_9_1(il[528]) - , poseidon2_B_9_2(il[529]) - , poseidon2_B_9_3(il[530]) - , poseidon2_EXT_LAYER_4(il[531]) - , poseidon2_EXT_LAYER_5(il[532]) - , poseidon2_EXT_LAYER_6(il[533]) - , poseidon2_EXT_LAYER_7(il[534]) - , poseidon2_T_0_4(il[535]) - , poseidon2_T_0_5(il[536]) - , poseidon2_T_0_6(il[537]) - , poseidon2_T_0_7(il[538]) - , poseidon2_T_1_4(il[539]) - , poseidon2_T_1_5(il[540]) - , poseidon2_T_1_6(il[541]) - , poseidon2_T_1_7(il[542]) - , poseidon2_T_2_4(il[543]) - , poseidon2_T_2_5(il[544]) - , poseidon2_T_2_6(il[545]) - , poseidon2_T_2_7(il[546]) - , poseidon2_T_3_4(il[547]) - , poseidon2_T_3_5(il[548]) - , poseidon2_T_3_6(il[549]) - , poseidon2_T_3_7(il[550]) - , poseidon2_T_60_4(il[551]) - , poseidon2_T_60_5(il[552]) - , poseidon2_T_60_6(il[553]) - , poseidon2_T_60_7(il[554]) - , poseidon2_T_61_4(il[555]) - , poseidon2_T_61_5(il[556]) - , poseidon2_T_61_6(il[557]) - , poseidon2_T_61_7(il[558]) - , poseidon2_T_62_4(il[559]) - , poseidon2_T_62_5(il[560]) - , poseidon2_T_62_6(il[561]) - , poseidon2_T_62_7(il[562]) - , poseidon2_T_63_4(il[563]) - , poseidon2_T_63_5(il[564]) - , poseidon2_T_63_6(il[565]) - , poseidon2_T_63_7(il[566]) - , poseidon2_a_0(il[567]) - , poseidon2_a_1(il[568]) - , poseidon2_a_2(il[569]) - , poseidon2_a_3(il[570]) - , poseidon2_b_0(il[571]) - , poseidon2_b_1(il[572]) - , poseidon2_b_2(il[573]) - , poseidon2_b_3(il[574]) - , poseidon2_clk(il[575]) - , poseidon2_input_addr(il[576]) - , poseidon2_mem_addr_read_a(il[577]) - , poseidon2_mem_addr_read_b(il[578]) - , poseidon2_mem_addr_read_c(il[579]) - , poseidon2_mem_addr_read_d(il[580]) - , poseidon2_mem_addr_write_a(il[581]) - , poseidon2_mem_addr_write_b(il[582]) - , poseidon2_mem_addr_write_c(il[583]) - , poseidon2_mem_addr_write_d(il[584]) - , poseidon2_output_addr(il[585]) - , poseidon2_sel_poseidon_perm(il[586]) - , sha256_clk(il[587]) - , sha256_input(il[588]) - , sha256_output(il[589]) - , sha256_sel_sha256_compression(il[590]) - , sha256_state(il[591]) - , slice_addr(il[592]) - , slice_clk(il[593]) - , slice_cnt(il[594]) - , slice_col_offset(il[595]) - , slice_one_min_inv(il[596]) - , slice_sel_cd_cpy(il[597]) - , slice_sel_mem_active(il[598]) - , slice_sel_return(il[599]) - , slice_sel_start(il[600]) - , slice_space_id(il[601]) - , slice_val(il[602]) - , lookup_pow_2_0_counts(il[603]) - , lookup_pow_2_1_counts(il[604]) - , lookup_u8_0_counts(il[605]) - , lookup_u8_1_counts(il[606]) - , lookup_u16_0_counts(il[607]) - , lookup_u16_1_counts(il[608]) - , lookup_u16_2_counts(il[609]) - , lookup_u16_3_counts(il[610]) - , lookup_u16_4_counts(il[611]) - , lookup_u16_5_counts(il[612]) - , lookup_u16_6_counts(il[613]) - , lookup_u16_7_counts(il[614]) - , lookup_u16_8_counts(il[615]) - , lookup_u16_9_counts(il[616]) - , lookup_u16_10_counts(il[617]) - , lookup_u16_11_counts(il[618]) - , lookup_u16_12_counts(il[619]) - , lookup_u16_13_counts(il[620]) - , lookup_u16_14_counts(il[621]) - , lookup_div_u16_0_counts(il[622]) - , lookup_div_u16_1_counts(il[623]) - , lookup_div_u16_2_counts(il[624]) - , lookup_div_u16_3_counts(il[625]) - , lookup_div_u16_4_counts(il[626]) - , lookup_div_u16_5_counts(il[627]) - , lookup_div_u16_6_counts(il[628]) - , lookup_div_u16_7_counts(il[629]) - , lookup_byte_lengths_counts(il[630]) - , lookup_byte_operations_counts(il[631]) - , lookup_opcode_gas_counts(il[632]) - , range_check_l2_gas_hi_counts(il[633]) - , range_check_l2_gas_lo_counts(il[634]) - , range_check_da_gas_hi_counts(il[635]) - , range_check_da_gas_lo_counts(il[636]) - , kernel_output_lookup_counts(il[637]) - , lookup_into_kernel_counts(il[638]) - , lookup_cd_value_counts(il[639]) - , lookup_ret_value_counts(il[640]) - , incl_main_tag_err_counts(il[641]) - , incl_mem_tag_err_counts(il[642]) - , lookup_mem_rng_chk_lo_counts(il[643]) - , lookup_mem_rng_chk_mid_counts(il[644]) - , lookup_mem_rng_chk_hi_counts(il[645]) - , perm_pos_mem_read_a_inv(il[646]) - , perm_pos_mem_read_b_inv(il[647]) - , perm_pos_mem_read_c_inv(il[648]) - , perm_pos_mem_read_d_inv(il[649]) - , perm_pos_mem_write_a_inv(il[650]) - , perm_pos_mem_write_b_inv(il[651]) - , perm_pos_mem_write_c_inv(il[652]) - , perm_pos_mem_write_d_inv(il[653]) - , perm_slice_mem_inv(il[654]) - , perm_main_alu_inv(il[655]) - , perm_main_bin_inv(il[656]) - , perm_main_conv_inv(il[657]) - , perm_main_pos2_perm_inv(il[658]) - , perm_main_pedersen_inv(il[659]) - , perm_main_slice_inv(il[660]) - , perm_main_mem_a_inv(il[661]) - , perm_main_mem_b_inv(il[662]) - , perm_main_mem_c_inv(il[663]) - , perm_main_mem_d_inv(il[664]) - , perm_main_mem_ind_addr_a_inv(il[665]) - , perm_main_mem_ind_addr_b_inv(il[666]) - , perm_main_mem_ind_addr_c_inv(il[667]) - , perm_main_mem_ind_addr_d_inv(il[668]) - , lookup_pow_2_0_inv(il[669]) - , lookup_pow_2_1_inv(il[670]) - , lookup_u8_0_inv(il[671]) - , lookup_u8_1_inv(il[672]) - , lookup_u16_0_inv(il[673]) - , lookup_u16_1_inv(il[674]) - , lookup_u16_2_inv(il[675]) - , lookup_u16_3_inv(il[676]) - , lookup_u16_4_inv(il[677]) - , lookup_u16_5_inv(il[678]) - , lookup_u16_6_inv(il[679]) - , lookup_u16_7_inv(il[680]) - , lookup_u16_8_inv(il[681]) - , lookup_u16_9_inv(il[682]) - , lookup_u16_10_inv(il[683]) - , lookup_u16_11_inv(il[684]) - , lookup_u16_12_inv(il[685]) - , lookup_u16_13_inv(il[686]) - , lookup_u16_14_inv(il[687]) - , lookup_div_u16_0_inv(il[688]) - , lookup_div_u16_1_inv(il[689]) - , lookup_div_u16_2_inv(il[690]) - , lookup_div_u16_3_inv(il[691]) - , lookup_div_u16_4_inv(il[692]) - , lookup_div_u16_5_inv(il[693]) - , lookup_div_u16_6_inv(il[694]) - , lookup_div_u16_7_inv(il[695]) - , lookup_byte_lengths_inv(il[696]) - , lookup_byte_operations_inv(il[697]) - , lookup_opcode_gas_inv(il[698]) - , range_check_l2_gas_hi_inv(il[699]) - , range_check_l2_gas_lo_inv(il[700]) - , range_check_da_gas_hi_inv(il[701]) - , range_check_da_gas_lo_inv(il[702]) - , kernel_output_lookup_inv(il[703]) - , lookup_into_kernel_inv(il[704]) - , lookup_cd_value_inv(il[705]) - , lookup_ret_value_inv(il[706]) - , incl_main_tag_err_inv(il[707]) - , incl_mem_tag_err_inv(il[708]) - , lookup_mem_rng_chk_lo_inv(il[709]) - , lookup_mem_rng_chk_mid_inv(il[710]) - , lookup_mem_rng_chk_hi_inv(il[711]) - , alu_a_hi_shift(il[712]) - , alu_a_lo_shift(il[713]) - , alu_b_hi_shift(il[714]) - , alu_b_lo_shift(il[715]) - , alu_cmp_rng_ctr_shift(il[716]) - , alu_div_u16_r0_shift(il[717]) - , alu_div_u16_r1_shift(il[718]) - , alu_div_u16_r2_shift(il[719]) - , alu_div_u16_r3_shift(il[720]) - , alu_div_u16_r4_shift(il[721]) - , alu_div_u16_r5_shift(il[722]) - , alu_div_u16_r6_shift(il[723]) - , alu_div_u16_r7_shift(il[724]) - , alu_op_add_shift(il[725]) - , alu_op_cast_shift(il[726]) - , alu_op_cast_prev_shift(il[727]) - , alu_op_div_shift(il[728]) - , alu_op_mul_shift(il[729]) - , alu_op_shl_shift(il[730]) - , alu_op_shr_shift(il[731]) - , alu_op_sub_shift(il[732]) - , alu_p_sub_a_hi_shift(il[733]) - , alu_p_sub_a_lo_shift(il[734]) - , alu_p_sub_b_hi_shift(il[735]) - , alu_p_sub_b_lo_shift(il[736]) - , alu_sel_alu_shift(il[737]) - , alu_sel_cmp_shift(il[738]) - , alu_sel_div_rng_chk_shift(il[739]) - , alu_sel_rng_chk_shift(il[740]) - , alu_sel_rng_chk_lookup_shift(il[741]) - , alu_u16_r0_shift(il[742]) - , alu_u16_r1_shift(il[743]) - , alu_u16_r2_shift(il[744]) - , alu_u16_r3_shift(il[745]) - , alu_u16_r4_shift(il[746]) - , alu_u16_r5_shift(il[747]) - , alu_u16_r6_shift(il[748]) - , alu_u8_r0_shift(il[749]) - , alu_u8_r1_shift(il[750]) - , binary_acc_ia_shift(il[751]) - , binary_acc_ib_shift(il[752]) - , binary_acc_ic_shift(il[753]) - , binary_mem_tag_ctr_shift(il[754]) - , binary_op_id_shift(il[755]) - , main_da_gas_remaining_shift(il[756]) - , main_emit_l2_to_l1_msg_write_offset_shift(il[757]) - , main_emit_note_hash_write_offset_shift(il[758]) - , main_emit_nullifier_write_offset_shift(il[759]) - , main_emit_unencrypted_log_write_offset_shift(il[760]) - , main_internal_return_ptr_shift(il[761]) - , main_l1_to_l2_msg_exists_write_offset_shift(il[762]) - , main_l2_gas_remaining_shift(il[763]) - , main_note_hash_exist_write_offset_shift(il[764]) - , main_nullifier_exists_write_offset_shift(il[765]) - , main_nullifier_non_exists_write_offset_shift(il[766]) - , main_pc_shift(il[767]) - , main_sel_execution_row_shift(il[768]) - , main_sload_write_offset_shift(il[769]) - , main_sstore_write_offset_shift(il[770]) - , mem_glob_addr_shift(il[771]) - , mem_rw_shift(il[772]) - , mem_sel_mem_shift(il[773]) - , mem_tag_shift(il[774]) - , mem_tsp_shift(il[775]) - , mem_val_shift(il[776]) - , slice_addr_shift(il[777]) - , slice_clk_shift(il[778]) - , slice_cnt_shift(il[779]) - , slice_col_offset_shift(il[780]) - , slice_sel_cd_cpy_shift(il[781]) - , slice_sel_mem_active_shift(il[782]) - , slice_sel_return_shift(il[783]) - , slice_sel_start_shift(il[784]) - , slice_space_id_shift(il[785]) + , alu_b_pow(il[26]) + , alu_c_hi(il[27]) + , alu_c_lo(il[28]) + , alu_cf(il[29]) + , alu_clk(il[30]) + , alu_cmp_gadget_gt(il[31]) + , alu_cmp_gadget_input_a(il[32]) + , alu_cmp_gadget_input_b(il[33]) + , alu_cmp_gadget_result(il[34]) + , alu_cmp_gadget_sel(il[35]) + , alu_ff_tag(il[36]) + , alu_ia(il[37]) + , alu_ib(il[38]) + , alu_ic(il[39]) + , alu_in_tag(il[40]) + , alu_max_bits_sub_b_bits(il[41]) + , alu_max_bits_sub_b_pow(il[42]) + , alu_op_add(il[43]) + , alu_op_cast(il[44]) + , alu_op_div(il[45]) + , alu_op_eq(il[46]) + , alu_op_lt(il[47]) + , alu_op_lte(il[48]) + , alu_op_mul(il[49]) + , alu_op_not(il[50]) + , alu_op_shl(il[51]) + , alu_op_shr(il[52]) + , alu_op_sub(il[53]) + , alu_partial_prod_hi(il[54]) + , alu_partial_prod_lo(il[55]) + , alu_range_check_input_value(il[56]) + , alu_range_check_num_bits(il[57]) + , alu_range_check_sel(il[58]) + , alu_remainder(il[59]) + , alu_sel_alu(il[60]) + , alu_sel_cmp(il[61]) + , alu_sel_shift_which(il[62]) + , alu_u128_tag(il[63]) + , alu_u16_tag(il[64]) + , alu_u32_tag(il[65]) + , alu_u64_tag(il[66]) + , alu_u8_tag(il[67]) + , alu_zero_shift(il[68]) + , binary_acc_ia(il[69]) + , binary_acc_ib(il[70]) + , binary_acc_ic(il[71]) + , binary_clk(il[72]) + , binary_ia_bytes(il[73]) + , binary_ib_bytes(il[74]) + , binary_ic_bytes(il[75]) + , binary_in_tag(il[76]) + , binary_mem_tag_ctr(il[77]) + , binary_mem_tag_ctr_inv(il[78]) + , binary_op_id(il[79]) + , binary_sel_bin(il[80]) + , binary_start(il[81]) + , cmp_a_hi(il[82]) + , cmp_a_lo(il[83]) + , cmp_b_hi(il[84]) + , cmp_b_lo(il[85]) + , cmp_borrow(il[86]) + , cmp_clk(il[87]) + , cmp_cmp_rng_ctr(il[88]) + , cmp_input_a(il[89]) + , cmp_input_b(il[90]) + , cmp_op_eq(il[91]) + , cmp_op_eq_diff_inv(il[92]) + , cmp_op_gt(il[93]) + , cmp_p_a_borrow(il[94]) + , cmp_p_b_borrow(il[95]) + , cmp_p_sub_a_hi(il[96]) + , cmp_p_sub_a_lo(il[97]) + , cmp_p_sub_b_hi(il[98]) + , cmp_p_sub_b_lo(il[99]) + , cmp_range_chk_clk(il[100]) + , cmp_res_hi(il[101]) + , cmp_res_lo(il[102]) + , cmp_result(il[103]) + , cmp_sel_cmp(il[104]) + , cmp_sel_rng_chk(il[105]) + , cmp_shift_sel(il[106]) + , conversion_clk(il[107]) + , conversion_input(il[108]) + , conversion_num_limbs(il[109]) + , conversion_radix(il[110]) + , conversion_sel_to_radix_le(il[111]) + , keccakf1600_clk(il[112]) + , keccakf1600_input(il[113]) + , keccakf1600_output(il[114]) + , keccakf1600_sel_keccakf1600(il[115]) + , main_abs_da_rem_gas(il[116]) + , main_abs_l2_rem_gas(il[117]) + , main_alu_in_tag(il[118]) + , main_base_da_gas_op_cost(il[119]) + , main_base_l2_gas_op_cost(il[120]) + , main_bin_op_id(il[121]) + , main_call_ptr(il[122]) + , main_da_gas_remaining(il[123]) + , main_da_out_of_gas(il[124]) + , main_dyn_da_gas_op_cost(il[125]) + , main_dyn_gas_multiplier(il[126]) + , main_dyn_l2_gas_op_cost(il[127]) + , main_emit_l2_to_l1_msg_write_offset(il[128]) + , main_emit_note_hash_write_offset(il[129]) + , main_emit_nullifier_write_offset(il[130]) + , main_emit_unencrypted_log_write_offset(il[131]) + , main_ia(il[132]) + , main_ib(il[133]) + , main_ic(il[134]) + , main_id(il[135]) + , main_id_zero(il[136]) + , main_ind_addr_a(il[137]) + , main_ind_addr_b(il[138]) + , main_ind_addr_c(il[139]) + , main_ind_addr_d(il[140]) + , main_internal_return_ptr(il[141]) + , main_inv(il[142]) + , main_kernel_in_offset(il[143]) + , main_kernel_out_offset(il[144]) + , main_l1_to_l2_msg_exists_write_offset(il[145]) + , main_l2_gas_remaining(il[146]) + , main_l2_out_of_gas(il[147]) + , main_mem_addr_a(il[148]) + , main_mem_addr_b(il[149]) + , main_mem_addr_c(il[150]) + , main_mem_addr_d(il[151]) + , main_note_hash_exist_write_offset(il[152]) + , main_nullifier_exists_write_offset(il[153]) + , main_nullifier_non_exists_write_offset(il[154]) + , main_op_err(il[155]) + , main_opcode_val(il[156]) + , main_pc(il[157]) + , main_r_in_tag(il[158]) + , main_rwa(il[159]) + , main_rwb(il[160]) + , main_rwc(il[161]) + , main_rwd(il[162]) + , main_sel_alu(il[163]) + , main_sel_bin(il[164]) + , main_sel_calldata(il[165]) + , main_sel_execution_row(il[166]) + , main_sel_kernel_inputs(il[167]) + , main_sel_kernel_out(il[168]) + , main_sel_last(il[169]) + , main_sel_mem_op_a(il[170]) + , main_sel_mem_op_b(il[171]) + , main_sel_mem_op_c(il[172]) + , main_sel_mem_op_d(il[173]) + , main_sel_mov_ia_to_ic(il[174]) + , main_sel_mov_ib_to_ic(il[175]) + , main_sel_op_add(il[176]) + , main_sel_op_address(il[177]) + , main_sel_op_and(il[178]) + , main_sel_op_block_number(il[179]) + , main_sel_op_calldata_copy(il[180]) + , main_sel_op_cast(il[181]) + , main_sel_op_chain_id(il[182]) + , main_sel_op_cmov(il[183]) + , main_sel_op_coinbase(il[184]) + , main_sel_op_dagasleft(il[185]) + , main_sel_op_div(il[186]) + , main_sel_op_ecadd(il[187]) + , main_sel_op_emit_l2_to_l1_msg(il[188]) + , main_sel_op_emit_note_hash(il[189]) + , main_sel_op_emit_nullifier(il[190]) + , main_sel_op_emit_unencrypted_log(il[191]) + , main_sel_op_eq(il[192]) + , main_sel_op_external_call(il[193]) + , main_sel_op_external_return(il[194]) + , main_sel_op_external_revert(il[195]) + , main_sel_op_fdiv(il[196]) + , main_sel_op_fee_per_da_gas(il[197]) + , main_sel_op_fee_per_l2_gas(il[198]) + , main_sel_op_function_selector(il[199]) + , main_sel_op_get_contract_instance(il[200]) + , main_sel_op_internal_call(il[201]) + , main_sel_op_internal_return(il[202]) + , main_sel_op_jump(il[203]) + , main_sel_op_jumpi(il[204]) + , main_sel_op_keccak(il[205]) + , main_sel_op_l1_to_l2_msg_exists(il[206]) + , main_sel_op_l2gasleft(il[207]) + , main_sel_op_lt(il[208]) + , main_sel_op_lte(il[209]) + , main_sel_op_mov(il[210]) + , main_sel_op_msm(il[211]) + , main_sel_op_mul(il[212]) + , main_sel_op_not(il[213]) + , main_sel_op_note_hash_exists(il[214]) + , main_sel_op_nullifier_exists(il[215]) + , main_sel_op_or(il[216]) + , main_sel_op_pedersen(il[217]) + , main_sel_op_pedersen_commit(il[218]) + , main_sel_op_poseidon2(il[219]) + , main_sel_op_radix_le(il[220]) + , main_sel_op_sender(il[221]) + , main_sel_op_set(il[222]) + , main_sel_op_sha256(il[223]) + , main_sel_op_shl(il[224]) + , main_sel_op_shr(il[225]) + , main_sel_op_sload(il[226]) + , main_sel_op_sstore(il[227]) + , main_sel_op_storage_address(il[228]) + , main_sel_op_sub(il[229]) + , main_sel_op_timestamp(il[230]) + , main_sel_op_transaction_fee(il[231]) + , main_sel_op_version(il[232]) + , main_sel_op_xor(il[233]) + , main_sel_q_kernel_lookup(il[234]) + , main_sel_q_kernel_output_lookup(il[235]) + , main_sel_resolve_ind_addr_a(il[236]) + , main_sel_resolve_ind_addr_b(il[237]) + , main_sel_resolve_ind_addr_c(il[238]) + , main_sel_resolve_ind_addr_d(il[239]) + , main_sel_returndata(il[240]) + , main_sel_rng_16(il[241]) + , main_sel_rng_8(il[242]) + , main_sel_slice_gadget(il[243]) + , main_side_effect_counter(il[244]) + , main_sload_write_offset(il[245]) + , main_space_id(il[246]) + , main_sstore_write_offset(il[247]) + , main_tag_err(il[248]) + , main_w_in_tag(il[249]) + , mem_addr(il[250]) + , mem_clk(il[251]) + , mem_diff(il[252]) + , mem_glob_addr(il[253]) + , mem_last(il[254]) + , mem_lastAccess(il[255]) + , mem_one_min_inv(il[256]) + , mem_r_in_tag(il[257]) + , mem_rw(il[258]) + , mem_sel_mem(il[259]) + , mem_sel_mov_ia_to_ic(il[260]) + , mem_sel_mov_ib_to_ic(il[261]) + , mem_sel_op_a(il[262]) + , mem_sel_op_b(il[263]) + , mem_sel_op_c(il[264]) + , mem_sel_op_cmov(il[265]) + , mem_sel_op_d(il[266]) + , mem_sel_op_poseidon_read_a(il[267]) + , mem_sel_op_poseidon_read_b(il[268]) + , mem_sel_op_poseidon_read_c(il[269]) + , mem_sel_op_poseidon_read_d(il[270]) + , mem_sel_op_poseidon_write_a(il[271]) + , mem_sel_op_poseidon_write_b(il[272]) + , mem_sel_op_poseidon_write_c(il[273]) + , mem_sel_op_poseidon_write_d(il[274]) + , mem_sel_op_slice(il[275]) + , mem_sel_resolve_ind_addr_a(il[276]) + , mem_sel_resolve_ind_addr_b(il[277]) + , mem_sel_resolve_ind_addr_c(il[278]) + , mem_sel_resolve_ind_addr_d(il[279]) + , mem_sel_rng_chk(il[280]) + , mem_skip_check_tag(il[281]) + , mem_space_id(il[282]) + , mem_tag(il[283]) + , mem_tag_err(il[284]) + , mem_tsp(il[285]) + , mem_val(il[286]) + , mem_w_in_tag(il[287]) + , pedersen_clk(il[288]) + , pedersen_input(il[289]) + , pedersen_output(il[290]) + , pedersen_sel_pedersen(il[291]) + , poseidon2_B_10_0(il[292]) + , poseidon2_B_10_1(il[293]) + , poseidon2_B_10_2(il[294]) + , poseidon2_B_10_3(il[295]) + , poseidon2_B_11_0(il[296]) + , poseidon2_B_11_1(il[297]) + , poseidon2_B_11_2(il[298]) + , poseidon2_B_11_3(il[299]) + , poseidon2_B_12_0(il[300]) + , poseidon2_B_12_1(il[301]) + , poseidon2_B_12_2(il[302]) + , poseidon2_B_12_3(il[303]) + , poseidon2_B_13_0(il[304]) + , poseidon2_B_13_1(il[305]) + , poseidon2_B_13_2(il[306]) + , poseidon2_B_13_3(il[307]) + , poseidon2_B_14_0(il[308]) + , poseidon2_B_14_1(il[309]) + , poseidon2_B_14_2(il[310]) + , poseidon2_B_14_3(il[311]) + , poseidon2_B_15_0(il[312]) + , poseidon2_B_15_1(il[313]) + , poseidon2_B_15_2(il[314]) + , poseidon2_B_15_3(il[315]) + , poseidon2_B_16_0(il[316]) + , poseidon2_B_16_1(il[317]) + , poseidon2_B_16_2(il[318]) + , poseidon2_B_16_3(il[319]) + , poseidon2_B_17_0(il[320]) + , poseidon2_B_17_1(il[321]) + , poseidon2_B_17_2(il[322]) + , poseidon2_B_17_3(il[323]) + , poseidon2_B_18_0(il[324]) + , poseidon2_B_18_1(il[325]) + , poseidon2_B_18_2(il[326]) + , poseidon2_B_18_3(il[327]) + , poseidon2_B_19_0(il[328]) + , poseidon2_B_19_1(il[329]) + , poseidon2_B_19_2(il[330]) + , poseidon2_B_19_3(il[331]) + , poseidon2_B_20_0(il[332]) + , poseidon2_B_20_1(il[333]) + , poseidon2_B_20_2(il[334]) + , poseidon2_B_20_3(il[335]) + , poseidon2_B_21_0(il[336]) + , poseidon2_B_21_1(il[337]) + , poseidon2_B_21_2(il[338]) + , poseidon2_B_21_3(il[339]) + , poseidon2_B_22_0(il[340]) + , poseidon2_B_22_1(il[341]) + , poseidon2_B_22_2(il[342]) + , poseidon2_B_22_3(il[343]) + , poseidon2_B_23_0(il[344]) + , poseidon2_B_23_1(il[345]) + , poseidon2_B_23_2(il[346]) + , poseidon2_B_23_3(il[347]) + , poseidon2_B_24_0(il[348]) + , poseidon2_B_24_1(il[349]) + , poseidon2_B_24_2(il[350]) + , poseidon2_B_24_3(il[351]) + , poseidon2_B_25_0(il[352]) + , poseidon2_B_25_1(il[353]) + , poseidon2_B_25_2(il[354]) + , poseidon2_B_25_3(il[355]) + , poseidon2_B_26_0(il[356]) + , poseidon2_B_26_1(il[357]) + , poseidon2_B_26_2(il[358]) + , poseidon2_B_26_3(il[359]) + , poseidon2_B_27_0(il[360]) + , poseidon2_B_27_1(il[361]) + , poseidon2_B_27_2(il[362]) + , poseidon2_B_27_3(il[363]) + , poseidon2_B_28_0(il[364]) + , poseidon2_B_28_1(il[365]) + , poseidon2_B_28_2(il[366]) + , poseidon2_B_28_3(il[367]) + , poseidon2_B_29_0(il[368]) + , poseidon2_B_29_1(il[369]) + , poseidon2_B_29_2(il[370]) + , poseidon2_B_29_3(il[371]) + , poseidon2_B_30_0(il[372]) + , poseidon2_B_30_1(il[373]) + , poseidon2_B_30_2(il[374]) + , poseidon2_B_30_3(il[375]) + , poseidon2_B_31_0(il[376]) + , poseidon2_B_31_1(il[377]) + , poseidon2_B_31_2(il[378]) + , poseidon2_B_31_3(il[379]) + , poseidon2_B_32_0(il[380]) + , poseidon2_B_32_1(il[381]) + , poseidon2_B_32_2(il[382]) + , poseidon2_B_32_3(il[383]) + , poseidon2_B_33_0(il[384]) + , poseidon2_B_33_1(il[385]) + , poseidon2_B_33_2(il[386]) + , poseidon2_B_33_3(il[387]) + , poseidon2_B_34_0(il[388]) + , poseidon2_B_34_1(il[389]) + , poseidon2_B_34_2(il[390]) + , poseidon2_B_34_3(il[391]) + , poseidon2_B_35_0(il[392]) + , poseidon2_B_35_1(il[393]) + , poseidon2_B_35_2(il[394]) + , poseidon2_B_35_3(il[395]) + , poseidon2_B_36_0(il[396]) + , poseidon2_B_36_1(il[397]) + , poseidon2_B_36_2(il[398]) + , poseidon2_B_36_3(il[399]) + , poseidon2_B_37_0(il[400]) + , poseidon2_B_37_1(il[401]) + , poseidon2_B_37_2(il[402]) + , poseidon2_B_37_3(il[403]) + , poseidon2_B_38_0(il[404]) + , poseidon2_B_38_1(il[405]) + , poseidon2_B_38_2(il[406]) + , poseidon2_B_38_3(il[407]) + , poseidon2_B_39_0(il[408]) + , poseidon2_B_39_1(il[409]) + , poseidon2_B_39_2(il[410]) + , poseidon2_B_39_3(il[411]) + , poseidon2_B_40_0(il[412]) + , poseidon2_B_40_1(il[413]) + , poseidon2_B_40_2(il[414]) + , poseidon2_B_40_3(il[415]) + , poseidon2_B_41_0(il[416]) + , poseidon2_B_41_1(il[417]) + , poseidon2_B_41_2(il[418]) + , poseidon2_B_41_3(il[419]) + , poseidon2_B_42_0(il[420]) + , poseidon2_B_42_1(il[421]) + , poseidon2_B_42_2(il[422]) + , poseidon2_B_42_3(il[423]) + , poseidon2_B_43_0(il[424]) + , poseidon2_B_43_1(il[425]) + , poseidon2_B_43_2(il[426]) + , poseidon2_B_43_3(il[427]) + , poseidon2_B_44_0(il[428]) + , poseidon2_B_44_1(il[429]) + , poseidon2_B_44_2(il[430]) + , poseidon2_B_44_3(il[431]) + , poseidon2_B_45_0(il[432]) + , poseidon2_B_45_1(il[433]) + , poseidon2_B_45_2(il[434]) + , poseidon2_B_45_3(il[435]) + , poseidon2_B_46_0(il[436]) + , poseidon2_B_46_1(il[437]) + , poseidon2_B_46_2(il[438]) + , poseidon2_B_46_3(il[439]) + , poseidon2_B_47_0(il[440]) + , poseidon2_B_47_1(il[441]) + , poseidon2_B_47_2(il[442]) + , poseidon2_B_47_3(il[443]) + , poseidon2_B_48_0(il[444]) + , poseidon2_B_48_1(il[445]) + , poseidon2_B_48_2(il[446]) + , poseidon2_B_48_3(il[447]) + , poseidon2_B_49_0(il[448]) + , poseidon2_B_49_1(il[449]) + , poseidon2_B_49_2(il[450]) + , poseidon2_B_49_3(il[451]) + , poseidon2_B_4_0(il[452]) + , poseidon2_B_4_1(il[453]) + , poseidon2_B_4_2(il[454]) + , poseidon2_B_4_3(il[455]) + , poseidon2_B_50_0(il[456]) + , poseidon2_B_50_1(il[457]) + , poseidon2_B_50_2(il[458]) + , poseidon2_B_50_3(il[459]) + , poseidon2_B_51_0(il[460]) + , poseidon2_B_51_1(il[461]) + , poseidon2_B_51_2(il[462]) + , poseidon2_B_51_3(il[463]) + , poseidon2_B_52_0(il[464]) + , poseidon2_B_52_1(il[465]) + , poseidon2_B_52_2(il[466]) + , poseidon2_B_52_3(il[467]) + , poseidon2_B_53_0(il[468]) + , poseidon2_B_53_1(il[469]) + , poseidon2_B_53_2(il[470]) + , poseidon2_B_53_3(il[471]) + , poseidon2_B_54_0(il[472]) + , poseidon2_B_54_1(il[473]) + , poseidon2_B_54_2(il[474]) + , poseidon2_B_54_3(il[475]) + , poseidon2_B_55_0(il[476]) + , poseidon2_B_55_1(il[477]) + , poseidon2_B_55_2(il[478]) + , poseidon2_B_55_3(il[479]) + , poseidon2_B_56_0(il[480]) + , poseidon2_B_56_1(il[481]) + , poseidon2_B_56_2(il[482]) + , poseidon2_B_56_3(il[483]) + , poseidon2_B_57_0(il[484]) + , poseidon2_B_57_1(il[485]) + , poseidon2_B_57_2(il[486]) + , poseidon2_B_57_3(il[487]) + , poseidon2_B_58_0(il[488]) + , poseidon2_B_58_1(il[489]) + , poseidon2_B_58_2(il[490]) + , poseidon2_B_58_3(il[491]) + , poseidon2_B_59_0(il[492]) + , poseidon2_B_59_1(il[493]) + , poseidon2_B_59_2(il[494]) + , poseidon2_B_59_3(il[495]) + , poseidon2_B_5_0(il[496]) + , poseidon2_B_5_1(il[497]) + , poseidon2_B_5_2(il[498]) + , poseidon2_B_5_3(il[499]) + , poseidon2_B_6_0(il[500]) + , poseidon2_B_6_1(il[501]) + , poseidon2_B_6_2(il[502]) + , poseidon2_B_6_3(il[503]) + , poseidon2_B_7_0(il[504]) + , poseidon2_B_7_1(il[505]) + , poseidon2_B_7_2(il[506]) + , poseidon2_B_7_3(il[507]) + , poseidon2_B_8_0(il[508]) + , poseidon2_B_8_1(il[509]) + , poseidon2_B_8_2(il[510]) + , poseidon2_B_8_3(il[511]) + , poseidon2_B_9_0(il[512]) + , poseidon2_B_9_1(il[513]) + , poseidon2_B_9_2(il[514]) + , poseidon2_B_9_3(il[515]) + , poseidon2_EXT_LAYER_4(il[516]) + , poseidon2_EXT_LAYER_5(il[517]) + , poseidon2_EXT_LAYER_6(il[518]) + , poseidon2_EXT_LAYER_7(il[519]) + , poseidon2_T_0_4(il[520]) + , poseidon2_T_0_5(il[521]) + , poseidon2_T_0_6(il[522]) + , poseidon2_T_0_7(il[523]) + , poseidon2_T_1_4(il[524]) + , poseidon2_T_1_5(il[525]) + , poseidon2_T_1_6(il[526]) + , poseidon2_T_1_7(il[527]) + , poseidon2_T_2_4(il[528]) + , poseidon2_T_2_5(il[529]) + , poseidon2_T_2_6(il[530]) + , poseidon2_T_2_7(il[531]) + , poseidon2_T_3_4(il[532]) + , poseidon2_T_3_5(il[533]) + , poseidon2_T_3_6(il[534]) + , poseidon2_T_3_7(il[535]) + , poseidon2_T_60_4(il[536]) + , poseidon2_T_60_5(il[537]) + , poseidon2_T_60_6(il[538]) + , poseidon2_T_60_7(il[539]) + , poseidon2_T_61_4(il[540]) + , poseidon2_T_61_5(il[541]) + , poseidon2_T_61_6(il[542]) + , poseidon2_T_61_7(il[543]) + , poseidon2_T_62_4(il[544]) + , poseidon2_T_62_5(il[545]) + , poseidon2_T_62_6(il[546]) + , poseidon2_T_62_7(il[547]) + , poseidon2_T_63_4(il[548]) + , poseidon2_T_63_5(il[549]) + , poseidon2_T_63_6(il[550]) + , poseidon2_T_63_7(il[551]) + , poseidon2_a_0(il[552]) + , poseidon2_a_1(il[553]) + , poseidon2_a_2(il[554]) + , poseidon2_a_3(il[555]) + , poseidon2_b_0(il[556]) + , poseidon2_b_1(il[557]) + , poseidon2_b_2(il[558]) + , poseidon2_b_3(il[559]) + , poseidon2_clk(il[560]) + , poseidon2_input_addr(il[561]) + , poseidon2_mem_addr_read_a(il[562]) + , poseidon2_mem_addr_read_b(il[563]) + , poseidon2_mem_addr_read_c(il[564]) + , poseidon2_mem_addr_read_d(il[565]) + , poseidon2_mem_addr_write_a(il[566]) + , poseidon2_mem_addr_write_b(il[567]) + , poseidon2_mem_addr_write_c(il[568]) + , poseidon2_mem_addr_write_d(il[569]) + , poseidon2_output_addr(il[570]) + , poseidon2_sel_poseidon_perm(il[571]) + , range_check_alu_rng_chk(il[572]) + , range_check_clk(il[573]) + , range_check_cmp_hi_bits_rng_chk(il[574]) + , range_check_cmp_lo_bits_rng_chk(il[575]) + , range_check_dyn_diff(il[576]) + , range_check_dyn_rng_chk_bits(il[577]) + , range_check_dyn_rng_chk_pow_2(il[578]) + , range_check_gas_da_rng_chk(il[579]) + , range_check_gas_l2_rng_chk(il[580]) + , range_check_is_lte_u112(il[581]) + , range_check_is_lte_u128(il[582]) + , range_check_is_lte_u16(il[583]) + , range_check_is_lte_u32(il[584]) + , range_check_is_lte_u48(il[585]) + , range_check_is_lte_u64(il[586]) + , range_check_is_lte_u80(il[587]) + , range_check_is_lte_u96(il[588]) + , range_check_mem_rng_chk(il[589]) + , range_check_rng_chk_bits(il[590]) + , range_check_sel_lookup_0(il[591]) + , range_check_sel_lookup_1(il[592]) + , range_check_sel_lookup_2(il[593]) + , range_check_sel_lookup_3(il[594]) + , range_check_sel_lookup_4(il[595]) + , range_check_sel_lookup_5(il[596]) + , range_check_sel_lookup_6(il[597]) + , range_check_sel_rng_chk(il[598]) + , range_check_u16_r0(il[599]) + , range_check_u16_r1(il[600]) + , range_check_u16_r2(il[601]) + , range_check_u16_r3(il[602]) + , range_check_u16_r4(il[603]) + , range_check_u16_r5(il[604]) + , range_check_u16_r6(il[605]) + , range_check_u16_r7(il[606]) + , range_check_value(il[607]) + , sha256_clk(il[608]) + , sha256_input(il[609]) + , sha256_output(il[610]) + , sha256_sel_sha256_compression(il[611]) + , sha256_state(il[612]) + , slice_addr(il[613]) + , slice_clk(il[614]) + , slice_cnt(il[615]) + , slice_col_offset(il[616]) + , slice_one_min_inv(il[617]) + , slice_sel_cd_cpy(il[618]) + , slice_sel_mem_active(il[619]) + , slice_sel_return(il[620]) + , slice_sel_start(il[621]) + , slice_space_id(il[622]) + , slice_val(il[623]) + , lookup_rng_chk_pow_2_counts(il[624]) + , lookup_rng_chk_diff_counts(il[625]) + , lookup_rng_chk_0_counts(il[626]) + , lookup_rng_chk_1_counts(il[627]) + , lookup_rng_chk_2_counts(il[628]) + , lookup_rng_chk_3_counts(il[629]) + , lookup_rng_chk_4_counts(il[630]) + , lookup_rng_chk_5_counts(il[631]) + , lookup_rng_chk_6_counts(il[632]) + , lookup_rng_chk_7_counts(il[633]) + , lookup_pow_2_0_counts(il[634]) + , lookup_pow_2_1_counts(il[635]) + , lookup_byte_lengths_counts(il[636]) + , lookup_byte_operations_counts(il[637]) + , lookup_opcode_gas_counts(il[638]) + , kernel_output_lookup_counts(il[639]) + , lookup_into_kernel_counts(il[640]) + , lookup_cd_value_counts(il[641]) + , lookup_ret_value_counts(il[642]) + , incl_main_tag_err_counts(il[643]) + , incl_mem_tag_err_counts(il[644]) + , perm_rng_mem_inv(il[645]) + , perm_rng_cmp_lo_inv(il[646]) + , perm_rng_cmp_hi_inv(il[647]) + , perm_rng_alu_inv(il[648]) + , perm_cmp_alu_inv(il[649]) + , perm_rng_gas_l2_inv(il[650]) + , perm_rng_gas_da_inv(il[651]) + , perm_pos_mem_read_a_inv(il[652]) + , perm_pos_mem_read_b_inv(il[653]) + , perm_pos_mem_read_c_inv(il[654]) + , perm_pos_mem_read_d_inv(il[655]) + , perm_pos_mem_write_a_inv(il[656]) + , perm_pos_mem_write_b_inv(il[657]) + , perm_pos_mem_write_c_inv(il[658]) + , perm_pos_mem_write_d_inv(il[659]) + , perm_slice_mem_inv(il[660]) + , perm_main_alu_inv(il[661]) + , perm_main_bin_inv(il[662]) + , perm_main_conv_inv(il[663]) + , perm_main_pos2_perm_inv(il[664]) + , perm_main_pedersen_inv(il[665]) + , perm_main_slice_inv(il[666]) + , perm_main_mem_a_inv(il[667]) + , perm_main_mem_b_inv(il[668]) + , perm_main_mem_c_inv(il[669]) + , perm_main_mem_d_inv(il[670]) + , perm_main_mem_ind_addr_a_inv(il[671]) + , perm_main_mem_ind_addr_b_inv(il[672]) + , perm_main_mem_ind_addr_c_inv(il[673]) + , perm_main_mem_ind_addr_d_inv(il[674]) + , lookup_rng_chk_pow_2_inv(il[675]) + , lookup_rng_chk_diff_inv(il[676]) + , lookup_rng_chk_0_inv(il[677]) + , lookup_rng_chk_1_inv(il[678]) + , lookup_rng_chk_2_inv(il[679]) + , lookup_rng_chk_3_inv(il[680]) + , lookup_rng_chk_4_inv(il[681]) + , lookup_rng_chk_5_inv(il[682]) + , lookup_rng_chk_6_inv(il[683]) + , lookup_rng_chk_7_inv(il[684]) + , lookup_pow_2_0_inv(il[685]) + , lookup_pow_2_1_inv(il[686]) + , lookup_byte_lengths_inv(il[687]) + , lookup_byte_operations_inv(il[688]) + , lookup_opcode_gas_inv(il[689]) + , kernel_output_lookup_inv(il[690]) + , lookup_into_kernel_inv(il[691]) + , lookup_cd_value_inv(il[692]) + , lookup_ret_value_inv(il[693]) + , incl_main_tag_err_inv(il[694]) + , incl_mem_tag_err_inv(il[695]) + , binary_acc_ia_shift(il[696]) + , binary_acc_ib_shift(il[697]) + , binary_acc_ic_shift(il[698]) + , binary_mem_tag_ctr_shift(il[699]) + , binary_op_id_shift(il[700]) + , cmp_a_hi_shift(il[701]) + , cmp_a_lo_shift(il[702]) + , cmp_b_hi_shift(il[703]) + , cmp_b_lo_shift(il[704]) + , cmp_cmp_rng_ctr_shift(il[705]) + , cmp_op_gt_shift(il[706]) + , cmp_p_sub_a_hi_shift(il[707]) + , cmp_p_sub_a_lo_shift(il[708]) + , cmp_p_sub_b_hi_shift(il[709]) + , cmp_p_sub_b_lo_shift(il[710]) + , cmp_sel_rng_chk_shift(il[711]) + , main_da_gas_remaining_shift(il[712]) + , main_emit_l2_to_l1_msg_write_offset_shift(il[713]) + , main_emit_note_hash_write_offset_shift(il[714]) + , main_emit_nullifier_write_offset_shift(il[715]) + , main_emit_unencrypted_log_write_offset_shift(il[716]) + , main_internal_return_ptr_shift(il[717]) + , main_l1_to_l2_msg_exists_write_offset_shift(il[718]) + , main_l2_gas_remaining_shift(il[719]) + , main_note_hash_exist_write_offset_shift(il[720]) + , main_nullifier_exists_write_offset_shift(il[721]) + , main_nullifier_non_exists_write_offset_shift(il[722]) + , main_pc_shift(il[723]) + , main_sel_execution_row_shift(il[724]) + , main_sload_write_offset_shift(il[725]) + , main_sstore_write_offset_shift(il[726]) + , mem_glob_addr_shift(il[727]) + , mem_rw_shift(il[728]) + , mem_sel_mem_shift(il[729]) + , mem_tag_shift(il[730]) + , mem_tsp_shift(il[731]) + , mem_val_shift(il[732]) + , slice_addr_shift(il[733]) + , slice_clk_shift(il[734]) + , slice_cnt_shift(il[735]) + , slice_col_offset_shift(il[736]) + , slice_sel_cd_cpy_shift(il[737]) + , slice_sel_mem_active_shift(il[738]) + , slice_sel_return_shift(il[739]) + , slice_sel_start_shift(il[740]) + , slice_space_id_shift(il[741]) {} AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index 4dda9760edc..47228fbf667 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -89,10 +89,10 @@ template using tuple_cat_t = decltype(std::tuple_cat(std:: // The entities that will be used in the flavor. // clang-format off #define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_first, main_zeroes, powers_power_of_2 -#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_borrow, alu_cf, alu_clk, alu_cmp_rng_ctr, alu_div_u16_r0, alu_div_u16_r1, alu_div_u16_r2, alu_div_u16_r3, alu_div_u16_r4, alu_div_u16_r5, alu_div_u16_r6, alu_div_u16_r7, alu_divisor_hi, alu_divisor_lo, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_op_add, alu_op_cast, alu_op_cast_prev, alu_op_div, alu_op_div_a_lt_b, alu_op_div_std, alu_op_eq, alu_op_eq_diff_inv, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_p_a_borrow, alu_p_b_borrow, alu_p_sub_a_hi, alu_p_sub_a_lo, alu_p_sub_b_hi, alu_p_sub_b_lo, alu_partial_prod_hi, alu_partial_prod_lo, alu_quotient_hi, alu_quotient_lo, alu_remainder, alu_res_hi, alu_res_lo, alu_sel_alu, alu_sel_cmp, alu_sel_div_rng_chk, alu_sel_rng_chk, alu_sel_rng_chk_lookup, alu_sel_shift_which, alu_shift_lt_bit_len, alu_t_sub_s_bits, alu_two_pow_s, alu_two_pow_t_sub_s, alu_u128_tag, alu_u16_r0, alu_u16_r1, alu_u16_r10, alu_u16_r11, alu_u16_r12, alu_u16_r13, alu_u16_r14, alu_u16_r2, alu_u16_r3, alu_u16_r4, alu_u16_r5, alu_u16_r6, alu_u16_r7, alu_u16_r8, alu_u16_r9, alu_u16_tag, alu_u32_tag, alu_u64_tag, alu_u8_r0, alu_u8_r1, alu_u8_tag, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, conversion_clk, conversion_input, conversion_num_limbs, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas_hi, main_abs_da_rem_gas_lo, main_abs_l2_rem_gas_hi, main_abs_l2_rem_gas_lo, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_last, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_cmov, main_sel_op_coinbase, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_pedersen, main_sel_op_pedersen_commit, main_sel_op_poseidon2, main_sel_op_radix_le, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_storage_address, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff_hi, mem_diff_lo, mem_diff_mid, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_cmov, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, pedersen_clk, pedersen_input, pedersen_output, pedersen_sel_pedersen, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_u8_0_counts, lookup_u8_1_counts, lookup_u16_0_counts, lookup_u16_1_counts, lookup_u16_2_counts, lookup_u16_3_counts, lookup_u16_4_counts, lookup_u16_5_counts, lookup_u16_6_counts, lookup_u16_7_counts, lookup_u16_8_counts, lookup_u16_9_counts, lookup_u16_10_counts, lookup_u16_11_counts, lookup_u16_12_counts, lookup_u16_13_counts, lookup_u16_14_counts, lookup_div_u16_0_counts, lookup_div_u16_1_counts, lookup_div_u16_2_counts, lookup_div_u16_3_counts, lookup_div_u16_4_counts, lookup_div_u16_5_counts, lookup_div_u16_6_counts, lookup_div_u16_7_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, range_check_l2_gas_hi_counts, range_check_l2_gas_lo_counts, range_check_da_gas_hi_counts, range_check_da_gas_lo_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, lookup_mem_rng_chk_lo_counts, lookup_mem_rng_chk_mid_counts, lookup_mem_rng_chk_hi_counts -#define DERIVED_WITNESS_ENTITIES perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_slice_mem_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_pos2_perm_inv, perm_main_pedersen_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_u8_0_inv, lookup_u8_1_inv, lookup_u16_0_inv, lookup_u16_1_inv, lookup_u16_2_inv, lookup_u16_3_inv, lookup_u16_4_inv, lookup_u16_5_inv, lookup_u16_6_inv, lookup_u16_7_inv, lookup_u16_8_inv, lookup_u16_9_inv, lookup_u16_10_inv, lookup_u16_11_inv, lookup_u16_12_inv, lookup_u16_13_inv, lookup_u16_14_inv, lookup_div_u16_0_inv, lookup_div_u16_1_inv, lookup_div_u16_2_inv, lookup_div_u16_3_inv, lookup_div_u16_4_inv, lookup_div_u16_5_inv, lookup_div_u16_6_inv, lookup_div_u16_7_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, range_check_l2_gas_hi_inv, range_check_l2_gas_lo_inv, range_check_da_gas_hi_inv, range_check_da_gas_lo_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv, lookup_mem_rng_chk_lo_inv, lookup_mem_rng_chk_mid_inv, lookup_mem_rng_chk_hi_inv -#define SHIFTED_ENTITIES alu_a_hi_shift, alu_a_lo_shift, alu_b_hi_shift, alu_b_lo_shift, alu_cmp_rng_ctr_shift, alu_div_u16_r0_shift, alu_div_u16_r1_shift, alu_div_u16_r2_shift, alu_div_u16_r3_shift, alu_div_u16_r4_shift, alu_div_u16_r5_shift, alu_div_u16_r6_shift, alu_div_u16_r7_shift, alu_op_add_shift, alu_op_cast_shift, alu_op_cast_prev_shift, alu_op_div_shift, alu_op_mul_shift, alu_op_shl_shift, alu_op_shr_shift, alu_op_sub_shift, alu_p_sub_a_hi_shift, alu_p_sub_a_lo_shift, alu_p_sub_b_hi_shift, alu_p_sub_b_lo_shift, alu_sel_alu_shift, alu_sel_cmp_shift, alu_sel_div_rng_chk_shift, alu_sel_rng_chk_shift, alu_sel_rng_chk_lookup_shift, alu_u16_r0_shift, alu_u16_r1_shift, alu_u16_r2_shift, alu_u16_r3_shift, alu_u16_r4_shift, alu_u16_r5_shift, alu_u16_r6_shift, alu_u8_r0_shift, alu_u8_r1_shift, binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_row_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift -#define TO_BE_SHIFTED(e) e.alu_a_hi, e.alu_a_lo, e.alu_b_hi, e.alu_b_lo, e.alu_cmp_rng_ctr, e.alu_div_u16_r0, e.alu_div_u16_r1, e.alu_div_u16_r2, e.alu_div_u16_r3, e.alu_div_u16_r4, e.alu_div_u16_r5, e.alu_div_u16_r6, e.alu_div_u16_r7, e.alu_op_add, e.alu_op_cast, e.alu_op_cast_prev, e.alu_op_div, e.alu_op_mul, e.alu_op_shl, e.alu_op_shr, e.alu_op_sub, e.alu_p_sub_a_hi, e.alu_p_sub_a_lo, e.alu_p_sub_b_hi, e.alu_p_sub_b_lo, e.alu_sel_alu, e.alu_sel_cmp, e.alu_sel_div_rng_chk, e.alu_sel_rng_chk, e.alu_sel_rng_chk_lookup, e.alu_u16_r0, e.alu_u16_r1, e.alu_u16_r2, e.alu_u16_r3, e.alu_u16_r4, e.alu_u16_r5, e.alu_u16_r6, e.alu_u8_r0, e.alu_u8_r1, e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_row, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id +#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_radix, conversion_sel_to_radix_le, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_last, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_cmov, main_sel_op_coinbase, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_pedersen, main_sel_op_pedersen_commit, main_sel_op_poseidon2, main_sel_op_radix_le, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_storage_address, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_cmov, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, pedersen_clk, pedersen_input, pedersen_output, pedersen_sel_pedersen, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_mem_rng_chk, range_check_rng_chk_bits, range_check_sel_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts +#define DERIVED_WITNESS_ENTITIES perm_rng_mem_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_rng_gas_l2_inv, perm_rng_gas_da_inv, perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_slice_mem_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_pos2_perm_inv, perm_main_pedersen_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv +#define SHIFTED_ENTITIES binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, cmp_a_hi_shift, cmp_a_lo_shift, cmp_b_hi_shift, cmp_b_lo_shift, cmp_cmp_rng_ctr_shift, cmp_op_gt_shift, cmp_p_sub_a_hi_shift, cmp_p_sub_a_lo_shift, cmp_p_sub_b_hi_shift, cmp_p_sub_b_lo_shift, cmp_sel_rng_chk_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_row_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift +#define TO_BE_SHIFTED(e) e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.cmp_a_hi, e.cmp_a_lo, e.cmp_b_hi, e.cmp_b_lo, e.cmp_cmp_rng_ctr, e.cmp_op_gt, e.cmp_p_sub_a_hi, e.cmp_p_sub_a_lo, e.cmp_p_sub_b_hi, e.cmp_p_sub_b_lo, e.cmp_sel_rng_chk, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_row, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id #define ALL_ENTITIES PRECOMPUTED_ENTITIES, WIRE_ENTITIES, DERIVED_WITNESS_ENTITIES, SHIFTED_ENTITIES // clang-format on @@ -118,12 +118,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 16; - static constexpr size_t NUM_WITNESS_ENTITIES = 696; - static constexpr size_t NUM_SHIFTED_ENTITIES = 74; + static constexpr size_t NUM_WITNESS_ENTITIES = 680; + static constexpr size_t NUM_SHIFTED_ENTITIES = 46; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 786; + static constexpr size_t NUM_ALL_ENTITIES = 742; // The total number of witnesses including shifts and derived entities. static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES;