diff --git a/barretenberg/cpp/pil/avm/avm_kernel.pil b/barretenberg/cpp/pil/avm/avm_kernel.pil index 2339ff5715e..d5b5ef256e5 100644 --- a/barretenberg/cpp/pil/avm/avm_kernel.pil +++ b/barretenberg/cpp/pil/avm/avm_kernel.pil @@ -3,8 +3,72 @@ include "constants.pil"; namespace avm_kernel(256); pol public kernel_inputs; - pol commit kernel_sel; + + pol public kernel_value_out; + pol public kernel_side_effect_out; + pol public kernel_metadata_out; + + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6463): just use one col for both of these + pol commit kernel_in_offset; + pol commit kernel_out_offset; // Note: in the future, with some codegen adjustments, this column will not be needed // as we can just add every entry in the public kernel_inputs to the lookup table pol commit q_public_input_kernel_add_to_table; + pol commit q_public_input_kernel_out_add_to_table; + + // Kernel Outputs + // + // The current implementation of kernel outputs is described within https://hackmd.io/zP1oMXF6Rf-L-ZZLXWmfHg + + // Global side effect counter; incremented after each side effect is produced. + pol commit side_effect_counter; + + // FIXED INDEXES + pol START_NOTE_HASH_EXISTS_WRITE_OFFSET = 0; + pol START_EMIT_NOTE_HASH_WRITE_OFFSET = 4; + pol START_NULLIFIER_EXISTS_OFFSET = 8; + pol START_EMIT_NULLIFIER_WRITE_OFFSET = 12; + pol START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = 16; + pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 20; + pol START_EMIT_L2_TO_l1_MSG = 24; + + pol START_SLOAD_WRITE_OFFSET = 28; + pol START_SSTORE_WRITE_OFFSET = 32; + + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6465): Must constrain write_offset counters to be less than side effect MAX + // Current write offsets for each opcode + pol commit note_hash_exist_write_offset; + pol commit emit_note_hash_write_offset; + pol commit nullifier_exists_write_offset; + pol commit emit_nullifier_write_offset; + pol commit l1_to_l2_msg_exists_write_offset; + pol commit emit_unencrypted_log_write_offset; + pol commit emit_l2_to_l1_msg_write_offset; + + pol commit sload_write_offset; + pol commit sstore_write_offset; + + pol NOT_LAST = (1 - avm_main.last); + + // Constraints to increase the offsets when the opcodes are found + #[NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK] + NOT_LAST * (note_hash_exist_write_offset' - (note_hash_exist_write_offset + avm_main.sel_op_note_hash_exists)) = 0; + #[EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK] + NOT_LAST * (emit_note_hash_write_offset' - (emit_note_hash_write_offset + avm_main.sel_op_emit_note_hash)) = 0; + #[NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK] + NOT_LAST * (nullifier_exists_write_offset' - (nullifier_exists_write_offset + avm_main.sel_op_nullifier_exists)) = 0; + #[EMIT_NULLIFIER_INC_CONSISTENCY_CHECK] + NOT_LAST * (emit_nullifier_write_offset' - (emit_nullifier_write_offset + avm_main.sel_op_emit_nullifier)) = 0; + #[L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK] + NOT_LAST * (l1_to_l2_msg_exists_write_offset' - (l1_to_l2_msg_exists_write_offset + avm_main.sel_op_l1_to_l2_msg_exists)) = 0; + #[EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK] + NOT_LAST * (emit_unencrypted_log_write_offset' - (emit_unencrypted_log_write_offset + avm_main.sel_op_emit_unencrypted_log)) = 0; + #[EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK] + NOT_LAST * (emit_l2_to_l1_msg_write_offset' - (emit_l2_to_l1_msg_write_offset + avm_main.sel_op_emit_l2_to_l1_msg)) = 0; + + + #[SLOAD_INC_CONSISTENCY_CHECK] + NOT_LAST * (sload_write_offset' - (sload_write_offset + avm_main.sel_op_sload)) = 0; + #[SSTORE_INC_CONSISTENCY_CHECK] + NOT_LAST * (sstore_write_offset' - (sstore_write_offset + avm_main.sel_op_sstore)) = 0; diff --git a/barretenberg/cpp/pil/avm/avm_main.pil b/barretenberg/cpp/pil/avm/avm_main.pil index c26cd614cd1..9c7261d0c79 100644 --- a/barretenberg/cpp/pil/avm/avm_main.pil +++ b/barretenberg/cpp/pil/avm/avm_main.pil @@ -7,6 +7,12 @@ include "avm_kernel.pil"; include "gadgets/avm_conversion.pil"; namespace avm_main(256); + //===== CONSTANT POLYNOMIALS ================================================== + pol constant clk(i) { i }; + pol constant first = [1] + [0]*; // Used mostly to toggle off the first row consisting + // only in first element of shifted polynomials. + + //===== KERNEL INPUTS ========================================================= // Kernel lookup selector opcodes pol commit q_kernel_lookup; @@ -27,14 +33,23 @@ namespace avm_main(256); pol commit sel_op_coinbase; pol commit sel_op_timestamp; + //===== KERNEL OUTPUTS ======================================================== + pol commit q_kernel_output_lookup; + + pol commit sel_op_note_hash_exists; + pol commit sel_op_emit_note_hash; + pol commit sel_op_nullifier_exists; + pol commit sel_op_emit_nullifier; + pol commit sel_op_l1_to_l2_msg_exists; + pol commit sel_op_emit_unencrypted_log; + pol commit sel_op_emit_l2_to_l1_msg; + + pol commit sel_op_sload; + pol commit sel_op_sstore; + //===== Gadget Selectors ====================================================== pol commit sel_op_radix_le; - //===== CONSTANT POLYNOMIALS ================================================== - pol constant clk(i) { i }; - pol constant first = [1] + [0]*; // Used mostly to toggle off the first row consisting - // only in first element of shifted polynomials. - //===== Fix Range Checks Selectors============================================= // We re-use the clk column for the lookup values of 8-bit resp. 16-bit range check. pol commit sel_rng_8; // Boolean selector for the 8-bit range check lookup @@ -177,6 +192,17 @@ namespace avm_main(256); sel_op_fee_per_da_gas * (1 - sel_op_fee_per_da_gas) = 0; sel_op_transaction_fee * (1 - sel_op_transaction_fee) = 0; + sel_op_note_hash_exists * (1 - sel_op_note_hash_exists) = 0; + sel_op_emit_note_hash * (1 - sel_op_emit_note_hash) = 0; + sel_op_nullifier_exists * (1 - sel_op_nullifier_exists) = 0; + sel_op_emit_nullifier * (1 - sel_op_emit_nullifier) = 0; + sel_op_l1_to_l2_msg_exists * (1 - sel_op_l1_to_l2_msg_exists) = 0; + sel_op_emit_unencrypted_log * (1 - sel_op_emit_unencrypted_log) = 0; + sel_op_emit_l2_to_l1_msg * (1 - sel_op_emit_l2_to_l1_msg) = 0; + + sel_op_sload * (1 - sel_op_sload) = 0; + sel_op_sstore * (1 - sel_op_sstore) = 0; + sel_op_radix_le * (1 - sel_op_radix_le) = 0; sel_op_add * (1 - sel_op_add) = 0; @@ -281,13 +307,20 @@ namespace avm_main(256); // Drawback is the need to paralllelize the latter. //===== KERNEL LOOKUPS ======================================================= - pol KERNEL_SELECTORS = ( - sel_op_sender + sel_op_address + sel_op_portal + sel_op_chain_id + sel_op_version + sel_op_block_number + - sel_op_coinbase + sel_op_timestamp + sel_op_fee_per_l2_gas + sel_op_fee_per_da_gas + sel_op_transaction_fee + pol KERNEL_INPUT_SELECTORS = ( + sel_op_sender + sel_op_address + sel_op_portal + sel_op_chain_id + sel_op_version + sel_op_block_number + sel_op_coinbase + + sel_op_timestamp + sel_op_fee_per_l2_gas + sel_op_fee_per_da_gas + sel_op_transaction_fee ); - // Ensure that only one kernel lookup is active when the kernel_sel is active - #[KERNEL_ACTIVE_CHECK] - KERNEL_SELECTORS * (1 - q_kernel_lookup) = 0; + // Ensure that only one kernel lookup is active when the kernel_in_offset is active + #[KERNEL_INPUT_ACTIVE_CHECK] + KERNEL_INPUT_SELECTORS * (1 - q_kernel_lookup) = 0; + + pol KERNEL_OUTPUT_SELECTORS = ( + sel_op_note_hash_exists + sel_op_emit_note_hash + sel_op_nullifier_exists + sel_op_emit_nullifier + sel_op_l1_to_l2_msg_exists + + sel_op_emit_unencrypted_log + sel_op_emit_l2_to_l1_msg + sel_op_sload + sel_op_sstore + ); + #[KERNEL_OUTPUT_ACTIVE_CHECK] + KERNEL_OUTPUT_SELECTORS * (1 - q_kernel_output_lookup) = 0; //===== CONTROL FLOW ======================================================= //===== JUMP =============================================================== @@ -324,7 +357,7 @@ namespace avm_main(256); //===== CONTROL_FLOW_CONSISTENCY ============================================ pol INTERNAL_CALL_STACK_SELECTORS = (first + sel_internal_call + sel_internal_return + sel_halt); pol OPCODE_SELECTORS = (sel_op_add + sel_op_sub + sel_op_div + sel_op_fdiv + sel_op_mul + sel_op_not - + sel_op_eq + sel_op_and + sel_op_or + sel_op_xor + sel_op_cast + KERNEL_SELECTORS); + + sel_op_eq + sel_op_and + sel_op_or + sel_op_xor + sel_op_cast + KERNEL_INPUT_SELECTORS + KERNEL_OUTPUT_SELECTORS); // Program counter must increment if not jumping or returning #[PC_INCREMENT] @@ -394,47 +427,93 @@ namespace avm_main(256); // The general pattern for environment lookups is as follows: // Each kernel opcode related to some fixed positions in the `public kernel_inputs` polynomial // We can lookup into a fixed index of this polynomial by including constraints that force the value - // of kernel_sel to the value relevant to the given opcode that is active + // of kernel_in_offset to the value relevant to the given opcode that is active // CALL CONTEXT #[SENDER_KERNEL] - sel_op_sender * (avm_kernel.kernel_sel - constants.SENDER_SELECTOR) = 0; + sel_op_sender * (avm_kernel.kernel_in_offset - constants.SENDER_SELECTOR) = 0; #[ADDRESS_KERNEL] - sel_op_address * (avm_kernel.kernel_sel - constants.ADDRESS_SELECTOR) = 0; + sel_op_address * (avm_kernel.kernel_in_offset - constants.ADDRESS_SELECTOR) = 0; #[PORTAL_KERNEL] - sel_op_portal * (avm_kernel.kernel_sel - constants.PORTAL_SELECTOR) = 0; + sel_op_portal * (avm_kernel.kernel_in_offset - constants.PORTAL_SELECTOR) = 0; // FEES #[FEE_DA_GAS_KERNEL] - sel_op_fee_per_da_gas * (avm_kernel.kernel_sel - constants.FEE_PER_DA_GAS_SELECTOR) = 0; + sel_op_fee_per_da_gas * (avm_kernel.kernel_in_offset - constants.FEE_PER_DA_GAS_SELECTOR) = 0; #[FEE_L2_GAS_KERNEL] - sel_op_fee_per_l2_gas * (avm_kernel.kernel_sel - constants.FEE_PER_L2_GAS_SELECTOR) = 0; + sel_op_fee_per_l2_gas * (avm_kernel.kernel_in_offset - constants.FEE_PER_L2_GAS_SELECTOR) = 0; #[FEE_TRANSACTION_FEE_KERNEL] - sel_op_transaction_fee * (avm_kernel.kernel_sel - constants.TRANSACTION_FEE_SELECTOR) = 0; + sel_op_transaction_fee * (avm_kernel.kernel_in_offset - constants.TRANSACTION_FEE_SELECTOR) = 0; // GLOBALS #[CHAIN_ID_KERNEL] - sel_op_chain_id * (avm_kernel.kernel_sel - constants.CHAIN_ID_SELECTOR) = 0; + sel_op_chain_id * (avm_kernel.kernel_in_offset - constants.CHAIN_ID_SELECTOR) = 0; #[VERSION_KERNEL] - sel_op_version * (avm_kernel.kernel_sel - constants.VERSION_SELECTOR) = 0; + sel_op_version * (avm_kernel.kernel_in_offset - constants.VERSION_SELECTOR) = 0; #[BLOCK_NUMBER_KERNEL] - sel_op_block_number * (avm_kernel.kernel_sel - constants.BLOCK_NUMBER_SELECTOR) = 0; + sel_op_block_number * (avm_kernel.kernel_in_offset - constants.BLOCK_NUMBER_SELECTOR) = 0; #[COINBASE_KERNEL] - sel_op_coinbase * (avm_kernel.kernel_sel - constants.COINBASE_SELECTOR) = 0; + sel_op_coinbase * (avm_kernel.kernel_in_offset - constants.COINBASE_SELECTOR) = 0; #[TIMESTAMP_KERNEL] - sel_op_timestamp * (avm_kernel.kernel_sel - constants.TIMESTAMP_SELECTOR) = 0; + sel_op_timestamp * (avm_kernel.kernel_in_offset - constants.TIMESTAMP_SELECTOR) = 0; + + // OUTPUTS LOOKUPS + // Constrain the value of kernel_out_offset to be the correct offset for the operation being performed + #[NOTE_HASH_KERNEL_OUTPUT] + sel_op_note_hash_exists * (avm_kernel.kernel_out_offset - (avm_kernel.START_NOTE_HASH_EXISTS_WRITE_OFFSET + avm_kernel.note_hash_exist_write_offset)) = 0; + first * avm_kernel.note_hash_exist_write_offset = 0; + + + #[EMIT_NOTE_HASH_KERNEL_OUTPUT] + sel_op_emit_note_hash * (avm_kernel.kernel_out_offset - (avm_kernel.START_EMIT_NOTE_HASH_WRITE_OFFSET + avm_kernel.emit_note_hash_write_offset)) = 0; + first * avm_kernel.emit_note_hash_write_offset = 0; + + #[NULLIFIER_EXISTS_KERNEL_OUTPUT] + sel_op_nullifier_exists * (avm_kernel.kernel_out_offset - (avm_kernel.START_NULLIFIER_EXISTS_OFFSET + avm_kernel.nullifier_exists_write_offset)) = 0; + first * avm_kernel.nullifier_exists_write_offset = 0; + + #[EMIT_NULLIFIER_KERNEL_OUTPUT] + sel_op_emit_nullifier * (avm_kernel.kernel_out_offset - (avm_kernel.START_EMIT_NULLIFIER_WRITE_OFFSET + avm_kernel.emit_nullifier_write_offset)) = 0; + first * avm_kernel.emit_nullifier_write_offset = 0; + + #[L1_TO_L2_MSG_EXISTS_KERNEL_OUTPUT] + sel_op_l1_to_l2_msg_exists * (avm_kernel.kernel_out_offset - (avm_kernel.START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET + avm_kernel.l1_to_l2_msg_exists_write_offset)) = 0; + first * avm_kernel.l1_to_l2_msg_exists_write_offset = 0; + + #[EMIT_UNENCRYPTED_LOG_KERNEL_OUTPUT] + sel_op_emit_unencrypted_log * (avm_kernel.kernel_out_offset - (avm_kernel.START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET + avm_kernel.emit_unencrypted_log_write_offset)) = 0; + first * avm_kernel.emit_unencrypted_log_write_offset = 0; + + #[EMIT_L2_TO_L1_MSGS_KERNEL_OUTPUT] + sel_op_emit_l2_to_l1_msg * (avm_kernel.kernel_out_offset - (avm_kernel.START_EMIT_L2_TO_l1_MSG + avm_kernel.emit_l2_to_l1_msg_write_offset)) = 0; + first * avm_kernel.emit_l2_to_l1_msg_write_offset = 0; + + #[SLOAD_KERNEL_OUTPUT] + sel_op_sload * (avm_kernel.kernel_out_offset - (avm_kernel.START_SLOAD_WRITE_OFFSET + avm_kernel.sload_write_offset)) = 0; + first * avm_kernel.sload_write_offset = 0; + + #[SSTORE_KERNEL_OUTPUT] + sel_op_sstore * (avm_kernel.kernel_out_offset - (avm_kernel.START_SSTORE_WRITE_OFFSET + avm_kernel.sstore_write_offset)) = 0; + first * avm_kernel.sstore_write_offset = 0; + + // When we encounter a state writing opcode + // We increment the side effect counter by 1 + KERNEL_OUTPUT_SELECTORS * (avm_kernel.side_effect_counter' - (avm_kernel.side_effect_counter + 1)) = 0; + + #[KERNEL_OUTPUT_LOOKUP] + q_kernel_output_lookup {avm_kernel.kernel_out_offset, ia, avm_kernel.side_effect_counter, ib} in avm_kernel.q_public_input_kernel_out_add_to_table {clk, avm_kernel.kernel_value_out__is_public, avm_kernel.kernel_side_effect_out__is_public, avm_kernel.kernel_metadata_out__is_public}; #[LOOKUP_INTO_KERNEL] // TODO: FIX not having the trailing is_public breaking compilation :( - q_kernel_lookup { avm_main.ia, avm_kernel.kernel_sel } in avm_kernel.q_public_input_kernel_add_to_table { avm_kernel.kernel_inputs__is_public, clk }; + q_kernel_lookup { avm_main.ia, avm_kernel.kernel_in_offset } in avm_kernel.q_public_input_kernel_add_to_table { avm_kernel.kernel_inputs__is_public, clk }; //====== Inter-table Constraints ============================================ #[INCL_MAIN_TAG_ERR] diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp new file mode 100644 index 00000000000..01b346e7a49 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_kernel.hpp @@ -0,0 +1,181 @@ + +#pragma once +#include "../../relation_parameters.hpp" +#include "../../relation_types.hpp" +#include "./declare_views.hpp" + +namespace bb::Avm_vm { + +template struct Avm_kernelRow { + FF avm_kernel_emit_l2_to_l1_msg_write_offset{}; + FF avm_kernel_emit_l2_to_l1_msg_write_offset_shift{}; + FF avm_kernel_emit_note_hash_write_offset{}; + FF avm_kernel_emit_note_hash_write_offset_shift{}; + FF avm_kernel_emit_nullifier_write_offset{}; + FF avm_kernel_emit_nullifier_write_offset_shift{}; + FF avm_kernel_emit_unencrypted_log_write_offset{}; + FF avm_kernel_emit_unencrypted_log_write_offset_shift{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset_shift{}; + FF avm_kernel_note_hash_exist_write_offset{}; + FF avm_kernel_note_hash_exist_write_offset_shift{}; + FF avm_kernel_nullifier_exists_write_offset{}; + FF avm_kernel_nullifier_exists_write_offset_shift{}; + FF avm_kernel_sload_write_offset{}; + FF avm_kernel_sload_write_offset_shift{}; + FF avm_kernel_sstore_write_offset{}; + FF avm_kernel_sstore_write_offset_shift{}; + FF avm_main_last{}; + FF avm_main_sel_op_emit_l2_to_l1_msg{}; + FF avm_main_sel_op_emit_note_hash{}; + FF avm_main_sel_op_emit_nullifier{}; + FF avm_main_sel_op_emit_unencrypted_log{}; + FF avm_main_sel_op_l1_to_l2_msg_exists{}; + FF avm_main_sel_op_note_hash_exists{}; + FF avm_main_sel_op_nullifier_exists{}; + FF avm_main_sel_op_sload{}; + FF avm_main_sel_op_sstore{}; +}; + +inline std::string get_relation_label_avm_kernel(int index) +{ + switch (index) { + case 0: + return "NOTE_HASH_EXISTS_INC_CONSISTENCY_CHECK"; + + case 1: + return "EMIT_NOTE_HASH_INC_CONSISTENCY_CHECK"; + + case 2: + return "NULLIFIER_EXISTS_INC_CONSISTENCY_CHECK"; + + case 3: + return "EMIT_NULLIFIER_INC_CONSISTENCY_CHECK"; + + case 4: + return "L1_TO_L2_MSG_EXISTS_INC_CONSISTENCY_CHECK"; + + case 5: + return "EMIT_UNENCRYPTED_LOG_INC_CONSISTENCY_CHECK"; + + case 6: + return "EMIT_L2_TO_L1_MSG_INC_CONSISTENCY_CHECK"; + + case 7: + return "SLOAD_INC_CONSISTENCY_CHECK"; + + case 8: + return "SSTORE_INC_CONSISTENCY_CHECK"; + } + return std::to_string(index); +} + +template class avm_kernelImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, + }; + + template + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) + { + + // Contribution 0 + { + Avm_DECLARE_VIEWS(0); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_note_hash_exist_write_offset_shift - + (avm_kernel_note_hash_exist_write_offset + avm_main_sel_op_note_hash_exists))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + Avm_DECLARE_VIEWS(1); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_note_hash_write_offset_shift - + (avm_kernel_emit_note_hash_write_offset + avm_main_sel_op_emit_note_hash))); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + Avm_DECLARE_VIEWS(2); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_nullifier_exists_write_offset_shift - + (avm_kernel_nullifier_exists_write_offset + avm_main_sel_op_nullifier_exists))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + Avm_DECLARE_VIEWS(3); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_nullifier_write_offset_shift - + (avm_kernel_emit_nullifier_write_offset + avm_main_sel_op_emit_nullifier))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + Avm_DECLARE_VIEWS(4); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_l1_to_l2_msg_exists_write_offset_shift - + (avm_kernel_l1_to_l2_msg_exists_write_offset + avm_main_sel_op_l1_to_l2_msg_exists))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + Avm_DECLARE_VIEWS(5); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_unencrypted_log_write_offset_shift - + (avm_kernel_emit_unencrypted_log_write_offset + avm_main_sel_op_emit_unencrypted_log))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + Avm_DECLARE_VIEWS(6); + + auto tmp = ((-avm_main_last + FF(1)) * + (avm_kernel_emit_l2_to_l1_msg_write_offset_shift - + (avm_kernel_emit_l2_to_l1_msg_write_offset + avm_main_sel_op_emit_l2_to_l1_msg))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + Avm_DECLARE_VIEWS(7); + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sload_write_offset_shift - + (avm_kernel_sload_write_offset + avm_main_sel_op_sload))); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + Avm_DECLARE_VIEWS(8); + + auto tmp = ((-avm_main_last + FF(1)) * (avm_kernel_sstore_write_offset_shift - + (avm_kernel_sstore_write_offset + avm_main_sel_op_sstore))); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + } +}; + +template using avm_kernel = Relation>; + +} // namespace bb::Avm_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp index b4626609f85..e583a589873 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/avm_main.hpp @@ -7,7 +7,19 @@ namespace bb::Avm_vm { template struct Avm_mainRow { - FF avm_kernel_kernel_sel{}; + FF avm_kernel_emit_l2_to_l1_msg_write_offset{}; + FF avm_kernel_emit_note_hash_write_offset{}; + FF avm_kernel_emit_nullifier_write_offset{}; + FF avm_kernel_emit_unencrypted_log_write_offset{}; + FF avm_kernel_kernel_in_offset{}; + FF avm_kernel_kernel_out_offset{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset{}; + FF avm_kernel_note_hash_exist_write_offset{}; + FF avm_kernel_nullifier_exists_write_offset{}; + FF avm_kernel_side_effect_counter{}; + FF avm_kernel_side_effect_counter_shift{}; + FF avm_kernel_sload_write_offset{}; + FF avm_kernel_sstore_write_offset{}; FF avm_main_alu_in_tag{}; FF avm_main_alu_sel{}; FF avm_main_bin_op_id{}; @@ -36,6 +48,7 @@ template struct Avm_mainRow { FF avm_main_pc{}; FF avm_main_pc_shift{}; FF avm_main_q_kernel_lookup{}; + FF avm_main_q_kernel_output_lookup{}; FF avm_main_r_in_tag{}; FF avm_main_rwa{}; FF avm_main_rwb{}; @@ -57,20 +70,29 @@ template struct Avm_mainRow { FF avm_main_sel_op_chain_id{}; FF avm_main_sel_op_coinbase{}; FF avm_main_sel_op_div{}; + FF avm_main_sel_op_emit_l2_to_l1_msg{}; + FF avm_main_sel_op_emit_note_hash{}; + FF avm_main_sel_op_emit_nullifier{}; + FF avm_main_sel_op_emit_unencrypted_log{}; FF avm_main_sel_op_eq{}; FF avm_main_sel_op_fdiv{}; FF avm_main_sel_op_fee_per_da_gas{}; FF avm_main_sel_op_fee_per_l2_gas{}; + FF avm_main_sel_op_l1_to_l2_msg_exists{}; FF avm_main_sel_op_lt{}; FF avm_main_sel_op_lte{}; FF avm_main_sel_op_mul{}; FF avm_main_sel_op_not{}; + FF avm_main_sel_op_note_hash_exists{}; + FF avm_main_sel_op_nullifier_exists{}; FF avm_main_sel_op_or{}; FF avm_main_sel_op_portal{}; FF avm_main_sel_op_radix_le{}; FF avm_main_sel_op_sender{}; FF avm_main_sel_op_shl{}; FF avm_main_sel_op_shr{}; + FF avm_main_sel_op_sload{}; + FF avm_main_sel_op_sstore{}; FF avm_main_sel_op_sub{}; FF avm_main_sel_op_timestamp{}; FF avm_main_sel_op_transaction_fee{}; @@ -84,100 +106,130 @@ template struct Avm_mainRow { inline std::string get_relation_label_avm_main(int index) { switch (index) { - case 48: + case 57: return "OUTPUT_U8"; - case 49: + case 58: return "SUBOP_FDIV"; - case 50: + case 59: return "SUBOP_FDIV_ZERO_ERR1"; - case 51: + case 60: return "SUBOP_FDIV_ZERO_ERR2"; - case 52: + case 61: return "SUBOP_FDIV_R_IN_TAG_FF"; - case 53: + case 62: return "SUBOP_FDIV_W_IN_TAG_FF"; - case 54: + case 63: return "SUBOP_ERROR_RELEVANT_OP"; - case 55: - return "KERNEL_ACTIVE_CHECK"; + case 64: + return "KERNEL_INPUT_ACTIVE_CHECK"; - case 57: + case 65: + return "KERNEL_OUTPUT_ACTIVE_CHECK"; + + case 67: return "RETURN_POINTER_INCREMENT"; - case 63: + case 73: return "RETURN_POINTER_DECREMENT"; - case 68: + case 78: return "PC_INCREMENT"; - case 69: + case 79: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 70: + case 80: return "SPACE_ID_INTERNAL"; - case 71: + case 81: return "SPACE_ID_STANDARD_OPCODES"; - case 72: + case 82: return "CMOV_CONDITION_RES_1"; - case 73: + case 83: return "CMOV_CONDITION_RES_2"; - case 76: + case 86: return "MOV_SAME_VALUE_A"; - case 77: + case 87: return "MOV_SAME_VALUE_B"; - case 78: + case 88: return "MOV_MAIN_SAME_TAG"; - case 82: + case 92: return "SENDER_KERNEL"; - case 83: + case 93: return "ADDRESS_KERNEL"; - case 84: + case 94: return "PORTAL_KERNEL"; - case 85: + case 95: return "FEE_DA_GAS_KERNEL"; - case 86: + case 96: return "FEE_L2_GAS_KERNEL"; - case 87: + case 97: return "FEE_TRANSACTION_FEE_KERNEL"; - case 88: + case 98: return "CHAIN_ID_KERNEL"; - case 89: + case 99: return "VERSION_KERNEL"; - case 90: + case 100: return "BLOCK_NUMBER_KERNEL"; - case 91: + case 101: return "COINBASE_KERNEL"; - case 92: + case 102: return "TIMESTAMP_KERNEL"; - case 93: + case 103: + return "NOTE_HASH_KERNEL_OUTPUT"; + + case 105: + return "EMIT_NOTE_HASH_KERNEL_OUTPUT"; + + case 107: + return "NULLIFIER_EXISTS_KERNEL_OUTPUT"; + + case 109: + return "EMIT_NULLIFIER_KERNEL_OUTPUT"; + + case 111: + return "L1_TO_L2_MSG_EXISTS_KERNEL_OUTPUT"; + + case 113: + return "EMIT_UNENCRYPTED_LOG_KERNEL_OUTPUT"; + + case 115: + return "EMIT_L2_TO_L1_MSGS_KERNEL_OUTPUT"; + + case 117: + return "SLOAD_KERNEL_OUTPUT"; + + case 119: + return "SSTORE_KERNEL_OUTPUT"; + + case 122: return "BIN_SEL_1"; - case 94: + case 123: return "BIN_SEL_2"; } return std::to_string(index); @@ -187,10 +239,11 @@ template class avm_mainImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 5, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 4, 4, 3, 3, 3, 3, 3, 4, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, }; template @@ -292,7 +345,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(11); - auto tmp = (avm_main_sel_op_radix_le * (-avm_main_sel_op_radix_le + FF(1))); + auto tmp = (avm_main_sel_op_note_hash_exists * (-avm_main_sel_op_note_hash_exists + FF(1))); tmp *= scaling_factor; std::get<11>(evals) += tmp; } @@ -300,7 +353,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(12); - auto tmp = (avm_main_sel_op_add * (-avm_main_sel_op_add + FF(1))); + auto tmp = (avm_main_sel_op_emit_note_hash * (-avm_main_sel_op_emit_note_hash + FF(1))); tmp *= scaling_factor; std::get<12>(evals) += tmp; } @@ -308,7 +361,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(13); - auto tmp = (avm_main_sel_op_sub * (-avm_main_sel_op_sub + FF(1))); + auto tmp = (avm_main_sel_op_nullifier_exists * (-avm_main_sel_op_nullifier_exists + FF(1))); tmp *= scaling_factor; std::get<13>(evals) += tmp; } @@ -316,7 +369,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(14); - auto tmp = (avm_main_sel_op_mul * (-avm_main_sel_op_mul + FF(1))); + auto tmp = (avm_main_sel_op_emit_nullifier * (-avm_main_sel_op_emit_nullifier + FF(1))); tmp *= scaling_factor; std::get<14>(evals) += tmp; } @@ -324,7 +377,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(15); - auto tmp = (avm_main_sel_op_div * (-avm_main_sel_op_div + FF(1))); + auto tmp = (avm_main_sel_op_l1_to_l2_msg_exists * (-avm_main_sel_op_l1_to_l2_msg_exists + FF(1))); tmp *= scaling_factor; std::get<15>(evals) += tmp; } @@ -332,7 +385,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(16); - auto tmp = (avm_main_sel_op_fdiv * (-avm_main_sel_op_fdiv + FF(1))); + auto tmp = (avm_main_sel_op_emit_unencrypted_log * (-avm_main_sel_op_emit_unencrypted_log + FF(1))); tmp *= scaling_factor; std::get<16>(evals) += tmp; } @@ -340,7 +393,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(17); - auto tmp = (avm_main_sel_op_not * (-avm_main_sel_op_not + FF(1))); + auto tmp = (avm_main_sel_op_emit_l2_to_l1_msg * (-avm_main_sel_op_emit_l2_to_l1_msg + FF(1))); tmp *= scaling_factor; std::get<17>(evals) += tmp; } @@ -348,7 +401,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(18); - auto tmp = (avm_main_sel_op_eq * (-avm_main_sel_op_eq + FF(1))); + auto tmp = (avm_main_sel_op_sload * (-avm_main_sel_op_sload + FF(1))); tmp *= scaling_factor; std::get<18>(evals) += tmp; } @@ -356,7 +409,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(19); - auto tmp = (avm_main_sel_op_and * (-avm_main_sel_op_and + FF(1))); + auto tmp = (avm_main_sel_op_sstore * (-avm_main_sel_op_sstore + FF(1))); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -364,7 +417,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(20); - auto tmp = (avm_main_sel_op_or * (-avm_main_sel_op_or + FF(1))); + auto tmp = (avm_main_sel_op_radix_le * (-avm_main_sel_op_radix_le + FF(1))); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -372,7 +425,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(21); - auto tmp = (avm_main_sel_op_xor * (-avm_main_sel_op_xor + FF(1))); + auto tmp = (avm_main_sel_op_add * (-avm_main_sel_op_add + FF(1))); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -380,7 +433,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(22); - auto tmp = (avm_main_sel_op_cast * (-avm_main_sel_op_cast + FF(1))); + auto tmp = (avm_main_sel_op_sub * (-avm_main_sel_op_sub + FF(1))); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -388,7 +441,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(23); - auto tmp = (avm_main_sel_op_lt * (-avm_main_sel_op_lt + FF(1))); + auto tmp = (avm_main_sel_op_mul * (-avm_main_sel_op_mul + FF(1))); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -396,7 +449,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(24); - auto tmp = (avm_main_sel_op_lte * (-avm_main_sel_op_lte + FF(1))); + auto tmp = (avm_main_sel_op_div * (-avm_main_sel_op_div + FF(1))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -404,7 +457,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(25); - auto tmp = (avm_main_sel_op_shl * (-avm_main_sel_op_shl + FF(1))); + auto tmp = (avm_main_sel_op_fdiv * (-avm_main_sel_op_fdiv + FF(1))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -412,7 +465,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(26); - auto tmp = (avm_main_sel_op_shr * (-avm_main_sel_op_shr + FF(1))); + auto tmp = (avm_main_sel_op_not * (-avm_main_sel_op_not + FF(1))); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -420,7 +473,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(27); - auto tmp = (avm_main_sel_internal_call * (-avm_main_sel_internal_call + FF(1))); + auto tmp = (avm_main_sel_op_eq * (-avm_main_sel_op_eq + FF(1))); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -428,7 +481,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(28); - auto tmp = (avm_main_sel_internal_return * (-avm_main_sel_internal_return + FF(1))); + auto tmp = (avm_main_sel_op_and * (-avm_main_sel_op_and + FF(1))); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -436,7 +489,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(29); - auto tmp = (avm_main_sel_jump * (-avm_main_sel_jump + FF(1))); + auto tmp = (avm_main_sel_op_or * (-avm_main_sel_op_or + FF(1))); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -444,7 +497,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(30); - auto tmp = (avm_main_sel_halt * (-avm_main_sel_halt + FF(1))); + auto tmp = (avm_main_sel_op_xor * (-avm_main_sel_op_xor + FF(1))); tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -452,7 +505,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(31); - auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); + auto tmp = (avm_main_sel_op_cast * (-avm_main_sel_op_cast + FF(1))); tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -460,7 +513,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(32); - auto tmp = (avm_main_sel_cmov * (-avm_main_sel_cmov + FF(1))); + auto tmp = (avm_main_sel_op_lt * (-avm_main_sel_op_lt + FF(1))); tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -468,7 +521,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(33); - auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); + auto tmp = (avm_main_sel_op_lte * (-avm_main_sel_op_lte + FF(1))); tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -476,7 +529,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(34); - auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); + auto tmp = (avm_main_sel_op_shl * (-avm_main_sel_op_shl + FF(1))); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -484,7 +537,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(35); - auto tmp = (avm_main_id_zero * (-avm_main_id_zero + FF(1))); + auto tmp = (avm_main_sel_op_shr * (-avm_main_sel_op_shr + FF(1))); tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -492,7 +545,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(36); - auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); + auto tmp = (avm_main_sel_internal_call * (-avm_main_sel_internal_call + FF(1))); tmp *= scaling_factor; std::get<36>(evals) += tmp; } @@ -500,7 +553,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(37); - auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); + auto tmp = (avm_main_sel_internal_return * (-avm_main_sel_internal_return + FF(1))); tmp *= scaling_factor; std::get<37>(evals) += tmp; } @@ -508,7 +561,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(38); - auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); + auto tmp = (avm_main_sel_jump * (-avm_main_sel_jump + FF(1))); tmp *= scaling_factor; std::get<38>(evals) += tmp; } @@ -516,7 +569,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(39); - auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); + auto tmp = (avm_main_sel_halt * (-avm_main_sel_halt + FF(1))); tmp *= scaling_factor; std::get<39>(evals) += tmp; } @@ -524,7 +577,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(40); - auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); + auto tmp = (avm_main_sel_mov * (-avm_main_sel_mov + FF(1))); tmp *= scaling_factor; std::get<40>(evals) += tmp; } @@ -532,7 +585,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(41); - auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); + auto tmp = (avm_main_sel_cmov * (-avm_main_sel_cmov + FF(1))); tmp *= scaling_factor; std::get<41>(evals) += tmp; } @@ -540,7 +593,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(42); - auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); + auto tmp = (avm_main_op_err * (-avm_main_op_err + FF(1))); tmp *= scaling_factor; std::get<42>(evals) += tmp; } @@ -548,7 +601,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(43); - auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); + auto tmp = (avm_main_tag_err * (-avm_main_tag_err + FF(1))); tmp *= scaling_factor; std::get<43>(evals) += tmp; } @@ -556,7 +609,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(44); - auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); + auto tmp = (avm_main_id_zero * (-avm_main_id_zero + FF(1))); tmp *= scaling_factor; std::get<44>(evals) += tmp; } @@ -564,7 +617,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(45); - auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); + auto tmp = (avm_main_mem_op_a * (-avm_main_mem_op_a + FF(1))); tmp *= scaling_factor; std::get<45>(evals) += tmp; } @@ -572,7 +625,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(46); - auto tmp = (avm_main_ind_op_c * (-avm_main_ind_op_c + FF(1))); + auto tmp = (avm_main_mem_op_b * (-avm_main_mem_op_b + FF(1))); tmp *= scaling_factor; std::get<46>(evals) += tmp; } @@ -580,7 +633,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(47); - auto tmp = (avm_main_ind_op_d * (-avm_main_ind_op_d + FF(1))); + auto tmp = (avm_main_mem_op_c * (-avm_main_mem_op_c + FF(1))); tmp *= scaling_factor; std::get<47>(evals) += tmp; } @@ -588,8 +641,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(48); - auto tmp = - (((avm_main_sel_op_eq + avm_main_sel_op_lte) + avm_main_sel_op_lt) * (avm_main_w_in_tag - FF(1))); + auto tmp = (avm_main_mem_op_d * (-avm_main_mem_op_d + FF(1))); tmp *= scaling_factor; std::get<48>(evals) += tmp; } @@ -597,8 +649,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(49); - auto tmp = - ((avm_main_sel_op_fdiv * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); + auto tmp = (avm_main_rwa * (-avm_main_rwa + FF(1))); tmp *= scaling_factor; std::get<49>(evals) += tmp; } @@ -606,8 +657,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(50); - auto tmp = ((avm_main_sel_op_fdiv + avm_main_sel_op_div) * - (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); + auto tmp = (avm_main_rwb * (-avm_main_rwb + FF(1))); tmp *= scaling_factor; std::get<50>(evals) += tmp; } @@ -615,7 +665,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(51); - auto tmp = (((avm_main_sel_op_fdiv + avm_main_sel_op_div) * avm_main_op_err) * (-avm_main_inv + FF(1))); + auto tmp = (avm_main_rwc * (-avm_main_rwc + FF(1))); tmp *= scaling_factor; std::get<51>(evals) += tmp; } @@ -623,7 +673,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(52); - auto tmp = (avm_main_sel_op_fdiv * (avm_main_r_in_tag - FF(6))); + auto tmp = (avm_main_rwd * (-avm_main_rwd + FF(1))); tmp *= scaling_factor; std::get<52>(evals) += tmp; } @@ -631,7 +681,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(53); - auto tmp = (avm_main_sel_op_fdiv * (avm_main_w_in_tag - FF(6))); + auto tmp = (avm_main_ind_op_a * (-avm_main_ind_op_a + FF(1))); tmp *= scaling_factor; std::get<53>(evals) += tmp; } @@ -639,7 +689,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(54); - auto tmp = (avm_main_op_err * ((avm_main_sel_op_fdiv + avm_main_sel_op_div) - FF(1))); + auto tmp = (avm_main_ind_op_b * (-avm_main_ind_op_b + FF(1))); tmp *= scaling_factor; std::get<54>(evals) += tmp; } @@ -647,16 +697,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(55); - auto tmp = (((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_portal) + - avm_main_sel_op_chain_id) + - avm_main_sel_op_version) + - avm_main_sel_op_block_number) + - avm_main_sel_op_coinbase) + - avm_main_sel_op_timestamp) + - avm_main_sel_op_fee_per_l2_gas) + - avm_main_sel_op_fee_per_da_gas) + - avm_main_sel_op_transaction_fee) * - (-avm_main_q_kernel_lookup + FF(1))); + auto tmp = (avm_main_ind_op_c * (-avm_main_ind_op_c + FF(1))); tmp *= scaling_factor; std::get<55>(evals) += tmp; } @@ -664,7 +705,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(56); - auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); + auto tmp = (avm_main_ind_op_d * (-avm_main_ind_op_d + FF(1))); tmp *= scaling_factor; std::get<56>(evals) += tmp; } @@ -672,8 +713,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(57); - auto tmp = (avm_main_sel_internal_call * - (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr + FF(1)))); + auto tmp = + (((avm_main_sel_op_eq + avm_main_sel_op_lte) + avm_main_sel_op_lt) * (avm_main_w_in_tag - FF(1))); tmp *= scaling_factor; std::get<57>(evals) += tmp; } @@ -681,7 +722,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(58); - auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); + auto tmp = + ((avm_main_sel_op_fdiv * (-avm_main_op_err + FF(1))) * ((avm_main_ic * avm_main_ib) - avm_main_ia)); tmp *= scaling_factor; std::get<58>(evals) += tmp; } @@ -689,7 +731,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(59); - auto tmp = (avm_main_sel_internal_call * (avm_main_pc_shift - avm_main_ia)); + auto tmp = ((avm_main_sel_op_fdiv + avm_main_sel_op_div) * + (((avm_main_ib * avm_main_inv) - FF(1)) + avm_main_op_err)); tmp *= scaling_factor; std::get<59>(evals) += tmp; } @@ -697,7 +740,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(60); - auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); + auto tmp = (((avm_main_sel_op_fdiv + avm_main_sel_op_div) * avm_main_op_err) * (-avm_main_inv + FF(1))); tmp *= scaling_factor; std::get<60>(evals) += tmp; } @@ -705,7 +748,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(61); - auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); + auto tmp = (avm_main_sel_op_fdiv * (avm_main_r_in_tag - FF(6))); tmp *= scaling_factor; std::get<61>(evals) += tmp; } @@ -713,7 +756,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(62); - auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); + auto tmp = (avm_main_sel_op_fdiv * (avm_main_w_in_tag - FF(6))); tmp *= scaling_factor; std::get<62>(evals) += tmp; } @@ -721,8 +764,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(63); - auto tmp = (avm_main_sel_internal_return * - (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr - FF(1)))); + auto tmp = (avm_main_op_err * ((avm_main_sel_op_fdiv + avm_main_sel_op_div) - FF(1))); tmp *= scaling_factor; std::get<63>(evals) += tmp; } @@ -730,7 +772,16 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(64); - auto tmp = (avm_main_sel_internal_return * ((avm_main_internal_return_ptr - FF(1)) - avm_main_mem_idx_a)); + auto tmp = (((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_portal) + + avm_main_sel_op_chain_id) + + avm_main_sel_op_version) + + avm_main_sel_op_block_number) + + avm_main_sel_op_coinbase) + + avm_main_sel_op_timestamp) + + avm_main_sel_op_fee_per_l2_gas) + + avm_main_sel_op_fee_per_da_gas) + + avm_main_sel_op_transaction_fee) * + (-avm_main_q_kernel_lookup + FF(1))); tmp *= scaling_factor; std::get<64>(evals) += tmp; } @@ -738,7 +789,15 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(65); - auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); + auto tmp = (((((((((avm_main_sel_op_note_hash_exists + avm_main_sel_op_emit_note_hash) + + avm_main_sel_op_nullifier_exists) + + avm_main_sel_op_emit_nullifier) + + avm_main_sel_op_l1_to_l2_msg_exists) + + avm_main_sel_op_emit_unencrypted_log) + + avm_main_sel_op_emit_l2_to_l1_msg) + + avm_main_sel_op_sload) + + avm_main_sel_op_sstore) * + (-avm_main_q_kernel_output_lookup + FF(1))); tmp *= scaling_factor; std::get<65>(evals) += tmp; } @@ -746,7 +805,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(66); - auto tmp = (avm_main_sel_internal_return * avm_main_rwa); + auto tmp = (avm_main_sel_jump * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<66>(evals) += tmp; } @@ -754,7 +813,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(67); - auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); + auto tmp = (avm_main_sel_internal_call * + (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<67>(evals) += tmp; } @@ -762,26 +822,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(68); - auto tmp = - ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * - (((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_fdiv) + - avm_main_sel_op_mul) + - avm_main_sel_op_not) + - avm_main_sel_op_eq) + - avm_main_sel_op_and) + - avm_main_sel_op_or) + - avm_main_sel_op_xor) + - avm_main_sel_op_cast) + - ((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_portal) + - avm_main_sel_op_chain_id) + - avm_main_sel_op_version) + - avm_main_sel_op_block_number) + - avm_main_sel_op_coinbase) + - avm_main_sel_op_timestamp) + - avm_main_sel_op_fee_per_l2_gas) + - avm_main_sel_op_fee_per_da_gas) + - avm_main_sel_op_transaction_fee))) * - (avm_main_pc_shift - (avm_main_pc + FF(1)))); + auto tmp = (avm_main_sel_internal_call * (avm_main_internal_return_ptr - avm_main_mem_idx_b)); tmp *= scaling_factor; std::get<68>(evals) += tmp; } @@ -789,10 +830,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(69); - auto tmp = ((-(((avm_main_first + avm_main_sel_internal_call) + avm_main_sel_internal_return) + - avm_main_sel_halt) + - FF(1)) * - (avm_main_internal_return_ptr_shift - avm_main_internal_return_ptr)); + auto tmp = (avm_main_sel_internal_call * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<69>(evals) += tmp; } @@ -800,7 +838,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(70); - auto tmp = ((avm_main_sel_internal_call + avm_main_sel_internal_return) * (avm_main_space_id - FF(255))); + auto tmp = (avm_main_sel_internal_call * ((avm_main_pc + FF(1)) - avm_main_ib)); tmp *= scaling_factor; std::get<70>(evals) += tmp; } @@ -808,25 +846,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(71); - auto tmp = - ((((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_fdiv) + - avm_main_sel_op_mul) + - avm_main_sel_op_not) + - avm_main_sel_op_eq) + - avm_main_sel_op_and) + - avm_main_sel_op_or) + - avm_main_sel_op_xor) + - avm_main_sel_op_cast) + - ((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_portal) + - avm_main_sel_op_chain_id) + - avm_main_sel_op_version) + - avm_main_sel_op_block_number) + - avm_main_sel_op_coinbase) + - avm_main_sel_op_timestamp) + - avm_main_sel_op_fee_per_l2_gas) + - avm_main_sel_op_fee_per_da_gas) + - avm_main_sel_op_transaction_fee)) * - (avm_main_call_ptr - avm_main_space_id)); + auto tmp = (avm_main_sel_internal_call * (avm_main_rwb - FF(1))); tmp *= scaling_factor; std::get<71>(evals) += tmp; } @@ -834,7 +854,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(72); - auto tmp = (avm_main_sel_cmov * (((avm_main_id * avm_main_inv) - FF(1)) + avm_main_id_zero)); + auto tmp = (avm_main_sel_internal_call * (avm_main_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<72>(evals) += tmp; } @@ -842,7 +862,8 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(73); - auto tmp = ((avm_main_sel_cmov * avm_main_id_zero) * (-avm_main_inv + FF(1))); + auto tmp = (avm_main_sel_internal_return * + (avm_main_internal_return_ptr_shift - (avm_main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<73>(evals) += tmp; } @@ -850,7 +871,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(74); - auto tmp = (avm_main_sel_mov_a - (avm_main_sel_mov + (avm_main_sel_cmov * (-avm_main_id_zero + FF(1))))); + auto tmp = (avm_main_sel_internal_return * ((avm_main_internal_return_ptr - FF(1)) - avm_main_mem_idx_a)); tmp *= scaling_factor; std::get<74>(evals) += tmp; } @@ -858,7 +879,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(75); - auto tmp = (avm_main_sel_mov_b - (avm_main_sel_cmov * avm_main_id_zero)); + auto tmp = (avm_main_sel_internal_return * (avm_main_pc_shift - avm_main_ia)); tmp *= scaling_factor; std::get<75>(evals) += tmp; } @@ -866,7 +887,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(76); - auto tmp = (avm_main_sel_mov_a * (avm_main_ia - avm_main_ic)); + auto tmp = (avm_main_sel_internal_return * avm_main_rwa); tmp *= scaling_factor; std::get<76>(evals) += tmp; } @@ -874,7 +895,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(77); - auto tmp = (avm_main_sel_mov_b * (avm_main_ib - avm_main_ic)); + auto tmp = (avm_main_sel_internal_return * (avm_main_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<77>(evals) += tmp; } @@ -882,7 +903,34 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(78); - auto tmp = ((avm_main_sel_mov + avm_main_sel_cmov) * (avm_main_r_in_tag - avm_main_w_in_tag)); + auto tmp = ((((-avm_main_first + FF(1)) * (-avm_main_sel_halt + FF(1))) * + ((((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + + avm_main_sel_op_fdiv) + + avm_main_sel_op_mul) + + avm_main_sel_op_not) + + avm_main_sel_op_eq) + + avm_main_sel_op_and) + + avm_main_sel_op_or) + + avm_main_sel_op_xor) + + avm_main_sel_op_cast) + + ((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_portal) + + avm_main_sel_op_chain_id) + + avm_main_sel_op_version) + + avm_main_sel_op_block_number) + + avm_main_sel_op_coinbase) + + avm_main_sel_op_timestamp) + + avm_main_sel_op_fee_per_l2_gas) + + avm_main_sel_op_fee_per_da_gas) + + avm_main_sel_op_transaction_fee)) + + ((((((((avm_main_sel_op_note_hash_exists + avm_main_sel_op_emit_note_hash) + + avm_main_sel_op_nullifier_exists) + + avm_main_sel_op_emit_nullifier) + + avm_main_sel_op_l1_to_l2_msg_exists) + + avm_main_sel_op_emit_unencrypted_log) + + avm_main_sel_op_emit_l2_to_l1_msg) + + avm_main_sel_op_sload) + + avm_main_sel_op_sstore))) * + (avm_main_pc_shift - (avm_main_pc + FF(1)))); tmp *= scaling_factor; std::get<78>(evals) += tmp; } @@ -890,18 +938,10 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(79); - auto tmp = - (avm_main_alu_sel - - ((((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + avm_main_sel_op_div) + - avm_main_sel_op_not) + - avm_main_sel_op_eq) + - avm_main_sel_op_lt) + - avm_main_sel_op_lte) + - avm_main_sel_op_shr) + - avm_main_sel_op_shl) + - avm_main_sel_op_cast) * - (-avm_main_tag_err + FF(1))) * - (-avm_main_op_err + FF(1)))); + auto tmp = ((-(((avm_main_first + avm_main_sel_internal_call) + avm_main_sel_internal_return) + + avm_main_sel_halt) + + FF(1)) * + (avm_main_internal_return_ptr_shift - avm_main_internal_return_ptr)); tmp *= scaling_factor; std::get<79>(evals) += tmp; } @@ -909,15 +949,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(80); - auto tmp = - ((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + avm_main_sel_op_div) + - avm_main_sel_op_not) + - avm_main_sel_op_eq) + - avm_main_sel_op_lt) + - avm_main_sel_op_lte) + - avm_main_sel_op_shr) + - avm_main_sel_op_shl) * - (avm_main_alu_in_tag - avm_main_r_in_tag)); + auto tmp = ((avm_main_sel_internal_call + avm_main_sel_internal_return) * (avm_main_space_id - FF(255))); tmp *= scaling_factor; std::get<80>(evals) += tmp; } @@ -925,7 +957,33 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(81); - auto tmp = (avm_main_sel_op_cast * (avm_main_alu_in_tag - avm_main_w_in_tag)); + auto tmp = + (((((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_div) + avm_main_sel_op_fdiv) + + avm_main_sel_op_mul) + + avm_main_sel_op_not) + + avm_main_sel_op_eq) + + avm_main_sel_op_and) + + avm_main_sel_op_or) + + avm_main_sel_op_xor) + + avm_main_sel_op_cast) + + ((((((((((avm_main_sel_op_sender + avm_main_sel_op_address) + avm_main_sel_op_portal) + + avm_main_sel_op_chain_id) + + avm_main_sel_op_version) + + avm_main_sel_op_block_number) + + avm_main_sel_op_coinbase) + + avm_main_sel_op_timestamp) + + avm_main_sel_op_fee_per_l2_gas) + + avm_main_sel_op_fee_per_da_gas) + + avm_main_sel_op_transaction_fee)) + + ((((((((avm_main_sel_op_note_hash_exists + avm_main_sel_op_emit_note_hash) + + avm_main_sel_op_nullifier_exists) + + avm_main_sel_op_emit_nullifier) + + avm_main_sel_op_l1_to_l2_msg_exists) + + avm_main_sel_op_emit_unencrypted_log) + + avm_main_sel_op_emit_l2_to_l1_msg) + + avm_main_sel_op_sload) + + avm_main_sel_op_sstore)) * + (avm_main_call_ptr - avm_main_space_id)); tmp *= scaling_factor; std::get<81>(evals) += tmp; } @@ -933,7 +991,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(82); - auto tmp = (avm_main_sel_op_sender * (avm_kernel_kernel_sel - FF(0))); + auto tmp = (avm_main_sel_cmov * (((avm_main_id * avm_main_inv) - FF(1)) + avm_main_id_zero)); tmp *= scaling_factor; std::get<82>(evals) += tmp; } @@ -941,7 +999,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(83); - auto tmp = (avm_main_sel_op_address * (avm_kernel_kernel_sel - FF(1))); + auto tmp = ((avm_main_sel_cmov * avm_main_id_zero) * (-avm_main_inv + FF(1))); tmp *= scaling_factor; std::get<83>(evals) += tmp; } @@ -949,7 +1007,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(84); - auto tmp = (avm_main_sel_op_portal * (avm_kernel_kernel_sel - FF(2))); + auto tmp = (avm_main_sel_mov_a - (avm_main_sel_mov + (avm_main_sel_cmov * (-avm_main_id_zero + FF(1))))); tmp *= scaling_factor; std::get<84>(evals) += tmp; } @@ -957,7 +1015,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(85); - auto tmp = (avm_main_sel_op_fee_per_da_gas * (avm_kernel_kernel_sel - FF(38))); + auto tmp = (avm_main_sel_mov_b - (avm_main_sel_cmov * avm_main_id_zero)); tmp *= scaling_factor; std::get<85>(evals) += tmp; } @@ -965,7 +1023,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(86); - auto tmp = (avm_main_sel_op_fee_per_l2_gas * (avm_kernel_kernel_sel - FF(39))); + auto tmp = (avm_main_sel_mov_a * (avm_main_ia - avm_main_ic)); tmp *= scaling_factor; std::get<86>(evals) += tmp; } @@ -973,7 +1031,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(87); - auto tmp = (avm_main_sel_op_transaction_fee * (avm_kernel_kernel_sel - FF(40))); + auto tmp = (avm_main_sel_mov_b * (avm_main_ib - avm_main_ic)); tmp *= scaling_factor; std::get<87>(evals) += tmp; } @@ -981,7 +1039,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(88); - auto tmp = (avm_main_sel_op_chain_id * (avm_kernel_kernel_sel - FF(29))); + auto tmp = ((avm_main_sel_mov + avm_main_sel_cmov) * (avm_main_r_in_tag - avm_main_w_in_tag)); tmp *= scaling_factor; std::get<88>(evals) += tmp; } @@ -989,7 +1047,18 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(89); - auto tmp = (avm_main_sel_op_version * (avm_kernel_kernel_sel - FF(30))); + auto tmp = + (avm_main_alu_sel - + ((((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + avm_main_sel_op_div) + + avm_main_sel_op_not) + + avm_main_sel_op_eq) + + avm_main_sel_op_lt) + + avm_main_sel_op_lte) + + avm_main_sel_op_shr) + + avm_main_sel_op_shl) + + avm_main_sel_op_cast) * + (-avm_main_tag_err + FF(1))) * + (-avm_main_op_err + FF(1)))); tmp *= scaling_factor; std::get<89>(evals) += tmp; } @@ -997,7 +1066,15 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(90); - auto tmp = (avm_main_sel_op_block_number * (avm_kernel_kernel_sel - FF(31))); + auto tmp = + ((((((((((avm_main_sel_op_add + avm_main_sel_op_sub) + avm_main_sel_op_mul) + avm_main_sel_op_div) + + avm_main_sel_op_not) + + avm_main_sel_op_eq) + + avm_main_sel_op_lt) + + avm_main_sel_op_lte) + + avm_main_sel_op_shr) + + avm_main_sel_op_shl) * + (avm_main_alu_in_tag - avm_main_r_in_tag)); tmp *= scaling_factor; std::get<90>(evals) += tmp; } @@ -1005,7 +1082,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(91); - auto tmp = (avm_main_sel_op_coinbase * (avm_kernel_kernel_sel - FF(33))); + auto tmp = (avm_main_sel_op_cast * (avm_main_alu_in_tag - avm_main_w_in_tag)); tmp *= scaling_factor; std::get<91>(evals) += tmp; } @@ -1013,7 +1090,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(92); - auto tmp = (avm_main_sel_op_timestamp * (avm_kernel_kernel_sel - FF(32))); + auto tmp = (avm_main_sel_op_sender * (avm_kernel_kernel_in_offset - FF(0))); tmp *= scaling_factor; std::get<92>(evals) += tmp; } @@ -1021,7 +1098,7 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(93); - auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); + auto tmp = (avm_main_sel_op_address * (avm_kernel_kernel_in_offset - FF(1))); tmp *= scaling_factor; std::get<93>(evals) += tmp; } @@ -1029,10 +1106,259 @@ template class avm_mainImpl { { Avm_DECLARE_VIEWS(94); - auto tmp = (avm_main_bin_sel - ((avm_main_sel_op_and + avm_main_sel_op_or) + avm_main_sel_op_xor)); + auto tmp = (avm_main_sel_op_portal * (avm_kernel_kernel_in_offset - FF(2))); tmp *= scaling_factor; std::get<94>(evals) += tmp; } + // Contribution 95 + { + Avm_DECLARE_VIEWS(95); + + auto tmp = (avm_main_sel_op_fee_per_da_gas * (avm_kernel_kernel_in_offset - FF(38))); + tmp *= scaling_factor; + std::get<95>(evals) += tmp; + } + // Contribution 96 + { + Avm_DECLARE_VIEWS(96); + + auto tmp = (avm_main_sel_op_fee_per_l2_gas * (avm_kernel_kernel_in_offset - FF(39))); + tmp *= scaling_factor; + std::get<96>(evals) += tmp; + } + // Contribution 97 + { + Avm_DECLARE_VIEWS(97); + + auto tmp = (avm_main_sel_op_transaction_fee * (avm_kernel_kernel_in_offset - FF(40))); + tmp *= scaling_factor; + std::get<97>(evals) += tmp; + } + // Contribution 98 + { + Avm_DECLARE_VIEWS(98); + + auto tmp = (avm_main_sel_op_chain_id * (avm_kernel_kernel_in_offset - FF(29))); + tmp *= scaling_factor; + std::get<98>(evals) += tmp; + } + // Contribution 99 + { + Avm_DECLARE_VIEWS(99); + + auto tmp = (avm_main_sel_op_version * (avm_kernel_kernel_in_offset - FF(30))); + tmp *= scaling_factor; + std::get<99>(evals) += tmp; + } + // Contribution 100 + { + Avm_DECLARE_VIEWS(100); + + auto tmp = (avm_main_sel_op_block_number * (avm_kernel_kernel_in_offset - FF(31))); + tmp *= scaling_factor; + std::get<100>(evals) += tmp; + } + // Contribution 101 + { + Avm_DECLARE_VIEWS(101); + + auto tmp = (avm_main_sel_op_coinbase * (avm_kernel_kernel_in_offset - FF(33))); + tmp *= scaling_factor; + std::get<101>(evals) += tmp; + } + // Contribution 102 + { + Avm_DECLARE_VIEWS(102); + + auto tmp = (avm_main_sel_op_timestamp * (avm_kernel_kernel_in_offset - FF(32))); + tmp *= scaling_factor; + std::get<102>(evals) += tmp; + } + // Contribution 103 + { + Avm_DECLARE_VIEWS(103); + + auto tmp = (avm_main_sel_op_note_hash_exists * + (avm_kernel_kernel_out_offset - (avm_kernel_note_hash_exist_write_offset + FF(0)))); + tmp *= scaling_factor; + std::get<103>(evals) += tmp; + } + // Contribution 104 + { + Avm_DECLARE_VIEWS(104); + + auto tmp = (avm_main_first * avm_kernel_note_hash_exist_write_offset); + tmp *= scaling_factor; + std::get<104>(evals) += tmp; + } + // Contribution 105 + { + Avm_DECLARE_VIEWS(105); + + auto tmp = (avm_main_sel_op_emit_note_hash * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_note_hash_write_offset + FF(4)))); + tmp *= scaling_factor; + std::get<105>(evals) += tmp; + } + // Contribution 106 + { + Avm_DECLARE_VIEWS(106); + + auto tmp = (avm_main_first * avm_kernel_emit_note_hash_write_offset); + tmp *= scaling_factor; + std::get<106>(evals) += tmp; + } + // Contribution 107 + { + Avm_DECLARE_VIEWS(107); + + auto tmp = (avm_main_sel_op_nullifier_exists * + (avm_kernel_kernel_out_offset - (avm_kernel_nullifier_exists_write_offset + FF(8)))); + tmp *= scaling_factor; + std::get<107>(evals) += tmp; + } + // Contribution 108 + { + Avm_DECLARE_VIEWS(108); + + auto tmp = (avm_main_first * avm_kernel_nullifier_exists_write_offset); + tmp *= scaling_factor; + std::get<108>(evals) += tmp; + } + // Contribution 109 + { + Avm_DECLARE_VIEWS(109); + + auto tmp = (avm_main_sel_op_emit_nullifier * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_nullifier_write_offset + FF(12)))); + tmp *= scaling_factor; + std::get<109>(evals) += tmp; + } + // Contribution 110 + { + Avm_DECLARE_VIEWS(110); + + auto tmp = (avm_main_first * avm_kernel_emit_nullifier_write_offset); + tmp *= scaling_factor; + std::get<110>(evals) += tmp; + } + // Contribution 111 + { + Avm_DECLARE_VIEWS(111); + + auto tmp = (avm_main_sel_op_l1_to_l2_msg_exists * + (avm_kernel_kernel_out_offset - (avm_kernel_l1_to_l2_msg_exists_write_offset + FF(16)))); + tmp *= scaling_factor; + std::get<111>(evals) += tmp; + } + // Contribution 112 + { + Avm_DECLARE_VIEWS(112); + + auto tmp = (avm_main_first * avm_kernel_l1_to_l2_msg_exists_write_offset); + tmp *= scaling_factor; + std::get<112>(evals) += tmp; + } + // Contribution 113 + { + Avm_DECLARE_VIEWS(113); + + auto tmp = (avm_main_sel_op_emit_unencrypted_log * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_unencrypted_log_write_offset + FF(20)))); + tmp *= scaling_factor; + std::get<113>(evals) += tmp; + } + // Contribution 114 + { + Avm_DECLARE_VIEWS(114); + + auto tmp = (avm_main_first * avm_kernel_emit_unencrypted_log_write_offset); + tmp *= scaling_factor; + std::get<114>(evals) += tmp; + } + // Contribution 115 + { + Avm_DECLARE_VIEWS(115); + + auto tmp = (avm_main_sel_op_emit_l2_to_l1_msg * + (avm_kernel_kernel_out_offset - (avm_kernel_emit_l2_to_l1_msg_write_offset + FF(24)))); + tmp *= scaling_factor; + std::get<115>(evals) += tmp; + } + // Contribution 116 + { + Avm_DECLARE_VIEWS(116); + + auto tmp = (avm_main_first * avm_kernel_emit_l2_to_l1_msg_write_offset); + tmp *= scaling_factor; + std::get<116>(evals) += tmp; + } + // Contribution 117 + { + Avm_DECLARE_VIEWS(117); + + auto tmp = + (avm_main_sel_op_sload * (avm_kernel_kernel_out_offset - (avm_kernel_sload_write_offset + FF(28)))); + tmp *= scaling_factor; + std::get<117>(evals) += tmp; + } + // Contribution 118 + { + Avm_DECLARE_VIEWS(118); + + auto tmp = (avm_main_first * avm_kernel_sload_write_offset); + tmp *= scaling_factor; + std::get<118>(evals) += tmp; + } + // Contribution 119 + { + Avm_DECLARE_VIEWS(119); + + auto tmp = + (avm_main_sel_op_sstore * (avm_kernel_kernel_out_offset - (avm_kernel_sstore_write_offset + FF(32)))); + tmp *= scaling_factor; + std::get<119>(evals) += tmp; + } + // Contribution 120 + { + Avm_DECLARE_VIEWS(120); + + auto tmp = (avm_main_first * avm_kernel_sstore_write_offset); + tmp *= scaling_factor; + std::get<120>(evals) += tmp; + } + // Contribution 121 + { + Avm_DECLARE_VIEWS(121); + + auto tmp = (((((((((avm_main_sel_op_note_hash_exists + avm_main_sel_op_emit_note_hash) + + avm_main_sel_op_nullifier_exists) + + avm_main_sel_op_emit_nullifier) + + avm_main_sel_op_l1_to_l2_msg_exists) + + avm_main_sel_op_emit_unencrypted_log) + + avm_main_sel_op_emit_l2_to_l1_msg) + + avm_main_sel_op_sload) + + avm_main_sel_op_sstore) * + (avm_kernel_side_effect_counter_shift - (avm_kernel_side_effect_counter + FF(1)))); + tmp *= scaling_factor; + std::get<121>(evals) += tmp; + } + // Contribution 122 + { + Avm_DECLARE_VIEWS(122); + + auto tmp = (avm_main_bin_op_id - (avm_main_sel_op_or + (avm_main_sel_op_xor * FF(2)))); + tmp *= scaling_factor; + std::get<122>(evals) += tmp; + } + // Contribution 123 + { + Avm_DECLARE_VIEWS(123); + + auto tmp = (avm_main_bin_sel - ((avm_main_sel_op_and + avm_main_sel_op_or) + avm_main_sel_op_xor)); + tmp *= scaling_factor; + std::get<123>(evals) += tmp; + } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp index 7ee02e24034..16af8374018 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/declare_views.hpp @@ -112,10 +112,36 @@ [[maybe_unused]] auto avm_conversion_num_limbs = View(new_term.avm_conversion_num_limbs); \ [[maybe_unused]] auto avm_conversion_radix = View(new_term.avm_conversion_radix); \ [[maybe_unused]] auto avm_conversion_to_radix_le_sel = View(new_term.avm_conversion_to_radix_le_sel); \ + [[maybe_unused]] auto avm_kernel_emit_l2_to_l1_msg_write_offset = \ + View(new_term.avm_kernel_emit_l2_to_l1_msg_write_offset); \ + [[maybe_unused]] auto avm_kernel_emit_note_hash_write_offset = \ + View(new_term.avm_kernel_emit_note_hash_write_offset); \ + [[maybe_unused]] auto avm_kernel_emit_nullifier_write_offset = \ + View(new_term.avm_kernel_emit_nullifier_write_offset); \ + [[maybe_unused]] auto avm_kernel_emit_unencrypted_log_write_offset = \ + View(new_term.avm_kernel_emit_unencrypted_log_write_offset); \ + [[maybe_unused]] auto avm_kernel_kernel_in_offset = View(new_term.avm_kernel_kernel_in_offset); \ [[maybe_unused]] auto avm_kernel_kernel_inputs__is_public = View(new_term.avm_kernel_kernel_inputs__is_public); \ - [[maybe_unused]] auto avm_kernel_kernel_sel = View(new_term.avm_kernel_kernel_sel); \ + [[maybe_unused]] auto avm_kernel_kernel_metadata_out__is_public = \ + View(new_term.avm_kernel_kernel_metadata_out__is_public); \ + [[maybe_unused]] auto avm_kernel_kernel_out_offset = View(new_term.avm_kernel_kernel_out_offset); \ + [[maybe_unused]] auto avm_kernel_kernel_side_effect_out__is_public = \ + View(new_term.avm_kernel_kernel_side_effect_out__is_public); \ + [[maybe_unused]] auto avm_kernel_kernel_value_out__is_public = \ + View(new_term.avm_kernel_kernel_value_out__is_public); \ + [[maybe_unused]] auto avm_kernel_l1_to_l2_msg_exists_write_offset = \ + View(new_term.avm_kernel_l1_to_l2_msg_exists_write_offset); \ + [[maybe_unused]] auto avm_kernel_note_hash_exist_write_offset = \ + View(new_term.avm_kernel_note_hash_exist_write_offset); \ + [[maybe_unused]] auto avm_kernel_nullifier_exists_write_offset = \ + View(new_term.avm_kernel_nullifier_exists_write_offset); \ [[maybe_unused]] auto avm_kernel_q_public_input_kernel_add_to_table = \ View(new_term.avm_kernel_q_public_input_kernel_add_to_table); \ + [[maybe_unused]] auto avm_kernel_q_public_input_kernel_out_add_to_table = \ + View(new_term.avm_kernel_q_public_input_kernel_out_add_to_table); \ + [[maybe_unused]] auto avm_kernel_side_effect_counter = View(new_term.avm_kernel_side_effect_counter); \ + [[maybe_unused]] auto avm_kernel_sload_write_offset = View(new_term.avm_kernel_sload_write_offset); \ + [[maybe_unused]] auto avm_kernel_sstore_write_offset = View(new_term.avm_kernel_sstore_write_offset); \ [[maybe_unused]] auto avm_main_alu_in_tag = View(new_term.avm_main_alu_in_tag); \ [[maybe_unused]] auto avm_main_alu_sel = View(new_term.avm_main_alu_sel); \ [[maybe_unused]] auto avm_main_bin_op_id = View(new_term.avm_main_bin_op_id); \ @@ -148,6 +174,7 @@ [[maybe_unused]] auto avm_main_op_err = View(new_term.avm_main_op_err); \ [[maybe_unused]] auto avm_main_pc = View(new_term.avm_main_pc); \ [[maybe_unused]] auto avm_main_q_kernel_lookup = View(new_term.avm_main_q_kernel_lookup); \ + [[maybe_unused]] auto avm_main_q_kernel_output_lookup = View(new_term.avm_main_q_kernel_output_lookup); \ [[maybe_unused]] auto avm_main_r_in_tag = View(new_term.avm_main_r_in_tag); \ [[maybe_unused]] auto avm_main_rwa = View(new_term.avm_main_rwa); \ [[maybe_unused]] auto avm_main_rwb = View(new_term.avm_main_rwb); \ @@ -169,20 +196,29 @@ [[maybe_unused]] auto avm_main_sel_op_chain_id = View(new_term.avm_main_sel_op_chain_id); \ [[maybe_unused]] auto avm_main_sel_op_coinbase = View(new_term.avm_main_sel_op_coinbase); \ [[maybe_unused]] auto avm_main_sel_op_div = View(new_term.avm_main_sel_op_div); \ + [[maybe_unused]] auto avm_main_sel_op_emit_l2_to_l1_msg = View(new_term.avm_main_sel_op_emit_l2_to_l1_msg); \ + [[maybe_unused]] auto avm_main_sel_op_emit_note_hash = View(new_term.avm_main_sel_op_emit_note_hash); \ + [[maybe_unused]] auto avm_main_sel_op_emit_nullifier = View(new_term.avm_main_sel_op_emit_nullifier); \ + [[maybe_unused]] auto avm_main_sel_op_emit_unencrypted_log = View(new_term.avm_main_sel_op_emit_unencrypted_log); \ [[maybe_unused]] auto avm_main_sel_op_eq = View(new_term.avm_main_sel_op_eq); \ [[maybe_unused]] auto avm_main_sel_op_fdiv = View(new_term.avm_main_sel_op_fdiv); \ [[maybe_unused]] auto avm_main_sel_op_fee_per_da_gas = View(new_term.avm_main_sel_op_fee_per_da_gas); \ [[maybe_unused]] auto avm_main_sel_op_fee_per_l2_gas = View(new_term.avm_main_sel_op_fee_per_l2_gas); \ + [[maybe_unused]] auto avm_main_sel_op_l1_to_l2_msg_exists = View(new_term.avm_main_sel_op_l1_to_l2_msg_exists); \ [[maybe_unused]] auto avm_main_sel_op_lt = View(new_term.avm_main_sel_op_lt); \ [[maybe_unused]] auto avm_main_sel_op_lte = View(new_term.avm_main_sel_op_lte); \ [[maybe_unused]] auto avm_main_sel_op_mul = View(new_term.avm_main_sel_op_mul); \ [[maybe_unused]] auto avm_main_sel_op_not = View(new_term.avm_main_sel_op_not); \ + [[maybe_unused]] auto avm_main_sel_op_note_hash_exists = View(new_term.avm_main_sel_op_note_hash_exists); \ + [[maybe_unused]] auto avm_main_sel_op_nullifier_exists = View(new_term.avm_main_sel_op_nullifier_exists); \ [[maybe_unused]] auto avm_main_sel_op_or = View(new_term.avm_main_sel_op_or); \ [[maybe_unused]] auto avm_main_sel_op_portal = View(new_term.avm_main_sel_op_portal); \ [[maybe_unused]] auto avm_main_sel_op_radix_le = View(new_term.avm_main_sel_op_radix_le); \ [[maybe_unused]] auto avm_main_sel_op_sender = View(new_term.avm_main_sel_op_sender); \ [[maybe_unused]] auto avm_main_sel_op_shl = View(new_term.avm_main_sel_op_shl); \ [[maybe_unused]] auto avm_main_sel_op_shr = View(new_term.avm_main_sel_op_shr); \ + [[maybe_unused]] auto avm_main_sel_op_sload = View(new_term.avm_main_sel_op_sload); \ + [[maybe_unused]] auto avm_main_sel_op_sstore = View(new_term.avm_main_sel_op_sstore); \ [[maybe_unused]] auto avm_main_sel_op_sub = View(new_term.avm_main_sel_op_sub); \ [[maybe_unused]] auto avm_main_sel_op_timestamp = View(new_term.avm_main_sel_op_timestamp); \ [[maybe_unused]] auto avm_main_sel_op_transaction_fee = View(new_term.avm_main_sel_op_transaction_fee); \ @@ -238,6 +274,7 @@ [[maybe_unused]] auto perm_main_mem_ind_d = View(new_term.perm_main_mem_ind_d); \ [[maybe_unused]] auto lookup_byte_lengths = View(new_term.lookup_byte_lengths); \ [[maybe_unused]] auto lookup_byte_operations = View(new_term.lookup_byte_operations); \ + [[maybe_unused]] auto kernel_output_lookup = View(new_term.kernel_output_lookup); \ [[maybe_unused]] auto lookup_into_kernel = View(new_term.lookup_into_kernel); \ [[maybe_unused]] auto incl_main_tag_err = View(new_term.incl_main_tag_err); \ [[maybe_unused]] auto incl_mem_tag_err = View(new_term.incl_mem_tag_err); \ @@ -273,6 +310,7 @@ [[maybe_unused]] auto lookup_div_u16_7 = View(new_term.lookup_div_u16_7); \ [[maybe_unused]] auto lookup_byte_lengths_counts = View(new_term.lookup_byte_lengths_counts); \ [[maybe_unused]] auto lookup_byte_operations_counts = View(new_term.lookup_byte_operations_counts); \ + [[maybe_unused]] auto kernel_output_lookup_counts = View(new_term.kernel_output_lookup_counts); \ [[maybe_unused]] auto lookup_into_kernel_counts = View(new_term.lookup_into_kernel_counts); \ [[maybe_unused]] auto incl_main_tag_err_counts = View(new_term.incl_main_tag_err_counts); \ [[maybe_unused]] auto incl_mem_tag_err_counts = View(new_term.incl_mem_tag_err_counts); \ @@ -351,6 +389,23 @@ [[maybe_unused]] auto avm_binary_acc_ic_shift = View(new_term.avm_binary_acc_ic_shift); \ [[maybe_unused]] auto avm_binary_mem_tag_ctr_shift = View(new_term.avm_binary_mem_tag_ctr_shift); \ [[maybe_unused]] auto avm_binary_op_id_shift = View(new_term.avm_binary_op_id_shift); \ + [[maybe_unused]] auto avm_kernel_emit_l2_to_l1_msg_write_offset_shift = \ + View(new_term.avm_kernel_emit_l2_to_l1_msg_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_emit_note_hash_write_offset_shift = \ + View(new_term.avm_kernel_emit_note_hash_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_emit_nullifier_write_offset_shift = \ + View(new_term.avm_kernel_emit_nullifier_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_emit_unencrypted_log_write_offset_shift = \ + View(new_term.avm_kernel_emit_unencrypted_log_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_l1_to_l2_msg_exists_write_offset_shift = \ + View(new_term.avm_kernel_l1_to_l2_msg_exists_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_note_hash_exist_write_offset_shift = \ + View(new_term.avm_kernel_note_hash_exist_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_nullifier_exists_write_offset_shift = \ + View(new_term.avm_kernel_nullifier_exists_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_side_effect_counter_shift = View(new_term.avm_kernel_side_effect_counter_shift); \ + [[maybe_unused]] auto avm_kernel_sload_write_offset_shift = View(new_term.avm_kernel_sload_write_offset_shift); \ + [[maybe_unused]] auto avm_kernel_sstore_write_offset_shift = View(new_term.avm_kernel_sstore_write_offset_shift); \ [[maybe_unused]] auto avm_main_internal_return_ptr_shift = View(new_term.avm_main_internal_return_ptr_shift); \ [[maybe_unused]] auto avm_main_pc_shift = View(new_term.avm_main_pc_shift); \ [[maybe_unused]] auto avm_mem_glob_addr_shift = View(new_term.avm_mem_glob_addr_shift); \ diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp new file mode 100644 index 00000000000..49023977d03 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/kernel_output_lookup.hpp @@ -0,0 +1,179 @@ + + +#pragma once + +#include "barretenberg/relations/generic_lookup/generic_lookup_relation.hpp" + +#include +#include + +namespace bb { + +/** + * @brief This class contains an example of how to set LookupSettings classes used by the + * GenericLookupRelationImpl class to specify a scaled lookup + * + * @details To create your own lookup: + * 1) Create a copy of this class and rename it + * 2) Update all the values with the ones needed for your lookup + * 3) Update "DECLARE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" and "DEFINE_LOOKUP_IMPLEMENTATIONS_FOR_ALL_SETTINGS" to + * include the new settings + * 4) Add the relation with the chosen settings to Relations in the flavor (for example,"` + * using Relations = std::tuple>;)` + * + */ +class kernel_output_lookup_lookup_settings { + public: + /** + * @brief The number of read terms (how many lookups we perform) in each row + * + */ + static constexpr size_t READ_TERMS = 1; + /** + * @brief The number of write terms (how many additions to the lookup table we make) in each row + * + */ + static constexpr size_t WRITE_TERMS = 1; + + /** + * @brief The type of READ_TERM used for each read index (basic and scaled) + * + */ + static constexpr size_t READ_TERM_TYPES[READ_TERMS] = { 0 }; + + /** + * @brief They type of WRITE_TERM used for each write index + * + */ + static constexpr size_t WRITE_TERM_TYPES[WRITE_TERMS] = { 0 }; + + /** + * @brief How many values represent a single lookup object. This value is used by the automatic read term + * implementation in the relation in case the lookup is a basic or scaled tuple and in the write term if it's a + * basic tuple + * + */ + static constexpr size_t LOOKUP_TUPLE_SIZE = 4; + + /** + * @brief The polynomial degree of the relation telling us if the inverse polynomial value needs to be computed + * + */ + static constexpr size_t INVERSE_EXISTS_POLYNOMIAL_DEGREE = 4; + + /** + * @brief The degree of the read term if implemented arbitrarily. This value is not used by basic and scaled read + * terms, but will cause compilation error if not defined + * + */ + static constexpr size_t READ_TERM_DEGREE = 0; + + /** + * @brief The degree of the write term if implemented arbitrarily. This value is not used by the basic write + * term, but will cause compilation error if not defined + * + */ + + static constexpr size_t WRITE_TERM_DEGREE = 0; + + /** + * @brief If this method returns true on a row of values, then the inverse polynomial exists at this index. + * Otherwise the value needs to be set to zero. + * + * @details If this is true then the lookup takes place in this row + * + */ + + template static inline auto inverse_polynomial_is_computed_at_row(const AllEntities& in) + { + return (in.avm_main_q_kernel_output_lookup == 1 || in.avm_kernel_q_public_input_kernel_out_add_to_table == 1); + } + + /** + * @brief Subprocedure for computing the value deciding if the inverse polynomial value needs to be checked in this + * row + * + * @tparam Accumulator Type specified by the lookup relation + * @tparam AllEntities Values/Univariates of all entities row + * @param in Value/Univariate of all entities at row/edge + * @return Accumulator + */ + + template + static inline auto compute_inverse_exists(const AllEntities& in) + { + using View = typename Accumulator::View; + const auto is_operation = View(in.avm_main_q_kernel_output_lookup); + const auto is_table_entry = View(in.avm_kernel_q_public_input_kernel_out_add_to_table); + return (is_operation + is_table_entry - is_operation * is_table_entry); + } + + /** + * @brief Get all the entities for the lookup when need to update them + * + * @details The generic structure of this tuple is described in ./generic_lookup_relation.hpp . The following is + description for the current case: + The entities are returned as a tuple of references in the following order (this is for ): + * - The entity/polynomial used to store the product of the inverse values + * - The entity/polynomial that specifies how many times the lookup table entry at this row has been looked up + * - READ_TERMS entities/polynomials that enable individual lookup operations + * - The entity/polynomial that enables adding an entry to the lookup table in this row + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the basic tuple being looked up as the first read term + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the previous accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the shifts in the second read term (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing the current accumulators in the second read term + (scaled tuple) + * - LOOKUP_TUPLE_SIZE entities/polynomials representing basic tuples added to the table + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_const_entities(const AllEntities& in) + { + + return std::forward_as_tuple(in.kernel_output_lookup, + in.kernel_output_lookup_counts, + in.avm_main_q_kernel_output_lookup, + in.avm_kernel_q_public_input_kernel_out_add_to_table, + in.avm_kernel_kernel_out_offset, + in.avm_main_ia, + in.avm_kernel_side_effect_counter, + in.avm_main_ib, + in.avm_main_clk, + in.avm_kernel_kernel_value_out__is_public, + in.avm_kernel_kernel_side_effect_out__is_public, + in.avm_kernel_kernel_metadata_out__is_public); + } + + /** + * @brief Get all the entities for the lookup when we only need to read them + * @details Same as in get_const_entities, but nonconst + * + * @return All the entities needed for the lookup + */ + + template static inline auto get_nonconst_entities(AllEntities& in) + { + + return std::forward_as_tuple(in.kernel_output_lookup, + in.kernel_output_lookup_counts, + in.avm_main_q_kernel_output_lookup, + in.avm_kernel_q_public_input_kernel_out_add_to_table, + in.avm_kernel_kernel_out_offset, + in.avm_main_ia, + in.avm_kernel_side_effect_counter, + in.avm_main_ib, + in.avm_main_clk, + in.avm_kernel_kernel_value_out__is_public, + in.avm_kernel_kernel_side_effect_out__is_public, + in.avm_kernel_kernel_metadata_out__is_public); + } +}; + +template +using kernel_output_lookup_relation = GenericLookupRelation; +template using kernel_output_lookup = GenericLookup; + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp index ac4eae2c174..8ece5f016e7 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/avm/lookup_into_kernel.hpp @@ -138,7 +138,7 @@ class lookup_into_kernel_lookup_settings { in.avm_main_q_kernel_lookup, in.avm_kernel_q_public_input_kernel_add_to_table, in.avm_main_ia, - in.avm_kernel_kernel_sel, + in.avm_kernel_kernel_in_offset, in.avm_kernel_kernel_inputs__is_public, in.avm_main_clk); } @@ -158,7 +158,7 @@ class lookup_into_kernel_lookup_settings { in.avm_main_q_kernel_lookup, in.avm_kernel_q_public_input_kernel_add_to_table, in.avm_main_ia, - in.avm_kernel_kernel_sel, + in.avm_kernel_kernel_in_offset, in.avm_kernel_kernel_inputs__is_public, in.avm_main_clk); } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp index 8ff696e1b92..abf467c180a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_common.hpp @@ -11,6 +11,17 @@ using Flavor = bb::AvmFlavor; using FF = Flavor::FF; using Row = bb::AvmFullRow; +// There are 4 public input columns, 1 for context inputs, and 3 for emitting side effects +using VmPublicInputs = std::tuple, // Input: Kernel context inputs + std::array, // Output: Kernel outputs data + std::array, // Output: Kernel outputs side effects + std::array>; // Output: Kernel outputs metadata +// Constants for indexing into the tuple above +static const size_t KERNEL_INPUTS = 0; +static const size_t KERNEL_OUTPUTS_VALUE = 1; +static const size_t KERNEL_OUTPUTS_SIDE_EFFECT_COUNTER = 2; +static const size_t KERNEL_OUTPUTS_METADATA = 3; + // Number of rows static const size_t AVM_TRACE_SIZE = 1 << 18; enum class IntermRegister : uint32_t { IA = 0, IB = 1, IC = 2, ID = 3 }; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp index f00c7305d7a..b7585d1f20d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.cpp @@ -2,7 +2,6 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/vm/avm_trace/avm_common.hpp" #include "barretenberg/vm/avm_trace/avm_deserialization.hpp" -#include "barretenberg/vm/avm_trace/avm_instructions.hpp" #include "barretenberg/vm/avm_trace/avm_opcode.hpp" #include "barretenberg/vm/avm_trace/avm_trace.hpp" #include "barretenberg/vm/generated/avm_circuit_builder.hpp" @@ -56,8 +55,9 @@ bool Execution::verify(AvmFlavor::VerificationKey vk, HonkProof const& proof) // output_state.pcs_verification_key = std::move(pcs_verification_key); // TODO: We hardcode public inputs for now - std::vector public_inputs = {}; - return verifier.verify_proof(proof, public_inputs); + VmPublicInputs public_inputs = {}; + std::vector> public_inputs_vec = copy_public_inputs_columns(public_inputs); + return verifier.verify_proof(proof, public_inputs_vec); } /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp index a6ca87d9272..d79127d01a6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_execution.hpp @@ -2,6 +2,7 @@ #include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/vm/avm_trace/avm_common.hpp" +#include "barretenberg/vm/avm_trace/avm_helper.hpp" #include "barretenberg/vm/avm_trace/avm_instructions.hpp" #include "barretenberg/vm/avm_trace/avm_trace.hpp" #include diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp index ad4f33cfd09..3720a7a0730 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.cpp @@ -101,4 +101,33 @@ bool is_operand_indirect(uint8_t ind_value, uint8_t operand_idx) return static_cast((ind_value & (1 << operand_idx)) >> operand_idx); } +std::vector> copy_public_inputs_columns(VmPublicInputs public_inputs) +{ + // We convert to a vector as the pil generated verifier is generic and unaware of the KERNEL_INPUTS_LENGTH + // For each of the public input vectors + std::vector public_inputs_kernel_inputs(KERNEL_INPUTS_LENGTH); + std::vector public_inputs_kernel_value_outputs(KERNEL_OUTPUTS_LENGTH); + std::vector public_inputs_kernel_side_effect_outputs(KERNEL_OUTPUTS_LENGTH); + std::vector public_inputs_kernel_metadata_outputs(KERNEL_OUTPUTS_LENGTH); + + std::copy(std::get<0>(public_inputs).begin(), std::get<0>(public_inputs).end(), public_inputs_kernel_inputs.data()); + std::copy(std::get<1>(public_inputs).begin(), + std::get<1>(public_inputs).end(), + public_inputs_kernel_value_outputs.data()); + std::copy(std::get<2>(public_inputs).begin(), + std::get<2>(public_inputs).end(), + public_inputs_kernel_side_effect_outputs.data()); + std::copy(std::get<3>(public_inputs).begin(), + std::get<3>(public_inputs).end(), + public_inputs_kernel_metadata_outputs.data()); + + std::vector> public_inputs_as_vec(4); + public_inputs_as_vec[0] = public_inputs_kernel_inputs; + public_inputs_as_vec[1] = public_inputs_kernel_value_outputs; + public_inputs_as_vec[2] = public_inputs_kernel_side_effect_outputs; + public_inputs_as_vec[3] = public_inputs_kernel_metadata_outputs; + + return public_inputs_as_vec; +} + } // namespace bb::avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.hpp index 2808f02dd4e..523168ff300 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_helper.hpp @@ -8,4 +8,10 @@ void log_avm_trace(std::vector const& trace, size_t beg, size_t end, bool e bool is_operand_indirect(uint8_t ind_value, uint8_t operand_idx); +// Copy Public Input Columns +// There are 4 public input columns, one for inputs, and 3 for the kernel outputs {value, side effect counter, metadata} +// The verifier is generic, and so accepts vectors of these values rather than the fixed length arrays that are used +// during circuit building. This method copies each array into a vector to be used by the verifier. +std::vector> copy_public_inputs_columns(VmPublicInputs public_inputs); + } // namespace bb::avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp index 7df78488b35..04b047fd5ab 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.cpp @@ -2,6 +2,7 @@ #include "barretenberg/vm/avm_trace/avm_common.hpp" #include "barretenberg/vm/avm_trace/avm_trace.hpp" #include "constants.hpp" +#include #include // For the meantime, we do not fire around the public inputs as a vector or otherwise @@ -9,78 +10,238 @@ namespace bb::avm_trace { -AvmKernelTraceBuilder::AvmKernelTraceBuilder(std::array kernel_inputs) - : kernel_inputs(kernel_inputs) +AvmKernelTraceBuilder::AvmKernelTraceBuilder(VmPublicInputs public_inputs) + : public_inputs(public_inputs) {} void AvmKernelTraceBuilder::reset() { - kernel_selector_counter.clear(); + kernel_input_selector_counter.clear(); + kernel_output_selector_counter.clear(); } -FF AvmKernelTraceBuilder::perform_kernel_lookup(uint32_t selector) +std::vector AvmKernelTraceBuilder::finalize() { - FF result = kernel_inputs[selector]; - kernel_selector_counter[selector]++; + return std::move(kernel_trace); +} + +FF AvmKernelTraceBuilder::perform_kernel_input_lookup(uint32_t selector) +{ + FF result = std::get<0>(public_inputs)[selector]; + kernel_input_selector_counter[selector]++; return result; } +void AvmKernelTraceBuilder::perform_kernel_output_lookup(uint32_t write_offset, const FF& value, const FF& metadata) +{ + std::get(public_inputs)[write_offset] = value; + std::get(public_inputs)[write_offset] = side_effect_counter; + std::get(public_inputs)[write_offset] = metadata; + + // Lookup counts + kernel_output_selector_counter[write_offset]++; + + side_effect_counter++; +} + // We want to be able to get the return value from the public inputs column // Get the return value, this will be places in ia // We read from the public inputs that were provided to the kernel FF AvmKernelTraceBuilder::op_sender() { - return perform_kernel_lookup(SENDER_SELECTOR); + return perform_kernel_input_lookup(SENDER_SELECTOR); } FF AvmKernelTraceBuilder::op_address() { - return perform_kernel_lookup(ADDRESS_SELECTOR); + return perform_kernel_input_lookup(ADDRESS_SELECTOR); } FF AvmKernelTraceBuilder::op_portal() { - return perform_kernel_lookup(PORTAL_SELECTOR); + return perform_kernel_input_lookup(PORTAL_SELECTOR); } FF AvmKernelTraceBuilder::op_fee_per_da_gas() { - return perform_kernel_lookup(FEE_PER_DA_GAS_SELECTOR); + return perform_kernel_input_lookup(FEE_PER_DA_GAS_SELECTOR); } FF AvmKernelTraceBuilder::op_fee_per_l2_gas() { - return perform_kernel_lookup(FEE_PER_L2_GAS_SELECTOR); + return perform_kernel_input_lookup(FEE_PER_L2_GAS_SELECTOR); } FF AvmKernelTraceBuilder::op_transaction_fee() { - return perform_kernel_lookup(TRANSACTION_FEE_SELECTOR); + return perform_kernel_input_lookup(TRANSACTION_FEE_SELECTOR); } FF AvmKernelTraceBuilder::op_chain_id() { - return perform_kernel_lookup(CHAIN_ID_SELECTOR); + return perform_kernel_input_lookup(CHAIN_ID_SELECTOR); } FF AvmKernelTraceBuilder::op_version() { - return perform_kernel_lookup(VERSION_SELECTOR); + return perform_kernel_input_lookup(VERSION_SELECTOR); } FF AvmKernelTraceBuilder::op_block_number() { - return perform_kernel_lookup(BLOCK_NUMBER_SELECTOR); + return perform_kernel_input_lookup(BLOCK_NUMBER_SELECTOR); } FF AvmKernelTraceBuilder::op_coinbase() { - return perform_kernel_lookup(COINBASE_SELECTOR); + return perform_kernel_input_lookup(COINBASE_SELECTOR); } FF AvmKernelTraceBuilder::op_timestamp() { - return perform_kernel_lookup(TIMESTAMP_SELECTOR); + return perform_kernel_input_lookup(TIMESTAMP_SELECTOR); +} + +// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): need to process hint from avm in order to know if +// output should be set to true or not +void AvmKernelTraceBuilder::op_note_hash_exists(uint32_t clk, const FF& note_hash, uint32_t result) +{ + + uint32_t offset = START_NOTE_HASH_EXISTS_WRITE_OFFSET + note_hash_exists_offset; + perform_kernel_output_lookup(offset, note_hash, FF(result)); + note_hash_exists_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_note_hash_exists = true, + }; + kernel_trace.push_back(entry); +} + +void AvmKernelTraceBuilder::op_emit_note_hash(uint32_t clk, const FF& note_hash) +{ + uint32_t offset = START_EMIT_NOTE_HASH_WRITE_OFFSET + emit_note_hash_offset; + perform_kernel_output_lookup(offset, note_hash, FF(0)); + emit_note_hash_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_emit_note_hash = true, + }; + kernel_trace.push_back(entry); +} + +// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): need to process hint from avm in order to know if +// output should be set to true or not +void AvmKernelTraceBuilder::op_nullifier_exists(uint32_t clk, const FF& nullifier, uint32_t result) +{ + uint32_t offset = START_NULLIFIER_EXISTS_OFFSET + nullifier_exists_offset; + perform_kernel_output_lookup(offset, nullifier, FF(result)); + nullifier_exists_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_nullifier_exists = true, + }; + kernel_trace.push_back(entry); +} + +void AvmKernelTraceBuilder::op_emit_nullifier(uint32_t clk, const FF& nullifier) +{ + uint32_t offset = START_EMIT_NULLIFIER_WRITE_OFFSET + emit_nullifier_offset; + perform_kernel_output_lookup(offset, nullifier, FF(0)); + emit_nullifier_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_emit_nullifier = true, + }; + kernel_trace.push_back(entry); +} + +// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): need to process hint from avm in order to know if +// output should be set to true or not +void AvmKernelTraceBuilder::op_l1_to_l2_msg_exists(uint32_t clk, const FF& message, uint32_t result) +{ + uint32_t offset = START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET + l1_to_l2_msg_exists_offset; + perform_kernel_output_lookup(offset, message, FF(result)); + l1_to_l2_msg_exists_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_l1_to_l2_msg_exists = true, + }; + kernel_trace.push_back(entry); +} + +void AvmKernelTraceBuilder::op_emit_unencrypted_log(uint32_t clk, const FF& log_hash) +{ + uint32_t offset = START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET + emit_unencrypted_log_offset; + perform_kernel_output_lookup(offset, log_hash, FF(0)); + emit_unencrypted_log_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_emit_unencrypted_log = true, + }; + kernel_trace.push_back(entry); +} + +void AvmKernelTraceBuilder::op_emit_l2_to_l1_msg(uint32_t clk, const FF& l2_to_l1_msg) +{ + uint32_t offset = START_L2_TO_L1_MSG_WRITE_OFFSET + emit_l2_to_l1_msg_offset; + perform_kernel_output_lookup(offset, l2_to_l1_msg, FF(0)); + emit_l2_to_l1_msg_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_emit_l2_to_l1_msg = true, + }; + kernel_trace.push_back(entry); +} + +void AvmKernelTraceBuilder::op_sload(uint32_t clk, const FF& slot, const FF& value) +{ + uint32_t offset = START_SLOAD_WRITE_OFFSET + sload_write_offset; + perform_kernel_output_lookup(offset, value, slot); + sload_write_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_sload = true, + }; + kernel_trace.push_back(entry); +} + +void AvmKernelTraceBuilder::op_sstore(uint32_t clk, const FF& slot, const FF& value) +{ + uint32_t offset = START_SSTORE_WRITE_OFFSET + sstore_write_offset; + perform_kernel_output_lookup(offset, value, slot); + sstore_write_offset++; + + KernelTraceEntry entry = { + .clk = clk, + .kernel_out_offset = offset, + .q_kernel_output_lookup = true, + .op_sstore = true, + }; + kernel_trace.push_back(entry); } } // namespace bb::avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp index dd06765131b..d21dc783fe0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_kernel_trace.hpp @@ -36,19 +36,39 @@ namespace bb::avm_trace { class AvmKernelTraceBuilder { public: struct KernelTraceEntry { - uint32_t kernel_selector = 0; + // Clk - to join black onto the main trace + uint32_t clk = 0; + uint32_t kernel_in_offset = 0; + uint32_t kernel_out_offset = 0; bool q_kernel_lookup = false; + bool q_kernel_output_lookup = false; + + // In finalise, the main trace writes the correct write_offset for each operation based appearing selectors + bool op_note_hash_exists = false; + bool op_emit_note_hash = false; + bool op_nullifier_exists = false; + bool op_emit_nullifier = false; + bool op_l1_to_l2_msg_exists = false; + bool op_emit_unencrypted_log = false; + bool op_emit_l2_to_l1_msg = false; + bool op_sload = false; + bool op_sstore = false; }; - std::array kernel_inputs{}; + VmPublicInputs public_inputs{}; // Counts the number of accesses into each SELECTOR for the environment selector lookups; - std::unordered_map kernel_selector_counter; + std::unordered_map kernel_input_selector_counter; + + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6484): as outputs are only written to once, we can + // optimise this to just hardcode the counter to be the same as the lookup selector value!!! + std::unordered_map kernel_output_selector_counter; // Constructor receives copy of kernel_inputs from the main trace builder - AvmKernelTraceBuilder(std::array kernel_inputs); + AvmKernelTraceBuilder(VmPublicInputs public_inputs); void reset(); + std::vector finalize(); // Context FF op_sender(); @@ -67,9 +87,51 @@ class AvmKernelTraceBuilder { FF op_coinbase(); FF op_timestamp(); + // Outputs + // Each returns the selector that was used + void op_note_hash_exists(uint32_t clk, const FF& note_hash, uint32_t result); + void op_emit_note_hash(uint32_t clk, const FF& note_hash); + void op_nullifier_exists(uint32_t clk, const FF& nullifier, uint32_t result); + void op_emit_nullifier(uint32_t clk, const FF& nullifier); + void op_l1_to_l2_msg_exists(uint32_t clk, const FF& message, uint32_t result); + void op_emit_unencrypted_log(uint32_t clk, const FF& log_hash); + void op_emit_l2_to_l1_msg(uint32_t clk, const FF& message); + + void op_sload(uint32_t clk, const FF& slot, const FF& value); + void op_sstore(uint32_t clk, const FF& slot, const FF& value); + + // Temp: these are temporary offsets + static const uint32_t START_NOTE_HASH_EXISTS_WRITE_OFFSET = 0; + static const uint32_t START_EMIT_NOTE_HASH_WRITE_OFFSET = 4; + static const uint32_t START_NULLIFIER_EXISTS_OFFSET = 8; + static const uint32_t START_EMIT_NULLIFIER_WRITE_OFFSET = 12; + static const uint32_t START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET = 16; + static const uint32_t START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 20; + static const uint32_t START_L2_TO_L1_MSG_WRITE_OFFSET = 24; + + static const uint32_t START_SLOAD_WRITE_OFFSET = 28; + static const uint32_t START_SSTORE_WRITE_OFFSET = 32; + private: std::vector kernel_trace; - FF perform_kernel_lookup(uint32_t selector); + // Side effect counter will incremenent when any state writing values are + // encountered + uint32_t side_effect_counter = 0; + + // Output index counters + uint32_t note_hash_exists_offset = 0; + uint32_t emit_note_hash_offset = 0; + uint32_t nullifier_exists_offset = 0; + uint32_t emit_nullifier_offset = 0; + uint32_t l1_to_l2_msg_exists_offset = 0; + uint32_t emit_unencrypted_log_offset = 0; + uint32_t emit_l2_to_l1_msg_offset = 0; + + uint32_t sload_write_offset = 0; + uint32_t sstore_write_offset = 0; + + FF perform_kernel_input_lookup(uint32_t selector); + void perform_kernel_output_lookup(uint32_t write_offset, const FF& value, const FF& metadata); }; } // namespace bb::avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp index 51078c7577c..01799fab2a8 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.cpp @@ -16,7 +16,6 @@ #include "avm_mem_trace.hpp" #include "avm_trace.hpp" #include "barretenberg/vm/avm_trace/avm_kernel_trace.hpp" -#include "barretenberg/vm/avm_trace/aztec_constants.hpp" namespace bb::avm_trace { @@ -24,9 +23,9 @@ namespace bb::avm_trace { * @brief Constructor of a trace builder of AVM. Only serves to set the capacity of the * underlying traces. */ -AvmTraceBuilder::AvmTraceBuilder(std::array kernel_inputs) +AvmTraceBuilder::AvmTraceBuilder(VmPublicInputs public_inputs) // NOTE: we initialise the environment builder here as it requires public inputs - : kernel_trace_builder(kernel_inputs) + : kernel_trace_builder(public_inputs) { main_trace.reserve(AVM_TRACE_SIZE); } @@ -126,7 +125,9 @@ void AvmTraceBuilder::op_add( mem_trace_builder.write_into_memory(call_ptr, clk, IntermRegister::IC, res.direct_c_offset, c, in_tag, in_tag); main_trace.push_back(Row{ + .avm_main_clk = clk, + .avm_main_alu_in_tag = FF(static_cast(in_tag)), .avm_main_call_ptr = call_ptr, .avm_main_ia = a, @@ -1095,7 +1096,7 @@ Row AvmTraceBuilder::create_kernel_lookup_opcode(uint32_t dst_offset, uint32_t s return Row{ .avm_main_clk = clk, - .avm_kernel_kernel_sel = selector, + .avm_kernel_kernel_in_offset = selector, .avm_main_call_ptr = call_ptr, .avm_main_ia = value, .avm_main_ind_a = 0, @@ -1208,6 +1209,195 @@ void AvmTraceBuilder::op_timestamp(uint32_t dst_offset) main_trace.push_back(row); } +// Helper function to add kernel lookup operations into the main trace +Row AvmTraceBuilder::create_kernel_output_opcode(uint32_t clk, uint32_t data_offset) +{ + AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IA, data_offset, AvmMemoryTag::FF, AvmMemoryTag::U0); + + return Row{ + .avm_main_clk = clk, + .avm_main_ia = read_a.val, + .avm_main_ind_a = 0, + .avm_main_internal_return_ptr = internal_return_ptr, + .avm_main_mem_idx_a = data_offset, + .avm_main_mem_op_a = 1, + .avm_main_pc = pc++, + .avm_main_q_kernel_output_lookup = 1, + .avm_main_r_in_tag = static_cast(AvmMemoryTag::FF), + .avm_main_rwa = 0, + }; +} + +Row AvmTraceBuilder::create_kernel_output_opcode_with_metadata( + uint32_t clk, uint32_t data_offset, AvmMemoryTag data_r_tag, uint32_t metadata_offset, AvmMemoryTag metadata_r_tag) +{ + AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IA, data_offset, data_r_tag, AvmMemoryTag::U0); + + AvmMemTraceBuilder::MemRead read_b = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IB, metadata_offset, metadata_r_tag, AvmMemoryTag::U0); + + return Row{ + .avm_main_clk = clk, + .avm_main_ia = read_a.val, + .avm_main_ib = read_b.val, + .avm_main_ind_a = 0, + .avm_main_ind_b = 0, + .avm_main_internal_return_ptr = internal_return_ptr, + .avm_main_mem_idx_a = data_offset, + .avm_main_mem_idx_b = metadata_offset, + .avm_main_mem_op_a = 1, + .avm_main_mem_op_b = 1, + .avm_main_pc = pc++, + .avm_main_q_kernel_output_lookup = 1, + .avm_main_r_in_tag = static_cast(data_r_tag), + .avm_main_rwa = 0, + .avm_main_rwb = 0, + }; +} + +Row AvmTraceBuilder::create_kernel_output_opcode_with_set_metadata_output( + uint32_t clk, uint32_t data_offset, AvmMemoryTag data_r_tag, uint32_t metadata_offset, FF write_value) +{ + AvmMemTraceBuilder::MemRead read_a = mem_trace_builder.read_and_load_from_memory( + call_ptr, clk, IntermRegister::IA, data_offset, data_r_tag, AvmMemoryTag::U8); + + mem_trace_builder.write_into_memory( + call_ptr, clk, IntermRegister::IB, metadata_offset, write_value, data_r_tag, AvmMemoryTag::U8); + + return Row{ + .avm_main_clk = clk, + .avm_main_ia = read_a.val, + .avm_main_ib = write_value, + .avm_main_ind_a = 0, + .avm_main_ind_b = 0, + .avm_main_internal_return_ptr = internal_return_ptr, + .avm_main_mem_idx_a = data_offset, + .avm_main_mem_idx_b = metadata_offset, + .avm_main_mem_op_a = 1, + .avm_main_mem_op_b = 1, + .avm_main_pc = pc++, + .avm_main_q_kernel_output_lookup = 1, + .avm_main_r_in_tag = static_cast(data_r_tag), + .avm_main_rwa = 0, + .avm_main_rwb = 1, + .avm_main_w_in_tag = static_cast(AvmMemoryTag::U8), + }; +} + +void AvmTraceBuilder::op_emit_note_hash(uint32_t note_hash_offset) +{ + auto const clk = static_cast(main_trace.size()); + + Row row = create_kernel_output_opcode(clk, note_hash_offset); + kernel_trace_builder.op_emit_note_hash(clk, row.avm_main_ia); + row.avm_main_sel_op_emit_note_hash = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_emit_nullifier(uint32_t nullifier_offset) +{ + auto const clk = static_cast(main_trace.size()); + + Row row = create_kernel_output_opcode(clk, nullifier_offset); + kernel_trace_builder.op_emit_nullifier(clk, row.avm_main_ia); + row.avm_main_sel_op_emit_nullifier = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_emit_l2_to_l1_msg(uint32_t msg_offset) +{ + auto const clk = static_cast(main_trace.size()); + + Row row = create_kernel_output_opcode(clk, msg_offset); + kernel_trace_builder.op_emit_l2_to_l1_msg(clk, row.avm_main_ia); + row.avm_main_sel_op_emit_l2_to_l1_msg = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_emit_unencrypted_log(uint32_t log_offset) +{ + auto const clk = static_cast(main_trace.size()); + + Row row = create_kernel_output_opcode(clk, log_offset); + kernel_trace_builder.op_emit_unencrypted_log(clk, row.avm_main_ia); + row.avm_main_sel_op_emit_unencrypted_log = FF(1); + + main_trace.push_back(row); +} + +// State output opcodes that include metadata +void AvmTraceBuilder::op_l1_to_l2_msg_exists(uint32_t log_offset, uint32_t dest_offset) +{ + auto const clk = static_cast(main_trace.size()); + + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/6481): success or fail must come from hint - it is + // always 1 for now + uint32_t result = 1; + Row row = + create_kernel_output_opcode_with_set_metadata_output(clk, log_offset, AvmMemoryTag::FF, dest_offset, result); + kernel_trace_builder.op_l1_to_l2_msg_exists(clk, row.avm_main_ia, result); + row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_note_hash_exists(uint32_t note_offset, uint32_t dest_offset) +{ + auto const clk = static_cast(main_trace.size()); + + // TODO(ISSUE_NUMBER): success or fail must come from hint - it is always 1 for now + uint32_t result = 1; + Row row = + create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, AvmMemoryTag::FF, dest_offset, result); + kernel_trace_builder.op_note_hash_exists(clk, row.avm_main_ia, result); + row.avm_main_sel_op_l1_to_l2_msg_exists = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_nullifier_exists(uint32_t note_offset, uint32_t dest_offset) +{ + auto const clk = static_cast(main_trace.size()); + + // TODO(ISSUE_NUMBER): success or fail must come from hint - it is always 1 for now + uint32_t result = 1; + Row row = + create_kernel_output_opcode_with_set_metadata_output(clk, note_offset, AvmMemoryTag::FF, dest_offset, result); + kernel_trace_builder.op_nullifier_exists(clk, row.avm_main_ia, result); + row.avm_main_sel_op_nullifier_exists = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_sload(uint32_t slot_offset, uint32_t value_offset) +{ + auto const clk = static_cast(main_trace.size()); + + Row row = + create_kernel_output_opcode_with_metadata(clk, value_offset, AvmMemoryTag::FF, slot_offset, AvmMemoryTag::FF); + kernel_trace_builder.op_sload(clk, row.avm_main_ib, row.avm_main_ia); + row.avm_main_sel_op_sload = FF(1); + + main_trace.push_back(row); +} + +void AvmTraceBuilder::op_sstore(uint32_t slot_offset, uint32_t value_offset) +{ + auto const clk = static_cast(main_trace.size()); + + Row row = + create_kernel_output_opcode_with_metadata(clk, value_offset, AvmMemoryTag::FF, slot_offset, AvmMemoryTag::FF); + kernel_trace_builder.op_sstore(clk, row.avm_main_ib, row.avm_main_ia); + row.avm_main_sel_op_sstore = FF(1); + + main_trace.push_back(row); +} + /** * @brief Cast an element pointed by the address a_offset into type specified by dst_tag and store the result in address given by dst_offset. @@ -2019,8 +2209,8 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c // 2**16 long) size_t const lookup_table_size = (bin_trace_size > 0 && range_check_required) ? 3 * (1 << 16) : 0; size_t const range_check_size = range_check_required ? UINT16_MAX + 1 : 0; - std::vector trace_sizes = { mem_trace_size, main_trace_size, alu_trace_size, lookup_table_size, - range_check_size, conv_trace_size, KERNEL_INPUTS_LENGTH, min_trace_size }; + std::vector trace_sizes = { mem_trace_size, main_trace_size, alu_trace_size, lookup_table_size, + range_check_size, conv_trace_size, KERNEL_OUTPUTS_LENGTH, min_trace_size }; auto trace_size = std::max_element(trace_sizes.begin(), trace_sizes.end()); // We only need to pad with zeroes to the size to the largest trace here, pow_2 padding is handled in the @@ -2438,12 +2628,152 @@ std::vector AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c for (uint32_t selector_index : KERNEL_INPUTS_SELECTORS) { auto& dest = main_trace.at(selector_index); dest.lookup_into_kernel_counts = - FF(kernel_trace_builder.kernel_selector_counter[static_cast(selector_index)]); + FF(kernel_trace_builder.kernel_input_selector_counter[static_cast(selector_index)]); dest.avm_kernel_q_public_input_kernel_add_to_table = FF(1); } + // Copy the kernel input public inputs for (size_t i = 0; i < KERNEL_INPUTS_LENGTH; i++) { - main_trace.at(i).avm_kernel_kernel_inputs__is_public = kernel_trace_builder.kernel_inputs.at(i); + main_trace.at(i).avm_kernel_kernel_inputs__is_public = + std::get(kernel_trace_builder.public_inputs).at(i); + } + + // Copy the kernel outputs counts into the main trace, + for (size_t i = 0; i < KERNEL_OUTPUTS_LENGTH; i++) { + main_trace.at(i).avm_kernel_kernel_value_out__is_public = + std::get(kernel_trace_builder.public_inputs).at(i); + + main_trace.at(i).avm_kernel_kernel_side_effect_out__is_public = + std::get(kernel_trace_builder.public_inputs).at(i); + + main_trace.at(i).avm_kernel_kernel_metadata_out__is_public = + std::get(kernel_trace_builder.public_inputs).at(i); + } + + // Write lookup counts for outputs + for (uint32_t i = 0; i < KERNEL_OUTPUTS_LENGTH; i++) { + auto value = kernel_trace_builder.kernel_output_selector_counter.find(i); + if (value != kernel_trace_builder.kernel_output_selector_counter.end()) { + auto& dest = main_trace.at(i); + dest.kernel_output_lookup_counts = FF(value->second); + dest.avm_kernel_q_public_input_kernel_out_add_to_table = FF(1); + } + } + + // Write the kernel trace into the main trace + // 1. The write offsets are constrained to be non changing over the entire trace, so we fill in the values until we + // hit an operation that changes one of the write_offsets (a relevant opcode) + // 2. Upon hitting the clk of each kernel operation we copy the values into the main trace + // 3. When an increment is required, we increment the value in the next row, then continue the process until the end + // 4. Whenever we hit the last row, we zero all write_offsets such that the shift relation will succeed + std::vector kernel_trace = kernel_trace_builder.finalize(); + size_t kernel_padding_main_trace_bottom = 1; + for (size_t i = 0; i < kernel_trace.size(); i++) { + auto const& src = kernel_trace.at(i); + // check the clock and iterate through the main trace until we hit the clock + auto clk = src.clk; + + // Until the next kernel changing instruction is encountered we set all of the values of the offset arrays + // to be the same as the previous row This satisfies the `offset' - (offset + operation_selector) = 0` + // constraints + for (size_t j = kernel_padding_main_trace_bottom; j < clk; j++) { + auto const& prev = main_trace.at(j - 1); + auto& dest = main_trace.at(j); + + dest.avm_kernel_note_hash_exist_write_offset = prev.avm_kernel_note_hash_exist_write_offset; + dest.avm_kernel_emit_note_hash_write_offset = prev.avm_kernel_emit_note_hash_write_offset; + dest.avm_kernel_nullifier_exists_write_offset = prev.avm_kernel_nullifier_exists_write_offset; + dest.avm_kernel_emit_nullifier_write_offset = prev.avm_kernel_emit_nullifier_write_offset; + dest.avm_kernel_emit_l2_to_l1_msg_write_offset = prev.avm_kernel_emit_l2_to_l1_msg_write_offset; + dest.avm_kernel_emit_unencrypted_log_write_offset = prev.avm_kernel_emit_unencrypted_log_write_offset; + dest.avm_kernel_l1_to_l2_msg_exists_write_offset = prev.avm_kernel_l1_to_l2_msg_exists_write_offset; + dest.avm_kernel_sload_write_offset = prev.avm_kernel_sload_write_offset; + dest.avm_kernel_sstore_write_offset = prev.avm_kernel_sstore_write_offset; + dest.avm_kernel_side_effect_counter = prev.avm_kernel_side_effect_counter; + } + + Row& curr = main_trace.at(clk); + + // Read in values from kernel trace + // Lookup values + curr.avm_kernel_kernel_in_offset = src.kernel_in_offset; + curr.avm_kernel_kernel_out_offset = src.kernel_out_offset; + curr.avm_main_q_kernel_lookup = static_cast(src.q_kernel_lookup); + curr.avm_main_q_kernel_output_lookup = static_cast(src.q_kernel_output_lookup); + + // Operation selectors + curr.avm_main_sel_op_note_hash_exists = static_cast(src.op_note_hash_exists); + curr.avm_main_sel_op_emit_note_hash = static_cast(src.op_emit_note_hash); + curr.avm_main_sel_op_nullifier_exists = static_cast(src.op_nullifier_exists); + curr.avm_main_sel_op_emit_nullifier = static_cast(src.op_emit_nullifier); + curr.avm_main_sel_op_l1_to_l2_msg_exists = static_cast(src.op_l1_to_l2_msg_exists); + curr.avm_main_sel_op_emit_unencrypted_log = static_cast(src.op_emit_unencrypted_log); + curr.avm_main_sel_op_emit_l2_to_l1_msg = static_cast(src.op_emit_l2_to_l1_msg); + curr.avm_main_sel_op_sload = static_cast(src.op_sload); + curr.avm_main_sel_op_sstore = static_cast(src.op_sstore); + + if (clk < main_trace_size) { + Row& next = main_trace.at(clk + 1); + + // Increment the write offset counter for the following row + if (src.op_note_hash_exists) { + next.avm_kernel_note_hash_exist_write_offset = curr.avm_kernel_note_hash_exist_write_offset + 1; + } else if (src.op_emit_note_hash) { + next.avm_kernel_emit_note_hash_write_offset = curr.avm_kernel_emit_note_hash_write_offset + 1; + } else if (src.op_emit_nullifier) { + next.avm_kernel_emit_nullifier_write_offset = curr.avm_kernel_emit_nullifier_write_offset + 1; + } else if (src.op_nullifier_exists) { + next.avm_kernel_nullifier_exists_write_offset = curr.avm_kernel_nullifier_exists_write_offset + 1; + } else if (src.op_l1_to_l2_msg_exists) { + next.avm_kernel_l1_to_l2_msg_exists_write_offset = curr.avm_kernel_l1_to_l2_msg_exists_write_offset + 1; + } else if (src.op_emit_l2_to_l1_msg) { + next.avm_kernel_emit_l2_to_l1_msg_write_offset = curr.avm_kernel_emit_l2_to_l1_msg_write_offset + 1; + } else if (src.op_emit_unencrypted_log) { + next.avm_kernel_emit_unencrypted_log_write_offset = + curr.avm_kernel_emit_unencrypted_log_write_offset + 1; + } else if (src.op_sload) { + next.avm_kernel_sload_write_offset = curr.avm_kernel_sload_write_offset + 1; + } else if (src.op_sstore) { + next.avm_kernel_sstore_write_offset = curr.avm_kernel_sstore_write_offset + 1; + } + + // The side effect counter will increment regardless of the offset value + next.avm_kernel_side_effect_counter = curr.avm_kernel_side_effect_counter + 1; + } + + kernel_padding_main_trace_bottom = clk + 1; + } + + // Pad out the main trace from the bottom of the main trace until the end + for (size_t i = kernel_padding_main_trace_bottom + 1; i < main_trace_size; ++i) { + + Row const& prev = main_trace.at(i - 1); + Row& dest = main_trace.at(i); + + // Setting all of the counters to 0 after the IS_LAST check so we can satisfy the constraints until the end + if (i == main_trace_size) { + dest.avm_kernel_note_hash_exist_write_offset = 0; + dest.avm_kernel_emit_note_hash_write_offset = 0; + dest.avm_kernel_nullifier_exists_write_offset = 0; + dest.avm_kernel_emit_nullifier_write_offset = 0; + dest.avm_kernel_l1_to_l2_msg_exists_write_offset = 0; + dest.avm_kernel_emit_unencrypted_log_write_offset = 0; + dest.avm_kernel_emit_l2_to_l1_msg_write_offset = 0; + dest.avm_kernel_sload_write_offset = 0; + dest.avm_kernel_sstore_write_offset = 0; + dest.avm_kernel_side_effect_counter = 0; + } else { + dest.avm_kernel_note_hash_exist_write_offset = prev.avm_kernel_note_hash_exist_write_offset; + dest.avm_kernel_emit_note_hash_write_offset = prev.avm_kernel_emit_note_hash_write_offset; + dest.avm_kernel_nullifier_exists_write_offset = prev.avm_kernel_nullifier_exists_write_offset; + dest.avm_kernel_emit_nullifier_write_offset = prev.avm_kernel_emit_nullifier_write_offset; + dest.avm_kernel_l1_to_l2_msg_exists_write_offset = prev.avm_kernel_l1_to_l2_msg_exists_write_offset; + dest.avm_kernel_emit_unencrypted_log_write_offset = prev.avm_kernel_emit_unencrypted_log_write_offset; + dest.avm_kernel_emit_l2_to_l1_msg_write_offset = prev.avm_kernel_emit_l2_to_l1_msg_write_offset; + dest.avm_kernel_sload_write_offset = prev.avm_kernel_sload_write_offset; + dest.avm_kernel_sstore_write_offset = prev.avm_kernel_sstore_write_offset; + dest.avm_kernel_side_effect_counter = prev.avm_kernel_side_effect_counter; + } } // Adding extra row for the shifted values at the top of the execution trace. diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp index 36baa3b76fd..89a4b3f76b3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/avm_trace.hpp @@ -23,7 +23,7 @@ namespace bb::avm_trace { class AvmTraceBuilder { public: - AvmTraceBuilder(std::array kernel_inputs = {}); + AvmTraceBuilder(VmPublicInputs public_inputs = {}); std::vector finalize(uint32_t min_trace_size = 0, bool range_check_required = false); void reset(); @@ -96,6 +96,21 @@ class AvmTraceBuilder { void op_coinbase(uint32_t dst_offset); void op_timestamp(uint32_t dst_offset); + // Outputs + // With single output values + void op_emit_note_hash(uint32_t note_hash_offset); + void op_emit_nullifier(uint32_t nullifier_offset); + void op_emit_unencrypted_log(uint32_t log_offset); + void op_emit_l2_to_l1_msg(uint32_t msg_offset); + + // With additional metadata output + void op_l1_to_l2_msg_exists(uint32_t msg_offset, uint32_t dest_offset); + void op_note_hash_exists(uint32_t note_hash_offset, uint32_t dest_offset); + void op_nullifier_exists(uint32_t nullifier_offset, uint32_t dest_offset); + + void op_sload(uint32_t slot_offset, uint32_t value_offset); + void op_sstore(uint32_t slot_offset, uint32_t value_offset); + // Cast an element pointed by the address a_offset into type specified by dst_tag and // store the result in address given by dst_offset. void op_cast(uint8_t indirect, uint32_t a_offset, uint32_t dst_offset, AvmMemoryTag dst_tag); @@ -155,7 +170,64 @@ class AvmTraceBuilder { AvmKernelTraceBuilder kernel_trace_builder; AvmConversionTraceBuilder conversion_trace_builder; + /** + * @brief Create a kernel lookup opcode object + * + * Used for looking up into the kernel inputs (context) - {caller, address, etc.} + * + * @param dst_offset - Memory address to write the lookup result to + * @param selector - The index of the kernel input lookup column + * @param value - The value read from the memory address + * @param w_tag - The memory tag of the value read + * @return Row + */ Row create_kernel_lookup_opcode(uint32_t dst_offset, uint32_t selector, FF value, AvmMemoryTag w_tag); + + /** + * @brief Create a kernel output opcode object + * + * Used for writing to the kernel app outputs - {new_note_hash, new_nullifier, etc.} + * + * @param clk - The trace clk + * @param data_offset - The memory address to read the output from + * @return Row + */ + Row create_kernel_output_opcode(uint32_t clk, uint32_t data_offset); + + /** + * @brief Create a kernel output opcode with metadata object + * + * Used for writing to the kernel app outputs with extra metadata - {sload, sstore} (value, slot) + * + * @param clk - The trace clk + * @param data_offset - The offset of the main value to output + * @param data_r_tag - The data type of the value + * @param metadata_offset - The offset of the metadata (slot in the sload example) + * @param metadata_r_tag - The data type of the metadata + * @return Row + */ + Row create_kernel_output_opcode_with_metadata(uint32_t clk, + uint32_t data_offset, + AvmMemoryTag data_r_tag, + uint32_t metadata_offset, + AvmMemoryTag metadata_r_tag); + + /** + * @brief Create a kernel output opcode with set metadata output object + * + * Used for writing output opcode where one value is written and comes from a hint + * {note_hash_exists, nullifier_exists, etc. } Where a boolean output if it exists must also be written + * + * @param clk - The trace clk + * @param data_offset - The offset of the main value to output + * @param data_r_tag - The data type of the value + * @param metadata_offset - The offset of the metadata (slot in the sload example) + * @param write_value - The value to be written into the result - in all instances this is used - it is a boolean + * @return Row + */ + Row create_kernel_output_opcode_with_set_metadata_output( + uint32_t clk, uint32_t data_offset, AvmMemoryTag data_r_tag, uint32_t metadata_offset, FF write_value); + void finalise_mem_trace_lookup_counts(); IndirectThreeResolution resolve_ind_three( diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp index 980fcfd48e6..577f0d4482a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/aztec_constants.hpp @@ -2,6 +2,15 @@ #pragma once #include +const size_t MAX_NEW_NOTE_HASHES_PER_CALL = 16; +const size_t MAX_NEW_NULLIFIERS_PER_CALL = 16; +const size_t MAX_NEW_L2_TO_L1_MSGS_PER_CALL = 2; +const size_t MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 16; +const size_t MAX_PUBLIC_DATA_READS_PER_CALL = 16; +const size_t MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32; +const size_t MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32; +const size_t MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL = 32; +const size_t MAX_UNENCRYPTED_LOGS_PER_CALL = 4; const size_t GAS_FEES_LENGTH = 2; const size_t GAS_LENGTH = 2; const size_t CALL_CONTEXT_LENGTH = 6; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp index 6b0acc1c3df..898559a8a32 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/constants.hpp @@ -5,4 +5,9 @@ // NOTE(MD): for now we will only include the public inputs that are included in call_context // With more being added in subsequent prs // KERNEL_INPUTS_LENGTH = CALL_CONTEXT_LENGTH + -inline const std::size_t KERNEL_INPUTS_LENGTH = PUBLIC_CONTEXT_INPUTS_LENGTH; \ No newline at end of file +inline const std::size_t KERNEL_INPUTS_LENGTH = PUBLIC_CONTEXT_INPUTS_LENGTH; + +inline const std::size_t KERNEL_OUTPUTS_LENGTH = + MAX_NOTE_HASH_READ_REQUESTS_PER_CALL + MAX_NEW_NOTE_HASHES_PER_CALL + MAX_NULLIFIER_READ_REQUESTS_PER_CALL + + MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + + MAX_UNENCRYPTED_LOGS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp index a4d32752548..9853ca55d0c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_circuit_builder.hpp @@ -19,10 +19,12 @@ #include "barretenberg/relations/generated/avm/avm_alu.hpp" #include "barretenberg/relations/generated/avm/avm_binary.hpp" #include "barretenberg/relations/generated/avm/avm_conversion.hpp" +#include "barretenberg/relations/generated/avm/avm_kernel.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" #include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" #include "barretenberg/relations/generated/avm/incl_mem_tag_err.hpp" +#include "barretenberg/relations/generated/avm/kernel_output_lookup.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_lengths.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" #include "barretenberg/relations/generated/avm/lookup_div_u16_0.hpp" @@ -182,9 +184,24 @@ template struct AvmFullRow { FF avm_conversion_num_limbs{}; FF avm_conversion_radix{}; FF avm_conversion_to_radix_le_sel{}; + FF avm_kernel_emit_l2_to_l1_msg_write_offset{}; + FF avm_kernel_emit_note_hash_write_offset{}; + FF avm_kernel_emit_nullifier_write_offset{}; + FF avm_kernel_emit_unencrypted_log_write_offset{}; + FF avm_kernel_kernel_in_offset{}; FF avm_kernel_kernel_inputs__is_public{}; - FF avm_kernel_kernel_sel{}; + FF avm_kernel_kernel_metadata_out__is_public{}; + FF avm_kernel_kernel_out_offset{}; + FF avm_kernel_kernel_side_effect_out__is_public{}; + FF avm_kernel_kernel_value_out__is_public{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset{}; + FF avm_kernel_note_hash_exist_write_offset{}; + FF avm_kernel_nullifier_exists_write_offset{}; FF avm_kernel_q_public_input_kernel_add_to_table{}; + FF avm_kernel_q_public_input_kernel_out_add_to_table{}; + FF avm_kernel_side_effect_counter{}; + FF avm_kernel_sload_write_offset{}; + FF avm_kernel_sstore_write_offset{}; FF avm_main_alu_in_tag{}; FF avm_main_alu_sel{}; FF avm_main_bin_op_id{}; @@ -217,6 +234,7 @@ template struct AvmFullRow { FF avm_main_op_err{}; FF avm_main_pc{}; FF avm_main_q_kernel_lookup{}; + FF avm_main_q_kernel_output_lookup{}; FF avm_main_r_in_tag{}; FF avm_main_rwa{}; FF avm_main_rwb{}; @@ -238,20 +256,29 @@ template struct AvmFullRow { FF avm_main_sel_op_chain_id{}; FF avm_main_sel_op_coinbase{}; FF avm_main_sel_op_div{}; + FF avm_main_sel_op_emit_l2_to_l1_msg{}; + FF avm_main_sel_op_emit_note_hash{}; + FF avm_main_sel_op_emit_nullifier{}; + FF avm_main_sel_op_emit_unencrypted_log{}; FF avm_main_sel_op_eq{}; FF avm_main_sel_op_fdiv{}; FF avm_main_sel_op_fee_per_da_gas{}; FF avm_main_sel_op_fee_per_l2_gas{}; + FF avm_main_sel_op_l1_to_l2_msg_exists{}; FF avm_main_sel_op_lt{}; FF avm_main_sel_op_lte{}; FF avm_main_sel_op_mul{}; FF avm_main_sel_op_not{}; + FF avm_main_sel_op_note_hash_exists{}; + FF avm_main_sel_op_nullifier_exists{}; FF avm_main_sel_op_or{}; FF avm_main_sel_op_portal{}; FF avm_main_sel_op_radix_le{}; FF avm_main_sel_op_sender{}; FF avm_main_sel_op_shl{}; FF avm_main_sel_op_shr{}; + FF avm_main_sel_op_sload{}; + FF avm_main_sel_op_sstore{}; FF avm_main_sel_op_sub{}; FF avm_main_sel_op_timestamp{}; FF avm_main_sel_op_transaction_fee{}; @@ -307,6 +334,7 @@ template struct AvmFullRow { FF perm_main_mem_ind_d{}; FF lookup_byte_lengths{}; FF lookup_byte_operations{}; + FF kernel_output_lookup{}; FF lookup_into_kernel{}; FF incl_main_tag_err{}; FF incl_mem_tag_err{}; @@ -342,6 +370,7 @@ template struct AvmFullRow { FF lookup_div_u16_7{}; FF lookup_byte_lengths_counts{}; FF lookup_byte_operations_counts{}; + FF kernel_output_lookup_counts{}; FF lookup_into_kernel_counts{}; FF incl_main_tag_err_counts{}; FF incl_mem_tag_err_counts{}; @@ -419,6 +448,16 @@ template struct AvmFullRow { FF avm_binary_acc_ic_shift{}; FF avm_binary_mem_tag_ctr_shift{}; FF avm_binary_op_id_shift{}; + FF avm_kernel_emit_l2_to_l1_msg_write_offset_shift{}; + FF avm_kernel_emit_note_hash_write_offset_shift{}; + FF avm_kernel_emit_nullifier_write_offset_shift{}; + FF avm_kernel_emit_unencrypted_log_write_offset_shift{}; + FF avm_kernel_l1_to_l2_msg_exists_write_offset_shift{}; + FF avm_kernel_note_hash_exist_write_offset_shift{}; + FF avm_kernel_nullifier_exists_write_offset_shift{}; + FF avm_kernel_side_effect_counter_shift{}; + FF avm_kernel_sload_write_offset_shift{}; + FF avm_kernel_sstore_write_offset_shift{}; FF avm_main_internal_return_ptr_shift{}; FF avm_main_pc_shift{}; FF avm_mem_glob_addr_shift{}; @@ -439,8 +478,8 @@ class AvmCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 355; - static constexpr size_t num_polys = 303; + static constexpr size_t num_fixed_columns = 392; + static constexpr size_t num_polys = 330; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -566,10 +605,28 @@ class AvmCircuitBuilder { polys.avm_conversion_num_limbs[i] = rows[i].avm_conversion_num_limbs; polys.avm_conversion_radix[i] = rows[i].avm_conversion_radix; polys.avm_conversion_to_radix_le_sel[i] = rows[i].avm_conversion_to_radix_le_sel; + polys.avm_kernel_emit_l2_to_l1_msg_write_offset[i] = rows[i].avm_kernel_emit_l2_to_l1_msg_write_offset; + polys.avm_kernel_emit_note_hash_write_offset[i] = rows[i].avm_kernel_emit_note_hash_write_offset; + polys.avm_kernel_emit_nullifier_write_offset[i] = rows[i].avm_kernel_emit_nullifier_write_offset; + polys.avm_kernel_emit_unencrypted_log_write_offset[i] = + rows[i].avm_kernel_emit_unencrypted_log_write_offset; + polys.avm_kernel_kernel_in_offset[i] = rows[i].avm_kernel_kernel_in_offset; polys.avm_kernel_kernel_inputs__is_public[i] = rows[i].avm_kernel_kernel_inputs__is_public; - polys.avm_kernel_kernel_sel[i] = rows[i].avm_kernel_kernel_sel; + polys.avm_kernel_kernel_metadata_out__is_public[i] = rows[i].avm_kernel_kernel_metadata_out__is_public; + polys.avm_kernel_kernel_out_offset[i] = rows[i].avm_kernel_kernel_out_offset; + polys.avm_kernel_kernel_side_effect_out__is_public[i] = + rows[i].avm_kernel_kernel_side_effect_out__is_public; + polys.avm_kernel_kernel_value_out__is_public[i] = rows[i].avm_kernel_kernel_value_out__is_public; + polys.avm_kernel_l1_to_l2_msg_exists_write_offset[i] = rows[i].avm_kernel_l1_to_l2_msg_exists_write_offset; + polys.avm_kernel_note_hash_exist_write_offset[i] = rows[i].avm_kernel_note_hash_exist_write_offset; + polys.avm_kernel_nullifier_exists_write_offset[i] = rows[i].avm_kernel_nullifier_exists_write_offset; polys.avm_kernel_q_public_input_kernel_add_to_table[i] = rows[i].avm_kernel_q_public_input_kernel_add_to_table; + polys.avm_kernel_q_public_input_kernel_out_add_to_table[i] = + rows[i].avm_kernel_q_public_input_kernel_out_add_to_table; + polys.avm_kernel_side_effect_counter[i] = rows[i].avm_kernel_side_effect_counter; + polys.avm_kernel_sload_write_offset[i] = rows[i].avm_kernel_sload_write_offset; + polys.avm_kernel_sstore_write_offset[i] = rows[i].avm_kernel_sstore_write_offset; polys.avm_main_alu_in_tag[i] = rows[i].avm_main_alu_in_tag; polys.avm_main_alu_sel[i] = rows[i].avm_main_alu_sel; polys.avm_main_bin_op_id[i] = rows[i].avm_main_bin_op_id; @@ -602,6 +659,7 @@ class AvmCircuitBuilder { polys.avm_main_op_err[i] = rows[i].avm_main_op_err; polys.avm_main_pc[i] = rows[i].avm_main_pc; polys.avm_main_q_kernel_lookup[i] = rows[i].avm_main_q_kernel_lookup; + polys.avm_main_q_kernel_output_lookup[i] = rows[i].avm_main_q_kernel_output_lookup; polys.avm_main_r_in_tag[i] = rows[i].avm_main_r_in_tag; polys.avm_main_rwa[i] = rows[i].avm_main_rwa; polys.avm_main_rwb[i] = rows[i].avm_main_rwb; @@ -623,20 +681,29 @@ class AvmCircuitBuilder { polys.avm_main_sel_op_chain_id[i] = rows[i].avm_main_sel_op_chain_id; polys.avm_main_sel_op_coinbase[i] = rows[i].avm_main_sel_op_coinbase; polys.avm_main_sel_op_div[i] = rows[i].avm_main_sel_op_div; + polys.avm_main_sel_op_emit_l2_to_l1_msg[i] = rows[i].avm_main_sel_op_emit_l2_to_l1_msg; + polys.avm_main_sel_op_emit_note_hash[i] = rows[i].avm_main_sel_op_emit_note_hash; + polys.avm_main_sel_op_emit_nullifier[i] = rows[i].avm_main_sel_op_emit_nullifier; + polys.avm_main_sel_op_emit_unencrypted_log[i] = rows[i].avm_main_sel_op_emit_unencrypted_log; polys.avm_main_sel_op_eq[i] = rows[i].avm_main_sel_op_eq; polys.avm_main_sel_op_fdiv[i] = rows[i].avm_main_sel_op_fdiv; polys.avm_main_sel_op_fee_per_da_gas[i] = rows[i].avm_main_sel_op_fee_per_da_gas; polys.avm_main_sel_op_fee_per_l2_gas[i] = rows[i].avm_main_sel_op_fee_per_l2_gas; + polys.avm_main_sel_op_l1_to_l2_msg_exists[i] = rows[i].avm_main_sel_op_l1_to_l2_msg_exists; polys.avm_main_sel_op_lt[i] = rows[i].avm_main_sel_op_lt; polys.avm_main_sel_op_lte[i] = rows[i].avm_main_sel_op_lte; polys.avm_main_sel_op_mul[i] = rows[i].avm_main_sel_op_mul; polys.avm_main_sel_op_not[i] = rows[i].avm_main_sel_op_not; + polys.avm_main_sel_op_note_hash_exists[i] = rows[i].avm_main_sel_op_note_hash_exists; + polys.avm_main_sel_op_nullifier_exists[i] = rows[i].avm_main_sel_op_nullifier_exists; polys.avm_main_sel_op_or[i] = rows[i].avm_main_sel_op_or; polys.avm_main_sel_op_portal[i] = rows[i].avm_main_sel_op_portal; polys.avm_main_sel_op_radix_le[i] = rows[i].avm_main_sel_op_radix_le; polys.avm_main_sel_op_sender[i] = rows[i].avm_main_sel_op_sender; polys.avm_main_sel_op_shl[i] = rows[i].avm_main_sel_op_shl; polys.avm_main_sel_op_shr[i] = rows[i].avm_main_sel_op_shr; + polys.avm_main_sel_op_sload[i] = rows[i].avm_main_sel_op_sload; + polys.avm_main_sel_op_sstore[i] = rows[i].avm_main_sel_op_sstore; polys.avm_main_sel_op_sub[i] = rows[i].avm_main_sel_op_sub; polys.avm_main_sel_op_timestamp[i] = rows[i].avm_main_sel_op_timestamp; polys.avm_main_sel_op_transaction_fee[i] = rows[i].avm_main_sel_op_transaction_fee; @@ -681,6 +748,7 @@ class AvmCircuitBuilder { polys.avm_mem_w_in_tag[i] = rows[i].avm_mem_w_in_tag; polys.lookup_byte_lengths_counts[i] = rows[i].lookup_byte_lengths_counts; polys.lookup_byte_operations_counts[i] = rows[i].lookup_byte_operations_counts; + polys.kernel_output_lookup_counts[i] = rows[i].kernel_output_lookup_counts; polys.lookup_into_kernel_counts[i] = rows[i].lookup_into_kernel_counts; polys.incl_main_tag_err_counts[i] = rows[i].incl_main_tag_err_counts; polys.incl_mem_tag_err_counts[i] = rows[i].incl_mem_tag_err_counts; @@ -760,6 +828,23 @@ class AvmCircuitBuilder { polys.avm_binary_acc_ic_shift = Polynomial(polys.avm_binary_acc_ic.shifted()); polys.avm_binary_mem_tag_ctr_shift = Polynomial(polys.avm_binary_mem_tag_ctr.shifted()); polys.avm_binary_op_id_shift = Polynomial(polys.avm_binary_op_id.shifted()); + polys.avm_kernel_emit_l2_to_l1_msg_write_offset_shift = + Polynomial(polys.avm_kernel_emit_l2_to_l1_msg_write_offset.shifted()); + polys.avm_kernel_emit_note_hash_write_offset_shift = + Polynomial(polys.avm_kernel_emit_note_hash_write_offset.shifted()); + polys.avm_kernel_emit_nullifier_write_offset_shift = + Polynomial(polys.avm_kernel_emit_nullifier_write_offset.shifted()); + polys.avm_kernel_emit_unencrypted_log_write_offset_shift = + Polynomial(polys.avm_kernel_emit_unencrypted_log_write_offset.shifted()); + polys.avm_kernel_l1_to_l2_msg_exists_write_offset_shift = + Polynomial(polys.avm_kernel_l1_to_l2_msg_exists_write_offset.shifted()); + polys.avm_kernel_note_hash_exist_write_offset_shift = + Polynomial(polys.avm_kernel_note_hash_exist_write_offset.shifted()); + polys.avm_kernel_nullifier_exists_write_offset_shift = + Polynomial(polys.avm_kernel_nullifier_exists_write_offset.shifted()); + polys.avm_kernel_side_effect_counter_shift = Polynomial(polys.avm_kernel_side_effect_counter.shifted()); + polys.avm_kernel_sload_write_offset_shift = Polynomial(polys.avm_kernel_sload_write_offset.shifted()); + polys.avm_kernel_sstore_write_offset_shift = Polynomial(polys.avm_kernel_sstore_write_offset.shifted()); polys.avm_main_internal_return_ptr_shift = Polynomial(polys.avm_main_internal_return_ptr.shifted()); polys.avm_main_pc_shift = Polynomial(polys.avm_main_pc.shifted()); polys.avm_mem_glob_addr_shift = Polynomial(polys.avm_mem_glob_addr.shifted()); @@ -854,6 +939,11 @@ class AvmCircuitBuilder { "avm_conversion", Avm_vm::get_relation_label_avm_conversion); }; + auto avm_kernel = [=]() { + return evaluate_relation.template operator()>("avm_kernel", + Avm_vm::get_relation_label_avm_kernel); + }; + auto avm_main = [=]() { return evaluate_relation.template operator()>("avm_main", Avm_vm::get_relation_label_avm_main); @@ -917,6 +1007,11 @@ class AvmCircuitBuilder { "LOOKUP_BYTE_OPERATIONS"); }; + auto kernel_output_lookup = [=]() { + return evaluate_logderivative.template operator()>( + "KERNEL_OUTPUT_LOOKUP"); + }; + auto lookup_into_kernel = [=]() { return evaluate_logderivative.template operator()>("LOOKUP_INTO_KERNEL"); }; @@ -1063,6 +1158,8 @@ class AvmCircuitBuilder { relation_futures.emplace_back(std::async(std::launch::async, avm_conversion)); + relation_futures.emplace_back(std::async(std::launch::async, avm_kernel)); + relation_futures.emplace_back(std::async(std::launch::async, avm_main)); relation_futures.emplace_back(std::async(std::launch::async, avm_mem)); @@ -1093,6 +1190,8 @@ class AvmCircuitBuilder { relation_futures.emplace_back(std::async(std::launch::async, lookup_byte_operations)); + relation_futures.emplace_back(std::async(std::launch::async, kernel_output_lookup)); + relation_futures.emplace_back(std::async(std::launch::async, lookup_into_kernel)); relation_futures.emplace_back(std::async(std::launch::async, incl_main_tag_err)); @@ -1174,6 +1273,8 @@ class AvmCircuitBuilder { avm_conversion(); + avm_kernel(); + avm_main(); avm_mem(); @@ -1204,6 +1305,8 @@ class AvmCircuitBuilder { lookup_byte_operations(); + kernel_output_lookup(); + lookup_into_kernel(); incl_main_tag_err(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp index 981021d4e3c..6f8c5344a36 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_flavor.hpp @@ -16,10 +16,12 @@ #include "barretenberg/relations/generated/avm/avm_alu.hpp" #include "barretenberg/relations/generated/avm/avm_binary.hpp" #include "barretenberg/relations/generated/avm/avm_conversion.hpp" +#include "barretenberg/relations/generated/avm/avm_kernel.hpp" #include "barretenberg/relations/generated/avm/avm_main.hpp" #include "barretenberg/relations/generated/avm/avm_mem.hpp" #include "barretenberg/relations/generated/avm/incl_main_tag_err.hpp" #include "barretenberg/relations/generated/avm/incl_mem_tag_err.hpp" +#include "barretenberg/relations/generated/avm/kernel_output_lookup.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_lengths.hpp" #include "barretenberg/relations/generated/avm/lookup_byte_operations.hpp" #include "barretenberg/relations/generated/avm/lookup_div_u16_0.hpp" @@ -85,11 +87,11 @@ class AvmFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 301; + static constexpr size_t NUM_WITNESS_ENTITIES = 328; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 355; + static constexpr size_t NUM_ALL_ENTITIES = 392; using GrandProductRelations = std::tuple, perm_main_bin_relation, @@ -104,6 +106,7 @@ class AvmFlavor { perm_main_mem_ind_d_relation, lookup_byte_lengths_relation, lookup_byte_operations_relation, + kernel_output_lookup_relation, lookup_into_kernel_relation, incl_main_tag_err_relation, incl_mem_tag_err_relation, @@ -141,6 +144,7 @@ class AvmFlavor { using Relations = std::tuple, Avm_vm::avm_binary, Avm_vm::avm_conversion, + Avm_vm::avm_kernel, Avm_vm::avm_main, Avm_vm::avm_mem, perm_main_alu_relation, @@ -156,6 +160,7 @@ class AvmFlavor { perm_main_mem_ind_d_relation, lookup_byte_lengths_relation, lookup_byte_operations_relation, + kernel_output_lookup_relation, lookup_into_kernel_relation, incl_main_tag_err_relation, incl_mem_tag_err_relation, @@ -330,9 +335,24 @@ class AvmFlavor { avm_conversion_num_limbs, avm_conversion_radix, avm_conversion_to_radix_le_sel, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_kernel_in_offset, avm_kernel_kernel_inputs__is_public, - avm_kernel_kernel_sel, + avm_kernel_kernel_metadata_out__is_public, + avm_kernel_kernel_out_offset, + avm_kernel_kernel_side_effect_out__is_public, + avm_kernel_kernel_value_out__is_public, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, avm_kernel_q_public_input_kernel_add_to_table, + avm_kernel_q_public_input_kernel_out_add_to_table, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_alu_in_tag, avm_main_alu_sel, avm_main_bin_op_id, @@ -365,6 +385,7 @@ class AvmFlavor { avm_main_op_err, avm_main_pc, avm_main_q_kernel_lookup, + avm_main_q_kernel_output_lookup, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, @@ -386,20 +407,29 @@ class AvmFlavor { avm_main_sel_op_chain_id, avm_main_sel_op_coinbase, avm_main_sel_op_div, + avm_main_sel_op_emit_l2_to_l1_msg, + avm_main_sel_op_emit_note_hash, + avm_main_sel_op_emit_nullifier, + avm_main_sel_op_emit_unencrypted_log, avm_main_sel_op_eq, avm_main_sel_op_fdiv, avm_main_sel_op_fee_per_da_gas, avm_main_sel_op_fee_per_l2_gas, + avm_main_sel_op_l1_to_l2_msg_exists, avm_main_sel_op_lt, avm_main_sel_op_lte, avm_main_sel_op_mul, avm_main_sel_op_not, + avm_main_sel_op_note_hash_exists, + avm_main_sel_op_nullifier_exists, avm_main_sel_op_or, avm_main_sel_op_portal, avm_main_sel_op_radix_le, avm_main_sel_op_sender, avm_main_sel_op_shl, avm_main_sel_op_shr, + avm_main_sel_op_sload, + avm_main_sel_op_sstore, avm_main_sel_op_sub, avm_main_sel_op_timestamp, avm_main_sel_op_transaction_fee, @@ -455,6 +485,7 @@ class AvmFlavor { perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, + kernel_output_lookup, lookup_into_kernel, incl_main_tag_err, incl_mem_tag_err, @@ -490,6 +521,7 @@ class AvmFlavor { lookup_div_u16_7, lookup_byte_lengths_counts, lookup_byte_operations_counts, + kernel_output_lookup_counts, lookup_into_kernel_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, @@ -634,9 +666,24 @@ class AvmFlavor { avm_conversion_num_limbs, avm_conversion_radix, avm_conversion_to_radix_le_sel, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_kernel_in_offset, avm_kernel_kernel_inputs__is_public, - avm_kernel_kernel_sel, + avm_kernel_kernel_metadata_out__is_public, + avm_kernel_kernel_out_offset, + avm_kernel_kernel_side_effect_out__is_public, + avm_kernel_kernel_value_out__is_public, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, avm_kernel_q_public_input_kernel_add_to_table, + avm_kernel_q_public_input_kernel_out_add_to_table, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_alu_in_tag, avm_main_alu_sel, avm_main_bin_op_id, @@ -669,6 +716,7 @@ class AvmFlavor { avm_main_op_err, avm_main_pc, avm_main_q_kernel_lookup, + avm_main_q_kernel_output_lookup, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, @@ -690,20 +738,29 @@ class AvmFlavor { avm_main_sel_op_chain_id, avm_main_sel_op_coinbase, avm_main_sel_op_div, + avm_main_sel_op_emit_l2_to_l1_msg, + avm_main_sel_op_emit_note_hash, + avm_main_sel_op_emit_nullifier, + avm_main_sel_op_emit_unencrypted_log, avm_main_sel_op_eq, avm_main_sel_op_fdiv, avm_main_sel_op_fee_per_da_gas, avm_main_sel_op_fee_per_l2_gas, + avm_main_sel_op_l1_to_l2_msg_exists, avm_main_sel_op_lt, avm_main_sel_op_lte, avm_main_sel_op_mul, avm_main_sel_op_not, + avm_main_sel_op_note_hash_exists, + avm_main_sel_op_nullifier_exists, avm_main_sel_op_or, avm_main_sel_op_portal, avm_main_sel_op_radix_le, avm_main_sel_op_sender, avm_main_sel_op_shl, avm_main_sel_op_shr, + avm_main_sel_op_sload, + avm_main_sel_op_sstore, avm_main_sel_op_sub, avm_main_sel_op_timestamp, avm_main_sel_op_transaction_fee, @@ -759,6 +816,7 @@ class AvmFlavor { perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, + kernel_output_lookup, lookup_into_kernel, incl_main_tag_err, incl_mem_tag_err, @@ -794,6 +852,7 @@ class AvmFlavor { lookup_div_u16_7, lookup_byte_lengths_counts, lookup_byte_operations_counts, + kernel_output_lookup_counts, lookup_into_kernel_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, @@ -943,9 +1002,24 @@ class AvmFlavor { avm_conversion_num_limbs, avm_conversion_radix, avm_conversion_to_radix_le_sel, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_kernel_in_offset, avm_kernel_kernel_inputs__is_public, - avm_kernel_kernel_sel, + avm_kernel_kernel_metadata_out__is_public, + avm_kernel_kernel_out_offset, + avm_kernel_kernel_side_effect_out__is_public, + avm_kernel_kernel_value_out__is_public, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, avm_kernel_q_public_input_kernel_add_to_table, + avm_kernel_q_public_input_kernel_out_add_to_table, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_alu_in_tag, avm_main_alu_sel, avm_main_bin_op_id, @@ -978,6 +1052,7 @@ class AvmFlavor { avm_main_op_err, avm_main_pc, avm_main_q_kernel_lookup, + avm_main_q_kernel_output_lookup, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, @@ -999,20 +1074,29 @@ class AvmFlavor { avm_main_sel_op_chain_id, avm_main_sel_op_coinbase, avm_main_sel_op_div, + avm_main_sel_op_emit_l2_to_l1_msg, + avm_main_sel_op_emit_note_hash, + avm_main_sel_op_emit_nullifier, + avm_main_sel_op_emit_unencrypted_log, avm_main_sel_op_eq, avm_main_sel_op_fdiv, avm_main_sel_op_fee_per_da_gas, avm_main_sel_op_fee_per_l2_gas, + avm_main_sel_op_l1_to_l2_msg_exists, avm_main_sel_op_lt, avm_main_sel_op_lte, avm_main_sel_op_mul, avm_main_sel_op_not, + avm_main_sel_op_note_hash_exists, + avm_main_sel_op_nullifier_exists, avm_main_sel_op_or, avm_main_sel_op_portal, avm_main_sel_op_radix_le, avm_main_sel_op_sender, avm_main_sel_op_shl, avm_main_sel_op_shr, + avm_main_sel_op_sload, + avm_main_sel_op_sstore, avm_main_sel_op_sub, avm_main_sel_op_timestamp, avm_main_sel_op_transaction_fee, @@ -1068,6 +1152,7 @@ class AvmFlavor { perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, + kernel_output_lookup, lookup_into_kernel, incl_main_tag_err, incl_mem_tag_err, @@ -1103,6 +1188,7 @@ class AvmFlavor { lookup_div_u16_7, lookup_byte_lengths_counts, lookup_byte_operations_counts, + kernel_output_lookup_counts, lookup_into_kernel_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, @@ -1180,6 +1266,16 @@ class AvmFlavor { avm_binary_acc_ic_shift, avm_binary_mem_tag_ctr_shift, avm_binary_op_id_shift, + avm_kernel_emit_l2_to_l1_msg_write_offset_shift, + avm_kernel_emit_note_hash_write_offset_shift, + avm_kernel_emit_nullifier_write_offset_shift, + avm_kernel_emit_unencrypted_log_write_offset_shift, + avm_kernel_l1_to_l2_msg_exists_write_offset_shift, + avm_kernel_note_hash_exist_write_offset_shift, + avm_kernel_nullifier_exists_write_offset_shift, + avm_kernel_side_effect_counter_shift, + avm_kernel_sload_write_offset_shift, + avm_kernel_sstore_write_offset_shift, avm_main_internal_return_ptr_shift, avm_main_pc_shift, avm_mem_glob_addr_shift, @@ -1301,9 +1397,24 @@ class AvmFlavor { avm_conversion_num_limbs, avm_conversion_radix, avm_conversion_to_radix_le_sel, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_kernel_in_offset, avm_kernel_kernel_inputs__is_public, - avm_kernel_kernel_sel, + avm_kernel_kernel_metadata_out__is_public, + avm_kernel_kernel_out_offset, + avm_kernel_kernel_side_effect_out__is_public, + avm_kernel_kernel_value_out__is_public, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, avm_kernel_q_public_input_kernel_add_to_table, + avm_kernel_q_public_input_kernel_out_add_to_table, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_alu_in_tag, avm_main_alu_sel, avm_main_bin_op_id, @@ -1336,6 +1447,7 @@ class AvmFlavor { avm_main_op_err, avm_main_pc, avm_main_q_kernel_lookup, + avm_main_q_kernel_output_lookup, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, @@ -1357,20 +1469,29 @@ class AvmFlavor { avm_main_sel_op_chain_id, avm_main_sel_op_coinbase, avm_main_sel_op_div, + avm_main_sel_op_emit_l2_to_l1_msg, + avm_main_sel_op_emit_note_hash, + avm_main_sel_op_emit_nullifier, + avm_main_sel_op_emit_unencrypted_log, avm_main_sel_op_eq, avm_main_sel_op_fdiv, avm_main_sel_op_fee_per_da_gas, avm_main_sel_op_fee_per_l2_gas, + avm_main_sel_op_l1_to_l2_msg_exists, avm_main_sel_op_lt, avm_main_sel_op_lte, avm_main_sel_op_mul, avm_main_sel_op_not, + avm_main_sel_op_note_hash_exists, + avm_main_sel_op_nullifier_exists, avm_main_sel_op_or, avm_main_sel_op_portal, avm_main_sel_op_radix_le, avm_main_sel_op_sender, avm_main_sel_op_shl, avm_main_sel_op_shr, + avm_main_sel_op_sload, + avm_main_sel_op_sstore, avm_main_sel_op_sub, avm_main_sel_op_timestamp, avm_main_sel_op_transaction_fee, @@ -1426,6 +1547,7 @@ class AvmFlavor { perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, + kernel_output_lookup, lookup_into_kernel, incl_main_tag_err, incl_mem_tag_err, @@ -1461,6 +1583,7 @@ class AvmFlavor { lookup_div_u16_7, lookup_byte_lengths_counts, lookup_byte_operations_counts, + kernel_output_lookup_counts, lookup_into_kernel_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, @@ -1538,6 +1661,16 @@ class AvmFlavor { avm_binary_acc_ic_shift, avm_binary_mem_tag_ctr_shift, avm_binary_op_id_shift, + avm_kernel_emit_l2_to_l1_msg_write_offset_shift, + avm_kernel_emit_note_hash_write_offset_shift, + avm_kernel_emit_nullifier_write_offset_shift, + avm_kernel_emit_unencrypted_log_write_offset_shift, + avm_kernel_l1_to_l2_msg_exists_write_offset_shift, + avm_kernel_note_hash_exist_write_offset_shift, + avm_kernel_nullifier_exists_write_offset_shift, + avm_kernel_side_effect_counter_shift, + avm_kernel_sload_write_offset_shift, + avm_kernel_sstore_write_offset_shift, avm_main_internal_return_ptr_shift, avm_main_pc_shift, avm_mem_glob_addr_shift, @@ -1659,9 +1792,24 @@ class AvmFlavor { avm_conversion_num_limbs, avm_conversion_radix, avm_conversion_to_radix_le_sel, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_kernel_in_offset, avm_kernel_kernel_inputs__is_public, - avm_kernel_kernel_sel, + avm_kernel_kernel_metadata_out__is_public, + avm_kernel_kernel_out_offset, + avm_kernel_kernel_side_effect_out__is_public, + avm_kernel_kernel_value_out__is_public, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, avm_kernel_q_public_input_kernel_add_to_table, + avm_kernel_q_public_input_kernel_out_add_to_table, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_alu_in_tag, avm_main_alu_sel, avm_main_bin_op_id, @@ -1694,6 +1842,7 @@ class AvmFlavor { avm_main_op_err, avm_main_pc, avm_main_q_kernel_lookup, + avm_main_q_kernel_output_lookup, avm_main_r_in_tag, avm_main_rwa, avm_main_rwb, @@ -1715,20 +1864,29 @@ class AvmFlavor { avm_main_sel_op_chain_id, avm_main_sel_op_coinbase, avm_main_sel_op_div, + avm_main_sel_op_emit_l2_to_l1_msg, + avm_main_sel_op_emit_note_hash, + avm_main_sel_op_emit_nullifier, + avm_main_sel_op_emit_unencrypted_log, avm_main_sel_op_eq, avm_main_sel_op_fdiv, avm_main_sel_op_fee_per_da_gas, avm_main_sel_op_fee_per_l2_gas, + avm_main_sel_op_l1_to_l2_msg_exists, avm_main_sel_op_lt, avm_main_sel_op_lte, avm_main_sel_op_mul, avm_main_sel_op_not, + avm_main_sel_op_note_hash_exists, + avm_main_sel_op_nullifier_exists, avm_main_sel_op_or, avm_main_sel_op_portal, avm_main_sel_op_radix_le, avm_main_sel_op_sender, avm_main_sel_op_shl, avm_main_sel_op_shr, + avm_main_sel_op_sload, + avm_main_sel_op_sstore, avm_main_sel_op_sub, avm_main_sel_op_timestamp, avm_main_sel_op_transaction_fee, @@ -1784,6 +1942,7 @@ class AvmFlavor { perm_main_mem_ind_d, lookup_byte_lengths, lookup_byte_operations, + kernel_output_lookup, lookup_into_kernel, incl_main_tag_err, incl_mem_tag_err, @@ -1819,6 +1978,7 @@ class AvmFlavor { lookup_div_u16_7, lookup_byte_lengths_counts, lookup_byte_operations_counts, + kernel_output_lookup_counts, lookup_into_kernel_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts, @@ -1899,6 +2059,16 @@ class AvmFlavor { avm_binary_acc_ic, avm_binary_mem_tag_ctr, avm_binary_op_id, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_internal_return_ptr, avm_main_pc, avm_mem_glob_addr, @@ -1954,6 +2124,16 @@ class AvmFlavor { avm_binary_acc_ic_shift, avm_binary_mem_tag_ctr_shift, avm_binary_op_id_shift, + avm_kernel_emit_l2_to_l1_msg_write_offset_shift, + avm_kernel_emit_note_hash_write_offset_shift, + avm_kernel_emit_nullifier_write_offset_shift, + avm_kernel_emit_unencrypted_log_write_offset_shift, + avm_kernel_l1_to_l2_msg_exists_write_offset_shift, + avm_kernel_note_hash_exist_write_offset_shift, + avm_kernel_nullifier_exists_write_offset_shift, + avm_kernel_side_effect_counter_shift, + avm_kernel_sload_write_offset_shift, + avm_kernel_sstore_write_offset_shift, avm_main_internal_return_ptr_shift, avm_main_pc_shift, avm_mem_glob_addr_shift, @@ -2019,6 +2199,16 @@ class AvmFlavor { avm_binary_acc_ic, avm_binary_mem_tag_ctr, avm_binary_op_id, + avm_kernel_emit_l2_to_l1_msg_write_offset, + avm_kernel_emit_note_hash_write_offset, + avm_kernel_emit_nullifier_write_offset, + avm_kernel_emit_unencrypted_log_write_offset, + avm_kernel_l1_to_l2_msg_exists_write_offset, + avm_kernel_note_hash_exist_write_offset, + avm_kernel_nullifier_exists_write_offset, + avm_kernel_side_effect_counter, + avm_kernel_sload_write_offset, + avm_kernel_sstore_write_offset, avm_main_internal_return_ptr, avm_main_pc, avm_mem_glob_addr, @@ -2059,6 +2249,8 @@ class AvmFlavor { prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); + bb::compute_logderivative_inverse>( + prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( prover_polynomials, relation_parameters, this->circuit_size); bb::compute_logderivative_inverse>( @@ -2335,9 +2527,25 @@ class AvmFlavor { Base::avm_conversion_num_limbs = "AVM_CONVERSION_NUM_LIMBS"; Base::avm_conversion_radix = "AVM_CONVERSION_RADIX"; Base::avm_conversion_to_radix_le_sel = "AVM_CONVERSION_TO_RADIX_LE_SEL"; + Base::avm_kernel_emit_l2_to_l1_msg_write_offset = "AVM_KERNEL_EMIT_L2_TO_L1_MSG_WRITE_OFFSET"; + Base::avm_kernel_emit_note_hash_write_offset = "AVM_KERNEL_EMIT_NOTE_HASH_WRITE_OFFSET"; + Base::avm_kernel_emit_nullifier_write_offset = "AVM_KERNEL_EMIT_NULLIFIER_WRITE_OFFSET"; + Base::avm_kernel_emit_unencrypted_log_write_offset = "AVM_KERNEL_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET"; + Base::avm_kernel_kernel_in_offset = "AVM_KERNEL_KERNEL_IN_OFFSET"; Base::avm_kernel_kernel_inputs__is_public = "AVM_KERNEL_KERNEL_INPUTS__IS_PUBLIC"; - Base::avm_kernel_kernel_sel = "AVM_KERNEL_KERNEL_SEL"; + Base::avm_kernel_kernel_metadata_out__is_public = "AVM_KERNEL_KERNEL_METADATA_OUT__IS_PUBLIC"; + Base::avm_kernel_kernel_out_offset = "AVM_KERNEL_KERNEL_OUT_OFFSET"; + Base::avm_kernel_kernel_side_effect_out__is_public = "AVM_KERNEL_KERNEL_SIDE_EFFECT_OUT__IS_PUBLIC"; + Base::avm_kernel_kernel_value_out__is_public = "AVM_KERNEL_KERNEL_VALUE_OUT__IS_PUBLIC"; + Base::avm_kernel_l1_to_l2_msg_exists_write_offset = "AVM_KERNEL_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET"; + Base::avm_kernel_note_hash_exist_write_offset = "AVM_KERNEL_NOTE_HASH_EXIST_WRITE_OFFSET"; + Base::avm_kernel_nullifier_exists_write_offset = "AVM_KERNEL_NULLIFIER_EXISTS_WRITE_OFFSET"; Base::avm_kernel_q_public_input_kernel_add_to_table = "AVM_KERNEL_Q_PUBLIC_INPUT_KERNEL_ADD_TO_TABLE"; + Base::avm_kernel_q_public_input_kernel_out_add_to_table = + "AVM_KERNEL_Q_PUBLIC_INPUT_KERNEL_OUT_ADD_TO_TABLE"; + Base::avm_kernel_side_effect_counter = "AVM_KERNEL_SIDE_EFFECT_COUNTER"; + Base::avm_kernel_sload_write_offset = "AVM_KERNEL_SLOAD_WRITE_OFFSET"; + Base::avm_kernel_sstore_write_offset = "AVM_KERNEL_SSTORE_WRITE_OFFSET"; Base::avm_main_alu_in_tag = "AVM_MAIN_ALU_IN_TAG"; Base::avm_main_alu_sel = "AVM_MAIN_ALU_SEL"; Base::avm_main_bin_op_id = "AVM_MAIN_BIN_OP_ID"; @@ -2370,6 +2578,7 @@ class AvmFlavor { Base::avm_main_op_err = "AVM_MAIN_OP_ERR"; Base::avm_main_pc = "AVM_MAIN_PC"; Base::avm_main_q_kernel_lookup = "AVM_MAIN_Q_KERNEL_LOOKUP"; + Base::avm_main_q_kernel_output_lookup = "AVM_MAIN_Q_KERNEL_OUTPUT_LOOKUP"; Base::avm_main_r_in_tag = "AVM_MAIN_R_IN_TAG"; Base::avm_main_rwa = "AVM_MAIN_RWA"; Base::avm_main_rwb = "AVM_MAIN_RWB"; @@ -2391,20 +2600,29 @@ class AvmFlavor { Base::avm_main_sel_op_chain_id = "AVM_MAIN_SEL_OP_CHAIN_ID"; Base::avm_main_sel_op_coinbase = "AVM_MAIN_SEL_OP_COINBASE"; Base::avm_main_sel_op_div = "AVM_MAIN_SEL_OP_DIV"; + Base::avm_main_sel_op_emit_l2_to_l1_msg = "AVM_MAIN_SEL_OP_EMIT_L2_TO_L1_MSG"; + Base::avm_main_sel_op_emit_note_hash = "AVM_MAIN_SEL_OP_EMIT_NOTE_HASH"; + Base::avm_main_sel_op_emit_nullifier = "AVM_MAIN_SEL_OP_EMIT_NULLIFIER"; + Base::avm_main_sel_op_emit_unencrypted_log = "AVM_MAIN_SEL_OP_EMIT_UNENCRYPTED_LOG"; Base::avm_main_sel_op_eq = "AVM_MAIN_SEL_OP_EQ"; Base::avm_main_sel_op_fdiv = "AVM_MAIN_SEL_OP_FDIV"; Base::avm_main_sel_op_fee_per_da_gas = "AVM_MAIN_SEL_OP_FEE_PER_DA_GAS"; Base::avm_main_sel_op_fee_per_l2_gas = "AVM_MAIN_SEL_OP_FEE_PER_L2_GAS"; + Base::avm_main_sel_op_l1_to_l2_msg_exists = "AVM_MAIN_SEL_OP_L1_TO_L2_MSG_EXISTS"; Base::avm_main_sel_op_lt = "AVM_MAIN_SEL_OP_LT"; Base::avm_main_sel_op_lte = "AVM_MAIN_SEL_OP_LTE"; Base::avm_main_sel_op_mul = "AVM_MAIN_SEL_OP_MUL"; Base::avm_main_sel_op_not = "AVM_MAIN_SEL_OP_NOT"; + Base::avm_main_sel_op_note_hash_exists = "AVM_MAIN_SEL_OP_NOTE_HASH_EXISTS"; + Base::avm_main_sel_op_nullifier_exists = "AVM_MAIN_SEL_OP_NULLIFIER_EXISTS"; Base::avm_main_sel_op_or = "AVM_MAIN_SEL_OP_OR"; Base::avm_main_sel_op_portal = "AVM_MAIN_SEL_OP_PORTAL"; Base::avm_main_sel_op_radix_le = "AVM_MAIN_SEL_OP_RADIX_LE"; Base::avm_main_sel_op_sender = "AVM_MAIN_SEL_OP_SENDER"; Base::avm_main_sel_op_shl = "AVM_MAIN_SEL_OP_SHL"; Base::avm_main_sel_op_shr = "AVM_MAIN_SEL_OP_SHR"; + Base::avm_main_sel_op_sload = "AVM_MAIN_SEL_OP_SLOAD"; + Base::avm_main_sel_op_sstore = "AVM_MAIN_SEL_OP_SSTORE"; Base::avm_main_sel_op_sub = "AVM_MAIN_SEL_OP_SUB"; Base::avm_main_sel_op_timestamp = "AVM_MAIN_SEL_OP_TIMESTAMP"; Base::avm_main_sel_op_transaction_fee = "AVM_MAIN_SEL_OP_TRANSACTION_FEE"; @@ -2460,6 +2678,7 @@ class AvmFlavor { Base::perm_main_mem_ind_d = "PERM_MAIN_MEM_IND_D"; Base::lookup_byte_lengths = "LOOKUP_BYTE_LENGTHS"; Base::lookup_byte_operations = "LOOKUP_BYTE_OPERATIONS"; + Base::kernel_output_lookup = "KERNEL_OUTPUT_LOOKUP"; Base::lookup_into_kernel = "LOOKUP_INTO_KERNEL"; Base::incl_main_tag_err = "INCL_MAIN_TAG_ERR"; Base::incl_mem_tag_err = "INCL_MEM_TAG_ERR"; @@ -2495,6 +2714,7 @@ class AvmFlavor { Base::lookup_div_u16_7 = "LOOKUP_DIV_U16_7"; Base::lookup_byte_lengths_counts = "LOOKUP_BYTE_LENGTHS_COUNTS"; Base::lookup_byte_operations_counts = "LOOKUP_BYTE_OPERATIONS_COUNTS"; + Base::kernel_output_lookup_counts = "KERNEL_OUTPUT_LOOKUP_COUNTS"; Base::lookup_into_kernel_counts = "LOOKUP_INTO_KERNEL_COUNTS"; Base::incl_main_tag_err_counts = "INCL_MAIN_TAG_ERR_COUNTS"; Base::incl_mem_tag_err_counts = "INCL_MEM_TAG_ERR_COUNTS"; @@ -2655,9 +2875,24 @@ class AvmFlavor { Commitment avm_conversion_num_limbs; Commitment avm_conversion_radix; Commitment avm_conversion_to_radix_le_sel; + Commitment avm_kernel_emit_l2_to_l1_msg_write_offset; + Commitment avm_kernel_emit_note_hash_write_offset; + Commitment avm_kernel_emit_nullifier_write_offset; + Commitment avm_kernel_emit_unencrypted_log_write_offset; + Commitment avm_kernel_kernel_in_offset; Commitment avm_kernel_kernel_inputs__is_public; - Commitment avm_kernel_kernel_sel; + Commitment avm_kernel_kernel_metadata_out__is_public; + Commitment avm_kernel_kernel_out_offset; + Commitment avm_kernel_kernel_side_effect_out__is_public; + Commitment avm_kernel_kernel_value_out__is_public; + Commitment avm_kernel_l1_to_l2_msg_exists_write_offset; + Commitment avm_kernel_note_hash_exist_write_offset; + Commitment avm_kernel_nullifier_exists_write_offset; Commitment avm_kernel_q_public_input_kernel_add_to_table; + Commitment avm_kernel_q_public_input_kernel_out_add_to_table; + Commitment avm_kernel_side_effect_counter; + Commitment avm_kernel_sload_write_offset; + Commitment avm_kernel_sstore_write_offset; Commitment avm_main_alu_in_tag; Commitment avm_main_alu_sel; Commitment avm_main_bin_op_id; @@ -2690,6 +2925,7 @@ class AvmFlavor { Commitment avm_main_op_err; Commitment avm_main_pc; Commitment avm_main_q_kernel_lookup; + Commitment avm_main_q_kernel_output_lookup; Commitment avm_main_r_in_tag; Commitment avm_main_rwa; Commitment avm_main_rwb; @@ -2711,20 +2947,29 @@ class AvmFlavor { Commitment avm_main_sel_op_chain_id; Commitment avm_main_sel_op_coinbase; Commitment avm_main_sel_op_div; + Commitment avm_main_sel_op_emit_l2_to_l1_msg; + Commitment avm_main_sel_op_emit_note_hash; + Commitment avm_main_sel_op_emit_nullifier; + Commitment avm_main_sel_op_emit_unencrypted_log; Commitment avm_main_sel_op_eq; Commitment avm_main_sel_op_fdiv; Commitment avm_main_sel_op_fee_per_da_gas; Commitment avm_main_sel_op_fee_per_l2_gas; + Commitment avm_main_sel_op_l1_to_l2_msg_exists; Commitment avm_main_sel_op_lt; Commitment avm_main_sel_op_lte; Commitment avm_main_sel_op_mul; Commitment avm_main_sel_op_not; + Commitment avm_main_sel_op_note_hash_exists; + Commitment avm_main_sel_op_nullifier_exists; Commitment avm_main_sel_op_or; Commitment avm_main_sel_op_portal; Commitment avm_main_sel_op_radix_le; Commitment avm_main_sel_op_sender; Commitment avm_main_sel_op_shl; Commitment avm_main_sel_op_shr; + Commitment avm_main_sel_op_sload; + Commitment avm_main_sel_op_sstore; Commitment avm_main_sel_op_sub; Commitment avm_main_sel_op_timestamp; Commitment avm_main_sel_op_transaction_fee; @@ -2780,6 +3025,7 @@ class AvmFlavor { Commitment perm_main_mem_ind_d; Commitment lookup_byte_lengths; Commitment lookup_byte_operations; + Commitment kernel_output_lookup; Commitment lookup_into_kernel; Commitment incl_main_tag_err; Commitment incl_mem_tag_err; @@ -2815,6 +3061,7 @@ class AvmFlavor { Commitment lookup_div_u16_7; Commitment lookup_byte_lengths_counts; Commitment lookup_byte_operations_counts; + Commitment kernel_output_lookup_counts; Commitment lookup_into_kernel_counts; Commitment incl_main_tag_err_counts; Commitment incl_mem_tag_err_counts; @@ -2976,11 +3223,37 @@ class AvmFlavor { avm_conversion_num_limbs = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_conversion_radix = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_conversion_to_radix_le_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_emit_l2_to_l1_msg_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_emit_note_hash_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_emit_nullifier_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_emit_unencrypted_log_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_kernel_in_offset = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_kernel_kernel_inputs__is_public = deserialize_from_buffer(Transcript::proof_data, num_frs_read); - avm_kernel_kernel_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_kernel_metadata_out__is_public = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_kernel_out_offset = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_kernel_side_effect_out__is_public = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_kernel_value_out__is_public = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_l1_to_l2_msg_exists_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_note_hash_exist_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_nullifier_exists_write_offset = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_kernel_q_public_input_kernel_add_to_table = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_q_public_input_kernel_out_add_to_table = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_side_effect_counter = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_sload_write_offset = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_kernel_sstore_write_offset = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_alu_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_alu_sel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_bin_op_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -3013,6 +3286,7 @@ class AvmFlavor { avm_main_op_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_pc = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_q_kernel_lookup = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_q_kernel_output_lookup = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_r_in_tag = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_rwa = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_rwb = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -3034,20 +3308,34 @@ class AvmFlavor { avm_main_sel_op_chain_id = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_coinbase = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_div = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_emit_l2_to_l1_msg = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_emit_note_hash = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_emit_nullifier = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_emit_unencrypted_log = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_eq = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_fdiv = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_fee_per_da_gas = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_fee_per_l2_gas = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_l1_to_l2_msg_exists = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_lt = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_lte = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_mul = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_not = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_note_hash_exists = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_nullifier_exists = + deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_or = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_portal = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_radix_le = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_sender = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_shl = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_shr = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_sload = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + avm_main_sel_op_sstore = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_sub = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_timestamp = deserialize_from_buffer(Transcript::proof_data, num_frs_read); avm_main_sel_op_transaction_fee = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -3103,6 +3391,7 @@ class AvmFlavor { perm_main_mem_ind_d = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_lengths = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_operations = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + kernel_output_lookup = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_into_kernel = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_main_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_mem_tag_err = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -3138,6 +3427,7 @@ class AvmFlavor { lookup_div_u16_7 = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_lengths_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_byte_operations_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); + kernel_output_lookup_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); lookup_into_kernel_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_main_tag_err_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); incl_mem_tag_err_counts = deserialize_from_buffer(Transcript::proof_data, num_frs_read); @@ -3302,9 +3592,24 @@ class AvmFlavor { serialize_to_buffer(avm_conversion_num_limbs, Transcript::proof_data); serialize_to_buffer(avm_conversion_radix, Transcript::proof_data); serialize_to_buffer(avm_conversion_to_radix_le_sel, Transcript::proof_data); + serialize_to_buffer(avm_kernel_emit_l2_to_l1_msg_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_emit_note_hash_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_emit_nullifier_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_emit_unencrypted_log_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_kernel_in_offset, Transcript::proof_data); serialize_to_buffer(avm_kernel_kernel_inputs__is_public, Transcript::proof_data); - serialize_to_buffer(avm_kernel_kernel_sel, Transcript::proof_data); + serialize_to_buffer(avm_kernel_kernel_metadata_out__is_public, Transcript::proof_data); + serialize_to_buffer(avm_kernel_kernel_out_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_kernel_side_effect_out__is_public, Transcript::proof_data); + serialize_to_buffer(avm_kernel_kernel_value_out__is_public, Transcript::proof_data); + serialize_to_buffer(avm_kernel_l1_to_l2_msg_exists_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_note_hash_exist_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_nullifier_exists_write_offset, Transcript::proof_data); serialize_to_buffer(avm_kernel_q_public_input_kernel_add_to_table, Transcript::proof_data); + serialize_to_buffer(avm_kernel_q_public_input_kernel_out_add_to_table, Transcript::proof_data); + serialize_to_buffer(avm_kernel_side_effect_counter, Transcript::proof_data); + serialize_to_buffer(avm_kernel_sload_write_offset, Transcript::proof_data); + serialize_to_buffer(avm_kernel_sstore_write_offset, Transcript::proof_data); serialize_to_buffer(avm_main_alu_in_tag, Transcript::proof_data); serialize_to_buffer(avm_main_alu_sel, Transcript::proof_data); serialize_to_buffer(avm_main_bin_op_id, Transcript::proof_data); @@ -3337,6 +3642,7 @@ class AvmFlavor { serialize_to_buffer(avm_main_op_err, Transcript::proof_data); serialize_to_buffer(avm_main_pc, Transcript::proof_data); serialize_to_buffer(avm_main_q_kernel_lookup, Transcript::proof_data); + serialize_to_buffer(avm_main_q_kernel_output_lookup, Transcript::proof_data); serialize_to_buffer(avm_main_r_in_tag, Transcript::proof_data); serialize_to_buffer(avm_main_rwa, Transcript::proof_data); serialize_to_buffer(avm_main_rwb, Transcript::proof_data); @@ -3358,20 +3664,29 @@ class AvmFlavor { serialize_to_buffer(avm_main_sel_op_chain_id, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_coinbase, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_div, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_emit_l2_to_l1_msg, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_emit_note_hash, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_emit_nullifier, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_emit_unencrypted_log, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_eq, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_fdiv, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_fee_per_da_gas, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_fee_per_l2_gas, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_l1_to_l2_msg_exists, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_lt, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_lte, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_mul, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_not, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_note_hash_exists, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_nullifier_exists, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_or, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_portal, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_radix_le, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_sender, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_shl, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_shr, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_sload, Transcript::proof_data); + serialize_to_buffer(avm_main_sel_op_sstore, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_sub, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_timestamp, Transcript::proof_data); serialize_to_buffer(avm_main_sel_op_transaction_fee, Transcript::proof_data); @@ -3427,6 +3742,7 @@ class AvmFlavor { serialize_to_buffer(perm_main_mem_ind_d, Transcript::proof_data); serialize_to_buffer(lookup_byte_lengths, Transcript::proof_data); serialize_to_buffer(lookup_byte_operations, Transcript::proof_data); + serialize_to_buffer(kernel_output_lookup, Transcript::proof_data); serialize_to_buffer(lookup_into_kernel, Transcript::proof_data); serialize_to_buffer(incl_main_tag_err, Transcript::proof_data); serialize_to_buffer(incl_mem_tag_err, Transcript::proof_data); @@ -3462,6 +3778,7 @@ class AvmFlavor { serialize_to_buffer(lookup_div_u16_7, Transcript::proof_data); serialize_to_buffer(lookup_byte_lengths_counts, Transcript::proof_data); serialize_to_buffer(lookup_byte_operations_counts, Transcript::proof_data); + serialize_to_buffer(kernel_output_lookup_counts, Transcript::proof_data); serialize_to_buffer(lookup_into_kernel_counts, Transcript::proof_data); serialize_to_buffer(incl_main_tag_err_counts, Transcript::proof_data); serialize_to_buffer(incl_mem_tag_err_counts, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp index 25f6d1fe17e..5b42548846d 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.cpp @@ -168,11 +168,37 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_conversion_num_limbs = commitment_key->commit(key->avm_conversion_num_limbs); witness_commitments.avm_conversion_radix = commitment_key->commit(key->avm_conversion_radix); witness_commitments.avm_conversion_to_radix_le_sel = commitment_key->commit(key->avm_conversion_to_radix_le_sel); + witness_commitments.avm_kernel_emit_l2_to_l1_msg_write_offset = + commitment_key->commit(key->avm_kernel_emit_l2_to_l1_msg_write_offset); + witness_commitments.avm_kernel_emit_note_hash_write_offset = + commitment_key->commit(key->avm_kernel_emit_note_hash_write_offset); + witness_commitments.avm_kernel_emit_nullifier_write_offset = + commitment_key->commit(key->avm_kernel_emit_nullifier_write_offset); + witness_commitments.avm_kernel_emit_unencrypted_log_write_offset = + commitment_key->commit(key->avm_kernel_emit_unencrypted_log_write_offset); + witness_commitments.avm_kernel_kernel_in_offset = commitment_key->commit(key->avm_kernel_kernel_in_offset); witness_commitments.avm_kernel_kernel_inputs__is_public = commitment_key->commit(key->avm_kernel_kernel_inputs__is_public); - witness_commitments.avm_kernel_kernel_sel = commitment_key->commit(key->avm_kernel_kernel_sel); + witness_commitments.avm_kernel_kernel_metadata_out__is_public = + commitment_key->commit(key->avm_kernel_kernel_metadata_out__is_public); + witness_commitments.avm_kernel_kernel_out_offset = commitment_key->commit(key->avm_kernel_kernel_out_offset); + witness_commitments.avm_kernel_kernel_side_effect_out__is_public = + commitment_key->commit(key->avm_kernel_kernel_side_effect_out__is_public); + witness_commitments.avm_kernel_kernel_value_out__is_public = + commitment_key->commit(key->avm_kernel_kernel_value_out__is_public); + witness_commitments.avm_kernel_l1_to_l2_msg_exists_write_offset = + commitment_key->commit(key->avm_kernel_l1_to_l2_msg_exists_write_offset); + witness_commitments.avm_kernel_note_hash_exist_write_offset = + commitment_key->commit(key->avm_kernel_note_hash_exist_write_offset); + witness_commitments.avm_kernel_nullifier_exists_write_offset = + commitment_key->commit(key->avm_kernel_nullifier_exists_write_offset); witness_commitments.avm_kernel_q_public_input_kernel_add_to_table = commitment_key->commit(key->avm_kernel_q_public_input_kernel_add_to_table); + witness_commitments.avm_kernel_q_public_input_kernel_out_add_to_table = + commitment_key->commit(key->avm_kernel_q_public_input_kernel_out_add_to_table); + witness_commitments.avm_kernel_side_effect_counter = commitment_key->commit(key->avm_kernel_side_effect_counter); + witness_commitments.avm_kernel_sload_write_offset = commitment_key->commit(key->avm_kernel_sload_write_offset); + witness_commitments.avm_kernel_sstore_write_offset = commitment_key->commit(key->avm_kernel_sstore_write_offset); witness_commitments.avm_main_alu_in_tag = commitment_key->commit(key->avm_main_alu_in_tag); witness_commitments.avm_main_alu_sel = commitment_key->commit(key->avm_main_alu_sel); witness_commitments.avm_main_bin_op_id = commitment_key->commit(key->avm_main_bin_op_id); @@ -205,6 +231,7 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_main_op_err = commitment_key->commit(key->avm_main_op_err); witness_commitments.avm_main_pc = commitment_key->commit(key->avm_main_pc); witness_commitments.avm_main_q_kernel_lookup = commitment_key->commit(key->avm_main_q_kernel_lookup); + witness_commitments.avm_main_q_kernel_output_lookup = commitment_key->commit(key->avm_main_q_kernel_output_lookup); witness_commitments.avm_main_r_in_tag = commitment_key->commit(key->avm_main_r_in_tag); witness_commitments.avm_main_rwa = commitment_key->commit(key->avm_main_rwa); witness_commitments.avm_main_rwb = commitment_key->commit(key->avm_main_rwb); @@ -226,20 +253,34 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_main_sel_op_chain_id = commitment_key->commit(key->avm_main_sel_op_chain_id); witness_commitments.avm_main_sel_op_coinbase = commitment_key->commit(key->avm_main_sel_op_coinbase); witness_commitments.avm_main_sel_op_div = commitment_key->commit(key->avm_main_sel_op_div); + witness_commitments.avm_main_sel_op_emit_l2_to_l1_msg = + commitment_key->commit(key->avm_main_sel_op_emit_l2_to_l1_msg); + witness_commitments.avm_main_sel_op_emit_note_hash = commitment_key->commit(key->avm_main_sel_op_emit_note_hash); + witness_commitments.avm_main_sel_op_emit_nullifier = commitment_key->commit(key->avm_main_sel_op_emit_nullifier); + witness_commitments.avm_main_sel_op_emit_unencrypted_log = + commitment_key->commit(key->avm_main_sel_op_emit_unencrypted_log); witness_commitments.avm_main_sel_op_eq = commitment_key->commit(key->avm_main_sel_op_eq); witness_commitments.avm_main_sel_op_fdiv = commitment_key->commit(key->avm_main_sel_op_fdiv); witness_commitments.avm_main_sel_op_fee_per_da_gas = commitment_key->commit(key->avm_main_sel_op_fee_per_da_gas); witness_commitments.avm_main_sel_op_fee_per_l2_gas = commitment_key->commit(key->avm_main_sel_op_fee_per_l2_gas); + witness_commitments.avm_main_sel_op_l1_to_l2_msg_exists = + commitment_key->commit(key->avm_main_sel_op_l1_to_l2_msg_exists); witness_commitments.avm_main_sel_op_lt = commitment_key->commit(key->avm_main_sel_op_lt); witness_commitments.avm_main_sel_op_lte = commitment_key->commit(key->avm_main_sel_op_lte); witness_commitments.avm_main_sel_op_mul = commitment_key->commit(key->avm_main_sel_op_mul); witness_commitments.avm_main_sel_op_not = commitment_key->commit(key->avm_main_sel_op_not); + witness_commitments.avm_main_sel_op_note_hash_exists = + commitment_key->commit(key->avm_main_sel_op_note_hash_exists); + witness_commitments.avm_main_sel_op_nullifier_exists = + commitment_key->commit(key->avm_main_sel_op_nullifier_exists); witness_commitments.avm_main_sel_op_or = commitment_key->commit(key->avm_main_sel_op_or); witness_commitments.avm_main_sel_op_portal = commitment_key->commit(key->avm_main_sel_op_portal); witness_commitments.avm_main_sel_op_radix_le = commitment_key->commit(key->avm_main_sel_op_radix_le); witness_commitments.avm_main_sel_op_sender = commitment_key->commit(key->avm_main_sel_op_sender); witness_commitments.avm_main_sel_op_shl = commitment_key->commit(key->avm_main_sel_op_shl); witness_commitments.avm_main_sel_op_shr = commitment_key->commit(key->avm_main_sel_op_shr); + witness_commitments.avm_main_sel_op_sload = commitment_key->commit(key->avm_main_sel_op_sload); + witness_commitments.avm_main_sel_op_sstore = commitment_key->commit(key->avm_main_sel_op_sstore); witness_commitments.avm_main_sel_op_sub = commitment_key->commit(key->avm_main_sel_op_sub); witness_commitments.avm_main_sel_op_timestamp = commitment_key->commit(key->avm_main_sel_op_timestamp); witness_commitments.avm_main_sel_op_transaction_fee = commitment_key->commit(key->avm_main_sel_op_transaction_fee); @@ -284,6 +325,7 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.avm_mem_w_in_tag = commitment_key->commit(key->avm_mem_w_in_tag); witness_commitments.lookup_byte_lengths_counts = commitment_key->commit(key->lookup_byte_lengths_counts); witness_commitments.lookup_byte_operations_counts = commitment_key->commit(key->lookup_byte_operations_counts); + witness_commitments.kernel_output_lookup_counts = commitment_key->commit(key->kernel_output_lookup_counts); witness_commitments.lookup_into_kernel_counts = commitment_key->commit(key->lookup_into_kernel_counts); witness_commitments.incl_main_tag_err_counts = commitment_key->commit(key->incl_main_tag_err_counts); witness_commitments.incl_mem_tag_err_counts = commitment_key->commit(key->incl_mem_tag_err_counts); @@ -443,11 +485,42 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_conversion_radix, witness_commitments.avm_conversion_radix); transcript->send_to_verifier(commitment_labels.avm_conversion_to_radix_le_sel, witness_commitments.avm_conversion_to_radix_le_sel); + transcript->send_to_verifier(commitment_labels.avm_kernel_emit_l2_to_l1_msg_write_offset, + witness_commitments.avm_kernel_emit_l2_to_l1_msg_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_emit_note_hash_write_offset, + witness_commitments.avm_kernel_emit_note_hash_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_emit_nullifier_write_offset, + witness_commitments.avm_kernel_emit_nullifier_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_emit_unencrypted_log_write_offset, + witness_commitments.avm_kernel_emit_unencrypted_log_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_in_offset, + witness_commitments.avm_kernel_kernel_in_offset); transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_inputs__is_public, witness_commitments.avm_kernel_kernel_inputs__is_public); - transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_sel, witness_commitments.avm_kernel_kernel_sel); + transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_metadata_out__is_public, + witness_commitments.avm_kernel_kernel_metadata_out__is_public); + transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_out_offset, + witness_commitments.avm_kernel_kernel_out_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_side_effect_out__is_public, + witness_commitments.avm_kernel_kernel_side_effect_out__is_public); + transcript->send_to_verifier(commitment_labels.avm_kernel_kernel_value_out__is_public, + witness_commitments.avm_kernel_kernel_value_out__is_public); + transcript->send_to_verifier(commitment_labels.avm_kernel_l1_to_l2_msg_exists_write_offset, + witness_commitments.avm_kernel_l1_to_l2_msg_exists_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_note_hash_exist_write_offset, + witness_commitments.avm_kernel_note_hash_exist_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_nullifier_exists_write_offset, + witness_commitments.avm_kernel_nullifier_exists_write_offset); transcript->send_to_verifier(commitment_labels.avm_kernel_q_public_input_kernel_add_to_table, witness_commitments.avm_kernel_q_public_input_kernel_add_to_table); + transcript->send_to_verifier(commitment_labels.avm_kernel_q_public_input_kernel_out_add_to_table, + witness_commitments.avm_kernel_q_public_input_kernel_out_add_to_table); + transcript->send_to_verifier(commitment_labels.avm_kernel_side_effect_counter, + witness_commitments.avm_kernel_side_effect_counter); + transcript->send_to_verifier(commitment_labels.avm_kernel_sload_write_offset, + witness_commitments.avm_kernel_sload_write_offset); + transcript->send_to_verifier(commitment_labels.avm_kernel_sstore_write_offset, + witness_commitments.avm_kernel_sstore_write_offset); transcript->send_to_verifier(commitment_labels.avm_main_alu_in_tag, witness_commitments.avm_main_alu_in_tag); transcript->send_to_verifier(commitment_labels.avm_main_alu_sel, witness_commitments.avm_main_alu_sel); transcript->send_to_verifier(commitment_labels.avm_main_bin_op_id, witness_commitments.avm_main_bin_op_id); @@ -482,6 +555,8 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_pc, witness_commitments.avm_main_pc); transcript->send_to_verifier(commitment_labels.avm_main_q_kernel_lookup, witness_commitments.avm_main_q_kernel_lookup); + transcript->send_to_verifier(commitment_labels.avm_main_q_kernel_output_lookup, + witness_commitments.avm_main_q_kernel_output_lookup); transcript->send_to_verifier(commitment_labels.avm_main_r_in_tag, witness_commitments.avm_main_r_in_tag); transcript->send_to_verifier(commitment_labels.avm_main_rwa, witness_commitments.avm_main_rwa); transcript->send_to_verifier(commitment_labels.avm_main_rwb, witness_commitments.avm_main_rwb); @@ -509,16 +584,30 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_sel_op_coinbase, witness_commitments.avm_main_sel_op_coinbase); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_div, witness_commitments.avm_main_sel_op_div); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_emit_l2_to_l1_msg, + witness_commitments.avm_main_sel_op_emit_l2_to_l1_msg); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_emit_note_hash, + witness_commitments.avm_main_sel_op_emit_note_hash); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_emit_nullifier, + witness_commitments.avm_main_sel_op_emit_nullifier); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_emit_unencrypted_log, + witness_commitments.avm_main_sel_op_emit_unencrypted_log); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_eq, witness_commitments.avm_main_sel_op_eq); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_fdiv, witness_commitments.avm_main_sel_op_fdiv); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_fee_per_da_gas, witness_commitments.avm_main_sel_op_fee_per_da_gas); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_fee_per_l2_gas, witness_commitments.avm_main_sel_op_fee_per_l2_gas); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_l1_to_l2_msg_exists, + witness_commitments.avm_main_sel_op_l1_to_l2_msg_exists); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_lt, witness_commitments.avm_main_sel_op_lt); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_lte, witness_commitments.avm_main_sel_op_lte); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_mul, witness_commitments.avm_main_sel_op_mul); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_not, witness_commitments.avm_main_sel_op_not); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_note_hash_exists, + witness_commitments.avm_main_sel_op_note_hash_exists); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_nullifier_exists, + witness_commitments.avm_main_sel_op_nullifier_exists); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_or, witness_commitments.avm_main_sel_op_or); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_portal, witness_commitments.avm_main_sel_op_portal); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_radix_le, @@ -526,6 +615,8 @@ void AvmProver::execute_wire_commitments_round() transcript->send_to_verifier(commitment_labels.avm_main_sel_op_sender, witness_commitments.avm_main_sel_op_sender); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_shl, witness_commitments.avm_main_sel_op_shl); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_shr, witness_commitments.avm_main_sel_op_shr); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_sload, witness_commitments.avm_main_sel_op_sload); + transcript->send_to_verifier(commitment_labels.avm_main_sel_op_sstore, witness_commitments.avm_main_sel_op_sstore); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_sub, witness_commitments.avm_main_sel_op_sub); transcript->send_to_verifier(commitment_labels.avm_main_sel_op_timestamp, witness_commitments.avm_main_sel_op_timestamp); @@ -575,6 +666,8 @@ void AvmProver::execute_wire_commitments_round() witness_commitments.lookup_byte_lengths_counts); transcript->send_to_verifier(commitment_labels.lookup_byte_operations_counts, witness_commitments.lookup_byte_operations_counts); + transcript->send_to_verifier(commitment_labels.kernel_output_lookup_counts, + witness_commitments.kernel_output_lookup_counts); transcript->send_to_verifier(commitment_labels.lookup_into_kernel_counts, witness_commitments.lookup_into_kernel_counts); transcript->send_to_verifier(commitment_labels.incl_main_tag_err_counts, @@ -647,6 +740,7 @@ void AvmProver::execute_log_derivative_inverse_round() witness_commitments.perm_main_mem_ind_d = commitment_key->commit(key->perm_main_mem_ind_d); witness_commitments.lookup_byte_lengths = commitment_key->commit(key->lookup_byte_lengths); witness_commitments.lookup_byte_operations = commitment_key->commit(key->lookup_byte_operations); + witness_commitments.kernel_output_lookup = commitment_key->commit(key->kernel_output_lookup); witness_commitments.lookup_into_kernel = commitment_key->commit(key->lookup_into_kernel); witness_commitments.incl_main_tag_err = commitment_key->commit(key->incl_main_tag_err); witness_commitments.incl_mem_tag_err = commitment_key->commit(key->incl_mem_tag_err); @@ -695,6 +789,7 @@ void AvmProver::execute_log_derivative_inverse_round() transcript->send_to_verifier(commitment_labels.perm_main_mem_ind_d, witness_commitments.perm_main_mem_ind_d); transcript->send_to_verifier(commitment_labels.lookup_byte_lengths, witness_commitments.lookup_byte_lengths); transcript->send_to_verifier(commitment_labels.lookup_byte_operations, witness_commitments.lookup_byte_operations); + transcript->send_to_verifier(commitment_labels.kernel_output_lookup, witness_commitments.kernel_output_lookup); transcript->send_to_verifier(commitment_labels.lookup_into_kernel, witness_commitments.lookup_into_kernel); transcript->send_to_verifier(commitment_labels.incl_main_tag_err, witness_commitments.incl_main_tag_err); transcript->send_to_verifier(commitment_labels.incl_mem_tag_err, witness_commitments.incl_mem_tag_err); @@ -765,13 +860,13 @@ void AvmProver::execute_zeromorph_rounds() transcript); } -HonkProof AvmProver::export_proof() +HonkProof& AvmProver::export_proof() { proof = transcript->proof_data; return proof; } -HonkProof AvmProver::construct_proof() +HonkProof& AvmProver::construct_proof() { // Add circuit size public input size and public inputs to transcript. execute_preamble_round(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp index 74d504446a3..47e2603a9ca 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_prover.hpp @@ -32,8 +32,8 @@ class AvmProver { void execute_relation_check_rounds(); void execute_zeromorph_rounds(); - HonkProof export_proof(); - HonkProof construct_proof(); + HonkProof& export_proof(); + HonkProof& construct_proof(); std::shared_ptr transcript = std::make_shared(); diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp index 7d9e39866e4..84fabd2f035 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.cpp @@ -46,7 +46,7 @@ using FF = AvmFlavor::FF; * @brief This function verifies an Avm Honk proof for given program settings. * */ -bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& public_inputs) +bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector>& public_inputs) { using Flavor = AvmFlavor; using FF = Flavor::FF; @@ -248,12 +248,43 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.avm_conversion_radix); commitments.avm_conversion_to_radix_le_sel = transcript->template receive_from_prover(commitment_labels.avm_conversion_to_radix_le_sel); + commitments.avm_kernel_emit_l2_to_l1_msg_write_offset = transcript->template receive_from_prover( + commitment_labels.avm_kernel_emit_l2_to_l1_msg_write_offset); + commitments.avm_kernel_emit_note_hash_write_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_emit_note_hash_write_offset); + commitments.avm_kernel_emit_nullifier_write_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_emit_nullifier_write_offset); + commitments.avm_kernel_emit_unencrypted_log_write_offset = transcript->template receive_from_prover( + commitment_labels.avm_kernel_emit_unencrypted_log_write_offset); + commitments.avm_kernel_kernel_in_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_kernel_in_offset); commitments.avm_kernel_kernel_inputs__is_public = transcript->template receive_from_prover(commitment_labels.avm_kernel_kernel_inputs__is_public); - commitments.avm_kernel_kernel_sel = - transcript->template receive_from_prover(commitment_labels.avm_kernel_kernel_sel); + commitments.avm_kernel_kernel_metadata_out__is_public = transcript->template receive_from_prover( + commitment_labels.avm_kernel_kernel_metadata_out__is_public); + commitments.avm_kernel_kernel_out_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_kernel_out_offset); + commitments.avm_kernel_kernel_side_effect_out__is_public = transcript->template receive_from_prover( + commitment_labels.avm_kernel_kernel_side_effect_out__is_public); + commitments.avm_kernel_kernel_value_out__is_public = + transcript->template receive_from_prover(commitment_labels.avm_kernel_kernel_value_out__is_public); + commitments.avm_kernel_l1_to_l2_msg_exists_write_offset = transcript->template receive_from_prover( + commitment_labels.avm_kernel_l1_to_l2_msg_exists_write_offset); + commitments.avm_kernel_note_hash_exist_write_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_note_hash_exist_write_offset); + commitments.avm_kernel_nullifier_exists_write_offset = transcript->template receive_from_prover( + commitment_labels.avm_kernel_nullifier_exists_write_offset); commitments.avm_kernel_q_public_input_kernel_add_to_table = transcript->template receive_from_prover( commitment_labels.avm_kernel_q_public_input_kernel_add_to_table); + commitments.avm_kernel_q_public_input_kernel_out_add_to_table = + transcript->template receive_from_prover( + commitment_labels.avm_kernel_q_public_input_kernel_out_add_to_table); + commitments.avm_kernel_side_effect_counter = + transcript->template receive_from_prover(commitment_labels.avm_kernel_side_effect_counter); + commitments.avm_kernel_sload_write_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_sload_write_offset); + commitments.avm_kernel_sstore_write_offset = + transcript->template receive_from_prover(commitment_labels.avm_kernel_sstore_write_offset); commitments.avm_main_alu_in_tag = transcript->template receive_from_prover(commitment_labels.avm_main_alu_in_tag); commitments.avm_main_alu_sel = @@ -307,6 +338,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu commitments.avm_main_pc = transcript->template receive_from_prover(commitment_labels.avm_main_pc); commitments.avm_main_q_kernel_lookup = transcript->template receive_from_prover(commitment_labels.avm_main_q_kernel_lookup); + commitments.avm_main_q_kernel_output_lookup = + transcript->template receive_from_prover(commitment_labels.avm_main_q_kernel_output_lookup); commitments.avm_main_r_in_tag = transcript->template receive_from_prover(commitment_labels.avm_main_r_in_tag); commitments.avm_main_rwa = transcript->template receive_from_prover(commitment_labels.avm_main_rwa); @@ -345,6 +378,14 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_coinbase); commitments.avm_main_sel_op_div = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_div); + commitments.avm_main_sel_op_emit_l2_to_l1_msg = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_emit_l2_to_l1_msg); + commitments.avm_main_sel_op_emit_note_hash = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_emit_note_hash); + commitments.avm_main_sel_op_emit_nullifier = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_emit_nullifier); + commitments.avm_main_sel_op_emit_unencrypted_log = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_emit_unencrypted_log); commitments.avm_main_sel_op_eq = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_eq); commitments.avm_main_sel_op_fdiv = @@ -353,6 +394,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_fee_per_da_gas); commitments.avm_main_sel_op_fee_per_l2_gas = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_fee_per_l2_gas); + commitments.avm_main_sel_op_l1_to_l2_msg_exists = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_l1_to_l2_msg_exists); commitments.avm_main_sel_op_lt = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_lt); commitments.avm_main_sel_op_lte = @@ -361,6 +404,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_mul); commitments.avm_main_sel_op_not = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_not); + commitments.avm_main_sel_op_note_hash_exists = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_note_hash_exists); + commitments.avm_main_sel_op_nullifier_exists = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_nullifier_exists); commitments.avm_main_sel_op_or = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_or); commitments.avm_main_sel_op_portal = @@ -373,6 +420,10 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_shl); commitments.avm_main_sel_op_shr = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_shr); + commitments.avm_main_sel_op_sload = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_sload); + commitments.avm_main_sel_op_sstore = + transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_sstore); commitments.avm_main_sel_op_sub = transcript->template receive_from_prover(commitment_labels.avm_main_sel_op_sub); commitments.avm_main_sel_op_timestamp = @@ -450,6 +501,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths_counts); commitments.lookup_byte_operations_counts = transcript->template receive_from_prover(commitment_labels.lookup_byte_operations_counts); + commitments.kernel_output_lookup_counts = + transcript->template receive_from_prover(commitment_labels.kernel_output_lookup_counts); commitments.lookup_into_kernel_counts = transcript->template receive_from_prover(commitment_labels.lookup_into_kernel_counts); commitments.incl_main_tag_err_counts = @@ -545,6 +598,8 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu transcript->template receive_from_prover(commitment_labels.lookup_byte_lengths); commitments.lookup_byte_operations = transcript->template receive_from_prover(commitment_labels.lookup_byte_operations); + commitments.kernel_output_lookup = + transcript->template receive_from_prover(commitment_labels.kernel_output_lookup); commitments.lookup_into_kernel = transcript->template receive_from_prover(commitment_labels.lookup_into_kernel); commitments.incl_main_tag_err = @@ -612,8 +667,32 @@ bool AvmVerifier::verify_proof(const HonkProof& proof, const std::vector& pu return false; } - FF public_column_evaluation = evaluate_public_input_column(public_inputs, circuit_size, multivariate_challenge); - if (public_column_evaluation != claimed_evaluations.avm_kernel_kernel_inputs__is_public) { + // Public columns evaluation checks + + FF avm_kernel_kernel_inputs__is_public_evaluation = + evaluate_public_input_column(public_inputs[0], circuit_size, multivariate_challenge); + if (avm_kernel_kernel_inputs__is_public_evaluation != claimed_evaluations.avm_kernel_kernel_inputs__is_public) { + return false; + } + + FF avm_kernel_kernel_metadata_out__is_public_evaluation = + evaluate_public_input_column(public_inputs[1], circuit_size, multivariate_challenge); + if (avm_kernel_kernel_metadata_out__is_public_evaluation != + claimed_evaluations.avm_kernel_kernel_metadata_out__is_public) { + return false; + } + + FF avm_kernel_kernel_side_effect_out__is_public_evaluation = + evaluate_public_input_column(public_inputs[2], circuit_size, multivariate_challenge); + if (avm_kernel_kernel_side_effect_out__is_public_evaluation != + claimed_evaluations.avm_kernel_kernel_side_effect_out__is_public) { + return false; + } + + FF avm_kernel_kernel_value_out__is_public_evaluation = + evaluate_public_input_column(public_inputs[3], circuit_size, multivariate_challenge); + if (avm_kernel_kernel_value_out__is_public_evaluation != + claimed_evaluations.avm_kernel_kernel_value_out__is_public) { return false; } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp index 6a1a09e82b8..2b7e126f1f1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/avm_verifier.hpp @@ -23,7 +23,7 @@ class AvmVerifier { AvmVerifier& operator=(const AvmVerifier& other) = delete; AvmVerifier& operator=(AvmVerifier&& other) noexcept; - bool verify_proof(const HonkProof& proof, const std::vector& public_inputs); + bool verify_proof(const HonkProof& proof, const std::vector>& public_inputs); std::shared_ptr key; std::map commitments; diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp index d03cc1c5277..45622c1d86f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/avm_kernel.test.cpp @@ -3,6 +3,7 @@ #include "barretenberg/vm/avm_trace/avm_common.hpp" #include "barretenberg/vm/avm_trace/avm_kernel_trace.hpp" #include "barretenberg/vm/avm_trace/constants.hpp" +#include "barretenberg/vm/tests/helpers.test.hpp" namespace tests_avm { using namespace bb; @@ -19,21 +20,29 @@ class AvmKernelPositiveTests : public ::testing::Test {}; class AvmKernelNegativeTests : public ::testing::Test {}; using KernelInputs = std::array; -KernelInputs get_kernel_inputs() + +VmPublicInputs get_public_inputs() { + VmPublicInputs public_inputs = {}; + std::array kernel_inputs; for (size_t i = 0; i < KERNEL_INPUTS_LENGTH; i++) { kernel_inputs[i] = FF(i + 1); } - return kernel_inputs; + + // Copy the kernel inputs into the public inputs object + std::get<0>(public_inputs) = kernel_inputs; + + return public_inputs; } // Template helper function to apply boilerplate around the kernel lookup tests template void test_kernel_lookup(OpcodesFunc apply_opcodes, CheckFunc check_trace) { - KernelInputs kernel_inputs = get_kernel_inputs(); - AvmTraceBuilder trace_builder(kernel_inputs); + VmPublicInputs public_inputs = get_public_inputs(); + + AvmTraceBuilder trace_builder(public_inputs); // We should return a value of 1 for the sender, as it exists at index 0 apply_opcodes(trace_builder); @@ -44,7 +53,7 @@ void test_kernel_lookup(OpcodesFunc apply_opcodes, CheckFunc check_trace) check_trace(trace); - validate_trace(std::move(trace), kernel_inputs); + validate_trace(std::move(trace), public_inputs); } /* @@ -53,7 +62,7 @@ void test_kernel_lookup(OpcodesFunc apply_opcodes, CheckFunc check_trace) void expect_row(std::vector::const_iterator row, FF selector, FF ia, FF mem_idx_a, AvmMemoryTag w_in_tag) { // Checks dependent on the opcode - EXPECT_EQ(row->avm_kernel_kernel_sel, selector); + EXPECT_EQ(row->avm_kernel_kernel_in_offset, selector); EXPECT_EQ(row->avm_main_ia, ia); EXPECT_EQ(row->avm_main_mem_idx_a, mem_idx_a); @@ -61,23 +70,91 @@ void expect_row(std::vector::const_iterator row, FF selector, FF ia, FF mem EXPECT_EQ(row->avm_main_rwa, FF(1)); EXPECT_EQ(row->avm_main_ind_a, FF(0)); EXPECT_EQ(row->avm_mem_op_a, FF(1)); - // TODO: below should really be a field element for each type EXPECT_EQ(row->avm_main_w_in_tag, static_cast(w_in_tag)); EXPECT_EQ(row->avm_main_q_kernel_lookup, FF(1)); } +void expect_output_table_row(std::vector::const_iterator row, + FF selector, + FF ia, + FF mem_idx_a, + AvmMemoryTag w_in_tag, + uint32_t side_effect_counter) +{ + // Checks dependent on the opcode + EXPECT_EQ(row->avm_kernel_kernel_out_offset, selector); + EXPECT_EQ(row->avm_main_ia, ia); + EXPECT_EQ(row->avm_main_mem_idx_a, mem_idx_a); + + // Checks that are fixed for kernel inputs + EXPECT_EQ(row->avm_main_rwa, FF(0)); + EXPECT_EQ(row->avm_main_ind_a, FF(0)); + EXPECT_EQ(row->avm_main_mem_op_a, FF(1)); + EXPECT_EQ(row->avm_main_r_in_tag, static_cast(w_in_tag)); + EXPECT_EQ(row->avm_main_q_kernel_output_lookup, FF(1)); + + EXPECT_EQ(row->avm_kernel_side_effect_counter, FF(side_effect_counter)); +} + +void expect_output_table_row_with_metadata(std::vector::const_iterator row, + FF selector, + FF ia, + FF mem_idx_a, + FF ib, + FF mem_idx_b, + AvmMemoryTag w_in_tag, + uint32_t side_effect_counter) +{ + expect_output_table_row(row, selector, ia, mem_idx_a, w_in_tag, side_effect_counter); + + EXPECT_EQ(row->avm_main_ib, ib); + EXPECT_EQ(row->avm_main_mem_idx_b, mem_idx_b); + + // Checks that are fixed for kernel inputs + EXPECT_EQ(row->avm_main_rwb, FF(0)); + EXPECT_EQ(row->avm_main_ind_b, FF(0)); + EXPECT_EQ(row->avm_main_mem_op_b, FF(1)); +} + +void expect_output_table_row_with_exists_metadata(std::vector::const_iterator row, + FF selector, + FF ia, + FF mem_idx_a, + FF ib, + FF mem_idx_b, + AvmMemoryTag w_in_tag, + uint32_t side_effect_counter) +{ + expect_output_table_row(row, selector, ia, mem_idx_a, w_in_tag, side_effect_counter); + + EXPECT_EQ(row->avm_main_ib, ib); + EXPECT_EQ(row->avm_main_mem_idx_b, mem_idx_b); + + // Checks that are fixed for kernel inputs + EXPECT_EQ(row->avm_main_rwb, FF(1)); + EXPECT_EQ(row->avm_main_ind_b, FF(0)); + EXPECT_EQ(row->avm_main_mem_op_b, FF(1)); +} + +void check_kernel_outputs(const Row& row, FF value, FF side_effect_counter, FF metadata) +{ + EXPECT_EQ(row.avm_kernel_kernel_value_out__is_public, value); + EXPECT_EQ(row.avm_kernel_kernel_side_effect_out__is_public, side_effect_counter); + EXPECT_EQ(row.avm_kernel_kernel_metadata_out__is_public, metadata); +} + TEST_F(AvmKernelPositiveTests, kernelSender) { uint32_t dst_offset = 42; // We test that the sender opcode is included at index 0 in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_sender(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sender == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); - expect_row(sender_row, - /*kernel_sel=*/SENDER_SELECTOR, + expect_row(row, + /*kernel_in_offset=*/SENDER_SELECTOR, /*ia=*/SENDER_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -97,7 +174,7 @@ TEST_F(AvmKernelPositiveTests, kernelAddress) EXPECT_TRUE(address_row != trace.end()); expect_row(address_row, - /*kernel_sel=*/ADDRESS_SELECTOR, + /*kernel_in_offset=*/ADDRESS_SELECTOR, /*ia=*/ADDRESS_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -116,7 +193,7 @@ TEST_F(AvmKernelPositiveTests, kernelPortal) EXPECT_TRUE(portal_row != trace.end()); expect_row(portal_row, - /*kernel_sel=*/PORTAL_SELECTOR, + /*kernel_in_offset=*/PORTAL_SELECTOR, /*ia=*/PORTAL_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -135,7 +212,7 @@ TEST_F(AvmKernelPositiveTests, kernelFeePerDa) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/FEE_PER_DA_GAS_SELECTOR, + /*kernel_in_offset=*/FEE_PER_DA_GAS_SELECTOR, /*ia=*/FEE_PER_DA_GAS_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -154,7 +231,7 @@ TEST_F(AvmKernelPositiveTests, kernelFeePerL2) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/FEE_PER_L2_GAS_SELECTOR, + /*kernel_in_offset=*/FEE_PER_L2_GAS_SELECTOR, /*ia=*/FEE_PER_L2_GAS_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -173,7 +250,7 @@ TEST_F(AvmKernelPositiveTests, kernelTransactionFee) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/TRANSACTION_FEE_SELECTOR, + /*kernel_in_offset=*/TRANSACTION_FEE_SELECTOR, /*ia=*/TRANSACTION_FEE_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -192,7 +269,7 @@ TEST_F(AvmKernelPositiveTests, kernelChainId) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/CHAIN_ID_SELECTOR, + /*kernel_in_offset=*/CHAIN_ID_SELECTOR, /*ia=*/CHAIN_ID_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -211,7 +288,7 @@ TEST_F(AvmKernelPositiveTests, kernelVersion) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/VERSION_SELECTOR, + /*kernel_in_offset=*/VERSION_SELECTOR, /*ia=*/VERSION_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -230,7 +307,7 @@ TEST_F(AvmKernelPositiveTests, kernelBlockNumber) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/BLOCK_NUMBER_SELECTOR, + /*kernel_in_offset=*/BLOCK_NUMBER_SELECTOR, /*ia=*/BLOCK_NUMBER_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, @@ -249,7 +326,7 @@ TEST_F(AvmKernelPositiveTests, kernelCoinbase) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/COINBASE_SELECTOR, + /*kernel_in_offset=*/COINBASE_SELECTOR, /*ia=*/COINBASE_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a*/ dst_offset, @@ -268,7 +345,7 @@ TEST_F(AvmKernelPositiveTests, kernelTimestamp) EXPECT_TRUE(fee_row != trace.end()); expect_row(fee_row, - /*kernel_sel=*/TIMESTAMP_SELECTOR, + /*kernel_in_offset=*/TIMESTAMP_SELECTOR, /*ia=*/TIMESTAMP_SELECTOR + 1, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a*/ dst_offset, @@ -288,8 +365,8 @@ void negative_test_incorrect_ia_kernel_lookup(OpcodesFunc apply_opcodes, FF incorrect_ia, auto expected_message) { - KernelInputs kernel_inputs = get_kernel_inputs(); - AvmTraceBuilder trace_builder(kernel_inputs); + VmPublicInputs public_inputs = get_public_inputs(); + AvmTraceBuilder trace_builder(public_inputs); // We should return a value of 1 for the sender, as it exists at index 0 apply_opcodes(trace_builder); @@ -306,7 +383,7 @@ void negative_test_incorrect_ia_kernel_lookup(OpcodesFunc apply_opcodes, check_trace(trace); - EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace), kernel_inputs), expected_message); + EXPECT_THROW_WITH_MESSAGE(validate_trace_check_circuit(std::move(trace), public_inputs), expected_message); } TEST_F(AvmKernelNegativeTests, incorrectIaSender) @@ -317,13 +394,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaSender) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_sender(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sender == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/SENDER_SELECTOR, + row, + /*kernel_in_offset=*/SENDER_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -340,13 +417,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaAddress) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_address(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_address == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/ADDRESS_SELECTOR, + row, + /*kernel_in_offset=*/ADDRESS_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -363,13 +440,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaPortal) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_portal(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_portal == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/PORTAL_SELECTOR, + row, + /*kernel_in_offset=*/PORTAL_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -386,13 +463,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaDaGas) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_fee_per_da_gas(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = std::ranges::find_if( + std::vector::const_iterator row = std::ranges::find_if( trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_fee_per_da_gas == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/FEE_PER_DA_GAS_SELECTOR, + row, + /*kernel_in_offset=*/FEE_PER_DA_GAS_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -409,13 +486,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIal2Gas) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_fee_per_l2_gas(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = std::ranges::find_if( + std::vector::const_iterator row = std::ranges::find_if( trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_fee_per_l2_gas == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/FEE_PER_L2_GAS_SELECTOR, + row, + /*kernel_in_offset=*/FEE_PER_L2_GAS_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -432,13 +509,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaTransactionFee) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_transaction_fee(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = std::ranges::find_if( + std::vector::const_iterator row = std::ranges::find_if( trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_transaction_fee == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/TRANSACTION_FEE_SELECTOR, + row, + /*kernel_in_offset=*/TRANSACTION_FEE_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -455,13 +532,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaChainId) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_chain_id(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_chain_id == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/CHAIN_ID_SELECTOR, + row, + /*kernel_in_offset=*/CHAIN_ID_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -478,13 +555,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaVersion) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_version(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_version == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/VERSION_SELECTOR, + row, + /*kernel_in_offset=*/VERSION_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -501,13 +578,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaBlockNumber) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_block_number(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = std::ranges::find_if( + std::vector::const_iterator row = std::ranges::find_if( trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_block_number == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/BLOCK_NUMBER_SELECTOR, + row, + /*kernel_in_offset=*/BLOCK_NUMBER_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -524,13 +601,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaTimestamp) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_timestamp(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = std::ranges::find_if( + std::vector::const_iterator row = std::ranges::find_if( trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_timestamp == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/TIMESTAMP_SELECTOR, + row, + /*kernel_in_offset=*/TIMESTAMP_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a*/ dst_offset, /*w_in_tag=*/AvmMemoryTag::U64); @@ -547,13 +624,13 @@ TEST_F(AvmKernelNegativeTests, incorrectIaCoinbase) // We test that the sender opcode is inlcuded at index x in the public inputs auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { trace_builder.op_coinbase(dst_offset); }; auto checks = [=](const std::vector& trace) { - std::vector::const_iterator sender_row = + std::vector::const_iterator row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_coinbase == FF(1); }); - EXPECT_TRUE(sender_row != trace.end()); + EXPECT_TRUE(row != trace.end()); expect_row( - sender_row, - /*kernel_sel=*/COINBASE_SELECTOR, + row, + /*kernel_in_offset=*/COINBASE_SELECTOR, /*ia=*/incorrect_ia, // Note the value generated above for public inputs is the same as the index read + 1 /*mem_idx_a=*/dst_offset, /*w_in_tag=*/AvmMemoryTag::FF); @@ -562,4 +639,309 @@ TEST_F(AvmKernelNegativeTests, incorrectIaCoinbase) negative_test_incorrect_ia_kernel_lookup(apply_opcodes, checks, incorrect_ia, "PERM_MAIN_MEM_A"); } +// KERNEL OUTPUTS +class AvmKernelOutputPositiveTests : public ::testing::Test {}; +class AvmKernelOutputNegativeTests : public ::testing::Test {}; + +TEST_F(AvmKernelOutputPositiveTests, kernelEmitNoteHash) +{ + uint32_t offset = 42; + // We write the note hash into memory + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, 1234, offset, AvmMemoryTag::FF); + trace_builder.op_emit_note_hash(offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_note_hash == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_EMIT_NOTE_HASH_WRITE_OFFSET; + + expect_output_table_row( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/1234, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0); + + check_kernel_outputs(trace.at(output_offset + 1), 1234, /*side_effect_counter=*/0, /*metadata=*/0); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelEmitNullifier) +{ + uint32_t offset = 42; + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, 1234, offset, AvmMemoryTag::FF); + trace_builder.op_emit_nullifier(offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_nullifier == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_EMIT_NULLIFIER_WRITE_OFFSET; + + expect_output_table_row( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/1234, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0); + + // Validate lookup and counts + // Plus 1 as we have a padded empty first row + check_kernel_outputs(trace.at(output_offset + 1), 1234, /*side_effect_counter=*/0, /*metadata=*/0); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelEmitL2ToL1Msg) +{ + uint32_t offset = 42; + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, 1234, offset, AvmMemoryTag::FF); + trace_builder.op_emit_l2_to_l1_msg(offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_l2_to_l1_msg == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_L2_TO_L1_MSG_WRITE_OFFSET; + + expect_output_table_row( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/1234, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0 + + ); + + check_kernel_outputs(trace.at(output_offset + 1), 1234, /*side_effect_counter=*/0, /*metadata=*/0); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelEmitUnencryptedLog) +{ + uint32_t offset = 42; + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, 1234, offset, AvmMemoryTag::FF); + trace_builder.op_emit_unencrypted_log(offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_emit_unencrypted_log == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET; + + expect_output_table_row( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/1234, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0); + + check_kernel_outputs(trace.at(output_offset + 1), 1234, 0, 0); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelSload) +{ + uint32_t value_offset = 42; + auto value = 1234; + uint32_t metadata_offset = 420; + auto slot = 12345; + + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); + trace_builder.op_set(0, static_cast(slot), metadata_offset, AvmMemoryTag::FF); + trace_builder.op_sload(metadata_offset, value_offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sload == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_SLOAD_WRITE_OFFSET; + + expect_output_table_row_with_metadata( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/value_offset, + /*ib=*/slot, + /*mem_idx_b=*/metadata_offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0 + + ); + + check_kernel_outputs(trace.at(output_offset + 1), value, /*side_effect_counter=*/0, slot); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelSstore) +{ + uint32_t value_offset = 42; + auto value = 1234; + uint32_t metadata_offset = 420; + auto slot = 12345; + + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); + trace_builder.op_set(0, static_cast(slot), metadata_offset, AvmMemoryTag::FF); + trace_builder.op_sstore(metadata_offset, value_offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = + std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_sstore == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_SSTORE_WRITE_OFFSET; + + expect_output_table_row_with_metadata( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/value_offset, + /*ib=*/slot, + /*mem_idx_b=*/metadata_offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0); + + check_kernel_outputs(trace.at(output_offset + 1), value, /*side_effect_counter=*/0, slot); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelNoteHashExists) +{ + uint32_t value_offset = 42; + auto value = 1234; + uint32_t metadata_offset = 420; + auto exists = 1; + + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); + trace_builder.op_note_hash_exists(value_offset, metadata_offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_note_hash_exists == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_NOTE_HASH_EXISTS_WRITE_OFFSET; + + expect_output_table_row_with_exists_metadata( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/value_offset, + /*ib=*/exists, + /*mem_idx_b=*/metadata_offset, + /*w_in_tag=*/AvmMemoryTag::FF, + + /*side_effect_counter=*/0); + + check_kernel_outputs(trace.at(output_offset + 1), value, /*side_effect_counter=*/0, exists); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelNullifierExists) +{ + uint32_t value_offset = 42; + auto value = 1234; + uint32_t metadata_offset = 420; + auto exists = 1; + + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); + trace_builder.op_nullifier_exists(value_offset, metadata_offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_nullifier_exists == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_NULLIFIER_EXISTS_OFFSET; + + expect_output_table_row_with_exists_metadata( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/value_offset, + /*ib=*/exists, + /*mem_idx_b=*/metadata_offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0); + + check_kernel_outputs(trace.at(output_offset + 1), value, /*side_effect_counter=*/0, exists); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + +TEST_F(AvmKernelOutputPositiveTests, kernelL1ToL2MsgExists) +{ + uint32_t value_offset = 42; + auto value = 1234; + uint32_t metadata_offset = 420; + auto exists = 1; + + auto apply_opcodes = [=](AvmTraceBuilder& trace_builder) { + trace_builder.op_set(0, static_cast(value), value_offset, AvmMemoryTag::FF); + trace_builder.op_l1_to_l2_msg_exists(value_offset, metadata_offset); + }; + auto checks = [=](const std::vector& trace) { + std::vector::const_iterator row = std::ranges::find_if( + trace.begin(), trace.end(), [](Row r) { return r.avm_main_sel_op_l1_to_l2_msg_exists == FF(1); }); + EXPECT_TRUE(row != trace.end()); + + // Check the outputs of the trace + uint32_t output_offset = AvmKernelTraceBuilder::START_L1_TO_L2_MSG_EXISTS_WRITE_OFFSET; + + expect_output_table_row_with_exists_metadata( + row, + /*kernel_in_offset=*/output_offset, + /*ia=*/value, // Note the value generated above for public inputs is the same as the index read + 1 + /*mem_idx_a=*/value_offset, + /*ib=*/exists, + /*mem_idx_b=*/metadata_offset, + /*w_in_tag=*/AvmMemoryTag::FF, + /*side_effect_counter=*/0); + + check_kernel_outputs(trace.at(output_offset + 1), value, /*side_effect_counter=*/0, exists); + }; + + test_kernel_lookup(apply_opcodes, checks); +} + } // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index b1fb19d3817..18e319e1f54 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -1,7 +1,9 @@ #include "barretenberg/vm/tests/helpers.test.hpp" #include "avm_common.test.hpp" +#include "barretenberg/vm/avm_trace/avm_helper.hpp" #include "barretenberg/vm/avm_trace/constants.hpp" #include "barretenberg/vm/generated/avm_flavor.hpp" +#include using namespace bb; namespace tests_avm { @@ -21,7 +23,7 @@ std::vector gen_three_op_params(std::vector opera * * @param trace The execution trace */ -void validate_trace_check_circuit(std::vector&& trace, std::array public_inputs) +void validate_trace_check_circuit(std::vector&& trace, VmPublicInputs public_inputs) { validate_trace(std::move(trace), public_inputs, false); }; @@ -32,7 +34,7 @@ void validate_trace_check_circuit(std::vector&& trace, std::array&& trace, std::array public_inputs, bool with_proof) +void validate_trace(std::vector&& trace, VmPublicInputs public_inputs, bool with_proof) { auto circuit_builder = AvmCircuitBuilder(); circuit_builder.set_trace(std::move(trace)); @@ -45,9 +47,7 @@ void validate_trace(std::vector&& trace, std::array public_inputs_as_vec(KERNEL_INPUTS_LENGTH); - std::copy(public_inputs.begin(), public_inputs.end(), public_inputs_as_vec.data()); + std::vector> public_inputs_as_vec = bb::avm_trace::copy_public_inputs_columns(public_inputs); bool verified = verifier.verify_proof(proof, public_inputs_as_vec); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp index 6715ec52ef1..1dc310000ad 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp @@ -1,7 +1,7 @@ #pragma once +#include "barretenberg/vm/avm_trace/avm_common.hpp" #include "barretenberg/vm/avm_trace/avm_trace.hpp" -#include "barretenberg/vm/avm_trace/constants.hpp" #include #define EXPECT_THROW_WITH_MESSAGE(code, expectedMessage) \ @@ -19,6 +19,7 @@ using FF = Flavor::FF; using Row = bb::AvmFullRow; using ThreeOpParam = std::array; using ThreeOpParamRow = std::tuple; +using VmPublicInputs = bb::avm_trace::VmPublicInputs; // To toggle all relevant unit tests with proving, set the env variable "AVM_TESTS_ENABLE_PROVING". static const bool ENABLE_PROVING = std::getenv("AVM_TESTS_ENABLE_PROVING") != nullptr; @@ -26,10 +27,8 @@ static const bool ENABLE_PROVING = std::getenv("AVM_TESTS_ENABLE_PROVING") != nu // If the test is expecting a relation to fail, then use validate_trace_check_circuit. // Otherwise, use validate_trace with a single argument. If the proving needs to be // enabled all the time in a given test, use validate_trace with setting with_proof = true. -void validate_trace_check_circuit(std::vector&& trace, std::array kernel_inputs = {}); -void validate_trace(std::vector&& trace, - std::array kernel_inputs = {}, - bool with_proof = ENABLE_PROVING); +void validate_trace_check_circuit(std::vector&& trace, VmPublicInputs public_inputs = {}); +void validate_trace(std::vector&& trace, VmPublicInputs public_inputs = {}, bool with_proof = ENABLE_PROVING); void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue, diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index ad8c57f95ec..dfa4492de6a 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -21,6 +21,15 @@ const CPP_CONSTANTS = [ 'HEADER_LENGTH', 'CALL_CONTEXT_LENGTH', 'PUBLIC_CONTEXT_INPUTS_LENGTH', + 'MAX_NOTE_HASH_READ_REQUESTS_PER_CALL', + 'MAX_NEW_NOTE_HASHES_PER_CALL', + 'MAX_NULLIFIER_READ_REQUESTS_PER_CALL', + 'MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL', + 'MAX_NEW_NULLIFIERS_PER_CALL', + 'MAX_NEW_L2_TO_L1_MSGS_PER_CALL', + 'MAX_UNENCRYPTED_LOGS_PER_CALL', + 'MAX_PUBLIC_DATA_READS_PER_CALL', + 'MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL', ]; /**