From 27867a2f0ec8cc8981891f82f60a05a7bf100052 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Fri, 7 Feb 2025 17:01:10 +0000 Subject: [PATCH] feat: Remove tree root checks from public base --- .../src/base/private_base_rollup.nr | 8 +- .../rollup-lib/src/base/public_base_rollup.nr | 667 ++---------------- .../rollup-lib/src/base/state_diff_hints.nr | 22 +- .../crates/types/src/abis/tree_snapshots.nr | 11 + .../crates/types/src/tests/fixture_builder.nr | 7 + .../src/structs/rollup/base_rollup_hints.ts | 18 +- .../structs/rollup/state_diff_hints.test.ts | 11 +- .../src/structs/rollup/state_diff_hints.ts | 127 ---- .../circuits.js/src/tests/factories.ts | 65 +- .../src/conversion/server.ts | 30 - .../prover-client/src/mocks/test_context.ts | 21 +- .../orchestrator/block-building-helpers.ts | 37 - .../orchestrator/orchestrator_errors.test.ts | 2 +- .../orchestrator_mixed_blocks.test.ts | 2 +- .../orchestrator_single_blocks.test.ts | 4 +- .../orchestrator_workflow.test.ts | 4 +- 16 files changed, 88 insertions(+), 948 deletions(-) diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/private_base_rollup.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/private_base_rollup.nr index 71813404daa1..c2b379aa5ed2 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/private_base_rollup.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/private_base_rollup.nr @@ -19,8 +19,8 @@ use super::components::constants::validate_tx_constant_data; use dep::types::{ abis::{ append_only_tree_snapshot::AppendOnlyTreeSnapshot, constant_rollup_data::ConstantRollupData, - nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite, - public_log::PublicLog, sponge_blob::SpongeBlob, tube::PrivateTubeData, + public_data_write::PublicDataWrite, public_log::PublicLog, sponge_blob::SpongeBlob, + tube::PrivateTubeData, }, constants::{ ARCHIVE_HEIGHT, MAX_PUBLIC_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, @@ -173,10 +173,6 @@ impl PrivateBaseRollupInputs { ) } - fn create_nullifier_subtree(leaves: [NullifierLeafPreimage; N]) -> Field { - calculate_subtree_root(leaves.map(|leaf: NullifierLeafPreimage| leaf.hash())) - } - fn build_fee_public_data_write(self, tx_fee: Field) -> PublicDataWrite { let fee_payer = self.tube_data.public_inputs.fee_payer; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr index 91076f4bf685..c8759045f9bf 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/public_base_rollup.nr @@ -3,33 +3,23 @@ use crate::{ base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs}, tx_effect::TxEffect, }, - base::{ - components::{ - archive::perform_archive_membership_check, constants::validate_combined_constant_data, - nullifier_tree::nullifier_tree_batch_insert, public_data_tree::public_data_tree_insert, - PublicTubeDataValidator, - }, - state_diff_hints::PublicBaseStateDiffHints, + base::components::{ + archive::perform_archive_membership_check, constants::validate_combined_constant_data, + PublicTubeDataValidator, }, components::{append_tx_effects_for_blob, compute_kernel_out_hash}, }; use dep::types::{ abis::{ - append_only_tree_snapshot::AppendOnlyTreeSnapshot, avm_circuit_public_inputs::AvmProofData, - combined_constant_data::CombinedConstantData, constant_rollup_data::ConstantRollupData, - log_hash::ScopedLogHash, nullifier_leaf_preimage::NullifierLeafPreimage, - public_data_write::PublicDataWrite, sponge_blob::SpongeBlob, tube::PublicTubeData, - }, - constants::{ - ARCHIVE_HEIGHT, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT, + avm_circuit_public_inputs::AvmProofData, combined_constant_data::CombinedConstantData, + constant_rollup_data::ConstantRollupData, log_hash::ScopedLogHash, sponge_blob::SpongeBlob, + tube::PublicTubeData, }, + constants::ARCHIVE_HEIGHT, hash::silo_l2_to_l1_message, - merkle_tree::{ - append_only_tree, calculate_empty_tree_root, calculate_subtree_root, MembershipWitness, - }, + merkle_tree::MembershipWitness, messaging::l2_to_l1_message::ScopedL2ToL1Message, - partial_state_reference::PartialStateReference, - traits::{Hash, is_empty}, + traits::Hash, utils::arrays::array_merge, }; @@ -37,11 +27,8 @@ pub struct PublicBaseRollupInputs { tube_data: PublicTubeData, avm_proof_data: AvmProofData, - start: PartialStateReference, start_sponge_blob: SpongeBlob, - state_diff_hints: PublicBaseStateDiffHints, - archive_root_membership_witness: MembershipWitness, constants: ConstantRollupData, } @@ -121,8 +108,6 @@ impl PublicBaseRollupInputs { ); validate_combined_constant_data(combined_constant_data, self.constants); - self.validate_kernel_start_state(); - let rollup_validation_requests = self.tube_data.public_inputs.rollup_validation_requests; // Verify the max block number @@ -136,26 +121,6 @@ impl PublicBaseRollupInputs { } let tx_effect = self.generate_tx_effect(reverted, combined_constant_data); - - let commitments_tree_subroot = calculate_subtree_root(tx_effect.note_hashes); - - let empty_commitments_subtree_root = calculate_empty_tree_root(NOTE_HASH_SUBTREE_HEIGHT); - - let end_note_hash_tree_snapshot = append_only_tree::insert_subtree_to_snapshot_tree( - self.start.note_hash_tree, - self.state_diff_hints.note_hash_subtree_sibling_path, - empty_commitments_subtree_root, - commitments_tree_subroot, - NOTE_HASH_SUBTREE_HEIGHT as u8, - ); - - // Insert nullifiers: - let end_nullifier_tree_snapshot = - self.check_nullifier_tree_non_membership_and_insert_to_tree(tx_effect); - - // Validate public data update requests and update public data tree - let end_public_data_tree_snapshot = - self.validate_and_process_public_state(tx_effect.public_data_writes); // Append the tx effects for blob(s) let out_hash = compute_kernel_out_hash(tx_effect.l2_to_l1_msgs); @@ -169,35 +134,16 @@ impl PublicBaseRollupInputs { combined_constant_data.historical_header, ); - assert( - end_note_hash_tree_snapshot.eq( - self.avm_proof_data.public_inputs.end_tree_snapshots.note_hash_tree, - ), - "Mismatch note hash tree base rollup vs AVM", - ); - assert( - end_nullifier_tree_snapshot.eq( - self.avm_proof_data.public_inputs.end_tree_snapshots.nullifier_tree, - ), - "Mismatch nullifier tree base rollup vs AVM", - ); - assert( - end_public_data_tree_snapshot.eq( - self.avm_proof_data.public_inputs.end_tree_snapshots.public_data_tree, - ), - "Mismatch public data tree base rollup vs AVM", - ); - BaseOrMergeRollupPublicInputs { rollup_type: BASE_ROLLUP_TYPE, num_txs: 1, constants: self.constants, - start: self.start, - end: PartialStateReference { - note_hash_tree: end_note_hash_tree_snapshot, - nullifier_tree: end_nullifier_tree_snapshot, - public_data_tree: end_public_data_tree_snapshot, - }, + start: self + .avm_proof_data + .public_inputs + .start_tree_snapshots + .to_partial_state_reference(), + end: self.avm_proof_data.public_inputs.end_tree_snapshots.to_partial_state_reference(), start_sponge_blob: self.start_sponge_blob, end_sponge_blob, out_hash, @@ -205,74 +151,12 @@ impl PublicBaseRollupInputs { accumulated_mana_used: self.avm_proof_data.public_inputs.end_gas_used.l2_gas as Field, } } - - fn check_nullifier_tree_non_membership_and_insert_to_tree( - self, - tx_effect: TxEffect, - ) -> AppendOnlyTreeSnapshot { - nullifier_tree_batch_insert( - self.start.nullifier_tree, - tx_effect.nullifiers, - self.state_diff_hints.sorted_nullifiers, - self.state_diff_hints.sorted_nullifier_indexes, - self.state_diff_hints.nullifier_subtree_sibling_path, - self.state_diff_hints.nullifier_predecessor_preimages, - self.state_diff_hints.nullifier_predecessor_membership_witnesses, - ) - } - - fn create_nullifier_subtree(leaves: [NullifierLeafPreimage; N]) -> Field { - calculate_subtree_root(leaves.map(|leaf: NullifierLeafPreimage| leaf.hash())) - } - - fn validate_kernel_start_state(self) { - let start_tree_snapshots = self.avm_proof_data.public_inputs.start_tree_snapshots; - let start_state = PartialStateReference { - note_hash_tree: start_tree_snapshots.note_hash_tree, - nullifier_tree: start_tree_snapshots.nullifier_tree, - public_data_tree: start_tree_snapshots.public_data_tree, - }; - if !is_empty(start_state) { - assert( - start_state.note_hash_tree.eq(self.start.note_hash_tree), - "Mismatch start state for note hash tree", - ); - assert( - start_state.nullifier_tree.eq(self.start.nullifier_tree), - "Mismatch start state for nullifier tree", - ); - assert( - start_state.public_data_tree.eq(self.start.public_data_tree), - "Mismatch start state for public data tree", - ); - } - } - - fn validate_and_process_public_state( - self, - all_update_requests: [PublicDataWrite; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], - ) -> AppendOnlyTreeSnapshot { - let mut snapshot = self.start.public_data_tree; - for i in 0..all_update_requests.len() { - let update_request = all_update_requests[i]; - snapshot = public_data_tree_insert( - update_request, - snapshot, - self.state_diff_hints.low_public_data_writes_preimages[i], - self.state_diff_hints.low_public_data_writes_witnesses[i], - self.state_diff_hints.public_data_tree_sibling_paths[i], - ); - } - snapshot - } } mod tests { use crate::{ abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs, - base::{ - public_base_rollup::PublicBaseRollupInputs, state_diff_hints::PublicBaseStateDiffHints, - }, + base::public_base_rollup::PublicBaseRollupInputs, components::{ append_tx_effects_for_blob, encode_blob_prefix, TX_EFFECTS_BLOB_HASH_INPUT_FIELDS, }, @@ -283,35 +167,28 @@ mod tests { append_only_tree_snapshot::AppendOnlyTreeSnapshot, constant_rollup_data::ConstantRollupData, nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite, - side_effect::OrderedValue, sponge_blob::SpongeBlob, + side_effect::OrderedValue, sponge_blob::SpongeBlob, tree_snapshots::TreeSnapshots, }, address::EthAddress, constants::{ ARCHIVE_HEIGHT, AVM_VK_INDEX, CONTRACT_CLASS_LOGS_PREFIX, L2_L1_MSGS_PREFIX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT, - NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NOTE_HASH_TREE_HEIGHT, NOTES_PREFIX, - NULLIFIER_SUBTREE_HEIGHT, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, - NULLIFIERS_PREFIX, PRIVATE_LOG_SIZE_IN_FIELDS, PRIVATE_LOGS_PREFIX, - PUBLIC_DATA_TREE_HEIGHT, PUBLIC_DATA_UPDATE_REQUESTS_PREFIX, PUBLIC_LOG_SIZE_IN_FIELDS, - PUBLIC_LOGS_PREFIX, REVERT_CODE_PREFIX, TUBE_VK_INDEX, TX_FEE_PREFIX, TX_START_PREFIX, + MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTES_PREFIX, NULLIFIERS_PREFIX, + PRIVATE_LOG_SIZE_IN_FIELDS, PRIVATE_LOGS_PREFIX, PUBLIC_DATA_UPDATE_REQUESTS_PREFIX, + PUBLIC_LOG_SIZE_IN_FIELDS, PUBLIC_LOGS_PREFIX, REVERT_CODE_PREFIX, TUBE_VK_INDEX, + TX_FEE_PREFIX, TX_START_PREFIX, }, data::{PublicDataTreeLeaf, PublicDataTreeLeafPreimage}, hash::silo_l2_to_l1_message, - merkle_tree::{leaf_preimage::LeafPreimage, MembershipWitness}, + merkle_tree::MembershipWitness, messaging::l2_to_l1_message::ScopedL2ToL1Message, - partial_state_reference::PartialStateReference, tests::{ fixture_builder::FixtureBuilder, fixtures::{self, merkle_tree::generate_full_sha_tree}, merkle_tree_utils::NonEmptyMerkleTree, - utils::pad_end, - }, - traits::{Empty, Hash, is_empty}, - utils::{ - arrays::{array_concat, get_sorted_tuple::get_sorted_tuple}, - field::{field_from_bytes, full_field_less_than}, }, + traits::{Empty, Hash, Serialize}, + utils::{arrays::array_concat, field::field_from_bytes}, }; struct NullifierInsertion { @@ -321,75 +198,7 @@ mod tests { global MAX_NULLIFIERS_PER_TEST: u32 = 4; global AVAILABLE_PUBLIC_DATA_LEAVES_FOR_TEST: u32 = 128; - global AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST: u32 = 7; global PRE_EXISTING_PUBLIC_DATA_LEAVES: u32 = 10; - - fn update_public_data_tree( - public_data_tree: &mut NonEmptyMerkleTree, - snapshot: AppendOnlyTreeSnapshot, - writes: [(u32, PublicDataTreeLeaf); MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], - mut pre_existing_public_data: [PublicDataTreeLeafPreimage; EXISTING_LEAVES], - ) -> ([PublicDataTreeLeafPreimage; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], [MembershipWitness; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], [[Field; PUBLIC_DATA_TREE_HEIGHT]; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], AppendOnlyTreeSnapshot) { - let mut low_leaves = - [PublicDataTreeLeafPreimage::empty(); MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX]; - let mut low_public_data_writes_witnesses = - [MembershipWitness::empty(); MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX]; - let mut insertion_witnesses = - [[0; PUBLIC_DATA_TREE_HEIGHT]; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX]; - - let mut current_next_leaf_index = snapshot.next_available_leaf_index; - for i in 0..writes.len() { - let (low_leaf_index, write) = writes[i]; - if (!is_empty(write)) { - let low_leaf = pre_existing_public_data[low_leaf_index]; - let mut new_leaf = PublicDataTreeLeafPreimage::empty(); - if low_leaf.slot == write.slot { - pre_existing_public_data[low_leaf_index].value = write.value; - } else { - new_leaf = PublicDataTreeLeafPreimage { - slot: write.slot, - value: write.value, - next_slot: low_leaf.next_slot, - next_index: low_leaf.next_index, - }; - pre_existing_public_data[low_leaf_index] = PublicDataTreeLeafPreimage { - slot: low_leaf.slot, - value: low_leaf.value, - next_slot: write.slot, - next_index: PRE_EXISTING_PUBLIC_DATA_LEAVES + i, - }; - } - let low_public_data_writes_witness = MembershipWitness { - leaf_index: low_leaf_index as Field, - sibling_path: public_data_tree.get_sibling_path(low_leaf_index), - }; - - public_data_tree.update_leaf( - low_leaf_index, - pre_existing_public_data[low_leaf_index].hash(), - ); - - let insertion_witness = public_data_tree.get_sibling_path(current_next_leaf_index); - - public_data_tree.update_leaf(current_next_leaf_index, new_leaf.hash()); - - low_leaves[i] = low_leaf; - low_public_data_writes_witnesses[i] = low_public_data_writes_witness; - insertion_witnesses[i] = insertion_witness; - if low_leaf.slot != write.slot { - current_next_leaf_index += 1; - } - } - } - ( - low_leaves, low_public_data_writes_witnesses, insertion_witnesses, - AppendOnlyTreeSnapshot { - root: public_data_tree.get_root(), - next_available_leaf_index: current_next_leaf_index, - }, - ) - } - struct PublicBaseRollupInputsBuilder { tube_data: FixtureBuilder, avm_data: FixtureBuilder, @@ -460,162 +269,18 @@ mod tests { sibling_path } - fn update_nullifier_tree_with_new_leaves( - mut self, - nullifier_tree: &mut NonEmptyMerkleTree, - start_nullifier_tree_snapshot: AppendOnlyTreeSnapshot, - ) -> ([NullifierLeafPreimage; MAX_NULLIFIERS_PER_TX], [MembershipWitness; MAX_NULLIFIERS_PER_TX], [Field; MAX_NULLIFIERS_PER_TX], [u32; MAX_NULLIFIERS_PER_TX], [Field; NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH], AppendOnlyTreeSnapshot) { - let mut nullifier_predecessor_preimages = - [NullifierLeafPreimage::empty(); MAX_NULLIFIERS_PER_TX]; - let mut low_nullifier_membership_witness = - [MembershipWitness::empty(); MAX_NULLIFIERS_PER_TX]; - - /// Safety: This is a mock for testing only - let sorted_new_nullifier_tuples = unsafe { - get_sorted_tuple( - self.nullifiers.storage().map(|insertion: NullifierInsertion| insertion.value), - |a, b| full_field_less_than(b, a), - ) - }; - - let mut sorted_nullifiers = [0; MAX_NULLIFIERS_PER_TX]; - let mut sorted_nullifiers_indexes = [0; MAX_NULLIFIERS_PER_TX]; - - for i in 0..MAX_NULLIFIERS_PER_TX { - if (i as u32) < (MAX_NULLIFIERS_PER_TEST as u32) { - sorted_nullifiers[i] = sorted_new_nullifier_tuples[i].elem; - sorted_nullifiers_indexes[i] = sorted_new_nullifier_tuples[i].original_index; - } else { - sorted_nullifiers[i] = 0; - sorted_nullifiers_indexes[i] = i; - } - } - - let mut pre_existing_nullifiers = self.pre_existing_nullifiers; - let mut insertion_subtree = [NullifierLeafPreimage::empty(); MAX_NULLIFIERS_PER_TX]; - - for i in 0..MAX_NULLIFIERS_PER_TEST { - if i < self.nullifiers.len() { - let sorted_tuple = sorted_new_nullifier_tuples[i]; - let new_nullifier = sorted_tuple.elem; - let original_index = sorted_tuple.original_index; - - let low_index = self.nullifiers.get_unchecked(original_index).existing_index; - - let mut low_preimage = pre_existing_nullifiers[low_index]; - let new_leaf = NullifierLeafPreimage { - nullifier: new_nullifier, - next_nullifier: low_preimage.next_nullifier, - next_index: low_preimage.next_index, - }; - nullifier_predecessor_preimages[i] = low_preimage; - low_nullifier_membership_witness[i] = MembershipWitness { - leaf_index: low_index as Field, - sibling_path: nullifier_tree.get_sibling_path(low_index), - }; - - low_preimage.next_nullifier = new_nullifier; - low_preimage.next_index = - start_nullifier_tree_snapshot.next_available_leaf_index + original_index; - pre_existing_nullifiers[low_index] = low_preimage; - - nullifier_tree.update_leaf(low_index, low_preimage.hash()); - insertion_subtree[original_index] = new_leaf; - } - } - - let nullifier_subtree_sibling_path = PublicBaseRollupInputsBuilder::extract_subtree_sibling_path( - nullifier_tree.get_sibling_path(self.pre_existing_nullifiers.len()), - [0; NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH], - ); - - for i in 0..insertion_subtree.len() { - let leaf = insertion_subtree[i].as_leaf(); - nullifier_tree.update_leaf( - start_nullifier_tree_snapshot.next_available_leaf_index + i, - leaf, - ); - } - - let end_nullifier_tree_snapshot = AppendOnlyTreeSnapshot { - root: nullifier_tree.get_root(), - next_available_leaf_index: start_nullifier_tree_snapshot.next_available_leaf_index - + MAX_NULLIFIERS_PER_TX, - }; - - ( - nullifier_predecessor_preimages, low_nullifier_membership_witness, - sorted_nullifiers, sorted_nullifiers_indexes, nullifier_subtree_sibling_path, - end_nullifier_tree_snapshot, - ) - } - unconstrained fn build_inputs(mut self) -> PublicBaseRollupInputs { let mut tube_data = self.tube_data.to_public_tube_data(); let mut avm_proof_data = self.avm_data.to_avm_proof_data(self.reverted); avm_proof_data.public_inputs.transaction_fee = self.transaction_fee; - let mut start_note_hash_tree = NonEmptyMerkleTree::new( - pad_end::( - self.pre_existing_notes, - 0, - ), - [0; NOTE_HASH_TREE_HEIGHT], - [0; NOTE_HASH_TREE_HEIGHT - NOTE_HASH_SUBTREE_HEIGHT - 1], - [0; NOTE_HASH_SUBTREE_HEIGHT + 1], - ); - let start_note_hash_tree_snapshot = AppendOnlyTreeSnapshot { - root: start_note_hash_tree.get_root(), - next_available_leaf_index: self.pre_existing_notes.len(), - }; - let note_hash_subtree_sibling_path = PublicBaseRollupInputsBuilder::extract_subtree_sibling_path( - start_note_hash_tree.get_sibling_path(self.pre_existing_notes.len()), - [0; NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH], - ); - for i in 0..MAX_NOTE_HASHES_PER_TX { - let note_hash = avm_proof_data.public_inputs.accumulated_data.note_hashes[i]; - start_note_hash_tree.update_leaf(MAX_NOTE_HASHES_PER_TX + i, note_hash); - } - avm_proof_data.public_inputs.end_tree_snapshots.note_hash_tree = AppendOnlyTreeSnapshot { - root: start_note_hash_tree.get_root(), - next_available_leaf_index: MAX_NOTE_HASHES_PER_TX * 2, - }; - - let mut start_nullifier_tree = NonEmptyMerkleTree::new( - pad_end::( - self.pre_existing_nullifiers.map(|preimage: NullifierLeafPreimage| { - preimage.hash() - }), - 0, - ), - [0; NULLIFIER_TREE_HEIGHT], - [0; NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_HEIGHT - 1], - [0; NULLIFIER_SUBTREE_HEIGHT + 1], - ); - - let start_nullifier_tree_snapshot = AppendOnlyTreeSnapshot { - root: start_nullifier_tree.get_root(), - next_available_leaf_index: MAX_NULLIFIERS_PER_TX, - }; - let mut pre_existing_leaves = [0; AVAILABLE_PUBLIC_DATA_LEAVES_FOR_TEST]; for i in 0..self.pre_existing_public_data.len() { pre_existing_leaves[i] = self.pre_existing_public_data[i].hash(); } - let mut start_public_data_tree = NonEmptyMerkleTree::new( - pre_existing_leaves, - [0; PUBLIC_DATA_TREE_HEIGHT], - [0; PUBLIC_DATA_TREE_HEIGHT - AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST], - [0; AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST], - ); - let start_public_data_tree_snapshot = AppendOnlyTreeSnapshot { - root: start_public_data_tree.get_root(), - next_available_leaf_index: self.pre_existing_public_data.len(), - }; - let start_archive = NonEmptyMerkleTree::new( self.pre_existing_blocks, [0; ARCHIVE_HEIGHT], @@ -627,42 +292,17 @@ mod tests { next_available_leaf_index: start_archive.get_next_available_index() as u32, }; - let (nullifier_predecessor_preimages, nullifier_predecessor_membership_witnesses, sorted_nullifiers, sorted_nullifier_indexes, nullifier_subtree_sibling_path, end_nullifier_tree_snapshot) = self - .update_nullifier_tree_with_new_leaves( - &mut start_nullifier_tree, - start_nullifier_tree_snapshot, - ); - for i in 0..self.nullifiers.len() { let nullifier = self.nullifiers.get_unchecked(i); avm_proof_data.public_inputs.accumulated_data.nullifiers[i] = nullifier.value; } - avm_proof_data.public_inputs.end_tree_snapshots.nullifier_tree = - end_nullifier_tree_snapshot; - - let (low_public_data_writes_preimages, low_public_data_writes_witnesses, public_data_tree_sibling_paths, end_public_data_tree_snapshot) = update_public_data_tree( - &mut start_public_data_tree, - start_public_data_tree_snapshot, - self.public_data_writes.storage(), - self.pre_existing_public_data, - ); - - avm_proof_data.public_inputs.end_tree_snapshots.public_data_tree = - end_public_data_tree_snapshot; - for i in 0..self.public_data_writes.len() { let leaf = self.public_data_writes.get_unchecked(i).1; avm_proof_data.public_inputs.accumulated_data.public_data_writes[i] = PublicDataWrite { leaf_slot: leaf.slot, value: leaf.value }; } - let start = PartialStateReference { - note_hash_tree: start_note_hash_tree_snapshot, - nullifier_tree: start_nullifier_tree_snapshot, - public_data_tree: start_public_data_tree_snapshot, - }; - let tx_effect = self.build_pre_existing_tx_effects(); let start_sponge_blob = append_tx_effects_for_blob( @@ -670,24 +310,10 @@ mod tests { SpongeBlob::new(TX_EFFECTS_BLOB_HASH_INPUT_FIELDS), ); - let state_diff_hints = PublicBaseStateDiffHints { - nullifier_predecessor_preimages, - nullifier_predecessor_membership_witnesses, - sorted_nullifiers, - sorted_nullifier_indexes, - note_hash_subtree_sibling_path, - nullifier_subtree_sibling_path, - low_public_data_writes_preimages, - low_public_data_writes_witnesses, - public_data_tree_sibling_paths, - }; - PublicBaseRollupInputs { tube_data, avm_proof_data, - start, start_sponge_blob, - state_diff_hints, archive_root_membership_witness: MembershipWitness { leaf_index: 0, sibling_path: start_archive.get_sibling_path(0), @@ -732,176 +358,6 @@ mod tests { } } - #[test] - unconstrained fn note_hashes_tree() { - let mut builder = PublicBaseRollupInputsBuilder::new(); - - let note_hashes = [27, 28, 29, 30, 31, 32]; - for i in 0..note_hashes.len() { - builder.avm_data.add_new_note_hash(note_hashes[i]); - } - let mut expected_commitments_tree = NonEmptyMerkleTree::new( - [0; MAX_NOTE_HASHES_PER_TX * 2], - [0; NOTE_HASH_TREE_HEIGHT], - [0; NOTE_HASH_TREE_HEIGHT - NOTE_HASH_SUBTREE_HEIGHT - 1], - [0; NOTE_HASH_SUBTREE_HEIGHT + 1], - ); - - let outputs = builder.execute(); - let expected_start_note_hash_tree_snapshot = AppendOnlyTreeSnapshot { - root: expected_commitments_tree.get_root(), - next_available_leaf_index: MAX_NOTE_HASHES_PER_TX as u32, - }; - assert(outputs.start.note_hash_tree.eq(expected_start_note_hash_tree_snapshot)); - - for i in 0..note_hashes.len() { - expected_commitments_tree.update_leaf(i + MAX_NOTE_HASHES_PER_TX, note_hashes[i]); - } - let expected_end_note_hash_tree_snapshot = AppendOnlyTreeSnapshot { - root: expected_commitments_tree.get_root(), - next_available_leaf_index: (MAX_NOTE_HASHES_PER_TX * 2) as u32, - }; - assert(outputs.end.note_hash_tree.eq(expected_end_note_hash_tree_snapshot)); - } - - #[test] - unconstrained fn new_nullifier_tree_empty() { - // This test checks for insertions of all 0 values - // In this special case we will not need to provide sibling paths to check insertion of the nullifier values - // This is because 0 values are not actually inserted into the tree, rather the inserted subtree is left - // empty to begin with. - let mut builder = PublicBaseRollupInputsBuilder::new(); - - builder.pre_existing_nullifiers[0] = - NullifierLeafPreimage { nullifier: 0, next_nullifier: 7, next_index: 1 }; - builder.pre_existing_nullifiers[1] = - NullifierLeafPreimage { nullifier: 7, next_nullifier: 0, next_index: 0 }; - - builder.succeeds(); - } - - #[test] - unconstrained fn nullifier_insertion_test() { - let mut builder = PublicBaseRollupInputsBuilder::new(); - - builder.pre_existing_nullifiers[0] = - NullifierLeafPreimage { nullifier: 0, next_nullifier: 7, next_index: 1 }; - builder.pre_existing_nullifiers[1] = - NullifierLeafPreimage { nullifier: 7, next_nullifier: 0, next_index: 0 }; - - builder.nullifiers.push(NullifierInsertion { existing_index: 0, value: 1 }); - let mut tree_nullifiers = [NullifierLeafPreimage::empty(); MAX_NULLIFIERS_PER_TX * 2]; - tree_nullifiers[0] = NullifierLeafPreimage { - nullifier: 0, - next_nullifier: 1, - next_index: MAX_NULLIFIERS_PER_TX, - }; - tree_nullifiers[1] = builder.pre_existing_nullifiers[1]; - tree_nullifiers[MAX_NULLIFIERS_PER_TX] = - NullifierLeafPreimage { nullifier: 1, next_nullifier: 7, next_index: 1 }; - - let mut end_nullifier_tree = NonEmptyMerkleTree::new( - tree_nullifiers.map(|preimage: NullifierLeafPreimage| preimage.hash()), - [0; NULLIFIER_TREE_HEIGHT], - [0; NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_HEIGHT - 1], - [0; NULLIFIER_SUBTREE_HEIGHT + 1], - ); - - let output = builder.execute(); - - assert(output.end.nullifier_tree.eq( - AppendOnlyTreeSnapshot { - root: end_nullifier_tree.get_root(), - next_available_leaf_index: 2 * MAX_NULLIFIERS_PER_TX as u32, - }, - )); - } - - #[test] - unconstrained fn new_nullifier_tree_all_larger() { - let mut builder = PublicBaseRollupInputsBuilder::new(); - - builder.pre_existing_nullifiers[0] = - NullifierLeafPreimage { nullifier: 0, next_nullifier: 7, next_index: 1 }; - builder.pre_existing_nullifiers[1] = - NullifierLeafPreimage { nullifier: 7, next_nullifier: 0, next_index: 0 }; - - builder.nullifiers.push(NullifierInsertion { existing_index: 1, value: 8 }); - for i in 1..builder.nullifiers.max_len() { - builder.nullifiers.push( - NullifierInsertion { existing_index: 1, value: (8 + i) as Field }, - ); - } - - let output = builder.execute(); - let mut tree_nullifiers = [NullifierLeafPreimage::empty(); MAX_NULLIFIERS_PER_TX * 2]; - tree_nullifiers[0] = builder.pre_existing_nullifiers[0]; - - tree_nullifiers[1] = NullifierLeafPreimage { - nullifier: 7, - next_nullifier: 8, - next_index: MAX_NULLIFIERS_PER_TX, - }; - - let last_index = builder.nullifiers.max_len() - 1; - for i in 0..last_index { - tree_nullifiers[MAX_NULLIFIERS_PER_TX + i] = NullifierLeafPreimage { - nullifier: (8 + i) as Field, - next_nullifier: (8 + i + 1) as Field, - next_index: MAX_NULLIFIERS_PER_TX + i + 1, - }; - } - tree_nullifiers[MAX_NULLIFIERS_PER_TX + last_index] = NullifierLeafPreimage { - nullifier: (8 + last_index) as Field, - next_nullifier: 0, - next_index: 0, - }; - - let mut end_nullifier_tree = NonEmptyMerkleTree::new( - tree_nullifiers.map(|preimage: NullifierLeafPreimage| preimage.hash()), - [0; NULLIFIER_TREE_HEIGHT], - [0; NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_HEIGHT - 1], - [0; NULLIFIER_SUBTREE_HEIGHT + 1], - ); - - assert(output.end.nullifier_tree.eq( - AppendOnlyTreeSnapshot { - root: end_nullifier_tree.get_root(), - next_available_leaf_index: 2 * MAX_NULLIFIERS_PER_TX as u32, - }, - )); - } - - #[test(should_fail_with = "Invalid low leaf")] - unconstrained fn new_nullifier_tree_double_spend() { - let mut builder = PublicBaseRollupInputsBuilder::new(); - - builder.pre_existing_nullifiers[0] = - NullifierLeafPreimage { nullifier: 0, next_nullifier: 7, next_index: 1 }; - builder.pre_existing_nullifiers[1] = - NullifierLeafPreimage { nullifier: 7, next_nullifier: 0, next_index: 0 }; - - builder.nullifiers.push(NullifierInsertion { existing_index: 1, value: 8 }); - builder.nullifiers.push(NullifierInsertion { existing_index: 1, value: 8 }); - - builder.fails(); - } - - #[test(should_fail_with = "Invalid low leaf")] - unconstrained fn new_nullifier_tree_double_spend_same_batch() { - let mut builder = PublicBaseRollupInputsBuilder::new(); - - builder.pre_existing_nullifiers[0] = - NullifierLeafPreimage { nullifier: 0, next_nullifier: 7, next_index: 1 }; - builder.pre_existing_nullifiers[1] = - NullifierLeafPreimage { nullifier: 7, next_nullifier: 0, next_index: 0 }; - - builder.nullifiers.push(NullifierInsertion { existing_index: 1, value: 8 }); - builder.nullifiers.push(NullifierInsertion { existing_index: 1, value: 8 }); - - builder.fails(); - } - #[test] unconstrained fn empty_tx_effects_sponge() { let outputs = PublicBaseRollupInputsBuilder::new().execute(); @@ -1207,68 +663,27 @@ mod tests { } #[test] - unconstrained fn single_public_state_write() { + unconstrained fn passes_state_roots_from_avm() { let mut builder = PublicBaseRollupInputsBuilder::new(); + let start_snapshot = TreeSnapshots { + note_hash_tree: AppendOnlyTreeSnapshot { root: 1, next_available_leaf_index: 2 }, + nullifier_tree: AppendOnlyTreeSnapshot { root: 3, next_available_leaf_index: 4 }, + public_data_tree: AppendOnlyTreeSnapshot { root: 5, next_available_leaf_index: 6 }, + l1_to_l2_message_tree: AppendOnlyTreeSnapshot::zero(), + }; + let end_snapshot = TreeSnapshots { + note_hash_tree: AppendOnlyTreeSnapshot { root: 7, next_available_leaf_index: 8 }, + nullifier_tree: AppendOnlyTreeSnapshot { root: 9, next_available_leaf_index: 10 }, + public_data_tree: AppendOnlyTreeSnapshot { root: 11, next_available_leaf_index: 12 }, + l1_to_l2_message_tree: AppendOnlyTreeSnapshot::zero(), + }; - builder.pre_existing_public_data[0] = - PublicDataTreeLeafPreimage { slot: 27, value: 28, next_slot: 0, next_index: 0 }; - builder.public_data_writes.push((0, PublicDataTreeLeaf { slot: 27, value: 29 })); + builder.avm_data.start_snapshots = start_snapshot; + builder.avm_data.end_snapshots = end_snapshot; let outputs = builder.execute(); - let updated_leaf = - PublicDataTreeLeafPreimage { slot: 27, value: 29, next_slot: 0, next_index: 0 }; - - let mut expected_public_data_tree = NonEmptyMerkleTree::new( - [updated_leaf.hash(), 0], - [0; PUBLIC_DATA_TREE_HEIGHT], - [0; PUBLIC_DATA_TREE_HEIGHT - 1], - [0; 1], - ); - - assert_eq(outputs.end.public_data_tree.root, expected_public_data_tree.get_root()); + assert_eq(outputs.start, start_snapshot.to_partial_state_reference()); + assert_eq(outputs.end, end_snapshot.to_partial_state_reference()); } - #[test] - unconstrained fn multiple_public_state_read_writes() { - let mut builder = PublicBaseRollupInputsBuilder::new(); - - builder.pre_existing_public_data[0] = - PublicDataTreeLeafPreimage { slot: 20, value: 40, next_slot: 28, next_index: 1 }; - builder.pre_existing_public_data[1] = - PublicDataTreeLeafPreimage { slot: 28, value: 41, next_slot: 29, next_index: 2 }; - builder.pre_existing_public_data[2] = - PublicDataTreeLeafPreimage { slot: 29, value: 42, next_slot: 30, next_index: 3 }; - builder.pre_existing_public_data[3] = - PublicDataTreeLeafPreimage { slot: 30, value: 43, next_slot: 0, next_index: 0 }; - builder.public_data_writes.push((0, PublicDataTreeLeaf { slot: 25, value: 60 })); - builder.public_data_writes.push((0, PublicDataTreeLeaf { slot: 20, value: 90 })); - - let outputs = builder.execute(); - - let mut public_data_leaves = [0; AVAILABLE_PUBLIC_DATA_LEAVES_FOR_TEST]; - public_data_leaves[0] = PublicDataTreeLeafPreimage { - slot: 20, - value: 90, - next_slot: 25, - next_index: PRE_EXISTING_PUBLIC_DATA_LEAVES, - } - .hash(); - public_data_leaves[1] = - PublicDataTreeLeafPreimage { slot: 28, value: 41, next_slot: 29, next_index: 2 }.hash(); - public_data_leaves[2] = - PublicDataTreeLeafPreimage { slot: 29, value: 42, next_slot: 30, next_index: 3 }.hash(); - public_data_leaves[3] = - PublicDataTreeLeafPreimage { slot: 30, value: 43, next_slot: 0, next_index: 0 }.hash(); - public_data_leaves[PRE_EXISTING_PUBLIC_DATA_LEAVES] = - PublicDataTreeLeafPreimage { slot: 25, value: 60, next_slot: 28, next_index: 1 }.hash(); - - let mut expected_public_data_tree = NonEmptyMerkleTree::new( - public_data_leaves, - [0; PUBLIC_DATA_TREE_HEIGHT], - [0; PUBLIC_DATA_TREE_HEIGHT - AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST], - [0; AVAILABLE_PUBLIC_DATA_SUBTREE_HEIGHT_FOR_TEST], - ); - - assert_eq(outputs.end.public_data_tree.root, expected_public_data_tree.get_root()); - } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr index f34019c544d6..ee6a91502c92 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/base/state_diff_hints.nr @@ -1,9 +1,8 @@ use dep::types::{ abis::nullifier_leaf_preimage::NullifierLeafPreimage, constants::{ - MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, - NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, + MAX_NULLIFIERS_PER_TX, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, + NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, }, data::PublicDataTreeLeafPreimage, merkle_tree::MembershipWitness, @@ -27,20 +26,3 @@ pub(crate) struct PrivateBaseStateDiffHints { pub(crate) fee_write_sibling_path: [Field; PUBLIC_DATA_TREE_HEIGHT], } -pub(crate) struct PublicBaseStateDiffHints { - pub(crate) nullifier_predecessor_preimages: [NullifierLeafPreimage; MAX_NULLIFIERS_PER_TX], - pub(crate) nullifier_predecessor_membership_witnesses: [MembershipWitness; MAX_NULLIFIERS_PER_TX], - - pub(crate) sorted_nullifiers: [Field; MAX_NULLIFIERS_PER_TX], - pub(crate) sorted_nullifier_indexes: [u32; MAX_NULLIFIERS_PER_TX], - - // For inserting the new subtrees into their respective trees: - // Note: the insertion leaf index can be derived from the snapshots' `next_available_leaf_index` values (tree - // snapshots of the relevant trees are stored in partial state reference). - pub(crate) note_hash_subtree_sibling_path: [Field; NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH], - pub(crate) nullifier_subtree_sibling_path: [Field; NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH], - - pub(crate) low_public_data_writes_preimages: [PublicDataTreeLeafPreimage; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], - pub(crate) low_public_data_writes_witnesses: [MembershipWitness; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], - pub(crate) public_data_tree_sibling_paths: [[Field; PUBLIC_DATA_TREE_HEIGHT]; MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], -} diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_snapshots.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_snapshots.nr index 7fb6948bfcbd..97b096bb23e4 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_snapshots.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/tree_snapshots.nr @@ -1,6 +1,7 @@ use crate::{ abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot, constants::TREE_SNAPSHOTS_LENGTH, + partial_state_reference::PartialStateReference, traits::{Deserialize, Empty, Serialize}, }; @@ -11,6 +12,16 @@ pub struct TreeSnapshots { pub public_data_tree: AppendOnlyTreeSnapshot, } +impl TreeSnapshots { + pub fn to_partial_state_reference(self) -> PartialStateReference { + PartialStateReference { + note_hash_tree: self.note_hash_tree, + nullifier_tree: self.nullifier_tree, + public_data_tree: self.public_data_tree, + } + } +} + impl Eq for TreeSnapshots { fn eq(self, other: TreeSnapshots) -> bool { self.l1_to_l2_message_tree.eq(other.l1_to_l2_message_tree) 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 a043820e1866..55638754a9b5 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 @@ -33,6 +33,7 @@ use crate::{ public_log::PublicLog, read_request::{ReadRequest, ScopedReadRequest}, side_effect::{Counted, OrderedValue, scoped::Scoped}, + tree_snapshots::TreeSnapshots, tube::{PrivateTubeData, PublicTubeData}, tx_constant_data::TxConstantData, validation_requests::{ @@ -163,6 +164,8 @@ pub struct FixtureBuilder { // Tree snapshots. pub archive_tree: AppendOnlyTreeSnapshot, + pub start_snapshots: TreeSnapshots, + pub end_snapshots: TreeSnapshots, // Counters. pub min_revertible_side_effect_counter: u32, @@ -569,6 +572,8 @@ impl FixtureBuilder { result.public_inputs.reverted = reverted; result.public_inputs.global_variables = self.global_variables; result.public_inputs.accumulated_data = self.to_avm_accumulated_data(); + result.public_inputs.start_tree_snapshots = self.start_snapshots; + result.public_inputs.end_tree_snapshots = self.end_snapshots; result } @@ -1138,6 +1143,8 @@ impl Empty for FixtureBuilder { protocol_contract_tree_root: 0, protocol_contract_sibling_path: [0; PROTOCOL_CONTRACT_TREE_HEIGHT], archive_tree: AppendOnlyTreeSnapshot::zero(), + start_snapshots: TreeSnapshots::empty(), + end_snapshots: TreeSnapshots::empty(), revert_code: 0, min_revertible_side_effect_counter: 0, counter_start: 0, diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts index 5450a3c25cfe..6b86eec3a2c6 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup_hints.ts @@ -8,7 +8,7 @@ import { MembershipWitness } from '../membership_witness.js'; import { PartialStateReference } from '../partial_state_reference.js'; import { PublicDataHint } from '../public_data_hint.js'; import { ConstantRollupData } from './constant_rollup_data.js'; -import { PrivateBaseStateDiffHints, PublicBaseStateDiffHints } from './state_diff_hints.js'; +import { PrivateBaseStateDiffHints } from './state_diff_hints.js'; export type BaseRollupHints = PrivateBaseRollupHints | PublicBaseRollupHints; @@ -94,12 +94,8 @@ export class PrivateBaseRollupHints { export class PublicBaseRollupHints { constructor( - /** Partial state reference at the start of the rollup. */ - public start: PartialStateReference, /** Sponge state to absorb blob inputs at the start of the rollup. */ public startSpongeBlob: SpongeBlob, - /** Hints used while proving state diff validity. */ - public stateDiffHints: PublicBaseStateDiffHints, /** * Membership witnesses of blocks referred by each of the 2 kernels. */ @@ -115,13 +111,7 @@ export class PublicBaseRollupHints { } static getFields(fields: FieldsOf) { - return [ - fields.start, - fields.startSpongeBlob, - fields.stateDiffHints, - fields.archiveRootMembershipWitness, - fields.constants, - ] as const; + return [fields.startSpongeBlob, fields.archiveRootMembershipWitness, fields.constants] as const; } /** @@ -143,9 +133,7 @@ export class PublicBaseRollupHints { static fromBuffer(buffer: Buffer | BufferReader): PublicBaseRollupHints { const reader = BufferReader.asReader(buffer); return new PublicBaseRollupHints( - reader.readObject(PartialStateReference), reader.readObject(SpongeBlob), - reader.readObject(PublicBaseStateDiffHints), MembershipWitness.fromBuffer(reader, ARCHIVE_HEIGHT), reader.readObject(ConstantRollupData), ); @@ -157,9 +145,7 @@ export class PublicBaseRollupHints { static empty() { return new PublicBaseRollupHints( - PartialStateReference.empty(), SpongeBlob.empty(), - PublicBaseStateDiffHints.empty(), MembershipWitness.empty(ARCHIVE_HEIGHT), ConstantRollupData.empty(), ); diff --git a/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.test.ts b/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.test.ts index a473a1375fad..c044226fd14c 100644 --- a/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.test.ts +++ b/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.test.ts @@ -1,5 +1,5 @@ -import { makePrivateBaseStateDiffHints, makePublicBaseStateDiffHints } from '../../tests/factories.js'; -import { PrivateBaseStateDiffHints, PublicBaseStateDiffHints } from './state_diff_hints.js'; +import { makePrivateBaseStateDiffHints } from '../../tests/factories.js'; +import { PrivateBaseStateDiffHints } from './state_diff_hints.js'; describe('StateDiffHints', () => { it('serializes private hints to buffer and deserializes it back', () => { @@ -8,11 +8,4 @@ describe('StateDiffHints', () => { const res = PrivateBaseStateDiffHints.fromBuffer(buffer); expect(res).toEqual(expected); }); - - it('serializes public hints to buffer and deserializes it back', () => { - const expected = makePublicBaseStateDiffHints(); - const buffer = expected.toBuffer(); - const res = PublicBaseStateDiffHints.fromBuffer(buffer); - expect(res).toEqual(expected); - }); }); diff --git a/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts b/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts index f1b2a5e986b5..b7e1683a58d2 100644 --- a/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts +++ b/yarn-project/circuits.js/src/structs/rollup/state_diff_hints.ts @@ -5,7 +5,6 @@ import { type FieldsOf } from '@aztec/foundation/types'; import { MAX_NULLIFIERS_PER_TX, - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, NULLIFIER_TREE_HEIGHT, @@ -125,129 +124,3 @@ export class PrivateBaseStateDiffHints { ); } } - -export class PublicBaseStateDiffHints { - constructor( - /** - * The nullifiers which need to be updated to perform the batch insertion of the new nullifiers. - * See `StandardIndexedTree.batchInsert` function for more details. - */ - public nullifierPredecessorPreimages: Tuple, - /** - * Membership witnesses for the nullifiers which need to be updated to perform the batch insertion of the new - * nullifiers. - */ - public nullifierPredecessorMembershipWitnesses: Tuple< - MembershipWitness, - typeof MAX_NULLIFIERS_PER_TX - >, - /** - * The nullifiers to be inserted in the tree, sorted high to low. - */ - public sortedNullifiers: Tuple, - /** - * The indexes of the sorted nullifiers to the original ones. - */ - public sortedNullifierIndexes: Tuple, - /** - * Sibling path "pointing to" where the new note hash subtree should be inserted into the note hash tree. - */ - public noteHashSubtreeSiblingPath: Tuple, - /** - * Sibling path "pointing to" where the new nullifiers subtree should be inserted into the nullifier tree. - */ - public nullifierSubtreeSiblingPath: Tuple, - - /** - * Preimages of the low leaves for the public data writes - */ - public lowPublicDataWritesPreimages: Tuple< - PublicDataTreeLeafPreimage, - typeof MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX - >, - - /** - * Membership witnesses for the low leaves for the public data writes - */ - public lowPublicDataWritesMembershipWitnesses: Tuple< - MembershipWitness, - typeof MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX - >, - - /** - * Sibling paths "pointing to" where the new public data writes should be inserted (one by one) into the public data tree. - */ - public publicDataTreeSiblingPaths: Tuple< - Tuple, - typeof MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX - >, - ) {} - - static from(fields: FieldsOf): PublicBaseStateDiffHints { - return new PublicBaseStateDiffHints(...PublicBaseStateDiffHints.getFields(fields)); - } - - static getFields(fields: FieldsOf) { - return [ - fields.nullifierPredecessorPreimages, - fields.nullifierPredecessorMembershipWitnesses, - fields.sortedNullifiers, - fields.sortedNullifierIndexes, - fields.noteHashSubtreeSiblingPath, - fields.nullifierSubtreeSiblingPath, - fields.lowPublicDataWritesPreimages, - fields.lowPublicDataWritesMembershipWitnesses, - fields.publicDataTreeSiblingPaths, - ] as const; - } - - /** - * Serializes the state diff hints to a buffer. - * @returns A buffer of the serialized state diff hints. - */ - toBuffer(): Buffer { - return serializeToBuffer(...PublicBaseStateDiffHints.getFields(this)); - } - - /** - * Deserializes the state diff hints from a buffer. - * @param buffer - A buffer to deserialize from. - * @returns A new PublicBaseStateDiffHints instance. - */ - static fromBuffer(buffer: Buffer | BufferReader): PublicBaseStateDiffHints { - const reader = BufferReader.asReader(buffer); - return new PublicBaseStateDiffHints( - reader.readArray(MAX_NULLIFIERS_PER_TX, NullifierLeafPreimage), - reader.readArray(MAX_NULLIFIERS_PER_TX, { - fromBuffer: buffer => MembershipWitness.fromBuffer(buffer, NULLIFIER_TREE_HEIGHT), - }), - reader.readArray(MAX_NULLIFIERS_PER_TX, Fr), - reader.readNumbers(MAX_NULLIFIERS_PER_TX), - reader.readArray(NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, Fr), - reader.readArray(NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, Fr), - reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataTreeLeafPreimage), - reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, { - fromBuffer: buffer => MembershipWitness.fromBuffer(buffer, PUBLIC_DATA_TREE_HEIGHT), - }), - reader.readArray(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, { - fromBuffer(reader) { - return BufferReader.asReader(reader).readArray(PUBLIC_DATA_TREE_HEIGHT, Fr); - }, - }), - ); - } - - static empty() { - return new PublicBaseStateDiffHints( - makeTuple(MAX_NULLIFIERS_PER_TX, NullifierLeafPreimage.empty), - makeTuple(MAX_NULLIFIERS_PER_TX, () => MembershipWitness.empty(NULLIFIER_TREE_HEIGHT)), - makeTuple(MAX_NULLIFIERS_PER_TX, Fr.zero), - makeTuple(MAX_NULLIFIERS_PER_TX, () => 0), - makeTuple(NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, Fr.zero), - makeTuple(NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, Fr.zero), - makeTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataTreeLeafPreimage.empty), - makeTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, () => MembershipWitness.empty(PUBLIC_DATA_TREE_HEIGHT)), - makeTuple(MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, () => makeTuple(PUBLIC_DATA_TREE_HEIGHT, Fr.zero)), - ); - } -} diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 1d0cc54296e3..3715216c2cfc 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -165,7 +165,7 @@ import { PrivateTubeData } from '../structs/rollup/private_tube_data.js'; import { PublicBaseRollupInputs } from '../structs/rollup/public_base_rollup_inputs.js'; import { PublicTubeData } from '../structs/rollup/public_tube_data.js'; import { RootRollupInputs, RootRollupPublicInputs } from '../structs/rollup/root_rollup.js'; -import { PrivateBaseStateDiffHints, PublicBaseStateDiffHints } from '../structs/rollup/state_diff_hints.js'; +import { PrivateBaseStateDiffHints } from '../structs/rollup/state_diff_hints.js'; import { RollupValidationRequests } from '../structs/rollup_validation_requests.js'; import { AppendOnlyTreeSnapshot } from '../structs/trees/append_only_tree_snapshot.js'; @@ -1076,63 +1076,6 @@ export function makePrivateBaseStateDiffHints(seed = 1): PrivateBaseStateDiffHin ); } -/** - * Creates an instance of PublicBaseStateDiffHints with arbitrary values based on the provided seed. - * @param seed - The seed to use for generating the hints. - * @returns A PublicBaseStateDiffHints object. - */ -export function makePublicBaseStateDiffHints(seed = 1): PublicBaseStateDiffHints { - const nullifierPredecessorPreimages = makeTuple( - MAX_NULLIFIERS_PER_TX, - x => new NullifierLeafPreimage(fr(x), fr(x + 0x100), BigInt(x + 0x200)), - seed + 0x1000, - ); - - const nullifierPredecessorMembershipWitnesses = makeTuple( - MAX_NULLIFIERS_PER_TX, - x => makeMembershipWitness(NULLIFIER_TREE_HEIGHT, x), - seed + 0x2000, - ); - - const sortedNullifiers = makeTuple(MAX_NULLIFIERS_PER_TX, fr, seed + 0x3000); - - const sortedNullifierIndexes = makeTuple(MAX_NULLIFIERS_PER_TX, i => i, seed + 0x4000); - - const noteHashSubtreeSiblingPath = makeTuple(NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH, fr, seed + 0x5000); - - const nullifierSubtreeSiblingPath = makeTuple(NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, fr, seed + 0x6000); - - const lowPublicDataWritesPreimages = makeTuple( - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - makePublicDataTreeLeafPreimage, - seed + 0x7000, - ); - - const lowPublicDataWritesMembershipWitnesses = makeTuple( - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - i => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, i), - seed + 0x8000, - ); - - const publicDataTreeSiblingPaths = makeTuple( - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - i => makeTuple(PUBLIC_DATA_TREE_HEIGHT, fr, i), - seed + 0x9000, - ); - - return new PublicBaseStateDiffHints( - nullifierPredecessorPreimages, - nullifierPredecessorMembershipWitnesses, - sortedNullifiers, - sortedNullifierIndexes, - noteHashSubtreeSiblingPath, - nullifierSubtreeSiblingPath, - lowPublicDataWritesPreimages, - lowPublicDataWritesMembershipWitnesses, - publicDataTreeSiblingPaths, - ); -} - function makeVkWitnessData(seed = 1) { return new VkWitnessData(VerificationKeyData.makeFakeHonk(), seed, makeTuple(VK_TREE_HEIGHT, fr, seed + 0x100)); } @@ -1169,20 +1112,14 @@ function makePrivateBaseRollupHints(seed = 1) { } function makePublicBaseRollupHints(seed = 1) { - const start = makePartialStateReference(seed + 0x100); - const startSpongeBlob = makeSpongeBlob(seed + 0x200); - const stateDiffHints = makePublicBaseStateDiffHints(seed + 0x600); - const archiveRootMembershipWitness = makeMembershipWitness(ARCHIVE_HEIGHT, seed + 0x9000); const constants = makeConstantRollupData(0x100); return PublicBaseRollupHints.from({ - start, startSpongeBlob, - stateDiffHints, archiveRootMembershipWitness, constants, }); diff --git a/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts b/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts index c6ba0c6f315a..8ccdbd971d13 100644 --- a/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts +++ b/yarn-project/noir-protocol-circuits-types/src/conversion/server.ts @@ -11,7 +11,6 @@ import { type MembershipWitness, type NESTED_RECURSIVE_PROOF_LENGTH, type NULLIFIER_TREE_HEIGHT, - type PUBLIC_DATA_TREE_HEIGHT, ParityPublicInputs, type PrivateToAvmAccumulatedData, type PrivateToAvmAccumulatedDataArrayLengths, @@ -50,7 +49,6 @@ import { type PrivateBaseStateDiffHints, type PrivateTubeData, type PublicBaseRollupInputs, - type PublicBaseStateDiffHints, type PublicTubeData, type RootRollupInputs, RootRollupPublicInputs, @@ -94,7 +92,6 @@ import type { PrivateToRollupKernelCircuitPublicInputs as PrivateToRollupKernelCircuitPublicInputsNoir, PrivateTubeData as PrivateTubeDataNoir, PublicBaseRollupInputs as PublicBaseRollupInputsNoir, - PublicBaseStateDiffHints as PublicBaseStateDiffHintsNoir, PublicDataHint as PublicDataHintNoir, PublicTubeData as PublicTubeDataNoir, RollupValidationRequests as RollupValidationRequestsNoir, @@ -765,31 +762,6 @@ export function mapPrivateBaseStateDiffHintsToNoir(hints: PrivateBaseStateDiffHi }; } -/** - * Maps public base state diff hints to a noir state diff hints. - * @param hints - The state diff hints. - * @returns The noir state diff hints. - */ -export function mapPublicBaseStateDiffHintsToNoir(hints: PublicBaseStateDiffHints): PublicBaseStateDiffHintsNoir { - return { - nullifier_predecessor_preimages: mapTuple(hints.nullifierPredecessorPreimages, mapNullifierLeafPreimageToNoir), - nullifier_predecessor_membership_witnesses: mapTuple( - hints.nullifierPredecessorMembershipWitnesses, - (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), - ), - sorted_nullifiers: mapTuple(hints.sortedNullifiers, mapFieldToNoir), - sorted_nullifier_indexes: mapTuple(hints.sortedNullifierIndexes, (index: number) => mapNumberToNoir(index)), - note_hash_subtree_sibling_path: mapTuple(hints.noteHashSubtreeSiblingPath, mapFieldToNoir), - nullifier_subtree_sibling_path: mapTuple(hints.nullifierSubtreeSiblingPath, mapFieldToNoir), - low_public_data_writes_preimages: mapTuple(hints.lowPublicDataWritesPreimages, mapPublicDataTreePreimageToNoir), - low_public_data_writes_witnesses: mapTuple( - hints.lowPublicDataWritesMembershipWitnesses, - (witness: MembershipWitness) => mapMembershipWitnessToNoir(witness), - ), - public_data_tree_sibling_paths: mapTuple(hints.publicDataTreeSiblingPaths, path => mapTuple(path, mapFieldToNoir)), - }; -} - /** * Maps base parity inputs to noir. * @param inputs - The circuits.js base parity inputs. @@ -867,9 +839,7 @@ export function mapPublicBaseRollupInputsToNoir(inputs: PublicBaseRollupInputs): return { tube_data: mapPublicTubeDataToNoir(inputs.tubeData), avm_proof_data: mapAvmProofDataToNoir(inputs.avmProofData), - start: mapPartialStateReferenceToNoir(inputs.hints.start), start_sponge_blob: mapSpongeBlobToNoir(inputs.hints.startSpongeBlob), - state_diff_hints: mapPublicBaseStateDiffHintsToNoir(inputs.hints.stateDiffHints), archive_root_membership_witness: mapMembershipWitnessToNoir(inputs.hints.archiveRootMembershipWitness), constants: mapConstantRollupDataToNoir(inputs.hints.constants), diff --git a/yarn-project/prover-client/src/mocks/test_context.ts b/yarn-project/prover-client/src/mocks/test_context.ts index 8bc3c05980d2..b74b02537695 100644 --- a/yarn-project/prover-client/src/mocks/test_context.ts +++ b/yarn-project/prover-client/src/mocks/test_context.ts @@ -183,7 +183,7 @@ export class TestContext { const txs = await timesParallel(numTxs, i => this.makeProcessedTx({ seed: i + blockNum * 1000, globalVariables, ...makeProcessedTxOpts(i) }), ); - await this.setEndTreeRoots(txs); + await this.setTreeRoots(txs); const block = await buildBlock(txs, globalVariables, msgs, db); this.headers.set(blockNum, block.header); @@ -220,17 +220,24 @@ export class TestContext { ); } - public async setEndTreeRoots(txs: ProcessedTx[]) { + public async setTreeRoots(txs: ProcessedTx[]) { const db = await this.worldState.fork(); for (const tx of txs) { + const startStateReference = await db.getStateReference(); await updateExpectedTreesFromTxs(db, [tx]); - const stateReference = await db.getStateReference(); + const endStateReference = await db.getStateReference(); if (tx.avmProvingRequest) { + tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots = new TreeSnapshots( + startStateReference.l1ToL2MessageTree, + startStateReference.partial.noteHashTree, + startStateReference.partial.nullifierTree, + startStateReference.partial.publicDataTree, + ); tx.avmProvingRequest.inputs.publicInputs.endTreeSnapshots = new TreeSnapshots( - stateReference.l1ToL2MessageTree, - stateReference.partial.noteHashTree, - stateReference.partial.nullifierTree, - stateReference.partial.publicDataTree, + endStateReference.l1ToL2MessageTree, + endStateReference.partial.noteHashTree, + endStateReference.partial.nullifierTree, + endStateReference.partial.publicDataTree, ); } } 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 6d73bd64cc69..645e112a6b69 100644 --- a/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts +++ b/yarn-project/prover-client/src/orchestrator/block-building-helpers.ts @@ -16,7 +16,6 @@ import { type GlobalVariables, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MembershipWitness, MerkleTreeCalculator, NOTE_HASH_SUBTREE_HEIGHT, @@ -42,7 +41,6 @@ import { PrivateBaseRollupHints, PrivateBaseStateDiffHints, PublicBaseRollupHints, - PublicBaseStateDiffHints, } from '@aztec/circuits.js/rollup'; import { makeTuple } from '@aztec/foundation/array'; import { padArrayEnd } from '@aztec/foundation/collection'; @@ -139,39 +137,6 @@ export const buildBaseRollupHints = runInSpan( await startSpongeBlob.absorb(tx.txEffect.toBlobFields()); if (tx.avmProvingRequest) { - // Build public base rollup hints - const stateDiffHints = PublicBaseStateDiffHints.from({ - nullifierPredecessorPreimages: makeTuple(MAX_NULLIFIERS_PER_TX, i => - i < nullifierWitnessLeaves.length - ? (nullifierWitnessLeaves[i].leafPreimage as NullifierLeafPreimage) - : NullifierLeafPreimage.empty(), - ), - nullifierPredecessorMembershipWitnesses: makeTuple(MAX_NULLIFIERS_PER_TX, i => - i < nullifierPredecessorMembershipWitnessesWithoutPadding.length - ? nullifierPredecessorMembershipWitnessesWithoutPadding[i] - : makeEmptyMembershipWitness(NULLIFIER_TREE_HEIGHT), - ), - sortedNullifiers: makeTuple(MAX_NULLIFIERS_PER_TX, i => Fr.fromBuffer(sortednullifiers[i])), - sortedNullifierIndexes: makeTuple(MAX_NULLIFIERS_PER_TX, i => sortedNewLeavesIndexes[i]), - noteHashSubtreeSiblingPath, - nullifierSubtreeSiblingPath, - lowPublicDataWritesPreimages: padArrayEnd( - txPublicDataUpdateRequestInfo.lowPublicDataWritesPreimages, - PublicDataTreeLeafPreimage.empty(), - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - ), - lowPublicDataWritesMembershipWitnesses: padArrayEnd( - txPublicDataUpdateRequestInfo.lowPublicDataWritesMembershipWitnesses, - MembershipWitness.empty(PUBLIC_DATA_TREE_HEIGHT), - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - ), - publicDataTreeSiblingPaths: padArrayEnd( - txPublicDataUpdateRequestInfo.publicDataWritesSiblingPaths, - makeTuple(PUBLIC_DATA_TREE_HEIGHT, () => Fr.ZERO), - MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - ), - }); - const blockHash = await tx.constants.historicalHeader.hash(); const archiveRootMembershipWitness = await getMembershipWitnessFor( blockHash, @@ -181,9 +146,7 @@ export const buildBaseRollupHints = runInSpan( ); return PublicBaseRollupHints.from({ - start, startSpongeBlob: inputSpongeBlob, - stateDiffHints, archiveRootMembershipWitness, constants, }); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts index a55cab7951c5..b4190484a898 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_errors.test.ts @@ -25,7 +25,7 @@ describe('prover/orchestrator/errors', () => { describe('errors', () => { it('throws if adding too many transactions', async () => { const txs = await timesParallel(4, i => context.makeProcessedTx(i + 1)); - await context.setEndTreeRoots(txs); + await context.setTreeRoots(txs); orchestrator.startNewEpoch(1, 1, 1); await orchestrator.startNewBlock(context.globalVariables, [], context.getPreviousBlockHeader()); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts index f33af88fb5c5..cc1ae11f4c5d 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_mixed_blocks.test.ts @@ -13,7 +13,7 @@ describe('prover/orchestrator/mixed-blocks', () => { const runTest = async (numTxs: number) => { const txs = await timesParallel(numTxs, i => context.makeProcessedTx(i + 1)); - await context.setEndTreeRoots(txs); + await context.setTreeRoots(txs); const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts index 6dccedb628b3..c5fbd7986f77 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_single_blocks.test.ts @@ -31,7 +31,7 @@ describe('prover/orchestrator/blocks', () => { it('builds a block with 1 transaction', async () => { const txs = [await context.makeProcessedTx(1)]; - await context.setEndTreeRoots(txs); + await context.setTreeRoots(txs); // This will need to be a 2 tx block context.orchestrator.startNewEpoch(1, 1, 1); @@ -46,7 +46,7 @@ describe('prover/orchestrator/blocks', () => { it('builds a block concurrently with transaction simulation', async () => { const txs = await timesParallel(4, i => context.makeProcessedTx(i + 1)); - await context.setEndTreeRoots(txs); + await context.setTreeRoots(txs); const l1ToL2Messages = range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 1 + 0x400).map(fr); context.orchestrator.startNewEpoch(1, 1, 1); diff --git a/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts b/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts index d3a83da47a27..ec1fc614584b 100644 --- a/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts +++ b/yarn-project/prover-client/src/orchestrator/orchestrator_workflow.test.ts @@ -115,7 +115,7 @@ describe('prover/orchestrator', () => { orchestrator.startNewEpoch(1, 1, 1); await orchestrator.startNewBlock(globalVariables, [], previousBlockHeader); const txs = await Promise.all([context.makeProcessedTx(1), context.makeProcessedTx(2)]); - await context.setEndTreeRoots(txs); + await context.setTreeRoots(txs); await orchestrator.addTxs(txs); // wait for the block root proof to try to be enqueued @@ -143,7 +143,7 @@ describe('prover/orchestrator', () => { getTubeSpy.mockReset(); await orchestrator.startNewBlock(globalVariables, [], previousBlockHeader); - await context.setEndTreeRoots(processedTxs); + await context.setTreeRoots(processedTxs); await orchestrator.addTxs(processedTxs); await orchestrator.setBlockCompleted(context.blockNumber); const result = await orchestrator.finaliseEpoch();