From a974ec82d01595bd4245fa8ac44e25f4b57cf397 Mon Sep 17 00:00:00 2001 From: Leila Wang Date: Mon, 8 Apr 2024 15:56:03 +0100 Subject: [PATCH] feat: only export values from accumulated data (#5604) Exporting note hashes and nullifiers as fields instead of side effects from CombinedAccumulatedData. --- .../src/private_kernel_tail.nr | 30 +- .../src/private_kernel_tail_to_public.nr | 26 +- .../rollup-lib/src/base/base_rollup_inputs.nr | 8 +- .../crates/rollup-lib/src/components.nr | 4 +- .../crates/types/src/abis/accumulated_data.nr | 2 - .../combined_accumulated_data.nr | 8 +- .../combined_accumulated_data_builder.nr | 42 -- .../private_accumulated_data_builder.nr | 4 +- .../crates/types/src/hash.nr | 19 - .../crates/types/src/tests/fixture_builder.nr | 17 +- yarn-project/circuit-types/src/mocks.ts | 4 +- .../circuit-types/src/tx/processed_tx.ts | 6 +- yarn-project/circuit-types/src/tx/tx.ts | 4 +- yarn-project/circuits.js/package.json | 1 + yarn-project/circuits.js/src/index.ts | 1 + .../src/interfaces/index.ts | 4 + .../kernel/combined_accumulated_data.ts | 13 +- .../kernel/kernel_circuit_public_inputs.ts | 2 +- ...ivate_kernel_tail_circuit_public_inputs.ts | 8 +- .../circuits.js/src/structs/side_effects.ts | 10 - .../circuits.js/src/tests/factories.ts | 9 +- yarn-project/circuits.js/src/utils/index.ts | 40 +- .../circuits.js/src/utils/utils.test.ts | 157 ++-- .../src/integration_l1_publisher.test.ts | 14 +- yarn-project/foundation/package.json | 1 - yarn-project/foundation/src/index.ts | 1 - .../src/__snapshots__/index.test.ts.snap | 704 ++++-------------- .../src/type_conversion.ts | 8 +- .../orchestrator/block-building-helpers.ts | 4 +- .../src/orchestrator/orchestrator.test.ts | 28 +- .../src/kernel_prover/kernel_prover.test.ts | 7 +- .../src/sequencer/sequencer.test.ts | 2 +- .../src/sequencer/tail_phase_manager.ts | 27 +- .../src/sequencer/tx_validator.ts | 2 +- 34 files changed, 353 insertions(+), 864 deletions(-) delete mode 100644 noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data_builder.nr rename yarn-project/{foundation => circuits.js}/src/interfaces/index.ts (52%) diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr index a655a8f017c..9c1d74fe688 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail.nr @@ -71,7 +71,7 @@ mod tests { kernel_circuit_public_inputs::KernelCircuitPublicInputs, max_block_number::MaxBlockNumber, side_effect::{SideEffect, SideEffectLinkedToNoteHash, Ordered} }, - hash::compute_unique_siloed_note_hashes, + hash::{compute_note_hash_nonce, compute_unique_siloed_note_hash}, tests::{fixture_builder::FixtureBuilder, sort::sort_get_sorted_hints}, utils::{arrays::{array_eq, array_length}}, traits::{Empty, is_empty, is_empty_array} }; @@ -98,12 +98,16 @@ mod tests { // A helper function that uses the first nullifer in the previous kernel to compute the unique siloed // note_hashes for the given note_hashes. - pub fn compute_unique_siloed_note_hashes( - self, - note_hashes: [SideEffect; N] - ) -> [SideEffect; N] { + pub fn compute_unique_siloed_note_hashes(self, note_hashes: [SideEffect; N]) -> [Field; N] { let first_nullifier = self.previous_kernel.new_nullifiers.get_unchecked(0); - compute_unique_siloed_note_hashes(first_nullifier.value, note_hashes) + let mut unique_siloed_note_hashes = [0; N]; + for i in 0..N { + if note_hashes[i].value != 0 { + let nonce = compute_note_hash_nonce(first_nullifier.value, i); + unique_siloed_note_hashes[i] = compute_unique_siloed_note_hash(nonce, note_hashes[i].value); + } + } + unique_siloed_note_hashes } pub fn add_pending_note_hash_read_request(&mut self, note_hash_index: u64) { @@ -271,7 +275,7 @@ mod tests { assert( array_eq( public_inputs.end.new_nullifiers, - [new_nullifiers[0], new_nullifiers[2]] + [new_nullifiers[0].value, new_nullifiers[2].value] ) ); } @@ -298,7 +302,7 @@ mod tests { assert( array_eq( public_inputs.end.new_nullifiers, - [new_nullifiers[0], new_nullifiers[2]] + [new_nullifiers[0].value, new_nullifiers[2].value] ) ); } @@ -317,7 +321,7 @@ mod tests { // Only the first nullifier is left after squashing. assert(is_empty_array(public_inputs.end.new_note_hashes)); - assert(array_eq(public_inputs.end.new_nullifiers, [new_nullifiers[0]])); + assert(array_eq(public_inputs.end.new_nullifiers, [new_nullifiers[0].value])); } #[test] @@ -341,17 +345,13 @@ mod tests { builder.previous_kernel.new_note_hashes.extend_from_array(reversed_note_hashes); builder.previous_kernel.new_nullifiers.extend_from_array(reversed_nullifiers); - let sorted_unique_note_hashes = compute_unique_siloed_note_hashes( - // tx nullifier is part of non revertible accumulated data - builder.previous_kernel.new_nullifiers.get_unchecked(0).value, - sorted_note_hashes - ); + let sorted_unique_note_hashes = builder.compute_unique_siloed_note_hashes(sorted_note_hashes); let public_inputs = builder.execute(); for i in 0..10 { assert(public_inputs.end.new_note_hashes[i].eq(sorted_unique_note_hashes[i])); - assert(public_inputs.end.new_nullifiers[i].eq(sorted_nullifiers[i])); + assert(public_inputs.end.new_nullifiers[i].eq(sorted_nullifiers[i].value)); } } diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr index 7d0635d44c4..e6a9c96be08 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/private_kernel_tail_to_public.nr @@ -71,7 +71,7 @@ mod tests { kernel_circuit_public_inputs::PublicKernelCircuitPublicInputs, side_effect::{SideEffect, SideEffectLinkedToNoteHash, Ordered} }, - hash::compute_unique_siloed_note_hashes, + hash::{compute_note_hash_nonce, compute_unique_siloed_note_hash}, tests::{fixture_builder::FixtureBuilder, sort::sort_get_sorted_hints}, utils::{arrays::{array_eq, array_length}}, traits::is_empty_array }; @@ -104,7 +104,17 @@ mod tests { note_hashes: [SideEffect; N] ) -> [SideEffect; N] { let first_nullifier = self.previous_kernel.new_nullifiers.get_unchecked(0); - compute_unique_siloed_note_hashes(first_nullifier.value, note_hashes) + let mut unique_siloed_note_hashes = [SideEffect::empty(); N]; + for i in 0..N { + if note_hashes[i].value != 0 { + let nonce = compute_note_hash_nonce(first_nullifier.value, i); + unique_siloed_note_hashes[i] = SideEffect { + value: compute_unique_siloed_note_hash(nonce, note_hashes[i].value), + counter: note_hashes[i].counter, + }; + } + } + unique_siloed_note_hashes } pub fn add_pending_note_hash_read_request(&mut self, note_hash_index: u64) { @@ -367,11 +377,7 @@ mod tests { builder.previous_kernel.new_note_hashes.extend_from_array(reversed_note_hashes); builder.previous_kernel.new_nullifiers.extend_from_array(reversed_nullifiers); - let sorted_unique_note_hashes = compute_unique_siloed_note_hashes( - // tx nullifier is part of non revertible accumulated data - builder.previous_kernel.new_nullifiers.get_unchecked(0).value, - sorted_note_hashes - ); + let sorted_unique_note_hashes = builder.compute_unique_siloed_note_hashes(sorted_note_hashes); let public_inputs = builder.execute(); @@ -470,11 +476,7 @@ mod tests { let new_note_hashes = builder.previous_kernel.new_note_hashes.storage; let public_inputs = builder.execute(); - let siloed_note_hashes = compute_unique_siloed_note_hashes( - // tx nullifier is part of non revertible accumulated data - public_inputs.end_non_revertible.new_nullifiers[0].value, - new_note_hashes - ); + let siloed_note_hashes = builder.compute_unique_siloed_note_hashes(new_note_hashes); assert( array_eq( diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr index 60f2bc65163..498632b4bd1 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/base_rollup_inputs.nr @@ -13,7 +13,7 @@ use dep::types::{ membership_witness::{ArchiveRootMembershipWitness, NullifierMembershipWitness, PublicDataMembershipWitness}, nullifier_leaf_preimage::NullifierLeafPreimage, public_data_update_request::PublicDataUpdateRequest, public_data_read::PublicDataRead, kernel_data::KernelData, - side_effect::{SideEffect, SideEffectLinkedToNoteHash}, accumulated_data::CombinedAccumulatedData + side_effect::{SideEffect, SideEffectLinkedToNoteHash} }, constants::{ NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, @@ -126,13 +126,13 @@ impl BaseRollupInputs { // TODO(Kev): This should say calculate_commitments_subtree_root // Cpp code says calculate_commitments_subtree, so I'm leaving it as is for now fn calculate_commitments_subtree(self) -> Field { - calculate_subtree_root(self.kernel_data.public_inputs.end.new_note_hashes.map(|c: SideEffect| c.value)) + calculate_subtree_root(self.kernel_data.public_inputs.end.new_note_hashes) } fn check_nullifier_tree_non_membership_and_insert_to_tree(self) -> AppendOnlyTreeSnapshot { indexed_tree::batch_insert( self.start.nullifier_tree, - self.kernel_data.public_inputs.end.new_nullifiers.map(|nullifier: SideEffectLinkedToNoteHash| nullifier.value), + self.kernel_data.public_inputs.end.new_nullifiers, self.state_diff_hints.sorted_nullifiers, self.state_diff_hints.sorted_nullifier_indexes, self.state_diff_hints.nullifier_subtree_sibling_path, @@ -580,7 +580,7 @@ mod tests { let low_index = self.new_nullifiers.get_unchecked(original_index).existing_index; - kernel_data.public_inputs.end.new_nullifiers[original_index].value = new_nullifier; + kernel_data.public_inputs.end.new_nullifiers[original_index] = new_nullifier; let mut low_preimage = pre_existing_nullifiers[low_index]; nullifier_predecessor_preimages[i] = low_preimage; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index 7b79a319548..e9ff3019cbb 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -154,12 +154,12 @@ pub fn compute_tx_effects_hash(combined: CombinedAccumulatedData, revert_code: u offset += 1; for j in 0..MAX_NEW_NOTE_HASHES_PER_TX { - txs_effects_hash_input[offset + j] = new_note_hashes[j].value; + txs_effects_hash_input[offset + j] = new_note_hashes[j]; } offset += MAX_NEW_NOTE_HASHES_PER_TX ; for j in 0..MAX_NEW_NULLIFIERS_PER_TX { - txs_effects_hash_input[offset + j] = new_nullifiers[j].value; + txs_effects_hash_input[offset + j] = new_nullifiers[j]; } offset += MAX_NEW_NULLIFIERS_PER_TX ; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data.nr index 335ee3d7a23..2e8ec3cef79 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data.nr @@ -1,5 +1,4 @@ mod combined_accumulated_data; -mod combined_accumulated_data_builder; mod private_accumulated_data; mod private_accumulated_data_builder; mod public_accumulated_data; @@ -7,7 +6,6 @@ mod public_accumulated_data_builder; use crate::abis::accumulated_data::{ combined_accumulated_data::CombinedAccumulatedData, - combined_accumulated_data_builder::CombinedAccumulatedDataBuilder, private_accumulated_data::PrivateAccumulatedData, private_accumulated_data_builder::PrivateAccumulatedDataBuilder, public_accumulated_data::PublicAccumulatedData, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr index 97f10103185..9595eadf453 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data.nr @@ -12,8 +12,8 @@ use crate::{ }; struct CombinedAccumulatedData { - new_note_hashes: [SideEffect; MAX_NEW_NOTE_HASHES_PER_TX], - new_nullifiers: [SideEffectLinkedToNoteHash; MAX_NEW_NULLIFIERS_PER_TX], + new_note_hashes: [Field; MAX_NEW_NOTE_HASHES_PER_TX], + new_nullifiers: [Field; MAX_NEW_NULLIFIERS_PER_TX], new_l2_to_l1_msgs: [Field; MAX_NEW_L2_TO_L1_MSGS_PER_TX], encrypted_logs_hash: Field, @@ -30,8 +30,8 @@ struct CombinedAccumulatedData { impl CombinedAccumulatedData { pub fn recombine(non_revertible: PublicAccumulatedData, revertible: PublicAccumulatedData) -> Self { CombinedAccumulatedData { - new_note_hashes: array_merge(non_revertible.new_note_hashes, revertible.new_note_hashes), - new_nullifiers: array_merge(non_revertible.new_nullifiers, revertible.new_nullifiers), + new_note_hashes: array_merge(non_revertible.new_note_hashes, revertible.new_note_hashes).map(|n: SideEffect| n.value), + new_nullifiers: array_merge(non_revertible.new_nullifiers, revertible.new_nullifiers).map(|n: SideEffectLinkedToNoteHash| n.value), new_l2_to_l1_msgs: revertible.new_l2_to_l1_msgs, encrypted_logs_hash: revertible.encrypted_logs_hash, unencrypted_logs_hash: revertible.unencrypted_logs_hash, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data_builder.nr deleted file mode 100644 index 375fc530327..00000000000 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/combined_accumulated_data_builder.nr +++ /dev/null @@ -1,42 +0,0 @@ -use crate::{ - abis::{ - accumulated_data::combined_accumulated_data::CombinedAccumulatedData, - public_data_update_request::PublicDataUpdateRequest, - side_effect::{SideEffect, SideEffectLinkedToNoteHash} -} -}; -use crate::constants::{ - MAX_NEW_NOTE_HASHES_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX -}; - -struct CombinedAccumulatedDataBuilder { - new_note_hashes: BoundedVec, - new_nullifiers: BoundedVec, - new_l2_to_l1_msgs: BoundedVec, - - encrypted_logs_hash: Field, - unencrypted_logs_hash: Field, - - // Here so that the gas cost of this request can be measured by circuits, without actually needing to feed in the - // variable-length data. - encrypted_log_preimages_length: Field, - unencrypted_log_preimages_length: Field, - - public_data_update_requests: BoundedVec, -} - -impl CombinedAccumulatedDataBuilder { - pub fn finish(self) -> CombinedAccumulatedData { - CombinedAccumulatedData { - new_note_hashes: self.new_note_hashes.storage, - new_nullifiers: self.new_nullifiers.storage, - new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage, - encrypted_logs_hash: self.encrypted_logs_hash, - unencrypted_logs_hash: self.unencrypted_logs_hash, - encrypted_log_preimages_length: self.encrypted_log_preimages_length, - unencrypted_log_preimages_length: self.unencrypted_log_preimages_length, - public_data_update_requests: self.public_data_update_requests.storage - } - } -} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr index 0fed9cb468f..eca17161fc4 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/accumulated_data/private_accumulated_data_builder.nr @@ -50,8 +50,8 @@ impl PrivateAccumulatedDataBuilder { pub fn to_combined(self) -> CombinedAccumulatedData { CombinedAccumulatedData { - new_note_hashes: self.new_note_hashes.storage, - new_nullifiers: self.new_nullifiers.storage, + new_note_hashes: self.new_note_hashes.storage.map(|n: SideEffect| n.value), + new_nullifiers: self.new_nullifiers.storage.map(|n: SideEffectLinkedToNoteHash| n.value), new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage, encrypted_logs_hash: self.encrypted_logs_hash, unencrypted_logs_hash: self.unencrypted_logs_hash, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr index 9e632b6e1b5..396ed601c2f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/hash.nr @@ -3,7 +3,6 @@ use crate::mocked::VerificationKey; use crate::abis::function_selector::FunctionSelector; use crate::abis::contract_class_function_leaf_preimage::ContractClassFunctionLeafPreimage; use crate::contract_class_id::ContractClassId; -use crate::abis::side_effect::SideEffect; use crate::utils::{uint256::U256, field::field_from_bytes_32_trunc}; use crate::constants::{ FUNCTION_TREE_HEIGHT, GENERATOR_INDEX__SILOED_NOTE_HASH, GENERATOR_INDEX__OUTER_NULLIFIER, @@ -148,24 +147,6 @@ pub fn compute_unique_siloed_note_hash(nonce: Field, siloed_note_hash: Field) -> ) } -pub fn compute_unique_siloed_note_hashes( - first_nullifier: Field, - siloed_note_hashes: [SideEffect; N] -) -> [SideEffect; N] { - let mut unique_siloed_note_hashes = [SideEffect::empty(); N]; - for i in 0..N { - let siloed_note_hash = siloed_note_hashes[i]; - if siloed_note_hash.value != 0 { - let nonce = compute_note_hash_nonce(first_nullifier, i); - unique_siloed_note_hashes[i] = SideEffect { - value: compute_unique_siloed_note_hash(nonce, siloed_note_hash.value), - counter: siloed_note_hash.counter - }; - } - } - unique_siloed_note_hashes -} - pub fn pedersen_hash(inputs: [Field; N], hash_index: u32) -> Field { dep::std::hash::pedersen_hash_with_separator(inputs, hash_index) } 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 4fa846432b5..703b4bd6bfe 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 @@ -2,8 +2,8 @@ use crate::{ abis::{ call_context::CallContext, call_request::{CallerContext, CallRequest}, accumulated_data::{ - CombinedAccumulatedData, CombinedAccumulatedDataBuilder, PrivateAccumulatedData, - PrivateAccumulatedDataBuilder, PublicAccumulatedData, PublicAccumulatedDataBuilder + CombinedAccumulatedData, PrivateAccumulatedData, PrivateAccumulatedDataBuilder, + PublicAccumulatedData, PublicAccumulatedDataBuilder }, combined_constant_data::CombinedConstantData, kernel_circuit_public_inputs::{KernelCircuitPublicInputs, PrivateKernelCircuitPublicInputs, PublicKernelCircuitPublicInputs}, @@ -137,17 +137,16 @@ impl FixtureBuilder { } pub fn to_combined_accumulated_data(self) -> CombinedAccumulatedData { - let public_inputs = CombinedAccumulatedDataBuilder { - new_note_hashes: self.new_note_hashes, - new_nullifiers: self.new_nullifiers, - new_l2_to_l1_msgs: self.new_l2_to_l1_msgs, + CombinedAccumulatedData { + new_note_hashes: self.new_note_hashes.storage.map(|n: SideEffect| n.value), + new_nullifiers: self.new_nullifiers.storage.map(|n: SideEffectLinkedToNoteHash| n.value), + new_l2_to_l1_msgs: self.new_l2_to_l1_msgs.storage, encrypted_logs_hash: self.encrypted_logs_hash, unencrypted_logs_hash: self.unencrypted_logs_hash, encrypted_log_preimages_length: self.encrypted_log_preimages_length, unencrypted_log_preimages_length: self.unencrypted_log_preimages_length, - public_data_update_requests: self.public_data_update_requests - }; - public_inputs.finish() + public_data_update_requests: self.public_data_update_requests.storage + } } pub fn to_validation_requests(self) -> ValidationRequests { diff --git a/yarn-project/circuit-types/src/mocks.ts b/yarn-project/circuit-types/src/mocks.ts index 2bca46b6f83..6b742f38a8e 100644 --- a/yarn-project/circuit-types/src/mocks.ts +++ b/yarn-project/circuit-types/src/mocks.ts @@ -49,7 +49,7 @@ export const mockTx = ( const isForPublic = totalPublicCallRequests > 0; const data = PrivateKernelTailCircuitPublicInputs.empty(); - const firstNullifier = new SideEffectLinkedToNoteHash(new Fr(seed), new Fr(seed + 1), Fr.ZERO); + const firstNullifier = new SideEffectLinkedToNoteHash(new Fr(seed + 1), new Fr(seed + 2), Fr.ZERO); if (isForPublic) { data.forRollup = undefined; @@ -67,7 +67,7 @@ export const mockTx = ( : CallRequest.empty(), ); } else { - data.forRollup!.end.newNullifiers[0] = firstNullifier; + data.forRollup!.end.newNullifiers[0] = firstNullifier.value; } const target = isForPublic ? data.forPublic! : data.forRollup!; diff --git a/yarn-project/circuit-types/src/tx/processed_tx.ts b/yarn-project/circuit-types/src/tx/processed_tx.ts index b59642ab3b1..a70335cb85f 100644 --- a/yarn-project/circuit-types/src/tx/processed_tx.ts +++ b/yarn-project/circuit-types/src/tx/processed_tx.ts @@ -13,8 +13,6 @@ import { KernelCircuitPublicInputs, type Proof, type PublicKernelCircuitPublicInputs, - type SideEffect, - type SideEffectLinkedToNoteHash, makeEmptyProof, } from '@aztec/circuits.js'; @@ -131,8 +129,8 @@ export function makeEmptyProcessedTx(header: Header, chainId: Fr, version: Fr): export function toTxEffect(tx: ProcessedTx): TxEffect { return new TxEffect( tx.data.revertCode, - tx.data.end.newNoteHashes.map((c: SideEffect) => c.value).filter(h => !h.isZero()), - tx.data.end.newNullifiers.map((n: SideEffectLinkedToNoteHash) => n.value).filter(h => !h.isZero()), + tx.data.end.newNoteHashes.filter(h => !h.isZero()), + tx.data.end.newNullifiers.filter(h => !h.isZero()), tx.data.end.newL2ToL1Msgs.filter(h => !h.isZero()), tx.data.end.publicDataUpdateRequests .map(t => new PublicDataWrite(t.leafSlot, t.newValue)) diff --git a/yarn-project/circuit-types/src/tx/tx.ts b/yarn-project/circuit-types/src/tx/tx.ts index bfa009872fc..02d4273ab6a 100644 --- a/yarn-project/circuit-types/src/tx/tx.ts +++ b/yarn-project/circuit-types/src/tx/tx.ts @@ -139,10 +139,10 @@ export class Tx { getTxHash(): TxHash { // Private kernel functions are executed client side and for this reason tx hash is already set as first nullifier const firstNullifier = this.data.getNonEmptyNullifiers()[0]; - if (!firstNullifier || firstNullifier.isEmpty()) { + if (!firstNullifier || firstNullifier.isZero()) { throw new Error(`Cannot get tx hash since first nullifier is missing`); } - return new TxHash(firstNullifier.value.toBuffer()); + return new TxHash(firstNullifier.toBuffer()); } /** Returns stats about this tx. */ diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index ad9e4e7cd81..1c2c3ea55b9 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -11,6 +11,7 @@ "./hash": "./dest/hash/index.js", "./barretenberg": "./dest/barretenberg/index.js", "./testing": "./dest/tests/index.js", + "./interfaces": "./dest/interfaces/index.js", "./utils": "./dest/utils/index.js", "./types": "./dest/types/index.js", "./constants": "./dest/constants.gen.js", diff --git a/yarn-project/circuits.js/src/index.ts b/yarn-project/circuits.js/src/index.ts index f74c41c5932..3b6fdbcd0e6 100644 --- a/yarn-project/circuits.js/src/index.ts +++ b/yarn-project/circuits.js/src/index.ts @@ -2,6 +2,7 @@ export * from './constants.gen.js'; export * from './contract/index.js'; export * from './debug_log.js'; export * from './hints/index.js'; +export * from './interfaces/index.js'; export * from './keys/index.js'; export * from './structs/index.js'; export * from './types/index.js'; diff --git a/yarn-project/foundation/src/interfaces/index.ts b/yarn-project/circuits.js/src/interfaces/index.ts similarity index 52% rename from yarn-project/foundation/src/interfaces/index.ts rename to yarn-project/circuits.js/src/interfaces/index.ts index 5672d325649..a0d93eab93d 100644 --- a/yarn-project/foundation/src/interfaces/index.ts +++ b/yarn-project/circuits.js/src/interfaces/index.ts @@ -1,3 +1,7 @@ export interface IsEmpty { isEmpty: () => boolean; } + +export interface Ordered { + counter: number; +} diff --git a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts index 66be5891125..07700e094ea 100644 --- a/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts +++ b/yarn-project/circuits.js/src/structs/kernel/combined_accumulated_data.ts @@ -10,7 +10,6 @@ import { MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, } from '../../constants.gen.js'; import { PublicDataUpdateRequest } from '../public_data_update_request.js'; -import { SideEffect, SideEffectLinkedToNoteHash } from '../side_effects.js'; /** * Data that is accumulated during the execution of the transaction. @@ -20,11 +19,11 @@ export class CombinedAccumulatedData { /** * The new note hashes made in this transaction. */ - public newNoteHashes: Tuple, + public newNoteHashes: Tuple, /** * The new nullifiers made in this transaction. */ - public newNullifiers: Tuple, + public newNullifiers: Tuple, /** * All the new L2 to L1 messages created in this transaction. */ @@ -78,8 +77,8 @@ export class CombinedAccumulatedData { static fromBuffer(buffer: Buffer | BufferReader): CombinedAccumulatedData { const reader = BufferReader.asReader(buffer); return new CombinedAccumulatedData( - reader.readArray(MAX_NEW_NOTE_HASHES_PER_TX, SideEffect), - reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, SideEffectLinkedToNoteHash), + reader.readArray(MAX_NEW_NOTE_HASHES_PER_TX, Fr), + reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), reader.readArray(MAX_NEW_L2_TO_L1_MSGS_PER_TX, Fr), Fr.fromBuffer(reader), Fr.fromBuffer(reader), @@ -100,8 +99,8 @@ export class CombinedAccumulatedData { static empty() { return new CombinedAccumulatedData( - makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, SideEffect.empty), - makeTuple(MAX_NEW_NULLIFIERS_PER_TX, SideEffectLinkedToNoteHash.empty), + makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, Fr.zero), + makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, Fr.zero), Fr.zero(), Fr.zero(), diff --git a/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.ts index 61f8ae1d479..cb59c58b76d 100644 --- a/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/kernel/kernel_circuit_public_inputs.ts @@ -35,7 +35,7 @@ export class KernelCircuitPublicInputs { ) {} getNonEmptyNullifiers() { - return this.end.newNullifiers.filter(n => !n.isEmpty()); + return this.end.newNullifiers.filter(n => !n.isZero()); } toBuffer() { diff --git a/yarn-project/circuits.js/src/structs/kernel/private_kernel_tail_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/kernel/private_kernel_tail_circuit_public_inputs.ts index 641f0ded81f..cc7ac7fb8b4 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_kernel_tail_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_kernel_tail_circuit_public_inputs.ts @@ -152,9 +152,9 @@ export class PrivateKernelTailCircuitPublicInputs { MAX_NEW_NULLIFIERS_PER_TX, this.forPublic.endNonRevertibleData.newNoteHashes, this.forPublic.end.newNoteHashes, - ) + ).map(n => n.value) : this.forRollup!.end.newNoteHashes; - return noteHashes.filter(n => !n.isEmpty()); + return noteHashes.filter(n => !n.isZero()); } getNonEmptyNullifiers() { @@ -163,9 +163,9 @@ export class PrivateKernelTailCircuitPublicInputs { MAX_NEW_NULLIFIERS_PER_TX, this.forPublic.endNonRevertibleData.newNullifiers, this.forPublic.end.newNullifiers, - ) + ).map(n => n.value) : this.forRollup!.end.newNullifiers; - return nullifiers.filter(n => !n.isEmpty()); + return nullifiers.filter(n => !n.isZero()); } static fromBuffer(buffer: Buffer | BufferReader): PrivateKernelTailCircuitPublicInputs { diff --git a/yarn-project/circuits.js/src/structs/side_effects.ts b/yarn-project/circuits.js/src/structs/side_effects.ts index e91c0bb3356..9e09b15255a 100644 --- a/yarn-project/circuits.js/src/structs/side_effects.ts +++ b/yarn-project/circuits.js/src/structs/side_effects.ts @@ -190,13 +190,3 @@ export function nonEmptySideEffects(sideEffects: SideEffectType[]): SideEffectTy export function sideEffectArrayToValueArray(sideEffects: SideEffectType[]): Fr[] { return sideEffects.map(sideEffect => sideEffect.value); } - -/** - * Compare two side effects based on their counter. - * @param a - A side effect - * @param b - Another side effect - * @returns - The order of the two side effects - */ -export function sideEffectCmp(a: SideEffectType, b: SideEffectType): -1 | 0 | 1 { - return a.counter.cmp(b.counter); -} diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index ea651678f24..a765a4065be 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -287,13 +287,8 @@ export function makeCombinedAccumulatedData(seed = 1, full = false): CombinedAcc const tupleGenerator = full ? makeTuple : makeHalfFullTuple; return new CombinedAccumulatedData( - tupleGenerator(MAX_NEW_NOTE_HASHES_PER_TX, sideEffectFromNumber, seed + 0x120, SideEffect.empty), - tupleGenerator( - MAX_NEW_NULLIFIERS_PER_TX, - sideEffectLinkedFromNumber, - seed + 0x200, - SideEffectLinkedToNoteHash.empty, - ), + tupleGenerator(MAX_NEW_NOTE_HASHES_PER_TX, fr, seed + 0x120, Fr.zero), + tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200, Fr.zero), tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x600, Fr.zero), fr(seed + 0x700), // encrypted logs hash fr(seed + 0x800), // unencrypted logs hash diff --git a/yarn-project/circuits.js/src/utils/index.ts b/yarn-project/circuits.js/src/utils/index.ts index 9863d50ffce..18ce9109990 100644 --- a/yarn-project/circuits.js/src/utils/index.ts +++ b/yarn-project/circuits.js/src/utils/index.ts @@ -1,6 +1,7 @@ -import { type IsEmpty } from '@aztec/foundation/interfaces'; import { type Tuple } from '@aztec/foundation/serialize'; +import { type IsEmpty, type Ordered } from '../interfaces/index.js'; + // Define these utils here as their design is very specific to kernel's accumulated data and not general enough to be put in foundation. // Returns number of non-empty items in an array. @@ -33,27 +34,18 @@ export function mergeAccumulatedData( return arr; } -// Combines an array of length N and an array of length M into an array of length N + M. -// All non-empty items are aggregated continuously from index 0. -export function concatAccumulatedData( - length: NM, - arr0: Tuple, - arr1: Tuple, -): Tuple { - const combinedLength = arr0.length + arr1.length; - if (combinedLength !== length) { - throw new Error(`Provided length does not match combined length. Expected ${combinedLength}. Got ${length}.`); - } - - const numNonEmptyItems0 = countAccumulatedItems(arr0); - const numNonEmptyItems1 = countAccumulatedItems(arr1); - const arr = [...arr0, ...arr1] as Tuple; - if (numNonEmptyItems0 < arr0.length) { - const emptyItem = arr0[numNonEmptyItems0]; - arr1.slice(0, numNonEmptyItems1).forEach((item, i) => { - arr[i + numNonEmptyItems0] = item; - arr[arr0.length + i] = emptyItem; - }); - } - return arr; +// Sort items by their counters in ascending order. All empty items (counter === 0) are padded to the right. +export function sortByCounter(arr: T[]): T[] { + return [...arr].sort((a, b) => { + if (a.counter === b.counter) { + return 0; + } + if (a.counter === 0) { + return 1; // Move empty items to the right. + } + if (b.counter === 0) { + return -1; // Move non-empty items to the left. + } + return a.counter - b.counter; + }); } diff --git a/yarn-project/circuits.js/src/utils/utils.test.ts b/yarn-project/circuits.js/src/utils/utils.test.ts index 80e46e7e93b..3fe9bf564aa 100644 --- a/yarn-project/circuits.js/src/utils/utils.test.ts +++ b/yarn-project/circuits.js/src/utils/utils.test.ts @@ -1,18 +1,18 @@ import { makeTuple } from '@aztec/foundation/array'; -import { type IsEmpty } from '@aztec/foundation/interfaces'; import { type Tuple } from '@aztec/foundation/serialize'; -import { concatAccumulatedData, countAccumulatedItems, mergeAccumulatedData } from './index.js'; +import { type IsEmpty } from '../interfaces/index.js'; +import { countAccumulatedItems, mergeAccumulatedData, sortByCounter } from './index.js'; class TestItem { - constructor(public value: number) {} + constructor(public value: number, public counter = 0) {} static empty() { return new TestItem(0); } isEmpty() { - return this.value === 0; + return !this.value && !this.counter; } } @@ -103,71 +103,102 @@ describe('hints utils', () => { }); }); - describe('concatAccumulatedData', () => { - const length0 = 3; - const length1 = 5; - const length = length0 + length1; - let arr0: Tuple; - let arr1: Tuple; - - beforeEach(() => { - arr0 = makeTuple(length0, TestItem.empty); - arr1 = makeTuple(length1, TestItem.empty); - }); - - it('propagates items from arr0', () => { - arr0[0] = new TestItem(12); - arr0[1] = new TestItem(34); - const nullifiers = concatAccumulatedData(length, arr0, arr1); - expect(nullifiers.slice(0, 2)).toEqual([arr0[0], arr0[1]]); - expectEmptyArrays(nullifiers.slice(2)); - }); + describe('sortByCounter', () => { + it('sorts descending items in ascending order', () => { + // Original array is in descending order. + const arr: TestItem[] = []; + for (let i = 0; i < 6; ++i) { + arr[i] = new TestItem(i, 100 - i); + } - it('propagates items from arr1', () => { - arr1[0] = new TestItem(1); - arr1[1] = new TestItem(2); - const nullifiers = concatAccumulatedData(length, arr0, arr1); - expect(nullifiers.slice(0, 2)).toEqual([arr1[0], arr1[1]]); - expectEmptyArrays(nullifiers.slice(2)); - }); + const sorted = sortByCounter(arr); - it('combines items from both arrays', () => { - arr0[0] = new TestItem(12); - arr0[1] = new TestItem(34); - arr1[0] = new TestItem(1); - arr1[1] = new TestItem(2); - const nullifiers = concatAccumulatedData(length, arr0, arr1); - expect(nullifiers.slice(0, 4)).toEqual([arr0[0], arr0[1], arr1[0], arr1[1]]); - expectEmptyArrays(nullifiers.slice(4)); - }); - - it('combines all items from both arrays', () => { - arr0 = makeTuple(length0, i => new TestItem(i + 1)); - arr1 = makeTuple(length1, i => new TestItem(i + 999)); - const nullifiers = concatAccumulatedData(length, arr0, arr1); - expect(nullifiers).toEqual([...arr0, ...arr1]); + for (let i = 1; i < arr.length; ++i) { + expect(sorted[i].counter).toBeGreaterThan(sorted[i - 1].counter); + } + expect(sorted).toEqual(arr.slice().reverse()); }); - it('throws if given length is incorrect', () => { - expect(() => concatAccumulatedData(length + 1, arr0, arr1)).toThrow( - /Provided length does not match combined length./, - ); - }); + it('sorts ascending items in ascending order', () => { + const arr: TestItem[] = []; + for (let i = 0; i < 6; ++i) { + arr[i] = new TestItem(i, i + 1); + } - it('throws if arr0 contains non-continuous items', () => { - arr0[0] = new TestItem(12); - arr0[2] = new TestItem(34); - expect(() => concatAccumulatedData(length, arr0, arr1)).toThrow( - 'Non-empty items must be placed continuously from index 0.', - ); - }); + const sorted = sortByCounter(arr); - it('throws if arr1 contains non-continuous items', () => { - arr1[0] = new TestItem(12); - arr1[2] = new TestItem(34); - expect(() => concatAccumulatedData(length, arr0, arr1)).toThrow( - 'Non-empty items must be placed continuously from index 0.', - ); + for (let i = 1; i < arr.length; ++i) { + expect(sorted[i].counter).toBeGreaterThan(sorted[i - 1].counter); + } + expect(sorted).toEqual(arr); + }); + + it('sorts random items in ascending order', () => { + const arr: TestItem[] = [ + new TestItem(2, 13), + new TestItem(3, 328), + new TestItem(4, 4), + new TestItem(5, 59), + new TestItem(6, 1), + ]; + + const sorted = sortByCounter(arr); + + expect(sorted).toEqual([ + new TestItem(6, 1), + new TestItem(4, 4), + new TestItem(2, 13), + new TestItem(5, 59), + new TestItem(3, 328), + ]); + }); + + it('sorts random items and keep empty items to the right', () => { + const arr: TestItem[] = [ + new TestItem(2, 13), + new TestItem(3, 328), + new TestItem(4, 4), + new TestItem(5, 59), + new TestItem(6, 1), + TestItem.empty(), + TestItem.empty(), + ]; + + const sorted = sortByCounter(arr); + + expect(sorted).toEqual([ + new TestItem(6, 1), + new TestItem(4, 4), + new TestItem(2, 13), + new TestItem(5, 59), + new TestItem(3, 328), + TestItem.empty(), + TestItem.empty(), + ]); + }); + + it('sorts random items and pads empty items to the right', () => { + const arr: TestItem[] = [ + TestItem.empty(), + new TestItem(2, 13), + new TestItem(3, 328), + new TestItem(4, 4), + new TestItem(5, 59), + TestItem.empty(), + new TestItem(6, 1), + ]; + + const sorted = sortByCounter(arr); + + expect(sorted).toEqual([ + new TestItem(6, 1), + new TestItem(4, 4), + new TestItem(2, 13), + new TestItem(5, 59), + new TestItem(3, 328), + TestItem.empty(), + TestItem.empty(), + ]); }); }); }); diff --git a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts index 3c179d61741..a0669c1d33a 100644 --- a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts @@ -27,9 +27,8 @@ import { MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PublicDataUpdateRequest, - SideEffectLinkedToNoteHash, } from '@aztec/circuits.js'; -import { fr, makeNewSideEffect, makeNewSideEffectLinkedToNoteHash, makeProof } from '@aztec/circuits.js/testing'; +import { fr, makeProof } from '@aztec/circuits.js/testing'; import { type L1ContractAddresses, createEthereumChain } from '@aztec/ethereum'; import { makeTuple, range } from '@aztec/foundation/array'; import { openTmpStore } from '@aztec/kv-store/utils'; @@ -180,14 +179,9 @@ describe('L1Publisher integration', () => { const processedTx = makeProcessedTx(tx, kernelOutput, makeProof()); - processedTx.data.end.newNoteHashes = makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, makeNewSideEffect, seed + 0x100); - processedTx.data.end.newNullifiers = makeTuple( - MAX_NEW_NULLIFIERS_PER_TX, - makeNewSideEffectLinkedToNoteHash, - seed + 0x200, - ); - processedTx.data.end.newNullifiers[processedTx.data.end.newNullifiers.length - 1] = - SideEffectLinkedToNoteHash.empty(); + processedTx.data.end.newNoteHashes = makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, fr, seed + 0x100); + processedTx.data.end.newNullifiers = makeTuple(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200); + processedTx.data.end.newNullifiers[processedTx.data.end.newNullifiers.length - 1] = Fr.ZERO; processedTx.data.end.newL2ToL1Msgs = makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x300); processedTx.data.end.encryptedLogsHash = Fr.fromBuffer(processedTx.encryptedLogs.hash()); processedTx.data.end.unencryptedLogsHash = Fr.fromBuffer(processedTx.unencryptedLogs.hash()); diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 1987eb4f805..04ceb11d013 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -17,7 +17,6 @@ "./error": "./dest/error/index.js", "./eth-address": "./dest/eth-address/index.js", "./fifo": "./dest/fifo/index.js", - "./interfaces": "./dest/interfaces/index.js", "./json-rpc": "./dest/json-rpc/index.js", "./json-rpc/server": "./dest/json-rpc/server/index.js", "./json-rpc/client": "./dest/json-rpc/client/index.js", diff --git a/yarn-project/foundation/src/index.ts b/yarn-project/foundation/src/index.ts index bd36d4b0cf6..7e06583f10d 100644 --- a/yarn-project/foundation/src/index.ts +++ b/yarn-project/foundation/src/index.ts @@ -10,7 +10,6 @@ export * as errors from './errors/index.js'; export * as ethAddress from './eth-address/index.js'; export * as fields from './fields/index.js'; export * as fifo from './fifo/index.js'; -export * as interfaces from './interfaces/index.js'; export * as jsonRpc from './json-rpc/index.js'; export * as jsonRpcClient from './json-rpc/client/index.js'; export * as jsonRpcServer from './json-rpc/server/index.js'; diff --git a/yarn-project/noir-protocol-circuits-types/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-protocol-circuits-types/src/__snapshots__/index.test.ts.snap index 4490cf8b836..9e0de452c9c 100644 --- a/yarn-project/noir-protocol-circuits-types/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-protocol-circuits-types/src/__snapshots__/index.test.ts.snap @@ -1734,584 +1734,136 @@ PrivateKernelTailCircuitPublicInputs { Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, ], "newNoteHashes": [ - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000002>, - "value": Fr<0x0dcb66fbb43a6913e88885837284a9be49d752af2d04d80b9d256d355ce997c2>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffect { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, + Fr<0x0dcb66fbb43a6913e88885837284a9be49d752af2d04d80b9d256d355ce997c2>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, ], "newNullifiers": [ - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x234186448896c6a32b6b07ca8aff31e24cad89898b0ff31c2ee2ca29663af7fa>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000001>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0f95aa9d5d0af78a4d9e4bec46f9a81e75b4fd9f67523422bb4b6e5f0d5be154>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000003>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x1b061f7c46db8c9f35f68521619a97428f4ccf1d6812f11e3439b183292817a7>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, - SideEffectLinkedToNoteHash { - "counter": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "noteHash": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - "value": Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, - }, + Fr<0x234186448896c6a32b6b07ca8aff31e24cad89898b0ff31c2ee2ca29663af7fa>, + Fr<0x0f95aa9d5d0af78a4d9e4bec46f9a81e75b4fd9f67523422bb4b6e5f0d5be154>, + Fr<0x1b061f7c46db8c9f35f68521619a97428f4ccf1d6812f11e3439b183292817a7>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, + Fr<0x0000000000000000000000000000000000000000000000000000000000000000>, ], "publicDataUpdateRequests": [ PublicDataUpdateRequest { 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 baf959d05f9..667bbcf6a98 100644 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts @@ -1072,8 +1072,8 @@ export function mapCombinedAccumulatedDataFromNoir( combinedAccumulatedData: CombinedAccumulatedDataNoir, ): CombinedAccumulatedData { return new CombinedAccumulatedData( - mapTupleFromNoir(combinedAccumulatedData.new_note_hashes, MAX_NEW_NOTE_HASHES_PER_TX, mapSideEffectFromNoir), - mapTupleFromNoir(combinedAccumulatedData.new_nullifiers, MAX_NEW_NULLIFIERS_PER_TX, mapSideEffectLinkedFromNoir), + mapTupleFromNoir(combinedAccumulatedData.new_note_hashes, MAX_NEW_NOTE_HASHES_PER_TX, mapFieldFromNoir), + mapTupleFromNoir(combinedAccumulatedData.new_nullifiers, MAX_NEW_NULLIFIERS_PER_TX, mapFieldFromNoir), mapTupleFromNoir(combinedAccumulatedData.new_l2_to_l1_msgs, MAX_NEW_L2_TO_L1_MSGS_PER_TX, mapFieldFromNoir), mapFieldFromNoir(combinedAccumulatedData.encrypted_logs_hash), mapFieldFromNoir(combinedAccumulatedData.unencrypted_logs_hash), @@ -1091,8 +1091,8 @@ export function mapCombinedAccumulatedDataToNoir( combinedAccumulatedData: CombinedAccumulatedData, ): CombinedAccumulatedDataNoir { return { - new_note_hashes: mapTuple(combinedAccumulatedData.newNoteHashes, mapSideEffectToNoir), - new_nullifiers: mapTuple(combinedAccumulatedData.newNullifiers, mapSideEffectLinkedToNoir), + new_note_hashes: mapTuple(combinedAccumulatedData.newNoteHashes, mapFieldToNoir), + new_nullifiers: mapTuple(combinedAccumulatedData.newNullifiers, mapFieldToNoir), new_l2_to_l1_msgs: mapTuple(combinedAccumulatedData.newL2ToL1Msgs, mapFieldToNoir), encrypted_logs_hash: mapFieldToNoir(combinedAccumulatedData.encryptedLogsHash), unencrypted_logs_hash: mapFieldToNoir(combinedAccumulatedData.unencryptedLogsHash), diff --git a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts index 6cbc988145a..3d214ee8c0d 100644 --- a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts +++ b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts @@ -91,7 +91,7 @@ export async function buildBaseRollupInput( // Update the note hash trees with the new items being inserted to get the new roots // that will be used by the next iteration of the base rollup circuit, skipping the empty ones - const newNoteHashes = tx.data.end.newNoteHashes.map(x => x.value); + const newNoteHashes = tx.data.end.newNoteHashes; await db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, newNoteHashes); // The read witnesses for a given TX should be generated before the writes of the same TX are applied. @@ -106,7 +106,7 @@ export async function buildBaseRollupInput( sortedNewLeavesIndexes, } = await db.batchInsert( MerkleTreeId.NULLIFIER_TREE, - tx.data.end.newNullifiers.map(sideEffectLinkedToNoteHash => sideEffectLinkedToNoteHash.value.toBuffer()), + tx.data.end.newNullifiers.map(n => n.toBuffer()), NULLIFIER_SUBTREE_HEIGHT, ); if (nullifierWitnessLeaves === undefined) { diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator.test.ts index 61d933576c7..b6cda33d01b 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator.test.ts @@ -25,15 +25,10 @@ import { PublicDataTreeLeaf, PublicDataUpdateRequest, type RootRollupPublicInputs, - SideEffect, - SideEffectLinkedToNoteHash, - sideEffectCmp, } from '@aztec/circuits.js'; import { fr, makeBaseOrMergeRollupPublicInputs, - makeNewSideEffect, - makeNewSideEffectLinkedToNoteHash, makeParityPublicInputs, makeProof, makeRootRollupPublicInputs, @@ -130,20 +125,20 @@ describe('prover/tx-prover', () => { MerkleTreeId.NOTE_HASH_TREE, txs.flatMap(tx => padArrayEnd( - tx.data.end.newNoteHashes.filter(x => !x.isEmpty()).sort(sideEffectCmp), - SideEffect.empty(), + tx.data.end.newNoteHashes.filter(x => !x.isZero()), + Fr.zero(), MAX_NEW_NOTE_HASHES_PER_TX, - ).map(l => l.value), + ), ), ); await expectsDb.batchInsert( MerkleTreeId.NULLIFIER_TREE, txs.flatMap(tx => padArrayEnd( - tx.data.end.newNullifiers.filter(x => !x.isEmpty()).sort(sideEffectCmp), - SideEffectLinkedToNoteHash.empty(), + tx.data.end.newNullifiers.filter(x => !x.isZero()), + Fr.zero(), MAX_NEW_NULLIFIERS_PER_TX, - ).map(x => x.value.toBuffer()), + ).map(x => x.toBuffer()), ), NULLIFIER_SUBTREE_HEIGHT, ); @@ -247,15 +242,10 @@ describe('prover/tx-prover', () => { const processedTx = makeProcessedTx(tx, kernelOutput, makeProof()); - processedTx.data.end.newNoteHashes = makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, makeNewSideEffect, seed + 0x100); - processedTx.data.end.newNullifiers = makeTuple( - MAX_NEW_NULLIFIERS_PER_TX, - makeNewSideEffectLinkedToNoteHash, - seed + 0x100000, - ); + processedTx.data.end.newNoteHashes = makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, fr, seed + 0x100); + processedTx.data.end.newNullifiers = makeTuple(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x100000); - processedTx.data.end.newNullifiers[tx.data.forPublic!.end.newNullifiers.length - 1] = - SideEffectLinkedToNoteHash.empty(); + processedTx.data.end.newNullifiers[tx.data.forPublic!.end.newNullifiers.length - 1] = Fr.zero(); processedTx.data.end.newL2ToL1Msgs = makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x300); processedTx.data.end.encryptedLogsHash = Fr.fromBuffer(processedTx.encryptedLogs.hash()); diff --git a/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts b/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts index 8e7394b5dd9..c8638d6dc95 100644 --- a/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts +++ b/yarn-project/pxe/src/kernel_prover/kernel_prover.test.ts @@ -96,12 +96,11 @@ describe('Kernel Prover', () => { const createProofOutputFinal = (newNoteIndices: number[]) => { const publicInputs = PrivateKernelTailCircuitPublicInputs.empty(); - const commitments = makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, () => SideEffect.empty()); + const noteHashes = makeTuple(MAX_NEW_NOTE_HASHES_PER_TX, () => Fr.ZERO); for (let i = 0; i < newNoteIndices.length; i++) { - commitments[i] = new SideEffect(generateFakeSiloedCommitment(notesAndSlots[newNoteIndices[i]]), Fr.ZERO); + noteHashes[i] = generateFakeSiloedCommitment(notesAndSlots[newNoteIndices[i]]); } - - publicInputs.forRollup!.end.newNoteHashes = commitments; + publicInputs.forRollup!.end.newNoteHashes = noteHashes; return { publicInputs, diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index fafbf634235..76d6fb6a050 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -172,7 +172,7 @@ describe('sequencer', () => { ); // We make a nullifier from tx1 a part of the nullifier tree, so it gets rejected as double spend - const doubleSpendNullifier = doubleSpendTx.data.forRollup!.end.newNullifiers[0].value.toBuffer(); + const doubleSpendNullifier = doubleSpendTx.data.forRollup!.end.newNullifiers[0].toBuffer(); merkleTreeOps.findLeafIndex.mockImplementation((treeId: MerkleTreeId, value: any) => { return Promise.resolve( treeId === MerkleTreeId.NULLIFIER_TREE && value.equals(doubleSpendNullifier) ? 1n : undefined, diff --git a/yarn-project/sequencer-client/src/sequencer/tail_phase_manager.ts b/yarn-project/sequencer-client/src/sequencer/tail_phase_manager.ts index e41a05b818b..748dca637cd 100644 --- a/yarn-project/sequencer-client/src/sequencer/tail_phase_manager.ts +++ b/yarn-project/sequencer-client/src/sequencer/tail_phase_manager.ts @@ -1,14 +1,17 @@ import { type Tx } from '@aztec/circuit-types'; import { + type Fr, type GlobalVariables, type Header, type KernelCircuitPublicInputs, - type MAX_NEW_NOTE_HASHES_PER_TX, + MAX_NEW_NOTE_HASHES_PER_TX, type Proof, type PublicKernelCircuitPublicInputs, PublicKernelTailCircuitPrivateInputs, type SideEffect, makeEmptyProof, + mergeAccumulatedData, + sortByCounter, } from '@aztec/circuits.js'; import { type Tuple } from '@aztec/foundation/serialize'; import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator'; @@ -62,9 +65,15 @@ export class TailPhaseManager extends AbstractPhaseManager { previousProof: Proof, ): Promise<[KernelCircuitPublicInputs, Proof]> { const output = await this.simulate(previousOutput, previousProof); + // Temporary hack. Should sort them in the tail circuit. - // TODO(#757): Enforce proper ordering of public state actions - output.end.newNoteHashes = this.sortNoteHashes(output.end.newNoteHashes); + const noteHashes = mergeAccumulatedData( + MAX_NEW_NOTE_HASHES_PER_TX, + previousOutput.endNonRevertibleData.newNoteHashes, + previousOutput.end.newNoteHashes, + ); + output.end.newNoteHashes = this.sortNoteHashes(noteHashes); + return [output, makeEmptyProof()]; } @@ -93,12 +102,10 @@ export class TailPhaseManager extends AbstractPhaseManager { return this.publicKernel.publicKernelCircuitTail(inputs); } - private sortNoteHashes(noteHashes: Tuple): Tuple { - return noteHashes.sort((n0, n1) => { - if (n0.isEmpty()) { - return 1; - } - return Number(n0.counter.toBigInt() - n1.counter.toBigInt()); - }); + private sortNoteHashes(noteHashes: Tuple): Tuple { + return sortByCounter(noteHashes.map(n => ({ ...n, counter: n.counter.toNumber() }))).map(n => n.value) as Tuple< + Fr, + N + >; } } diff --git a/yarn-project/sequencer-client/src/sequencer/tx_validator.ts b/yarn-project/sequencer-client/src/sequencer/tx_validator.ts index 457aedf2d34..59be5a8a99a 100644 --- a/yarn-project/sequencer-client/src/sequencer/tx_validator.ts +++ b/yarn-project/sequencer-client/src/sequencer/tx_validator.ts @@ -138,7 +138,7 @@ export class TxValidator { * @returns Whether this is a problematic double spend that the L1 contract would reject. */ async #validateNullifiers(tx: Tx | ProcessedTx, thisBlockNullifiers: Set): Promise { - const newNullifiers = tx.data.getNonEmptyNullifiers().map(x => x.value.toBigInt()); + const newNullifiers = tx.data.getNonEmptyNullifiers().map(x => x.toBigInt()); // Ditch this tx if it has repeated nullifiers const uniqueNullifiers = new Set(newNullifiers);