From 6c060e6dab0a44886da04e53d576e41e04a603c5 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 09:49:32 +0000 Subject: [PATCH 01/14] 972 - Rephrase comments in constants.hpp and rename commitments related constants --- .../abis/combined_accumulated_data.hpp | 2 +- .../abis/private_circuit_public_inputs.hpp | 6 ++-- .../abis/public_circuit_public_inputs.hpp | 2 +- .../aztec3/circuits/kernel/private/common.cpp | 2 +- ...tive_private_kernel_circuit_inner.test.cpp | 4 +-- ...native_private_kernel_circuit_ordering.cpp | 10 +++--- ...e_private_kernel_circuit_ordering.test.cpp | 6 ++-- .../kernel/private/private_kernel_circuit.cpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 28 +++++++++-------- .../aztec3/circuits/kernel/public/common.hpp | 2 +- .../src/aztec3/circuits/rollup/base/.test.cpp | 10 +++--- .../base/native_base_rollup_circuit.cpp | 4 +-- .../circuits/rollup/components/components.cpp | 10 +++--- .../src/aztec3/circuits/rollup/root/.test.cpp | 10 +++--- .../circuits/rollup/test_utils/utils.cpp | 8 ++--- circuits/cpp/src/aztec3/constants.hpp | 31 +++++++++++-------- .../acir-simulator/src/acvm/deserialize.ts | 4 +-- .../src/client/private_execution.test.ts | 4 +-- .../src/account_state/account_state.test.ts | 14 ++++----- .../src/account_state/account_state.ts | 4 +-- .../src/kernel_prover/kernel_prover.test.ts | 4 +-- .../circuits.js/src/structs/constants.ts | 4 +-- .../kernel/combined_accumulated_data.ts | 10 +++--- .../structs/private_circuit_public_inputs.ts | 6 ++-- .../structs/public_circuit_public_inputs.ts | 8 ++--- .../src/structs/rollup/base_rollup.ts | 4 +-- .../circuits.js/src/tests/factories.ts | 12 +++---- .../src/integration_l1_publisher.test.ts | 4 +-- .../block_builder/solo_block_builder.test.ts | 4 +-- .../src/sequencer/public_processor.ts | 4 +-- yarn-project/types/src/l2_block.ts | 20 ++++++------ yarn-project/types/src/l2_block_context.ts | 4 +-- .../server_world_state_synchroniser.test.ts | 4 +-- 33 files changed, 129 insertions(+), 122 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index 4bd6f4c34daf..94c124ae98d9 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -25,7 +25,7 @@ template struct CombinedAccumulatedData { AggregationObject aggregation_object{}; - std::array new_commitments{}; + std::array new_commitments{}; std::array new_nullifiers{}; std::array private_call_stack{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index 2215ebfe6f46..f3fd4fd62b38 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -29,7 +29,7 @@ template class PrivateCircuitPublicInputs { std::array read_requests{}; - std::array new_commitments{}; + std::array new_commitments{}; std::array new_nullifiers{}; std::array private_call_stack{}; @@ -303,7 +303,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array read_requests; - std::array new_commitments; + std::array new_commitments; std::array new_nullifiers; std::array private_call_stack; @@ -335,7 +335,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array const& read_requests, - std::array const& new_commitments, + std::array const& new_commitments, std::array const& new_nullifiers, std::array const& private_call_stack, diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index 839c90b41377..e817582e4a54 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -31,7 +31,7 @@ template struct PublicCircuitPublicInputs { std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> contract_storage_reads{}; std::array public_call_stack{}; - std::array new_commitments{}; + std::array new_commitments{}; std::array new_nullifiers{}; std::array new_l2_to_l1_msgs{}; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 0a0770502f04..6b314b4b703c 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -141,7 +141,7 @@ void common_update_end_values(DummyBuilder& builder, // Enhance commitments and nullifiers with domain separation whereby domain is the contract. { // commitments & nullifiers - std::array siloed_new_commitments{}; + std::array siloed_new_commitments{}; for (size_t i = 0; i < new_commitments.size(); ++i) { siloed_new_commitments[i] = new_commitments[i] == 0 ? 0 : silo_commitment(storage_contract_address, new_commitments[i]); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp index 98a380b127e1..6d06b5b046bf 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_inner.test.cpp @@ -190,8 +190,8 @@ TEST_F(native_private_kernel_inner_tests, private_kernel_should_fail_if_aggregat do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); // Mock the previous new commitments to be full, therefore no need commitments can be added - std::array full_new_commitments{}; - for (size_t i = 0; i < KERNEL_NEW_COMMITMENTS_LENGTH; ++i) { + std::array full_new_commitments{}; + for (size_t i = 0; i < MAX_NEW_COMMITMENTS_PER_TX; ++i) { full_new_commitments[i] = i + 1; } private_inputs.previous_kernel.public_inputs.end.new_commitments = full_new_commitments; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp index d55e29cf0df1..e8ed8ec54573 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.cpp @@ -26,7 +26,7 @@ void chop_pending_commitments(DummyBuilder& builder, std::array const& read_requests, std::array, READ_REQUESTS_LENGTH> const& read_request_membership_witnesses, - std::array& new_commitments) + std::array& new_commitments) { // chop commitments from the previous call(s) for (size_t i = 0; i < READ_REQUESTS_LENGTH; i++) { @@ -34,13 +34,13 @@ void chop_pending_commitments(DummyBuilder& builder, const auto is_transient_read = (read_request_membership_witnesses[i].leaf_index == NT::fr(-1)); if (is_transient_read) { - size_t match_pos = KERNEL_NEW_COMMITMENTS_LENGTH; - for (size_t j = 0; j < KERNEL_NEW_COMMITMENTS_LENGTH; j++) { + size_t match_pos = MAX_NEW_COMMITMENTS_PER_TX; + for (size_t j = 0; j < MAX_NEW_COMMITMENTS_PER_TX; j++) { match_pos = (read_request == new_commitments[j]) ? j : match_pos; } // chop the pending commitment, i.e., replacing with 0. - if (match_pos != KERNEL_NEW_COMMITMENTS_LENGTH) { + if (match_pos != MAX_NEW_COMMITMENTS_PER_TX) { new_commitments[match_pos] = fr(0); } else { builder.do_assert( @@ -52,7 +52,7 @@ void chop_pending_commitments(DummyBuilder& builder, } // Move all zero entries of this array to the end and preserve ordering of other entries - utils::array_rearrange(new_commitments); + utils::array_rearrange(new_commitments); } KernelCircuitPublicInputs native_private_kernel_circuit_ordering( diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp index a61fef88068b..97f6bdec398c 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_ordering.test.cpp @@ -33,7 +33,7 @@ TEST_F(native_private_kernel_ordering_tests, native_one_read_request_choping_com { auto private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); - std::array new_commitments{}; + std::array new_commitments{}; std::array read_requests{}; std::array, READ_REQUESTS_LENGTH> read_request_membership_witnesses{}; @@ -61,7 +61,7 @@ TEST_F(native_private_kernel_ordering_tests, native_read_requests_choping_commit { auto private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); - std::array new_commitments{}; + std::array new_commitments{}; std::array read_requests{}; std::array, READ_REQUESTS_LENGTH> read_request_membership_witnesses{}; @@ -98,7 +98,7 @@ TEST_F(native_private_kernel_ordering_tests, native_read_request_unknown_fails) { auto private_inputs = do_private_call_get_kernel_inputs_inner(false, deposit, standard_test_args()); - std::array new_commitments{}; + std::array new_commitments{}; std::array read_requests{}; std::array, READ_REQUESTS_LENGTH> read_request_membership_witnesses{}; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp index 8af328b9bfed..0d99193fd28e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp @@ -149,7 +149,7 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne } { // commitments, nullifiers, and contracts - std::array siloed_new_commitments; + std::array siloed_new_commitments; for (size_t i = 0; i < new_commitments.size(); ++i) { siloed_new_commitments[i] = CT::fr::conditional_assign( new_commitments[i] == 0, 0, silo_commitment(storage_contract_address, new_commitments[i])); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 2e010cc6633d..62da0b6929d0 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -125,7 +125,8 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, std::array const return_values = array_of_values(count); std::array const public_call_stack = array_of_values(count); - std::array const new_commitments = array_of_values(count); + std::array const new_commitments = + array_of_values(count); std::array const new_nullifiers = array_of_values(count); std::array const new_l2_to_l1_msgs = array_of_values(count); @@ -206,11 +207,11 @@ public_data_update_requests_from_contract_storage_update_requests( return values; } -std::array new_commitments_as_siloed_commitments( - std::array const& new_commitments, NT::fr const& contract_address) +std::array new_commitments_as_siloed_commitments( + std::array const& new_commitments, NT::fr const& contract_address) { - std::array siloed_commitments{}; - for (size_t i = 0; i < NEW_COMMITMENTS_LENGTH; ++i) { + std::array siloed_commitments{}; + for (size_t i = 0; i < MAX_NEW_COMMITMENTS_PER_CALL; ++i) { if (!new_commitments[i].is_zero()) { siloed_commitments[i] = silo_commitment(contract_address, new_commitments[i]); } @@ -317,8 +318,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat generate_contract_storage_update_requests(seed, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH / 2); std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const reads = generate_contract_storage_reads(seed, KERNEL_PUBLIC_DATA_READS_LENGTH / 2); - std::array const new_commitments = - array_of_values(seed, NEW_COMMITMENTS_LENGTH / 2); + std::array const new_commitments = + array_of_values(seed, MAX_NEW_COMMITMENTS_PER_CALL / 2); std::array const new_nullifiers = array_of_values(seed, NEW_NULLIFIERS_LENGTH / 2); std::array const new_l2_to_l1_msgs = @@ -387,8 +388,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat public_call_stack[0] = public_call_data.call_stack_item.hash(); CombinedAccumulatedData const end_accumulated_data = { - .new_commitments = array_of_values( - seed, private_previous ? KERNEL_NEW_COMMITMENTS_LENGTH / 2 : 0), + .new_commitments = + array_of_values(seed, private_previous ? MAX_NEW_COMMITMENTS_PER_TX / 2 : 0), .new_nullifiers = array_of_values( seed, private_previous ? KERNEL_NEW_NULLIFIERS_LENGTH / 2 : 0), .private_call_stack = array_of_values(seed, 0), @@ -1016,7 +1017,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre inputs.previous_kernel.public_inputs.end.public_data_reads = initial_reads; // setup 2 previous new commitments - std::array initial_commitments{}; + std::array initial_commitments{}; initial_commitments[0] = fr(1); initial_commitments[1] = fr(2); inputs.previous_kernel.public_inputs.end.new_commitments = initial_commitments; @@ -1097,8 +1098,9 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre expected_new_reads, public_inputs.end.public_data_reads)); - std::array const expected_new_commitments = new_commitments_as_siloed_commitments( - inputs.public_call.call_stack_item.public_inputs.new_commitments, contract_address); + std::array const expected_new_commitments = + new_commitments_as_siloed_commitments(inputs.public_call.call_stack_item.public_inputs.new_commitments, + contract_address); ASSERT_TRUE(source_arrays_are_in_target(inputs.previous_kernel.public_inputs.end.new_commitments, expected_new_commitments, @@ -1198,7 +1200,7 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_nullifiers_on_static_ inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = empty_array_of_values, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(); inputs.public_call.call_stack_item.public_inputs.new_commitments = - empty_array_of_values(); + empty_array_of_values(); // regenerate call data hash inputs.previous_kernel.public_inputs.end.public_call_stack[0] = diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index 1b9bb343ee16..5a9448ea44bd 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -287,7 +287,7 @@ void propagate_new_commitments(Builder& builder, const auto& new_commitments = public_call_public_inputs.new_commitments; const auto& storage_contract_address = public_call_public_inputs.call_context.storage_contract_address; - std::array siloed_new_commitments{}; + std::array siloed_new_commitments{}; for (size_t i = 0; i < new_commitments.size(); ++i) { if (!new_commitments[i].is_zero()) { siloed_new_commitments[i] = silo_commitment(storage_contract_address, new_commitments[i]); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 4c9c6f877278..6dcce2962af1 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -255,11 +255,11 @@ TEST_F(base_rollup_tests, native_new_commitments_tree) // Then get sibling path so we can verify insert them into the tree. std::array, 2> kernel_data = { get_empty_kernel(), get_empty_kernel() }; - std::array new_commitments = { 0, 1, 2, 3, 4, 5, 6, 7 }; + std::array new_commitments = { 0, 1, 2, 3, 4, 5, 6, 7 }; for (uint8_t i = 0; i < 2; i++) { - std::array kernel_commitments; - for (uint8_t j = 0; j < KERNEL_NEW_COMMITMENTS_LENGTH; j++) { - kernel_commitments[j] = new_commitments[i * KERNEL_NEW_COMMITMENTS_LENGTH + j]; + std::array kernel_commitments; + for (uint8_t j = 0; j < MAX_NEW_COMMITMENTS_PER_TX; j++) { + kernel_commitments[j] = new_commitments[i * MAX_NEW_COMMITMENTS_PER_TX + j]; } kernel_data[i].public_inputs.end.new_commitments = kernel_commitments; } @@ -275,7 +275,7 @@ TEST_F(base_rollup_tests, native_new_commitments_tree) } AppendOnlyTreeSnapshot const expected_end_commitments_snapshot = { .root = private_data_tree.root(), - .next_available_leaf_index = 2 * KERNEL_NEW_COMMITMENTS_LENGTH, + .next_available_leaf_index = 2 * MAX_NEW_COMMITMENTS_PER_TX, }; auto inputs = base_rollup_inputs_from_kernels(kernel_data); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 137245dbe1df..879790092df2 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -102,13 +102,13 @@ NT::fr calculate_commitments_subtree(DummyBuilder& builder, BaseRollupInputs con auto new_commitments = baseRollupInputs.kernel_data[i].public_inputs.end.new_commitments; // Our commitments size MUST be 4 to calculate our subtrees correctly - builder.do_assert(new_commitments.size() == KERNEL_NEW_COMMITMENTS_LENGTH, + builder.do_assert(new_commitments.size() == MAX_NEW_COMMITMENTS_PER_TX, "New commitments in kernel data must be 4", CircuitErrorCode::BASE__INCORRECT_NUM_OF_NEW_COMMITMENTS); for (size_t j = 0; j < new_commitments.size(); j++) { // todo: batch insert - commitments_tree.update_element(i * KERNEL_NEW_COMMITMENTS_LENGTH + j, new_commitments[j]); + commitments_tree.update_element(i * MAX_NEW_COMMITMENTS_PER_TX + j, new_commitments[j]); } } diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index 2f706bde379f..ac26a8dc77bf 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -103,7 +103,7 @@ std::array compute_kernels_calldata_hash( { // Compute calldata hashes // Consist of 2 kernels - // 2 * KERNEL_NEW_COMMITMENTS_LENGTH fields for commitments + // 2 * MAX_NEW_COMMITMENTS_PER_TX fields for commitments // 2 * KERNEL_NEW_NULLIFIERS_LENGTH fields for nullifiers // 8 public data update requests (4 per kernel) -> 16 fields // 4 l2 -> l1 messages (2 per kernel) -> 4 fields @@ -111,7 +111,7 @@ std::array compute_kernels_calldata_hash( // 2 encrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes // 2 unencrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes auto const number_of_inputs = - (KERNEL_NEW_COMMITMENTS_LENGTH + KERNEL_NEW_NULLIFIERS_LENGTH + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + + (MAX_NEW_COMMITMENTS_PER_TX + KERNEL_NEW_NULLIFIERS_LENGTH + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + KERNEL_NEW_CONTRACTS_LENGTH * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256) * @@ -128,10 +128,10 @@ std::array compute_kernels_calldata_hash( size_t offset = 0; - for (size_t j = 0; j < KERNEL_NEW_COMMITMENTS_LENGTH; j++) { - calldata_hash_inputs[offset + i * KERNEL_NEW_COMMITMENTS_LENGTH + j] = new_commitments[j]; + for (size_t j = 0; j < MAX_NEW_COMMITMENTS_PER_TX; j++) { + calldata_hash_inputs[offset + i * MAX_NEW_COMMITMENTS_PER_TX + j] = new_commitments[j]; } - offset += KERNEL_NEW_COMMITMENTS_LENGTH * 2; + offset += MAX_NEW_COMMITMENTS_PER_TX * 2; for (size_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { calldata_hash_inputs[offset + i * KERNEL_NEW_NULLIFIERS_LENGTH + j] = new_nullifiers[j]; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp index bec64e1093ac..b4005c76c7e2 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -183,11 +183,11 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) // Create commitments for (uint8_t kernel_j = 0; kernel_j < 4; kernel_j++) { - std::array new_commitments; - for (uint8_t commitment_k = 0; commitment_k < KERNEL_NEW_COMMITMENTS_LENGTH; commitment_k++) { - auto val = fr(kernel_j * KERNEL_NEW_COMMITMENTS_LENGTH + commitment_k + 1); + std::array new_commitments; + for (uint8_t commitment_k = 0; commitment_k < MAX_NEW_COMMITMENTS_PER_TX; commitment_k++) { + auto val = fr(kernel_j * MAX_NEW_COMMITMENTS_PER_TX + commitment_k + 1); new_commitments[commitment_k] = val; - data_tree.update_element(kernel_j * KERNEL_NEW_COMMITMENTS_LENGTH + commitment_k, val); + data_tree.update_element(kernel_j * MAX_NEW_COMMITMENTS_PER_TX + commitment_k, val); } kernels[kernel_j].public_inputs.end.new_commitments = new_commitments; @@ -258,7 +258,7 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) rootRollupInputs.previous_rollup_data[1].base_or_merge_rollup_public_inputs.end_private_data_tree_snapshot); AppendOnlyTreeSnapshot const expected_private_data_tree_snapshot = { .root = data_tree.root(), .next_available_leaf_index = - 4 * KERNEL_NEW_COMMITMENTS_LENGTH }; + 4 * MAX_NEW_COMMITMENTS_PER_TX }; ASSERT_EQ(outputs.end_private_data_tree_snapshot, expected_private_data_tree_snapshot); // Check public data trees diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index cd531d85473f..fe480c2b47e6 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -52,7 +52,7 @@ namespace aztec3::circuits::rollup::test_utils::utils { std::vector get_empty_calldata_leaf() { auto const number_of_inputs = - (KERNEL_NEW_COMMITMENTS_LENGTH + KERNEL_NEW_NULLIFIERS_LENGTH + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + + (MAX_NEW_COMMITMENTS_PER_TX + KERNEL_NEW_NULLIFIERS_LENGTH + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + KERNEL_NEW_CONTRACTS_LENGTH * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * 2) * 2; @@ -262,8 +262,8 @@ std::array, 2> get_previous_rollup_data(DummyBuilder& bui std::array nullifiers; for (size_t i = 0; i < 2; i++) { - for (size_t j = 0; j < KERNEL_NEW_COMMITMENTS_LENGTH; j++) { - private_data_tree.update_element(i * KERNEL_NEW_COMMITMENTS_LENGTH + j, + for (size_t j = 0; j < MAX_NEW_COMMITMENTS_PER_TX; j++) { + private_data_tree.update_element(i * MAX_NEW_COMMITMENTS_PER_TX + j, kernel_data[i].public_inputs.end.new_commitments[j]); } auto contract_data = kernel_data[i].public_inputs.end.new_contracts[0]; @@ -288,7 +288,7 @@ std::array, 2> get_previous_rollup_data(DummyBuilder& bui get_sibling_path(contract_tree, 2, CONTRACT_SUBTREE_DEPTH); base_rollup_input_2.new_commitments_subtree_sibling_path = get_sibling_path( - private_data_tree, 2 * KERNEL_NEW_COMMITMENTS_LENGTH, PRIVATE_DATA_SUBTREE_DEPTH); + private_data_tree, 2 * MAX_NEW_COMMITMENTS_PER_TX, PRIVATE_DATA_SUBTREE_DEPTH); auto base_public_input_2 = aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, base_rollup_input_2); diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 2153ba84a7b5..82c202d07868 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -14,33 +14,38 @@ constexpr size_t log2(size_t input) return (input < 2) ? 0 : 1 + log2(input / 2); } - // Note: must be kept in sync with ts/structs/constants.ts constexpr size_t ARGS_LENGTH = 16; constexpr size_t RETURN_VALUES_LENGTH = 4; - constexpr size_t READ_REQUESTS_LENGTH = 4; - /** - * Note: The number of commitments that 1 function call can output is: NEW_COMMITMENTS_LENGTH = 4. The number of - * nullifiers that 1 function call can output is: NEW_NULLIFIERS_LENGTH = 4. This is different from - * KERNEL_NEW_COMMITMENTS_LENGTH and KERNEL_NEW_NULLIFIERS_LENGTH because, in the kernel circuits, we accumulate the - * commitments and the nullifiers from all functions calls in a transaction. Therefore, we always must have: + * Convention for constant array lengths are mainly divided in 2 classes: + * - FUNCTION CALL + * - TRANSACTION + * + * Agreed convention is to use MAX_XXX_PER_CALL resp. MAX_XXX_PER_TX, where XXX denotes a type of element such as + * commitment, or nullifier, e.g.,: + * - MAX_NEW_NULLIFIERS_PER_CALL + * - MAX_NEW_COMMITMENTS_PER_TX + * + * In the kernel circuits, we accumulate elements such as commitments and the nullifiers from all functions calls in a + * transaction. Therefore, we always must have: + * MAX_XXX_PER_TX ≥ MAX_XXX_PER_CALL * - * KERNEL_NEW_COMMITMENTS_LENGTH ≥ NEW_COMMITMENTS_LENGTH - * KERNEL_NEW_NULLIFIERS_LENGTH ≥ NEW_NULLIFIERS_LENGTH + * For instance: + * MAX_NEW_COMMITMENTS_PER_TX ≥ MAX_NEW_COMMITMENTS_PER_CALL + * MAX_NEW_NULLIFIERS_PER_TX ≥ MAX_NEW_NULLIFIERS_PER_CALL * */ -// TODO(962): Rename this to `COMMITMENTS_PER_KERNEL` and make it consistent across the codebase. -constexpr size_t NEW_COMMITMENTS_LENGTH = 4; +constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 4; constexpr size_t NEW_NULLIFIERS_LENGTH = 4; constexpr size_t PRIVATE_CALL_STACK_LENGTH = 4; constexpr size_t PUBLIC_CALL_STACK_LENGTH = 4; constexpr size_t NEW_L2_TO_L1_MSGS_LENGTH = 2; -constexpr size_t KERNEL_NEW_COMMITMENTS_LENGTH = PRIVATE_CALL_STACK_LENGTH * NEW_COMMITMENTS_LENGTH; +constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = PRIVATE_CALL_STACK_LENGTH * MAX_NEW_COMMITMENTS_PER_CALL; constexpr size_t KERNEL_NEW_NULLIFIERS_LENGTH = PRIVATE_CALL_STACK_LENGTH * NEW_NULLIFIERS_LENGTH; constexpr size_t KERNEL_NEW_CONTRACTS_LENGTH = 1; constexpr size_t KERNEL_PRIVATE_CALL_STACK_LENGTH = 8; @@ -66,7 +71,7 @@ constexpr size_t CONTRACT_SUBTREE_INCLUSION_CHECK_DEPTH = CONTRACT_TREE_HEIGHT - // TODO(961): Use this constant everywhere instead of hard-coded "2". constexpr size_t KERNELS_PER_ROLLUP = 2; constexpr size_t PRIVATE_DATA_SUBTREE_DEPTH = - static_cast(log2(KERNELS_PER_ROLLUP * KERNEL_NEW_COMMITMENTS_LENGTH)); + static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_COMMITMENTS_PER_TX)); constexpr size_t PRIVATE_DATA_SUBTREE_INCLUSION_CHECK_DEPTH = PRIVATE_DATA_TREE_HEIGHT - PRIVATE_DATA_SUBTREE_DEPTH; constexpr size_t NULLIFIER_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * KERNEL_NEW_NULLIFIERS_LENGTH)); diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index 09660529f9ea..03ca12ed7315 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -1,7 +1,7 @@ import { CallContext, ContractDeploymentData, - NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, NEW_NULLIFIERS_LENGTH, NUM_FIELDS_PER_SHA256, @@ -124,7 +124,7 @@ export function extractPublicInputs(partialWitness: ACVMWitness, acir: Buffer): const argsHash = witnessReader.readField(); const returnValues = witnessReader.readFieldArray(RETURN_VALUES_LENGTH); const readRequests = witnessReader.readFieldArray(READ_REQUESTS_LENGTH); - const newCommitments = witnessReader.readFieldArray(NEW_COMMITMENTS_LENGTH); + const newCommitments = witnessReader.readFieldArray(MAX_NEW_COMMITMENTS_PER_CALL); const newNullifiers = witnessReader.readFieldArray(NEW_NULLIFIERS_LENGTH); const privateCallStack = witnessReader.readFieldArray(PRIVATE_CALL_STACK_LENGTH); const publicCallStack = witnessReader.readFieldArray(PUBLIC_CALL_STACK_LENGTH); diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 2a811e5f594d..71340cda0b57 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -4,7 +4,7 @@ import { ContractDeploymentData, FunctionData, L1_TO_L2_MESSAGES_TREE_HEIGHT, - NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_CALL, PRIVATE_DATA_TREE_HEIGHT, PrivateHistoricTreeRoots, PublicCallRequest, @@ -120,7 +120,7 @@ describe('Private Execution test suite', () => { it('should run the empty constructor', async () => { const abi = TestContractAbi.functions[0]; const result = await runSimulator({ abi, isConstructor: true }); - expect(result.callStackItem.publicInputs.newCommitments).toEqual(new Array(NEW_COMMITMENTS_LENGTH).fill(Fr.ZERO)); + expect(result.callStackItem.publicInputs.newCommitments).toEqual(new Array(MAX_NEW_COMMITMENTS_PER_CALL).fill(Fr.ZERO)); }); }); diff --git a/yarn-project/aztec-rpc/src/account_state/account_state.test.ts b/yarn-project/aztec-rpc/src/account_state/account_state.test.ts index beab72a07d16..3a4879f5cf82 100644 --- a/yarn-project/aztec-rpc/src/account_state/account_state.test.ts +++ b/yarn-project/aztec-rpc/src/account_state/account_state.test.ts @@ -1,6 +1,6 @@ import { AztecNode } from '@aztec/aztec-node'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; -import { AztecAddress, CircuitsWasm, KERNEL_NEW_COMMITMENTS_LENGTH } from '@aztec/circuits.js'; +import { AztecAddress, CircuitsWasm, MAX_NEW_COMMITMENTS_PER_TX } from '@aztec/circuits.js'; import { Fr, Point } from '@aztec/foundation/fields'; import { ConstantKeyPair, KeyPair, KeyStore } from '@aztec/key-store'; import { FunctionL2Logs, L2Block, L2BlockContext, L2BlockL2Logs, NoteSpendingInfo, TxL2Logs } from '@aztec/types'; @@ -22,14 +22,14 @@ describe('Account State', () => { const createEncryptedLogsAndOwnedNoteSpendingInfo = (ownedDataIndices: number[] = []) => { ownedDataIndices.forEach(index => { - if (index >= KERNEL_NEW_COMMITMENTS_LENGTH) { - throw new Error(`Data index should be less than ${KERNEL_NEW_COMMITMENTS_LENGTH}.`); + if (index >= MAX_NEW_COMMITMENTS_PER_TX) { + throw new Error(`Data index should be less than ${MAX_NEW_COMMITMENTS_PER_TX}.`); } }); const txLogs: TxL2Logs[] = []; const ownedNoteSpendingInfo: NoteSpendingInfo[] = []; - for (let i = 0; i < KERNEL_NEW_COMMITMENTS_LENGTH; ++i) { + for (let i = 0; i < MAX_NEW_COMMITMENTS_PER_TX; ++i) { const noteSpendingInfo = NoteSpendingInfo.random(); const isOwner = ownedDataIndices.includes(i); const publicKey = isOwner ? owner.getPublicKey() : Point.random(); @@ -140,15 +140,15 @@ describe('Account State', () => { expect(addNoteSpendingInfoBatchSpy).toHaveBeenCalledWith([ expect.objectContaining({ ...ownedNoteSpendingInfos[0], - index: BigInt(KERNEL_NEW_COMMITMENTS_LENGTH + 1), + index: BigInt(MAX_NEW_COMMITMENTS_PER_TX + 1), }), expect.objectContaining({ ...ownedNoteSpendingInfos[1], - index: BigInt(KERNEL_NEW_COMMITMENTS_LENGTH * 4), + index: BigInt(MAX_NEW_COMMITMENTS_PER_TX * 4), }), expect.objectContaining({ ...ownedNoteSpendingInfos[2], - index: BigInt(KERNEL_NEW_COMMITMENTS_LENGTH * 4 + 2), + index: BigInt(MAX_NEW_COMMITMENTS_PER_TX * 4 + 2), }), ]); }); diff --git a/yarn-project/aztec-rpc/src/account_state/account_state.ts b/yarn-project/aztec-rpc/src/account_state/account_state.ts index bc3e90c6b99c..1e68e55a4d30 100644 --- a/yarn-project/aztec-rpc/src/account_state/account_state.ts +++ b/yarn-project/aztec-rpc/src/account_state/account_state.ts @@ -1,6 +1,6 @@ import { AcirSimulator, collectEncryptedLogs, collectEnqueuedPublicFunctionCalls } from '@aztec/acir-simulator'; import { AztecNode } from '@aztec/aztec-node'; -import { CircuitsWasm, KERNEL_NEW_COMMITMENTS_LENGTH, PrivateHistoricTreeRoots } from '@aztec/circuits.js'; +import { CircuitsWasm, MAX_NEW_COMMITMENTS_PER_TX, PrivateHistoricTreeRoots } from '@aztec/circuits.js'; import { ContractAbi, FunctionType } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -326,7 +326,7 @@ export class AccountState { // TODO(Maddiaa): this calculation is brittle. // https://github.com/AztecProtocol/aztec-packages/issues/788 let dataStartIndex = - (l2BlockContexts[0].block.number - INITIAL_L2_BLOCK_NUM) * this.TXS_PER_BLOCK * KERNEL_NEW_COMMITMENTS_LENGTH; + (l2BlockContexts[0].block.number - INITIAL_L2_BLOCK_NUM) * this.TXS_PER_BLOCK * MAX_NEW_COMMITMENTS_PER_TX; const blocksAndNoteSpendingInfo: ProcessedData[] = []; // Iterate over both blocks and encrypted logs. diff --git a/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts b/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts index 2e8d4b5bd8f8..400e2e7a872f 100644 --- a/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts +++ b/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts @@ -1,6 +1,6 @@ import { ExecutionResult, NewNoteData } from '@aztec/acir-simulator'; import { - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KernelCircuitPublicInputs, MembershipWitness, PRIVATE_CALL_STACK_LENGTH, @@ -64,7 +64,7 @@ describe('Kernel Prover', () => { const publicInputs = KernelCircuitPublicInputs.empty(); const commitments = newNoteIndices.map(idx => generateFakeSiloedCommitment(notes[idx])); // TODO(AD) FIXME(AD) This cast is bad. Why is this not the correct length when this is called? - publicInputs.end.newCommitments = commitments as Tuple; + publicInputs.end.newCommitments = commitments as Tuple; return { publicInputs, proof: makeEmptyProof(), diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 5c3a7abce4fc..175a7a8a6496 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -6,14 +6,14 @@ export const RETURN_VALUES_LENGTH = 4; export const READ_REQUESTS_LENGTH = 4; -export const NEW_COMMITMENTS_LENGTH = 4; +export const MAX_NEW_COMMITMENTS_PER_CALL = 4; export const NEW_NULLIFIERS_LENGTH = 4; export const NEW_L2_TO_L1_MSGS_LENGTH = 2; export const PRIVATE_CALL_STACK_LENGTH = 4; export const PUBLIC_CALL_STACK_LENGTH = 4; -export const KERNEL_NEW_COMMITMENTS_LENGTH = 16; // PRIVATE_CALL_STACK_LENGTH * NEW_COMMITMENTS_LENGTH +export const MAX_NEW_COMMITMENTS_PER_TX = 16; // PRIVATE_CALL_STACK_LENGTH * MAX_NEW_COMMITMENTS_PER_CALL export const KERNEL_NEW_NULLIFIERS_LENGTH = 16; // PRIVATE_CALL_STACK_LENGTH * NEW_NULLIFIERS_LENGTH export const KERNEL_NEW_CONTRACTS_LENGTH = 1; export const KERNEL_PRIVATE_CALL_STACK_LENGTH = 8; 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 846a41f42be4..4f2260d6ba0c 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 @@ -2,7 +2,7 @@ import { serializeToBuffer } from '../../utils/serialize.js'; import { AggregationObject } from '../aggregation_object.js'; import { KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, @@ -278,7 +278,7 @@ export class CombinedAccumulatedData { /** * The number of new commitments made in this transaction. */ - public newCommitments: Tuple, + public newCommitments: Tuple, /** * The number of new nullifiers made in this transaction. */ @@ -330,7 +330,7 @@ export class CombinedAccumulatedData { */ public publicDataReads: Tuple, ) { - assertMemberLength(this, 'newCommitments', KERNEL_NEW_COMMITMENTS_LENGTH); + assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); assertMemberLength(this, 'newNullifiers', KERNEL_NEW_NULLIFIERS_LENGTH); assertMemberLength(this, 'privateCallStack', KERNEL_PRIVATE_CALL_STACK_LENGTH); assertMemberLength(this, 'publicCallStack', KERNEL_PUBLIC_CALL_STACK_LENGTH); @@ -375,7 +375,7 @@ export class CombinedAccumulatedData { const reader = BufferReader.asReader(buffer); return new CombinedAccumulatedData( reader.readObject(AggregationObject), - reader.readArray(KERNEL_NEW_COMMITMENTS_LENGTH, Fr), + reader.readArray(MAX_NEW_COMMITMENTS_PER_TX, Fr), reader.readArray(KERNEL_NEW_NULLIFIERS_LENGTH, Fr), reader.readArray(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr), reader.readArray(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr), @@ -403,7 +403,7 @@ export class CombinedAccumulatedData { static empty() { return new CombinedAccumulatedData( AggregationObject.makeFake(), - makeTuple(KERNEL_NEW_COMMITMENTS_LENGTH, Fr.zero), + makeTuple(MAX_NEW_COMMITMENTS_PER_TX, Fr.zero), makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, Fr.zero), makeTuple(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index 6d7f8b51aaaf..e415b015c56d 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -3,7 +3,7 @@ import { assertMemberLength, FieldsOf } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { - NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, NEW_NULLIFIERS_LENGTH, NUM_FIELDS_PER_SHA256, @@ -107,7 +107,7 @@ export class PrivateCircuitPublicInputs { ) { assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); assertMemberLength(this, 'readRequests', READ_REQUESTS_LENGTH); - assertMemberLength(this, 'newCommitments', NEW_COMMITMENTS_LENGTH); + assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', NEW_NULLIFIERS_LENGTH); assertMemberLength(this, 'privateCallStack', PRIVATE_CALL_STACK_LENGTH); assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); @@ -138,7 +138,7 @@ export class PrivateCircuitPublicInputs { Fr.ZERO, frArray(RETURN_VALUES_LENGTH), frArray(READ_REQUESTS_LENGTH), - frArray(NEW_COMMITMENTS_LENGTH), + frArray(MAX_NEW_COMMITMENTS_PER_CALL), frArray(NEW_NULLIFIERS_LENGTH), frArray(PRIVATE_CALL_STACK_LENGTH), frArray(PUBLIC_CALL_STACK_LENGTH), diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 73506efa334e..60baed612a41 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -8,7 +8,7 @@ import { CallContext } from './call_context.js'; import { KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, - NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, NEW_NULLIFIERS_LENGTH, NUM_FIELDS_PER_SHA256, @@ -165,7 +165,7 @@ export class PublicCircuitPublicInputs { /** * New commitments created within a public execution call */ - public newCommitments: Tuple, + public newCommitments: Tuple, /** * New nullifiers created within a public execution call */ @@ -194,7 +194,7 @@ export class PublicCircuitPublicInputs { ) { assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); - assertMemberLength(this, 'newCommitments', NEW_COMMITMENTS_LENGTH); + assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', NEW_NULLIFIERS_LENGTH); assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'contractStorageUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); @@ -223,7 +223,7 @@ export class PublicCircuitPublicInputs { makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, ContractStorageUpdateRequest.empty), makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, ContractStorageRead.empty), makeTuple(PUBLIC_CALL_STACK_LENGTH, Fr.zero), - makeTuple(NEW_COMMITMENTS_LENGTH, Fr.zero), + makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), makeTuple(NEW_NULLIFIERS_LENGTH, Fr.zero), makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), makeTuple(2, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 15a520ce0eb5..0e9cac36d579 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -5,7 +5,7 @@ import { serializeToBuffer } from '../../utils/serialize.js'; import { CONTRACT_TREE_HEIGHT, CONTRACT_TREE_ROOTS_TREE_HEIGHT, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, KERNEL_PUBLIC_DATA_READS_LENGTH, @@ -135,7 +135,7 @@ export class BaseRollupInputs { * Height of the private data subtree which is to be inserted into the private data tree. * Note: There are notes from 2 kernels being processed here so kernel new commitments length is multiplied by 2. */ - public static PRIVATE_DATA_SUBTREE_HEIGHT = Math.log2(KERNEL_NEW_COMMITMENTS_LENGTH * 2); + public static PRIVATE_DATA_SUBTREE_HEIGHT = Math.log2(MAX_NEW_COMMITMENTS_PER_TX * 2); /** * Height of the contract subtree which is to be inserted into the contract tree. */ diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 0365f75cc24d..5532491958a7 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -26,7 +26,7 @@ import { Fr, FunctionData, G1AffineElement, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, @@ -40,7 +40,7 @@ import { L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH, MembershipWitness, MergeRollupInputs, - NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, NEW_NULLIFIERS_LENGTH, NULLIFIER_TREE_HEIGHT, @@ -201,7 +201,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu return new CombinedAccumulatedData( makeAggregationObject(seed), - tupleGenerator(KERNEL_NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), + tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), // private call stack must be empty tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), @@ -227,7 +227,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated return new CombinedAccumulatedData( makeAggregationObject(seed), - tupleGenerator(KERNEL_NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), + tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x300), tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), @@ -314,7 +314,7 @@ export function makePublicCircuitPublicInputs( tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeContractStorageUpdateRequest, seed + 0x400), tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeContractStorageRead, seed + 0x500), tupleGenerator(PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x600), - tupleGenerator(NEW_COMMITMENTS_LENGTH, fr, seed + 0x700), + tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), tupleGenerator(NEW_NULLIFIERS_LENGTH, fr, seed + 0x800), tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x900), tupleGenerator(2, fr, seed + 0x901), @@ -610,7 +610,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn argsHash: fr(seed + 0x100), returnValues: makeTuple(RETURN_VALUES_LENGTH, fr, seed + 0x200), readRequests: makeTuple(READ_REQUESTS_LENGTH, fr, seed + 0x300), - newCommitments: makeTuple(NEW_COMMITMENTS_LENGTH, fr, seed + 0x400), + newCommitments: makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x400), newNullifiers: makeTuple(NEW_NULLIFIERS_LENGTH, fr, seed + 0x500), privateCallStack: makeTuple(PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x600), publicCallStack: makeTuple(PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x700), 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 bf5ee0025c49..4006d117c56c 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 @@ -2,7 +2,7 @@ import { createMemDown, getConfigEnvVars } from '@aztec/aztec-node'; import { AztecAddress, GlobalVariables, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -171,7 +171,7 @@ describe('L1Publisher integration', () => { const processedTx = await makeProcessedTx(tx, kernelOutput, makeProof()); - processedTx.data.end.newCommitments = makeTuple(KERNEL_NEW_COMMITMENTS_LENGTH, fr, seed + 0x100); + processedTx.data.end.newCommitments = makeTuple(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100); processedTx.data.end.newNullifiers = makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200); processedTx.data.end.newNullifiers[processedTx.data.end.newNullifiers.length - 1] = Fr.ZERO; processedTx.data.end.newL2ToL1Msgs = makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x300); diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index 206dc58090ad..c32ae9c1d01a 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -5,7 +5,7 @@ import { CircuitsWasm, Fr, GlobalVariables, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, KERNEL_PUBLIC_CALL_STACK_LENGTH, @@ -299,7 +299,7 @@ describe('sequencer/solo_block_builder', () => { const processedTx = await makeProcessedTx(tx, kernelOutput, makeProof()); - processedTx.data.end.newCommitments = makeTuple(KERNEL_NEW_COMMITMENTS_LENGTH, fr, seed + 0x100); + processedTx.data.end.newCommitments = makeTuple(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100); processedTx.data.end.newNullifiers = makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200); processedTx.data.end.newNullifiers[tx.data.end.newNullifiers.length - 1] = Fr.ZERO; processedTx.data.end.newL2ToL1Msgs = makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x300); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index 80edc504c16e..d0342ff44303 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -10,7 +10,7 @@ import { KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, KernelCircuitPublicInputs, MembershipWitness, - NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, NEW_NULLIFIERS_LENGTH, PUBLIC_CALL_STACK_LENGTH, @@ -210,7 +210,7 @@ export class PublicProcessor { callContext: result.execution.callContext, proverAddress: AztecAddress.random(), argsHash: await computeVarArgsHash(wasm, result.execution.args), - newCommitments: padArrayEnd(result.newCommitments, Fr.ZERO, NEW_COMMITMENTS_LENGTH), + newCommitments: padArrayEnd(result.newCommitments, Fr.ZERO, MAX_NEW_COMMITMENTS_PER_CALL), newNullifiers: padArrayEnd(result.newNullifiers, Fr.ZERO, NEW_NULLIFIERS_LENGTH), newL2ToL1Msgs: padArrayEnd(result.newL2ToL1Messages, Fr.ZERO, NEW_L2_TO_L1_MSGS_LENGTH), returnValues: padArrayEnd(result.returnValues, Fr.ZERO, RETURN_VALUES_LENGTH), diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index 00f4589ec0c8..06d4fff08892 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -1,6 +1,6 @@ import { AppendOnlyTreeSnapshot, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -146,8 +146,8 @@ export class L2Block { newEncryptedLogs?: L2BlockL2Logs, newUnencryptedLogs?: L2BlockL2Logs, ) { - if (newCommitments.length % KERNEL_NEW_COMMITMENTS_LENGTH !== 0) { - throw new Error(`The number of new commitments must be a multiple of ${KERNEL_NEW_COMMITMENTS_LENGTH}.`); + if (newCommitments.length % MAX_NEW_COMMITMENTS_PER_TX !== 0) { + throw new Error(`The number of new commitments must be a multiple of ${MAX_NEW_COMMITMENTS_PER_TX}.`); } if (newEncryptedLogs) { @@ -177,7 +177,7 @@ export class L2Block { numUnencryptedLogs = 1, ): L2Block { const newNullifiers = times(KERNEL_NEW_NULLIFIERS_LENGTH * txsPerBlock, Fr.random); - const newCommitments = times(KERNEL_NEW_COMMITMENTS_LENGTH * txsPerBlock, Fr.random); + const newCommitments = times(MAX_NEW_COMMITMENTS_PER_TX * txsPerBlock, Fr.random); const newContracts = times(KERNEL_NEW_CONTRACTS_LENGTH * txsPerBlock, Fr.random); const newContractData = times(KERNEL_NEW_CONTRACTS_LENGTH * txsPerBlock, ContractData.random); const newPublicDataWrites = times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * txsPerBlock, PublicDataWrite.random); @@ -493,7 +493,7 @@ export class L2Block { throw new Error(`L2 block already has ${logType} attached.`); } - const numTxs = this.newCommitments.length / KERNEL_NEW_COMMITMENTS_LENGTH; + const numTxs = this.newCommitments.length / MAX_NEW_COMMITMENTS_PER_TX; if (numTxs !== logs.txLogs.length) { throw new Error( @@ -611,11 +611,11 @@ export class L2Block { return layers[layers.length - 1][0]; }; - const leafCount = this.newCommitments.length / (KERNEL_NEW_COMMITMENTS_LENGTH * 2); + const leafCount = this.newCommitments.length / (MAX_NEW_COMMITMENTS_PER_TX * 2); const leafs: Buffer[] = []; for (let i = 0; i < leafCount; i++) { - const commitmentsPerBase = KERNEL_NEW_COMMITMENTS_LENGTH * 2; + const commitmentsPerBase = MAX_NEW_COMMITMENTS_PER_TX * 2; const nullifiersPerBase = KERNEL_NEW_NULLIFIERS_LENGTH * 2; const publicDataUpdateRequestsPerBase = KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2; const l2ToL1MsgsPerBase = KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * 2; @@ -677,14 +677,14 @@ export class L2Block { * @returns The tx. */ getTx(txIndex: number) { - const numTxs = Math.floor(this.newCommitments.length / KERNEL_NEW_COMMITMENTS_LENGTH); + const numTxs = Math.floor(this.newCommitments.length / MAX_NEW_COMMITMENTS_PER_TX); if (txIndex >= numTxs) { throw new Error(`Failed to get tx ${txIndex}. Block ${this.globalVariables.blockNumber} only has ${numTxs} txs.`); } const newCommitments = this.newCommitments.slice( - KERNEL_NEW_COMMITMENTS_LENGTH * txIndex, - KERNEL_NEW_COMMITMENTS_LENGTH * (txIndex + 1), + MAX_NEW_COMMITMENTS_PER_TX * txIndex, + MAX_NEW_COMMITMENTS_PER_TX * (txIndex + 1), ); const newNullifiers = this.newNullifiers.slice( KERNEL_NEW_NULLIFIERS_LENGTH * txIndex, diff --git a/yarn-project/types/src/l2_block_context.ts b/yarn-project/types/src/l2_block_context.ts index 2d88244aab82..13753513d110 100644 --- a/yarn-project/types/src/l2_block_context.ts +++ b/yarn-project/types/src/l2_block_context.ts @@ -1,4 +1,4 @@ -import { KERNEL_NEW_COMMITMENTS_LENGTH } from '@aztec/circuits.js'; +import { MAX_NEW_COMMITMENTS_PER_TX } from '@aztec/circuits.js'; import { L2Block } from './l2_block.js'; import { TxHash } from './tx_hash.js'; @@ -17,7 +17,7 @@ export class L2BlockContext { */ public readonly block: L2Block, ) { - this.txHashes = new Array(Math.floor(block.newCommitments.length / KERNEL_NEW_COMMITMENTS_LENGTH)); + this.txHashes = new Array(Math.floor(block.newCommitments.length / MAX_NEW_COMMITMENTS_PER_TX)); } /** diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts index cd2a01168da4..d4efbf9d1d51 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts @@ -2,7 +2,7 @@ import { AppendOnlyTreeSnapshot, CircuitsWasm, GlobalVariables, - KERNEL_NEW_COMMITMENTS_LENGTH, + MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, KERNEL_NEW_NULLIFIERS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -78,7 +78,7 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = endPublicDataTreeRoot: Fr.random(), endL1ToL2MessageTreeSnapshot: getMockTreeSnapshot(), endTreeOfHistoricL1ToL2MessageTreeRootsSnapshot: getMockTreeSnapshot(), - newCommitments: times(KERNEL_NEW_COMMITMENTS_LENGTH, Fr.random), + newCommitments: times(MAX_NEW_COMMITMENTS_PER_TX, Fr.random), newNullifiers: times(KERNEL_NEW_NULLIFIERS_LENGTH, Fr.random), newContracts: newContractsCommitments?.map(x => Fr.fromBuffer(x)) ?? [Fr.random()], newContractData: times(KERNEL_NEW_CONTRACTS_LENGTH, getMockContractData), From fd92f4bdac2e50e5f388a7648c67260e9fb84098 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 09:51:51 +0000 Subject: [PATCH 02/14] 972 - rename nullifiers related constants --- .../abis/combined_accumulated_data.hpp | 2 +- .../abis/private_circuit_public_inputs.hpp | 6 +-- .../abis/public_circuit_public_inputs.hpp | 2 +- .../abis/rollup/base/base_rollup_inputs.hpp | 4 +- .../aztec3/circuits/kernel/private/common.cpp | 2 +- .../kernel/private/private_kernel_circuit.cpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 23 ++++---- .../aztec3/circuits/kernel/public/common.hpp | 2 +- .../src/aztec3/circuits/rollup/base/.test.cpp | 52 +++++++++---------- .../base/native_base_rollup_circuit.cpp | 8 +-- .../circuits/rollup/components/components.cpp | 10 ++-- .../circuits/rollup/test_utils/utils.cpp | 36 ++++++------- .../circuits/rollup/test_utils/utils.hpp | 4 +- circuits/cpp/src/aztec3/constants.hpp | 6 +-- .../acir-simulator/src/acvm/deserialize.ts | 4 +- .../circuits.js/src/structs/constants.ts | 4 +- .../kernel/combined_accumulated_data.ts | 10 ++-- .../structs/private_circuit_public_inputs.ts | 6 +-- .../structs/public_circuit_public_inputs.ts | 8 +-- .../src/structs/rollup/base_rollup.ts | 8 +-- .../circuits.js/src/tests/factories.ts | 16 +++--- .../src/integration_l1_publisher.test.ts | 4 +- .../block_builder/solo_block_builder.test.ts | 6 +-- .../src/sequencer/public_processor.ts | 4 +- yarn-project/types/src/l2_block.ts | 10 ++-- .../server_world_state_synchroniser.test.ts | 4 +- .../world-state/src/world-state-db/index.ts | 4 +- 27 files changed, 124 insertions(+), 123 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index 94c124ae98d9..c8d987787235 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -26,7 +26,7 @@ template struct CombinedAccumulatedData { AggregationObject aggregation_object{}; std::array new_commitments{}; - std::array new_nullifiers{}; + std::array new_nullifiers{}; std::array private_call_stack{}; std::array public_call_stack{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index f3fd4fd62b38..05b1576c8149 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -30,7 +30,7 @@ template class PrivateCircuitPublicInputs { std::array read_requests{}; std::array new_commitments{}; - std::array new_nullifiers{}; + std::array new_nullifiers{}; std::array private_call_stack{}; std::array public_call_stack{}; @@ -304,7 +304,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array read_requests; std::array new_commitments; - std::array new_nullifiers; + std::array new_nullifiers; std::array private_call_stack; std::array public_call_stack; @@ -336,7 +336,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array const& read_requests, std::array const& new_commitments, - std::array const& new_nullifiers, + std::array const& new_nullifiers, std::array const& private_call_stack, std::array const& public_call_stack, diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index e817582e4a54..9c6eed798a4e 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -32,7 +32,7 @@ template struct PublicCircuitPublicInputs { std::array public_call_stack{}; std::array new_commitments{}; - std::array new_nullifiers{}; + std::array new_nullifiers{}; std::array new_l2_to_l1_msgs{}; std::array unencrypted_logs_hash{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp index e0740f761a9a..3278ed125134 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp @@ -21,8 +21,8 @@ template struct BaseRollupInputs { AppendOnlyTreeSnapshot start_contract_tree_snapshot; fr start_public_data_tree_root; - std::array, 2 * KERNEL_NEW_NULLIFIERS_LENGTH> low_nullifier_leaf_preimages; - std::array, 2 * KERNEL_NEW_NULLIFIERS_LENGTH> + std::array, 2 * MAX_NEW_NULLIFIERS_PER_TX> low_nullifier_leaf_preimages; + std::array, 2 * MAX_NEW_NULLIFIERS_PER_TX> low_nullifier_membership_witness; // For inserting the new subtrees into their respective trees: diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 6b314b4b703c..f51355c1df5b 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -147,7 +147,7 @@ void common_update_end_values(DummyBuilder& builder, new_commitments[i] == 0 ? 0 : silo_commitment(storage_contract_address, new_commitments[i]); } - std::array siloed_new_nullifiers{}; + std::array siloed_new_nullifiers{}; for (size_t i = 0; i < new_nullifiers.size(); ++i) { siloed_new_nullifiers[i] = new_nullifiers[i] == 0 ? 0 : silo_nullifier(storage_contract_address, new_nullifiers[i]); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp index 0d99193fd28e..fb864602187e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp @@ -154,7 +154,7 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne siloed_new_commitments[i] = CT::fr::conditional_assign( new_commitments[i] == 0, 0, silo_commitment(storage_contract_address, new_commitments[i])); } - std::array siloed_new_nullifiers; + std::array siloed_new_nullifiers; for (size_t i = 0; i < new_nullifiers.size(); ++i) { siloed_new_nullifiers[i] = CT::fr::conditional_assign( new_nullifiers[i] == 0, 0, silo_nullifier(storage_contract_address, new_nullifiers[i])); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 62da0b6929d0..cd7823290043 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -127,7 +127,8 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, array_of_values(count); std::array const new_commitments = array_of_values(count); - std::array const new_nullifiers = array_of_values(count); + std::array const new_nullifiers = + array_of_values(count); std::array const new_l2_to_l1_msgs = array_of_values(count); std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const reads = @@ -219,11 +220,11 @@ std::array new_commitments_as_siloed_commitmen return siloed_commitments; } -std::array new_nullifiers_as_siloed_nullifiers( - std::array const& new_nullifiers, NT::fr const& contract_address) +std::array new_nullifiers_as_siloed_nullifiers( + std::array const& new_nullifiers, NT::fr const& contract_address) { - std::array siloed_nullifiers{}; - for (size_t i = 0; i < NEW_NULLIFIERS_LENGTH; ++i) { + std::array siloed_nullifiers{}; + for (size_t i = 0; i < MAX_NEW_NULLIFIERS_PER_CALL; ++i) { if (!new_nullifiers[i].is_zero()) { siloed_nullifiers[i] = silo_nullifier(contract_address, new_nullifiers[i]); } @@ -320,8 +321,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat generate_contract_storage_reads(seed, KERNEL_PUBLIC_DATA_READS_LENGTH / 2); std::array const new_commitments = array_of_values(seed, MAX_NEW_COMMITMENTS_PER_CALL / 2); - std::array const new_nullifiers = - array_of_values(seed, NEW_NULLIFIERS_LENGTH / 2); + std::array const new_nullifiers = + array_of_values(seed, MAX_NEW_NULLIFIERS_PER_CALL / 2); std::array const new_l2_to_l1_msgs = array_of_values(seed, NEW_L2_TO_L1_MSGS_LENGTH / 2); std::array const unencrypted_logs_hash = @@ -390,8 +391,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat CombinedAccumulatedData const end_accumulated_data = { .new_commitments = array_of_values(seed, private_previous ? MAX_NEW_COMMITMENTS_PER_TX / 2 : 0), - .new_nullifiers = array_of_values( - seed, private_previous ? KERNEL_NEW_NULLIFIERS_LENGTH / 2 : 0), + .new_nullifiers = + array_of_values(seed, private_previous ? MAX_NEW_NULLIFIERS_PER_TX / 2 : 0), .private_call_stack = array_of_values(seed, 0), .public_call_stack = public_call_stack, .new_l2_to_l1_msgs = array_of_values( @@ -1023,7 +1024,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre inputs.previous_kernel.public_inputs.end.new_commitments = initial_commitments; // setup 2 previous new nullifiers - std::array initial_nullifiers{}; + std::array initial_nullifiers{}; initial_nullifiers[0] = fr(12345); initial_nullifiers[1] = fr(67890); inputs.previous_kernel.public_inputs.end.new_nullifiers = initial_nullifiers; @@ -1106,7 +1107,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre expected_new_commitments, public_inputs.end.new_commitments)); - std::array const expected_new_nullifiers = new_nullifiers_as_siloed_nullifiers( + std::array const expected_new_nullifiers = new_nullifiers_as_siloed_nullifiers( inputs.public_call.call_stack_item.public_inputs.new_nullifiers, contract_address); ASSERT_TRUE(source_arrays_are_in_target(inputs.previous_kernel.public_inputs.end.new_nullifiers, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index 5a9448ea44bd..99b886ebe760 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -316,7 +316,7 @@ void propagate_new_nullifiers(Builder& builder, const auto& new_nullifiers = public_call_public_inputs.new_nullifiers; const auto& storage_contract_address = public_call_public_inputs.call_context.storage_contract_address; - std::array siloed_new_nullifiers{}; + std::array siloed_new_nullifiers{}; for (size_t i = 0; i < new_nullifiers.size(); ++i) { if (!new_nullifiers[i].is_zero()) { siloed_new_nullifiers[i] = silo_nullifier(storage_contract_address, new_nullifiers[i]); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 6dcce2962af1..2a017ac3548b 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -312,8 +312,8 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_empty) // This is because 0 values are not actually inserted into the tree, rather the inserted subtree is left // empty to begin with. - std::array const new_nullifiers{}; - std::vector initial_values(2 * KERNEL_NEW_NULLIFIERS_LENGTH - 1); + std::array const new_nullifiers{}; + std::vector initial_values(2 * MAX_NEW_NULLIFIERS_PER_TX - 1); for (size_t i = 0; i < initial_values.size(); i++) { initial_values[i] = i + 1; @@ -346,16 +346,16 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_empty) ASSERT_EQ(outputs.end_nullifier_tree_snapshot, end_nullifier_tree_snapshot); ASSERT_EQ(outputs.end_nullifier_tree_snapshot.root, outputs.start_nullifier_tree_snapshot.root); ASSERT_EQ(outputs.end_nullifier_tree_snapshot.next_available_leaf_index, - outputs.start_nullifier_tree_snapshot.next_available_leaf_index + 2 * KERNEL_NEW_NULLIFIERS_LENGTH); + outputs.start_nullifier_tree_snapshot.next_available_leaf_index + 2 * MAX_NEW_NULLIFIERS_PER_TX); ASSERT_FALSE(builder.failed()) << builder.failure_msgs; } -void nullifier_insertion_test(std::array new_nullifiers) +void nullifier_insertion_test(std::array new_nullifiers) { // @todo We can probably reuse this more than we are already doing. // Regression test caught when testing the typescript nullifier tree implementation - std::vector initial_values(2 * KERNEL_NEW_NULLIFIERS_LENGTH - 1); + std::vector initial_values(2 * MAX_NEW_NULLIFIERS_PER_TX - 1); for (size_t i = 0; i < initial_values.size(); i++) { initial_values[i] = i + 1; } @@ -370,9 +370,9 @@ void nullifier_insertion_test(std::array n DummyBuilder builder = DummyBuilder("base_rollup_tests__nullifier_insertion_test"); std::array, 2> kernel_data = { get_empty_kernel(), get_empty_kernel() }; for (uint8_t i = 0; i < 2; i++) { - std::array kernel_nullifiers; - for (uint8_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { - kernel_nullifiers[j] = new_nullifiers[i * KERNEL_NEW_NULLIFIERS_LENGTH + j]; + std::array kernel_nullifiers; + for (uint8_t j = 0; j < MAX_NEW_NULLIFIERS_PER_TX; j++) { + kernel_nullifiers[j] = new_nullifiers[i * MAX_NEW_NULLIFIERS_PER_TX + j]; } kernel_data[i].public_inputs.end.new_nullifiers = kernel_nullifiers; } @@ -386,16 +386,16 @@ void nullifier_insertion_test(std::array n ASSERT_EQ(outputs.start_nullifier_tree_snapshot, start_nullifier_tree_snapshot); ASSERT_EQ(outputs.end_nullifier_tree_snapshot, end_nullifier_tree_snapshot); ASSERT_EQ(outputs.end_nullifier_tree_snapshot.next_available_leaf_index, - outputs.start_nullifier_tree_snapshot.next_available_leaf_index + KERNEL_NEW_NULLIFIERS_LENGTH * 2); + outputs.start_nullifier_tree_snapshot.next_available_leaf_index + MAX_NEW_NULLIFIERS_PER_TX * 2); ASSERT_FALSE(builder.failed()) << builder.failure_msgs; } TEST_F(base_rollup_tests, native_new_nullifier_tree_all_larger) { - std::array initial_values; + std::array initial_values; for (size_t i = 0; i < initial_values.size(); i++) { - initial_values[i] = 2 * KERNEL_NEW_NULLIFIERS_LENGTH + i; + initial_values[i] = 2 * MAX_NEW_NULLIFIERS_PER_TX + i; } nullifier_insertion_test(initial_values); @@ -403,23 +403,23 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_all_larger) TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse_insertions) { - std::array initial_values; + std::array initial_values; for (size_t i = 0; i < initial_values.size(); i++) { - initial_values[i] = 2 * KERNEL_NEW_NULLIFIERS_LENGTH + 5 * i + 1; + initial_values[i] = 2 * MAX_NEW_NULLIFIERS_PER_TX + 5 * i + 1; } nullifier_insertion_test(initial_values); } TEST_F(base_rollup_tests, native_new_nullifier_tree_sparse) { - std::array nullifiers; + std::array nullifiers; for (size_t i = 0; i < nullifiers.size(); i++) { - nullifiers[i] = 2 * KERNEL_NEW_NULLIFIERS_LENGTH + 5 * i + 1; + nullifiers[i] = 2 * MAX_NEW_NULLIFIERS_PER_TX + 5 * i + 1; } - std::vector initial_values(2 * KERNEL_NEW_NULLIFIERS_LENGTH - 1); + std::vector initial_values(2 * MAX_NEW_NULLIFIERS_PER_TX - 1); for (size_t i = 0; i < initial_values.size(); i++) { initial_values[i] = 5 * (i + 1); @@ -468,15 +468,15 @@ TEST_F(base_rollup_tests, native_nullifier_tree_regression) // KERNEL_NEW_NULLILFIERS_LENGTH -1 more) simulating that a rollup inserting two random values has already // succeeded. Note that this corresponds to 3 (1 already initialized and 2 new ones) base rollups. This rollup then // adds two further random values that will end up having their low nullifiers point at each other - std::vector initial_values(6 * KERNEL_NEW_NULLIFIERS_LENGTH - 1, 0); - for (size_t i = 0; i < 2 * KERNEL_NEW_NULLIFIERS_LENGTH - 1; i++) { + std::vector initial_values(6 * MAX_NEW_NULLIFIERS_PER_TX - 1, 0); + for (size_t i = 0; i < 2 * MAX_NEW_NULLIFIERS_PER_TX - 1; i++) { initial_values[i] = i + 1; } // Note these are hex representations initial_values[7] = uint256_t("2bb9aa4a22a6ae7204f2c67abaab59cead6558cde4ee25ce3464704cb2e38136"); initial_values[8] = uint256_t("16a732095298ccca828c4d747813f8bd46e188079ed17904e2c9de50760833c8"); - std::array new_nullifiers = { 0 }; + std::array new_nullifiers = { 0 }; new_nullifiers[0] = uint256_t("16da4f27fb78de7e0db4c5a04b569bc46382c5f471da2f7d670beff1614e0118"), new_nullifiers[1] = uint256_t("26ab07ce103a55e29f11478eaa36cebd10c4834b143a7debcc7ef53bfdb547dd"); @@ -514,7 +514,7 @@ TEST_F(base_rollup_tests, native_nullifier_tree_regression) TEST_F(base_rollup_tests, nullifier_tree_regression_2) { // Regression test caught when testing the typescript nullifier tree implementation - std::array new_nullifiers = { 0 }; + std::array new_nullifiers = { 0 }; new_nullifiers[0] = uint256_t("2a7d956c1365d259646d2d85babe1abb793bb8789e98df7e2336a29a0c91fd01"); new_nullifiers[1] = uint256_t("236bf2d113f9ffee89df1a7a04890c9ad3583c6773eb9cdec484184f66abd4c6"); new_nullifiers[4] = uint256_t("2f5c8a1ee33c7104b244e22a3e481637cd501c9eae868cfab6b16e3b4ef3d635"); @@ -525,7 +525,7 @@ TEST_F(base_rollup_tests, nullifier_tree_regression_2) TEST_F(base_rollup_tests, nullifier_tree_regression_3) { - std::array new_nullifiers = { 0 }; + std::array new_nullifiers = { 0 }; new_nullifiers[0] = uint256_t("0740a17aa6437e71836d2adcdcb3f52879bb869cdd9c8fb8dc39a12846cd17f2"); new_nullifiers[1] = uint256_t("282e0e2f38310a7c7c98b636830b66f3276294560e26ef2499da10892f00af8f"); new_nullifiers[4] = uint256_t("0f117936e888bd3befb4435f4d65300d25609e95a3d1563f62ef7e58c294f578"); @@ -544,8 +544,8 @@ TEST_F(base_rollup_tests, native_new_nullifier_tree_double_spend) BaseRollupInputs const empty_inputs = base_rollup_inputs_from_kernels({ get_empty_kernel(), get_empty_kernel() }); fr const nullifier_to_insert = - 2 * KERNEL_NEW_NULLIFIERS_LENGTH + 4; // arbitrary value greater than 2 * KERNEL_NEW_NULLIFIERS_LENGTH - std::array new_nullifiers{}; + 2 * MAX_NEW_NULLIFIERS_PER_TX + 4; // arbitrary value greater than 2 * MAX_NEW_NULLIFIERS_PER_TX + std::array new_nullifiers{}; new_nullifiers[0] = nullifier_to_insert; new_nullifiers[2] = nullifier_to_insert; @@ -586,9 +586,9 @@ TEST_F(base_rollup_tests, native_calldata_hash) // Commitments inserted are [1,2,3,4,5,6,7,8 ...]. Nullifiers inserted are [8,9,10,11,12,13,14,15 ...] for (size_t i = 0; i < 2; ++i) { - for (size_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { - kernel_data[i].public_inputs.end.new_commitments[j] = fr(i * KERNEL_NEW_NULLIFIERS_LENGTH + j + 1); - kernel_data[i].public_inputs.end.new_nullifiers[j] = fr((2 + i) * KERNEL_NEW_NULLIFIERS_LENGTH + j); + for (size_t j = 0; j < MAX_NEW_NULLIFIERS_PER_TX; j++) { + kernel_data[i].public_inputs.end.new_commitments[j] = fr(i * MAX_NEW_NULLIFIERS_PER_TX + j + 1); + kernel_data[i].public_inputs.end.new_nullifiers[j] = fr((2 + i) * MAX_NEW_NULLIFIERS_PER_TX + j); } } diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 879790092df2..55a7ee167ea2 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -188,7 +188,7 @@ void perform_historical_l1_to_l2_message_tree_membership_checks(DummyBuilder& bu } NT::fr create_nullifier_subtree( - std::array const& nullifier_leaves) + std::array const& nullifier_leaves) { // Build a merkle tree of the nullifiers MerkleTree nullifier_subtree = MerkleTree(NULLIFIER_SUBTREE_DEPTH); @@ -223,7 +223,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB // 2. If we receive the 0 nullifier leaf (where all values are 0, we skip insertion and leave a sparse subtree) // New nullifier subtree - std::array nullifier_insertion_subtree; + std::array nullifier_insertion_subtree; // This will update on each iteration auto current_nullifier_tree_root = baseRollupInputs.start_nullifier_tree_snapshot.root; @@ -236,9 +236,9 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB for (size_t i = 0; i < 2; i++) { auto new_nullifiers = baseRollupInputs.kernel_data[i].public_inputs.end.new_nullifiers; // For each of our nullifiers - for (size_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { + for (size_t j = 0; j < MAX_NEW_NULLIFIERS_PER_TX; j++) { // Witness containing index and path - auto nullifier_index = i * KERNEL_NEW_NULLIFIERS_LENGTH + j; + auto nullifier_index = i * MAX_NEW_NULLIFIERS_PER_TX + j; auto witness = baseRollupInputs.low_nullifier_membership_witness[nullifier_index]; // Preimage of the lo-index required for a non-membership proof diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index ac26a8dc77bf..2ff413a04463 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -104,14 +104,14 @@ std::array compute_kernels_calldata_hash( // Compute calldata hashes // Consist of 2 kernels // 2 * MAX_NEW_COMMITMENTS_PER_TX fields for commitments - // 2 * KERNEL_NEW_NULLIFIERS_LENGTH fields for nullifiers + // 2 * MAX_NEW_NULLIFIERS_PER_TX fields for nullifiers // 8 public data update requests (4 per kernel) -> 16 fields // 4 l2 -> l1 messages (2 per kernel) -> 4 fields // 2 contract deployments (1 per kernel) -> 6 fields // 2 encrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes // 2 unencrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes auto const number_of_inputs = - (MAX_NEW_COMMITMENTS_PER_TX + KERNEL_NEW_NULLIFIERS_LENGTH + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + + (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + KERNEL_NEW_CONTRACTS_LENGTH * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256) * @@ -133,10 +133,10 @@ std::array compute_kernels_calldata_hash( } offset += MAX_NEW_COMMITMENTS_PER_TX * 2; - for (size_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { - calldata_hash_inputs[offset + i * KERNEL_NEW_NULLIFIERS_LENGTH + j] = new_nullifiers[j]; + for (size_t j = 0; j < MAX_NEW_NULLIFIERS_PER_TX; j++) { + calldata_hash_inputs[offset + i * MAX_NEW_NULLIFIERS_PER_TX + j] = new_nullifiers[j]; } - offset += KERNEL_NEW_NULLIFIERS_LENGTH * 2; + offset += MAX_NEW_NULLIFIERS_PER_TX * 2; for (size_t j = 0; j < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; j++) { calldata_hash_inputs[offset + i * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + j * 2] = diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index fe480c2b47e6..594504f9ecd9 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -52,7 +52,7 @@ namespace aztec3::circuits::rollup::test_utils::utils { std::vector get_empty_calldata_leaf() { auto const number_of_inputs = - (MAX_NEW_COMMITMENTS_PER_TX + KERNEL_NEW_NULLIFIERS_LENGTH + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + + (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + KERNEL_NEW_CONTRACTS_LENGTH * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * 2) * 2; @@ -128,16 +128,16 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne }, .constants = constantRollupData }; - std::vector initial_values(2 * KERNEL_NEW_NULLIFIERS_LENGTH - 1); + std::vector initial_values(2 * MAX_NEW_NULLIFIERS_PER_TX - 1); for (size_t i = 0; i < initial_values.size(); i++) { initial_values[i] = i + 1; } - std::array nullifiers; + std::array nullifiers; for (size_t i = 0; i < 2; i++) { - for (size_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { - nullifiers[i * KERNEL_NEW_NULLIFIERS_LENGTH + j] = kernel_data[i].public_inputs.end.new_nullifiers[j]; + for (size_t j = 0; j < MAX_NEW_NULLIFIERS_PER_TX; j++) { + nullifiers[i * MAX_NEW_NULLIFIERS_PER_TX + j] = kernel_data[i].public_inputs.end.new_nullifiers[j]; } } @@ -254,12 +254,12 @@ std::array, 2> get_previous_rollup_data(DummyBuilder& bui // Build the trees based on inputs in base_rollup_input_1. MerkleTree private_data_tree = MerkleTree(PRIVATE_DATA_TREE_HEIGHT); MerkleTree contract_tree = MerkleTree(CONTRACT_TREE_HEIGHT); - std::vector initial_values(2 * KERNEL_NEW_NULLIFIERS_LENGTH - 1); + std::vector initial_values(2 * MAX_NEW_NULLIFIERS_PER_TX - 1); for (size_t i = 0; i < initial_values.size(); i++) { initial_values[i] = i + 1; } - std::array nullifiers; + std::array nullifiers; for (size_t i = 0; i < 2; i++) { for (size_t j = 0; j < MAX_NEW_COMMITMENTS_PER_TX; j++) { @@ -270,9 +270,9 @@ std::array, 2> get_previous_rollup_data(DummyBuilder& bui if (!contract_data.is_empty()) { contract_tree.update_element(i, contract_data.hash()); } - for (size_t j = 0; j < KERNEL_NEW_NULLIFIERS_LENGTH; j++) { + for (size_t j = 0; j < MAX_NEW_NULLIFIERS_PER_TX; j++) { initial_values.push_back(kernel_data[i].public_inputs.end.new_nullifiers[j]); - nullifiers[i * KERNEL_NEW_NULLIFIERS_LENGTH + j] = kernel_data[2 + i].public_inputs.end.new_nullifiers[j]; + nullifiers[i * MAX_NEW_NULLIFIERS_PER_TX + j] = kernel_data[2 + i].public_inputs.end.new_nullifiers[j]; } } @@ -392,7 +392,7 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values(BaseRollupI size_t starting_insertion_value = 0, size_t spacing = 5) { - const size_t NUMBER_OF_NULLIFIERS = KERNEL_NEW_NULLIFIERS_LENGTH * 2; + const size_t NUMBER_OF_NULLIFIERS = MAX_NEW_NULLIFIERS_PER_TX * 2; std::array nullifiers; for (size_t i = 0; i < NUMBER_OF_NULLIFIERS; ++i) { auto insertion_val = (starting_insertion_value + i * spacing); @@ -409,11 +409,11 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values(BaseRollupI } nullifier_tree_testing_values generate_nullifier_tree_testing_values( - BaseRollupInputs inputs, std::array new_nullifiers, size_t spacing = 5) + BaseRollupInputs inputs, std::array new_nullifiers, size_t spacing = 5) { // Generate initial values lin spaced std::vector initial_values; - for (size_t i = 1; i < 2 * KERNEL_NEW_NULLIFIERS_LENGTH; ++i) { + for (size_t i = 1; i < 2 * MAX_NEW_NULLIFIERS_PER_TX; ++i) { initial_values.emplace_back(i * spacing); } @@ -422,7 +422,7 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values( nullifier_tree_testing_values generate_nullifier_tree_testing_values_explicit( BaseRollupInputs rollupInputs, - std::array new_nullifiers, + std::array new_nullifiers, const std::vector& initial_values) { size_t const start_tree_size = initial_values.size() + 1; @@ -435,21 +435,21 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values_explicit( .next_available_leaf_index = static_cast(start_tree_size), }; - const size_t NUMBER_OF_NULLIFIERS = KERNEL_NEW_NULLIFIERS_LENGTH * 2; + const size_t NUMBER_OF_NULLIFIERS = MAX_NEW_NULLIFIERS_PER_TX * 2; std::array new_nullifier_leaves{}; // Calculate the predecessor nullifier pre-images // Get insertion values std::vector insertion_values; - std::array new_nullifiers_kernel_1{}; - std::array new_nullifiers_kernel_2{}; + std::array new_nullifiers_kernel_1{}; + std::array new_nullifiers_kernel_2{}; for (size_t i = 0; i < NUMBER_OF_NULLIFIERS; ++i) { auto insertion_val = new_nullifiers[i]; - if (i < KERNEL_NEW_NULLIFIERS_LENGTH) { + if (i < MAX_NEW_NULLIFIERS_PER_TX) { new_nullifiers_kernel_1[i] = insertion_val; } else { - new_nullifiers_kernel_2[i - KERNEL_NEW_NULLIFIERS_LENGTH] = insertion_val; + new_nullifiers_kernel_2[i - MAX_NEW_NULLIFIERS_PER_TX] = insertion_val; } insertion_values.push_back(insertion_val); reference_tree.update_element(insertion_val); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp index eff8c73caaf4..14fcd2461e5b 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.hpp @@ -71,7 +71,7 @@ abis::AppendOnlyTreeSnapshot get_snapshot_of_tree_state(NullifierMemoryTreeT nullifier_tree_testing_values generate_nullifier_tree_testing_values_explicit( BaseRollupInputs inputs, - std::array new_nullifiers, + std::array new_nullifiers, const std::vector& initial_values); nullifier_tree_testing_values generate_nullifier_tree_testing_values(BaseRollupInputs inputs, @@ -81,7 +81,7 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values(BaseRollupI std::array get_empty_l1_to_l2_messages(); nullifier_tree_testing_values generate_nullifier_tree_testing_values( - BaseRollupInputs inputs, std::array new_nullifiers, size_t spacing); + BaseRollupInputs inputs, std::array new_nullifiers, size_t spacing); NullifierMemoryTreeTestingHarness get_initial_nullifier_tree(const std::vector& initial_values); diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 82c202d07868..236cad1b5543 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -39,14 +39,14 @@ constexpr size_t READ_REQUESTS_LENGTH = 4; * */ constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 4; -constexpr size_t NEW_NULLIFIERS_LENGTH = 4; +constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4; constexpr size_t PRIVATE_CALL_STACK_LENGTH = 4; constexpr size_t PUBLIC_CALL_STACK_LENGTH = 4; constexpr size_t NEW_L2_TO_L1_MSGS_LENGTH = 2; constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = PRIVATE_CALL_STACK_LENGTH * MAX_NEW_COMMITMENTS_PER_CALL; -constexpr size_t KERNEL_NEW_NULLIFIERS_LENGTH = PRIVATE_CALL_STACK_LENGTH * NEW_NULLIFIERS_LENGTH; +constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = PRIVATE_CALL_STACK_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL; constexpr size_t KERNEL_NEW_CONTRACTS_LENGTH = 1; constexpr size_t KERNEL_PRIVATE_CALL_STACK_LENGTH = 8; constexpr size_t KERNEL_PUBLIC_CALL_STACK_LENGTH = 8; @@ -74,7 +74,7 @@ constexpr size_t PRIVATE_DATA_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_COMMITMENTS_PER_TX)); constexpr size_t PRIVATE_DATA_SUBTREE_INCLUSION_CHECK_DEPTH = PRIVATE_DATA_TREE_HEIGHT - PRIVATE_DATA_SUBTREE_DEPTH; -constexpr size_t NULLIFIER_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * KERNEL_NEW_NULLIFIERS_LENGTH)); +constexpr size_t NULLIFIER_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_NULLIFIERS_PER_TX)); constexpr size_t NULLIFIER_SUBTREE_INCLUSION_CHECK_DEPTH = NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_DEPTH; // NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP must equal 2^L1_TO_L2_MSG_SUBTREE_DEPTH for subtree insertions. diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index 03ca12ed7315..555c8622ee06 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -3,7 +3,7 @@ import { ContractDeploymentData, MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, - NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, PRIVATE_CALL_STACK_LENGTH, PUBLIC_CALL_STACK_LENGTH, @@ -125,7 +125,7 @@ export function extractPublicInputs(partialWitness: ACVMWitness, acir: Buffer): const returnValues = witnessReader.readFieldArray(RETURN_VALUES_LENGTH); const readRequests = witnessReader.readFieldArray(READ_REQUESTS_LENGTH); const newCommitments = witnessReader.readFieldArray(MAX_NEW_COMMITMENTS_PER_CALL); - const newNullifiers = witnessReader.readFieldArray(NEW_NULLIFIERS_LENGTH); + const newNullifiers = witnessReader.readFieldArray(MAX_NEW_NULLIFIERS_PER_CALL); const privateCallStack = witnessReader.readFieldArray(PRIVATE_CALL_STACK_LENGTH); const publicCallStack = witnessReader.readFieldArray(PUBLIC_CALL_STACK_LENGTH); const newL2ToL1Msgs = witnessReader.readFieldArray(NEW_L2_TO_L1_MSGS_LENGTH); diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 175a7a8a6496..d2a701829dd2 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -7,14 +7,14 @@ export const RETURN_VALUES_LENGTH = 4; export const READ_REQUESTS_LENGTH = 4; export const MAX_NEW_COMMITMENTS_PER_CALL = 4; -export const NEW_NULLIFIERS_LENGTH = 4; +export const MAX_NEW_NULLIFIERS_PER_CALL = 4; export const NEW_L2_TO_L1_MSGS_LENGTH = 2; export const PRIVATE_CALL_STACK_LENGTH = 4; export const PUBLIC_CALL_STACK_LENGTH = 4; export const MAX_NEW_COMMITMENTS_PER_TX = 16; // PRIVATE_CALL_STACK_LENGTH * MAX_NEW_COMMITMENTS_PER_CALL -export const KERNEL_NEW_NULLIFIERS_LENGTH = 16; // PRIVATE_CALL_STACK_LENGTH * NEW_NULLIFIERS_LENGTH +export const MAX_NEW_NULLIFIERS_PER_TX = 16; // PRIVATE_CALL_STACK_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL export const KERNEL_NEW_CONTRACTS_LENGTH = 1; export const KERNEL_PRIVATE_CALL_STACK_LENGTH = 8; export const KERNEL_PUBLIC_CALL_STACK_LENGTH = 8; 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 4f2260d6ba0c..40729d29ec9a 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 @@ -4,7 +4,7 @@ import { KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, KERNEL_PRIVATE_CALL_STACK_LENGTH, KERNEL_PUBLIC_CALL_STACK_LENGTH, @@ -282,7 +282,7 @@ export class CombinedAccumulatedData { /** * The number of new nullifiers made in this transaction. */ - public newNullifiers: Tuple, + public newNullifiers: Tuple, /** * Current private call stack. */ @@ -331,7 +331,7 @@ export class CombinedAccumulatedData { public publicDataReads: Tuple, ) { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); - assertMemberLength(this, 'newNullifiers', KERNEL_NEW_NULLIFIERS_LENGTH); + assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); assertMemberLength(this, 'privateCallStack', KERNEL_PRIVATE_CALL_STACK_LENGTH); assertMemberLength(this, 'publicCallStack', KERNEL_PUBLIC_CALL_STACK_LENGTH); assertMemberLength(this, 'newL2ToL1Msgs', KERNEL_NEW_L2_TO_L1_MSGS_LENGTH); @@ -376,7 +376,7 @@ export class CombinedAccumulatedData { return new CombinedAccumulatedData( reader.readObject(AggregationObject), reader.readArray(MAX_NEW_COMMITMENTS_PER_TX, Fr), - reader.readArray(KERNEL_NEW_NULLIFIERS_LENGTH, Fr), + reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), reader.readArray(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr), reader.readArray(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr), reader.readArray(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr), @@ -404,7 +404,7 @@ export class CombinedAccumulatedData { return new CombinedAccumulatedData( AggregationObject.makeFake(), makeTuple(MAX_NEW_COMMITMENTS_PER_TX, Fr.zero), - makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, Fr.zero), + makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), makeTuple(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr.zero), makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index e415b015c56d..6b05c1e81c94 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -5,7 +5,7 @@ import { CallContext } from './call_context.js'; import { MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, - NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, PRIVATE_CALL_STACK_LENGTH, PUBLIC_CALL_STACK_LENGTH, @@ -108,7 +108,7 @@ export class PrivateCircuitPublicInputs { assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); assertMemberLength(this, 'readRequests', READ_REQUESTS_LENGTH); assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); - assertMemberLength(this, 'newNullifiers', NEW_NULLIFIERS_LENGTH); + assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'privateCallStack', PRIVATE_CALL_STACK_LENGTH); assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); @@ -139,7 +139,7 @@ export class PrivateCircuitPublicInputs { frArray(RETURN_VALUES_LENGTH), frArray(READ_REQUESTS_LENGTH), frArray(MAX_NEW_COMMITMENTS_PER_CALL), - frArray(NEW_NULLIFIERS_LENGTH), + frArray(MAX_NEW_NULLIFIERS_PER_CALL), frArray(PRIVATE_CALL_STACK_LENGTH), frArray(PUBLIC_CALL_STACK_LENGTH), frArray(NEW_L2_TO_L1_MSGS_LENGTH), diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 60baed612a41..06b977688c0a 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -10,7 +10,7 @@ import { KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, - NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, PUBLIC_CALL_STACK_LENGTH, RETURN_VALUES_LENGTH, @@ -169,7 +169,7 @@ export class PublicCircuitPublicInputs { /** * New nullifiers created within a public execution call */ - public newNullifiers: Tuple, + public newNullifiers: Tuple, /** * New L2 to L1 messages generated during the call. */ @@ -195,7 +195,7 @@ export class PublicCircuitPublicInputs { assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); - assertMemberLength(this, 'newNullifiers', NEW_NULLIFIERS_LENGTH); + assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'contractStorageUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); assertMemberLength(this, 'contractStorageReads', KERNEL_PUBLIC_DATA_READS_LENGTH); @@ -224,7 +224,7 @@ export class PublicCircuitPublicInputs { makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, ContractStorageRead.empty), makeTuple(PUBLIC_CALL_STACK_LENGTH, Fr.zero), makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), - makeTuple(NEW_NULLIFIERS_LENGTH, Fr.zero), + makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, Fr.zero), makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), makeTuple(2, Fr.zero), Fr.ZERO, diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 0e9cac36d579..1c3cfba867af 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -7,7 +7,7 @@ import { CONTRACT_TREE_ROOTS_TREE_HEIGHT, MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, @@ -143,7 +143,7 @@ export class BaseRollupInputs { /** * Height of the nullifier subtree which is to be inserted into the nullifier tree. */ - public static NULLIFIER_SUBTREE_HEIGHT = Math.log2(KERNEL_NEW_NULLIFIERS_LENGTH * 2); + public static NULLIFIER_SUBTREE_HEIGHT = Math.log2(MAX_NEW_NULLIFIERS_PER_TX * 2); constructor( /** @@ -230,8 +230,8 @@ export class BaseRollupInputs { */ public constants: ConstantBaseRollupData, ) { - assertMemberLength(this, 'lowNullifierLeafPreimages', 2 * KERNEL_NEW_NULLIFIERS_LENGTH); - assertMemberLength(this, 'lowNullifierMembershipWitness', 2 * KERNEL_NEW_NULLIFIERS_LENGTH); + assertMemberLength(this, 'lowNullifierLeafPreimages', 2 * MAX_NEW_NULLIFIERS_PER_TX); + assertMemberLength(this, 'lowNullifierMembershipWitness', 2 * MAX_NEW_NULLIFIERS_PER_TX); assertMemberLength( this, 'newCommitmentsSubtreeSiblingPath', diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 5532491958a7..dc0724756b81 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -29,7 +29,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, KERNEL_PRIVATE_CALL_STACK_LENGTH, KERNEL_PUBLIC_CALL_STACK_LENGTH, @@ -42,7 +42,7 @@ import { MergeRollupInputs, MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, - NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_CALL, NULLIFIER_TREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, NUM_FIELDS_PER_SHA256, @@ -202,7 +202,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu return new CombinedAccumulatedData( makeAggregationObject(seed), tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), - tupleGenerator(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), + tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), // private call stack must be empty tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), @@ -228,7 +228,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated return new CombinedAccumulatedData( makeAggregationObject(seed), tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), - tupleGenerator(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), + tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x300), tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), @@ -315,7 +315,7 @@ export function makePublicCircuitPublicInputs( tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeContractStorageRead, seed + 0x500), tupleGenerator(PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x600), tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), - tupleGenerator(NEW_NULLIFIERS_LENGTH, fr, seed + 0x800), + tupleGenerator(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x800), tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x900), tupleGenerator(2, fr, seed + 0x901), fr(seed + 0x902), @@ -611,7 +611,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn returnValues: makeTuple(RETURN_VALUES_LENGTH, fr, seed + 0x200), readRequests: makeTuple(READ_REQUESTS_LENGTH, fr, seed + 0x300), newCommitments: makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x400), - newNullifiers: makeTuple(NEW_NULLIFIERS_LENGTH, fr, seed + 0x500), + newNullifiers: makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x500), privateCallStack: makeTuple(PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x600), publicCallStack: makeTuple(PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x700), newL2ToL1Msgs: makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x800), @@ -848,11 +848,11 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { const startContractTreeSnapshot = makeAppendOnlyTreeSnapshot(seed + 0x300); const startPublicDataTreeRoot = fr(seed + 0x400); - const lowNullifierLeafPreimages = range(2 * KERNEL_NEW_NULLIFIERS_LENGTH, seed + 0x1000).map( + const lowNullifierLeafPreimages = range(2 * MAX_NEW_NULLIFIERS_PER_TX, seed + 0x1000).map( x => new NullifierLeafPreimage(fr(x), fr(x + 0x100), x + 0x200), ); - const lowNullifierMembershipWitness = range(2 * KERNEL_NEW_NULLIFIERS_LENGTH, seed + 0x2000).map(x => + const lowNullifierMembershipWitness = range(2 * MAX_NEW_NULLIFIERS_PER_TX, seed + 0x2000).map(x => makeMembershipWitness(NULLIFIER_TREE_HEIGHT, x), ); 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 4006d117c56c..b51a5d576431 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 @@ -4,7 +4,7 @@ import { GlobalVariables, MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, KernelCircuitPublicInputs, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, @@ -172,7 +172,7 @@ describe('L1Publisher integration', () => { const processedTx = await makeProcessedTx(tx, kernelOutput, makeProof()); processedTx.data.end.newCommitments = makeTuple(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100); - processedTx.data.end.newNullifiers = makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200); + 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(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x300); processedTx.data.end.newContracts = [makeNewContractData(seed + 0x1000)]; diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index c32ae9c1d01a..87fc7de24e02 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -7,7 +7,7 @@ import { GlobalVariables, MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_CALL_STACK_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, KernelCircuitPublicInputs, @@ -300,7 +300,7 @@ describe('sequencer/solo_block_builder', () => { const processedTx = await makeProcessedTx(tx, kernelOutput, makeProof()); processedTx.data.end.newCommitments = makeTuple(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100); - processedTx.data.end.newNullifiers = makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200); + processedTx.data.end.newNullifiers = makeTuple(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200); processedTx.data.end.newNullifiers[tx.data.end.newNullifiers.length - 1] = Fr.ZERO; processedTx.data.end.newL2ToL1Msgs = makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x300); processedTx.data.end.newContracts = [makeNewContractData(seed + 0x1000)]; @@ -375,7 +375,7 @@ describe('sequencer/solo_block_builder', () => { const prover = new EmptyRollupProver(); builder = new SoloBlockBuilder(builderDb, vks, simulator, prover); // update the starting tree - const updateVals = Array(4 * KERNEL_NEW_NULLIFIERS_LENGTH).fill(0n); + const updateVals = Array(4 * MAX_NEW_NULLIFIERS_PER_TX).fill(0n); updateVals[0] = 19777494491628650244807463906174285795660759352776418619064841306523677458742n; updateVals[1] = 10246291467305176436335175657884940686778521321101740385288169037814567547848n; diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index d0342ff44303..f35ac2a1df87 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -12,7 +12,7 @@ import { MembershipWitness, MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, - NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_CALL, PUBLIC_CALL_STACK_LENGTH, PreviousKernelData, Proof, @@ -211,7 +211,7 @@ export class PublicProcessor { proverAddress: AztecAddress.random(), argsHash: await computeVarArgsHash(wasm, result.execution.args), newCommitments: padArrayEnd(result.newCommitments, Fr.ZERO, MAX_NEW_COMMITMENTS_PER_CALL), - newNullifiers: padArrayEnd(result.newNullifiers, Fr.ZERO, NEW_NULLIFIERS_LENGTH), + newNullifiers: padArrayEnd(result.newNullifiers, Fr.ZERO, MAX_NEW_NULLIFIERS_PER_CALL), newL2ToL1Msgs: padArrayEnd(result.newL2ToL1Messages, Fr.ZERO, NEW_L2_TO_L1_MSGS_LENGTH), returnValues: padArrayEnd(result.returnValues, Fr.ZERO, RETURN_VALUES_LENGTH), contractStorageReads: padArrayEnd( diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index 06d4fff08892..8fe27d3afa69 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -2,7 +2,7 @@ import { AppendOnlyTreeSnapshot, MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, @@ -176,7 +176,7 @@ export class L2Block { numEncryptedLogs = 2, numUnencryptedLogs = 1, ): L2Block { - const newNullifiers = times(KERNEL_NEW_NULLIFIERS_LENGTH * txsPerBlock, Fr.random); + const newNullifiers = times(MAX_NEW_NULLIFIERS_PER_TX * txsPerBlock, Fr.random); const newCommitments = times(MAX_NEW_COMMITMENTS_PER_TX * txsPerBlock, Fr.random); const newContracts = times(KERNEL_NEW_CONTRACTS_LENGTH * txsPerBlock, Fr.random); const newContractData = times(KERNEL_NEW_CONTRACTS_LENGTH * txsPerBlock, ContractData.random); @@ -616,7 +616,7 @@ export class L2Block { for (let i = 0; i < leafCount; i++) { const commitmentsPerBase = MAX_NEW_COMMITMENTS_PER_TX * 2; - const nullifiersPerBase = KERNEL_NEW_NULLIFIERS_LENGTH * 2; + const nullifiersPerBase = MAX_NEW_NULLIFIERS_PER_TX * 2; const publicDataUpdateRequestsPerBase = KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2; const l2ToL1MsgsPerBase = KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * 2; const commitmentsBuffer = Buffer.concat( @@ -687,8 +687,8 @@ export class L2Block { MAX_NEW_COMMITMENTS_PER_TX * (txIndex + 1), ); const newNullifiers = this.newNullifiers.slice( - KERNEL_NEW_NULLIFIERS_LENGTH * txIndex, - KERNEL_NEW_NULLIFIERS_LENGTH * (txIndex + 1), + MAX_NEW_NULLIFIERS_PER_TX * txIndex, + MAX_NEW_NULLIFIERS_PER_TX * (txIndex + 1), ); const newPublicDataWrites = this.newPublicDataWrites.slice( KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * txIndex, diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts index d4efbf9d1d51..6f1c9aa5a185 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts @@ -4,7 +4,7 @@ import { GlobalVariables, MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_CONTRACTS_LENGTH, - KERNEL_NEW_NULLIFIERS_LENGTH, + MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, NEW_L2_TO_L1_MSGS_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, @@ -79,7 +79,7 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = endL1ToL2MessageTreeSnapshot: getMockTreeSnapshot(), endTreeOfHistoricL1ToL2MessageTreeRootsSnapshot: getMockTreeSnapshot(), newCommitments: times(MAX_NEW_COMMITMENTS_PER_TX, Fr.random), - newNullifiers: times(KERNEL_NEW_NULLIFIERS_LENGTH, Fr.random), + newNullifiers: times(MAX_NEW_NULLIFIERS_PER_TX, Fr.random), newContracts: newContractsCommitments?.map(x => Fr.fromBuffer(x)) ?? [Fr.random()], newContractData: times(KERNEL_NEW_CONTRACTS_LENGTH, getMockContractData), newPublicDataWrites: times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataWrite.random), diff --git a/yarn-project/world-state/src/world-state-db/index.ts b/yarn-project/world-state/src/world-state-db/index.ts index 11f7958b5c8b..5b5f51e8904a 100644 --- a/yarn-project/world-state/src/world-state-db/index.ts +++ b/yarn-project/world-state/src/world-state-db/index.ts @@ -1,7 +1,7 @@ import { LeafData, SiblingPath, LowLeafWitnessData } from '@aztec/merkle-tree'; import { L2Block, MerkleTreeId } from '@aztec/types'; import { createDebugLogger } from '@aztec/foundation/log'; -import { KERNEL_NEW_NULLIFIERS_LENGTH } from '@aztec/circuits.js'; +import { MAX_NEW_NULLIFIERS_PER_TX } from '@aztec/circuits.js'; export * from './merkle_trees.js'; export { LeafData } from '@aztec/merkle-tree'; @@ -31,7 +31,7 @@ export type PublicTreeId = MerkleTreeId.PUBLIC_DATA_TREE; * 1024 leaves for the first block, because there's only neat space for 1023 leaves after 0. By padding with 1023 * more leaves, we can then insert the first block of 1024 leaves into indices 1024:2047. */ -export const INITIAL_NULLIFIER_TREE_SIZE = 2 * KERNEL_NEW_NULLIFIERS_LENGTH; +export const INITIAL_NULLIFIER_TREE_SIZE = 2 * MAX_NEW_NULLIFIERS_PER_TX; /** * Defines tree information. From e0a311fe9051578b676093003d70ae5fc074b763 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 10:11:23 +0000 Subject: [PATCH 03/14] 972 - rename constants related to private call stack --- .../abis/combined_accumulated_data.hpp | 2 +- .../abis/private_circuit_public_inputs.hpp | 45 ++++++++++--------- .../call_context_reconciliation_data.hpp | 4 +- .../abis/private_kernel/private_call_data.hpp | 2 +- .../apps/function_execution_context.hpp | 6 +-- .../kernel/private/testing_harness.cpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 4 +- circuits/cpp/src/aztec3/constants.hpp | 8 ++-- .../cpp/src/aztec3/utils/circuit_errors.hpp | 2 +- .../acir-simulator/src/acvm/deserialize.ts | 4 +- .../src/kernel_prover/kernel_prover.test.ts | 4 +- .../src/kernel_prover/kernel_prover.ts | 8 ++-- .../circuits.js/src/structs/constants.ts | 8 ++-- .../kernel/combined_accumulated_data.ts | 10 ++--- .../src/structs/kernel/private_kernel.ts | 4 +- .../structs/private_circuit_public_inputs.ts | 6 +-- .../circuits.js/src/tests/factories.ts | 12 ++--- .../src/sequencer/public_processor.test.ts | 6 +-- 18 files changed, 69 insertions(+), 68 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index c8d987787235..edd9a14d123d 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -28,7 +28,7 @@ template struct CombinedAccumulatedData { std::array new_commitments{}; std::array new_nullifiers{}; - std::array private_call_stack{}; + std::array private_call_stack{}; std::array public_call_stack{}; std::array new_l2_to_l1_msgs{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index 05b1576c8149..445e73f315e7 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -32,7 +32,7 @@ template class PrivateCircuitPublicInputs { std::array new_commitments{}; std::array new_nullifiers{}; - std::array private_call_stack{}; + std::array private_call_stack{}; std::array public_call_stack{}; std::array new_l2_to_l1_msgs{}; @@ -306,7 +306,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array new_commitments; std::array new_nullifiers; - std::array private_call_stack; + std::array private_call_stack; std::array public_call_stack; std::array new_l2_to_l1_msgs; @@ -328,35 +328,36 @@ template class OptionalPrivateCircuitPublicInputs { OptionalPrivateCircuitPublicInputs() = default; - OptionalPrivateCircuitPublicInputs(std::optional> const& call_context, + OptionalPrivateCircuitPublicInputs( + std::optional> const& call_context, - opt_fr const& args_hash, - std::array const& return_values, + opt_fr const& args_hash, + std::array const& return_values, - std::array const& read_requests, + std::array const& read_requests, - std::array const& new_commitments, - std::array const& new_nullifiers, + std::array const& new_commitments, + std::array const& new_nullifiers, - std::array const& private_call_stack, - std::array const& public_call_stack, - std::array const& new_l2_to_l1_msgs, + std::array const& private_call_stack, + std::array const& public_call_stack, + std::array const& new_l2_to_l1_msgs, - std::array const& encrypted_logs_hash, - std::array const& unencrypted_logs_hash, + std::array const& encrypted_logs_hash, + std::array const& unencrypted_logs_hash, - opt_fr const& encrypted_log_preimages_length, - opt_fr const& unencrypted_log_preimages_length, + opt_fr const& encrypted_log_preimages_length, + opt_fr const& unencrypted_log_preimages_length, - opt_fr const& historic_private_data_tree_root, - opt_fr const& historic_nullifier_tree_root, - opt_fr const& historic_contract_tree_root, - opt_fr const& historic_l1_to_l2_messages_tree_root, + opt_fr const& historic_private_data_tree_root, + opt_fr const& historic_nullifier_tree_root, + opt_fr const& historic_contract_tree_root, + opt_fr const& historic_l1_to_l2_messages_tree_root, - std::optional> const& contract_deployment_data, + std::optional> const& contract_deployment_data, - opt_fr const& chain_id, - opt_fr const& version) + opt_fr const& chain_id, + opt_fr const& version) : call_context(call_context) , args_hash(args_hash) , return_values(return_values) diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp index 1a527f39c745..cc282b431c08 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp @@ -22,8 +22,8 @@ // * This class needs an explanation... // * // */ -// std::array, PRIVATE_CALL_STACK_LENGTH> private_call_contexts; -// std::array private_counterparts; +// std::array, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> private_call_contexts; +// std::array private_counterparts; // std::array, PUBLIC_CALL_STACK_LENGTH> public_call_contexts; // std::array public_counterparts; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp index b9887739eb21..d67d22e0fb53 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp @@ -26,7 +26,7 @@ template struct PrivateCallData { CallStackItem call_stack_item{}; - std::array, PRIVATE_CALL_STACK_LENGTH> private_call_stack_preimages{}; + std::array, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> private_call_stack_preimages{}; // std::array, PUBLIC_CALL_STACK_LENGTH> public_call_stack_preimages; diff --git a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp index f44ff1cbc71a..b3e466de22a3 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp @@ -50,7 +50,7 @@ template class FunctionExecutionContext { Contract* contract = nullptr; - std::array>, PRIVATE_CALL_STACK_LENGTH> + std::array>, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> nested_private_call_exec_ctxs; // TODO: make this private! @@ -124,9 +124,9 @@ template class FunctionExecutionContext { /** * @brief Get the call_stack_items of any nested function calls made by this exec_ctx's function. */ - std::array, PRIVATE_CALL_STACK_LENGTH> get_private_call_stack_items() + std::array, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> get_private_call_stack_items() { - std::array, PRIVATE_CALL_STACK_LENGTH> result; + std::array, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> result; for (size_t i = 0; i < result.size(); ++i) { auto& nested_exec_ctx = nested_private_call_exec_ctxs[i]; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp index b4128ea12c9f..7a93358a9065 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/testing_harness.cpp @@ -447,7 +447,7 @@ PrivateKernelInputsInner do_private_call_get_kernel_inputs_inner( // We mock a kernel circuit proof to initialize ipnut required by an inner call //*************************************************************************** - std::array initial_kernel_private_call_stack{}; + std::array initial_kernel_private_call_stack{}; initial_kernel_private_call_stack[0] = private_call_data.call_stack_item.hash(); auto const& private_circuit_public_inputs = private_call_data.call_stack_item.public_inputs; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index cd7823290043..cf5e3c0539ad 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -393,7 +393,7 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat array_of_values(seed, private_previous ? MAX_NEW_COMMITMENTS_PER_TX / 2 : 0), .new_nullifiers = array_of_values(seed, private_previous ? MAX_NEW_NULLIFIERS_PER_TX / 2 : 0), - .private_call_stack = array_of_values(seed, 0), + .private_call_stack = array_of_values(seed, 0), .public_call_stack = public_call_stack, .new_l2_to_l1_msgs = array_of_values( seed, private_previous ? KERNEL_NEW_L2_TO_L1_MSGS_LENGTH / 2 : 0), @@ -464,7 +464,7 @@ void validate_private_data_propagation(const PublicKernelInputs& inputs, const KernelCircuitPublicInputs& public_inputs) { ASSERT_TRUE(source_arrays_are_in_target(inputs.previous_kernel.public_inputs.end.private_call_stack, - std::array{}, + std::array{}, public_inputs.end.private_call_stack)); ASSERT_TRUE(source_arrays_are_in_target(inputs.previous_kernel.public_inputs.end.new_contracts, diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 236cad1b5543..6f6ebca9d209 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -41,14 +41,14 @@ constexpr size_t READ_REQUESTS_LENGTH = 4; constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 4; constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4; -constexpr size_t PRIVATE_CALL_STACK_LENGTH = 4; +constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t PUBLIC_CALL_STACK_LENGTH = 4; constexpr size_t NEW_L2_TO_L1_MSGS_LENGTH = 2; -constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = PRIVATE_CALL_STACK_LENGTH * MAX_NEW_COMMITMENTS_PER_CALL; -constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = PRIVATE_CALL_STACK_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL; +constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; +constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL; constexpr size_t KERNEL_NEW_CONTRACTS_LENGTH = 1; -constexpr size_t KERNEL_PRIVATE_CALL_STACK_LENGTH = 8; +constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t KERNEL_PUBLIC_CALL_STACK_LENGTH = 8; constexpr size_t KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; constexpr size_t KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; diff --git a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp index 6c7947dc9668..b9788442332f 100644 --- a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp +++ b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp @@ -20,7 +20,7 @@ enum CircuitErrorCode : uint16_t { PRIVATE_KERNEL__CALCULATED_PRIVATE_CALL_HASH_AND_PROVIDED_PRIVATE_CALL_HASH_MISMATCH = 2007, PRIVATE_KERNEL__PRIVATE_CALL_STACK_ITEM_HASH_MISMATCH = 2008, PRIVATE_KERNEL__NON_PRIVATE_FUNCTION_EXECUTED_WITH_PRIVATE_KERNEL = 2009, - PRIVATE_KERNEL__PRIVATE_CALL_STACK_LENGTH_MISMATCH = 2010, + PRIVATE_KERNEL__MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL_MISMATCH = 2010, PRIVATE_KERNEL__UNSUPPORTED_OP = 2011, PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH = 2012, PRIVATE_KERNEL__NON_PRIVATE_KERNEL_VERIFIED_WITH_PRIVATE_KERNEL = 2013, diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index 555c8622ee06..4f80dda07ac9 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -5,7 +5,7 @@ import { NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, - PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PUBLIC_CALL_STACK_LENGTH, PrivateCircuitPublicInputs, READ_REQUESTS_LENGTH, @@ -126,7 +126,7 @@ export function extractPublicInputs(partialWitness: ACVMWitness, acir: Buffer): const readRequests = witnessReader.readFieldArray(READ_REQUESTS_LENGTH); const newCommitments = witnessReader.readFieldArray(MAX_NEW_COMMITMENTS_PER_CALL); const newNullifiers = witnessReader.readFieldArray(MAX_NEW_NULLIFIERS_PER_CALL); - const privateCallStack = witnessReader.readFieldArray(PRIVATE_CALL_STACK_LENGTH); + const privateCallStack = witnessReader.readFieldArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); const publicCallStack = witnessReader.readFieldArray(PUBLIC_CALL_STACK_LENGTH); const newL2ToL1Msgs = witnessReader.readFieldArray(NEW_L2_TO_L1_MSGS_LENGTH); diff --git a/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts b/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts index 400e2e7a872f..8e9def4a21b1 100644 --- a/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts +++ b/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.test.ts @@ -3,7 +3,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, KernelCircuitPublicInputs, MembershipWitness, - PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PrivateCallStackItem, PrivateCircuitPublicInputs, READ_REQUESTS_LENGTH, @@ -141,7 +141,7 @@ describe('Kernel Prover', () => { }); it('should throw if call stack is too deep', async () => { - dependencies.a = Array(PRIVATE_CALL_STACK_LENGTH + 1) + dependencies.a = Array(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL + 1) .fill(0) .map((_, i) => `${i}`); const executionResult = createExecutionResult('a'); diff --git a/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.ts b/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.ts index c394fcfadf35..aad942e953b4 100644 --- a/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.ts +++ b/yarn-project/aztec-rpc/src/kernel_prover/kernel_prover.ts @@ -5,7 +5,7 @@ import { Fr, KernelCircuitPublicInputs, MembershipWitness, - PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PRIVATE_DATA_TREE_HEIGHT, PreviousKernelData, PrivateCallData, @@ -85,14 +85,14 @@ export class KernelProver { const currentExecution = executionStack.pop()!; executionStack.push(...currentExecution.nestedExecutions); const privateCallStackPreimages = currentExecution.nestedExecutions.map(result => result.callStackItem); - if (privateCallStackPreimages.length > PRIVATE_CALL_STACK_LENGTH) { + if (privateCallStackPreimages.length > MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL) { throw new Error( - `Too many items in the call stack. Maximum amount is ${PRIVATE_CALL_STACK_LENGTH}. Got ${privateCallStackPreimages.length}.`, + `Too many items in the call stack. Maximum amount is ${MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL}. Got ${privateCallStackPreimages.length}.`, ); } // Pad with empty items to reach max/const length expected by circuit. privateCallStackPreimages.push( - ...Array(PRIVATE_CALL_STACK_LENGTH - privateCallStackPreimages.length) + ...Array(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL - privateCallStackPreimages.length) .fill(0) .map(() => PrivateCallStackItem.empty()), ); diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index d2a701829dd2..4177aa3002d4 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -10,13 +10,13 @@ export const MAX_NEW_COMMITMENTS_PER_CALL = 4; export const MAX_NEW_NULLIFIERS_PER_CALL = 4; export const NEW_L2_TO_L1_MSGS_LENGTH = 2; -export const PRIVATE_CALL_STACK_LENGTH = 4; +export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; export const PUBLIC_CALL_STACK_LENGTH = 4; -export const MAX_NEW_COMMITMENTS_PER_TX = 16; // PRIVATE_CALL_STACK_LENGTH * MAX_NEW_COMMITMENTS_PER_CALL -export const MAX_NEW_NULLIFIERS_PER_TX = 16; // PRIVATE_CALL_STACK_LENGTH * MAX_NEW_NULLIFIERS_PER_CALL +export const MAX_NEW_COMMITMENTS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL +export const MAX_NEW_NULLIFIERS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL export const KERNEL_NEW_CONTRACTS_LENGTH = 1; -export const KERNEL_PRIVATE_CALL_STACK_LENGTH = 8; +export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const KERNEL_PUBLIC_CALL_STACK_LENGTH = 8; export const KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; export const KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; 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 40729d29ec9a..1a088817d077 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 @@ -6,7 +6,7 @@ import { KERNEL_NEW_CONTRACTS_LENGTH, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, - KERNEL_PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_CALL_STACK_LENGTH, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -286,7 +286,7 @@ export class CombinedAccumulatedData { /** * Current private call stack. */ - public privateCallStack: Tuple, + public privateCallStack: Tuple, /** * Current public call stack. */ @@ -332,7 +332,7 @@ export class CombinedAccumulatedData { ) { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); - assertMemberLength(this, 'privateCallStack', KERNEL_PRIVATE_CALL_STACK_LENGTH); + assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); assertMemberLength(this, 'publicCallStack', KERNEL_PUBLIC_CALL_STACK_LENGTH); assertMemberLength(this, 'newL2ToL1Msgs', KERNEL_NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); @@ -377,7 +377,7 @@ export class CombinedAccumulatedData { reader.readObject(AggregationObject), reader.readArray(MAX_NEW_COMMITMENTS_PER_TX, Fr), reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), - reader.readArray(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr), + reader.readArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr), reader.readArray(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr), reader.readArray(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr), reader.readArray(2, Fr), @@ -405,7 +405,7 @@ export class CombinedAccumulatedData { AggregationObject.makeFake(), makeTuple(MAX_NEW_COMMITMENTS_PER_TX, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), - makeTuple(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), + makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr.zero), makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), makeTuple(2, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts index bf8e947af1b1..3f0e2f61cd26 100644 --- a/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/private_kernel.ts @@ -5,7 +5,7 @@ import { PrivateCallStackItem } from '../call_stack_item.js'; import { CONTRACT_TREE_HEIGHT, FUNCTION_TREE_HEIGHT, - PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PRIVATE_DATA_TREE_HEIGHT, READ_REQUESTS_LENGTH, } from '../constants.js'; @@ -60,7 +60,7 @@ export class PrivateCallData { */ public acirHash: Fr, ) { - assertMemberLength(this, 'privateCallStackPreimages', PRIVATE_CALL_STACK_LENGTH); + assertMemberLength(this, 'privateCallStackPreimages', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); assertMemberLength(this, 'readRequestMembershipWitnesses', READ_REQUESTS_LENGTH); } diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index 6b05c1e81c94..0a3939af7c07 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -7,7 +7,7 @@ import { NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, - PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PUBLIC_CALL_STACK_LENGTH, READ_REQUESTS_LENGTH, RETURN_VALUES_LENGTH, @@ -109,7 +109,7 @@ export class PrivateCircuitPublicInputs { assertMemberLength(this, 'readRequests', READ_REQUESTS_LENGTH); assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); - assertMemberLength(this, 'privateCallStack', PRIVATE_CALL_STACK_LENGTH); + assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); @@ -140,7 +140,7 @@ export class PrivateCircuitPublicInputs { frArray(READ_REQUESTS_LENGTH), frArray(MAX_NEW_COMMITMENTS_PER_CALL), frArray(MAX_NEW_NULLIFIERS_PER_CALL), - frArray(PRIVATE_CALL_STACK_LENGTH), + frArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL), frArray(PUBLIC_CALL_STACK_LENGTH), frArray(NEW_L2_TO_L1_MSGS_LENGTH), frArray(NUM_FIELDS_PER_SHA256), diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index dc0724756b81..5eab6925cb65 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -31,7 +31,7 @@ import { KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, - KERNEL_PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_CALL_STACK_LENGTH, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -49,7 +49,7 @@ import { NewContractData, NullifierLeafPreimage, OptionallyRevealedData, - PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PRIVATE_DATA_TREE_HEIGHT, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, PUBLIC_CALL_STACK_LENGTH, @@ -203,7 +203,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu makeAggregationObject(seed), tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), - tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), // private call stack must be empty + tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), // private call stack must be empty tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), tupleGenerator(2, fr, seed + 0x600), // encrypted logs hash @@ -229,7 +229,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated makeAggregationObject(seed), tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), - tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x300), + tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x300), tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), tupleGenerator(2, fr, seed + 0x600), // encrypted logs hash @@ -566,7 +566,7 @@ export function makeTxRequest(seed = 1): TxRequest { export function makePrivateCallData(seed = 1): PrivateCallData { return PrivateCallData.from({ callStackItem: makePrivateCallStackItem(seed), - privateCallStackPreimages: makeTuple(PRIVATE_CALL_STACK_LENGTH, makePrivateCallStackItem, seed + 0x10), + privateCallStackPreimages: makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, makePrivateCallStackItem, seed + 0x10), proof: new Proof(Buffer.alloc(16).fill(seed + 0x50)), vk: makeVerificationKey(), functionLeafMembershipWitness: makeMembershipWitness(FUNCTION_TREE_HEIGHT, seed + 0x30), @@ -612,7 +612,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn readRequests: makeTuple(READ_REQUESTS_LENGTH, fr, seed + 0x300), newCommitments: makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x400), newNullifiers: makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x500), - privateCallStack: makeTuple(PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x600), + privateCallStack: makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), publicCallStack: makeTuple(PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x700), newL2ToL1Msgs: makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x800), encryptedLogsHash: makeTuple(NUM_FIELDS_PER_SHA256, fr, seed + 0x900), diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index 5f1547f27f82..aff4c1b3cff4 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -7,7 +7,7 @@ import { Fr, FunctionData, GlobalVariables, - KERNEL_PRIVATE_CALL_STACK_LENGTH, + MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_CALL_STACK_LENGTH, PUBLIC_DATA_TREE_HEIGHT, Proof, @@ -133,7 +133,7 @@ describe('public_processor', () => { const kernelOutput = makeKernelPublicInputs(0x10); kernelOutput.end.publicCallStack = padArrayEnd(callStackHashes, Fr.ZERO, KERNEL_PUBLIC_CALL_STACK_LENGTH); - kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, KERNEL_PRIVATE_CALL_STACK_LENGTH); + kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); const tx = new Tx(kernelOutput, proof, TxL2Logs.random(2, 3), TxL2Logs.random(3, 2), [], callRequests); @@ -161,7 +161,7 @@ describe('public_processor', () => { const kernelOutput = makeKernelPublicInputs(0x10); kernelOutput.end.publicCallStack = padArrayEnd([callStackHash], Fr.ZERO, KERNEL_PUBLIC_CALL_STACK_LENGTH); - kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, KERNEL_PRIVATE_CALL_STACK_LENGTH); + kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); const tx = new Tx(kernelOutput, proof, TxL2Logs.random(2, 3), TxL2Logs.random(3, 2), [], [callRequest]); From 58d5d8068502281301b7cd2d1aaf365308e5f4f3 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 10:49:53 +0000 Subject: [PATCH 04/14] 972 - rename public stack related constants --- .../abis/combined_accumulated_data.hpp | 2 +- .../abis/private_circuit_public_inputs.hpp | 6 +- .../call_context_reconciliation_data.hpp | 4 +- .../abis/private_kernel/private_call_data.hpp | 3 +- .../abis/public_circuit_public_inputs.hpp | 2 +- .../abis/public_kernel/public_call_data.hpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 56 ++++++++++--------- circuits/cpp/src/aztec3/constants.hpp | 4 +- .../acir-simulator/src/acvm/deserialize.ts | 4 +- .../src/client/private_execution.ts | 4 +- .../circuits.js/src/structs/constants.ts | 4 +- .../kernel/combined_accumulated_data.ts | 10 ++-- .../src/structs/kernel/public_kernel.ts | 6 +- .../structs/private_circuit_public_inputs.ts | 6 +- .../structs/public_circuit_public_inputs.ts | 8 +-- .../circuits.js/src/tests/factories.ts | 16 +++--- yarn-project/p2p/src/client/mocks.ts | 4 +- .../p2p/src/service/tx_messages.test.ts | 4 +- .../block_builder/solo_block_builder.test.ts | 4 +- yarn-project/sequencer-client/src/mocks/tx.ts | 4 +- .../src/sequencer/public_processor.test.ts | 8 +-- .../src/sequencer/public_processor.ts | 10 ++-- 22 files changed, 87 insertions(+), 84 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index edd9a14d123d..f364763d1409 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -29,7 +29,7 @@ template struct CombinedAccumulatedData { std::array new_nullifiers{}; std::array private_call_stack{}; - std::array public_call_stack{}; + std::array public_call_stack{}; std::array new_l2_to_l1_msgs{}; std::array encrypted_logs_hash{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index 445e73f315e7..c842568d0abb 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -33,7 +33,7 @@ template class PrivateCircuitPublicInputs { std::array new_nullifiers{}; std::array private_call_stack{}; - std::array public_call_stack{}; + std::array public_call_stack{}; std::array new_l2_to_l1_msgs{}; std::array encrypted_logs_hash{}; @@ -307,7 +307,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array new_nullifiers; std::array private_call_stack; - std::array public_call_stack; + std::array public_call_stack; std::array new_l2_to_l1_msgs; std::array encrypted_logs_hash; @@ -340,7 +340,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array const& new_nullifiers, std::array const& private_call_stack, - std::array const& public_call_stack, + std::array const& public_call_stack, std::array const& new_l2_to_l1_msgs, std::array const& encrypted_logs_hash, diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp index cc282b431c08..7964edf7fd6e 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp @@ -25,8 +25,8 @@ // std::array, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> private_call_contexts; // std::array private_counterparts; -// std::array, PUBLIC_CALL_STACK_LENGTH> public_call_contexts; -// std::array public_counterparts; +// std::array, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL> public_call_contexts; +// std::array public_counterparts; // // std::array contract_deployment_call_stack; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp index d67d22e0fb53..50aaf1cec066 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/private_call_data.hpp @@ -28,7 +28,8 @@ template struct PrivateCallData { std::array, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL> private_call_stack_preimages{}; - // std::array, PUBLIC_CALL_STACK_LENGTH> public_call_stack_preimages; + // std::array, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL> + // public_call_stack_preimages; NativeTypes::Proof proof{}; // TODO: how to express proof as native/circuit type when it gets used as a buffer? std::shared_ptr vk; diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index 9c6eed798a4e..a65115b0dd55 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -30,7 +30,7 @@ template struct PublicCircuitPublicInputs { contract_storage_update_requests{}; std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> contract_storage_reads{}; - std::array public_call_stack{}; + std::array public_call_stack{}; std::array new_commitments{}; std::array new_nullifiers{}; std::array new_l2_to_l1_msgs{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp index 3a69895231f5..85849beb877d 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_kernel/public_call_data.hpp @@ -24,7 +24,7 @@ template struct PublicCallData { CallStackItem call_stack_item{}; - std::array, PUBLIC_CALL_STACK_LENGTH> public_call_stack_preimages{}; + std::array, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL> public_call_stack_preimages{}; NativeTypes::Proof proof{}; // TODO: how to express proof as native/circuit type when it gets used as a buffer? diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index cf5e3c0539ad..1140f980fcb6 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -123,8 +123,8 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, }; fr const args_hash = count; std::array const return_values = array_of_values(count); - std::array const public_call_stack = - array_of_values(count); + std::array const public_call_stack = + array_of_values(count); std::array const new_commitments = array_of_values(count); std::array const new_nullifiers = @@ -296,11 +296,11 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat .chain_id = 1, } }; - std::array child_call_stacks; + std::array child_call_stacks; NT::fr child_contract_address = 100000; NT::fr child_portal_contract_address = 200000; - std::array call_stack_hashes{}; - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + std::array call_stack_hashes{}; + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { // NOLINTNEXTLINE(readability-suspicious-call-argument) child_call_stacks[i] = generate_call_stack_item(child_contract_address, contract_address, @@ -385,7 +385,7 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat } }; - std::array public_call_stack{}; + std::array public_call_stack{}; public_call_stack[0] = public_call_data.call_stack_item.hash(); CombinedAccumulatedData const end_accumulated_data = { @@ -431,7 +431,7 @@ template void validate_public_kernel_outputs_correctly_propagated(const KernelInput& inputs, const KernelCircuitPublicInputs& public_inputs) { - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { ASSERT_EQ(public_inputs.end.public_call_stack[i], inputs.public_call.call_stack_item.public_inputs.public_call_stack[i]); } @@ -510,7 +510,7 @@ TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) ASSERT_FALSE(public_inputs.is_private); ASSERT_EQ(public_inputs.constants.tx_context, inputs.previous_kernel.public_inputs.constants.tx_context); - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { ASSERT_EQ(public_inputs.end.public_call_stack[i], inputs.public_call.call_stack_item.public_inputs.public_call_stack[i]); } @@ -555,7 +555,7 @@ TEST(public_kernel_tests, only_valid_update_requests_should_be_propagated) ASSERT_FALSE(public_inputs.is_private); ASSERT_EQ(public_inputs.constants.tx_context, inputs.previous_kernel.public_inputs.constants.tx_context); - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { ASSERT_EQ(public_inputs.end.public_call_stack[i], inputs.public_call.call_stack_item.public_inputs.public_call_stack[i]); } @@ -638,7 +638,7 @@ TEST(public_kernel_tests, private_call_should_fail) TEST(public_kernel_tests, inconsistent_call_hash_should_fail) { - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { DummyBuilder dummyBuilder = DummyBuilder(format("public_kernel_tests__inconsistent_call_hash_should_fail-", i)); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); @@ -652,7 +652,7 @@ TEST(public_kernel_tests, inconsistent_call_hash_should_fail) TEST(public_kernel_tests, incorrect_storage_contract_address_fails_for_regular_calls) { - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { DummyBuilder dummyBuilder = DummyBuilder(format("public_kernel_tests__incorrect_storage_contract_address_fails_for_regular_calls-", i)); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); @@ -671,7 +671,7 @@ TEST(public_kernel_tests, incorrect_storage_contract_address_fails_for_regular_c TEST(public_kernel_tests, incorrect_msg_sender_fails_for_regular_calls) { - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { DummyBuilder dummyBuilder = DummyBuilder(format("public_kernel_tests__incorrect_msg_sender_fails_for_regular_calls-", i)); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); @@ -697,13 +697,13 @@ TEST(public_kernel_tests, public_kernel_circuit_succeeds_for_mixture_of_regular_ const auto contract_portal_address = NT::fr(inputs.public_call.portal_contract_address); // redefine the child calls/stacks to use some delegate calls - std::array child_call_stacks; + std::array child_call_stacks; NT::uint32 const seed = 1000; NT::fr child_contract_address = 100000; NT::fr child_portal_contract_address = 200000; NT::boolean is_delegate_call = false; - std::array call_stack_hashes{}; - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + std::array call_stack_hashes{}; + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { child_call_stacks[i] = // NOLINTNEXTLINE(readability-suspicious-call-argument) generate_call_stack_item(child_contract_address, @@ -736,10 +736,10 @@ TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_msg_sender_in const auto contract_portal_address = NT::fr(inputs.public_call.portal_contract_address); // set the first call stack item to be a delegate call - std::array child_call_stacks; + std::array child_call_stacks; NT::uint32 const seed = 1000; NT::fr const child_contract_address = 100000; - std::array call_stack_hashes{}; + std::array call_stack_hashes{}; child_call_stacks[0] = // NOLINTNEXTLINE(readability-suspicious-call-argument) generate_call_stack_item(child_contract_address, @@ -769,10 +769,10 @@ TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_storage_contr const auto contract_portal_address = NT::fr(inputs.public_call.portal_contract_address); // set the first call stack item to be a delegate call - std::array child_call_stacks; + std::array child_call_stacks; NT::uint32 const seed = 1000; NT::fr const child_contract_address = 100000; - std::array call_stack_hashes{}; + std::array call_stack_hashes{}; child_call_stacks[0] = generate_call_stack_item(child_contract_address, origin_msg_sender, child_contract_address, // this should be contract_address @@ -800,11 +800,11 @@ TEST(public_kernel_tests, public_kernel_circuit_fails_on_incorrect_portal_contra // const auto contract_portal_address = NT::fr(inputs.public_call.portal_contract_address); // set the first call stack item to be a delegate call - std::array child_call_stacks; + std::array child_call_stacks; NT::uint32 const seed = 1000; NT::fr const child_contract_address = 100000; NT::fr const child_portal_contract = 200000; - std::array call_stack_hashes{}; + std::array call_stack_hashes{}; // NOLINTNEXTLINE(readability-suspicious-call-argument) child_call_stacks[0] = generate_call_stack_item(child_contract_address, origin_msg_sender, @@ -834,14 +834,14 @@ TEST(public_kernel_tests, public_kernel_circuit_only_checks_non_empty_call_stack // set all but the first call stack item to have a zero call stack hash // these call stack items will have an contract portal address but will be ignored as the call stack will be ignored - std::array& child_call_stacks = + std::array& child_call_stacks = inputs.public_call.public_call_stack_preimages; - std::array& call_stack_hashes = + std::array& call_stack_hashes = inputs.public_call.call_stack_item.public_inputs.public_call_stack; NT::uint32 const seed = 1000; NT::fr const child_contract_address = 100000; NT::fr const child_portal_contract = 200000; - for (size_t i = 1; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 1; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { // NOLINTNEXTLINE(readability-suspicious-call-argument) child_call_stacks[i] = generate_call_stack_item(child_contract_address, origin_msg_sender, @@ -899,7 +899,8 @@ TEST(public_kernel_tests, private_previous_kernel_empty_public_call_stack_should DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__private_previous_kernel_empty_public_call_stack_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(true); - inputs.previous_kernel.public_inputs.end.public_call_stack = std::array{}; + inputs.previous_kernel.public_inputs.end.public_call_stack = + std::array{}; auto public_inputs = native_public_kernel_circuit_private_previous_kernel(dummyBuilder, inputs); ASSERT_TRUE(dummyBuilder.failed()); ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); @@ -962,7 +963,8 @@ TEST(public_kernel_tests, public_previous_kernel_empty_public_call_stack_should_ DummyBuilder dummyBuilder = DummyBuilder("public_kernel_tests__public_previous_kernel_empty_public_call_stack_should_fail"); PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); - inputs.previous_kernel.public_inputs.end.public_call_stack = std::array{}; + inputs.previous_kernel.public_inputs.end.public_call_stack = + std::array{}; auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyBuilder, inputs); ASSERT_TRUE(dummyBuilder.failed()); ASSERT_EQ(dummyBuilder.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__EMPTY_PUBLIC_CALL_STACK); @@ -1040,7 +1042,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre validate_private_data_propagation(inputs, public_inputs); // this call should have been popped from the public call stack and the stack of call pre images pushed on - for (size_t i = 0; i < PUBLIC_CALL_STACK_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL; i++) { ASSERT_EQ(public_inputs.end.public_call_stack[i], inputs.public_call.call_stack_item.public_inputs.public_call_stack[i]); } diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 6f6ebca9d209..c4e8700a4479 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -42,14 +42,14 @@ constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 4; constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; -constexpr size_t PUBLIC_CALL_STACK_LENGTH = 4; +constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t NEW_L2_TO_L1_MSGS_LENGTH = 2; constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL; constexpr size_t KERNEL_NEW_CONTRACTS_LENGTH = 1; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; -constexpr size_t KERNEL_PUBLIC_CALL_STACK_LENGTH = 8; +constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; constexpr size_t KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; constexpr size_t KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index 4f80dda07ac9..73fdb62e5ceb 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -6,7 +6,7 @@ import { MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PrivateCircuitPublicInputs, READ_REQUESTS_LENGTH, RETURN_VALUES_LENGTH, @@ -127,7 +127,7 @@ export function extractPublicInputs(partialWitness: ACVMWitness, acir: Buffer): const newCommitments = witnessReader.readFieldArray(MAX_NEW_COMMITMENTS_PER_CALL); const newNullifiers = witnessReader.readFieldArray(MAX_NEW_NULLIFIERS_PER_CALL); const privateCallStack = witnessReader.readFieldArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); - const publicCallStack = witnessReader.readFieldArray(PUBLIC_CALL_STACK_LENGTH); + const publicCallStack = witnessReader.readFieldArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); const newL2ToL1Msgs = witnessReader.readFieldArray(NEW_L2_TO_L1_MSGS_LENGTH); const encryptedLogsHash = witnessReader.readFieldArray(NUM_FIELDS_PER_SHA256); diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index fd0672efcf04..f8aa15609b42 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -3,7 +3,7 @@ import { CircuitsWasm, ContractDeploymentData, FunctionData, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PrivateCallStackItem, PublicCallRequest, } from '@aztec/circuits.js'; @@ -192,7 +192,7 @@ export class PrivateFunctionExecution { // TODO(#499): Noir fails to compute the enqueued calls preimages properly, since it cannot use pedersen generators, so we patch those values here. const publicCallStackItems = await Promise.all(enqueuedPublicFunctionCalls.map(c => c.toPublicCallStackItem())); const publicStack = await Promise.all(publicCallStackItems.map(c => computeCallStackItemHash(wasm, c))); - callStackItem.publicInputs.publicCallStack = padArrayEnd(publicStack, Fr.ZERO, PUBLIC_CALL_STACK_LENGTH); + callStackItem.publicInputs.publicCallStack = padArrayEnd(publicStack, Fr.ZERO, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); // TODO: This should be set manually by the circuit publicInputs.contractDeploymentData.deployerPublicKey = diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 4177aa3002d4..114aae966327 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -11,13 +11,13 @@ export const MAX_NEW_NULLIFIERS_PER_CALL = 4; export const NEW_L2_TO_L1_MSGS_LENGTH = 2; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; -export const PUBLIC_CALL_STACK_LENGTH = 4; +export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_NEW_COMMITMENTS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL export const MAX_NEW_NULLIFIERS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL export const KERNEL_NEW_CONTRACTS_LENGTH = 1; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; -export const KERNEL_PUBLIC_CALL_STACK_LENGTH = 8; +export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; export const KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; export const KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; export const KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; 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 1a088817d077..8938bd8ec233 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 @@ -7,7 +7,7 @@ import { MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - KERNEL_PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, NEW_L2_TO_L1_MSGS_LENGTH, @@ -290,7 +290,7 @@ export class CombinedAccumulatedData { /** * Current public call stack. */ - public publicCallStack: Tuple, + public publicCallStack: Tuple, /** * All the new L2 to L1 messages created in this transaction. */ @@ -333,7 +333,7 @@ export class CombinedAccumulatedData { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); - assertMemberLength(this, 'publicCallStack', KERNEL_PUBLIC_CALL_STACK_LENGTH); + assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); assertMemberLength(this, 'newL2ToL1Msgs', KERNEL_NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); @@ -378,7 +378,7 @@ export class CombinedAccumulatedData { reader.readArray(MAX_NEW_COMMITMENTS_PER_TX, Fr), reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), reader.readArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr), - reader.readArray(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr), + reader.readArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Fr), reader.readArray(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr), reader.readArray(2, Fr), reader.readArray(2, Fr), @@ -406,7 +406,7 @@ export class CombinedAccumulatedData { makeTuple(MAX_NEW_COMMITMENTS_PER_TX, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), - makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr.zero), + makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Fr.zero), makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), makeTuple(2, Fr.zero), makeTuple(2, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts index cb676b7cb9fd..22b267cb1a67 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts @@ -6,7 +6,7 @@ import { PublicCallStackItem } from '../call_stack_item.js'; import { KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PUBLIC_DATA_TREE_HEIGHT, } from '../constants.js'; import { MembershipWitness } from '../membership_witness.js'; @@ -82,7 +82,7 @@ export class PublicCallData { /** * Children call stack items. */ - public readonly publicCallStackPreimages: Tuple, + public readonly publicCallStackPreimages: Tuple, /** * Proof of the call stack item execution. */ @@ -96,7 +96,7 @@ export class PublicCallData { */ public readonly bytecodeHash: Fr, ) { - assertMemberLength(this, 'publicCallStackPreimages', PUBLIC_CALL_STACK_LENGTH); + assertMemberLength(this, 'publicCallStackPreimages', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); } toBuffer() { diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index 0a3939af7c07..d1ab3afd7ed0 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -8,7 +8,7 @@ import { MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, READ_REQUESTS_LENGTH, RETURN_VALUES_LENGTH, } from './constants.js'; @@ -110,7 +110,7 @@ export class PrivateCircuitPublicInputs { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); - assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); + assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); @@ -141,7 +141,7 @@ export class PrivateCircuitPublicInputs { frArray(MAX_NEW_COMMITMENTS_PER_CALL), frArray(MAX_NEW_NULLIFIERS_PER_CALL), frArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL), - frArray(PUBLIC_CALL_STACK_LENGTH), + frArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL), frArray(NEW_L2_TO_L1_MSGS_LENGTH), frArray(NUM_FIELDS_PER_SHA256), frArray(NUM_FIELDS_PER_SHA256), diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 06b977688c0a..ace77785fc92 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -12,7 +12,7 @@ import { NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, RETURN_VALUES_LENGTH, } from './constants.js'; @@ -161,7 +161,7 @@ export class PublicCircuitPublicInputs { /** * Public call stack of the current kernel iteration. */ - public publicCallStack: Tuple, + public publicCallStack: Tuple, /** * New commitments created within a public execution call */ @@ -193,7 +193,7 @@ export class PublicCircuitPublicInputs { public proverAddress: AztecAddress, ) { assertMemberLength(this, 'returnValues', RETURN_VALUES_LENGTH); - assertMemberLength(this, 'publicCallStack', PUBLIC_CALL_STACK_LENGTH); + assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); @@ -222,7 +222,7 @@ export class PublicCircuitPublicInputs { makeTuple(RETURN_VALUES_LENGTH, Fr.zero), makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, ContractStorageUpdateRequest.empty), makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, ContractStorageRead.empty), - makeTuple(PUBLIC_CALL_STACK_LENGTH, Fr.zero), + makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, Fr.zero), makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, Fr.zero), makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 5eab6925cb65..b9cb1bfeefc4 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -32,7 +32,7 @@ import { MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - KERNEL_PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, KernelCircuitPublicInputs, @@ -52,7 +52,7 @@ import { MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, PRIVATE_DATA_TREE_HEIGHT, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PUBLIC_DATA_TREE_HEIGHT, Point, PreviousKernelData, @@ -204,7 +204,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), // private call stack must be empty - tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), + tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x400), tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), tupleGenerator(2, fr, seed + 0x600), // encrypted logs hash tupleGenerator(2, fr, seed + 0x700), // unencrypted logs hash @@ -230,7 +230,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated tupleGenerator(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100), tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x300), - tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), + tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x400), tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), tupleGenerator(2, fr, seed + 0x600), // encrypted logs hash tupleGenerator(2, fr, seed + 0x700), // unencrypted logs hash @@ -313,7 +313,7 @@ export function makePublicCircuitPublicInputs( tupleGenerator(RETURN_VALUES_LENGTH, fr, seed + 0x200), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeContractStorageUpdateRequest, seed + 0x400), tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeContractStorageRead, seed + 0x500), - tupleGenerator(PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x600), + tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), tupleGenerator(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x800), tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x900), @@ -470,7 +470,7 @@ export function makePublicCallStackItem(seed = 1, full = false): PublicCallStack export async function makePublicCallData(seed = 1, full = false): Promise { const publicCallData = new PublicCallData( makePublicCallStackItem(seed, full), - makeTuple(PUBLIC_CALL_STACK_LENGTH, makePublicCallStackItem, seed + 0x300), + makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, makePublicCallStackItem, seed + 0x300), makeProof(), fr(seed + 1), fr(seed + 2), @@ -539,7 +539,7 @@ export async function makePublicKernelInputsWithEmptyOutput(seed = 1): Promise

{ TxL2Logs.random(8, 3), // 8 priv function invocations creating 3 encrypted logs each TxL2Logs.random(11, 2), // 8 priv + 3 pub function invocations creating 2 unencrypted logs each [], - times(KERNEL_PUBLIC_CALL_STACK_LENGTH, makePublicCallRequest), + times(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, makePublicCallRequest), ); }; diff --git a/yarn-project/p2p/src/service/tx_messages.test.ts b/yarn-project/p2p/src/service/tx_messages.test.ts index d7743631025f..a70a33ec0db6 100644 --- a/yarn-project/p2p/src/service/tx_messages.test.ts +++ b/yarn-project/p2p/src/service/tx_messages.test.ts @@ -1,4 +1,4 @@ -import { KERNEL_PUBLIC_CALL_STACK_LENGTH, Proof } from '@aztec/circuits.js'; +import { MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Proof } from '@aztec/circuits.js'; import { makeKernelPublicInputs, makePublicCallRequest } from '@aztec/circuits.js/factories'; import { EncodedContractFunction, Tx, TxHash, TxL2Logs } from '@aztec/types'; import { expect } from '@jest/globals'; @@ -20,7 +20,7 @@ import { const makeTx = () => { const encodedPublicFunctions = [EncodedContractFunction.random(), EncodedContractFunction.random()]; - const enqueuedPublicFunctionCalls = times(KERNEL_PUBLIC_CALL_STACK_LENGTH, i => makePublicCallRequest(i)); + const enqueuedPublicFunctionCalls = times(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, i => makePublicCallRequest(i)); return new Tx( makeKernelPublicInputs(), Proof.fromBuffer(Buffer.alloc(10, 9)), diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index 87fc7de24e02..a89f76da4bc5 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -8,7 +8,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, KernelCircuitPublicInputs, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, @@ -154,7 +154,7 @@ describe('sequencer/solo_block_builder', () => { makeEmptyLogs(), makeEmptyLogs(), [], - times(KERNEL_PUBLIC_CALL_STACK_LENGTH, makePublicCallRequest), + times(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, makePublicCallRequest), ), ); diff --git a/yarn-project/sequencer-client/src/mocks/tx.ts b/yarn-project/sequencer-client/src/mocks/tx.ts index 8352e95e393b..ed7456b21c10 100644 --- a/yarn-project/sequencer-client/src/mocks/tx.ts +++ b/yarn-project/sequencer-client/src/mocks/tx.ts @@ -1,4 +1,4 @@ -import { KERNEL_PUBLIC_CALL_STACK_LENGTH, makeEmptyProof } from '@aztec/circuits.js'; +import { MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, makeEmptyProof } from '@aztec/circuits.js'; import { makeKernelPublicInputs, makePublicCallRequest } from '@aztec/circuits.js/factories'; import { FunctionL2Logs, Tx, TxL2Logs } from '@aztec/types'; import times from 'lodash.times'; @@ -21,6 +21,6 @@ export function makeTx(seed = 0) { TxL2Logs.random(2, 3), TxL2Logs.random(3, 0), [], - times(KERNEL_PUBLIC_CALL_STACK_LENGTH, makePublicCallRequest), + times(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, makePublicCallRequest), ); } diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index aff4c1b3cff4..a1c4cce618f6 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -8,7 +8,7 @@ import { FunctionData, GlobalVariables, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, - KERNEL_PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, PUBLIC_DATA_TREE_HEIGHT, Proof, PublicCallRequest, @@ -84,7 +84,7 @@ describe('public_processor', () => { it('skips txs without public execution requests', async function () { const tx = makeTx(); - tx.data.end.publicCallStack = makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, Fr.zero); + tx.data.end.publicCallStack = makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Fr.zero); const hash = await tx.getTxHash(); const [processed, failed] = await processor.process([tx], GlobalVariables.empty()); @@ -132,7 +132,7 @@ describe('public_processor', () => { const callStackHashes = callStackItems.map(call => computeCallStackItemHash(wasm, call)); const kernelOutput = makeKernelPublicInputs(0x10); - kernelOutput.end.publicCallStack = padArrayEnd(callStackHashes, Fr.ZERO, KERNEL_PUBLIC_CALL_STACK_LENGTH); + kernelOutput.end.publicCallStack = padArrayEnd(callStackHashes, Fr.ZERO, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); const tx = new Tx(kernelOutput, proof, TxL2Logs.random(2, 3), TxL2Logs.random(3, 2), [], callRequests); @@ -160,7 +160,7 @@ describe('public_processor', () => { const callStackHash = computeCallStackItemHash(wasm, callStackItem); const kernelOutput = makeKernelPublicInputs(0x10); - kernelOutput.end.publicCallStack = padArrayEnd([callStackHash], Fr.ZERO, KERNEL_PUBLIC_CALL_STACK_LENGTH); + kernelOutput.end.publicCallStack = padArrayEnd([callStackHash], Fr.ZERO, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); kernelOutput.end.privateCallStack = padArrayEnd([], Fr.ZERO, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); const tx = new Tx(kernelOutput, proof, TxL2Logs.random(2, 3), TxL2Logs.random(3, 2), [], [callRequest]); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index f35ac2a1df87..a02925a6a70c 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -13,7 +13,7 @@ import { MAX_NEW_COMMITMENTS_PER_CALL, NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_CALL, - PUBLIC_CALL_STACK_LENGTH, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PreviousKernelData, Proof, PublicCallData, @@ -243,12 +243,12 @@ export class PublicProcessor { protected async getPublicCallStackPreimages(result: PublicExecutionResult) { const nested = result.nestedExecutions; const preimages: PublicCallStackItem[] = await Promise.all(nested.map(n => this.getPublicCallStackItem(n))); - if (preimages.length > PUBLIC_CALL_STACK_LENGTH) { - throw new Error(`Public call stack size exceeded (max ${PUBLIC_CALL_STACK_LENGTH}, got ${preimages.length})`); + if (preimages.length > MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) { + throw new Error(`Public call stack size exceeded (max ${MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL}, got ${preimages.length})`); } // Top of the stack is at the end of the array, so we padStart - return padArrayStart(preimages, PublicCallStackItem.empty(), PUBLIC_CALL_STACK_LENGTH); + return padArrayStart(preimages, PublicCallStackItem.empty(), MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); } protected getBytecodeHash(_result: PublicExecutionResult) { @@ -268,7 +268,7 @@ export class PublicProcessor { */ protected async getPublicCallData( result: PublicExecutionResult, - preimages: Tuple, + preimages: Tuple, isExecutionRequest = false, ) { const bytecodeHash = await this.getBytecodeHash(result); From 9fe15366fc72f90902a604c98d9892dae0efc1fc Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 10:53:41 +0000 Subject: [PATCH 05/14] Rename KERNEL_NEW_CONTRACTS_LENGTH by MAX_NEW_CONTRACTS_PER_TX --- .../circuits/abis/combined_accumulated_data.hpp | 2 +- .../kernel/private/private_kernel_circuit.cpp | 4 ++-- .../src/aztec3/circuits/kernel/public/.test.cpp | 4 ++-- .../circuits/rollup/components/components.cpp | 6 +++--- .../aztec3/circuits/rollup/test_utils/utils.cpp | 2 +- circuits/cpp/src/aztec3/constants.hpp | 2 +- yarn-project/circuits.js/src/structs/constants.ts | 2 +- .../structs/kernel/combined_accumulated_data.ts | 10 +++++----- .../circuits.js/src/structs/rollup/base_rollup.ts | 4 ++-- yarn-project/circuits.js/src/tests/factories.ts | 6 +++--- yarn-project/types/src/l2_block.ts | 14 +++++++------- .../server_world_state_synchroniser.test.ts | 4 ++-- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index f364763d1409..821374f5d9db 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -40,7 +40,7 @@ template struct CombinedAccumulatedData { fr encrypted_log_preimages_length = 0; fr unencrypted_log_preimages_length = 0; - std::array, KERNEL_NEW_CONTRACTS_LENGTH> new_contracts{}; + std::array, MAX_NEW_CONTRACTS_PER_TX> new_contracts{}; std::array, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH> optionally_revealed_data{}; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp index fb864602187e..12e7087c2369 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp @@ -144,8 +144,8 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne .function_tree_root = contract_deployment_data.function_tree_root, }; - array_push, KERNEL_NEW_CONTRACTS_LENGTH>(public_inputs.end.new_contracts, - new_contract_data); + array_push, MAX_NEW_CONTRACTS_PER_TX>(public_inputs.end.new_contracts, + new_contract_data); } { // commitments, nullifiers, and contracts diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 1140f980fcb6..10fe0ddf25ce 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -402,7 +402,7 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat .unencrypted_logs_hash = array_of_values(seed, NUM_FIELDS_PER_SHA256), .encrypted_log_preimages_length = private_previous ? ++seed : 0, .unencrypted_log_preimages_length = ++seed, - .new_contracts = std::array, KERNEL_NEW_CONTRACTS_LENGTH>(), + .new_contracts = std::array, MAX_NEW_CONTRACTS_PER_TX>(), .optionally_revealed_data = std::array, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH>(), .public_data_update_requests = std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(), @@ -468,7 +468,7 @@ void validate_private_data_propagation(const PublicKernelInputs& inputs, public_inputs.end.private_call_stack)); ASSERT_TRUE(source_arrays_are_in_target(inputs.previous_kernel.public_inputs.end.new_contracts, - std::array, KERNEL_NEW_CONTRACTS_LENGTH>(), + std::array, MAX_NEW_CONTRACTS_PER_TX>(), public_inputs.end.new_contracts)); ASSERT_EQ(inputs.previous_kernel.public_inputs.end.encrypted_logs_hash, diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index 2ff413a04463..dc28a77d04e9 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -112,7 +112,7 @@ std::array compute_kernels_calldata_hash( // 2 unencrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes auto const number_of_inputs = (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + KERNEL_NEW_CONTRACTS_LENGTH * 3 + + KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + MAX_NEW_CONTRACTS_PER_TX * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256) * 2; @@ -154,13 +154,13 @@ std::array compute_kernels_calldata_hash( auto const contract_leaf = kernel_data[i].public_inputs.end.new_contracts[0]; calldata_hash_inputs[offset + i] = contract_leaf.hash(); - offset += KERNEL_NEW_CONTRACTS_LENGTH * 2; + offset += MAX_NEW_CONTRACTS_PER_TX * 2; auto new_contracts = kernel_data[i].public_inputs.end.new_contracts; calldata_hash_inputs[offset + i * 2] = new_contracts[0].contract_address; calldata_hash_inputs[offset + i * 2 + 1] = new_contracts[0].portal_contract_address; - offset += KERNEL_NEW_CONTRACTS_LENGTH * 2 * 2; + offset += MAX_NEW_CONTRACTS_PER_TX * 2 * 2; for (size_t j = 0; j < NUM_FIELDS_PER_SHA256; j++) { calldata_hash_inputs[offset + i * 2 + j] = encryptedLogsHash[j]; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index 594504f9ecd9..5ceb59f80e5d 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -53,7 +53,7 @@ std::vector get_empty_calldata_leaf() { auto const number_of_inputs = (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + KERNEL_NEW_CONTRACTS_LENGTH * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + + KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + MAX_NEW_CONTRACTS_PER_TX * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * 2) * 2; diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index c4e8700a4479..0bead898b305 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -47,7 +47,7 @@ constexpr size_t NEW_L2_TO_L1_MSGS_LENGTH = 2; constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL; -constexpr size_t KERNEL_NEW_CONTRACTS_LENGTH = 1; +constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 114aae966327..af313ce78661 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -15,7 +15,7 @@ export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_NEW_COMMITMENTS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL export const MAX_NEW_NULLIFIERS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL -export const KERNEL_NEW_CONTRACTS_LENGTH = 1; +export const MAX_NEW_CONTRACTS_PER_TX = 1; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; export const KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; 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 8938bd8ec233..9bffb4619993 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 @@ -3,7 +3,7 @@ import { AggregationObject } from '../aggregation_object.js'; import { KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_CONTRACTS_LENGTH, + MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, @@ -316,7 +316,7 @@ export class CombinedAccumulatedData { /** * All the new contracts deployed in this transaction. */ - public newContracts: Tuple, + public newContracts: Tuple, /** * All the optionally revealed data in this transaction. */ @@ -337,7 +337,7 @@ export class CombinedAccumulatedData { assertMemberLength(this, 'newL2ToL1Msgs', KERNEL_NEW_L2_TO_L1_MSGS_LENGTH); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); - assertMemberLength(this, 'newContracts', KERNEL_NEW_CONTRACTS_LENGTH); + assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); assertMemberLength(this, 'optionallyRevealedData', KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH); assertMemberLength(this, 'publicDataUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); assertMemberLength(this, 'publicDataReads', KERNEL_PUBLIC_DATA_READS_LENGTH); @@ -384,7 +384,7 @@ export class CombinedAccumulatedData { reader.readArray(2, Fr), reader.readFr(), reader.readFr(), - reader.readArray(KERNEL_NEW_CONTRACTS_LENGTH, NewContractData), + reader.readArray(MAX_NEW_CONTRACTS_PER_TX, NewContractData), reader.readArray(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, OptionallyRevealedData), reader.readArray(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataUpdateRequest), reader.readArray(KERNEL_PUBLIC_DATA_READS_LENGTH, PublicDataRead), @@ -412,7 +412,7 @@ export class CombinedAccumulatedData { makeTuple(2, Fr.zero), Fr.zero(), Fr.zero(), - makeTuple(KERNEL_NEW_CONTRACTS_LENGTH, NewContractData.empty), + makeTuple(MAX_NEW_CONTRACTS_PER_TX, NewContractData.empty), makeTuple(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, OptionallyRevealedData.empty), makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataUpdateRequest.empty), makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, PublicDataRead.empty), diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 1c3cfba867af..a930067d8b46 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -6,7 +6,7 @@ import { CONTRACT_TREE_HEIGHT, CONTRACT_TREE_ROOTS_TREE_HEIGHT, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_CONTRACTS_LENGTH, + MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -139,7 +139,7 @@ export class BaseRollupInputs { /** * Height of the contract subtree which is to be inserted into the contract tree. */ - public static CONTRACT_SUBTREE_HEIGHT = Math.log2(KERNEL_NEW_CONTRACTS_LENGTH * 2); + public static CONTRACT_SUBTREE_HEIGHT = Math.log2(MAX_NEW_CONTRACTS_PER_TX * 2); /** * Height of the nullifier subtree which is to be inserted into the nullifier tree. */ diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index b9cb1bfeefc4..288c5fbdccc3 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -27,7 +27,7 @@ import { FunctionData, G1AffineElement, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_CONTRACTS_LENGTH, + MAX_NEW_CONTRACTS_PER_TX, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, @@ -210,7 +210,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu tupleGenerator(2, fr, seed + 0x700), // unencrypted logs hash fr(seed + 0x800), // encrypted_log_preimages_length fr(seed + 0x900), // unencrypted_log_preimages_length - tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0xa00), + tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0xb00), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0xc00), tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeEmptyPublicDataRead, seed + 0xd00), @@ -236,7 +236,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated tupleGenerator(2, fr, seed + 0x700), // unencrypted logs hash fr(seed + 0x800), // encrypted_log_preimages_length fr(seed + 0x900), // unencrypted_log_preimages_length - tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0xa00), + tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0xb00), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0xc00), tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, seed + 0xd00), diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index 8fe27d3afa69..f7225974b5ca 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -1,7 +1,7 @@ import { AppendOnlyTreeSnapshot, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_CONTRACTS_LENGTH, + MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, @@ -178,8 +178,8 @@ export class L2Block { ): L2Block { const newNullifiers = times(MAX_NEW_NULLIFIERS_PER_TX * txsPerBlock, Fr.random); const newCommitments = times(MAX_NEW_COMMITMENTS_PER_TX * txsPerBlock, Fr.random); - const newContracts = times(KERNEL_NEW_CONTRACTS_LENGTH * txsPerBlock, Fr.random); - const newContractData = times(KERNEL_NEW_CONTRACTS_LENGTH * txsPerBlock, ContractData.random); + const newContracts = times(MAX_NEW_CONTRACTS_PER_TX * txsPerBlock, Fr.random); + const newContractData = times(MAX_NEW_CONTRACTS_PER_TX * txsPerBlock, ContractData.random); const newPublicDataWrites = times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * txsPerBlock, PublicDataWrite.random); const newL1ToL2Messages = times(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, Fr.random); const newL2ToL1Msgs = times(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr.random); @@ -699,12 +699,12 @@ export class L2Block { KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * (txIndex + 1), ); const newContracts = this.newContracts.slice( - KERNEL_NEW_CONTRACTS_LENGTH * txIndex, - KERNEL_NEW_CONTRACTS_LENGTH * (txIndex + 1), + MAX_NEW_CONTRACTS_PER_TX * txIndex, + MAX_NEW_CONTRACTS_PER_TX * (txIndex + 1), ); const newContractData = this.newContractData.slice( - KERNEL_NEW_CONTRACTS_LENGTH * txIndex, - KERNEL_NEW_CONTRACTS_LENGTH * (txIndex + 1), + MAX_NEW_CONTRACTS_PER_TX * txIndex, + MAX_NEW_CONTRACTS_PER_TX * (txIndex + 1), ); return new L2Tx(newCommitments, newNullifiers, newPublicDataWrites, newL2ToL1Msgs, newContracts, newContractData); diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts index 6f1c9aa5a185..1ea4d7b55920 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts @@ -3,7 +3,7 @@ import { CircuitsWasm, GlobalVariables, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_CONTRACTS_LENGTH, + MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, NEW_L2_TO_L1_MSGS_LENGTH, @@ -81,7 +81,7 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = newCommitments: times(MAX_NEW_COMMITMENTS_PER_TX, Fr.random), newNullifiers: times(MAX_NEW_NULLIFIERS_PER_TX, Fr.random), newContracts: newContractsCommitments?.map(x => Fr.fromBuffer(x)) ?? [Fr.random()], - newContractData: times(KERNEL_NEW_CONTRACTS_LENGTH, getMockContractData), + newContractData: times(MAX_NEW_CONTRACTS_PER_TX, getMockContractData), newPublicDataWrites: times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataWrite.random), newL1ToL2Messages: getMockL1ToL2MessagesData(), newL2ToL1Msgs: times(NEW_L2_TO_L1_MSGS_LENGTH, Fr.random), From 356de78f254f074d53563a3c15aa7c4a5aa78d3b Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 10:56:26 +0000 Subject: [PATCH 06/14] 972 - rename constants related to L2_TO_L1_MSGS --- .../abis/combined_accumulated_data.hpp | 2 +- .../abis/private_circuit_public_inputs.hpp | 6 ++--- .../call_context_reconciliation_data.hpp | 4 ++-- .../abis/public_circuit_public_inputs.hpp | 2 +- .../aztec3/circuits/kernel/private/common.cpp | 2 +- .../kernel/private/private_kernel_circuit.cpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 24 +++++++++---------- .../aztec3/circuits/kernel/public/common.hpp | 2 +- .../circuits/rollup/components/components.cpp | 8 +++---- .../src/aztec3/circuits/rollup/root/.test.cpp | 6 ++--- .../circuits/rollup/test_utils/utils.cpp | 2 +- circuits/cpp/src/aztec3/constants.hpp | 4 ++-- .../acir-simulator/src/acvm/deserialize.ts | 4 ++-- .../circuits.js/src/structs/constants.ts | 4 ++-- .../kernel/combined_accumulated_data.ts | 12 +++++----- .../structs/private_circuit_public_inputs.ts | 6 ++--- .../structs/public_circuit_public_inputs.ts | 8 +++---- .../circuits.js/src/tests/factories.ts | 12 +++++----- .../src/integration_l1_publisher.test.ts | 4 ++-- .../block_builder/solo_block_builder.test.ts | 4 ++-- .../src/sequencer/public_processor.ts | 4 ++-- yarn-project/types/src/l2_block.ts | 10 ++++---- .../server_world_state_synchroniser.test.ts | 4 ++-- 23 files changed, 68 insertions(+), 68 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index 821374f5d9db..a1812fc4ade5 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -30,7 +30,7 @@ template struct CombinedAccumulatedData { std::array private_call_stack{}; std::array public_call_stack{}; - std::array new_l2_to_l1_msgs{}; + std::array new_l2_to_l1_msgs{}; std::array encrypted_logs_hash{}; std::array unencrypted_logs_hash{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp index c842568d0abb..b80438208fbe 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_circuit_public_inputs.hpp @@ -34,7 +34,7 @@ template class PrivateCircuitPublicInputs { std::array private_call_stack{}; std::array public_call_stack{}; - std::array new_l2_to_l1_msgs{}; + std::array new_l2_to_l1_msgs{}; std::array encrypted_logs_hash{}; std::array unencrypted_logs_hash{}; @@ -308,7 +308,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array private_call_stack; std::array public_call_stack; - std::array new_l2_to_l1_msgs; + std::array new_l2_to_l1_msgs; std::array encrypted_logs_hash; std::array unencrypted_logs_hash; @@ -341,7 +341,7 @@ template class OptionalPrivateCircuitPublicInputs { std::array const& private_call_stack, std::array const& public_call_stack, - std::array const& new_l2_to_l1_msgs, + std::array const& new_l2_to_l1_msgs, std::array const& encrypted_logs_hash, std::array const& unencrypted_logs_hash, diff --git a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp index 7964edf7fd6e..7889c49b6419 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/private_kernel/call_context_reconciliation_data.hpp @@ -30,8 +30,8 @@ // // std::array contract_deployment_call_stack; -// std::array, NEW_L2_TO_L1_MSGS_LENGTH> l1_call_contexts; -// std::array l1_counterparts; // TODO: this is probably wrong. +// std::array, MAX_NEW_L2_TO_L1_MSGS_PER_CALL> l1_call_contexts; +// std::array l1_counterparts; // TODO: this is probably wrong. // template // CallContextReconciliationData> to_circuit_type(Builder& builder) const diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index a65115b0dd55..09e07ef6924f 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -33,7 +33,7 @@ template struct PublicCircuitPublicInputs { std::array public_call_stack{}; std::array new_commitments{}; std::array new_nullifiers{}; - std::array new_l2_to_l1_msgs{}; + std::array new_l2_to_l1_msgs{}; std::array unencrypted_logs_hash{}; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index f51355c1df5b..b5200a4e784b 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -168,7 +168,7 @@ void common_update_end_values(DummyBuilder& builder, { // new l2 to l1 messages const auto& portal_contract_address = private_call.portal_contract_address; const auto& new_l2_to_l1_msgs = private_call_public_inputs.new_l2_to_l1_msgs; - std::array new_l2_to_l1_msgs_to_insert{}; + std::array new_l2_to_l1_msgs_to_insert{}; for (size_t i = 0; i < new_l2_to_l1_msgs.size(); ++i) { if (!new_l2_to_l1_msgs[i].is_zero()) { new_l2_to_l1_msgs_to_insert[i] = compute_l2_to_l1_hash(storage_contract_address, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp index 12e7087c2369..77a6f9549a6a 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/private_kernel_circuit.cpp @@ -173,7 +173,7 @@ void update_end_values(PrivateKernelInputsInner const& private_inputs, Kerne // { // const auto& new_l2_to_l1_msgs = private_call_public_inputs.new_l2_to_l1_msgs; - // std::array l1_call_stack; + // std::array l1_call_stack; // for (size_t i = 0; i < new_l2_to_l1_msgs.size(); ++i) { // l1_call_stack[i] = CT::fr::conditional_assign( diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 10fe0ddf25ce..887d37f266cb 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -129,8 +129,8 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, array_of_values(count); std::array const new_nullifiers = array_of_values(count); - std::array const new_l2_to_l1_msgs = - array_of_values(count); + std::array const new_l2_to_l1_msgs = + array_of_values(count); std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const reads = generate_contract_storage_reads(count); std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const update_requests = @@ -232,15 +232,15 @@ std::array new_nullifiers_as_siloed_nullifiers( return siloed_nullifiers; } -std::array new_l2_messages_from_message( - std::array const& new_messages, +std::array new_l2_messages_from_message( + std::array const& new_messages, NT::fr const& contract_address, fr const& portal_contract_address, fr const& chain_id, fr const& version) { - std::array formatted_msgs{}; - for (size_t i = 0; i < NEW_L2_TO_L1_MSGS_LENGTH; ++i) { + std::array formatted_msgs{}; + for (size_t i = 0; i < MAX_NEW_L2_TO_L1_MSGS_PER_CALL; ++i) { if (!new_messages[i].is_zero()) { formatted_msgs[i] = compute_l2_to_l1_hash( contract_address, version, portal_contract_address, chain_id, new_messages[i]); @@ -323,8 +323,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat array_of_values(seed, MAX_NEW_COMMITMENTS_PER_CALL / 2); std::array const new_nullifiers = array_of_values(seed, MAX_NEW_NULLIFIERS_PER_CALL / 2); - std::array const new_l2_to_l1_msgs = - array_of_values(seed, NEW_L2_TO_L1_MSGS_LENGTH / 2); + std::array const new_l2_to_l1_msgs = + array_of_values(seed, MAX_NEW_L2_TO_L1_MSGS_PER_CALL / 2); std::array const unencrypted_logs_hash = array_of_values(seed, NUM_FIELDS_PER_SHA256); fr const unencrypted_log_preimages_length = ++seed; @@ -395,8 +395,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat array_of_values(seed, private_previous ? MAX_NEW_NULLIFIERS_PER_TX / 2 : 0), .private_call_stack = array_of_values(seed, 0), .public_call_stack = public_call_stack, - .new_l2_to_l1_msgs = array_of_values( - seed, private_previous ? KERNEL_NEW_L2_TO_L1_MSGS_LENGTH / 2 : 0), + .new_l2_to_l1_msgs = array_of_values( + seed, private_previous ? MAX_NEW_L2_TO_L1_MSGS_PER_TX / 2 : 0), .encrypted_logs_hash = array_of_values( seed, private_previous ? 2 : 0), // only private kernel is producing encrypted logs .unencrypted_logs_hash = array_of_values(seed, NUM_FIELDS_PER_SHA256), @@ -1032,7 +1032,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre inputs.previous_kernel.public_inputs.end.new_nullifiers = initial_nullifiers; // setup 1 new l2 to l1 messages - std::array initial_l2_to_l1_messages{}; + std::array initial_l2_to_l1_messages{}; initial_l2_to_l1_messages[0] = fr(1); inputs.previous_kernel.public_inputs.end.new_l2_to_l1_msgs = initial_l2_to_l1_messages; @@ -1120,7 +1120,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre fr const chain_id = inputs.previous_kernel.public_inputs.constants.tx_context.chain_id; fr const version = inputs.previous_kernel.public_inputs.constants.tx_context.version; - std::array const expected_new_messages = + std::array const expected_new_messages = new_l2_messages_from_message(inputs.public_call.call_stack_item.public_inputs.new_l2_to_l1_msgs, contract_address, portal_contract_address, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index 99b886ebe760..f2ecbf8cb971 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -345,7 +345,7 @@ void propagate_new_l2_to_l1_messages(Builder& builder, const auto& storage_contract_address = public_call_public_inputs.call_context.storage_contract_address; const auto& new_l2_to_l1_msgs = public_call_public_inputs.new_l2_to_l1_msgs; - std::array new_l2_to_l1_msgs_to_insert{}; + std::array new_l2_to_l1_msgs_to_insert{}; for (size_t i = 0; i < new_l2_to_l1_msgs.size(); ++i) { if (!new_l2_to_l1_msgs[i].is_zero()) { const auto chain_id = public_kernel_inputs.previous_kernel.public_inputs.constants.tx_context.chain_id; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index dc28a77d04e9..8c3577bbdd1b 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -112,7 +112,7 @@ std::array compute_kernels_calldata_hash( // 2 unencrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes auto const number_of_inputs = (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + MAX_NEW_CONTRACTS_PER_TX * 3 + + MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256) * 2; @@ -146,10 +146,10 @@ std::array compute_kernels_calldata_hash( } offset += KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 * 2; - for (size_t j = 0; j < KERNEL_NEW_L2_TO_L1_MSGS_LENGTH; j++) { - calldata_hash_inputs[offset + i * KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + j] = newL2ToL1msgs[j]; + for (size_t j = 0; j < MAX_NEW_L2_TO_L1_MSGS_PER_TX; j++) { + calldata_hash_inputs[offset + i * MAX_NEW_L2_TO_L1_MSGS_PER_TX + j] = newL2ToL1msgs[j]; } - offset += KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * 2; + offset += MAX_NEW_L2_TO_L1_MSGS_PER_TX * 2; auto const contract_leaf = kernel_data[i].public_inputs.end.new_contracts[0]; calldata_hash_inputs[offset + i] = contract_leaf.hash(); diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp index b4005c76c7e2..678bed199ceb 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp @@ -191,9 +191,9 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic) } kernels[kernel_j].public_inputs.end.new_commitments = new_commitments; - std::array new_l2_to_l1_messages; - for (uint8_t i = 0; i < KERNEL_NEW_L2_TO_L1_MSGS_LENGTH; i++) { - auto val = fr(kernel_j * KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + i + 1); + std::array new_l2_to_l1_messages; + for (uint8_t i = 0; i < MAX_NEW_L2_TO_L1_MSGS_PER_TX; i++) { + auto val = fr(kernel_j * MAX_NEW_L2_TO_L1_MSGS_PER_TX + i + 1); new_l2_to_l1_messages[i] = val; } kernels[kernel_j].public_inputs.end.new_l2_to_l1_msgs = new_l2_to_l1_messages; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index 5ceb59f80e5d..a3f5a15d24e3 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -53,7 +53,7 @@ std::vector get_empty_calldata_leaf() { auto const number_of_inputs = (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH + MAX_NEW_CONTRACTS_PER_TX * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + + MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * 2) * 2; diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 0bead898b305..09a0dde22c0f 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -43,14 +43,14 @@ constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; -constexpr size_t NEW_L2_TO_L1_MSGS_LENGTH = 2; +constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL; constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; -constexpr size_t KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; +constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; constexpr size_t KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; constexpr size_t KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; constexpr size_t KERNEL_PUBLIC_DATA_READS_LENGTH = 4; diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index 73fdb62e5ceb..36b38e4eabc0 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -2,7 +2,7 @@ import { CallContext, ContractDeploymentData, MAX_NEW_COMMITMENTS_PER_CALL, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, @@ -128,7 +128,7 @@ export function extractPublicInputs(partialWitness: ACVMWitness, acir: Buffer): const newNullifiers = witnessReader.readFieldArray(MAX_NEW_NULLIFIERS_PER_CALL); const privateCallStack = witnessReader.readFieldArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); const publicCallStack = witnessReader.readFieldArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); - const newL2ToL1Msgs = witnessReader.readFieldArray(NEW_L2_TO_L1_MSGS_LENGTH); + const newL2ToL1Msgs = witnessReader.readFieldArray(MAX_NEW_L2_TO_L1_MSGS_PER_CALL); const encryptedLogsHash = witnessReader.readFieldArray(NUM_FIELDS_PER_SHA256); const unencryptedLogsHash = witnessReader.readFieldArray(NUM_FIELDS_PER_SHA256); diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index af313ce78661..29defbff5e3f 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -8,7 +8,7 @@ export const READ_REQUESTS_LENGTH = 4; export const MAX_NEW_COMMITMENTS_PER_CALL = 4; export const MAX_NEW_NULLIFIERS_PER_CALL = 4; -export const NEW_L2_TO_L1_MSGS_LENGTH = 2; +export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; @@ -18,7 +18,7 @@ export const MAX_NEW_NULLIFIERS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PE export const MAX_NEW_CONTRACTS_PER_TX = 1; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; -export const KERNEL_NEW_L2_TO_L1_MSGS_LENGTH = 2; +export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; export const KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; export const KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; export const KERNEL_PUBLIC_DATA_READS_LENGTH = 4; 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 9bffb4619993..62a0e89464b1 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 @@ -1,7 +1,7 @@ import { serializeToBuffer } from '../../utils/serialize.js'; import { AggregationObject } from '../aggregation_object.js'; import { - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, @@ -10,7 +10,7 @@ import { MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, NUM_FIELDS_PER_SHA256, } from '../constants.js'; import { FunctionData } from '../function_data.js'; @@ -294,7 +294,7 @@ export class CombinedAccumulatedData { /** * All the new L2 to L1 messages created in this transaction. */ - public newL2ToL1Msgs: Tuple, + public newL2ToL1Msgs: Tuple, /** * Accumulated encrypted logs hash from all the previous kernel iterations. * Note: Represented as a tuple of 2 fields in order to fit in all of the 256 bits of sha256 hash. @@ -334,7 +334,7 @@ export class CombinedAccumulatedData { assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX); assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX); - assertMemberLength(this, 'newL2ToL1Msgs', KERNEL_NEW_L2_TO_L1_MSGS_LENGTH); + assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_TX); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); @@ -379,7 +379,7 @@ export class CombinedAccumulatedData { reader.readArray(MAX_NEW_NULLIFIERS_PER_TX, Fr), reader.readArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr), reader.readArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Fr), - reader.readArray(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr), + reader.readArray(MAX_NEW_L2_TO_L1_MSGS_PER_TX, Fr), reader.readArray(2, Fr), reader.readArray(2, Fr), reader.readFr(), @@ -407,7 +407,7 @@ export class CombinedAccumulatedData { makeTuple(MAX_NEW_NULLIFIERS_PER_TX, Fr.zero), makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, Fr.zero), - makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), + makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, Fr.zero), makeTuple(2, Fr.zero), makeTuple(2, Fr.zero), Fr.zero(), diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index d1ab3afd7ed0..f6bc57c0ca94 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -4,7 +4,7 @@ import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { MAX_NEW_COMMITMENTS_PER_CALL, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, @@ -111,7 +111,7 @@ export class PrivateCircuitPublicInputs { assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'privateCallStack', MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL); assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); - assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); + assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); } @@ -142,7 +142,7 @@ export class PrivateCircuitPublicInputs { frArray(MAX_NEW_NULLIFIERS_PER_CALL), frArray(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL), frArray(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL), - frArray(NEW_L2_TO_L1_MSGS_LENGTH), + frArray(MAX_NEW_L2_TO_L1_MSGS_PER_CALL), frArray(NUM_FIELDS_PER_SHA256), frArray(NUM_FIELDS_PER_SHA256), Fr.ZERO, diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index ace77785fc92..cfe0cb6ee237 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -9,7 +9,7 @@ import { KERNEL_PUBLIC_DATA_READS_LENGTH, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, MAX_NEW_COMMITMENTS_PER_CALL, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, NUM_FIELDS_PER_SHA256, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, @@ -173,7 +173,7 @@ export class PublicCircuitPublicInputs { /** * New L2 to L1 messages generated during the call. */ - public newL2ToL1Msgs: Tuple, + public newL2ToL1Msgs: Tuple, /** * Hash of the unencrypted logs emitted in this function call. * Note: Represented as an array of 2 fields in order to fit in all of the 256 bits of sha256 hash. @@ -196,7 +196,7 @@ export class PublicCircuitPublicInputs { assertMemberLength(this, 'publicCallStack', MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); - assertMemberLength(this, 'newL2ToL1Msgs', NEW_L2_TO_L1_MSGS_LENGTH); + assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); assertMemberLength(this, 'contractStorageUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); assertMemberLength(this, 'contractStorageReads', KERNEL_PUBLIC_DATA_READS_LENGTH); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); @@ -225,7 +225,7 @@ export class PublicCircuitPublicInputs { makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, Fr.zero), makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, Fr.zero), - makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, Fr.zero), + makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, Fr.zero), makeTuple(2, Fr.zero), Fr.ZERO, Fr.ZERO, diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 288c5fbdccc3..727c41044497 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -28,7 +28,7 @@ import { G1AffineElement, MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, @@ -41,7 +41,7 @@ import { MembershipWitness, MergeRollupInputs, MAX_NEW_COMMITMENTS_PER_CALL, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, NULLIFIER_TREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, @@ -205,7 +205,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, Fr.zero), // private call stack must be empty tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x400), - tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), + tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x500), tupleGenerator(2, fr, seed + 0x600), // encrypted logs hash tupleGenerator(2, fr, seed + 0x700), // unencrypted logs hash fr(seed + 0x800), // encrypted_log_preimages_length @@ -231,7 +231,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated tupleGenerator(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200), tupleGenerator(MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x300), tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, fr, seed + 0x400), - tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), + tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x500), tupleGenerator(2, fr, seed + 0x600), // encrypted logs hash tupleGenerator(2, fr, seed + 0x700), // unencrypted logs hash fr(seed + 0x800), // encrypted_log_preimages_length @@ -316,7 +316,7 @@ export function makePublicCircuitPublicInputs( tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), tupleGenerator(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x800), - tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x900), + tupleGenerator(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, fr, seed + 0x900), tupleGenerator(2, fr, seed + 0x901), fr(seed + 0x902), fr(seed + 0xa00), @@ -614,7 +614,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn newNullifiers: makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x500), privateCallStack: makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), publicCallStack: makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x700), - newL2ToL1Msgs: makeTuple(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x800), + newL2ToL1Msgs: makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, fr, seed + 0x800), encryptedLogsHash: makeTuple(NUM_FIELDS_PER_SHA256, fr, seed + 0x900), unencryptedLogsHash: makeTuple(NUM_FIELDS_PER_SHA256, fr, seed + 0xa00), encryptedLogPreimagesLength: fr(seed + 0xb00), 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 b51a5d576431..06188ee94292 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 @@ -3,7 +3,7 @@ import { AztecAddress, GlobalVariables, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, KernelCircuitPublicInputs, @@ -174,7 +174,7 @@ describe('L1Publisher integration', () => { processedTx.data.end.newCommitments = makeTuple(MAX_NEW_COMMITMENTS_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(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x300); + processedTx.data.end.newL2ToL1Msgs = makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x300); processedTx.data.end.newContracts = [makeNewContractData(seed + 0x1000)]; processedTx.data.end.encryptedLogsHash = to2Fields(L2Block.computeKernelLogsHash(processedTx.encryptedLogs)); processedTx.data.end.unencryptedLogsHash = to2Fields(L2Block.computeKernelLogsHash(processedTx.unencryptedLogs)); diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index a89f76da4bc5..bf87c17db0a3 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -6,7 +6,7 @@ import { Fr, GlobalVariables, MAX_NEW_COMMITMENTS_PER_TX, - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, @@ -302,7 +302,7 @@ describe('sequencer/solo_block_builder', () => { processedTx.data.end.newCommitments = makeTuple(MAX_NEW_COMMITMENTS_PER_TX, fr, seed + 0x100); processedTx.data.end.newNullifiers = makeTuple(MAX_NEW_NULLIFIERS_PER_TX, fr, seed + 0x200); processedTx.data.end.newNullifiers[tx.data.end.newNullifiers.length - 1] = Fr.ZERO; - processedTx.data.end.newL2ToL1Msgs = makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x300); + processedTx.data.end.newL2ToL1Msgs = makeTuple(MAX_NEW_L2_TO_L1_MSGS_PER_TX, fr, seed + 0x300); processedTx.data.end.newContracts = [makeNewContractData(seed + 0x1000)]; processedTx.data.end.encryptedLogsHash = to2Fields(L2Block.computeKernelLogsHash(processedTx.encryptedLogs)); processedTx.data.end.unencryptedLogsHash = to2Fields(L2Block.computeKernelLogsHash(processedTx.unencryptedLogs)); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index a02925a6a70c..e2582bda90d4 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -11,7 +11,7 @@ import { KernelCircuitPublicInputs, MembershipWitness, MAX_NEW_COMMITMENTS_PER_CALL, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PreviousKernelData, @@ -212,7 +212,7 @@ export class PublicProcessor { argsHash: await computeVarArgsHash(wasm, result.execution.args), newCommitments: padArrayEnd(result.newCommitments, Fr.ZERO, MAX_NEW_COMMITMENTS_PER_CALL), newNullifiers: padArrayEnd(result.newNullifiers, Fr.ZERO, MAX_NEW_NULLIFIERS_PER_CALL), - newL2ToL1Msgs: padArrayEnd(result.newL2ToL1Messages, Fr.ZERO, NEW_L2_TO_L1_MSGS_LENGTH), + newL2ToL1Msgs: padArrayEnd(result.newL2ToL1Messages, Fr.ZERO, MAX_NEW_L2_TO_L1_MSGS_PER_CALL), returnValues: padArrayEnd(result.returnValues, Fr.ZERO, RETURN_VALUES_LENGTH), contractStorageReads: padArrayEnd( result.contractStorageReads, diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index f7225974b5ca..2cf6c922aa2f 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -5,7 +5,7 @@ import { MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_TX, GlobalVariables, } from '@aztec/circuits.js'; import { makeAppendOnlyTreeSnapshot, makeGlobalVariables } from '@aztec/circuits.js/factories'; @@ -182,7 +182,7 @@ export class L2Block { const newContractData = times(MAX_NEW_CONTRACTS_PER_TX * txsPerBlock, ContractData.random); const newPublicDataWrites = times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * txsPerBlock, PublicDataWrite.random); const newL1ToL2Messages = times(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, Fr.random); - const newL2ToL1Msgs = times(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, Fr.random); + const newL2ToL1Msgs = times(MAX_NEW_L2_TO_L1_MSGS_PER_TX, Fr.random); const newEncryptedLogs = L2BlockL2Logs.random(txsPerBlock, numPrivateFunctionCalls, numEncryptedLogs); const newUnencryptedLogs = L2BlockL2Logs.random(txsPerBlock, numPublicFunctionCalls, numUnencryptedLogs); @@ -618,7 +618,7 @@ export class L2Block { const commitmentsPerBase = MAX_NEW_COMMITMENTS_PER_TX * 2; const nullifiersPerBase = MAX_NEW_NULLIFIERS_PER_TX * 2; const publicDataUpdateRequestsPerBase = KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2; - const l2ToL1MsgsPerBase = KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * 2; + const l2ToL1MsgsPerBase = MAX_NEW_L2_TO_L1_MSGS_PER_TX * 2; const commitmentsBuffer = Buffer.concat( this.newCommitments.slice(i * commitmentsPerBase, (i + 1) * commitmentsPerBase).map(x => x.toBuffer()), ); @@ -695,8 +695,8 @@ export class L2Block { KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * (txIndex + 1), ); const newL2ToL1Msgs = this.newL2ToL1Msgs.slice( - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * txIndex, - KERNEL_NEW_L2_TO_L1_MSGS_LENGTH * (txIndex + 1), + MAX_NEW_L2_TO_L1_MSGS_PER_TX * txIndex, + MAX_NEW_L2_TO_L1_MSGS_PER_TX * (txIndex + 1), ); const newContracts = this.newContracts.slice( MAX_NEW_CONTRACTS_PER_TX * txIndex, diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts index 1ea4d7b55920..bd436bc3c976 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts @@ -6,7 +6,7 @@ import { MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, - NEW_L2_TO_L1_MSGS_LENGTH, + MAX_NEW_L2_TO_L1_MSGS_PER_CALL, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, } from '@aztec/circuits.js'; import { INITIAL_LEAF, Pedersen, SiblingPath } from '@aztec/merkle-tree'; @@ -84,7 +84,7 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = newContractData: times(MAX_NEW_CONTRACTS_PER_TX, getMockContractData), newPublicDataWrites: times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataWrite.random), newL1ToL2Messages: getMockL1ToL2MessagesData(), - newL2ToL1Msgs: times(NEW_L2_TO_L1_MSGS_LENGTH, Fr.random), + newL2ToL1Msgs: times(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, Fr.random), newEncryptedLogs, }); return block; From 2b262cfb909685db6a53290a1c9d087433aa0e9c Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 11:10:48 +0000 Subject: [PATCH 07/14] 972 - rename KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH into MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX --- .../aztec3/circuits/abis/combined_accumulated_data.hpp | 2 +- .../cpp/src/aztec3/circuits/kernel/public/.test.cpp | 3 ++- circuits/cpp/src/aztec3/constants.hpp | 2 +- yarn-project/circuits.js/src/structs/constants.ts | 2 +- .../src/structs/kernel/combined_accumulated_data.ts | 10 +++++----- yarn-project/circuits.js/src/tests/factories.ts | 6 +++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index a1812fc4ade5..28207a72cfc2 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -42,7 +42,7 @@ template struct CombinedAccumulatedData { std::array, MAX_NEW_CONTRACTS_PER_TX> new_contracts{}; - std::array, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH> optionally_revealed_data{}; + std::array, MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX> optionally_revealed_data{}; std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> public_data_update_requests{}; std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> public_data_reads{}; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 887d37f266cb..6027f3e7cce5 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -403,7 +403,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat .encrypted_log_preimages_length = private_previous ? ++seed : 0, .unencrypted_log_preimages_length = ++seed, .new_contracts = std::array, MAX_NEW_CONTRACTS_PER_TX>(), - .optionally_revealed_data = std::array, KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH>(), + .optionally_revealed_data = + std::array, MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX>(), .public_data_update_requests = std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(), .public_data_reads = std::array, KERNEL_PUBLIC_DATA_READS_LENGTH>() diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 09a0dde22c0f..bdfc7e8d300d 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -51,7 +51,7 @@ constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; -constexpr size_t KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; +constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; constexpr size_t KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; constexpr size_t KERNEL_PUBLIC_DATA_READS_LENGTH = 4; constexpr size_t KERNEL_NUM_ENCRYPTED_LOGS_HASHES = 1; diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 29defbff5e3f..33e5210ea679 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -19,7 +19,7 @@ export const MAX_NEW_CONTRACTS_PER_TX = 1; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; -export const KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH = 4; +export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; export const KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; export const KERNEL_PUBLIC_DATA_READS_LENGTH = 4; 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 62a0e89464b1..2be5dc41d375 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 @@ -5,7 +5,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, + MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, @@ -320,7 +320,7 @@ export class CombinedAccumulatedData { /** * All the optionally revealed data in this transaction. */ - public optionallyRevealedData: Tuple, + public optionallyRevealedData: Tuple, /** * All the public data update requests made in this transaction. */ @@ -338,7 +338,7 @@ export class CombinedAccumulatedData { assertMemberLength(this, 'encryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); - assertMemberLength(this, 'optionallyRevealedData', KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH); + assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX); assertMemberLength(this, 'publicDataUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); assertMemberLength(this, 'publicDataReads', KERNEL_PUBLIC_DATA_READS_LENGTH); } @@ -385,7 +385,7 @@ export class CombinedAccumulatedData { reader.readFr(), reader.readFr(), reader.readArray(MAX_NEW_CONTRACTS_PER_TX, NewContractData), - reader.readArray(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, OptionallyRevealedData), + reader.readArray(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData), reader.readArray(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataUpdateRequest), reader.readArray(KERNEL_PUBLIC_DATA_READS_LENGTH, PublicDataRead), ); @@ -413,7 +413,7 @@ export class CombinedAccumulatedData { Fr.zero(), Fr.zero(), makeTuple(MAX_NEW_CONTRACTS_PER_TX, NewContractData.empty), - makeTuple(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, OptionallyRevealedData.empty), + makeTuple(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData.empty), makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataUpdateRequest.empty), makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, PublicDataRead.empty), ); diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 727c41044497..4ed971d57e22 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -30,7 +30,7 @@ import { MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, + MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, KERNEL_PUBLIC_DATA_READS_LENGTH, @@ -211,7 +211,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu fr(seed + 0x800), // encrypted_log_preimages_length fr(seed + 0x900), // unencrypted_log_preimages_length tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), - tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0xb00), + tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xb00), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0xc00), tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeEmptyPublicDataRead, seed + 0xd00), ); @@ -237,7 +237,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated fr(seed + 0x800), // encrypted_log_preimages_length fr(seed + 0x900), // unencrypted_log_preimages_length tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), - tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0xb00), + tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xb00), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0xc00), tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, seed + 0xd00), ); From 91235fd8da2e0acd5a359e24e6ad8280a93acd7f Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 11:13:16 +0000 Subject: [PATCH 08/14] 972 - rename un/encrypted_logs_hash related constants --- .../src/aztec3/circuits/rollup/components/components.cpp | 6 +++--- .../cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp | 4 ++-- circuits/cpp/src/aztec3/constants.hpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index 8c3577bbdd1b..cf03edeae582 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -113,8 +113,8 @@ std::array compute_kernels_calldata_hash( auto const number_of_inputs = (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + - KERNEL_NUM_ENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256 + - KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256) * + NUM_ENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256 + + NUM_UNENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256) * 2; std::array calldata_hash_inputs{}; @@ -166,7 +166,7 @@ std::array compute_kernels_calldata_hash( calldata_hash_inputs[offset + i * 2 + j] = encryptedLogsHash[j]; } - offset += KERNEL_NUM_ENCRYPTED_LOGS_HASHES * NUM_FIELDS_PER_SHA256 * 2; + offset += NUM_ENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256 * 2; for (size_t j = 0; j < NUM_FIELDS_PER_SHA256; j++) { calldata_hash_inputs[offset + i * 2 + j] = unencryptedLogsHash[j]; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index a3f5a15d24e3..1c93a00da12c 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -53,8 +53,8 @@ std::vector get_empty_calldata_leaf() { auto const number_of_inputs = (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + - MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + KERNEL_NUM_ENCRYPTED_LOGS_HASHES * 2 + - KERNEL_NUM_UNENCRYPTED_LOGS_HASHES * 2) * + MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + NUM_ENCRYPTED_LOGS_HASHES_PER_TX * 2 + + NUM_UNENCRYPTED_LOGS_HASHES_PER_TX * 2) * 2; // We subtract 4 from inputs size because 1 logs hash is stored in 2 fields and those 2 fields get converted only diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index bdfc7e8d300d..1fab4b58d520 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -54,8 +54,8 @@ constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; constexpr size_t KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; constexpr size_t KERNEL_PUBLIC_DATA_READS_LENGTH = 4; -constexpr size_t KERNEL_NUM_ENCRYPTED_LOGS_HASHES = 1; -constexpr size_t KERNEL_NUM_UNENCRYPTED_LOGS_HASHES = 1; +constexpr size_t NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1; +constexpr size_t NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1; constexpr size_t VK_TREE_HEIGHT = 3; constexpr size_t FUNCTION_TREE_HEIGHT = 4; From 03d75798d5f4987510f2b9e05971003cafe9dc20 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 11:16:18 +0000 Subject: [PATCH 09/14] 972 - rename constants related to public data reads and requests --- .../abis/combined_accumulated_data.hpp | 4 +- .../abis/public_circuit_public_inputs.hpp | 4 +- .../abis/rollup/base/base_rollup_inputs.hpp | 4 +- .../aztec3/circuits/kernel/public/.test.cpp | 72 +++++++++---------- .../aztec3/circuits/kernel/public/common.hpp | 4 +- .../base/native_base_rollup_circuit.cpp | 16 ++--- .../circuits/rollup/components/components.cpp | 10 +-- .../circuits/rollup/test_utils/utils.cpp | 10 +-- circuits/cpp/src/aztec3/constants.hpp | 4 +- .../src/kernel/public_kernel.test.ts | 4 +- .../circuits.js/src/structs/constants.ts | 4 +- .../kernel/combined_accumulated_data.ts | 20 +++--- .../src/structs/kernel/public_kernel.ts | 8 +-- .../structs/public_circuit_public_inputs.ts | 16 ++--- .../src/structs/rollup/base_rollup.ts | 8 +-- .../circuits.js/src/tests/factories.ts | 24 +++---- .../src/integration_l1_publisher.test.ts | 4 +- .../block_builder/solo_block_builder.test.ts | 4 +- .../src/sequencer/public_processor.ts | 8 +-- yarn-project/types/src/l2_block.ts | 10 +-- .../server_world_state_synchroniser.test.ts | 4 +- 21 files changed, 121 insertions(+), 121 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index 28207a72cfc2..d31c8fb74b96 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -44,8 +44,8 @@ template struct CombinedAccumulatedData { std::array, MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX> optionally_revealed_data{}; - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> public_data_update_requests{}; - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> public_data_reads{}; + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> public_data_update_requests{}; + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> public_data_reads{}; // for serialization, update with new fields MSGPACK_FIELDS(aggregation_object, diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index 09e07ef6924f..bb31032e2c65 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -26,9 +26,9 @@ template struct PublicCircuitPublicInputs { fr args_hash = 0; std::array return_values{}; - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> contract_storage_update_requests{}; - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> contract_storage_reads{}; + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> contract_storage_reads{}; std::array public_call_stack{}; std::array new_commitments{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp index 3278ed125134..a1e4348bdbf3 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp @@ -30,9 +30,9 @@ template struct BaseRollupInputs { std::array new_commitments_subtree_sibling_path; std::array new_nullifiers_subtree_sibling_path; std::array new_contracts_subtree_sibling_path; - std::array, 2 * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> + std::array, 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> new_public_data_update_requests_sibling_paths; - std::array, 2 * KERNEL_PUBLIC_DATA_READS_LENGTH> + std::array, 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> new_public_data_reads_sibling_paths; std::array, 2> diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 6027f3e7cce5..012222e85bb2 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -70,11 +70,11 @@ template std::array empty_array_of_values() return values; } -std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> +std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> generate_contract_storage_update_requests(NT::uint32& count, - NT::uint32 num_values_required = KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH) + NT::uint32 num_values_required = MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) { - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> values; + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> values; for (size_t i = 0; i < num_values_required; i++) { const auto prev = count++; values[i] = ContractStorageUpdateRequest{ @@ -86,10 +86,10 @@ generate_contract_storage_update_requests(NT::uint32& count, return values; } -std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> generate_contract_storage_reads( - NT::uint32& count, NT::uint32 num_values_required = KERNEL_PUBLIC_DATA_READS_LENGTH) +std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> generate_contract_storage_reads( + NT::uint32& count, NT::uint32 num_values_required = MAX_KERNEL_PUBLIC_DATA_READS_PER_TX) { - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> values; + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> values; for (size_t i = 0; i < num_values_required; i++) { const auto prev = count++; values[i] = ContractStorageRead{ @@ -131,9 +131,9 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, array_of_values(count); std::array const new_l2_to_l1_msgs = array_of_values(count); - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const reads = generate_contract_storage_reads(count); - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const update_requests = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const update_requests = generate_contract_storage_update_requests(count); // create the public circuit public inputs @@ -177,12 +177,12 @@ PublicDataUpdateRequest public_data_update_request_from_contract_storage_upd }; } -std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> public_data_reads_from_contract_storage_reads( - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const& public_data_reads, +std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> public_data_reads_from_contract_storage_reads( + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const& public_data_reads, NT::fr const& contract_address) { - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> values; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_READS_LENGTH; i++) { + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> values; + for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; i++) { const auto& read = public_data_reads[i]; if (read.is_empty()) { continue; @@ -192,13 +192,13 @@ std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> public_data_read return values; } -std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> +std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> public_data_update_requests_from_contract_storage_update_requests( - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const& update_requests, + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const& update_requests, NT::fr const& contract_address) { - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> values; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; i++) { + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> values; + for (size_t i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; i++) { const auto& update_request = update_requests[i]; if (update_request.is_empty()) { continue; @@ -315,10 +315,10 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat std::array const return_values = array_of_values(seed, RETURN_VALUES_LENGTH / 2); - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const update_requests = - generate_contract_storage_update_requests(seed, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH / 2); - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const reads = - generate_contract_storage_reads(seed, KERNEL_PUBLIC_DATA_READS_LENGTH / 2); + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const update_requests = + generate_contract_storage_update_requests(seed, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX / 2); + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const reads = + generate_contract_storage_reads(seed, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX / 2); std::array const new_commitments = array_of_values(seed, MAX_NEW_COMMITMENTS_PER_CALL / 2); std::array const new_nullifiers = @@ -406,8 +406,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat .optionally_revealed_data = std::array, MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX>(), .public_data_update_requests = - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(), - .public_data_reads = std::array, KERNEL_PUBLIC_DATA_READS_LENGTH>() + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(), + .public_data_reads = std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX>() }; const KernelCircuitPublicInputs public_inputs = { @@ -439,7 +439,7 @@ void validate_public_kernel_outputs_correctly_propagated(const KernelInput& inpu const auto contract_address = inputs.public_call.call_stack_item.contract_address; size_t st_index = 0; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; i++) { + for (size_t i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; i++) { const auto& contract_storage_update_request = inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests[i]; if (contract_storage_update_request.is_empty()) { @@ -451,7 +451,7 @@ void validate_public_kernel_outputs_correctly_propagated(const KernelInput& inpu } size_t sr_index = 0; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_READS_LENGTH; i++) { + for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; i++) { const auto& read = inputs.public_call.call_stack_item.public_inputs.contract_storage_reads[i]; if (read.is_empty()) { continue; @@ -495,8 +495,8 @@ TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) .storage_slot = 123456789, .current_value = 76543, }; - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> reads = - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH>(); + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX>(); reads[1] = first_valid; reads[3] = second_valid; inputs.public_call.call_stack_item.public_inputs.contract_storage_reads = reads; @@ -540,8 +540,8 @@ TEST(public_kernel_tests, only_valid_update_requests_should_be_propagated) .old_value = 86543, .new_value = 86544, }; - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> update_requests = - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(); + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> update_requests = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); update_requests[1] = first_valid; update_requests[3] = second_valid; inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = update_requests; @@ -999,8 +999,8 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre .old_value = 86543, .new_value = 86544, }; - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> initial_writes = - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(); + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> initial_writes = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); initial_writes[0] = first_write; initial_writes[1] = second_write; inputs.previous_kernel.public_inputs.end.public_data_update_requests = initial_writes; @@ -1014,8 +1014,8 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre .leaf_index = 987654321, .value = 96544, }; - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> initial_reads = - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH>(); + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> initial_reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX>(); initial_reads[0] = first_read; initial_reads[1] = second_read; inputs.previous_kernel.public_inputs.end.public_data_reads = initial_reads; @@ -1069,7 +1069,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre const auto contract_address = inputs.public_call.call_stack_item.contract_address; const auto portal_contract_address = inputs.public_call.portal_contract_address; - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const expected_new_writes = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const expected_new_writes = public_data_update_requests_from_contract_storage_update_requests( inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests, contract_address); @@ -1094,7 +1094,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre expected_new_writes, public_inputs.end.public_data_update_requests)); - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const expected_new_reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const expected_new_reads = public_data_reads_from_contract_storage_reads( inputs.public_call.call_stack_item.public_inputs.contract_storage_reads, contract_address); @@ -1178,7 +1178,7 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_commitments_on_static // set previously set items to 0 inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = - empty_array_of_values, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(); + empty_array_of_values, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); // regenerate call data hash inputs.previous_kernel.public_inputs.end.public_call_stack[0] = @@ -1202,7 +1202,7 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_nullifiers_on_static_ // set previously set items to 0 inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = - empty_array_of_values, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH>(); + empty_array_of_values, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); inputs.public_call.call_stack_item.public_inputs.new_commitments = empty_array_of_values(); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index f2ecbf8cb971..d5600e54baee 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -228,7 +228,7 @@ void propagate_valid_public_data_update_requests(Builder& builder, const auto& contract_address = public_kernel_inputs.public_call.call_stack_item.contract_address; const auto& update_requests = public_kernel_inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; ++i) { + for (size_t i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; ++i) { const auto& update_request = update_requests[i]; if (update_request.is_empty()) { continue; @@ -255,7 +255,7 @@ void propagate_valid_public_data_reads(Builder& builder, { const auto& contract_address = public_kernel_inputs.public_call.call_stack_item.contract_address; const auto& reads = public_kernel_inputs.public_call.call_stack_item.public_inputs.contract_storage_reads; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_READS_LENGTH; ++i) { + for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; ++i) { const auto& contract_storage_read = reads[i]; if (contract_storage_read.is_empty()) { continue; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 55a7ee167ea2..7afd08a6f2f8 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -377,14 +377,14 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB fr insert_public_data_update_requests( DummyBuilder& builder, fr tree_root, - std::array, KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const& + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const& public_data_update_requests, size_t witnesses_offset, - std::array, 2 * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH> const& witnesses) + std::array, 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const& witnesses) { auto root = tree_root; - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; ++i) { + for (size_t i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; ++i) { const auto& state_write = public_data_update_requests[i]; const auto& witness = witnesses[i + witnesses_offset]; @@ -408,11 +408,11 @@ fr insert_public_data_update_requests( void validate_public_data_reads( DummyBuilder& builder, fr tree_root, - std::array, KERNEL_PUBLIC_DATA_READS_LENGTH> const& public_data_reads, + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const& public_data_reads, size_t witnesses_offset, - std::array, 2 * KERNEL_PUBLIC_DATA_READS_LENGTH> const& witnesses) + std::array, 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const& witnesses) { - for (size_t i = 0; i < KERNEL_PUBLIC_DATA_READS_LENGTH; ++i) { + for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; ++i) { const auto& public_data_read = public_data_reads[i]; const auto& witness = witnesses[i + witnesses_offset]; @@ -450,14 +450,14 @@ fr validate_and_process_public_state(DummyBuilder& builder, BaseRollupInputs con validate_public_data_reads(builder, mid_public_data_tree_root, baseRollupInputs.kernel_data[1].public_inputs.end.public_data_reads, - KERNEL_PUBLIC_DATA_READS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, baseRollupInputs.new_public_data_reads_sibling_paths); auto end_public_data_tree_root = insert_public_data_update_requests( builder, mid_public_data_tree_root, baseRollupInputs.kernel_data[1].public_inputs.end.public_data_update_requests, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, baseRollupInputs.new_public_data_update_requests_sibling_paths); return end_public_data_tree_root; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp index cf03edeae582..da3b4c2149b2 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/components/components.cpp @@ -111,7 +111,7 @@ std::array compute_kernels_calldata_hash( // 2 encrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes // 2 unencrypted logs hashes (1 per kernel) -> 4 fields --> 2 sha256 hashes --> 64 bytes auto const number_of_inputs = - (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + + (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 + MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + NUM_ENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256 + NUM_UNENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256) * @@ -138,13 +138,13 @@ std::array compute_kernels_calldata_hash( } offset += MAX_NEW_NULLIFIERS_PER_TX * 2; - for (size_t j = 0; j < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; j++) { - calldata_hash_inputs[offset + i * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + j * 2] = + for (size_t j = 0; j < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; j++) { + calldata_hash_inputs[offset + i * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 + j * 2] = public_data_update_requests[j].leaf_index; - calldata_hash_inputs[offset + i * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + j * 2 + 1] = + calldata_hash_inputs[offset + i * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 + j * 2 + 1] = public_data_update_requests[j].new_value; } - offset += KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 * 2; + offset += MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 * 2; for (size_t j = 0; j < MAX_NEW_L2_TO_L1_MSGS_PER_TX; j++) { calldata_hash_inputs[offset + i * MAX_NEW_L2_TO_L1_MSGS_PER_TX + j] = newL2ToL1msgs[j]; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index 1c93a00da12c..fae58b0432f8 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -52,7 +52,7 @@ namespace aztec3::circuits::rollup::test_utils::utils { std::vector get_empty_calldata_leaf() { auto const number_of_inputs = - (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2 + + (MAX_NEW_COMMITMENTS_PER_TX + MAX_NEW_NULLIFIERS_PER_TX + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2 + MAX_NEW_L2_TO_L1_MSGS_PER_TX + MAX_NEW_CONTRACTS_PER_TX * 3 + NUM_ENCRYPTED_LOGS_HASHES_PER_TX * 2 + NUM_UNENCRYPTED_LOGS_HASHES_PER_TX * 2) * 2; @@ -183,17 +183,17 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne // Then we collect all sibling paths for the reads in the left tx, and then apply the update requests while // collecting their paths. And then repeat for the right tx. for (size_t i = 0; i < 2; i++) { - for (size_t j = 0; j < KERNEL_PUBLIC_DATA_READS_LENGTH; j++) { + for (size_t j = 0; j < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; j++) { auto public_data_read = kernel_data[i].public_inputs.end.public_data_reads[j]; if (public_data_read.is_empty()) { continue; } auto leaf_index = uint256_t(public_data_read.leaf_index); - baseRollupInputs.new_public_data_reads_sibling_paths[i * KERNEL_PUBLIC_DATA_READS_LENGTH + j] = + baseRollupInputs.new_public_data_reads_sibling_paths[i * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX + j] = get_sibling_path(public_data_tree, leaf_index); } - for (size_t j = 0; j < KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH; j++) { + for (size_t j = 0; j < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; j++) { auto public_data_update_request = kernel_data[i].public_inputs.end.public_data_update_requests[j]; if (public_data_update_request.is_empty()) { continue; @@ -201,7 +201,7 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne auto leaf_index = uint256_t(public_data_update_request.leaf_index); public_data_tree.update_element(leaf_index, public_data_update_request.new_value); baseRollupInputs - .new_public_data_update_requests_sibling_paths[i * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH + j] = + .new_public_data_update_requests_sibling_paths[i * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + j] = get_sibling_path(public_data_tree, leaf_index); } } diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 1fab4b58d520..943da6485965 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -52,8 +52,8 @@ constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; -constexpr size_t KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; -constexpr size_t KERNEL_PUBLIC_DATA_READS_LENGTH = 4; +constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4; +constexpr size_t MAX_KERNEL_PUBLIC_DATA_READS_PER_TX = 4; constexpr size_t NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1; constexpr size_t NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1; diff --git a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts index 6b553a976162..4b35456da80f 100644 --- a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts +++ b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts @@ -1,4 +1,4 @@ -import { CircuitError, KERNEL_PUBLIC_DATA_READS_LENGTH, makeTuple, simulatePublicKernelCircuit } from '../index.js'; +import { CircuitError, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makeTuple, simulatePublicKernelCircuit } from '../index.js'; import { makePublicDataRead, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; describe('kernel/public_kernel', () => { @@ -27,7 +27,7 @@ describe('kernel/public_kernel', () => { input.previousKernel.publicInputs.isPrivate = false; // Cause array overflow - const fullStateReadsObject = makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, 0x01); + const fullStateReadsObject = makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, 0x01); input.previousKernel.publicInputs.end.publicDataReads = fullStateReadsObject; await expect(simulatePublicKernelCircuit(input)).rejects.toThrow( diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 33e5210ea679..ee265df1de32 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -20,8 +20,8 @@ export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; -export const KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH = 4; -export const KERNEL_PUBLIC_DATA_READS_LENGTH = 4; +export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4; +export const MAX_KERNEL_PUBLIC_DATA_READS_PER_TX = 4; export const VK_TREE_HEIGHT = 3; export const FUNCTION_TREE_HEIGHT = 4; 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 2be5dc41d375..ff0422e818fb 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 @@ -8,8 +8,8 @@ import { MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - KERNEL_PUBLIC_DATA_READS_LENGTH, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, NUM_FIELDS_PER_SHA256, } from '../constants.js'; @@ -324,11 +324,11 @@ export class CombinedAccumulatedData { /** * All the public data update requests made in this transaction. */ - public publicDataUpdateRequests: Tuple, + public publicDataUpdateRequests: Tuple, /** * All the public data reads made in this transaction. */ - public publicDataReads: Tuple, + public publicDataReads: Tuple, ) { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); @@ -339,8 +339,8 @@ export class CombinedAccumulatedData { assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX); - assertMemberLength(this, 'publicDataUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); - assertMemberLength(this, 'publicDataReads', KERNEL_PUBLIC_DATA_READS_LENGTH); + assertMemberLength(this, 'publicDataUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); + assertMemberLength(this, 'publicDataReads', MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); } toBuffer() { @@ -386,8 +386,8 @@ export class CombinedAccumulatedData { reader.readFr(), reader.readArray(MAX_NEW_CONTRACTS_PER_TX, NewContractData), reader.readArray(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData), - reader.readArray(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataUpdateRequest), - reader.readArray(KERNEL_PUBLIC_DATA_READS_LENGTH, PublicDataRead), + reader.readArray(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest), + reader.readArray(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, PublicDataRead), ); } @@ -414,8 +414,8 @@ export class CombinedAccumulatedData { Fr.zero(), makeTuple(MAX_NEW_CONTRACTS_PER_TX, NewContractData.empty), makeTuple(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData.empty), - makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataUpdateRequest.empty), - makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, PublicDataRead.empty), + makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest.empty), + makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, PublicDataRead.empty), ); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts index 22b267cb1a67..8a0eb87286e8 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts @@ -4,8 +4,8 @@ import { assertMemberLength } from '../../utils/jsUtils.js'; import { serializeToBuffer } from '../../utils/serialize.js'; import { PublicCallStackItem } from '../call_stack_item.js'; import { - KERNEL_PUBLIC_DATA_READS_LENGTH, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PUBLIC_DATA_TREE_HEIGHT, } from '../constants.js'; @@ -56,8 +56,8 @@ export class WitnessedPublicCallData { */ public readonly publicDataTreeRoot: Fr, ) { - assertMemberLength(this, 'updateRequestsHashPaths', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); - assertMemberLength(this, 'readsHashPaths', KERNEL_PUBLIC_DATA_READS_LENGTH); + assertMemberLength(this, 'updateRequestsHashPaths', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); + assertMemberLength(this, 'readsHashPaths', MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); } toBuffer() { diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index cfe0cb6ee237..44ae665f6b97 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -6,8 +6,8 @@ import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { - KERNEL_PUBLIC_DATA_READS_LENGTH, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NEW_COMMITMENTS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, @@ -152,12 +152,12 @@ export class PublicCircuitPublicInputs { */ public contractStorageUpdateRequests: Tuple< ContractStorageUpdateRequest, - typeof KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH + typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX >, /** * Contract storage reads executed during the call. */ - public contractStorageReads: Tuple, + public contractStorageReads: Tuple, /** * Public call stack of the current kernel iteration. */ @@ -197,8 +197,8 @@ export class PublicCircuitPublicInputs { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); - assertMemberLength(this, 'contractStorageUpdateRequests', KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); - assertMemberLength(this, 'contractStorageReads', KERNEL_PUBLIC_DATA_READS_LENGTH); + assertMemberLength(this, 'contractStorageUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); + assertMemberLength(this, 'contractStorageReads', MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); } @@ -220,8 +220,8 @@ export class PublicCircuitPublicInputs { CallContext.empty(), Fr.ZERO, makeTuple(RETURN_VALUES_LENGTH, Fr.zero), - makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, ContractStorageUpdateRequest.empty), - makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, ContractStorageRead.empty), + makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, ContractStorageUpdateRequest.empty), + makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, ContractStorageRead.empty), makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, Fr.zero), makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index a930067d8b46..26c2f7cdcda0 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -8,8 +8,8 @@ import { MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_PUBLIC_DATA_READS_LENGTH, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT, @@ -247,8 +247,8 @@ export class BaseRollupInputs { 'newContractsSubtreeSiblingPath', CONTRACT_TREE_HEIGHT - BaseRollupInputs.CONTRACT_SUBTREE_HEIGHT, ); - assertMemberLength(this, 'newPublicDataUpdateRequestsSiblingPaths', 2 * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH); - assertMemberLength(this, 'newPublicDataReadsSiblingPaths', 2 * KERNEL_PUBLIC_DATA_READS_LENGTH); + assertMemberLength(this, 'newPublicDataUpdateRequestsSiblingPaths', 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); + assertMemberLength(this, 'newPublicDataReadsSiblingPaths', 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); assertItemsLength(this, 'newPublicDataUpdateRequestsSiblingPaths', PUBLIC_DATA_TREE_HEIGHT); assertItemsLength(this, 'newPublicDataReadsSiblingPaths', PUBLIC_DATA_TREE_HEIGHT); } diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 4ed971d57e22..f3971863be52 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -33,8 +33,8 @@ import { MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - KERNEL_PUBLIC_DATA_READS_LENGTH, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, KernelCircuitPublicInputs, L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH, @@ -212,8 +212,8 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu fr(seed + 0x900), // unencrypted_log_preimages_length tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xb00), - tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0xc00), - tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeEmptyPublicDataRead, seed + 0xd00), + tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makeEmptyPublicDataUpdateRequest, seed + 0xc00), + tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makeEmptyPublicDataRead, seed + 0xd00), ); } @@ -238,8 +238,8 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated fr(seed + 0x900), // unencrypted_log_preimages_length tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xb00), - tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0xc00), - tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, seed + 0xd00), + tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makePublicDataUpdateRequest, seed + 0xc00), + tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, seed + 0xd00), ); } @@ -311,8 +311,8 @@ export function makePublicCircuitPublicInputs( makeCallContext(seed, storageContractAddress), fr(seed + 0x100), tupleGenerator(RETURN_VALUES_LENGTH, fr, seed + 0x200), - tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeContractStorageUpdateRequest, seed + 0x400), - tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeContractStorageRead, seed + 0x500), + tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makeContractStorageUpdateRequest, seed + 0x400), + tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makeContractStorageRead, seed + 0x500), tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), tupleGenerator(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x800), @@ -509,10 +509,10 @@ export async function makePublicCallData(seed = 1, full = false): Promise { return new WitnessedPublicCallData( await makePublicCallData(seed), - range(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, seed + 0x100).map(x => + range(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, seed + 0x100).map(x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), ), - makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), seed + 0x200), + makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), seed + 0x200), fr(seed + 0x300), ); } @@ -872,11 +872,11 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { ).map(x => fr(x)); const newPublicDataUpdateRequestsSiblingPaths = range( - 2 * KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, seed + 0x6000, ).map(x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr)); - const newPublicDataReadsSiblingPaths = range(2 * KERNEL_PUBLIC_DATA_READS_LENGTH, seed + 0x6000).map(x => + const newPublicDataReadsSiblingPaths = range(2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, seed + 0x6000).map(x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr), ); 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 06188ee94292..734ae02d66fe 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 @@ -5,7 +5,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, KernelCircuitPublicInputs, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PublicDataUpdateRequest, @@ -164,7 +164,7 @@ describe('L1Publisher integration', () => { kernelOutput.constants.txContext.version = fr(config.version); kernelOutput.constants.historicTreeRoots = await getCombinedHistoricTreeRoots(builderDb); kernelOutput.end.publicDataUpdateRequests = makeTuple( - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, i => new PublicDataUpdateRequest(fr(i), fr(0), fr(i + 10)), seed + 0x500, ); diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index bf87c17db0a3..a4d71a66be63 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -9,7 +9,7 @@ import { MAX_NEW_L2_TO_L1_MSGS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, KernelCircuitPublicInputs, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, Proof, @@ -292,7 +292,7 @@ describe('sequencer/solo_block_builder', () => { const kernelOutput = KernelCircuitPublicInputs.empty(); kernelOutput.constants.historicTreeRoots = await getCombinedHistoricTreeRoots(builderDb); kernelOutput.end.publicDataUpdateRequests = makeTuple( - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, i => new PublicDataUpdateRequest(fr(i), fr(0), fr(i + 10)), seed + 0x500, ); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index e2582bda90d4..15e5578d358d 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -6,8 +6,8 @@ import { ContractStorageUpdateRequest, Fr, GlobalVariables, - KERNEL_PUBLIC_DATA_READS_LENGTH, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, KernelCircuitPublicInputs, MembershipWitness, MAX_NEW_COMMITMENTS_PER_CALL, @@ -217,12 +217,12 @@ export class PublicProcessor { contractStorageReads: padArrayEnd( result.contractStorageReads, ContractStorageRead.empty(), - KERNEL_PUBLIC_DATA_READS_LENGTH, + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, ), contractStorageUpdateRequests: padArrayEnd( result.contractStorageUpdateRequests, ContractStorageUpdateRequest.empty(), - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, ), publicCallStack, unencryptedLogsHash, diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index 2cf6c922aa2f..eac4b1bb32c0 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -3,7 +3,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, MAX_NEW_L2_TO_L1_MSGS_PER_TX, GlobalVariables, @@ -180,7 +180,7 @@ export class L2Block { const newCommitments = times(MAX_NEW_COMMITMENTS_PER_TX * txsPerBlock, Fr.random); const newContracts = times(MAX_NEW_CONTRACTS_PER_TX * txsPerBlock, Fr.random); const newContractData = times(MAX_NEW_CONTRACTS_PER_TX * txsPerBlock, ContractData.random); - const newPublicDataWrites = times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * txsPerBlock, PublicDataWrite.random); + const newPublicDataWrites = times(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * txsPerBlock, PublicDataWrite.random); const newL1ToL2Messages = times(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, Fr.random); const newL2ToL1Msgs = times(MAX_NEW_L2_TO_L1_MSGS_PER_TX, Fr.random); const newEncryptedLogs = L2BlockL2Logs.random(txsPerBlock, numPrivateFunctionCalls, numEncryptedLogs); @@ -617,7 +617,7 @@ export class L2Block { for (let i = 0; i < leafCount; i++) { const commitmentsPerBase = MAX_NEW_COMMITMENTS_PER_TX * 2; const nullifiersPerBase = MAX_NEW_NULLIFIERS_PER_TX * 2; - const publicDataUpdateRequestsPerBase = KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * 2; + const publicDataUpdateRequestsPerBase = MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2; const l2ToL1MsgsPerBase = MAX_NEW_L2_TO_L1_MSGS_PER_TX * 2; const commitmentsBuffer = Buffer.concat( this.newCommitments.slice(i * commitmentsPerBase, (i + 1) * commitmentsPerBase).map(x => x.toBuffer()), @@ -691,8 +691,8 @@ export class L2Block { MAX_NEW_NULLIFIERS_PER_TX * (txIndex + 1), ); const newPublicDataWrites = this.newPublicDataWrites.slice( - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * txIndex, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH * (txIndex + 1), + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * txIndex, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * (txIndex + 1), ); const newL2ToL1Msgs = this.newL2ToL1Msgs.slice( MAX_NEW_L2_TO_L1_MSGS_PER_TX * txIndex, diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts index bd436bc3c976..bb4a50708698 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts @@ -5,7 +5,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, } from '@aztec/circuits.js'; @@ -82,7 +82,7 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = newNullifiers: times(MAX_NEW_NULLIFIERS_PER_TX, Fr.random), newContracts: newContractsCommitments?.map(x => Fr.fromBuffer(x)) ?? [Fr.random()], newContractData: times(MAX_NEW_CONTRACTS_PER_TX, getMockContractData), - newPublicDataWrites: times(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, PublicDataWrite.random), + newPublicDataWrites: times(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataWrite.random), newL1ToL2Messages: getMockL1ToL2MessagesData(), newL2ToL1Msgs: times(MAX_NEW_L2_TO_L1_MSGS_PER_CALL, Fr.random), newEncryptedLogs, From 0440f2d66ed45133cb377fceba3dcda525418993 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 11:42:53 +0000 Subject: [PATCH 10/14] 972 - re-order and comments constants --- circuits/cpp/src/aztec3/constants.hpp | 37 ++++++++++--------- .../circuits.js/src/structs/constants.ts | 28 ++++++++------ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 943da6485965..91ede5e07fd6 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -38,57 +38,60 @@ constexpr size_t READ_REQUESTS_LENGTH = 4; * MAX_NEW_NULLIFIERS_PER_TX ≥ MAX_NEW_NULLIFIERS_PER_CALL * */ + +// "PER CALL" CONSTANTS constexpr size_t MAX_NEW_COMMITMENTS_PER_CALL = 4; constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4; - constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; + +// "PER TRANSACTION" CONSTANTS constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; constexpr size_t MAX_NEW_NULLIFIERS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL; -constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; -constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4; constexpr size_t MAX_KERNEL_PUBLIC_DATA_READS_PER_TX = 4; +constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1; +constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; constexpr size_t NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1; constexpr size_t NUM_UNENCRYPTED_LOGS_HASHES_PER_TX = 1; +// ROLLUP CONSTANTS +constexpr size_t NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; +// TODO(961): Use this constant everywhere instead of hard-coded "2". +constexpr size_t KERNELS_PER_ROLLUP = 2; + + +// TREES RELATED CONSTANTS constexpr size_t VK_TREE_HEIGHT = 3; constexpr size_t FUNCTION_TREE_HEIGHT = 4; constexpr size_t CONTRACT_TREE_HEIGHT = 8; constexpr size_t PRIVATE_DATA_TREE_HEIGHT = 16; -constexpr size_t NULLIFIER_TREE_HEIGHT = 16; constexpr size_t PUBLIC_DATA_TREE_HEIGHT = 254; +constexpr size_t NULLIFIER_TREE_HEIGHT = 16; constexpr size_t L1_TO_L2_MSG_TREE_HEIGHT = 8; +constexpr size_t PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT = 8; +constexpr size_t CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; +constexpr size_t L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT = 8; +constexpr size_t ROLLUP_VK_TREE_HEIGHT = 8; // TODO: update +// SUB-TREES RELATED CONSTANTS constexpr size_t CONTRACT_SUBTREE_DEPTH = 1; constexpr size_t CONTRACT_SUBTREE_INCLUSION_CHECK_DEPTH = CONTRACT_TREE_HEIGHT - CONTRACT_SUBTREE_DEPTH; - -// TODO(961): Use this constant everywhere instead of hard-coded "2". -constexpr size_t KERNELS_PER_ROLLUP = 2; constexpr size_t PRIVATE_DATA_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_COMMITMENTS_PER_TX)); constexpr size_t PRIVATE_DATA_SUBTREE_INCLUSION_CHECK_DEPTH = PRIVATE_DATA_TREE_HEIGHT - PRIVATE_DATA_SUBTREE_DEPTH; - constexpr size_t NULLIFIER_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_NULLIFIERS_PER_TX)); constexpr size_t NULLIFIER_SUBTREE_INCLUSION_CHECK_DEPTH = NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_DEPTH; - -// NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP must equal 2^L1_TO_L2_MSG_SUBTREE_DEPTH for subtree insertions. -constexpr size_t L1_TO_L2_MSG_SUBTREE_DEPTH = 4; -constexpr size_t NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; +constexpr size_t L1_TO_L2_MSG_SUBTREE_DEPTH = static_cast(log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); constexpr size_t L1_TO_L2_MSG_SUBTREE_INCLUSION_CHECK_DEPTH = L1_TO_L2_MSG_TREE_HEIGHT - L1_TO_L2_MSG_SUBTREE_DEPTH; -constexpr size_t PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT = 8; -constexpr size_t CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; -constexpr size_t L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT = 8; -constexpr size_t ROLLUP_VK_TREE_HEIGHT = 8; // TODO: update constexpr size_t FUNCTION_SELECTOR_NUM_BYTES = 4; // must be <= 31 - // sha256 hash is stored in two fields to accommodate all 256-bits of the hash constexpr size_t NUM_FIELDS_PER_SHA256 = 2; diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index ee265df1de32..f6d69c15e21b 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -3,45 +3,51 @@ // In future: structured serialization? export const ARGS_LENGTH = 16; // MAX_ARGS in Noir export const RETURN_VALUES_LENGTH = 4; - export const READ_REQUESTS_LENGTH = 4; + +// "PER CALL" CONSTANTS export const MAX_NEW_COMMITMENTS_PER_CALL = 4; export const MAX_NEW_NULLIFIERS_PER_CALL = 4; -export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; - export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; +export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; +// "PER TRANSACTION" CONSTANTS export const MAX_NEW_COMMITMENTS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL export const MAX_NEW_NULLIFIERS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_NULLIFIERS_PER_CALL -export const MAX_NEW_CONTRACTS_PER_TX = 1; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; -export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4; export const MAX_KERNEL_PUBLIC_DATA_READS_PER_TX = 4; +export const MAX_NEW_CONTRACTS_PER_TX = 1; +export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; + +// ROLLUP CONSTANTS +export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; + +// TREES RELATED CONSTANTS export const VK_TREE_HEIGHT = 3; export const FUNCTION_TREE_HEIGHT = 4; export const CONTRACT_TREE_HEIGHT = 8; export const PRIVATE_DATA_TREE_HEIGHT = 16; export const PUBLIC_DATA_TREE_HEIGHT = 254; export const NULLIFIER_TREE_HEIGHT = 16; -export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; export const L1_TO_L2_MESSAGES_TREE_HEIGHT = 8; +export const PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT = 8; +export const CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; export const L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT = 8; +export const ROLLUP_VK_TREE_HEIGHT = 8; + + +// SUB-TREES RELATED CONSTANTS export const L1_TO_L2_MESSAGES_SUBTREE_HEIGHT = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); export const L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH = L1_TO_L2_MESSAGES_TREE_HEIGHT - L1_TO_L2_MESSAGES_SUBTREE_HEIGHT; -export const PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT = 8; -export const CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; -export const ROLLUP_VK_TREE_HEIGHT = 8; export const FUNCTION_SELECTOR_NUM_BYTES = 4; - export const MAPPING_SLOT_PEDERSEN_SEPARATOR = 4; - // sha256 hash is stored in two fields to accommodate all 256-bits of the hash export const NUM_FIELDS_PER_SHA256 = 2; From a86ceaf5b36fd2b4bc495ba6114921732d3d092d Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 11:58:38 +0000 Subject: [PATCH 11/14] 972 - harmonize naming conventions in constants --- .../abis/rollup/base/base_rollup_inputs.hpp | 6 +++--- .../abis/rollup/root/root_rollup_inputs.hpp | 2 +- .../src/aztec3/circuits/rollup/base/.test.cpp | 4 ++-- .../base/native_base_rollup_circuit.cpp | 20 +++++++++---------- .../root/native_root_rollup_circuit.cpp | 6 +++--- .../circuits/rollup/test_utils/utils.cpp | 16 +++++++-------- circuits/cpp/src/aztec3/constants.hpp | 18 +++++++++-------- .../src/client/private_execution.test.ts | 4 ++-- .../acir-simulator/src/public/index.test.ts | 4 ++-- .../aztec-node/src/aztec-node/aztec-node.ts | 4 ++-- .../aztec-node/src/aztec-node/http-node.ts | 4 ++-- .../aztec-node/src/aztec-node/server.ts | 4 ++-- .../circuits.js/src/structs/constants.ts | 8 ++++---- .../src/structs/rollup/base_rollup.ts | 6 +++--- .../src/structs/rollup/root_rollup.ts | 8 ++++---- .../circuits.js/src/tests/factories.ts | 12 +++++------ .../src/libs/noir-aztec/src/lib.nr | 2 +- .../messaging/l1_to_l2_message_getter_data.nr | 8 ++++---- .../src/block_builder/solo_block_builder.ts | 8 ++++---- .../src/world-state-db/merkle_trees.ts | 8 ++++---- 20 files changed, 77 insertions(+), 75 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp index a1e4348bdbf3..f844db81bfb1 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp @@ -27,9 +27,9 @@ template struct BaseRollupInputs { // For inserting the new subtrees into their respective trees: // Note: the insertion leaf index can be derived from the above snapshots' `next_available_leaf_index` values. - std::array new_commitments_subtree_sibling_path; - std::array new_nullifiers_subtree_sibling_path; - std::array new_contracts_subtree_sibling_path; + std::array new_commitments_subtree_sibling_path; + std::array new_nullifiers_subtree_sibling_path; + std::array new_contracts_subtree_sibling_path; std::array, 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> new_public_data_update_requests_sibling_paths; std::array, 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp index 5bb089f66d22..0fff9bd59813 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp @@ -23,7 +23,7 @@ template struct RootRollupInputs { // inputs required to process l1 to l2 messages std::array l1_to_l2_messages; - std::array new_l1_to_l2_message_tree_root_sibling_path; + std::array new_l1_to_l2_message_tree_root_sibling_path; std::array new_historic_l1_to_l2_message_roots_tree_sibling_path; AppendOnlyTreeSnapshot start_l1_to_l2_message_tree_snapshot; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp index 2a017ac3548b..30dd57971d4a 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/.test.cpp @@ -224,8 +224,8 @@ TEST_F(base_rollup_tests, native_contract_leaf_inserted_in_non_empty_snapshot_tr }; // Set the new_contracts_subtree_sibling_path - auto sibling_path = get_sibling_path( - start_contract_tree_snapshot, 12, CONTRACT_SUBTREE_DEPTH); + auto sibling_path = get_sibling_path( + start_contract_tree_snapshot, 12, CONTRACT_SUBTREE_HEIGHT); inputs.new_contracts_subtree_sibling_path = sibling_path; // create expected end contract tree snapshot diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 7afd08a6f2f8..07c1a398540f 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -84,7 +84,7 @@ std::vector calculate_contract_leaves(BaseRollupInputs const& baseRollup NT::fr calculate_contract_subtree(std::vector contract_leaves) { - MerkleTree contracts_tree = MerkleTree(CONTRACT_SUBTREE_DEPTH); + MerkleTree contracts_tree = MerkleTree(CONTRACT_SUBTREE_HEIGHT); // Compute the merkle root of a contract subtree // Contracts subtree @@ -96,7 +96,7 @@ NT::fr calculate_contract_subtree(std::vector contract_leaves) NT::fr calculate_commitments_subtree(DummyBuilder& builder, BaseRollupInputs const& baseRollupInputs) { - MerkleTree commitments_tree = MerkleTree(PRIVATE_DATA_SUBTREE_DEPTH); + MerkleTree commitments_tree = MerkleTree(PRIVATE_DATA_SUBTREE_HEIGHT); for (size_t i = 0; i < 2; i++) { auto new_commitments = baseRollupInputs.kernel_data[i].public_inputs.end.new_commitments; @@ -191,7 +191,7 @@ NT::fr create_nullifier_subtree( std::array const& nullifier_leaves) { // Build a merkle tree of the nullifiers - MerkleTree nullifier_subtree = MerkleTree(NULLIFIER_SUBTREE_DEPTH); + MerkleTree nullifier_subtree = MerkleTree(NULLIFIER_SUBTREE_HEIGHT); for (size_t i = 0; i < nullifier_leaves.size(); i++) { // hash() checks if nullifier is empty (and if so returns 0) nullifier_subtree.update_element(i, nullifier_leaves[i].hash()); @@ -348,9 +348,9 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB } // Check that the new subtree is to be inserted at the next location, and is empty currently - const auto empty_nullifier_subtree_root = components::calculate_empty_tree_root(NULLIFIER_SUBTREE_DEPTH); + const auto empty_nullifier_subtree_root = components::calculate_empty_tree_root(NULLIFIER_SUBTREE_HEIGHT); auto leafIndexNullifierSubtreeDepth = - baseRollupInputs.start_nullifier_tree_snapshot.next_available_leaf_index >> NULLIFIER_SUBTREE_DEPTH; + baseRollupInputs.start_nullifier_tree_snapshot.next_available_leaf_index >> NULLIFIER_SUBTREE_HEIGHT; check_membership(builder, empty_nullifier_subtree_root, leafIndexNullifierSubtreeDepth, @@ -364,7 +364,7 @@ AppendOnlySnapshot check_nullifier_tree_non_membership_and_insert_to_tree(DummyB // Calculate the new root // We are inserting a subtree rather than a full tree here - auto subtree_index = start_insertion_index >> (NULLIFIER_SUBTREE_DEPTH); + auto subtree_index = start_insertion_index >> (NULLIFIER_SUBTREE_HEIGHT); auto new_root = root_from_sibling_path(nullifier_subtree_root, subtree_index, nullifier_sibling_path); // Return the new state of the nullifier tree @@ -493,25 +493,25 @@ BaseOrMergeRollupPublicInputs base_rollup_circuit(DummyBuilder& builder, BaseRol NT::fr const commitments_tree_subroot = calculate_commitments_subtree(builder, baseRollupInputs); // Insert commitment subtrees: - const auto empty_commitments_subtree_root = components::calculate_empty_tree_root(PRIVATE_DATA_SUBTREE_DEPTH); + const auto empty_commitments_subtree_root = components::calculate_empty_tree_root(PRIVATE_DATA_SUBTREE_HEIGHT); auto end_private_data_tree_snapshot = components::insert_subtree_to_snapshot_tree(builder, baseRollupInputs.start_private_data_tree_snapshot, baseRollupInputs.new_commitments_subtree_sibling_path, empty_commitments_subtree_root, commitments_tree_subroot, - PRIVATE_DATA_SUBTREE_DEPTH, + PRIVATE_DATA_SUBTREE_HEIGHT, "empty commitment subtree membership check"); // Insert contract subtrees: - const auto empty_contracts_subtree_root = components::calculate_empty_tree_root(CONTRACT_SUBTREE_DEPTH); + const auto empty_contracts_subtree_root = components::calculate_empty_tree_root(CONTRACT_SUBTREE_HEIGHT); auto end_contract_tree_snapshot = components::insert_subtree_to_snapshot_tree(builder, baseRollupInputs.start_contract_tree_snapshot, baseRollupInputs.new_contracts_subtree_sibling_path, empty_contracts_subtree_root, contracts_tree_subroot, - CONTRACT_SUBTREE_DEPTH, + CONTRACT_SUBTREE_HEIGHT, "empty contract subtree membership check"); // Insert nullifiers: diff --git a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp index 945d3bcbbdd6..f6f7f9a2c6a9 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/root/native_root_rollup_circuit.cpp @@ -26,7 +26,7 @@ namespace aztec3::circuits::rollup::native_root_rollup { */ NT::fr calculate_subtree(std::array leaves) { - MerkleTree merkle_tree = MerkleTree(L1_TO_L2_MSG_SUBTREE_DEPTH); + MerkleTree merkle_tree = MerkleTree(L1_TO_L2_MSG_SUBTREE_HEIGHT); for (size_t i = 0; i < NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP; i++) { merkle_tree.update_element(i, leaves[i]); @@ -109,14 +109,14 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu auto l1_to_l2_subtree_root = calculate_subtree(rootRollupInputs.l1_to_l2_messages); // // Insert subtree into the l1 to l2 data tree - const auto empty_l1_to_l2_subtree_root = components::calculate_empty_tree_root(L1_TO_L2_MSG_SUBTREE_DEPTH); + const auto empty_l1_to_l2_subtree_root = components::calculate_empty_tree_root(L1_TO_L2_MSG_SUBTREE_HEIGHT); auto new_l1_to_l2_messages_tree_snapshot = components::insert_subtree_to_snapshot_tree(builder, rootRollupInputs.start_l1_to_l2_message_tree_snapshot, rootRollupInputs.new_l1_to_l2_message_tree_root_sibling_path, empty_l1_to_l2_subtree_root, l1_to_l2_subtree_root, - L1_TO_L2_MSG_SUBTREE_DEPTH, + L1_TO_L2_MSG_SUBTREE_HEIGHT, "l1 to l2 message tree insertion"); // Update the historic l1 to l2 data tree diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index fae58b0432f8..cde217de2f5d 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -147,10 +147,10 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne baseRollupInputs = std::get<0>(temp); baseRollupInputs.new_contracts_subtree_sibling_path = - get_sibling_path(contract_tree, 0, CONTRACT_SUBTREE_DEPTH); + get_sibling_path(contract_tree, 0, CONTRACT_SUBTREE_HEIGHT); baseRollupInputs.new_commitments_subtree_sibling_path = - get_sibling_path(private_data_tree, 0, PRIVATE_DATA_SUBTREE_DEPTH); + get_sibling_path(private_data_tree, 0, PRIVATE_DATA_SUBTREE_HEIGHT); // Update public data tree to generate sibling paths: we first set the initial public data tree to the result of all @@ -285,10 +285,10 @@ std::array, 2> get_previous_rollup_data(DummyBuilder& bui base_rollup_input_2.start_contract_tree_snapshot = base_public_input_1.end_contract_tree_snapshot; base_rollup_input_2.new_contracts_subtree_sibling_path = - get_sibling_path(contract_tree, 2, CONTRACT_SUBTREE_DEPTH); + get_sibling_path(contract_tree, 2, CONTRACT_SUBTREE_HEIGHT); base_rollup_input_2.new_commitments_subtree_sibling_path = - get_sibling_path( - private_data_tree, 2 * MAX_NEW_COMMITMENTS_PER_TX, PRIVATE_DATA_SUBTREE_DEPTH); + get_sibling_path( + private_data_tree, 2 * MAX_NEW_COMMITMENTS_PER_TX, PRIVATE_DATA_SUBTREE_HEIGHT); auto base_public_input_2 = aztec3::circuits::rollup::native_base_rollup::base_rollup_circuit(builder, base_rollup_input_2); @@ -343,7 +343,7 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder, get_sibling_path(historic_l1_to_l2_msg_tree, 1, 0); // l1 to l2 tree auto l1_to_l2_tree_sibling_path = - get_sibling_path(l1_to_l2_msg_tree, 0, L1_TO_L2_MSG_SUBTREE_DEPTH); + get_sibling_path(l1_to_l2_msg_tree, 0, L1_TO_L2_MSG_SUBTREE_HEIGHT); // l1_to_l2_message tree snapshots AppendOnlyTreeSnapshot const start_l1_to_l2_msg_tree_snapshot = { @@ -494,10 +494,10 @@ nullifier_tree_testing_values generate_nullifier_tree_testing_values_explicit( }; std::vector sibling_path = reference_tree.get_sibling_path(start_tree_size); - std::array sibling_path_array; + std::array sibling_path_array; // Chop the first NULLIFIER-SUBTREE-DEPTH levels from the sibling_path - sibling_path.erase(sibling_path.begin(), sibling_path.begin() + NULLIFIER_SUBTREE_DEPTH); + sibling_path.erase(sibling_path.begin(), sibling_path.begin() + NULLIFIER_SUBTREE_HEIGHT); std::copy(sibling_path.begin(), sibling_path.end(), sibling_path_array.begin()); // Update our start state diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 91ede5e07fd6..7580eea4e2c3 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -79,18 +79,20 @@ constexpr size_t CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; constexpr size_t L1_TO_L2_MSG_TREE_ROOTS_TREE_HEIGHT = 8; constexpr size_t ROLLUP_VK_TREE_HEIGHT = 8; // TODO: update + // SUB-TREES RELATED CONSTANTS -constexpr size_t CONTRACT_SUBTREE_DEPTH = 1; -constexpr size_t CONTRACT_SUBTREE_INCLUSION_CHECK_DEPTH = CONTRACT_TREE_HEIGHT - CONTRACT_SUBTREE_DEPTH; -constexpr size_t PRIVATE_DATA_SUBTREE_DEPTH = +constexpr size_t CONTRACT_SUBTREE_HEIGHT = 1; +constexpr size_t CONTRACT_SUBTREE_SIBLING_PATH_LENGTH = CONTRACT_TREE_HEIGHT - CONTRACT_SUBTREE_HEIGHT; +constexpr size_t PRIVATE_DATA_SUBTREE_HEIGHT = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_COMMITMENTS_PER_TX)); -constexpr size_t PRIVATE_DATA_SUBTREE_INCLUSION_CHECK_DEPTH = PRIVATE_DATA_TREE_HEIGHT - PRIVATE_DATA_SUBTREE_DEPTH; -constexpr size_t NULLIFIER_SUBTREE_DEPTH = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_NULLIFIERS_PER_TX)); -constexpr size_t NULLIFIER_SUBTREE_INCLUSION_CHECK_DEPTH = NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_DEPTH; -constexpr size_t L1_TO_L2_MSG_SUBTREE_DEPTH = static_cast(log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); -constexpr size_t L1_TO_L2_MSG_SUBTREE_INCLUSION_CHECK_DEPTH = L1_TO_L2_MSG_TREE_HEIGHT - L1_TO_L2_MSG_SUBTREE_DEPTH; +constexpr size_t PRIVATE_DATA_SUBTREE_SIBLING_PATH_LENGTH = PRIVATE_DATA_TREE_HEIGHT - PRIVATE_DATA_SUBTREE_HEIGHT; +constexpr size_t NULLIFIER_SUBTREE_HEIGHT = static_cast(log2(KERNELS_PER_ROLLUP * MAX_NEW_NULLIFIERS_PER_TX)); +constexpr size_t NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = NULLIFIER_TREE_HEIGHT - NULLIFIER_SUBTREE_HEIGHT; +constexpr size_t L1_TO_L2_MSG_SUBTREE_HEIGHT = static_cast(log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); +constexpr size_t L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = L1_TO_L2_MSG_TREE_HEIGHT - L1_TO_L2_MSG_SUBTREE_HEIGHT; +// MISC CONSTANTS constexpr size_t FUNCTION_SELECTOR_NUM_BYTES = 4; // must be <= 31 // sha256 hash is stored in two fields to accommodate all 256-bits of the hash constexpr size_t NUM_FIELDS_PER_SHA256 = 2; diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 71340cda0b57..2b5ad32a14fa 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -3,7 +3,7 @@ import { CircuitsWasm, ContractDeploymentData, FunctionData, - L1_TO_L2_MESSAGES_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, MAX_NEW_COMMITMENTS_PER_CALL, PRIVATE_DATA_TREE_HEIGHT, PrivateHistoricTreeRoots, @@ -47,7 +47,7 @@ describe('Private Execution test suite', () => { const treeHeights: { [name: string]: number } = { privateData: PRIVATE_DATA_TREE_HEIGHT, - l1ToL2Messages: L1_TO_L2_MESSAGES_TREE_HEIGHT, + l1ToL2Messages: L1_TO_L2_MSG_TREE_HEIGHT, }; const trees: { [name: keyof typeof treeHeights]: AppendOnlyTree } = {}; const txContext = new TxContext(false, false, false, ContractDeploymentData.empty(), new Fr(69), new Fr(420)); diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index e63f4b0e8dec..0182d9993408 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -4,7 +4,7 @@ import { FunctionData, CircuitsWasm, PrivateHistoricTreeRoots, - L1_TO_L2_MESSAGES_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, GlobalVariables, } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; @@ -364,7 +364,7 @@ describe('ACIR public execution simulator', () => { return await Promise.resolve({ message: preimage.toFieldArray(), index: 0n, - siblingPath: Array(L1_TO_L2_MESSAGES_TREE_HEIGHT).fill(Fr.random()), + siblingPath: Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.random()), }); }); diff --git a/yarn-project/aztec-node/src/aztec-node/aztec-node.ts b/yarn-project/aztec-node/src/aztec-node/aztec-node.ts index 31141be438d6..6f3c818414f0 100644 --- a/yarn-project/aztec-node/src/aztec-node/aztec-node.ts +++ b/yarn-project/aztec-node/src/aztec-node/aztec-node.ts @@ -1,4 +1,4 @@ -import { CONTRACT_TREE_HEIGHT, L1_TO_L2_MESSAGES_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT } from '@aztec/circuits.js'; +import { CONTRACT_TREE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { ContractPublicData, @@ -141,7 +141,7 @@ export interface AztecNode { * @param leafIndex - Index of the leaf in the tree. * @returns The sibling path. */ - getL1ToL2MessagesTreePath(leafIndex: bigint): Promise>; + getL1ToL2MessagesTreePath(leafIndex: bigint): Promise>; /** * Gets the storage value at the given contract slot. Our version of eth_getStorageAt. diff --git a/yarn-project/aztec-node/src/aztec-node/http-node.ts b/yarn-project/aztec-node/src/aztec-node/http-node.ts index cf362ca41a04..dd7202691fa9 100644 --- a/yarn-project/aztec-node/src/aztec-node/http-node.ts +++ b/yarn-project/aztec-node/src/aztec-node/http-node.ts @@ -4,7 +4,7 @@ import { CONTRACT_TREE_HEIGHT, Fr, KernelCircuitPublicInputs, - L1_TO_L2_MESSAGES_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT, Proof, PublicCallRequest, @@ -313,7 +313,7 @@ export class HttpNode implements AztecNode { * @param leafIndex - Index of the leaf in the tree. * @returns The sibling path. */ - async getL1ToL2MessagesTreePath(leafIndex: bigint): Promise> { + async getL1ToL2MessagesTreePath(leafIndex: bigint): Promise> { const url = new URL(`${this.baseUrl}/l1-l2-path`); url.searchParams.append('leaf', leafIndex.toString()); const response = await (await fetch(url.toString())).json(); diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index d172a4d55215..55a8dd1c7753 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -3,7 +3,7 @@ import { CONTRACT_TREE_HEIGHT, CircuitsWasm, Fr, - L1_TO_L2_MESSAGES_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT, } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; @@ -283,7 +283,7 @@ export class AztecNodeService implements AztecNode { * @param leafIndex - Index of the leaf in the tree. * @returns The sibling path. */ - public getL1ToL2MessagesTreePath(leafIndex: bigint): Promise> { + public getL1ToL2MessagesTreePath(leafIndex: bigint): Promise> { return this.merkleTreeDB.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGES_TREE, leafIndex, false); } diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index f6d69c15e21b..e4f3b56ba91f 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -35,16 +35,16 @@ export const CONTRACT_TREE_HEIGHT = 8; export const PRIVATE_DATA_TREE_HEIGHT = 16; export const PUBLIC_DATA_TREE_HEIGHT = 254; export const NULLIFIER_TREE_HEIGHT = 16; -export const L1_TO_L2_MESSAGES_TREE_HEIGHT = 8; +export const L1_TO_L2_MSG_TREE_HEIGHT = 8; export const PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT = 8; export const CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; -export const L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT = 8; +export const L1_TO_L2_MSG_ROOTS_TREE_HEIGHT = 8; export const ROLLUP_VK_TREE_HEIGHT = 8; // SUB-TREES RELATED CONSTANTS -export const L1_TO_L2_MESSAGES_SUBTREE_HEIGHT = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); -export const L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH = L1_TO_L2_MESSAGES_TREE_HEIGHT - L1_TO_L2_MESSAGES_SUBTREE_HEIGHT; +export const L1_TO_L2_MSG_SUBTREE_HEIGHT = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); +export const L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = L1_TO_L2_MSG_TREE_HEIGHT - L1_TO_L2_MSG_SUBTREE_HEIGHT; export const FUNCTION_SELECTOR_NUM_BYTES = 4; diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index 26c2f7cdcda0..f67792ca95fc 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -10,7 +10,7 @@ import { MAX_NEW_NULLIFIERS_PER_TX, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, @@ -221,8 +221,8 @@ export class BaseRollupInputs { * Membership witnesses of L1-to-L2 message tree roots referred by each of the 2 kernels. */ public historicL1ToL2MsgTreeRootMembershipWitnesses: [ - MembershipWitness, - MembershipWitness, + MembershipWitness, + MembershipWitness, ], /** diff --git a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts index afd8a55da21f..ecdbabb1f02e 100644 --- a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts @@ -3,8 +3,8 @@ import { serializeToBuffer } from '../../utils/serialize.js'; import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; import { CONTRACT_TREE_ROOTS_TREE_HEIGHT, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, - L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, } from '../constants.js'; @@ -56,8 +56,8 @@ export class RootRollupInputs { ) { assertMemberLength(this, 'newHistoricPrivateDataTreeRootSiblingPath', PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT); assertMemberLength(this, 'newHistoricContractDataTreeRootSiblingPath', CONTRACT_TREE_ROOTS_TREE_HEIGHT); - assertMemberLength(this, 'newL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH); - assertMemberLength(this, 'newHistoricL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT); + assertMemberLength(this, 'newL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH); + assertMemberLength(this, 'newHistoricL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MSG_ROOTS_TREE_HEIGHT); assertMemberLength(this, 'newL1ToL2Messages', NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP); } diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index f3971863be52..f87d9e7f737c 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -36,8 +36,8 @@ import { MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, KernelCircuitPublicInputs, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, - L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, MembershipWitness, MergeRollupInputs, MAX_NEW_COMMITMENTS_PER_CALL, @@ -781,8 +781,8 @@ export function makeRootRollupInputs(seed = 0, blockNumber: number | undefined = makeTuple(PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, fr, 0x2000), makeTuple(CONTRACT_TREE_ROOTS_TREE_HEIGHT, fr, 0x2100), makeTuple(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, fr, 0x2100), - makeTuple(L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH, fr, 0x2100), - makeTuple(L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, fr, 0x2100), + makeTuple(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, fr, 0x2100), + makeTuple(L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, fr, 0x2100), makeAppendOnlyTreeSnapshot(seed + 0x2200), makeAppendOnlyTreeSnapshot(seed + 0x2300), ); @@ -893,8 +893,8 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { ]; const historicL1ToL2MsgTreeRootMembershipWitnesses: BaseRollupInputs['historicL1ToL2MsgTreeRootMembershipWitnesses'] = [ - makeMembershipWitness(L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, seed + 0xa000), - makeMembershipWitness(L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, seed + 0xb000), + makeMembershipWitness(L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, seed + 0xa000), + makeMembershipWitness(L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, seed + 0xb000), ]; const constants = makeConstantBaseRollupData(0x100); diff --git a/yarn-project/noir-contracts/src/libs/noir-aztec/src/lib.nr b/yarn-project/noir-contracts/src/libs/noir-aztec/src/lib.nr index 69efc59288e1..1992533f7f7e 100644 --- a/yarn-project/noir-contracts/src/libs/noir-aztec/src/lib.nr +++ b/yarn-project/noir-contracts/src/libs/noir-aztec/src/lib.nr @@ -13,4 +13,4 @@ mod oracle; mod entrypoint; global PRIVATE_DATA_TREE_HEIGHT: comptime Field = 16; -global L1_TO_L2_MESSAGES_TREE_HEIGHT: comptime Field = 8; +global L1_TO_L2_MSG_TREE_HEIGHT: comptime Field = 8; diff --git a/yarn-project/noir-contracts/src/libs/noir-aztec/src/messaging/l1_to_l2_message_getter_data.nr b/yarn-project/noir-contracts/src/libs/noir-aztec/src/messaging/l1_to_l2_message_getter_data.nr index 124c5bfc7746..f6befeccd1f2 100644 --- a/yarn-project/noir-contracts/src/libs/noir-aztec/src/messaging/l1_to_l2_message_getter_data.nr +++ b/yarn-project/noir-contracts/src/libs/noir-aztec/src/messaging/l1_to_l2_message_getter_data.nr @@ -4,20 +4,20 @@ use crate::utils::arr_copy_slice; struct L1ToL2MessageGetterData { message: L1ToL2Message, - sibling_path: [Field; crate::L1_TO_L2_MESSAGES_TREE_HEIGHT], + sibling_path: [Field; crate::L1_TO_L2_MSG_TREE_HEIGHT], leaf_index: Field, root: Field, } fn l1_to_l2_message_getter_len() -> comptime Field { - L1_TO_L2_MESSAGE_LEN + 1 + crate::L1_TO_L2_MESSAGES_TREE_HEIGHT + 1 + L1_TO_L2_MESSAGE_LEN + 1 + crate::L1_TO_L2_MSG_TREE_HEIGHT + 1 } fn make_l1_to_l2_message_getter_data(fields: [Field], start: comptime Field, secret: Field) -> L1ToL2MessageGetterData { L1ToL2MessageGetterData { message: L1ToL2Message::deserialize(arr_copy_slice(fields, [0; L1_TO_L2_MESSAGE_LEN], start), secret, fields[start + L1_TO_L2_MESSAGE_LEN]), leaf_index: fields[start + L1_TO_L2_MESSAGE_LEN], - sibling_path: arr_copy_slice(fields, [0; crate::L1_TO_L2_MESSAGES_TREE_HEIGHT], L1_TO_L2_MESSAGE_LEN + 1), - root: fields[start + L1_TO_L2_MESSAGE_LEN + crate::L1_TO_L2_MESSAGES_TREE_HEIGHT + 1], + sibling_path: arr_copy_slice(fields, [0; crate::L1_TO_L2_MSG_TREE_HEIGHT], L1_TO_L2_MESSAGE_LEN + 1), + root: fields[start + L1_TO_L2_MESSAGE_LEN + crate::L1_TO_L2_MSG_TREE_HEIGHT + 1], } } \ No newline at end of file diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts index 8b60ba254891..f5199900d5ab 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.ts @@ -6,8 +6,8 @@ import { CircuitsWasm, ConstantBaseRollupData, GlobalVariables, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, - L1_TO_L2_MESSAGES_SUBTREE_HEIGHT, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_SUBTREE_HEIGHT, MembershipWitness, MergeRollupInputs, NULLIFIER_TREE_HEIGHT, @@ -426,7 +426,7 @@ export class SoloBlockBuilder implements BlockBuilder { ); const newL1ToL2MessageTreeRootSiblingPath = await this.getSubtreeSiblingPath( MerkleTreeId.L1_TO_L2_MESSAGES_TREE, - L1_TO_L2_MESSAGES_SUBTREE_HEIGHT, + L1_TO_L2_MSG_SUBTREE_HEIGHT, ); // Get tree snapshots @@ -518,7 +518,7 @@ export class SoloBlockBuilder implements BlockBuilder { return this.getMembershipWitnessFor( tx.data.constants.historicTreeRoots.privateHistoricTreeRoots.l1ToL2MessagesTreeRoot, MerkleTreeId.L1_TO_L2_MESSAGES_ROOTS_TREE, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, ); } diff --git a/yarn-project/world-state/src/world-state-db/merkle_trees.ts b/yarn-project/world-state/src/world-state-db/merkle_trees.ts index 3892673f392a..89703cd74d45 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_trees.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_trees.ts @@ -4,8 +4,8 @@ import { CONTRACT_TREE_ROOTS_TREE_HEIGHT, CircuitsWasm, Fr, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, - L1_TO_L2_MESSAGES_TREE_HEIGHT, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, @@ -104,14 +104,14 @@ export class MerkleTrees implements MerkleTreeDb { this.db, hasher, `${MerkleTreeId[MerkleTreeId.L1_TO_L2_MESSAGES_TREE]}`, - L1_TO_L2_MESSAGES_TREE_HEIGHT, + L1_TO_L2_MSG_TREE_HEIGHT, ); const l1Tol2MessagesRootsTree: AppendOnlyTree = await newTree( StandardTree, this.db, hasher, `${MerkleTreeId[MerkleTreeId.L1_TO_L2_MESSAGES_ROOTS_TREE]}`, - L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, + L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, ); this.trees = [ contractTree, From 24939a4d56254ea627afc5f5f69b0d82f2a98411 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 12:35:56 +0000 Subject: [PATCH 12/14] 972 - introduce per-call constants for public data read/update requests --- .../abis/public_circuit_public_inputs.hpp | 4 +- .../aztec3/circuits/kernel/public/.test.cpp | 54 +++++++++---------- circuits/cpp/src/aztec3/constants.hpp | 3 +- .../circuits.js/src/structs/constants.ts | 3 ++ .../structs/public_circuit_public_inputs.ts | 16 +++--- .../circuits.js/src/tests/factories.ts | 19 ++++--- .../src/sequencer/public_processor.ts | 8 +-- 7 files changed, 58 insertions(+), 49 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index bb31032e2c65..1f351b5e48c7 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -26,9 +26,9 @@ template struct PublicCircuitPublicInputs { fr args_hash = 0; std::array return_values{}; - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> contract_storage_update_requests{}; - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> contract_storage_reads{}; + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> contract_storage_reads{}; std::array public_call_stack{}; std::array new_commitments{}; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index 012222e85bb2..a0f5863e5773 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -70,11 +70,11 @@ template std::array empty_array_of_values() return values; } -std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> +std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> generate_contract_storage_update_requests(NT::uint32& count, - NT::uint32 num_values_required = MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) + NT::uint32 num_values_required = MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL) { - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> values; + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> values; for (size_t i = 0; i < num_values_required; i++) { const auto prev = count++; values[i] = ContractStorageUpdateRequest{ @@ -86,10 +86,10 @@ generate_contract_storage_update_requests(NT::uint32& count, return values; } -std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> generate_contract_storage_reads( - NT::uint32& count, NT::uint32 num_values_required = MAX_KERNEL_PUBLIC_DATA_READS_PER_TX) +std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> generate_contract_storage_reads( + NT::uint32& count, NT::uint32 num_values_required = MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL) { - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> values; + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> values; for (size_t i = 0; i < num_values_required; i++) { const auto prev = count++; values[i] = ContractStorageRead{ @@ -131,9 +131,9 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, array_of_values(count); std::array const new_l2_to_l1_msgs = array_of_values(count); - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const reads = generate_contract_storage_reads(count); - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const update_requests = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> const update_requests = generate_contract_storage_update_requests(count); // create the public circuit public inputs @@ -177,12 +177,12 @@ PublicDataUpdateRequest public_data_update_request_from_contract_storage_upd }; } -std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> public_data_reads_from_contract_storage_reads( - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const& public_data_reads, +std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> public_data_reads_from_contract_storage_reads( + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const& public_data_reads, NT::fr const& contract_address) { - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> values; - for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; i++) { + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> values; + for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL; i++) { const auto& read = public_data_reads[i]; if (read.is_empty()) { continue; @@ -192,12 +192,12 @@ std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> public_data_ return values; } -std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> +std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> public_data_update_requests_from_contract_storage_update_requests( - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const& update_requests, + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> const& update_requests, NT::fr const& contract_address) { - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> values; + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> values; for (size_t i = 0; i < MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX; i++) { const auto& update_request = update_requests[i]; if (update_request.is_empty()) { @@ -315,10 +315,10 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat std::array const return_values = array_of_values(seed, RETURN_VALUES_LENGTH / 2); - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const update_requests = - generate_contract_storage_update_requests(seed, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX / 2); - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const reads = - generate_contract_storage_reads(seed, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX / 2); + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> const update_requests = + generate_contract_storage_update_requests(seed, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL / 2); + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const reads = + generate_contract_storage_reads(seed, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL / 2); std::array const new_commitments = array_of_values(seed, MAX_NEW_COMMITMENTS_PER_CALL / 2); std::array const new_nullifiers = @@ -495,8 +495,8 @@ TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) .storage_slot = 123456789, .current_value = 76543, }; - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> reads = - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX>(); + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL>(); reads[1] = first_valid; reads[3] = second_valid; inputs.public_call.call_stack_item.public_inputs.contract_storage_reads = reads; @@ -540,8 +540,8 @@ TEST(public_kernel_tests, only_valid_update_requests_should_be_propagated) .old_value = 86543, .new_value = 86544, }; - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> update_requests = - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> update_requests = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL>(); update_requests[1] = first_valid; update_requests[3] = second_valid; inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = update_requests; @@ -1069,7 +1069,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre const auto contract_address = inputs.public_call.call_stack_item.contract_address; const auto portal_contract_address = inputs.public_call.portal_contract_address; - std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> const expected_new_writes = + std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> const expected_new_writes = public_data_update_requests_from_contract_storage_update_requests( inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests, contract_address); @@ -1094,7 +1094,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre expected_new_writes, public_inputs.end.public_data_update_requests)); - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const expected_new_reads = + std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const expected_new_reads = public_data_reads_from_contract_storage_reads( inputs.public_call.call_stack_item.public_inputs.contract_storage_reads, contract_address); @@ -1178,7 +1178,7 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_commitments_on_static // set previously set items to 0 inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = - empty_array_of_values, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); + empty_array_of_values, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL>(); // regenerate call data hash inputs.previous_kernel.public_inputs.end.public_call_stack[0] = @@ -1202,7 +1202,7 @@ TEST(public_kernel_tests, public_kernel_fails_creating_new_nullifiers_on_static_ // set previously set items to 0 inputs.public_call.call_stack_item.public_inputs.contract_storage_update_requests = - empty_array_of_values, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(); + empty_array_of_values, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL>(); inputs.public_call.call_stack_item.public_inputs.new_commitments = empty_array_of_values(); diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 7580eea4e2c3..205bfe777f7a 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -45,7 +45,8 @@ constexpr size_t MAX_NEW_NULLIFIERS_PER_CALL = 4; constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; - +constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 4; +constexpr size_t MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL = 4; // "PER TRANSACTION" CONSTANTS constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index e4f3b56ba91f..f5beb4294087 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -12,6 +12,8 @@ export const MAX_NEW_NULLIFIERS_PER_CALL = 4; export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; +export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 4; +export const MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL = 4; // "PER TRANSACTION" CONSTANTS export const MAX_NEW_COMMITMENTS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL @@ -47,6 +49,7 @@ export const L1_TO_L2_MSG_SUBTREE_HEIGHT = Math.ceil(Math.log2(NUMBER_OF_L1_L2_M export const L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = L1_TO_L2_MSG_TREE_HEIGHT - L1_TO_L2_MSG_SUBTREE_HEIGHT; +// MISC CONSTANTS export const FUNCTION_SELECTOR_NUM_BYTES = 4; export const MAPPING_SLOT_PEDERSEN_SEPARATOR = 4; // sha256 hash is stored in two fields to accommodate all 256-bits of the hash diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 44ae665f6b97..725fabf327a5 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -6,8 +6,8 @@ import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_NEW_COMMITMENTS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, MAX_NEW_NULLIFIERS_PER_CALL, @@ -152,12 +152,12 @@ export class PublicCircuitPublicInputs { */ public contractStorageUpdateRequests: Tuple< ContractStorageUpdateRequest, - typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX + typeof MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL >, /** * Contract storage reads executed during the call. */ - public contractStorageReads: Tuple, + public contractStorageReads: Tuple, /** * Public call stack of the current kernel iteration. */ @@ -197,8 +197,8 @@ export class PublicCircuitPublicInputs { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_CALL); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); - assertMemberLength(this, 'contractStorageUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); - assertMemberLength(this, 'contractStorageReads', MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); + assertMemberLength(this, 'contractStorageUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL); + assertMemberLength(this, 'contractStorageReads', MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); } @@ -220,8 +220,8 @@ export class PublicCircuitPublicInputs { CallContext.empty(), Fr.ZERO, makeTuple(RETURN_VALUES_LENGTH, Fr.zero), - makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, ContractStorageUpdateRequest.empty), - makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, ContractStorageRead.empty), + makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, ContractStorageUpdateRequest.empty), + makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, ContractStorageRead.empty), makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, Fr.zero), makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, Fr.zero), diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index f87d9e7f737c..8cf93252d70c 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -35,6 +35,8 @@ import { MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, + MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, KernelCircuitPublicInputs, L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, @@ -311,8 +313,8 @@ export function makePublicCircuitPublicInputs( makeCallContext(seed, storageContractAddress), fr(seed + 0x100), tupleGenerator(RETURN_VALUES_LENGTH, fr, seed + 0x200), - tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makeContractStorageUpdateRequest, seed + 0x400), - tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makeContractStorageRead, seed + 0x500), + tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, makeContractStorageUpdateRequest, seed + 0x400), + tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, makeContractStorageRead, seed + 0x500), tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), tupleGenerator(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x800), @@ -512,7 +514,11 @@ export async function makeWitnessedPublicCallData(seed = 1): Promise makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), ), - makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), seed + 0x200), + makeTuple( + MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), + seed + 0x200, + ), fr(seed + 0x300), ); } @@ -871,10 +877,9 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { seed + 0x5000, ).map(x => fr(x)); - const newPublicDataUpdateRequestsSiblingPaths = range( - 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, - seed + 0x6000, - ).map(x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr)); + const newPublicDataUpdateRequestsSiblingPaths = range(2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, seed + 0x6000).map( + x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr), + ); const newPublicDataReadsSiblingPaths = range(2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, seed + 0x6000).map(x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr), diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index 15e5578d358d..c4f0bccec6b7 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -6,8 +6,8 @@ import { ContractStorageUpdateRequest, Fr, GlobalVariables, - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, KernelCircuitPublicInputs, MembershipWitness, MAX_NEW_COMMITMENTS_PER_CALL, @@ -217,12 +217,12 @@ export class PublicProcessor { contractStorageReads: padArrayEnd( result.contractStorageReads, ContractStorageRead.empty(), - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, ), contractStorageUpdateRequests: padArrayEnd( result.contractStorageUpdateRequests, ContractStorageUpdateRequest.empty(), - MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, ), publicCallStack, unencryptedLogsHash, From 09602f69fcec63246ff0d2e47e6e37ce13d46b90 Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 12:38:59 +0000 Subject: [PATCH 13/14] 972 - remove kernel word in some constants --- .../abis/combined_accumulated_data.hpp | 2 +- .../abis/public_circuit_public_inputs.hpp | 2 +- .../abis/rollup/base/base_rollup_inputs.hpp | 2 +- .../aztec3/circuits/kernel/public/.test.cpp | 34 +++++++++---------- .../aztec3/circuits/kernel/public/common.hpp | 2 +- .../base/native_base_rollup_circuit.cpp | 8 ++--- .../circuits/rollup/test_utils/utils.cpp | 4 +-- circuits/cpp/src/aztec3/constants.hpp | 4 +-- .../src/kernel/public_kernel.test.ts | 4 +-- .../circuits.js/src/structs/constants.ts | 4 +-- .../kernel/combined_accumulated_data.ts | 10 +++--- .../src/structs/kernel/public_kernel.ts | 4 +-- .../structs/public_circuit_public_inputs.ts | 8 ++--- .../src/structs/rollup/base_rollup.ts | 4 +-- .../circuits.js/src/tests/factories.ts | 14 ++++---- .../src/sequencer/public_processor.ts | 4 +-- 16 files changed, 55 insertions(+), 55 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp index d31c8fb74b96..5bd8b8f0afbc 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/combined_accumulated_data.hpp @@ -45,7 +45,7 @@ template struct CombinedAccumulatedData { std::array, MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX> optionally_revealed_data{}; std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> public_data_update_requests{}; - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> public_data_reads{}; + std::array, MAX_PUBLIC_DATA_READS_PER_TX> public_data_reads{}; // for serialization, update with new fields MSGPACK_FIELDS(aggregation_object, diff --git a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp index 1f351b5e48c7..6e8363e8f3e3 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/public_circuit_public_inputs.hpp @@ -28,7 +28,7 @@ template struct PublicCircuitPublicInputs { std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> contract_storage_update_requests{}; - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> contract_storage_reads{}; + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> contract_storage_reads{}; std::array public_call_stack{}; std::array new_commitments{}; diff --git a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp index f844db81bfb1..0d73150af0b4 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/rollup/base/base_rollup_inputs.hpp @@ -32,7 +32,7 @@ template struct BaseRollupInputs { std::array new_contracts_subtree_sibling_path; std::array, 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX> new_public_data_update_requests_sibling_paths; - std::array, 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> + std::array, 2 * MAX_PUBLIC_DATA_READS_PER_TX> new_public_data_reads_sibling_paths; std::array, 2> diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index a0f5863e5773..a98cf7a923f0 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -86,10 +86,10 @@ generate_contract_storage_update_requests(NT::uint32& count, return values; } -std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> generate_contract_storage_reads( - NT::uint32& count, NT::uint32 num_values_required = MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL) +std::array, MAX_PUBLIC_DATA_READS_PER_CALL> generate_contract_storage_reads( + NT::uint32& count, NT::uint32 num_values_required = MAX_PUBLIC_DATA_READS_PER_CALL) { - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> values; + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> values; for (size_t i = 0; i < num_values_required; i++) { const auto prev = count++; values[i] = ContractStorageRead{ @@ -131,7 +131,7 @@ PublicCallStackItem generate_call_stack_item(NT::fr contract_address, array_of_values(count); std::array const new_l2_to_l1_msgs = array_of_values(count); - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const reads = + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> const reads = generate_contract_storage_reads(count); std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> const update_requests = generate_contract_storage_update_requests(count); @@ -177,12 +177,12 @@ PublicDataUpdateRequest public_data_update_request_from_contract_storage_upd }; } -std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> public_data_reads_from_contract_storage_reads( - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const& public_data_reads, +std::array, MAX_PUBLIC_DATA_READS_PER_CALL> public_data_reads_from_contract_storage_reads( + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> const& public_data_reads, NT::fr const& contract_address) { - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> values; - for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL; i++) { + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> values; + for (size_t i = 0; i < MAX_PUBLIC_DATA_READS_PER_CALL; i++) { const auto& read = public_data_reads[i]; if (read.is_empty()) { continue; @@ -317,8 +317,8 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat array_of_values(seed, RETURN_VALUES_LENGTH / 2); std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL> const update_requests = generate_contract_storage_update_requests(seed, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL / 2); - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const reads = - generate_contract_storage_reads(seed, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL / 2); + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> const reads = + generate_contract_storage_reads(seed, MAX_PUBLIC_DATA_READS_PER_CALL / 2); std::array const new_commitments = array_of_values(seed, MAX_NEW_COMMITMENTS_PER_CALL / 2); std::array const new_nullifiers = @@ -407,7 +407,7 @@ PublicKernelInputs get_kernel_inputs_with_previous_kernel(NT::boolean privat std::array, MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX>(), .public_data_update_requests = std::array, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX>(), - .public_data_reads = std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX>() + .public_data_reads = std::array, MAX_PUBLIC_DATA_READS_PER_TX>() }; const KernelCircuitPublicInputs public_inputs = { @@ -451,7 +451,7 @@ void validate_public_kernel_outputs_correctly_propagated(const KernelInput& inpu } size_t sr_index = 0; - for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; i++) { + for (size_t i = 0; i < MAX_PUBLIC_DATA_READS_PER_TX; i++) { const auto& read = inputs.public_call.call_stack_item.public_inputs.contract_storage_reads[i]; if (read.is_empty()) { continue; @@ -495,8 +495,8 @@ TEST(public_kernel_tests, only_valid_public_data_reads_should_be_propagated) .storage_slot = 123456789, .current_value = 76543, }; - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> reads = - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL>(); + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> reads = + std::array, MAX_PUBLIC_DATA_READS_PER_CALL>(); reads[1] = first_valid; reads[3] = second_valid; inputs.public_call.call_stack_item.public_inputs.contract_storage_reads = reads; @@ -1014,8 +1014,8 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre .leaf_index = 987654321, .value = 96544, }; - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> initial_reads = - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX>(); + std::array, MAX_PUBLIC_DATA_READS_PER_TX> initial_reads = + std::array, MAX_PUBLIC_DATA_READS_PER_TX>(); initial_reads[0] = first_read; initial_reads[1] = second_read; inputs.previous_kernel.public_inputs.end.public_data_reads = initial_reads; @@ -1094,7 +1094,7 @@ TEST(public_kernel_tests, circuit_outputs_should_be_correctly_populated_with_pre expected_new_writes, public_inputs.end.public_data_update_requests)); - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL> const expected_new_reads = + std::array, MAX_PUBLIC_DATA_READS_PER_CALL> const expected_new_reads = public_data_reads_from_contract_storage_reads( inputs.public_call.call_stack_item.public_inputs.contract_storage_reads, contract_address); diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index d5600e54baee..0f610df737ff 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -255,7 +255,7 @@ void propagate_valid_public_data_reads(Builder& builder, { const auto& contract_address = public_kernel_inputs.public_call.call_stack_item.contract_address; const auto& reads = public_kernel_inputs.public_call.call_stack_item.public_inputs.contract_storage_reads; - for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; ++i) { + for (size_t i = 0; i < MAX_PUBLIC_DATA_READS_PER_TX; ++i) { const auto& contract_storage_read = reads[i]; if (contract_storage_read.is_empty()) { continue; diff --git a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp index 07c1a398540f..27f857499ae3 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/base/native_base_rollup_circuit.cpp @@ -408,11 +408,11 @@ fr insert_public_data_update_requests( void validate_public_data_reads( DummyBuilder& builder, fr tree_root, - std::array, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const& public_data_reads, + std::array, MAX_PUBLIC_DATA_READS_PER_TX> const& public_data_reads, size_t witnesses_offset, - std::array, 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX> const& witnesses) + std::array, 2 * MAX_PUBLIC_DATA_READS_PER_TX> const& witnesses) { - for (size_t i = 0; i < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; ++i) { + for (size_t i = 0; i < MAX_PUBLIC_DATA_READS_PER_TX; ++i) { const auto& public_data_read = public_data_reads[i]; const auto& witness = witnesses[i + witnesses_offset]; @@ -450,7 +450,7 @@ fr validate_and_process_public_state(DummyBuilder& builder, BaseRollupInputs con validate_public_data_reads(builder, mid_public_data_tree_root, baseRollupInputs.kernel_data[1].public_inputs.end.public_data_reads, - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_READS_PER_TX, baseRollupInputs.new_public_data_reads_sibling_paths); auto end_public_data_tree_root = insert_public_data_update_requests( diff --git a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp index cde217de2f5d..c9f4821122fb 100644 --- a/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp +++ b/circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp @@ -183,13 +183,13 @@ BaseRollupInputs base_rollup_inputs_from_kernels(std::array kerne // Then we collect all sibling paths for the reads in the left tx, and then apply the update requests while // collecting their paths. And then repeat for the right tx. for (size_t i = 0; i < 2; i++) { - for (size_t j = 0; j < MAX_KERNEL_PUBLIC_DATA_READS_PER_TX; j++) { + for (size_t j = 0; j < MAX_PUBLIC_DATA_READS_PER_TX; j++) { auto public_data_read = kernel_data[i].public_inputs.end.public_data_reads[j]; if (public_data_read.is_empty()) { continue; } auto leaf_index = uint256_t(public_data_read.leaf_index); - baseRollupInputs.new_public_data_reads_sibling_paths[i * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX + j] = + baseRollupInputs.new_public_data_reads_sibling_paths[i * MAX_PUBLIC_DATA_READS_PER_TX + j] = get_sibling_path(public_data_tree, leaf_index); } diff --git a/circuits/cpp/src/aztec3/constants.hpp b/circuits/cpp/src/aztec3/constants.hpp index 205bfe777f7a..113fc12d480d 100644 --- a/circuits/cpp/src/aztec3/constants.hpp +++ b/circuits/cpp/src/aztec3/constants.hpp @@ -46,7 +46,7 @@ constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 4; -constexpr size_t MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL = 4; +constexpr size_t MAX_PUBLIC_DATA_READS_PER_CALL = 4; // "PER TRANSACTION" CONSTANTS constexpr size_t MAX_NEW_COMMITMENTS_PER_TX = MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL; @@ -55,7 +55,7 @@ constexpr size_t MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; constexpr size_t MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; constexpr size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4; -constexpr size_t MAX_KERNEL_PUBLIC_DATA_READS_PER_TX = 4; +constexpr size_t MAX_PUBLIC_DATA_READS_PER_TX = 4; constexpr size_t MAX_NEW_CONTRACTS_PER_TX = 1; constexpr size_t MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; constexpr size_t NUM_ENCRYPTED_LOGS_HASHES_PER_TX = 1; diff --git a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts index 4b35456da80f..e8ffc4487457 100644 --- a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts +++ b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts @@ -1,4 +1,4 @@ -import { CircuitError, MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makeTuple, simulatePublicKernelCircuit } from '../index.js'; +import { CircuitError, MAX_PUBLIC_DATA_READS_PER_TX, makeTuple, simulatePublicKernelCircuit } from '../index.js'; import { makePublicDataRead, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; describe('kernel/public_kernel', () => { @@ -27,7 +27,7 @@ describe('kernel/public_kernel', () => { input.previousKernel.publicInputs.isPrivate = false; // Cause array overflow - const fullStateReadsObject = makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, 0x01); + const fullStateReadsObject = makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, 0x01); input.previousKernel.publicInputs.end.publicDataReads = fullStateReadsObject; await expect(simulatePublicKernelCircuit(input)).rejects.toThrow( diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index f5beb4294087..1faa1762c1fc 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -13,7 +13,7 @@ export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL = 4; export const MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 4; -export const MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL = 4; +export const MAX_PUBLIC_DATA_READS_PER_CALL = 4; // "PER TRANSACTION" CONSTANTS export const MAX_NEW_COMMITMENTS_PER_TX = 16; // MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL * MAX_NEW_COMMITMENTS_PER_CALL @@ -22,7 +22,7 @@ export const MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX = 8; export const MAX_NEW_L2_TO_L1_MSGS_PER_TX = 2; export const MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = 4; -export const MAX_KERNEL_PUBLIC_DATA_READS_PER_TX = 4; +export const MAX_PUBLIC_DATA_READS_PER_TX = 4; export const MAX_NEW_CONTRACTS_PER_TX = 1; export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; 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 ff0422e818fb..1effffde3fea 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 @@ -8,7 +8,7 @@ import { MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, NUM_FIELDS_PER_SHA256, @@ -328,7 +328,7 @@ export class CombinedAccumulatedData { /** * All the public data reads made in this transaction. */ - public publicDataReads: Tuple, + public publicDataReads: Tuple, ) { assertMemberLength(this, 'newCommitments', MAX_NEW_COMMITMENTS_PER_TX); assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_TX); @@ -340,7 +340,7 @@ export class CombinedAccumulatedData { assertMemberLength(this, 'newContracts', MAX_NEW_CONTRACTS_PER_TX); assertMemberLength(this, 'optionallyRevealedData', MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX); assertMemberLength(this, 'publicDataUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); - assertMemberLength(this, 'publicDataReads', MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); + assertMemberLength(this, 'publicDataReads', MAX_PUBLIC_DATA_READS_PER_TX); } toBuffer() { @@ -387,7 +387,7 @@ export class CombinedAccumulatedData { reader.readArray(MAX_NEW_CONTRACTS_PER_TX, NewContractData), reader.readArray(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData), reader.readArray(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest), - reader.readArray(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, PublicDataRead), + reader.readArray(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead), ); } @@ -415,7 +415,7 @@ export class CombinedAccumulatedData { makeTuple(MAX_NEW_CONTRACTS_PER_TX, NewContractData.empty), makeTuple(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, OptionallyRevealedData.empty), makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PublicDataUpdateRequest.empty), - makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, PublicDataRead.empty), + makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, PublicDataRead.empty), ); } } diff --git a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts index 8a0eb87286e8..f1ff09d66aef 100644 --- a/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts +++ b/yarn-project/circuits.js/src/structs/kernel/public_kernel.ts @@ -4,7 +4,7 @@ import { assertMemberLength } from '../../utils/jsUtils.js'; import { serializeToBuffer } from '../../utils/serialize.js'; import { PublicCallStackItem } from '../call_stack_item.js'; import { - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, PUBLIC_DATA_TREE_HEIGHT, @@ -57,7 +57,7 @@ export class WitnessedPublicCallData { public readonly publicDataTreeRoot: Fr, ) { assertMemberLength(this, 'updateRequestsHashPaths', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); - assertMemberLength(this, 'readsHashPaths', MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); + assertMemberLength(this, 'readsHashPaths', MAX_PUBLIC_DATA_READS_PER_TX); } toBuffer() { diff --git a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts index 725fabf327a5..091333bb4528 100644 --- a/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/public_circuit_public_inputs.ts @@ -6,7 +6,7 @@ import { FieldsOf, assertMemberLength, makeTuple } from '../utils/jsUtils.js'; import { serializeToBuffer } from '../utils/serialize.js'; import { CallContext } from './call_context.js'; import { - MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, MAX_NEW_COMMITMENTS_PER_CALL, MAX_NEW_L2_TO_L1_MSGS_PER_CALL, @@ -157,7 +157,7 @@ export class PublicCircuitPublicInputs { /** * Contract storage reads executed during the call. */ - public contractStorageReads: Tuple, + public contractStorageReads: Tuple, /** * Public call stack of the current kernel iteration. */ @@ -198,7 +198,7 @@ export class PublicCircuitPublicInputs { assertMemberLength(this, 'newNullifiers', MAX_NEW_NULLIFIERS_PER_CALL); assertMemberLength(this, 'newL2ToL1Msgs', MAX_NEW_L2_TO_L1_MSGS_PER_CALL); assertMemberLength(this, 'contractStorageUpdateRequests', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL); - assertMemberLength(this, 'contractStorageReads', MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL); + assertMemberLength(this, 'contractStorageReads', MAX_PUBLIC_DATA_READS_PER_CALL); assertMemberLength(this, 'unencryptedLogsHash', NUM_FIELDS_PER_SHA256); } @@ -221,7 +221,7 @@ export class PublicCircuitPublicInputs { Fr.ZERO, makeTuple(RETURN_VALUES_LENGTH, Fr.zero), makeTuple(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, ContractStorageUpdateRequest.empty), - makeTuple(MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, ContractStorageRead.empty), + makeTuple(MAX_PUBLIC_DATA_READS_PER_CALL, ContractStorageRead.empty), makeTuple(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, Fr.zero), makeTuple(MAX_NEW_COMMITMENTS_PER_CALL, Fr.zero), makeTuple(MAX_NEW_NULLIFIERS_PER_CALL, Fr.zero), diff --git a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts index f67792ca95fc..3949528b383c 100644 --- a/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/base_rollup.ts @@ -8,7 +8,7 @@ import { MAX_NEW_COMMITMENTS_PER_TX, MAX_NEW_CONTRACTS_PER_TX, MAX_NEW_NULLIFIERS_PER_TX, - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, @@ -248,7 +248,7 @@ export class BaseRollupInputs { CONTRACT_TREE_HEIGHT - BaseRollupInputs.CONTRACT_SUBTREE_HEIGHT, ); assertMemberLength(this, 'newPublicDataUpdateRequestsSiblingPaths', 2 * MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX); - assertMemberLength(this, 'newPublicDataReadsSiblingPaths', 2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX); + assertMemberLength(this, 'newPublicDataReadsSiblingPaths', 2 * MAX_PUBLIC_DATA_READS_PER_TX); assertItemsLength(this, 'newPublicDataUpdateRequestsSiblingPaths', PUBLIC_DATA_TREE_HEIGHT); assertItemsLength(this, 'newPublicDataReadsSiblingPaths', PUBLIC_DATA_TREE_HEIGHT); } diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 8cf93252d70c..a99207ece479 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -33,10 +33,10 @@ import { MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, MAX_PRIVATE_CALL_STACK_LENGTH_PER_TX, MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX, - MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, + MAX_PUBLIC_DATA_READS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, - MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_READS_PER_CALL, KernelCircuitPublicInputs, L1_TO_L2_MSG_ROOTS_TREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, @@ -215,7 +215,7 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xb00), tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makeEmptyPublicDataUpdateRequest, seed + 0xc00), - tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makeEmptyPublicDataRead, seed + 0xd00), + tupleGenerator(MAX_PUBLIC_DATA_READS_PER_TX, makeEmptyPublicDataRead, seed + 0xd00), ); } @@ -241,7 +241,7 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated tupleGenerator(MAX_NEW_CONTRACTS_PER_TX, makeNewContractData, seed + 0xa00), tupleGenerator(MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX, makeOptionallyRevealedData, seed + 0xb00), tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, makePublicDataUpdateRequest, seed + 0xc00), - tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, seed + 0xd00), + tupleGenerator(MAX_PUBLIC_DATA_READS_PER_TX, makePublicDataRead, seed + 0xd00), ); } @@ -314,7 +314,7 @@ export function makePublicCircuitPublicInputs( fr(seed + 0x100), tupleGenerator(RETURN_VALUES_LENGTH, fr, seed + 0x200), tupleGenerator(MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, makeContractStorageUpdateRequest, seed + 0x400), - tupleGenerator(MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, makeContractStorageRead, seed + 0x500), + tupleGenerator(MAX_PUBLIC_DATA_READS_PER_CALL, makeContractStorageRead, seed + 0x500), tupleGenerator(MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, fr, seed + 0x600), tupleGenerator(MAX_NEW_COMMITMENTS_PER_CALL, fr, seed + 0x700), tupleGenerator(MAX_NEW_NULLIFIERS_PER_CALL, fr, seed + 0x800), @@ -515,7 +515,7 @@ export async function makeWitnessedPublicCallData(seed = 1): Promise makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), seed + 0x200, ), @@ -881,7 +881,7 @@ export function makeBaseRollupInputs(seed = 0): BaseRollupInputs { x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr), ); - const newPublicDataReadsSiblingPaths = range(2 * MAX_KERNEL_PUBLIC_DATA_READS_PER_TX, seed + 0x6000).map(x => + const newPublicDataReadsSiblingPaths = range(2 * MAX_PUBLIC_DATA_READS_PER_TX, seed + 0x6000).map(x => range(PUBLIC_DATA_TREE_HEIGHT, x).map(fr), ); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index c4f0bccec6b7..2eb71fbf2919 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -6,7 +6,7 @@ import { ContractStorageUpdateRequest, Fr, GlobalVariables, - MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_READS_PER_CALL, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL, KernelCircuitPublicInputs, MembershipWitness, @@ -217,7 +217,7 @@ export class PublicProcessor { contractStorageReads: padArrayEnd( result.contractStorageReads, ContractStorageRead.empty(), - MAX_KERNEL_PUBLIC_DATA_READS_PER_CALL, + MAX_PUBLIC_DATA_READS_PER_CALL, ), contractStorageUpdateRequests: padArrayEnd( result.contractStorageUpdateRequests, From fc9c0a39b6a9b5dc7fb291940f06a583b72f080d Mon Sep 17 00:00:00 2001 From: jeanmon Date: Mon, 10 Jul 2023 12:42:03 +0000 Subject: [PATCH 14/14] 972 - TS prettier --- .../acir-simulator/src/client/private_execution.test.ts | 4 +++- yarn-project/acir-simulator/src/client/private_execution.ts | 6 +++++- yarn-project/aztec-cli/tsconfig.json | 2 +- yarn-project/circuits.js/src/structs/constants.ts | 4 ---- yarn-project/circuits.js/src/tests/factories.ts | 6 +----- .../sequencer-client/src/sequencer/public_processor.ts | 4 +++- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 2b5ad32a14fa..463ca599100e 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -120,7 +120,9 @@ describe('Private Execution test suite', () => { it('should run the empty constructor', async () => { const abi = TestContractAbi.functions[0]; const result = await runSimulator({ abi, isConstructor: true }); - expect(result.callStackItem.publicInputs.newCommitments).toEqual(new Array(MAX_NEW_COMMITMENTS_PER_CALL).fill(Fr.ZERO)); + expect(result.callStackItem.publicInputs.newCommitments).toEqual( + new Array(MAX_NEW_COMMITMENTS_PER_CALL).fill(Fr.ZERO), + ); }); }); diff --git a/yarn-project/acir-simulator/src/client/private_execution.ts b/yarn-project/acir-simulator/src/client/private_execution.ts index f8aa15609b42..d1016f8f4c60 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.ts @@ -192,7 +192,11 @@ export class PrivateFunctionExecution { // TODO(#499): Noir fails to compute the enqueued calls preimages properly, since it cannot use pedersen generators, so we patch those values here. const publicCallStackItems = await Promise.all(enqueuedPublicFunctionCalls.map(c => c.toPublicCallStackItem())); const publicStack = await Promise.all(publicCallStackItems.map(c => computeCallStackItemHash(wasm, c))); - callStackItem.publicInputs.publicCallStack = padArrayEnd(publicStack, Fr.ZERO, MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL); + callStackItem.publicInputs.publicCallStack = padArrayEnd( + publicStack, + Fr.ZERO, + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL, + ); // TODO: This should be set manually by the circuit publicInputs.contractDeploymentData.deployerPublicKey = diff --git a/yarn-project/aztec-cli/tsconfig.json b/yarn-project/aztec-cli/tsconfig.json index acaee34074f4..dd0ea8ffb33d 100644 --- a/yarn-project/aztec-cli/tsconfig.json +++ b/yarn-project/aztec-cli/tsconfig.json @@ -18,4 +18,4 @@ ], "include": ["src"], "exclude": ["contracts"] -} \ No newline at end of file +} diff --git a/yarn-project/circuits.js/src/structs/constants.ts b/yarn-project/circuits.js/src/structs/constants.ts index 1faa1762c1fc..34fb6c6d677b 100644 --- a/yarn-project/circuits.js/src/structs/constants.ts +++ b/yarn-project/circuits.js/src/structs/constants.ts @@ -5,7 +5,6 @@ export const ARGS_LENGTH = 16; // MAX_ARGS in Noir export const RETURN_VALUES_LENGTH = 4; export const READ_REQUESTS_LENGTH = 4; - // "PER CALL" CONSTANTS export const MAX_NEW_COMMITMENTS_PER_CALL = 4; export const MAX_NEW_NULLIFIERS_PER_CALL = 4; @@ -29,7 +28,6 @@ export const MAX_OPTIONALLY_REVEALED_DATA_LENGTH_PER_TX = 4; // ROLLUP CONSTANTS export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16; - // TREES RELATED CONSTANTS export const VK_TREE_HEIGHT = 3; export const FUNCTION_TREE_HEIGHT = 4; @@ -43,12 +41,10 @@ export const CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8; export const L1_TO_L2_MSG_ROOTS_TREE_HEIGHT = 8; export const ROLLUP_VK_TREE_HEIGHT = 8; - // SUB-TREES RELATED CONSTANTS export const L1_TO_L2_MSG_SUBTREE_HEIGHT = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP)); export const L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = L1_TO_L2_MSG_TREE_HEIGHT - L1_TO_L2_MSG_SUBTREE_HEIGHT; - // MISC CONSTANTS export const FUNCTION_SELECTOR_NUM_BYTES = 4; export const MAPPING_SLOT_PEDERSEN_SEPARATOR = 4; diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index a99207ece479..b6d0903c37ac 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -514,11 +514,7 @@ export async function makeWitnessedPublicCallData(seed = 1): Promise makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), ), - makeTuple( - MAX_PUBLIC_DATA_READS_PER_TX, - x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), - seed + 0x200, - ), + makeTuple(MAX_PUBLIC_DATA_READS_PER_TX, x => makeMembershipWitness(PUBLIC_DATA_TREE_HEIGHT, x), seed + 0x200), fr(seed + 0x300), ); } diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index 2eb71fbf2919..6e57986eaba5 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -244,7 +244,9 @@ export class PublicProcessor { const nested = result.nestedExecutions; const preimages: PublicCallStackItem[] = await Promise.all(nested.map(n => this.getPublicCallStackItem(n))); if (preimages.length > MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) { - throw new Error(`Public call stack size exceeded (max ${MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL}, got ${preimages.length})`); + throw new Error( + `Public call stack size exceeded (max ${MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL}, got ${preimages.length})`, + ); } // Top of the stack is at the end of the array, so we padStart