From 29ba730c9710a1ade63349d18823b1aea11a03b1 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:51:27 +0000 Subject: [PATCH 1/7] fix: add array overflow composer error --- .../aztec3/circuits/kernel/private/common.cpp | 15 +++++----- .../native_private_kernel_circuit_init.cpp | 10 ++++--- .../aztec3/circuits/kernel/public/.test.cpp | 19 ++++++++++++ .../aztec3/circuits/kernel/public/common.hpp | 29 ++++++++++++------- ...blic_kernel_circuit_no_previous_kernel.cpp | 4 +-- ...kernel_circuit_private_previous_kernel.cpp | 2 +- ..._kernel_circuit_public_previous_kernel.cpp | 2 +- circuits/cpp/src/aztec3/utils/array.hpp | 24 +++++++++++---- .../cpp/src/aztec3/utils/circuit_errors.hpp | 2 ++ 9 files changed, 74 insertions(+), 33 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp index 0b5f9de4f2e3..7ef5f3366ed8 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp @@ -81,16 +81,16 @@ void common_update_end_values(DummyComposer& composer, new_nullifiers[i] == 0 ? 0 : silo_nullifier(storage_contract_address, new_nullifiers[i]); } - push_array_to_array(siloed_new_commitments, public_inputs.end.new_commitments); - push_array_to_array(siloed_new_nullifiers, public_inputs.end.new_nullifiers); + push_array_to_array(composer, siloed_new_commitments, public_inputs.end.new_commitments); + push_array_to_array(composer, siloed_new_nullifiers, public_inputs.end.new_nullifiers); } { // call stacks const auto& this_private_call_stack = private_call_public_inputs.private_call_stack; - push_array_to_array(this_private_call_stack, public_inputs.end.private_call_stack); + push_array_to_array(composer, this_private_call_stack, public_inputs.end.private_call_stack); const auto& this_public_call_stack = private_call_public_inputs.public_call_stack; - push_array_to_array(this_public_call_stack, public_inputs.end.public_call_stack); + push_array_to_array(composer, this_public_call_stack, public_inputs.end.public_call_stack); } { // new l2 to l1 messages @@ -109,7 +109,7 @@ void common_update_end_values(DummyComposer& composer, new_l2_to_l1_msgs[i]); } } - push_array_to_array(new_l2_to_l1_msgs_to_insert, public_inputs.end.new_l2_to_l1_msgs); + push_array_to_array(composer, new_l2_to_l1_msgs_to_insert, public_inputs.end.new_l2_to_l1_msgs); } } @@ -144,8 +144,7 @@ void common_contract_logic(DummyComposer& composer, portal_contract_address, contract_dep_data.function_tree_root }; - array_push, KERNEL_NEW_CONTRACTS_LENGTH>(public_inputs.end.new_contracts, - native_new_contract_data); + array_push(composer, public_inputs.end.new_contracts, native_new_contract_data); composer.do_assert(contract_dep_data.constructor_vk_hash == private_call_vk_hash, "constructor_vk_hash doesn't match private_call_vk_hash", CircuitErrorCode::PRIVATE_KERNEL__INVALID_CONSTRUCTOR_VK_HASH); @@ -160,7 +159,7 @@ void common_contract_logic(DummyComposer& composer, auto const new_contract_address_nullifier = NT::fr::serialize_from_buffer(NT::blake3s(blake_input).data()); // push the contract address nullifier to nullifier vector - array_push(public_inputs.end.new_nullifiers, new_contract_address_nullifier); + array_push(composer, public_inputs.end.new_nullifiers, new_contract_address_nullifier); } else { // non-contract deployments must specify contract address being interacted with composer.do_assert(storage_contract_address != 0, diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp index e2e97fb7d300..1739ebe80751 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/native_private_kernel_circuit_init.cpp @@ -123,20 +123,22 @@ void validate_inputs(DummyComposer& composer, PrivateKernelInputsInit const& // hard-coded into the circuit and assert that that is the one which has been used in the base case). } -void update_end_values(PrivateKernelInputsInit const& private_inputs, KernelCircuitPublicInputs& public_inputs) +void update_end_values(DummyComposer& composer, + PrivateKernelInputsInit const& private_inputs, + KernelCircuitPublicInputs& public_inputs) { // We only initialzed constants member of public_inputs so far. Therefore, there must not be any // new nullifiers as part of public_inputs. ASSERT(is_array_empty(public_inputs.end.new_nullifiers)); // Since it's the first iteration, we need to push the the tx hash nullifier into the `new_nullifiers` array - array_push(public_inputs.end.new_nullifiers, private_inputs.signed_tx_request.hash()); + array_push(composer, public_inputs.end.new_nullifiers, private_inputs.signed_tx_request.hash()); // Nonce nullifier // DANGER: This is terrible. This should not be part of the protocol. This is an intentional bodge to reach a // milestone. This must not be the way we derive nonce nullifiers in production. It can be front-run by other // users. It is not domain separated. Naughty. - array_push(public_inputs.end.new_nullifiers, private_inputs.signed_tx_request.tx_request.nonce); + array_push(composer, public_inputs.end.new_nullifiers, private_inputs.signed_tx_request.tx_request.nonce); } // NOTE: THIS IS A VERY UNFINISHED WORK IN PROGRESS. @@ -161,7 +163,7 @@ KernelCircuitPublicInputs native_private_kernel_circuit_initial(DummyCompose // TODO(jeanmon) FIXME - https://github.com/AztecProtocol/aztec-packages/issues/671 // common_validate_call_stack(composer, private_inputs.private_call); - update_end_values(private_inputs, public_inputs); + update_end_values(composer, private_inputs, public_inputs); common_update_end_values(composer, private_inputs.private_call, 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 4ef2ccdb4e9f..cd07c5cf248e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -1121,4 +1121,23 @@ TEST(public_kernel_tests, previous_public_kernel_fails_if_incorrect_storage_cont ASSERT_EQ(dummyComposer.get_first_failure().code, CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); } + +// TODO: make a -ve test where this fails +TEST(public_kernel_tests, public_kernel_failure_if_too_many_commitments_are_pushed) +{ + DummyComposer dummyComposer = DummyComposer( + "public_kernel_tests__previous_public_kernel_fails_if_incorrect_storage_contract_on_delegate_call"); + PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); + + // the function call has the contract address and storage contract address equal and so it should fail for a + // delegate call + inputs.public_call.call_stack_item.public_inputs.call_context.is_delegate_call = true; + + auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); + ASSERT_TRUE(dummyComposer.failed()); + ASSERT_EQ(dummyComposer.get_first_failure().code, + CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); +} + + } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index 1ba6ffdea03e..59d740f5cc57 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -9,6 +9,7 @@ #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs_no_previous_kernel.hpp" #include "aztec3/circuits/hash.hpp" +#include "aztec3/constants.hpp" #include "aztec3/utils/array.hpp" #include "aztec3/utils/dummy_composer.hpp" @@ -202,8 +203,9 @@ void common_validate_inputs(DummyComposer& composer, KernelInput const& public_k * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param circuit_outputs The circuit outputs to be populated */ -template -void propagate_valid_public_data_update_requests(KernelInput const& public_kernel_inputs, +template +void propagate_valid_public_data_update_requests(Composer& composer, + KernelInput const& public_kernel_inputs, KernelCircuitPublicInputs& circuit_outputs) { const auto& contract_address = public_kernel_inputs.public_call.call_stack_item.contract_address; @@ -219,7 +221,7 @@ void propagate_valid_public_data_update_requests(KernelInput const& public_kerne .old_value = compute_public_data_tree_value(update_request.old_value), .new_value = compute_public_data_tree_value(update_request.new_value), }; - array_push(circuit_outputs.end.public_data_update_requests, new_write); + array_push(composer, circuit_outputs.end.public_data_update_requests, new_write); } } @@ -229,8 +231,10 @@ void propagate_valid_public_data_update_requests(KernelInput const& public_kerne * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param circuit_outputs The circuit outputs to be populated */ -template void propagate_valid_public_data_reads(KernelInput const& public_kernel_inputs, - KernelCircuitPublicInputs& circuit_outputs) +template +void propagate_valid_public_data_reads(Composer& composer, + KernelInput const& public_kernel_inputs, + KernelCircuitPublicInputs& circuit_outputs) { 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; @@ -243,28 +247,31 @@ template void propagate_valid_public_data_reads(KernelInp .leaf_index = compute_public_data_tree_index(contract_address, contract_storage_read.storage_slot), .value = compute_public_data_tree_value(contract_storage_read.current_value), }; - array_push(circuit_outputs.end.public_data_reads, new_read); + array_push(composer, circuit_outputs.end.public_data_reads, new_read); } } /** * @brief Propagates valid (i.e. non-empty) public data reads from this iteration to the circuit output * @tparam The type of kernel input + * @tparam The current composer * @param public_kernel_inputs The inputs to this iteration of the kernel circuit * @param circuit_outputs The circuit outputs to be populated */ -template void common_update_public_end_values(KernelInput const& public_kernel_inputs, - KernelCircuitPublicInputs& circuit_outputs) +template +void common_update_public_end_values(Composer& composer, + KernelInput const& public_kernel_inputs, + KernelCircuitPublicInputs& circuit_outputs) { // Updates the circuit outputs with new state changes, call stack etc circuit_outputs.is_private = false; const auto& stack = public_kernel_inputs.public_call.call_stack_item.public_inputs.public_call_stack; - push_array_to_array(stack, circuit_outputs.end.public_call_stack); + push_array_to_array(composer, stack, circuit_outputs.end.public_call_stack); - propagate_valid_public_data_update_requests(public_kernel_inputs, circuit_outputs); + propagate_valid_public_data_update_requests(composer, public_kernel_inputs, circuit_outputs); - propagate_valid_public_data_reads(public_kernel_inputs, circuit_outputs); + propagate_valid_public_data_reads(composer, public_kernel_inputs, circuit_outputs); } /** diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_no_previous_kernel.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_no_previous_kernel.cpp index 8cde730ba83a..52b833007a63 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_no_previous_kernel.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_no_previous_kernel.cpp @@ -66,9 +66,9 @@ void update_public_end_values(DummyComposer& composer, "new_nullifiers array must be empty in a first iteration of public kernel", CircuitErrorCode::PUBLIC_KERNEL__NEW_NULLIFIERS_NOT_EMPTY_IN_FIRST_ITERATION); - array_push(circuit_outputs.end.new_nullifiers, public_kernel_inputs.signed_tx_request.hash()); + array_push(composer, circuit_outputs.end.new_nullifiers, public_kernel_inputs.signed_tx_request.hash()); - common_update_public_end_values(public_kernel_inputs, circuit_outputs); + common_update_public_end_values(composer, public_kernel_inputs, circuit_outputs); } } // namespace diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp index d9acbdeb8a21..cb5e96c05115 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_private_previous_kernel.cpp @@ -65,7 +65,7 @@ KernelCircuitPublicInputs native_public_kernel_circuit_private_previous_kern validate_this_public_call_hash(composer, public_kernel_inputs, public_inputs); // update the public end state of the circuit - common_update_public_end_values(public_kernel_inputs, public_inputs); + common_update_public_end_values(composer, public_kernel_inputs, public_inputs); return public_inputs; }; diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp index ca10aa1c4284..6179bf3954b0 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/native_public_kernel_circuit_public_previous_kernel.cpp @@ -60,7 +60,7 @@ KernelCircuitPublicInputs native_public_kernel_circuit_public_previous_kerne validate_this_public_call_hash(composer, public_kernel_inputs, public_inputs); // update the public end state of the circuit - common_update_public_end_values(public_kernel_inputs, public_inputs); + common_update_public_end_values(composer, public_kernel_inputs, public_inputs); return public_inputs; }; diff --git a/circuits/cpp/src/aztec3/utils/array.hpp b/circuits/cpp/src/aztec3/utils/array.hpp index fc7da729a8cd..ee5025fb90e3 100644 --- a/circuits/cpp/src/aztec3/utils/array.hpp +++ b/circuits/cpp/src/aztec3/utils/array.hpp @@ -1,6 +1,9 @@ #pragma once #include "./types/native_types.hpp" +#include "aztec3/utils/circuit_errors.hpp" + +#include "barretenberg/proof_system/types/composer_type.hpp" #include /** @@ -97,10 +100,12 @@ template T array_pop(std::array& arr) /** * @brief Helper method to push an item into the first empty slot in an array * @tparam The type of the value stored in the array + * @tparam The composer type * @tparam The size of the array * @param The array into which we want to store the value */ -template void array_push(std::array& arr, T const& value) +template +void array_push(Composer& composer, std::array& arr, T const& value) { for (size_t i = 0; i < arr.size(); ++i) { if (is_empty(arr[i])) { @@ -108,7 +113,8 @@ template void array_push(std::array& arr, T c return; } } - throw_or_abort("array_push cannot push to a full array"); + // TODO(sean): update error types + composer.do_assert(false, "array_push cannot push to a full array", CircuitErrorCode::ARRAY_OVERFLOW); }; /** @@ -137,17 +143,23 @@ template NT::boolean is_array_empty(std::array -void push_array_to_array(std::array const& source, std::array& target) +template +void push_array_to_array(Composer& composer, std::array const& source, std::array& target) { // Check if the `source` array is too large vs the remaining capacity of the `target` array size_t const source_size = static_cast(uint256_t(array_length(source))); size_t const target_size = static_cast(uint256_t(array_length(target))); - ASSERT(source_size <= size_2 - target_size); + + // TODO(SEAN): Are these asserts making it into the wasm builds + composer.do_assert(source_size <= size_2 - target_size, + "push_array_to_array cannot overflow the target", + CircuitErrorCode::ARRAY_OVERFLOW); // Ensure that there are no non-zero values in the `target` array after the first zero-valued index + // TODO: FILL THIS IN INCLUDING ERROR TYPE for (size_t i = target_size; i < size_2; i++) { - ASSERT(is_empty(target[i])); + composer.do_assert( + is_empty(target[i]), "TODO: FILL THIS IN INCLUDING ERROR TYPE", CircuitErrorCode::ARRAY_OVERFLOW); } // Copy the non-zero elements of the `source` array to the `target` array at the first zero-valued index auto zero_index = target_size; diff --git a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp index 7ad669af5c4f..d1e006af99e0 100644 --- a/circuits/cpp/src/aztec3/utils/circuit_errors.hpp +++ b/circuits/cpp/src/aztec3/utils/circuit_errors.hpp @@ -75,8 +75,10 @@ enum CircuitErrorCode : uint16_t { CONTRACT_TREE_SNAPSHOT_MISMATCH = 7006, PUBLIC_DATA_TREE_ROOT_MISMATCH = 7007, MEMBERSHIP_CHECK_FAILED = 7008, + ARRAY_OVERFLOW = 7009, ROOT_CIRCUIT_FAILED = 8000, + }; struct CircuitError { From 0e4ed788d69db3d3d2e641ba451805412a3c8c24 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:07:19 +0000 Subject: [PATCH 2/7] fix: add negative test case for array overflow --- .../aztec3/circuits/kernel/private/.test.cpp | 25 +++++++++++++++++++ .../aztec3/circuits/kernel/public/.test.cpp | 18 ------------- circuits/cpp/src/aztec3/utils/array.hpp | 7 +++--- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index 1d4b3647b61c..f4c5d2e2d38e 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -670,6 +670,7 @@ TEST(private_kernel_tests, circuit_create_proof_cbinds) free((void*)public_inputs_buf); } + /** * @brief Test this dummy cbind */ @@ -685,4 +686,28 @@ TEST(private_kernel_tests, cbind_private_kernel__dummy_previous_kernel) EXPECT_EQ(actual_ss.str(), expected_ss.str()); } +TEST(private_kernel_tests, private_kernel_should_fail_if_aggregating_too_many_commitments) +{ + // Negative test to check if push_array_to_array fails if two many commitments are merged together + DummyComposer composer = DummyComposer("should_fail_if_aggregating_too_many_commitments"); + + NT::fr const& amount = 5; + NT::fr const& asset_id = 1; + NT::fr const& memo = 999; + + PrivateKernelInputsInner private_inputs = + do_private_call_get_kernel_inputs_inner(false, deposit, { amount, asset_id, memo }); + + // 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) { + full_new_commitments[i] = i + 1; + } + private_inputs.previous_kernel.public_inputs.end.new_commitments = full_new_commitments; + auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); + + ASSERT_TRUE(composer.failed()); + ASSERT_EQ(composer.failure_msgs, CircuitErrorCode::ARRAY_OVERFLOW); +} + } // namespace aztec3::circuits::kernel::private_kernel diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp index cd07c5cf248e..d03e3d1243f5 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/.test.cpp @@ -1122,22 +1122,4 @@ TEST(public_kernel_tests, previous_public_kernel_fails_if_incorrect_storage_cont CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); } -// TODO: make a -ve test where this fails -TEST(public_kernel_tests, public_kernel_failure_if_too_many_commitments_are_pushed) -{ - DummyComposer dummyComposer = DummyComposer( - "public_kernel_tests__previous_public_kernel_fails_if_incorrect_storage_contract_on_delegate_call"); - PublicKernelInputs inputs = get_kernel_inputs_with_previous_kernel(false); - - // the function call has the contract address and storage contract address equal and so it should fail for a - // delegate call - inputs.public_call.call_stack_item.public_inputs.call_context.is_delegate_call = true; - - auto public_inputs = native_public_kernel_circuit_public_previous_kernel(dummyComposer, inputs); - ASSERT_TRUE(dummyComposer.failed()); - ASSERT_EQ(dummyComposer.get_first_failure().code, - CircuitErrorCode::PUBLIC_KERNEL__CALL_CONTEXT_INVALID_STORAGE_ADDRESS_FOR_DELEGATE_CALL); -} - - } // namespace aztec3::circuits::kernel::public_kernel \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/utils/array.hpp b/circuits/cpp/src/aztec3/utils/array.hpp index ee5025fb90e3..ed086132992e 100644 --- a/circuits/cpp/src/aztec3/utils/array.hpp +++ b/circuits/cpp/src/aztec3/utils/array.hpp @@ -150,16 +150,15 @@ void push_array_to_array(Composer& composer, std::array const& source size_t const source_size = static_cast(uint256_t(array_length(source))); size_t const target_size = static_cast(uint256_t(array_length(target))); - // TODO(SEAN): Are these asserts making it into the wasm builds composer.do_assert(source_size <= size_2 - target_size, "push_array_to_array cannot overflow the target", CircuitErrorCode::ARRAY_OVERFLOW); // Ensure that there are no non-zero values in the `target` array after the first zero-valued index - // TODO: FILL THIS IN INCLUDING ERROR TYPE for (size_t i = target_size; i < size_2; i++) { - composer.do_assert( - is_empty(target[i]), "TODO: FILL THIS IN INCLUDING ERROR TYPE", CircuitErrorCode::ARRAY_OVERFLOW); + composer.do_assert(is_empty(target[i]), + "push_array_to_array inserting new array into a non empty space", + CircuitErrorCode::ARRAY_OVERFLOW); } // Copy the non-zero elements of the `source` array to the `target` array at the first zero-valued index auto zero_index = target_size; From 67beb4954de51b0fe1d2891444b2c7f2247f0c45 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:53:01 +0000 Subject: [PATCH 3/7] fix: update ts tests --- .../aztec3/circuits/kernel/private/.test.cpp | 2 +- .../src/kernel/public_kernel.test.ts | 18 +++++++- .../src/structs/kernel/index.test.ts | 4 +- .../circuits.js/src/tests/factories.ts | 45 ++++++++++--------- yarn-project/circuits.js/src/utils/jsUtils.ts | 11 +++++ 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp index f4c5d2e2d38e..cd48fee3e875 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/private/.test.cpp @@ -707,7 +707,7 @@ TEST(private_kernel_tests, private_kernel_should_fail_if_aggregating_too_many_co auto const& public_inputs = native_private_kernel_circuit_inner(composer, private_inputs); ASSERT_TRUE(composer.failed()); - ASSERT_EQ(composer.failure_msgs, CircuitErrorCode::ARRAY_OVERFLOW); + ASSERT_EQ(composer.get_first_failure().code, CircuitErrorCode::ARRAY_OVERFLOW); } } // namespace aztec3::circuits::kernel::private_kernel 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 16ae91252dc2..f0794027ffbb 100644 --- a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts +++ b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts @@ -1,5 +1,5 @@ -import { simulatePublicKernelCircuit, simulatePublicKernelCircuitNoPreviousKernel } from '../index.js'; -import { makePublicKernelInputsNoKernelInput, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; +import { CircuitError, KERNEL_PUBLIC_DATA_READS_LENGTH, makeTuple, simulatePublicKernelCircuit, simulatePublicKernelCircuitNoPreviousKernel } from '../index.js'; +import { makePublicDataRead, makePublicKernelInputsNoKernelInput, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; describe('kernel/public_kernel', () => { it('simulates public kernel circuit with previous public kernel', async function () { @@ -24,4 +24,18 @@ describe('kernel/public_kernel', () => { const result = await simulatePublicKernelCircuitNoPreviousKernel(input); expect(result).toBeDefined(); }); + + it("simulating public kernel circuit fails when aggregating proofs will overflow", async function () { + const input = await makePublicKernelInputsWithEmptyOutput(); + // Fix validity + input.publicCall.callStackItem.functionData.isConstructor = false; + input.publicCall.callStackItem.functionData.isPrivate = false; + input.previousKernel.publicInputs.isPrivate = false; + + // Cause array overflow + const fullStateReadsObject = makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, 0x01); + input.previousKernel.publicInputs.end.publicDataReads = fullStateReadsObject; + + await expect(simulatePublicKernelCircuit(input)).rejects.toThrow(new CircuitError(7009, "array_push cannot push to a full array")); + }) }); diff --git a/yarn-project/circuits.js/src/structs/kernel/index.test.ts b/yarn-project/circuits.js/src/structs/kernel/index.test.ts index ec27d316c3ad..4fb1576db3dd 100644 --- a/yarn-project/circuits.js/src/structs/kernel/index.test.ts +++ b/yarn-project/circuits.js/src/structs/kernel/index.test.ts @@ -45,9 +45,9 @@ describe('structs/kernel', () => { 'abis__test_roundtrip_serialize_signed_tx_request', ); }); - it(`serializes and prints CombinedAccumulatedData`, async () => { + it(`serializes and prints CombinedAccumulatedData`, async (seed = 1) => { await expectSerializeToMatchSnapshot( - makeAccumulatedData().toBuffer(), + makeAccumulatedData(seed, true).toBuffer(), 'abis__test_roundtrip_serialize_combined_accumulated_data', ); }); diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 473cf29d727d..25aae93fe925 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -84,6 +84,7 @@ import { NULLIFIER_TREE_HEIGHT, PRIVATE_DATA_TREE_HEIGHT, makeTuple, + makeHalfFullTuple, } from '../index.js'; /** @@ -192,18 +193,20 @@ export function makeContractStorageRead(seed = 1): ContractStorageRead { * @param seed - The seed to use for generating the accumulated data. * @returns An empty accumulated data. */ -export function makeEmptyAccumulatedData(seed = 1): CombinedAccumulatedData { +export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumulatedData { + const tupleGenerator = full ? makeTuple : makeHalfFullTuple; + return new CombinedAccumulatedData( makeAggregationObject(seed), - makeTuple(KERNEL_NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), - makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), - makeTuple(KERNEL_PRIVATE_CALL_STACK_LENGTH, Fr.zero), // private call stack must be empty - makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), - makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), - makeTuple(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0x600), - makeTuple(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), - makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0x800), - makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, makeEmptyPublicDataRead, seed + 0x900), + tupleGenerator(NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), + tupleGenerator(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), + tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), + tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0x600), + tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), + tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0x800), + tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeEmptyPublicDataRead, seed + 0x900), ); } @@ -212,18 +215,20 @@ export function makeEmptyAccumulatedData(seed = 1): CombinedAccumulatedData { * @param seed - The seed to use for generating the accumulated data. * @returns An accumulated data. */ -export function makeAccumulatedData(seed = 1): CombinedAccumulatedData { +export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulatedData { + const tupleGenerator = full ? makeTuple : makeHalfFullTuple; + return new CombinedAccumulatedData( makeAggregationObject(seed), - makeTuple(KERNEL_NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), - makeTuple(KERNEL_NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), - makeTuple(KERNEL_PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x300), - makeTuple(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), - makeTuple(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), - makeTuple(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0x600), - makeTuple(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), - makeTuple(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0x800), - makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, seed + 0x900), + tupleGenerator(NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), + tupleGenerator(NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), + tupleGenerator(KERNEL_PRIVATE_CALL_STACK_LENGTH, fr, seed + 0x300), + tupleGenerator(KERNEL_PUBLIC_CALL_STACK_LENGTH, fr, seed + 0x400), + tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), + tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0x600), + tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), + tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0x800), + tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, seed + 0x900), ); } diff --git a/yarn-project/circuits.js/src/utils/jsUtils.ts b/yarn-project/circuits.js/src/utils/jsUtils.ts index ea463929c4c9..06ff335854d9 100644 --- a/yarn-project/circuits.js/src/utils/jsUtils.ts +++ b/yarn-project/circuits.js/src/utils/jsUtils.ts @@ -26,6 +26,17 @@ export function makeTuple(length: N, fn: (i: number) => T, return Array.from({ length }, (v: any, i: number) => fn(i + offset)) as Tuple; } +/** + * Create an array over an integer range, filled with a function 'fn'. However, the latter half of the array are set to zeros. + * see `makeTuple` above. + * @param n - The number of integers. + * @param fn - The generator function. + * @returns The array of numbers. + */ +export function makeHalfFullTuple(length: N, fn: (i: number) => T, offset = 0) { + return Array.from({ length }, (v: any, i: number) => (i < length / 2) ? fn(i + offset) : fn(0)) as Tuple; +} + /** * Assert a member of an object is a certain length. * @param obj - An object. From 8c597f74a3db8f48df9041e78fc69c5753d71644 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 6 Jun 2023 17:54:34 +0000 Subject: [PATCH 4/7] fix: snapshot --- yarn-project/circuits.js/src/tests/factories.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 25aae93fe925..7c82789a62ce 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -323,7 +323,7 @@ export function makeEmptyKernelPublicInputs(seed = 1): KernelCircuitPublicInputs * @returns Kernel circuit public inputs. */ export function makeKernelPublicInputs(seed = 1): KernelCircuitPublicInputs { - return new KernelCircuitPublicInputs(makeAccumulatedData(seed), makeConstantData(seed + 0x100), true); + return new KernelCircuitPublicInputs(makeAccumulatedData(seed, true), makeConstantData(seed + 0x100), true); } /** From 5364b22efb7519f886eb2a16b2f6d8f64392c2ed Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Tue, 6 Jun 2023 18:19:49 +0000 Subject: [PATCH 5/7] fix: we appease the linter fix: linting --- .../src/kernel/public_kernel.test.ts | 24 ++++++++++++++----- .../circuits.js/src/tests/factories.ts | 12 +++++----- yarn-project/circuits.js/src/utils/jsUtils.ts | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) 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 f0794027ffbb..5ab11a909e09 100644 --- a/yarn-project/circuits.js/src/kernel/public_kernel.test.ts +++ b/yarn-project/circuits.js/src/kernel/public_kernel.test.ts @@ -1,5 +1,15 @@ -import { CircuitError, KERNEL_PUBLIC_DATA_READS_LENGTH, makeTuple, simulatePublicKernelCircuit, simulatePublicKernelCircuitNoPreviousKernel } from '../index.js'; -import { makePublicDataRead, makePublicKernelInputsNoKernelInput, makePublicKernelInputsWithEmptyOutput } from '../tests/factories.js'; +import { + CircuitError, + KERNEL_PUBLIC_DATA_READS_LENGTH, + makeTuple, + simulatePublicKernelCircuit, + simulatePublicKernelCircuitNoPreviousKernel, +} from '../index.js'; +import { + makePublicDataRead, + makePublicKernelInputsNoKernelInput, + makePublicKernelInputsWithEmptyOutput, +} from '../tests/factories.js'; describe('kernel/public_kernel', () => { it('simulates public kernel circuit with previous public kernel', async function () { @@ -25,17 +35,19 @@ describe('kernel/public_kernel', () => { expect(result).toBeDefined(); }); - it("simulating public kernel circuit fails when aggregating proofs will overflow", async function () { + it('simulating public kernel circuit fails when aggregating proofs will overflow', async function () { const input = await makePublicKernelInputsWithEmptyOutput(); // Fix validity input.publicCall.callStackItem.functionData.isConstructor = false; input.publicCall.callStackItem.functionData.isPrivate = false; input.previousKernel.publicInputs.isPrivate = false; - // Cause array overflow + // Cause array overflow const fullStateReadsObject = makeTuple(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, 0x01); input.previousKernel.publicInputs.end.publicDataReads = fullStateReadsObject; - await expect(simulatePublicKernelCircuit(input)).rejects.toThrow(new CircuitError(7009, "array_push cannot push to a full array")); - }) + await expect(simulatePublicKernelCircuit(input)).rejects.toThrow( + new CircuitError(7009, 'array_push cannot push to a full array'), + ); + }); }); diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 7c82789a62ce..bddf4e9de8f1 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -198,11 +198,11 @@ export function makeEmptyAccumulatedData(seed = 1, full = false): CombinedAccumu return new CombinedAccumulatedData( makeAggregationObject(seed), - tupleGenerator(NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), - tupleGenerator(NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), + tupleGenerator(KERNEL_NEW_COMMITMENTS_LENGTH, 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), - tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), + tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0x600), tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0x800), @@ -220,11 +220,11 @@ export function makeAccumulatedData(seed = 1, full = false): CombinedAccumulated return new CombinedAccumulatedData( makeAggregationObject(seed), - tupleGenerator(NEW_COMMITMENTS_LENGTH, fr, seed + 0x100), - tupleGenerator(NEW_NULLIFIERS_LENGTH, fr, seed + 0x200), + tupleGenerator(KERNEL_NEW_COMMITMENTS_LENGTH, 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), - tupleGenerator(NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), + tupleGenerator(KERNEL_NEW_L2_TO_L1_MSGS_LENGTH, fr, seed + 0x500), tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, makeNewContractData, seed + 0x600), tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0x800), diff --git a/yarn-project/circuits.js/src/utils/jsUtils.ts b/yarn-project/circuits.js/src/utils/jsUtils.ts index 06ff335854d9..916b2269a4fb 100644 --- a/yarn-project/circuits.js/src/utils/jsUtils.ts +++ b/yarn-project/circuits.js/src/utils/jsUtils.ts @@ -34,7 +34,7 @@ export function makeTuple(length: N, fn: (i: number) => T, * @returns The array of numbers. */ export function makeHalfFullTuple(length: N, fn: (i: number) => T, offset = 0) { - return Array.from({ length }, (v: any, i: number) => (i < length / 2) ? fn(i + offset) : fn(0)) as Tuple; + return Array.from({ length }, (v: any, i: number) => (i < length / 2 ? fn(i + offset) : fn(0))) as Tuple; } /** From 5c1606ce0b5b9fa5532ac9b0ae45480f932dee7e Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 7 Jun 2023 10:36:26 +0000 Subject: [PATCH 6/7] cleanup --- circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp | 1 - circuits/cpp/src/aztec3/utils/array.hpp | 1 - 2 files changed, 2 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp index 59d740f5cc57..b0aea4605d53 100644 --- a/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp +++ b/circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp @@ -9,7 +9,6 @@ #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp" #include "aztec3/circuits/abis/public_kernel/public_kernel_inputs_no_previous_kernel.hpp" #include "aztec3/circuits/hash.hpp" -#include "aztec3/constants.hpp" #include "aztec3/utils/array.hpp" #include "aztec3/utils/dummy_composer.hpp" diff --git a/circuits/cpp/src/aztec3/utils/array.hpp b/circuits/cpp/src/aztec3/utils/array.hpp index ed086132992e..92b2eb0725c1 100644 --- a/circuits/cpp/src/aztec3/utils/array.hpp +++ b/circuits/cpp/src/aztec3/utils/array.hpp @@ -113,7 +113,6 @@ void array_push(Composer& composer, std::array& arr, T const& value) return; } } - // TODO(sean): update error types composer.do_assert(false, "array_push cannot push to a full array", CircuitErrorCode::ARRAY_OVERFLOW); }; From 4ed27be305b022b62e6fc03b248880e89ccd8ecd Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Wed, 7 Jun 2023 10:47:45 +0000 Subject: [PATCH 7/7] fix: update merge snapshots --- .../kernel/__snapshots__/index.test.ts.snap | 200 +++++++++--------- .../__snapshots__/base_rollup.test.ts.snap | 80 +++---- .../circuits.js/src/tests/factories.ts | 16 +- 3 files changed, 148 insertions(+), 148 deletions(-) diff --git a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap index 3b2270874365..afa5aca6b957 100644 --- a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap @@ -87,28 +87,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xc01 +old_value: 0xc02 +new_value: 0xc03 + leaf_index: 0xc02 +old_value: 0xc03 +new_value: 0xc04 + leaf_index: 0xc03 +old_value: 0xc04 +new_value: 0xc05 + leaf_index: 0xc04 +old_value: 0xc05 +new_value: 0xc06 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xd01 +value: 0xd02 + leaf_index: 0xd02 +value: 0xd03 + leaf_index: 0xd03 +value: 0xd04 + leaf_index: 0xd04 +value: 0xd05 ] " `; @@ -228,28 +228,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xc01 +old_value: 0xc02 +new_value: 0xc03 + leaf_index: 0xc02 +old_value: 0xc03 +new_value: 0xc04 + leaf_index: 0xc03 +old_value: 0xc04 +new_value: 0xc05 + leaf_index: 0xc04 +old_value: 0xc05 +new_value: 0xc06 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xd01 +value: 0xd02 + leaf_index: 0xd02 +value: 0xd03 + leaf_index: 0xd03 +value: 0xd04 + leaf_index: 0xd04 +value: 0xd05 ] constants: @@ -602,28 +602,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xc01 +old_value: 0xc02 +new_value: 0xc03 + leaf_index: 0xc02 +old_value: 0xc03 +new_value: 0xc04 + leaf_index: 0xc03 +old_value: 0xc04 +new_value: 0xc05 + leaf_index: 0xc04 +old_value: 0xc05 +new_value: 0xc06 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xd01 +value: 0xd02 + leaf_index: 0xd02 +value: 0xd03 + leaf_index: 0xd03 +value: 0xd04 + leaf_index: 0xd04 +value: 0xd05 ] constants: @@ -949,28 +949,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xc01 +old_value: 0xc02 +new_value: 0xc03 + leaf_index: 0xc02 +old_value: 0xc03 +new_value: 0xc04 + leaf_index: 0xc03 +old_value: 0xc04 +new_value: 0xc05 + leaf_index: 0xc04 +old_value: 0xc05 +new_value: 0xc06 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xd01 +value: 0xd02 + leaf_index: 0xd02 +value: 0xd03 + leaf_index: 0xd03 +value: 0xd04 + leaf_index: 0xd04 +value: 0xd05 ] constants: @@ -1084,28 +1084,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xc01 +old_value: 0xc02 +new_value: 0xc03 + leaf_index: 0xc02 +old_value: 0xc03 +new_value: 0xc04 + leaf_index: 0xc03 +old_value: 0xc04 +new_value: 0xc05 + leaf_index: 0xc04 +old_value: 0xc05 +new_value: 0xc06 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xd01 +value: 0xd02 + leaf_index: 0xd02 +value: 0xd03 + leaf_index: 0xd03 +value: 0xd04 + leaf_index: 0xd04 +value: 0xd05 ] constants: diff --git a/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap b/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap index 2fa9c8939f24..28a8c8d6bfd0 100644 --- a/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/rollup/__snapshots__/base_rollup.test.ts.snap @@ -89,28 +89,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xd00 +old_value: 0xd01 +new_value: 0xd02 + leaf_index: 0xd01 +old_value: 0xd02 +new_value: 0xd03 + leaf_index: 0xd02 +old_value: 0xd03 +new_value: 0xd04 + leaf_index: 0xd03 +old_value: 0xd04 +new_value: 0xd05 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xe00 +value: 0xe01 + leaf_index: 0xe01 +value: 0xe02 + leaf_index: 0xe02 +value: 0xe03 + leaf_index: 0xe03 +value: 0xe04 ] constants: @@ -233,28 +233,28 @@ called_from_l1: 1 called_from_public_l2: 0 ] public_data_update_requests: -[ leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 - leaf_index: 0x0 -old_value: 0x0 -new_value: 0x0 +[ leaf_index: 0xe00 +old_value: 0xe01 +new_value: 0xe02 + leaf_index: 0xe01 +old_value: 0xe02 +new_value: 0xe03 + leaf_index: 0xe02 +old_value: 0xe03 +new_value: 0xe04 + leaf_index: 0xe03 +old_value: 0xe04 +new_value: 0xe05 ] public_data_reads: -[ leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 - leaf_index: 0x0 -value: 0x0 +[ leaf_index: 0xf00 +value: 0xf01 + leaf_index: 0xf01 +value: 0xf02 + leaf_index: 0xf02 +value: 0xf03 + leaf_index: 0xf03 +value: 0xf04 ] constants: diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 6afd835f3b5a..e54e9144a43c 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -206,10 +206,10 @@ 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 + 0x600), - tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), - tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makeEmptyPublicDataUpdateRequest, seed + 0x800), - tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makeEmptyPublicDataRead, seed + 0x900), + tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, 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), ); } @@ -232,10 +232,10 @@ 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 + 0x600), - tupleGenerator(KERNEL_OPTIONALLY_REVEALED_DATA_LENGTH, makeOptionallyRevealedData, seed + 0x700), - tupleGenerator(KERNEL_PUBLIC_DATA_UPDATE_REQUESTS_LENGTH, makePublicDataUpdateRequest, seed + 0x800), - tupleGenerator(KERNEL_PUBLIC_DATA_READS_LENGTH, makePublicDataRead, seed + 0x900), + tupleGenerator(KERNEL_NEW_CONTRACTS_LENGTH, 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), ); }