diff --git a/barretenberg/cpp/pil/vm2/opcodes/send_l2_to_l1_msg.pil b/barretenberg/cpp/pil/vm2/opcodes/send_l2_to_l1_msg.pil index e6d8081ae636..9a7d4896298c 100644 --- a/barretenberg/cpp/pil/vm2/opcodes/send_l2_to_l1_msg.pil +++ b/barretenberg/cpp/pil/vm2/opcodes/send_l2_to_l1_msg.pil @@ -66,5 +66,6 @@ namespace execution; // this is a virtual gadget that shares rows with the execu public_inputs.cols[2] }; + // Increase num message if error is off. We increase even in the discard case, since discard only implies not writing to public inputs. #[EMIT_L2_TO_L1_MSG_NUM_L2_TO_L1_MSGS_EMITTED_INCREASE] sel_execute_send_l2_to_l1_msg * (prev_num_l2_to_l1_messages + (1 - sel_opcode_error) - num_l2_to_l1_messages) = 0; diff --git a/barretenberg/cpp/pil/vm2/precomputed.pil b/barretenberg/cpp/pil/vm2/precomputed.pil index bae1b8184ab4..329900207244 100644 --- a/barretenberg/cpp/pil/vm2/precomputed.pil +++ b/barretenberg/cpp/pil/vm2/precomputed.pil @@ -170,7 +170,6 @@ pol constant envvar_pi_row_idx; pol constant is_address; pol constant is_sender; pol constant is_transactionfee; -pol constant is_feeperl2gas; pol constant is_isstaticcall; pol constant is_l2gasleft; pol constant is_dagasleft; diff --git a/barretenberg/cpp/pil/vm2/trees/nullifier_check.pil b/barretenberg/cpp/pil/vm2/trees/nullifier_check.pil index 444803edb6b4..9648ceb13950 100644 --- a/barretenberg/cpp/pil/vm2/trees/nullifier_check.pil +++ b/barretenberg/cpp/pil/vm2/trees/nullifier_check.pil @@ -71,7 +71,6 @@ namespace nullifier_check; // Inputs to the gadget pol commit write; write * (1 - write) = 0; - pol READ = 1 - write; // If writing, sel must be on write * (1 - sel) = 0; diff --git a/barretenberg/cpp/pil/vm2/trees/retrieved_bytecodes_tree_check.pil b/barretenberg/cpp/pil/vm2/trees/retrieved_bytecodes_tree_check.pil index 5a1d2cd02b68..f16659b7a04c 100644 --- a/barretenberg/cpp/pil/vm2/trees/retrieved_bytecodes_tree_check.pil +++ b/barretenberg/cpp/pil/vm2/trees/retrieved_bytecodes_tree_check.pil @@ -48,7 +48,6 @@ namespace retrieved_bytecodes_tree_check; // Inputs to the gadget pol commit write; write * (1 - write) = 0; - pol READ = 1 - write; pol commit class_id; pol commit root; diff --git a/barretenberg/cpp/pil/vm2/trees/written_public_data_slots_tree_check.pil b/barretenberg/cpp/pil/vm2/trees/written_public_data_slots_tree_check.pil index 815c5a766373..77cf00826f01 100644 --- a/barretenberg/cpp/pil/vm2/trees/written_public_data_slots_tree_check.pil +++ b/barretenberg/cpp/pil/vm2/trees/written_public_data_slots_tree_check.pil @@ -52,7 +52,6 @@ namespace written_public_data_slots_tree_check; // Inputs to the gadget pol commit write; write * (1 - write) = 0; - pol READ = 1 - write; pol commit slot; pol commit root; diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/avm_differential.fuzzer.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/avm_differential.fuzzer.cpp index 2567ed69f8a6..971d4d405c05 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/avm_differential.fuzzer.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/avm_differential.fuzzer.cpp @@ -6,9 +6,9 @@ #include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/control_flow.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzz.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp" #include "barretenberg/avm_fuzzer/mutations/fuzzer_data.hpp" @@ -17,6 +17,22 @@ using FuzzInstruction = ::FuzzInstruction; using namespace bb::avm2::fuzzer; +namespace { + +FuzzerContext create_context_with_predefined_functions() +{ + FuzzerContext context; + + // Register predefined functions + for (const auto& function : PREDEFINED_FUNCTIONS) { + context.register_contract_from_bytecode(function); + } + + return context; +} + +} // namespace + /// Initializes the typescript simulator process and the world state manager /// See yarn-project/simulator/scripts/fuzzing/ extern "C" int LLVMFuzzerInitialize(int*, char***) @@ -42,7 +58,8 @@ SimulatorResult fuzz(const uint8_t* buffer, size_t size) FuzzerWorldStateManager* ws_mgr = FuzzerWorldStateManager::getInstance(); ws_mgr->fork(); - auto res = fuzz_against_ts_simulator(deserialized_data); + auto context = create_context_with_predefined_functions(); + auto res = fuzz_against_ts_simulator(deserialized_data, context); ws_mgr->reset_world_state(); return res; @@ -53,6 +70,7 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* serialized_fuzzer_data, size_t max_size, unsigned int seed) { + auto context = create_context_with_predefined_functions(); auto rng = std::mt19937_64(seed); FuzzerData deserialized_data; try { @@ -62,7 +80,7 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* serialized_fuzzer_data, } catch (const std::exception& e) { deserialized_data = FuzzerData(); } - mutate_fuzzer_data(deserialized_data, rng); + mutate_fuzzer_data(deserialized_data, rng, context); auto [mutated_serialized_fuzzer_data, mutated_serialized_fuzzer_data_size] = msgpack_encode_buffer(deserialized_data); if (mutated_serialized_fuzzer_data_size > max_size) { diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/common/process.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/common/process.cpp index efde0a04cac5..5d49d5336287 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/common/process.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/common/process.cpp @@ -49,8 +49,22 @@ Process::~Process() void Process::write_line(const std::string& line) const { std::string command = line + "\n"; - write(stdin_fd, command.c_str(), command.size()); - fsync(stdin_fd); + const char* data = command.c_str(); + size_t remaining = command.size(); + + // We use a loop to ensure all data is written but throw if we encounter an error. + // This enables partial writes to be handled correctly. + while (remaining > 0) { + ssize_t written = write(stdin_fd, data, remaining); + if (written < 0) { + if (errno == EINTR) { + continue; + } + throw std::runtime_error("write() error: " + std::string(std::strerror(errno))); + } + data += written; + remaining -= static_cast(written); + } } std::string Process::read_line() const @@ -58,12 +72,15 @@ std::string Process::read_line() const char buffer[4096]; // NOLINT std::string response; ssize_t bytes_read = 0; - fsync(stdout_fd); while ((bytes_read = read(stdout_fd, buffer, sizeof(buffer))) > 0) { - response.append(buffer, static_cast(bytes_read)); - if (response.find('\n') != std::string::npos) { + // Check for newline in just the newly read data instead of going back through the entire response + const char* newline_pos = static_cast(memchr(buffer, '\n', static_cast(bytes_read))); + if (newline_pos != nullptr) { + // Found newline - append only up to and including the newline + response.append(buffer, static_cast(newline_pos - buffer + 1)); break; } + response.append(buffer, static_cast(bytes_read)); } if (bytes_read < 0 && errno != EINTR) { throw std::runtime_error("read() error: " + std::string(std::strerror(errno))); diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.cpp deleted file mode 100644 index e4fc80175048..000000000000 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp" - -#include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/control_flow.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp" -#include "barretenberg/common/log.hpp" -#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -#include "barretenberg/vm2/simulation/lib/contract_crypto.hpp" - -using namespace bb::avm2::fuzzer; - -// Temp Helper function to create a default contract class from bytecode -ContractClass create_default_class(const std::vector& bytecode) -{ - // This isn't strictly needed for pure simulation, but if we want to re-use inputs in proving we need valid - // commitment - auto bytecode_commitment = simulation::compute_public_bytecode_commitment(bytecode); - auto class_id = - simulation::compute_contract_class_id(/*artifact_hash=*/0, /*private_fn_root=*/0, bytecode_commitment); - return ContractClass{ - .id = class_id, - .artifact_hash = 0, - .private_functions_root = 0, - .packed_bytecode = bytecode, - }; -} - -// Temp Helper function to create a default contract instance from a class ID -ContractInstance create_default_instance(const ContractClassId& class_id) -{ - // To avoid Assertion failed: (contract_instance.public_keys.incoming_viewing_key.on_curve()) - auto affine_one = grumpkin::g1::affine_one; - return ContractInstance{ - .salt = 0, - .deployer = MSG_SENDER, - .current_contract_class_id = class_id, - .original_contract_class_id = class_id, - .initialization_hash = 0, - .public_keys = - PublicKeys{ - .nullifier_key = affine_one, - .incoming_viewing_key = affine_one, - .outgoing_viewing_key = affine_one, - .tagging_key = affine_one, - }, - }; -} - -// Temp Helper function to compute contract address from instance -AztecAddress compute_contract_address(const ContractInstance& instance) -{ - // This isn't strictly needed for pure simulation, but if we want to re-use inputs in proving we need valid - // addresses - return simulation::compute_contract_address(instance); -} - -// Creates a default transaction that the single app logic enqueued call can be inserted into -Tx create_default_tx(const AztecAddress& contract_address, - const AztecAddress& sender_address, - const std::vector& calldata, - [[maybe_unused]] const FF& transaction_fee, - bool is_static_call, - const Gas& gas_limit) -{ - return Tx{ - .hash = TRANSACTION_HASH, - .gas_settings = GasSettings{ - .gas_limits = gas_limit, - .max_fees_per_gas = GasFees{ .fee_per_da_gas = FEE_PER_DA_GAS, .fee_per_l2_gas = FEE_PER_L2_GAS }, - }, - .effective_gas_fees = EFFECTIVE_GAS_FEES, - .non_revertible_accumulated_data = AccumulatedData{ - .note_hashes = NON_REVERTIBLE_ACCUMULATED_DATA_NOTE_HASHES, - // This nullifier is needed to make the nonces for note hashes and expected by simulation_helper - .nullifiers = NON_REVERTIBLE_ACCUMULATED_DATA_NULLIFIERS, - .l2_to_l1_messages = NON_REVERTIBLE_ACCUMULATED_DATA_L2_TO_L1_MESSAGES, - }, - .revertible_accumulated_data = AccumulatedData{ - .note_hashes = REVERTIBLE_ACCUMULATED_DATA_NOTE_HASHES, - .nullifiers = REVERTIBLE_ACCUMULATED_DATA_NULLIFIERS, - .l2_to_l1_messages = REVERTIBLE_ACCUMULATED_DATA_L2_TO_L1_MESSAGES, - }, - .setup_enqueued_calls = SETUP_ENQUEUED_CALLS, - .app_logic_enqueued_calls = { - PublicCallRequestWithCalldata{ - .request = PublicCallRequest{ - .msg_sender = MSG_SENDER, - .contract_address = contract_address, - .is_static_call = is_static_call, - .calldata_hash = compute_calldata_hash(calldata), - }, - .calldata = calldata, - }, - }, - .teardown_enqueued_call = TEARDOWN_ENQUEUED_CALLS, - .gas_used_by_private = GAS_USED_BY_PRIVATE, - .fee_payer = sender_address, - }; -} - -namespace bb::avm2::fuzzer { - -ContractDBProxy* ContractDBProxy::instance = nullptr; - -ContractDBProxy::ContractDBProxy() -{ - contract_db = new FuzzerContractDB(); -} - -ContractDBProxy* ContractDBProxy::get_instance() -{ - if (instance == nullptr) { - instance = new ContractDBProxy(); - } - return instance; -} - -FF ContractDBProxy::register_contract_from_bytecode(const std::vector& bytecode) -{ - if (instance == nullptr) { - instance = new ContractDBProxy(); - } - auto default_class = create_default_class(bytecode); - auto default_instance = create_default_instance(default_class.id); - auto contract_address = simulation::compute_contract_address(default_instance); - instance->contract_db->add_contract_class(default_class.id, default_class); - instance->contract_db->add_contract_instance(contract_address, default_instance); - instance->registered_contract_addresses.push_back(contract_address); - - FuzzerWorldStateManager::getInstance()->register_contract_address(contract_address); - return contract_address; -} - -FF ContractDBProxy::get_function_address(size_t index) -{ - if (instance == nullptr) { - instance = new ContractDBProxy(); - } - if (instance->registered_contract_addresses.size() < 1) { - return FF::zero(); - } - return instance->registered_contract_addresses[index % (instance->registered_contract_addresses.size())]; -} - -void ContractDBProxy::reset_instance() -{ - if (instance != nullptr) { - delete instance->contract_db; - delete instance; - instance = new ContractDBProxy(); - } -} -} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp deleted file mode 100644 index 80ac14a2d9a5..000000000000 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/// Singleton proxy class for FuzzerContractDB -#pragma once - -#include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" -#include "barretenberg/vm2/common/field.hpp" - -namespace bb::avm2::fuzzer { - -class ContractDBProxy { - private: - static ContractDBProxy* instance; - ContractDBProxy(); - - FuzzerContractDB* contract_db; - std::vector registered_contract_addresses; - - public: - static ContractDBProxy* get_instance(); - - /// @brief Register a contract from its bytecode - /// @param bytecode The bytecode of the contract - /// @return The address of the registered contract - /// @note This function will also register the contract address in the world state - /// Adds the contract address to the registered_contract_addresses vector - static FF register_contract_from_bytecode(const std::vector& bytecode); - - static void reset_instance(); - - FuzzerContractDB* get_contract_db() const { return contract_db; } - - /// @brief Get the address of a function by index - /// @return registered_contract_addresses[index % (registered_contract_addresses.size())] - FF get_function_address(size_t index); -}; -} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.cpp index a43a83483d98..e1cb9d3d1c2d 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.cpp @@ -2,8 +2,8 @@ #include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/control_flow.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp" #include "barretenberg/common/log.hpp" @@ -11,7 +11,7 @@ using namespace bb::avm2::fuzzer; -SimulatorResult fuzz_against_ts_simulator(FuzzerData& fuzzer_data) +SimulatorResult fuzz_against_ts_simulator(FuzzerData& fuzzer_data, FuzzerContext& context) { auto control_flow = ControlFlow(fuzzer_data.instruction_blocks); for (const auto& cfg_instruction : fuzzer_data.cfg_instructions) { @@ -28,12 +28,9 @@ SimulatorResult fuzz_against_ts_simulator(FuzzerData& fuzzer_data) SimulatorResult cpp_result; FuzzerWorldStateManager* ws_mgr = FuzzerWorldStateManager::getInstance(); - ContractDBProxy* contract_db_proxy = ContractDBProxy::get_instance(); - for (const auto& function : PREDEFINED_FUNCTIONS) { - ContractDBProxy::register_contract_from_bytecode(function); - } - auto contract_address = ContractDBProxy::register_contract_from_bytecode(bytecode); - FuzzerContractDB contract_db = *contract_db_proxy->get_contract_db(); + + auto contract_address = context.register_contract_from_bytecode(bytecode); + FuzzerContractDB contract_db = context.get_contract_db(); // Create the transaction auto tx = create_default_tx( @@ -54,7 +51,7 @@ SimulatorResult fuzz_against_ts_simulator(FuzzerData& fuzzer_data) ws_mgr->checkpoint(); auto js_result = js_simulator->simulate(*ws_mgr, contract_db, tx); - ContractDBProxy::reset_instance(); + context.reset(); // If the results does not match if (!compare_simulator_results(cpp_result, js_result)) { diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.hpp index c200a8933a6b..f936fae7989d 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.hpp @@ -1,21 +1,12 @@ #pragma once +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp" /// @brief fuzz CPP vs JS simulator with the given fuzzer data /// @param fuzzer_data the fuzzer data to use for fuzzing +/// @param context the fuzzer context for contract management /// @returns the simulator result if the results are the same /// @throws an exception if the simulator results are different -SimulatorResult fuzz_against_ts_simulator(FuzzerData& fuzzer_data); - -// Helper functions to create default contract class, instance, and tx -ContractClass create_default_class(const std::vector& bytecode); -ContractInstance create_default_instance(const ContractClassId& class_id); -AztecAddress compute_contract_address(const ContractInstance& instance); -Tx create_default_tx(const AztecAddress& contract_address, - const AztecAddress& sender_address, - const std::vector& calldata, - const FF& transaction_fee, - bool is_static_call, - const Gas& gas_limit); +SimulatorResult fuzz_against_ts_simulator(FuzzerData& fuzzer_data, bb::avm2::fuzzer::FuzzerContext& context); diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.test.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.test.cpp index 3aa248f5cf65..6564892ce424 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.test.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzz.test.cpp @@ -3,9 +3,9 @@ #include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/control_flow.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzz.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/instruction.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp" @@ -15,11 +15,11 @@ using namespace bb::avm2::fuzzer; FuzzerWorldStateManager* ws_mgr = nullptr; -void register_functions() +void register_functions(FuzzerContext& context) { for (auto& function : PREDEFINED_FUNCTIONS) { try { - ContractDBProxy::register_contract_from_bytecode(function); + context.register_contract_from_bytecode(function); } catch (...) { std::cout << "Failed to register predefined function: " << function.size() << std::endl; continue; @@ -27,63 +27,97 @@ void register_functions() } } -SimulatorResult simulate_with_default_tx(std::vector& bytecode, std::vector calldata) -{ - FuzzerWorldStateManager::initialize(); - if (ws_mgr == nullptr) { - ws_mgr = FuzzerWorldStateManager::getInstance(); +class FuzzTest : public ::testing::Test { + protected: + void SetUp() override + { + FuzzerWorldStateManager::initialize(); + if (ws_mgr == nullptr) { + ws_mgr = FuzzerWorldStateManager::getInstance(); + } + ws_mgr->fork(); + context = FuzzerContext(); + register_functions(context); } - ws_mgr->fork(); - register_functions(); + void TearDown() override { ws_mgr->reset_world_state(); } + + SimulatorResult simulate_with_default_tx(std::vector& bytecode, std::vector calldata) + { + ws_mgr->checkpoint(); - ContractDBProxy* contract_db_proxy = ContractDBProxy::get_instance(); - auto contract_address = ContractDBProxy::register_contract_from_bytecode(bytecode); - FuzzerContractDB contract_db = *contract_db_proxy->get_contract_db(); + auto contract_address = context.register_contract_from_bytecode(bytecode); + FuzzerContractDB contract_db = context.get_contract_db(); - auto tx = create_default_tx(contract_address, MSG_SENDER, calldata, TRANSACTION_FEE, IS_STATIC_CALL, GAS_LIMIT); - FF fee_required_da = FF(tx.effective_gas_fees.fee_per_da_gas) * FF(tx.gas_settings.gas_limits.da_gas); - FF fee_required_l2 = FF(tx.effective_gas_fees.fee_per_l2_gas) * FF(tx.gas_settings.gas_limits.l2_gas); - ws_mgr->write_fee_payer_balance(tx.fee_payer, fee_required_da + fee_required_l2); - auto cpp_simulator = CppSimulator(); + auto tx = create_default_tx(contract_address, MSG_SENDER, calldata, TRANSACTION_FEE, IS_STATIC_CALL, GAS_LIMIT); + FF fee_required_da = FF(tx.effective_gas_fees.fee_per_da_gas) * FF(tx.gas_settings.gas_limits.da_gas); + FF fee_required_l2 = FF(tx.effective_gas_fees.fee_per_l2_gas) * FF(tx.gas_settings.gas_limits.l2_gas); + ws_mgr->write_fee_payer_balance(tx.fee_payer, fee_required_da + fee_required_l2); + auto cpp_simulator = CppSimulator(); - ws_mgr->checkpoint(); - try { auto result = cpp_simulator.simulate(*ws_mgr, contract_db, tx); + ws_mgr->revert(); - ws_mgr->reset_world_state(); + return result; - } catch (...) { - ws_mgr->revert(); - throw; } -} -namespace arithmetic { + FuzzerContext context; +}; -// set(addr 0, 5) set(addr 1, 2) OP(addr 0, addr 1, addr 2) return(addr 2) -FF get_result_of_instruction(FuzzInstruction instruction, - bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::U8) -{ - auto set_instruction_1 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, - .result_address = AddressRef{ .address = 0 }, - .value = 5 }; - auto set_instruction_2 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, - .result_address = AddressRef{ .address = 1 }, - .value = 2 }; - auto instructions = std::vector{ set_instruction_1, set_instruction_2, instruction }; - auto return_options = - ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 2 }; - auto instruction_blocks = std::vector>{ instructions }; - auto control_flow = ControlFlow(instruction_blocks); - control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); - auto bytecode = control_flow.build_bytecode(return_options); +namespace arithmetic { +class ArithmeticFuzzTest : public FuzzTest { + protected: + // set(addr 0, 5) set(addr 1, 2) OP(addr 0, addr 1, addr 2) return(addr 2) + FF get_result_of_instruction(FuzzInstruction instruction, + bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::U8) + { + auto set_instruction_1 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, + .result_address = AddressRef{ .address = 0 }, + .value = 5 }; + auto set_instruction_2 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, + .result_address = AddressRef{ .address = 1 }, + .value = 2 }; + auto instructions = std::vector{ set_instruction_1, set_instruction_2, instruction }; + auto return_options = + ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 2 }; + auto instruction_blocks = std::vector>{ instructions }; + auto control_flow = ControlFlow(instruction_blocks); + control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); + auto bytecode = control_flow.build_bytecode(return_options); + + auto result = simulate_with_default_tx(bytecode, {}); + return result.output.at(0); + } - auto result = simulate_with_default_tx(bytecode, {}); - return result.output.at(0); -} + // Helper function for 16-bit instructions + // set(addr 0, 5) set(addr 1, 2) OP_16(addr 0, addr 1, addr 2) return(addr 2) + FF get_result_of_instruction_16(FuzzInstruction instruction, + bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::U8) + { + auto set_instruction_1 = + SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, + .result_address = AddressRef{ .address = 0, .mode = AddressingMode::Direct }, + .value = 5 }; + auto set_instruction_2 = + SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, + .result_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }, + .value = 2 }; + auto instructions = std::vector{ set_instruction_1, set_instruction_2, instruction }; + + auto return_options = + ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 2 }; + auto instruction_blocks = std::vector>{ instructions }; + auto control_flow = ControlFlow(instruction_blocks); + control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); + auto bytecode = control_flow.build_bytecode(return_options); + + auto result = simulate_with_default_tx(bytecode, {}); + return result.output.at(0); + } +}; -TEST(fuzz, ADD8) +TEST_F(ArithmeticFuzzTest, ADD8) { auto add_instruction = ADD_8_Instruction{ .a_address = @@ -99,7 +133,7 @@ TEST(fuzz, ADD8) EXPECT_EQ(result, 7); } -TEST(fuzz, SUB8) +TEST_F(ArithmeticFuzzTest, SUB8) { auto sub_instruction = SUB_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -110,7 +144,7 @@ TEST(fuzz, SUB8) EXPECT_EQ(result, 3); } -TEST(fuzz, MUL8) +TEST_F(ArithmeticFuzzTest, MUL8) { auto mul_instruction = MUL_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -121,7 +155,7 @@ TEST(fuzz, MUL8) EXPECT_EQ(result, 10); } -TEST(fuzz, DIV8) +TEST_F(ArithmeticFuzzTest, DIV8) { auto div_instruction = DIV_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -132,7 +166,7 @@ TEST(fuzz, DIV8) EXPECT_EQ(result, 2); } -TEST(fuzz, EQ8) +TEST_F(ArithmeticFuzzTest, EQ8) { auto eq_instruction = EQ_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -143,7 +177,7 @@ TEST(fuzz, EQ8) EXPECT_EQ(result, 0); } -TEST(fuzz, LT8) +TEST_F(ArithmeticFuzzTest, LT8) { auto lt_instruction = LT_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -154,7 +188,7 @@ TEST(fuzz, LT8) EXPECT_EQ(result, 0); } -TEST(fuzz, LTE8) +TEST_F(ArithmeticFuzzTest, LTE8) { auto lte_instruction = LTE_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -165,7 +199,7 @@ TEST(fuzz, LTE8) EXPECT_EQ(result, 0); } -TEST(fuzz, AND8) +TEST_F(ArithmeticFuzzTest, AND8) { auto and_instruction = AND_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -176,7 +210,7 @@ TEST(fuzz, AND8) EXPECT_EQ(result, 0); } -TEST(fuzz, OR8) +TEST_F(ArithmeticFuzzTest, OR8) { auto or_instruction = OR_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -187,7 +221,7 @@ TEST(fuzz, OR8) EXPECT_EQ(result, 7); } -TEST(fuzz, XOR8) +TEST_F(ArithmeticFuzzTest, XOR8) { auto xor_instruction = XOR_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -198,7 +232,7 @@ TEST(fuzz, XOR8) EXPECT_EQ(result, 7); } -TEST(fuzz, SHL8) +TEST_F(ArithmeticFuzzTest, SHL8) { auto shl_instruction = SHL_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -209,7 +243,7 @@ TEST(fuzz, SHL8) EXPECT_EQ(result, 20); } -TEST(fuzz, SHR8) +TEST_F(ArithmeticFuzzTest, SHR8) { auto shr_instruction = SHR_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -221,7 +255,7 @@ TEST(fuzz, SHR8) } // set(0, 4, FF) set(1, 2, FF) fdiv(FF, 0, 1, 2) return(2) -TEST(fuzz, FDIV8) +TEST_F(ArithmeticFuzzTest, FDIV8) { auto fdiv_instruction = FDIV_8_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::FF, .index = 0, .mode = AddressingMode::Direct }, @@ -250,7 +284,7 @@ TEST(fuzz, FDIV8) } // set(0, 0, U8) not(U8, 0, 1) return(1) -TEST(fuzz, NOT8) +TEST_F(ArithmeticFuzzTest, NOT8) { auto set_instruction = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, @@ -272,33 +306,7 @@ TEST(fuzz, NOT8) EXPECT_EQ(result.output.at(0), 255); } -// Helper function for 16-bit instructions -// set(addr 0, 5) set(addr 1, 2) OP_16(addr 0, addr 1, addr 2) return(addr 2) -FF get_result_of_instruction_16(FuzzInstruction instruction, - bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::U8) -{ - auto set_instruction_1 = - SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, - .result_address = AddressRef{ .address = 0, .mode = AddressingMode::Direct }, - .value = 5 }; - auto set_instruction_2 = - SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, - .result_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }, - .value = 2 }; - auto instructions = std::vector{ set_instruction_1, set_instruction_2, instruction }; - - auto return_options = - ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 2 }; - auto instruction_blocks = std::vector>{ instructions }; - auto control_flow = ControlFlow(instruction_blocks); - control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); - auto bytecode = control_flow.build_bytecode(return_options); - - auto result = simulate_with_default_tx(bytecode, {}); - return result.output.at(0); -} - -TEST(fuzz, ADD16) +TEST_F(ArithmeticFuzzTest, ADD16) { auto add_instruction = ADD_16_Instruction{ .a_address = @@ -314,7 +322,7 @@ TEST(fuzz, ADD16) EXPECT_EQ(result, 7); } -TEST(fuzz, SUB16) +TEST_F(ArithmeticFuzzTest, SUB16) { auto sub_instruction = SUB_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -325,7 +333,7 @@ TEST(fuzz, SUB16) EXPECT_EQ(result, 3); } -TEST(fuzz, MUL16) +TEST_F(ArithmeticFuzzTest, MUL16) { auto mul_instruction = MUL_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -336,7 +344,7 @@ TEST(fuzz, MUL16) EXPECT_EQ(result, 10); } -TEST(fuzz, DIV16) +TEST_F(ArithmeticFuzzTest, DIV16) { auto div_instruction = DIV_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -347,7 +355,7 @@ TEST(fuzz, DIV16) EXPECT_EQ(result, 2); } -TEST(fuzz, EQ16) +TEST_F(ArithmeticFuzzTest, EQ16) { auto eq_instruction = EQ_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -358,7 +366,7 @@ TEST(fuzz, EQ16) EXPECT_EQ(result, 0); } -TEST(fuzz, LT16) +TEST_F(ArithmeticFuzzTest, LT16) { auto lt_instruction = LT_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -369,7 +377,7 @@ TEST(fuzz, LT16) EXPECT_EQ(result, 0); } -TEST(fuzz, LTE16) +TEST_F(ArithmeticFuzzTest, LTE16) { auto lte_instruction = LTE_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -380,7 +388,7 @@ TEST(fuzz, LTE16) EXPECT_EQ(result, 0); } -TEST(fuzz, AND16) +TEST_F(ArithmeticFuzzTest, AND16) { auto and_instruction = AND_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -391,7 +399,7 @@ TEST(fuzz, AND16) EXPECT_EQ(result, 0); } -TEST(fuzz, OR16) +TEST_F(ArithmeticFuzzTest, OR16) { auto or_instruction = OR_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -402,7 +410,7 @@ TEST(fuzz, OR16) EXPECT_EQ(result, 7); } -TEST(fuzz, XOR16) +TEST_F(ArithmeticFuzzTest, XOR16) { auto xor_instruction = XOR_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -413,7 +421,7 @@ TEST(fuzz, XOR16) EXPECT_EQ(result, 7); } -TEST(fuzz, SHL16) +TEST_F(ArithmeticFuzzTest, SHL16) { auto shl_instruction = SHL_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -424,7 +432,7 @@ TEST(fuzz, SHL16) EXPECT_EQ(result, 20); } -TEST(fuzz, SHR16) +TEST_F(ArithmeticFuzzTest, SHR16) { auto shr_instruction = SHR_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::U8, .index = 0, .mode = AddressingMode::Direct }, @@ -436,7 +444,7 @@ TEST(fuzz, SHR16) } // set(0, 4, FF) set(1, 2, FF) fdiv_16(FF, 0, 1, 2) return(2) -TEST(fuzz, FDIV16) +TEST_F(ArithmeticFuzzTest, FDIV16) { auto fdiv_instruction = FDIV_16_Instruction{ .a_address = VariableRef{ .tag = bb::avm2::MemoryTag::FF, .index = 0, .mode = AddressingMode::Direct }, @@ -465,7 +473,7 @@ TEST(fuzz, FDIV16) } // set(0, 0, U8) not_16(U8, 0, 1) return(1) -TEST(fuzz, NOT16) +TEST_F(ArithmeticFuzzTest, NOT16) { auto set_instruction = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, @@ -486,13 +494,14 @@ TEST(fuzz, NOT16) auto result = simulate_with_default_tx(bytecode, {}); EXPECT_EQ(result.output.at(0), 255); } + } // namespace arithmetic namespace type_conversion { // set(10, 1, U16) set(0, 2, U8) cast_8(U8, 0, 1, U16) return(1) // if cast worked, should return 2 (the U8 value cast to U16) // if cast failed, should return 1 (the original U16 value) -TEST(fuzz, CAST8) +TEST_F(FuzzTest, CAST8) { auto set_u16 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U16, .result_address = AddressRef{ .address = 10, .mode = AddressingMode::Direct }, @@ -520,7 +529,7 @@ TEST(fuzz, CAST8) // set(10, 1, U16) set(0, 2, U8) cast_16(U8, 0, 1, U16) return(1) // if cast worked, should return 2 (the U8 value cast to U16) // if cast failed, should return 1 (the original U16 value) -TEST(fuzz, CAST16) +TEST_F(FuzzTest, CAST16) { auto set_u16 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U16, .result_address = AddressRef{ .address = 10, .mode = AddressingMode::Direct }, @@ -548,7 +557,7 @@ TEST(fuzz, CAST16) namespace machine_memory { // set(0, 0xabcd, U16) return(0) -TEST(fuzz, SET16) +TEST_F(FuzzTest, SET16) { const uint16_t test_value = 0xABCD; auto set_instruction = @@ -567,7 +576,7 @@ TEST(fuzz, SET16) EXPECT_EQ(result.output.at(0), test_value); } // set(0, 0x12345678, U32) return(0) -TEST(fuzz, SET32) +TEST_F(FuzzTest, SET32) { const uint32_t test_value = 0x12345678UL; auto set_instruction = @@ -587,7 +596,7 @@ TEST(fuzz, SET32) } // set(0, 0xabcdef0123456789, U64) return(0) -TEST(fuzz, SET64) +TEST_F(FuzzTest, SET64) { const uint64_t test_value = 0xABCDEF0123456789ULL; auto set_instruction = @@ -607,7 +616,7 @@ TEST(fuzz, SET64) } // set(0, something, U128) return(0) -TEST(fuzz, SET128) +TEST_F(FuzzTest, SET128) { const uint64_t test_value_low = 0xFEDCBA9876543210ULL; const uint64_t test_value_high = 0x123456789ABCDEF0ULL; @@ -632,7 +641,7 @@ TEST(fuzz, SET128) } // set(0, 123456789, FF) return(0) -TEST(fuzz, SETFF) +TEST_F(FuzzTest, SETFF) { const bb::avm2::FF test_value = bb::avm2::FF(123456789); auto set_instruction = @@ -652,7 +661,7 @@ TEST(fuzz, SETFF) } // set(0, 0x42, U8) set(1, 0x43, U8) mov_8(U8, 0, 1) return(1) -TEST(fuzz, MOV8) +TEST_F(FuzzTest, MOV8) { const uint8_t test_value = 0x42; const uint8_t test_value2 = 0x43; @@ -680,7 +689,7 @@ TEST(fuzz, MOV8) } // set(0, 0xbabe, U16) set(1, 0xc0fe, U16) mov_16(U16, 0, 1) return(1) -TEST(fuzz, MOV16) +TEST_F(FuzzTest, MOV16) { const uint16_t test_value = 0xbabe; const uint16_t test_value2 = 0xc0fe; @@ -712,10 +721,86 @@ TEST(fuzz, MOV16) namespace control_flow { +class ControlFlowFuzzTest : public FuzzTest { + protected: + // set u1 condition value b1 + // ↙ ↘ + // set u1 b2 return 4 + // ↙ ↘ + // ret 2 ret 3 + FF simulate_jump_if_depth_2_helper(uint8_t first_boolean_value, uint8_t second_boolean_value) + { + auto set_instruction_block_1 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, + .result_address = AddressRef{ .address = 1 }, + .value = first_boolean_value }; + auto instruction_block_1 = std::vector{ set_instruction_block_1 }; + auto set_instruction_block_2 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, + .result_address = AddressRef{ .address = 2 }, + .value = second_boolean_value }; + auto instruction_block_2 = std::vector{ set_instruction_block_2 }; + auto instruction_blocks = std::vector>{ instruction_block_1, instruction_block_2 }; + for (uint8_t i = 2; i < 5; i++) { + auto set_instruction = + SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, + .result_address = AddressRef{ .address = i, .mode = AddressingMode::Direct }, + .value = i }; + instruction_blocks.push_back({ set_instruction }); + } + auto return_options = ReturnOptions{ .return_size = 1, + .return_value_tag = bb::avm2::MemoryTag::U8, + .return_value_offset_index = 1 }; + auto control_flow = ControlFlow(instruction_blocks); + control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); + control_flow.process_cfg_instruction( + JumpIfToNewBlock{ .then_program_block_instruction_block_idx = 1, // set second boolean + .else_program_block_instruction_block_idx = 4, // set 4 + .condition_offset_index = 0 }); + control_flow.process_cfg_instruction(JumpIfToNewBlock{ .then_program_block_instruction_block_idx = 2, // set 2 + .else_program_block_instruction_block_idx = 3, // set 3 + .condition_offset_index = 1 }); + auto bytecode = control_flow.build_bytecode(return_options); + + auto result = simulate_with_default_tx(bytecode, {}); + return result.output.at(0); + } + + // set u1 condition + // ↙ ↘ + // nop ----→ return 2 + FF simulate_jump_to_block_helper(uint8_t condition_value) + { + auto set_instruction_block_1 = + SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, + .result_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }, + .value = condition_value }; + auto set_return_value_block = std::vector{ SET_8_Instruction{ + .value_tag = bb::avm2::MemoryTag::U8, + .result_address = AddressRef{ .address = 10, .mode = AddressingMode::Direct }, + .value = 2 } }; + auto instruction_block_1 = std::vector{ set_instruction_block_1 }; + auto instruction_blocks = + std::vector>{ instruction_block_1, {}, set_return_value_block }; + auto return_options = ReturnOptions{ .return_size = 1, + .return_value_tag = bb::avm2::MemoryTag::U8, + .return_value_offset_index = 1 }; + auto control_flow = ControlFlow(instruction_blocks); + control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); + control_flow.process_cfg_instruction( + JumpIfToNewBlock{ .then_program_block_instruction_block_idx = 1, // noop + .else_program_block_instruction_block_idx = 2, // set return value + .condition_offset_index = 0 }); + control_flow.process_cfg_instruction(JumpToBlock{ .target_block_idx = 2 }); + auto bytecode = control_flow.build_bytecode(return_options); + + auto result = simulate_with_default_tx(bytecode, {}); + return result.output.at(0); + } +}; + // block1 set return value 10 // ↓ // block2 set return value 11 and return return value -TEST(fuzz, JumpToNewBlockSmoke) +TEST_F(ControlFlowFuzzTest, JumpToNewBlockSmoke) { auto block1_instructions = std::vector{ SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, @@ -742,7 +827,7 @@ TEST(fuzz, JumpToNewBlockSmoke) // block2 set return value 11 // ↓ // block3 set return value 12 and return return value -TEST(fuzz, JumpToNewBlockSmoke2) +TEST_F(ControlFlowFuzzTest, JumpToNewBlockSmoke2) { auto block1_instructions = std::vector{ SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, @@ -774,7 +859,7 @@ TEST(fuzz, JumpToNewBlockSmoke2) // ↓ // block2 tries to return u8 // if blocks does not share defined variables, block2 will return 0 -TEST(fuzz, JumpToNewBlockSharesVariables) +TEST_F(ControlFlowFuzzTest, JumpToNewBlockSharesVariables) { auto block1_instructions = std::vector{ SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, @@ -796,7 +881,7 @@ TEST(fuzz, JumpToNewBlockSharesVariables) // block1 set u1 condition value // ↙ ↘ // return 11 return 12 -TEST(fuzz, JumpIfToNewBlockSmoke) +TEST_F(ControlFlowFuzzTest, JumpIfToNewBlockSmoke) { auto set_true_block = std::vector{ SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, @@ -840,47 +925,7 @@ TEST(fuzz, JumpIfToNewBlockSmoke) EXPECT_EQ(result_2.output.at(0), 12); } -// set u1 condition value b1 -// ↙ ↘ -// set u1 b2 return 4 -// ↙ ↘ -// ret 2 ret 3 -FF simulate_jump_if_depth_2_helper(uint8_t first_boolean_value, uint8_t second_boolean_value) -{ - auto set_instruction_block_1 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, - .result_address = AddressRef{ .address = 1 }, - .value = first_boolean_value }; - auto instruction_block_1 = std::vector{ set_instruction_block_1 }; - auto set_instruction_block_2 = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, - .result_address = AddressRef{ .address = 2 }, - .value = second_boolean_value }; - auto instruction_block_2 = std::vector{ set_instruction_block_2 }; - auto instruction_blocks = std::vector>{ instruction_block_1, instruction_block_2 }; - for (uint8_t i = 2; i < 5; i++) { - auto set_instruction = - SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U8, - .result_address = AddressRef{ .address = i, .mode = AddressingMode::Direct }, - .value = i }; - instruction_blocks.push_back({ set_instruction }); - } - auto return_options = - ReturnOptions{ .return_size = 1, .return_value_tag = bb::avm2::MemoryTag::U8, .return_value_offset_index = 1 }; - auto control_flow = ControlFlow(instruction_blocks); - control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); - control_flow.process_cfg_instruction( - JumpIfToNewBlock{ .then_program_block_instruction_block_idx = 1, // set second boolean - .else_program_block_instruction_block_idx = 4, // set 4 - .condition_offset_index = 0 }); - control_flow.process_cfg_instruction(JumpIfToNewBlock{ .then_program_block_instruction_block_idx = 2, // set 2 - .else_program_block_instruction_block_idx = 3, // set 3 - .condition_offset_index = 1 }); - auto bytecode = control_flow.build_bytecode(return_options); - - auto result = simulate_with_default_tx(bytecode, {}); - return result.output.at(0); -} - -TEST(fuzz, JumpIfDepth2Smoke) +TEST_F(ControlFlowFuzzTest, JumpIfDepth2Smoke) { EXPECT_EQ(simulate_jump_if_depth_2_helper(1, 1), 2); EXPECT_EQ(simulate_jump_if_depth_2_helper(1, 0), 3); @@ -888,38 +933,7 @@ TEST(fuzz, JumpIfDepth2Smoke) EXPECT_EQ(simulate_jump_if_depth_2_helper(0, 0), 4); } -// set u1 condition -// ↙ ↘ -// nop ----→ return 2 -FF simulate_jump_to_block_helper(uint8_t condition_value) -{ - auto set_instruction_block_1 = - SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::U1, - .result_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }, - .value = condition_value }; - auto set_return_value_block = std::vector{ SET_8_Instruction{ - .value_tag = bb::avm2::MemoryTag::U8, - .result_address = AddressRef{ .address = 10, .mode = AddressingMode::Direct }, - .value = 2 } }; - auto instruction_block_1 = std::vector{ set_instruction_block_1 }; - auto instruction_blocks = - std::vector>{ instruction_block_1, {}, set_return_value_block }; - auto return_options = - ReturnOptions{ .return_size = 1, .return_value_tag = bb::avm2::MemoryTag::U8, .return_value_offset_index = 1 }; - auto control_flow = ControlFlow(instruction_blocks); - control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); - control_flow.process_cfg_instruction( - JumpIfToNewBlock{ .then_program_block_instruction_block_idx = 1, // noop - .else_program_block_instruction_block_idx = 2, // set return value - .condition_offset_index = 0 }); - control_flow.process_cfg_instruction(JumpToBlock{ .target_block_idx = 2 }); - auto bytecode = control_flow.build_bytecode(return_options); - - auto result = simulate_with_default_tx(bytecode, {}); - return result.output.at(0); -} - -TEST(fuzz, JumpToBlockSmoke) +TEST_F(ControlFlowFuzzTest, JumpToBlockSmoke) { EXPECT_EQ(simulate_jump_to_block_helper(1), 2); EXPECT_EQ(simulate_jump_to_block_helper(0), 2); @@ -930,7 +944,7 @@ TEST(fuzz, JumpToBlockSmoke) // set u1 condition value // ↙ ↘ // set FF, ret set U128, ret -TEST(fuzz, JumpIfToNewBlockWithReturn) +TEST_F(ControlFlowFuzzTest, JumpIfToNewBlockWithReturn) { // Block 0: Set condition (U1) auto set_condition_block = std::vector{ SET_8_Instruction{ @@ -1027,7 +1041,7 @@ TEST(fuzz, JumpIfToNewBlockWithReturn) } // namespace control_flow namespace public_storage { -TEST(fuzz, SstoreThenSload) +TEST_F(FuzzTest, SstoreThenSload) { // M[10] = 10 auto set_value_instruction = @@ -1070,30 +1084,32 @@ TEST(fuzz, SstoreThenSload) } // namespace public_storage namespace execution_environment { -FF getenvvar_helper(uint8_t type, bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::FF) -{ - auto getenvvar_instruction = - GETENVVAR_Instruction{ .result_address = AddressRef{ .address = 0, .mode = AddressingMode::Direct }, - .type = type }; - auto instruction_blocks = std::vector>{ { getenvvar_instruction } }; - auto control_flow = ControlFlow(instruction_blocks); - control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); - auto return_options = - ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 0 }; - auto bytecode = control_flow.build_bytecode(return_options); - - auto result = simulate_with_default_tx(bytecode, {}); - return result.output.at(0); -} +class ExecutionEnvironmentFuzzTest : public FuzzTest { + protected: + FF getenvvar_helper(uint8_t type, bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::FF) + { + auto getenvvar_instruction = + GETENVVAR_Instruction{ .result_address = AddressRef{ .address = 0, .mode = AddressingMode::Direct }, + .type = type }; + auto instruction_blocks = std::vector>{ { getenvvar_instruction } }; + auto control_flow = ControlFlow(instruction_blocks); + control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); + auto return_options = + ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 0 }; + auto bytecode = control_flow.build_bytecode(return_options); + + auto result = simulate_with_default_tx(bytecode, {}); + return result.output.at(0); + } +}; -TEST(fuzz, GetEnvVarSmoke) +TEST_F(ExecutionEnvironmentFuzzTest, GetEnvVarSmoke) { - EXPECT_EQ( - getenvvar_helper(0), - FF("0x02fea672ef18fe4b8d13dcfd8943797c99b9885da7b338d224dd5136a0cc8a6f")); // address with bytecode commitment - EXPECT_EQ(getenvvar_helper(1), MSG_SENDER); // sender, see simulator.cpp globals - EXPECT_EQ(getenvvar_helper(2), TRANSACTION_FEE); // transaction fee, see simulator.cpp globals + EXPECT_EQ(getenvvar_helper(0), + FF("0x02fea672ef18fe4b8d13dcfd8943797c99b9885da7b338d224dd5136a0cc8a6f")); // address with bytecode + EXPECT_EQ(getenvvar_helper(1), MSG_SENDER); // sender, see simulator.cpp + EXPECT_EQ(getenvvar_helper(2), TRANSACTION_FEE); // transaction fee, see simulator.cpp EXPECT_EQ(getenvvar_helper(3), CHAIN_ID); // chain id, see simulator.cpp globals EXPECT_EQ(getenvvar_helper(4), VERSION); // version, see simulator.cpp globals EXPECT_EQ(getenvvar_helper(5), BLOCK_NUMBER); // block number, see simulator.cpp globals @@ -1107,7 +1123,7 @@ TEST(fuzz, GetEnvVarSmoke) } // namespace execution_environment namespace notes_and_nullifiers { -TEST(fuzz, EmitNullifierThenNullifierExists) +TEST_F(FuzzTest, EmitNullifierThenNullifierExists) { auto set_field_instruction = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1132,7 +1148,7 @@ TEST(fuzz, EmitNullifierThenNullifierExists) EXPECT_EQ(result.output.at(0), 1); } -TEST(fuzz, EmitNullifierThenNullifierExistsOverwritingPreviousNullifier) +TEST_F(FuzzTest, EmitNullifierThenNullifierExistsOverwritingPreviousNullifier) { auto set_field_instruction = SET_8_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1157,7 +1173,7 @@ TEST(fuzz, EmitNullifierThenNullifierExistsOverwritingPreviousNullifier) EXPECT_EQ(result.output.at(0), 0); } -TEST(fuzz, EmitNoteHashThenNoteHashExists) +TEST_F(FuzzTest, EmitNoteHashThenNoteHashExists) { auto emit_note_hash_instruction = EMITNOTEHASH_Instruction{ .note_hash_address = AddressRef{ .address = 0, .mode = AddressingMode::Direct }, @@ -1185,7 +1201,7 @@ TEST(fuzz, EmitNoteHashThenNoteHashExists) } // namespace notes_and_nullifiers namespace calldata_returndata { -TEST(fuzz, CopyCalldataThenReturnData) +TEST_F(FuzzTest, CopyCalldataThenReturnData) { auto calldatacopy_instruction = CALLDATACOPY_Instruction{ .dst_address = AddressRef{ .address = 0 }, .copy_size = 1, @@ -1203,7 +1219,7 @@ TEST(fuzz, CopyCalldataThenReturnData) } // call internal function overwrites memory address -TEST(fuzz, InternalCall) +TEST_F(FuzzTest, InternalCall) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1229,7 +1245,7 @@ TEST(fuzz, InternalCall) namespace internal_calls { // check if internal call does not halt execution on return -TEST(fuzz, InternalCalledBlockUsesInternalReturn) +TEST_F(FuzzTest, InternalCalledBlockUsesInternalReturn) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1259,7 +1275,7 @@ TEST(fuzz, InternalCalledBlockUsesInternalReturn) // SSTORE(0, 1337); call f1; return SLOAD(0); // f1: SSTORE(0, 31337); call f2; INTERNALRETURN // f2: SSTORE(0, 313373); INTERNALRETURN -TEST(fuzz, SeveralInternalCalls) +TEST_F(FuzzTest, SeveralInternalCalls) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1305,7 +1321,7 @@ TEST(fuzz, SeveralInternalCalls) /// f1: SSTORE(0, 1337); call f2; SSTORE(0, 1337); INTERNALRETURN /// f2: SSTORE(0, 31337); INTERNALRETURN /// f3: SSTORE(0, 313373); INTERNALRETURN -TEST(fuzz, Reentrancy) +TEST_F(FuzzTest, Reentrancy) { auto set_field_instruction0 = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1359,7 +1375,7 @@ TEST(fuzz, Reentrancy) } // namespace internal_calls namespace avm_addressing { -TEST(fuzz, DirectWithIndirect) +TEST_F(FuzzTest, DirectWithIndirect) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1387,7 +1403,7 @@ TEST(fuzz, DirectWithIndirect) EXPECT_EQ(result.output.at(0), 30); } -TEST(fuzz, DirectWithIndirectRelative) +TEST_F(FuzzTest, DirectWithIndirectRelative) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1416,7 +1432,7 @@ TEST(fuzz, DirectWithIndirectRelative) EXPECT_EQ(result.output.at(0), 30); } -TEST(fuzz, IndirectResultCanBeUsedInNextInstruction) +TEST_F(FuzzTest, IndirectResultCanBeUsedInNextInstruction) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1442,7 +1458,7 @@ TEST(fuzz, IndirectResultCanBeUsedInNextInstruction) EXPECT_EQ(result.output.at(0), 400); } -TEST(fuzz, Memoryaddressing32BitWidth) +TEST_F(FuzzTest, Memoryaddressing32BitWidth) { auto set_field_instruction = SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, @@ -1474,7 +1490,7 @@ TEST(fuzz, Memoryaddressing32BitWidth) namespace misc { // TODO(defkit): get info from world state to be sure that the message will be sent / log emitted -TEST(fuzz, SendL2ToL1Msg) +TEST_F(FuzzTest, SendL2ToL1Msg) { auto sendl2tol1msg_instruction = SENDL2TOL1MSG_Instruction{ .recipient = 100, @@ -1490,7 +1506,7 @@ TEST(fuzz, SendL2ToL1Msg) EXPECT_EQ(result.reverted, false); } -TEST(fuzz, EmitUnencryptedLog) +TEST_F(FuzzTest, EmitUnencryptedLog) { auto log_size_address = AddressRef{ .address = 0, .mode = AddressingMode::Direct }; auto log_values_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }; @@ -1520,12 +1536,37 @@ TEST(fuzz, EmitUnencryptedLog) namespace external_calls { +class ExternalCallsFuzzTest : public FuzzTest { + protected: + FF get_contract_instance_helper(uint8_t member_enum, bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::FF) + { + FF address = context.get_contract_address(0); + std::vector instructions; + instructions.push_back( + SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, + .result_address = AddressRef{ .address = 123, .mode = AddressingMode::Direct }, + .value = address }); + instructions.push_back(GETCONTRACTINSTANCE_Instruction{ + .contract_address_address = AddressRef{ .address = 123, .mode = AddressingMode::Direct }, + .member_enum = member_enum, + .dst_address = AddressRef{ .address = 124, .mode = AddressingMode::Direct } }); + + auto instruction_blocks = std::vector>{ instructions }; + auto control_flow = ControlFlow(instruction_blocks); + control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); + auto bytecode = control_flow.build_bytecode( + ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 1 }); + auto result = simulate_with_default_tx(bytecode, {}); + return result.output.at(0); + } +}; + /// call(ADD8), returndatacopy, return /// ADD8: 1 + 1 -TEST(fuzz, ExternalCallToAdd8) +TEST_F(ExternalCallsFuzzTest, ExternalCallToAdd8) { std::vector instructions; - auto contract_address = bb::avm2::fuzzer::ContractDBProxy::get_instance()->get_function_address(0); + auto contract_address = context.get_contract_address(0); AddressRef contract_address_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }; instructions.push_back(SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, .result_address = contract_address_address, .value = contract_address }); @@ -1564,25 +1605,7 @@ TEST(fuzz, ExternalCallToAdd8) EXPECT_EQ(result.output.at(0), 2); } -FF get_contract_instance_helper(uint8_t member_enum, bb::avm2::MemoryTag return_value_tag = bb::avm2::MemoryTag::FF) -{ - auto get_contract_instance_instruction = - GETCONTRACTINSTANCE_Instruction{ .contract_index = 0, - .contract_address_address = - AddressRef{ .address = 123, .mode = AddressingMode::Direct }, - .dst_address = AddressRef{ .address = 124, .mode = AddressingMode::Direct }, - .member_enum = member_enum }; - - auto instruction_blocks = std::vector>{ { get_contract_instance_instruction } }; - auto control_flow = ControlFlow(instruction_blocks); - control_flow.process_cfg_instruction(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); - auto bytecode = control_flow.build_bytecode( - ReturnOptions{ .return_size = 1, .return_value_tag = return_value_tag, .return_value_offset_index = 1 }); - auto result = simulate_with_default_tx(bytecode, {}); - return result.output.at(0); -} - -TEST(fuzz, GetContractInstance) +TEST_F(ExternalCallsFuzzTest, GetContractInstance) { EXPECT_EQ(get_contract_instance_helper(0), @@ -1595,10 +1618,10 @@ TEST(fuzz, GetContractInstance) } // Calls add8, sucesscopy, return -TEST(fuzz, SuccessCopy) +TEST_F(ExternalCallsFuzzTest, SuccessCopy) { std::vector instructions; - auto contract_address = bb::avm2::fuzzer::ContractDBProxy::get_instance()->get_function_address(0); + auto contract_address = context.get_contract_address(0); AddressRef contract_address_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }; instructions.push_back(SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, .result_address = contract_address_address, .value = contract_address }); @@ -1639,10 +1662,10 @@ TEST(fuzz, SuccessCopy) // Performs static call to ZERO_DIVISION, SUCCESSCOPY, RETURN // The result should be 0 -TEST(fuzz, CallToZeroDivisionSuccessCopy) +TEST_F(ExternalCallsFuzzTest, CallToZeroDivisionSuccessCopy) { std::vector instructions; - auto contract_address = bb::avm2::fuzzer::ContractDBProxy::get_instance()->get_function_address(1); + auto contract_address = context.get_contract_address(1); AddressRef contract_address_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }; instructions.push_back(SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, .result_address = contract_address_address, .value = contract_address }); @@ -1681,10 +1704,10 @@ TEST(fuzz, CallToZeroDivisionSuccessCopy) } /// Performs static call to SSTORE_FUNCTION, SUCCESSCOPY, RETURN -TEST(fuzz, StaticCallToNonStaticFunctionSuccessCopy) +TEST_F(ExternalCallsFuzzTest, StaticCallToNonStaticFunctionSuccessCopy) { std::vector instructions; - auto contract_address = bb::avm2::fuzzer::ContractDBProxy::get_instance()->get_function_address(2); + auto contract_address = context.get_contract_address(2); AddressRef contract_address_address = AddressRef{ .address = 1, .mode = AddressingMode::Direct }; instructions.push_back(SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, .result_address = contract_address_address, .value = contract_address }); diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.cpp new file mode 100644 index 000000000000..04884770d3f7 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.cpp @@ -0,0 +1,80 @@ +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" + +#include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" +#include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" +#include "barretenberg/vm2/simulation/lib/contract_crypto.hpp" + +namespace bb::avm2::fuzzer { + +namespace { + +// Helper function to create a default contract class from bytecode +ContractClass create_default_class(const std::vector& bytecode) +{ + // This isn't strictly needed for pure simulation, but if we want to re-use inputs in proving we need valid + // commitment + auto bytecode_commitment = simulation::compute_public_bytecode_commitment(bytecode); + auto class_id = + simulation::compute_contract_class_id(/*artifact_hash=*/0, /*private_fn_root=*/0, bytecode_commitment); + return ContractClass{ + .id = class_id, + .artifact_hash = 0, + .private_functions_root = 0, + .packed_bytecode = bytecode, + }; +} + +// Helper function to create a default contract instance from a class ID +ContractInstance create_default_instance(const ContractClassId& class_id) +{ + // To avoid Assertion failed: (contract_instance.public_keys.incoming_viewing_key.on_curve()) + auto affine_one = grumpkin::g1::affine_one; + return ContractInstance{ + .salt = 0, + .deployer = MSG_SENDER, + .current_contract_class_id = class_id, + .original_contract_class_id = class_id, + .initialization_hash = 0, + .public_keys = + PublicKeys{ + .nullifier_key = affine_one, + .incoming_viewing_key = affine_one, + .outgoing_viewing_key = affine_one, + .tagging_key = affine_one, + }, + }; +} + +} // anonymous namespace + +FF FuzzerContext::register_contract_from_bytecode(const std::vector& bytecode) +{ + auto default_class = create_default_class(bytecode); + auto default_instance = create_default_instance(default_class.id); + auto contract_address = simulation::compute_contract_address(default_instance); + + contract_db_->add_contract_class(default_class.id, default_class); + contract_db_->add_contract_instance(contract_address, default_instance); + contract_addresses_.push_back(contract_address); + + try { + FuzzerWorldStateManager::getInstance()->register_contract_address(contract_address); + } catch (const std::exception& e) { + std::string msg = e.what(); + // Ignore duplicates, the contract is already registered + if (msg.find("is already present") == std::string::npos) { + // Re-throw other errors + throw e; + } + } + return contract_address; +} + +void FuzzerContext::reset() +{ + contract_addresses_.clear(); + contract_db_ = std::make_unique(); +} + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp new file mode 100644 index 000000000000..30126a7e2728 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp @@ -0,0 +1,61 @@ +/// FuzzerContext holds environment data for fuzzer instruction generation and contract management. +/// Top-level fuzzers create and modify this context, but it's passed as const& to +/// instruction generation functions (read-only access during generation). + +#pragma once + +#include +#include + +#include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" +#include "barretenberg/vm2/common/field.hpp" + +namespace bb::avm2::fuzzer { + +class FuzzerContext { + public: + FuzzerContext() + : contract_db_(std::make_unique()) + {} + + // ---- Mutable API (for top-level fuzzers) ---- + + /// @brief Register a contract from its bytecode + /// @param bytecode The bytecode of the contract + /// @return The address of the registered contract + /// @note This function will also register the contract address in the world state + FF register_contract_from_bytecode(const std::vector& bytecode); + + /// @brief Add a contract address to the context (without registering a contract) + void add_contract_address(FF address) { contract_addresses_.push_back(address); } + + /// @brief Clear all contract addresses and reset the contract DB + void reset(); + + // ---- Const API (for instruction generation, passed as const&) ---- + + /// @brief Get a contract address by index (wraps around using modulo) + /// @return The contract address, or FF::zero() if no contracts registered + FF get_contract_address(size_t index) const + { + if (contract_addresses_.empty()) { + return FF::zero(); + } + return contract_addresses_[index % contract_addresses_.size()]; + } + + /// @brief Check if any contracts are registered + bool has_contracts() const { return !contract_addresses_.empty(); } + + /// @brief Get the number of registered contracts + size_t contract_count() const { return contract_addresses_.size(); } + + /// @brief Get the contract database for simulation + FuzzerContractDB& get_contract_db() const { return *contract_db_; } + + private: + std::vector contract_addresses_; + std::unique_ptr contract_db_; +}; + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/program_block.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/program_block.cpp index f0469df60c64..c7122b26eb3e 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/program_block.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/program_block.cpp @@ -1,6 +1,5 @@ #include "barretenberg/avm_fuzzer/fuzz_lib/program_block.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/instruction.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/instruction_settings.hpp" #include "barretenberg/vm2/common/memory_types.hpp" diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.cpp index 2b93b296868d..398ab6764cbf 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.cpp @@ -19,6 +19,7 @@ #include "barretenberg/vm2/common/opcodes.hpp" #include "barretenberg/vm2/common/stringify.hpp" #include "barretenberg/vm2/simulation/interfaces/db.hpp" +#include "barretenberg/vm2/simulation/lib/contract_crypto.hpp" #include "barretenberg/vm2/simulation/lib/serialization.hpp" #include "barretenberg/vm2/simulation_helper.hpp" #include "barretenberg/world_state/types.hpp" @@ -30,7 +31,9 @@ using namespace bb::avm2::simulation; using namespace bb::avm2::fuzzer; using namespace bb::world_state; -// Helper function to serialize simulation request via +const auto MAX_RETURN_DATA_SIZE_IN_FIELDS = 1024; + +// Helper function to serialize simulation request via msgpack std::string serialize_simulation_request(const Tx& tx, const GlobalVariables& globals, const FuzzerContractDB& contract_db) @@ -78,6 +81,9 @@ SimulatorResult CppSimulator::simulate(fuzzer::FuzzerWorldStateManager& ws_mgr, .skip_fee_enforcement = false, .collect_call_metadata = true, .collect_public_inputs = true, + .collection_limits = { + .max_returndata_size_in_fields = MAX_RETURN_DATA_SIZE_IN_FIELDS, + }, }; ProtocolContracts protocol_contracts{}; @@ -163,8 +169,61 @@ SimulatorResult JsSimulator::simulate([[maybe_unused]] fuzzer::FuzzerWorldStateM return result; } -bool compare_simulator_results(const SimulatorResult& result1, const SimulatorResult& result2) +bool compare_simulator_results(SimulatorResult& result1, SimulatorResult& result2) { + // Since the simulator results are interchangeable between TS and C++, we limit the return data size for comparison + // todo(ilyas): we ideally specfify one param as the TS result and truncate only that one + if (result1.output.size() > MAX_RETURN_DATA_SIZE_IN_FIELDS) { + result1.output.resize(MAX_RETURN_DATA_SIZE_IN_FIELDS); + } + if (result2.output.size() > MAX_RETURN_DATA_SIZE_IN_FIELDS) { + result2.output.resize(MAX_RETURN_DATA_SIZE_IN_FIELDS); + } + return result1.reverted == result2.reverted && result1.output == result2.output && result1.end_tree_snapshots == result2.end_tree_snapshots; } + +// Creates a default transaction that the single app logic enqueued call can be inserted into +Tx create_default_tx(const AztecAddress& contract_address, + const AztecAddress& sender_address, + const std::vector& calldata, + [[maybe_unused]] const FF& transaction_fee, + bool is_static_call, + const Gas& gas_limit) +{ + return Tx{ + .hash = TRANSACTION_HASH, + .gas_settings = GasSettings{ + .gas_limits = gas_limit, + .max_fees_per_gas = GasFees{ .fee_per_da_gas = FEE_PER_DA_GAS, .fee_per_l2_gas = FEE_PER_L2_GAS }, + }, + .effective_gas_fees = EFFECTIVE_GAS_FEES, + .non_revertible_accumulated_data = AccumulatedData{ + .note_hashes = NON_REVERTIBLE_ACCUMULATED_DATA_NOTE_HASHES, + // This nullifier is needed to make the nonces for note hashes and expected by simulation_helper + .nullifiers = NON_REVERTIBLE_ACCUMULATED_DATA_NULLIFIERS, + .l2_to_l1_messages = NON_REVERTIBLE_ACCUMULATED_DATA_L2_TO_L1_MESSAGES, + }, + .revertible_accumulated_data = AccumulatedData{ + .note_hashes = REVERTIBLE_ACCUMULATED_DATA_NOTE_HASHES, + .nullifiers = REVERTIBLE_ACCUMULATED_DATA_NULLIFIERS, + .l2_to_l1_messages = REVERTIBLE_ACCUMULATED_DATA_L2_TO_L1_MESSAGES, + }, + .setup_enqueued_calls = SETUP_ENQUEUED_CALLS, + .app_logic_enqueued_calls = { + PublicCallRequestWithCalldata{ + .request = PublicCallRequest{ + .msg_sender = MSG_SENDER, + .contract_address = contract_address, + .is_static_call = is_static_call, + .calldata_hash = compute_calldata_hash(calldata), + }, + .calldata = calldata, + }, + }, + .teardown_enqueued_call = TEARDOWN_ENQUEUED_CALLS, + .gas_used_by_private = GAS_USED_BY_PRIVATE, + .fee_payer = sender_address, + }; +} diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp index 57d4c68fb05c..27e53dd05607 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp @@ -91,6 +91,6 @@ Tx create_default_tx(const AztecAddress& contract_address, bool is_static_call, const Gas& gas_limit); -bool compare_simulator_results(const SimulatorResult& result1, const SimulatorResult& result2); +bool compare_simulator_results(SimulatorResult& result1, SimulatorResult& result2); GlobalVariables create_default_globals(); diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.cpp index 03a29d1e4371..bac52c7b9904 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.cpp @@ -185,9 +185,9 @@ int fuzz_prover(FuzzerWorldStateManager& ws_mgr, FuzzerContractDB& contract_db, } // Initialize FuzzerTxData with sensible defaults -FuzzerTxData create_default_tx_data(std::mt19937_64& rng) +FuzzerTxData create_default_tx_data(std::mt19937_64& rng, const FuzzerContext& context) { - FuzzerData fuzzer_data = generate_fuzzer_data(rng); + FuzzerData fuzzer_data = generate_fuzzer_data(rng, context); FuzzerTxData tx_data = { .input_programs = { fuzzer_data }, .tx = create_default_tx(MSG_SENDER, MSG_SENDER, {}, TRANSACTION_FEE, IS_STATIC_CALL, GAS_LIMIT), @@ -205,10 +205,10 @@ FuzzerTxData create_default_tx_data(std::mt19937_64& rng) return tx_data; } -FuzzerTxData create_default_tx_data() +FuzzerTxData create_default_tx_data(const FuzzerContext& context) { std::mt19937_64 rng(0); - return create_default_tx_data(rng); + return create_default_tx_data(rng, context); } ContractArtifacts build_bytecode_and_artifacts(FuzzerData& fuzzer_data) @@ -243,7 +243,8 @@ ContractArtifacts build_bytecode_and_artifacts(FuzzerData& fuzzer_data) return { bytecode, contract_class, contract_instance }; } -size_t mutate_tx_data(uint8_t* serialized_fuzzer_data, +size_t mutate_tx_data(FuzzerContext& context, + uint8_t* serialized_fuzzer_data, size_t serialized_fuzzer_data_size, size_t max_size, unsigned int seed) @@ -256,13 +257,13 @@ size_t mutate_tx_data(uint8_t* serialized_fuzzer_data, .convert(tx_data); } catch (const std::exception&) { fuzz_info("Failed to deserialize input in CustomMutator, creating default FuzzerTxData"); - tx_data = create_default_tx_data(rng); + tx_data = create_default_tx_data(rng, context); } // Mutate the fuzzer data multiple times for better bytecode variety auto num_mutations = std::uniform_int_distribution(1, 5)(rng); for (uint8_t i = 0; i < num_mutations; i++) { - mutate_fuzzer_data_vec(tx_data.input_programs, rng, 64); + mutate_fuzzer_data_vec(context, tx_data.input_programs, rng, 64); } // Build up bytecodes, contract classes and instances from the fuzzer data diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.hpp index b715ad29e9e4..b946f8ed2a76 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/fuzzer_lib.hpp @@ -6,6 +6,7 @@ #include #include "barretenberg/avm_fuzzer/common/interfaces/dbs.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/simulator.hpp" #include "barretenberg/serialize/msgpack_impl.hpp" @@ -47,6 +48,7 @@ inline std::ostream& operator<<(std::ostream& os, const FuzzerTxData& data) using Bytecode = std::vector; using ContractArtifacts = std::tuple; +using FuzzerContext = bb::avm2::fuzzer::FuzzerContext; // Mutation configuration enum class TxDataMutationType : uint8_t { @@ -63,8 +65,8 @@ enum class TxDataMutationType : uint8_t { ContractArtifacts build_bytecode_and_artifacts(FuzzerData& fuzzer_data); // Create a default FuzzerTxData with sensible defaults -FuzzerTxData create_default_tx_data(std::mt19937_64& rng); -FuzzerTxData create_default_tx_data(); +FuzzerTxData create_default_tx_data(std::mt19937_64& rng, const FuzzerContext& context); +FuzzerTxData create_default_tx_data(const FuzzerContext& context); // Setup fuzzer state: register contracts and addresses in the world state void setup_fuzzer_state(bb::avm2::fuzzer::FuzzerWorldStateManager& ws_mgr, @@ -87,7 +89,8 @@ int fuzz_prover(bb::avm2::fuzzer::FuzzerWorldStateManager& ws_mgr, // Common custom mutator logic shared between fuzzers // Returns the new size of the mutated data, or 0 if mutation failed -size_t mutate_tx_data(uint8_t* serialized_fuzzer_data, +size_t mutate_tx_data(FuzzerContext& context, + uint8_t* serialized_fuzzer_data, size_t serialized_fuzzer_data_size, size_t max_size, unsigned int seed); diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp index af9ead637c00..06ab48f78f5e 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include @@ -16,10 +15,8 @@ /// @brief Insert a random element at a random index struct RandomInsertion { - template - static void mutate(std::mt19937_64& rng, - std::vector& vec, - std::function generate_random_element_function) + template + static void mutate(std::mt19937_64& rng, std::vector& vec, GenerateFn&& generate_random_element_function) { T element = generate_random_element_function(rng); if (!vec.empty()) { @@ -59,10 +56,8 @@ struct RandomSwap { /// @brief Mutate a random element at a random index struct RandomElementMutation { - template - static void mutate(std::mt19937_64& rng, - std::vector& vec, - std::function mutate_element_function) + template + static void mutate(std::mt19937_64& rng, std::vector& vec, MutateFn&& mutate_element_function) { if (!vec.empty()) { std::uniform_int_distribution dist(0, vec.size() - 1); @@ -72,23 +67,23 @@ struct RandomElementMutation { } }; -template +template void mutate_vec(std::vector& vec, std::mt19937_64& rng, - std::function mutate_element_function, - std::function generate_random_element_function, + MutateFn&& mutate_element_function, + GenerateFn&& generate_random_element_function, const VecMutationConfig& config) { // If vector is empty, force insertion (other mutations do nothing on empty vectors) if (vec.empty()) { - RandomInsertion::mutate(rng, vec, generate_random_element_function); + RandomInsertion::mutate(rng, vec, std::forward(generate_random_element_function)); return; } VecMutationOptions option = config.select(rng); switch (option) { case VecMutationOptions::Insertion: - RandomInsertion::mutate(rng, vec, generate_random_element_function); + RandomInsertion::mutate(rng, vec, std::forward(generate_random_element_function)); break; case VecMutationOptions::Deletion: RandomDeletion::mutate(rng, vec); @@ -97,7 +92,7 @@ void mutate_vec(std::vector& vec, RandomSwap::mutate(rng, vec); break; case VecMutationOptions::ElementMutation: - RandomElementMutation::mutate(rng, vec, mutate_element_function); + RandomElementMutation::mutate(rng, vec, std::forward(mutate_element_function)); break; } } diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.cpp index e833450812a4..5cabde405103 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.cpp @@ -10,9 +10,11 @@ #include "barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp" #include "barretenberg/vm2/common/tagged_value.hpp" +namespace bb::avm2::fuzzer { + using ValueTag = bb::avm2::ValueTag; -void mutate_fuzzer_data(FuzzerData& fuzzer_data, std::mt19937_64& rng) +void mutate_fuzzer_data(FuzzerData& fuzzer_data, std::mt19937_64& rng, const FuzzerContext& context) { auto num_of_mutation = std::uniform_int_distribution(0, MAX_MUTATION_NUM)(rng); for (uint8_t i = 0; i < num_of_mutation; i++) { @@ -20,11 +22,14 @@ void mutate_fuzzer_data(FuzzerData& fuzzer_data, std::mt19937_64& rng) auto mutation_config = BASIC_FUZZER_DATA_MUTATION_CONFIGURATION.select(rng); switch (mutation_config) { case FuzzerDataMutationOptions::InstructionMutation: - mutate_vec>(fuzzer_data.instruction_blocks, - rng, - mutate_instruction_block, - generate_instruction_block, - BASIC_VEC_MUTATION_CONFIGURATION); + mutate_vec>( + fuzzer_data.instruction_blocks, + rng, + [&context](std::vector& block, std::mt19937_64& r) { + mutate_instruction_block(block, r, context); + }, + [&context](std::mt19937_64& r) { return generate_instruction_block(r, context); }, + BASIC_VEC_MUTATION_CONFIGURATION); break; case FuzzerDataMutationOptions::ControlFlowCommandMutation: mutate_control_flow_vec(fuzzer_data.cfg_instructions, rng); @@ -44,7 +49,7 @@ void mutate_fuzzer_data(FuzzerData& fuzzer_data, std::mt19937_64& rng) } } -void add_default_instruction_block_if_empty(FuzzerData& fuzzer_data, std::mt19937_64& rng) +void add_default_instruction_block_if_empty(FuzzerData& fuzzer_data, std::mt19937_64& rng, const FuzzerContext& context) { if (fuzzer_data.instruction_blocks.empty()) { std::vector instruction_block; @@ -63,16 +68,18 @@ void add_default_instruction_block_if_empty(FuzzerData& fuzzer_data, std::mt1993 .value = 1, }); } - auto preamble = generate_instruction_block(rng); + auto preamble = generate_instruction_block(rng, context); instruction_block.insert(instruction_block.end(), preamble.begin(), preamble.end()); fuzzer_data.instruction_blocks.push_back(instruction_block); fuzzer_data.cfg_instructions.push_back(InsertSimpleInstructionBlock{ .instruction_block_idx = 0 }); } } -FuzzerData generate_fuzzer_data(std::mt19937_64& rng) +FuzzerData generate_fuzzer_data(std::mt19937_64& rng, const FuzzerContext& context) { FuzzerData fuzzer_data = FuzzerData(); - add_default_instruction_block_if_empty(fuzzer_data, rng); + add_default_instruction_block_if_empty(fuzzer_data, rng, context); return fuzzer_data; } + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.hpp index 090b9e0e2340..a8f0e51e0843 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/fuzzer_data.hpp @@ -2,8 +2,15 @@ #include +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" -void mutate_fuzzer_data(FuzzerData& fuzzer_data, std::mt19937_64& rng); -FuzzerData generate_fuzzer_data(std::mt19937_64& rng); -void add_default_instruction_block_if_empty(FuzzerData& fuzzer_data, std::mt19937_64& rng); +namespace bb::avm2::fuzzer { + +void mutate_fuzzer_data(FuzzerData& fuzzer_data, std::mt19937_64& rng, const FuzzerContext& context); +FuzzerData generate_fuzzer_data(std::mt19937_64& rng, const FuzzerContext& context); +void add_default_instruction_block_if_empty(FuzzerData& fuzzer_data, + std::mt19937_64& rng, + const FuzzerContext& context); + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.cpp index c0821668af3a..eafaa168f34f 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.cpp @@ -1,6 +1,6 @@ #include "barretenberg/avm_fuzzer/fuzz_lib/instruction.hpp" -#include "barretenberg/avm_fuzzer/fuzz_lib/contract_db_proxy.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/mutations/basic_types/field.hpp" #include "barretenberg/avm_fuzzer/mutations/basic_types/memory_tag.hpp" #include "barretenberg/avm_fuzzer/mutations/basic_types/uint16_t.hpp" @@ -448,7 +448,8 @@ std::vector generate_emitunencryptedlog_instruction(std::mt1993 return instructions; } -std::vector generate_call_instruction(std::mt19937_64& rng) +std::vector generate_call_instruction(std::mt19937_64& rng, + const bb::avm2::fuzzer::FuzzerContext& context) { // 80% chance to use backfill (4 out of 5) to increase success rate bool use_backfill = std::uniform_int_distribution(0, 4)(rng) != 0; @@ -468,11 +469,9 @@ std::vector generate_call_instruction(std::mt19937_64& rng) instructions.reserve(5); auto contract_address_address = generate_address_ref(rng, MAX_16BIT_OPERAND); - instructions.push_back(SET_FF_Instruction{ - .value_tag = bb::avm2::MemoryTag::FF, - .result_address = contract_address_address, - .value = - bb::avm2::fuzzer::ContractDBProxy::get_instance()->get_function_address(generate_random_uint16(rng)) }); + instructions.push_back(SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, + .result_address = contract_address_address, + .value = context.get_contract_address(generate_random_uint16(rng)) }); auto l2_gas_address = generate_address_ref(rng, MAX_16BIT_OPERAND); instructions.push_back(SET_32_Instruction{ .value_tag = bb::avm2::MemoryTag::U32, @@ -504,7 +503,8 @@ std::vector generate_call_instruction(std::mt19937_64& rng) return instructions; } -std::vector generate_getcontractinstance_instruction(std::mt19937_64& rng) +std::vector generate_getcontractinstance_instruction(std::mt19937_64& rng, + const bb::avm2::fuzzer::FuzzerContext& context) { bool use_backfill = std::uniform_int_distribution(0, 4)(rng) != 0; if (!use_backfill) { @@ -519,11 +519,9 @@ std::vector generate_getcontractinstance_instruction(std::mt199 instructions.reserve(2); auto contract_address_address = generate_address_ref(rng, MAX_16BIT_OPERAND); - instructions.push_back(SET_FF_Instruction{ - .value_tag = bb::avm2::MemoryTag::FF, - .result_address = contract_address_address, - .value = - bb::avm2::fuzzer::ContractDBProxy::get_instance()->get_function_address(generate_random_uint16(rng)) }); + instructions.push_back(SET_FF_Instruction{ .value_tag = bb::avm2::MemoryTag::FF, + .result_address = contract_address_address, + .value = context.get_contract_address(generate_random_uint16(rng)) }); uint8_t member_enum = std::uniform_int_distribution(0, 2)(rng); instructions.push_back(GETCONTRACTINSTANCE_Instruction{ @@ -535,7 +533,8 @@ std::vector generate_getcontractinstance_instruction(std::mt199 return instructions; } -std::vector generate_instruction(std::mt19937_64& rng) +namespace bb::avm2::fuzzer { +std::vector generate_instruction(std::mt19937_64& rng, const FuzzerContext& context) { InstructionGenerationOptions option = BASIC_INSTRUCTION_GENERATION_CONFIGURATION.select(rng); // forgive me @@ -705,13 +704,13 @@ std::vector generate_instruction(std::mt19937_64& rng) case InstructionGenerationOptions::EMITUNENCRYPTEDLOG: return generate_emitunencryptedlog_instruction(rng); case InstructionGenerationOptions::CALL: - return generate_call_instruction(rng); + return generate_call_instruction(rng, context); case InstructionGenerationOptions::RETURNDATASIZE_WITH_RETURNDATACOPY: return { RETURNDATASIZE_WITH_RETURNDATACOPY_Instruction{ .copy_size_offset = generate_random_uint16(rng), .dst_address = generate_random_uint16(rng), .rd_start_offset = generate_random_uint16(rng) } }; case InstructionGenerationOptions::GETCONTRACTINSTANCE: - return generate_getcontractinstance_instruction(rng); + return generate_getcontractinstance_instruction(rng, context); case InstructionGenerationOptions::SUCCESSCOPY: return { SUCCESSCOPY_Instruction{ .dst_address = generate_address_ref(rng, MAX_16BIT_OPERAND) } }; case InstructionGenerationOptions::ECADD: @@ -1358,7 +1357,9 @@ void mutate_toradixbe_instruction(TORADIXBE_Instruction& instruction, std::mt199 } } -void mutate_instruction(FuzzInstruction& instruction, std::mt19937_64& rng) +void mutate_instruction(FuzzInstruction& instruction, + std::mt19937_64& rng, + [[maybe_unused]] const FuzzerContext& context) { std::visit( overloaded{ @@ -1425,3 +1426,5 @@ void mutate_instruction(FuzzInstruction& instruction, std::mt19937_64& rng) [](auto&) { throw std::runtime_error("Unknown instruction"); } }, instruction); } + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.hpp index faed1c3c3415..a4952ea51b5c 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction.hpp @@ -3,9 +3,14 @@ #include #include +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/instruction.hpp" #include "barretenberg/avm_fuzzer/mutations/configuration.hpp" -/// @brief Generate one instruction and opcionally backfill -std::vector generate_instruction(std::mt19937_64& rng); -void mutate_instruction(FuzzInstruction& instruction, std::mt19937_64& rng); +namespace bb::avm2::fuzzer { + +/// @brief Generate one instruction and optionally backfill +std::vector generate_instruction(std::mt19937_64& rng, const FuzzerContext& context); +void mutate_instruction(FuzzInstruction& instruction, std::mt19937_64& rng, const FuzzerContext& context); + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.cpp index 6661941a73c2..4c2c5626af9b 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.cpp @@ -1,6 +1,5 @@ #include "barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp" -#include #include #include @@ -8,24 +7,28 @@ #include "barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp" #include "barretenberg/avm_fuzzer/mutations/instructions/instruction.hpp" +namespace bb::avm2::fuzzer { + constexpr uint16_t MAX_INSTRUCTION_BLOCK_SIZE_ON_GENERATION = 10; -std::vector generate_instruction_block(std::mt19937_64& rng) +std::vector generate_instruction_block(std::mt19937_64& rng, const FuzzerContext& context) { std::vector instruction_block; for (uint16_t i = 0; i < std::uniform_int_distribution(1, MAX_INSTRUCTION_BLOCK_SIZE_ON_GENERATION)(rng); i++) { - auto instructions = generate_instruction(rng); + auto instructions = generate_instruction(rng, context); instruction_block.insert(instruction_block.end(), instructions.begin(), instructions.end()); } return instruction_block; } -void mutate_instruction_block(std::vector& instruction_block, std::mt19937_64& rng) +void mutate_instruction_block(std::vector& instruction_block, + std::mt19937_64& rng, + const FuzzerContext& context) { // If vector is empty, force insertion (other mutations do nothing on empty vectors) if (instruction_block.empty()) { - auto new_instructions = generate_instruction(rng); + auto new_instructions = generate_instruction(rng, context); instruction_block.insert(instruction_block.end(), new_instructions.begin(), new_instructions.end()); return; } @@ -34,7 +37,7 @@ void mutate_instruction_block(std::vector& instruction_block, s switch (option) { case VecMutationOptions::Insertion: { // Custom insertion logic to handle vector-returning generator - auto new_instructions = generate_instruction(rng); + auto new_instructions = generate_instruction(rng, context); if (!new_instructions.empty()) { std::uniform_int_distribution dist(0, instruction_block.size()); size_t index = dist(rng); @@ -51,8 +54,11 @@ void mutate_instruction_block(std::vector& instruction_block, s RandomSwap::mutate(rng, instruction_block); break; case VecMutationOptions::ElementMutation: - RandomElementMutation::mutate( - rng, instruction_block, std::function(mutate_instruction)); + RandomElementMutation::mutate(rng, instruction_block, [&context](FuzzInstruction& instr, std::mt19937_64& r) { + mutate_instruction(instr, r, context); + }); break; } } + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp index b551a3b6c7c5..9af24f3bf40b 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp @@ -3,7 +3,14 @@ #include #include +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/instruction.hpp" -std::vector generate_instruction_block(std::mt19937_64& rng); -void mutate_instruction_block(std::vector& instruction_block, std::mt19937_64& rng); +namespace bb::avm2::fuzzer { + +std::vector generate_instruction_block(std::mt19937_64& rng, const FuzzerContext& context); +void mutate_instruction_block(std::vector& instruction_block, + std::mt19937_64& rng, + const FuzzerContext& context); + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.cpp index 71ec8b4dea49..5455e0ddf2a8 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.cpp @@ -5,6 +5,7 @@ #include "barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp" #include "barretenberg/avm_fuzzer/mutations/fuzzer_data.hpp" #include "barretenberg/avm_fuzzer/mutations/instructions/instruction_block.hpp" +#include "barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.hpp" #include "barretenberg/avm_fuzzer/mutations/tx_types/public_call_request.hpp" #include "barretenberg/vm2/common/avm_io.hpp" #include "barretenberg/vm2/common/aztec_constants.hpp" @@ -91,6 +92,16 @@ void mutate_tx(Tx& tx, std::vector& contract_addresses, std::mt199 fuzz_info("Mutating teardown enqueued call"); mutate_teardown(tx.teardown_enqueued_call, contract_addresses, rng); break; + case TxMutationOptions::NonRevertibleData: + // Mutate non-revertible accumulated data + fuzz_info("Mutating non-revertible accumulated data"); + mutate_non_revertible_accumulated_data(tx.non_revertible_accumulated_data, rng); + break; + case TxMutationOptions::RevertibleData: + // Mutate revertible accumulated data + fuzz_info("Mutating revertible accumulated data"); + mutate_revertible_accumulated_data(tx.revertible_accumulated_data, rng); + break; // case 2: // // Mutate gas_settings @@ -103,32 +114,6 @@ void mutate_tx(Tx& tx, std::vector& contract_addresses, std::mt199 // case 4: // // Mutate Deployment data // break; - // case 5: - // // Mutate non-revertible accumulated data - // // fixme: maybe don't change all stuff - // mutate_ff_vec(tx.non_revertible_accumulated_data.note_hashes, rng, MAX_NOTE_HASHES_PER_TX); - // mutate_ff_vec(tx.non_revertible_accumulated_data.nullifiers, rng, MAX_NULLIFIERS_PER_TX); - // mutate_vec(tx.non_revertible_accumulated_data.l2_to_l1_messages, - // rng, - // mutate_l2_to_l1_msg, - // generate_l2_to_l1_msg, - // BASIC_VEC_MUTATION_CONFIGURATION); - // if (tx.non_revertible_accumulated_data.nullifiers.empty()) { - // // Need to ensure the "tx nullifier" exists - // tx.non_revertible_accumulated_data.nullifiers.push_back(generate_random_field(rng)); - // } - // break; - // case 6: - // // Mutate revertible accumulated data - // mutate_ff_vec(tx.revertible_accumulated_data.note_hashes, rng, MAX_NOTE_HASHES_PER_TX); - // mutate_ff_vec(tx.revertible_accumulated_data.nullifiers, rng, MAX_NULLIFIERS_PER_TX); - // mutate_vec(tx.revertible_accumulated_data.l2_to_l1_messages, - // rng, - // mutate_l2_to_l1_msg, - // generate_l2_to_l1_msg, - // BASIC_VEC_MUTATION_CONFIGURATION); - // break; - // break; // case 8: // // Mutate gas_used_by_private // break; @@ -213,35 +198,10 @@ void mutate_gas_fees(GasFees& fees, std::mt19937_64& rng) } } -void mutate_l2_to_l1_msg(ScopedL2ToL1Message& msg, std::mt19937_64& rng) -{ - auto choice = std::uniform_int_distribution(0, 2)(rng); - - switch (choice) { - case 0: - // Mutate recipient - msg.message.recipient = generate_random_field(rng); - break; - case 1: - // Mutate content - msg.message.content = generate_random_field(rng); - break; - case 2: - // Mutate contract_address - msg.contract_address = generate_random_field(rng); - break; - } -} - -ScopedL2ToL1Message generate_l2_to_l1_msg(std::mt19937_64& rng) -{ - return ScopedL2ToL1Message{ - .message = L2ToL1Message{ .recipient = generate_random_field(rng), .content = generate_random_field(rng) }, - .contract_address = generate_random_field(rng), - }; -} - -void mutate_fuzzer_data_vec(std::vector& enqueued_calls, std::mt19937_64& rng, size_t max_size) +void mutate_fuzzer_data_vec(const FuzzerContext& context, + std::vector& enqueued_calls, + std::mt19937_64& rng, + size_t max_size) { auto choice = std::uniform_int_distribution(0, 1)(rng); switch (choice) { @@ -249,7 +209,7 @@ void mutate_fuzzer_data_vec(std::vector& enqueued_calls, std::mt1993 fuzz_info("Adding a new enqueued call"); // Add a new enqueued call if (enqueued_calls.size() < max_size) { - FuzzerData new_enqueued_call = generate_fuzzer_data(rng); + FuzzerData new_enqueued_call = generate_fuzzer_data(rng, context); enqueued_calls.push_back(new_enqueued_call); } break; @@ -260,8 +220,8 @@ void mutate_fuzzer_data_vec(std::vector& enqueued_calls, std::mt1993 if (!enqueued_calls.empty()) { size_t idx = std::uniform_int_distribution(0, enqueued_calls.size() - 1)(rng); fuzz_info("Mutating enqueued call at index: ", idx); - mutate_fuzzer_data(enqueued_calls[idx], rng); - add_default_instruction_block_if_empty(enqueued_calls[idx], rng); + mutate_fuzzer_data(enqueued_calls[idx], rng, context); + add_default_instruction_block_if_empty(enqueued_calls[idx], rng, context); } break; } diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.hpp index ab7f6f37bf30..3bc6d10d6534 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.hpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_data.hpp @@ -4,6 +4,7 @@ #include #include "barretenberg/avm_fuzzer/common/weighted_selection.hpp" +#include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_context.hpp" #include "barretenberg/avm_fuzzer/fuzz_lib/fuzzer_data.hpp" #include "barretenberg/vm2/common/avm_io.hpp" #include "barretenberg/vm2/common/aztec_types.hpp" @@ -12,14 +13,18 @@ enum class TxMutationOptions { SetupEnqueuedCalls, AppLogicEnqueuedCalls, TearDownEnqueuedCall, + NonRevertibleData, + RevertibleData, }; -using TxMutationConfig = WeightedSelectionConfig; +using TxMutationConfig = WeightedSelectionConfig; constexpr TxMutationConfig TX_MUTATION_CONFIGURATION = TxMutationConfig({ { TxMutationOptions::SetupEnqueuedCalls, 30 }, { TxMutationOptions::AppLogicEnqueuedCalls, 30 }, { TxMutationOptions::TearDownEnqueuedCall, 10 }, + { TxMutationOptions::NonRevertibleData, 15 }, + { TxMutationOptions::RevertibleData, 15 }, }); namespace bb::avm2::fuzzer { @@ -35,10 +40,9 @@ void mutate_gas(Gas& gas, std::mt19937_64& rng); // GasFees mutation void mutate_gas_fees(GasFees& fees, std::mt19937_64& rng); -// L2ToL1Msg vector mutation -void mutate_l2_to_l1_msg(ScopedL2ToL1Message& vec, std::mt19937_64& rng); -ScopedL2ToL1Message generate_l2_to_l1_msg(std::mt19937_64& rng); - -void mutate_fuzzer_data_vec(std::vector& enqueued_calls, std::mt19937_64& rng, size_t max_size = 10); +void mutate_fuzzer_data_vec(const FuzzerContext& context, + std::vector& enqueued_calls, + std::mt19937_64& rng, + size_t max_size = 10); } // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.cpp new file mode 100644 index 000000000000..02cdb70c335f --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.cpp @@ -0,0 +1,187 @@ +#include "barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.hpp" + +#include "barretenberg/avm_fuzzer/fuzz_lib/constants.hpp" +#include "barretenberg/avm_fuzzer/mutations/basic_types/field.hpp" +#include "barretenberg/avm_fuzzer/mutations/basic_types/vector.hpp" +#include "barretenberg/avm_fuzzer/mutations/configuration.hpp" +#include "barretenberg/vm2/common/avm_io.hpp" + +using bb::avm2::AztecAddress; +using bb::avm2::FF; + +namespace { + +// Generate a random note hash +FF generate_note_hash(std::mt19937_64& rng) +{ + return generate_random_field(rng); +} + +void mutate_note_hash(FF& note_hash, std::mt19937_64& rng) +{ + mutate_field(note_hash, rng, BASIC_FIELD_MUTATION_CONFIGURATION); +} + +// Generate a random nullifier +FF generate_nullifier(std::mt19937_64& rng) +{ + return generate_random_field(rng); +} + +void mutate_nullifier(FF& nullifier, std::mt19937_64& rng) +{ + mutate_field(nullifier, rng, BASIC_FIELD_MUTATION_CONFIGURATION); +} + +// Generate a random L2 to L1 message +ScopedL2ToL1Message generate_l2_to_l1_message(std::mt19937_64& rng) +{ + return ScopedL2ToL1Message{ + .message = L2ToL1Message{ .recipient = generate_random_field(rng), .content = generate_random_field(rng) }, + .contract_address = generate_random_field(rng), + }; +} + +void mutate_l2_to_l1_msg(ScopedL2ToL1Message& msg, std::mt19937_64& rng) +{ + auto choice = std::uniform_int_distribution(0, 2)(rng); + + switch (choice) { + case 0: + // Mutate recipient + msg.message.recipient = generate_random_field(rng); + break; + case 1: + // Mutate content + msg.message.content = generate_random_field(rng); + break; + case 2: + // Mutate contract_address + msg.contract_address = generate_random_field(rng); + break; + default: + break; + } +} + +AccumulatedData generate_accumulated_data(std::mt19937_64& rng) +{ + // When we generate new accumulated data we can simply generate a small number of entries + // We test the limits during mutation + std::vector note_hashes; + size_t num_note_hashes = std::uniform_int_distribution(0, 4)(rng); + note_hashes.reserve(num_note_hashes); + for (size_t i = 0; i < num_note_hashes; i++) { + note_hashes.push_back(generate_note_hash(rng)); + } + std::vector nullifiers; + size_t num_nullifiers = std::uniform_int_distribution(0, 4)(rng); + nullifiers.reserve(num_nullifiers); + for (size_t i = 0; i < num_nullifiers; i++) { + nullifiers.push_back(generate_nullifier(rng)); + } + std::vector l2_to_l1_messages; + size_t num_messages = std::uniform_int_distribution(0, 4)(rng); + l2_to_l1_messages.reserve(num_messages); + for (size_t i = 0; i < num_messages; i++) { + l2_to_l1_messages.push_back(generate_l2_to_l1_message(rng)); + } + + return AccumulatedData{ + .note_hashes = note_hashes, + .nullifiers = nullifiers, + .l2_to_l1_messages = l2_to_l1_messages, + }; +} + +void mutate_accumulated_data(AccumulatedData& input, std::mt19937_64& rng) +{ + using namespace bb::avm2::fuzzer; + // We only really care about the existence of note hashes, nullifiers, and L2 to L1 messages + // or if these values end up triggering limit errors during execution. + auto choice = ACCUMULATED_DATA_MUTATION_CONFIGURATION.select(rng); + switch (choice) { + case AccumulatedDataMutationOptions::NoteHashes: + mutate_vec_with_limit(input.note_hashes, + rng, + mutate_note_hash, + generate_note_hash, + BASIC_VEC_MUTATION_CONFIGURATION, + MAX_NOTE_HASHES_PER_TX); + break; + case AccumulatedDataMutationOptions::NoteHashesLimit: { + size_t original_size = input.note_hashes.size(); + input.note_hashes.resize(MAX_NOTE_HASHES_PER_TX); + for (size_t i = original_size; i < MAX_NOTE_HASHES_PER_TX; i++) { + input.note_hashes[i] = generate_note_hash(rng); + } + break; + } + case AccumulatedDataMutationOptions::Nullifiers: + mutate_vec_with_limit(input.nullifiers, + rng, + mutate_nullifier, + generate_nullifier, + BASIC_VEC_MUTATION_CONFIGURATION, + MAX_NULLIFIERS_PER_TX); + break; + case AccumulatedDataMutationOptions::NullifiersLimit: { + size_t original_size = input.nullifiers.size(); + input.nullifiers.resize(MAX_NULLIFIERS_PER_TX); + for (size_t i = original_size; i < MAX_NULLIFIERS_PER_TX; i++) { + input.nullifiers[i] = generate_nullifier(rng); + } + break; + } + case AccumulatedDataMutationOptions::L2ToL1Messages: + mutate_vec_with_limit(input.l2_to_l1_messages, + rng, + mutate_l2_to_l1_msg, + generate_l2_to_l1_message, + BASIC_VEC_MUTATION_CONFIGURATION, + MAX_L2_TO_L1_MSGS_PER_TX); + break; + case AccumulatedDataMutationOptions::L2ToL1MessagesLimit: { + size_t original_size = input.l2_to_l1_messages.size(); + input.l2_to_l1_messages.resize(MAX_L2_TO_L1_MSGS_PER_TX); + for (size_t i = original_size; i < MAX_L2_TO_L1_MSGS_PER_TX; i++) { + input.l2_to_l1_messages[i] = generate_l2_to_l1_message(rng); + } + break; + } + } +} + +} // namespace + +namespace bb::avm2::fuzzer { + +AccumulatedData generate_non_revertible_accumulated_data(std::mt19937_64& rng) +{ + AccumulatedData data = generate_accumulated_data(rng); + if (data.nullifiers.empty()) { + // Need to ensure the "tx nullifier" exists + data.nullifiers.push_back(generate_nullifier(rng)); + } + return data; +} +void mutate_non_revertible_accumulated_data(AccumulatedData& data, std::mt19937_64& rng) +{ + mutate_accumulated_data(data, rng); + if (data.nullifiers.empty()) { + // Need to ensure the "tx nullifier" exists + data.nullifiers.push_back(generate_nullifier(rng)); + } +} + +AccumulatedData generate_revertible_accumulated_data(std::mt19937_64& rng) +{ + return generate_accumulated_data(rng); +} + +void mutate_revertible_accumulated_data(AccumulatedData& data, std::mt19937_64& rng) +{ + mutate_accumulated_data(data, rng); +}; + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.hpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.hpp new file mode 100644 index 000000000000..0cc65ab7b18e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/mutations/tx_types/accumulated_data.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include + +#include "barretenberg/avm_fuzzer/common/weighted_selection.hpp" +#include "barretenberg/avm_fuzzer/mutations/configuration.hpp" +#include "barretenberg/vm2/common/avm_io.hpp" + +namespace bb::avm2::fuzzer { + +enum class AccumulatedDataMutationOptions : uint8_t { + NoteHashes, + NoteHashesLimit, + Nullifiers, + NullifiersLimit, + L2ToL1Messages, + L2ToL1MessagesLimit, +}; + +using AccumulatedDataMutationConfig = WeightedSelectionConfig; + +constexpr AccumulatedDataMutationConfig ACCUMULATED_DATA_MUTATION_CONFIGURATION = AccumulatedDataMutationConfig({ + { AccumulatedDataMutationOptions::NoteHashes, 20 }, + { AccumulatedDataMutationOptions::NoteHashesLimit, 1 }, + { AccumulatedDataMutationOptions::Nullifiers, 20 }, + { AccumulatedDataMutationOptions::NullifiersLimit, 1 }, + { AccumulatedDataMutationOptions::L2ToL1Messages, 20 }, + { AccumulatedDataMutationOptions::L2ToL1MessagesLimit, 1 }, +}); + +template +void mutate_vec_with_limit(std::vector& vec, + std::mt19937_64& rng, + std::function mutate_element_function, + std::function generate_random_element_function, + const VecMutationConfig& config, + size_t vec_limit) +{ + mutate_vec(vec, rng, mutate_element_function, generate_random_element_function, config); + if (vec.size() > vec_limit) { + vec.resize(vec_limit); + } +} + +AccumulatedData generate_non_revertible_accumulated_data(std::mt19937_64& rng); +void mutate_non_revertible_accumulated_data(AccumulatedData& data, std::mt19937_64& rng); + +AccumulatedData generate_revertible_accumulated_data(std::mt19937_64& rng); +void mutate_revertible_accumulated_data(AccumulatedData& data, std::mt19937_64& rng); + +} // namespace bb::avm2::fuzzer diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/prover.fuzzer.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/prover.fuzzer.cpp index 56a01bda9ec0..2dbab4d1ecfa 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/prover.fuzzer.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/prover.fuzzer.cpp @@ -22,23 +22,29 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* serialized_fuzzer_data, size_t max_size, unsigned int seed) { - return mutate_tx_data(serialized_fuzzer_data, serialized_fuzzer_data_size, max_size, seed); + // Haven't thought much about the lifecycle of this in the tx fuzzer. Maybe we want it in the serialized data? + // Or we can regenerate from the serialized data. + FuzzerContext context; + return mutate_tx_data(context, serialized_fuzzer_data, serialized_fuzzer_data_size, max_size, seed); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + FuzzerWorldStateManager* ws_mgr = FuzzerWorldStateManager::getInstance(); + FuzzerContractDB contract_db; + ws_mgr->fork(); + + FuzzerContext context; + FuzzerTxData tx_data; + try { msgpack::unpack((reinterpret_cast(data)), size).get().convert(tx_data); } catch (const std::exception& e) { fuzz_info("Failed to deserialize input in TestOneInput, using default. Exception: ", e.what()); - tx_data = create_default_tx_data(); + tx_data = create_default_tx_data(context); } - FuzzerWorldStateManager* ws_mgr = FuzzerWorldStateManager::getInstance(); - FuzzerContractDB contract_db; - ws_mgr->fork(); - // Setup contracts and fund fee payer // Fuzzer state is dependent on the tx data setup_fuzzer_state(*ws_mgr, contract_db, tx_data); diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/run_fuzzer.sh b/barretenberg/cpp/src/barretenberg/avm_fuzzer/run_fuzzer.sh index de3746bb1f8e..4513c2dc7030 100755 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/run_fuzzer.sh +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/run_fuzzer.sh @@ -29,7 +29,7 @@ shift # Handle list-targets command if [ "$COMMAND" = "list-targets" ]; then echo "Available fuzzing options ():" - echo " avm - AVM fuzzer (avm_fuzzer_avm_fuzzer)" + echo " avm - AVM fuzzer (avm_fuzzer_avm_differential_fuzzer)" echo " tx - Transaction fuzzer (avm_fuzzer_tx_fuzzer)" echo " prover - Prover fuzzer (avm_fuzzer_prover_fuzzer)" echo " alu - ALU fuzzer (harness_alu_fuzzer)" @@ -75,7 +75,7 @@ fi # Validate and map fuzzer type case "$FUZZER_ALIAS" in - avm) FUZZER_TYPE="avm_fuzzer_avm_fuzzer" ;; + avm) FUZZER_TYPE="avm_fuzzer_avm_differential_fuzzer" ;; tx) FUZZER_TYPE="avm_fuzzer_tx_fuzzer" ;; prover) FUZZER_TYPE="avm_fuzzer_prover_fuzzer" ;; alu) FUZZER_TYPE="harness_alu_fuzzer" ;; diff --git a/barretenberg/cpp/src/barretenberg/avm_fuzzer/tx.fuzzer.cpp b/barretenberg/cpp/src/barretenberg/avm_fuzzer/tx.fuzzer.cpp index a99ff1e62302..5343a0b5aea5 100644 --- a/barretenberg/cpp/src/barretenberg/avm_fuzzer/tx.fuzzer.cpp +++ b/barretenberg/cpp/src/barretenberg/avm_fuzzer/tx.fuzzer.cpp @@ -27,23 +27,28 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* serialized_fuzzer_data, size_t max_size, unsigned int seed) { - return mutate_tx_data(serialized_fuzzer_data, serialized_fuzzer_data_size, max_size, seed); + // Haven't thought much about the lifecycle of this in the tx fuzzer. Maybe we want it in the serialized data? + // Or we can regenerate from the serialized data. + FuzzerContext context; + return mutate_tx_data(context, serialized_fuzzer_data, serialized_fuzzer_data_size, max_size, seed); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + FuzzerWorldStateManager* ws_mgr = FuzzerWorldStateManager::getInstance(); + FuzzerContractDB contract_db; + ws_mgr->fork(); + + FuzzerContext context; + FuzzerTxData tx_data; try { msgpack::unpack((reinterpret_cast(data)), size).get().convert(tx_data); } catch (const std::exception& e) { fuzz_info("Failed to deserialize input in TestOneInput, using default. Exception: ", e.what()); - tx_data = create_default_tx_data(); + tx_data = create_default_tx_data(context); } - FuzzerWorldStateManager* ws_mgr = FuzzerWorldStateManager::getInstance(); - FuzzerContractDB contract_db; - ws_mgr->fork(); - // Setup contracts and fund fee payer setup_fuzzer_state(*ws_mgr, contract_db, tx_data); fund_fee_payer(*ws_mgr, tx_data.tx); diff --git a/barretenberg/cpp/src/barretenberg/vm2/constraining/avm_fixed_vk.hpp b/barretenberg/cpp/src/barretenberg/vm2/constraining/avm_fixed_vk.hpp index c6f6125c59ec..95c0f38624b2 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/constraining/avm_fixed_vk.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/constraining/avm_fixed_vk.hpp @@ -126,7 +126,6 @@ class AvmFixedVKCommitments { uint256_t("0x0000000000000000000000000000000000000000000000000000000000000001"), uint256_t( "0x0000000000000000000000000000000000000000000000000000000000000002")), // precomputed_is_deployer - Commitment::infinity(), // precomputed_is_feeperl2gas Commitment( uint256_t("0x020ad6e43ccd48a6a39e43897cc85187bd364919be8a3b82d4809715cfe489db"), uint256_t( diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp index c0830dd10eaf..743fc32f30f0 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/columns.hpp @@ -7,7 +7,7 @@ namespace bb::avm2 { // clang-format off -#define AVM2_PRECOMPUTED_ENTITIES_E(e) e precomputed_addressing_gas, e precomputed_bitwise_input_a, e precomputed_bitwise_input_b, e precomputed_bitwise_op_id, e precomputed_bitwise_output, e precomputed_clk, e precomputed_dyn_gas_id, e precomputed_envvar_pi_row_idx, e precomputed_exec_opcode, e precomputed_exec_opcode_base_da_gas, e precomputed_exec_opcode_dynamic_da_gas, e precomputed_exec_opcode_dynamic_l2_gas, e precomputed_exec_opcode_opcode_gas, e precomputed_expected_tag_reg_0_, e precomputed_expected_tag_reg_1_, e precomputed_expected_tag_reg_2_, e precomputed_expected_tag_reg_3_, e precomputed_expected_tag_reg_4_, e precomputed_expected_tag_reg_5_, e precomputed_first_row, e precomputed_instr_size, e precomputed_invalid_envvar_enum, e precomputed_is_address, e precomputed_is_class_id, e precomputed_is_cleanup, e precomputed_is_collect_fee, e precomputed_is_dagasleft, e precomputed_is_deployer, e precomputed_is_feeperl2gas, e precomputed_is_init_hash, e precomputed_is_isstaticcall, e precomputed_is_l2gasleft, e precomputed_is_public_call_request, e precomputed_is_revertible, e precomputed_is_sender, e precomputed_is_teardown, e precomputed_is_transactionfee, e precomputed_is_tree_padding, e precomputed_is_valid_member_enum, e precomputed_keccak_round_constant, e precomputed_next_phase_on_revert, e precomputed_opcode_out_of_range, e precomputed_out_tag, e precomputed_p_decomposition_limb, e precomputed_p_decomposition_limb_index, e precomputed_p_decomposition_radix, e precomputed_power_of_2, e precomputed_read_pi_length_offset, e precomputed_read_pi_start_offset, e precomputed_rw_reg_0_, e precomputed_rw_reg_1_, e precomputed_rw_reg_2_, e precomputed_rw_reg_3_, e precomputed_rw_reg_4_, e precomputed_rw_reg_5_, e precomputed_sel_addressing_gas, e precomputed_sel_bitwise, e precomputed_sel_envvar_pi_lookup_col0, e precomputed_sel_envvar_pi_lookup_col1, e precomputed_sel_exec_spec, e precomputed_sel_has_tag, e precomputed_sel_keccak, e precomputed_sel_mem_op_reg_0_, e precomputed_sel_mem_op_reg_1_, e precomputed_sel_mem_op_reg_2_, e precomputed_sel_mem_op_reg_3_, e precomputed_sel_mem_op_reg_4_, e precomputed_sel_mem_op_reg_5_, e precomputed_sel_mem_tag_out_of_range, e precomputed_sel_non_revertible_append_l2_l1_msg, e precomputed_sel_non_revertible_append_note_hash, e precomputed_sel_non_revertible_append_nullifier, e precomputed_sel_op_dc_0, e precomputed_sel_op_dc_1, e precomputed_sel_op_dc_10, e precomputed_sel_op_dc_11, e precomputed_sel_op_dc_12, e precomputed_sel_op_dc_13, e precomputed_sel_op_dc_14, e precomputed_sel_op_dc_15, e precomputed_sel_op_dc_16, e precomputed_sel_op_dc_17, e precomputed_sel_op_dc_2, e precomputed_sel_op_dc_3, e precomputed_sel_op_dc_4, e precomputed_sel_op_dc_5, e precomputed_sel_op_dc_6, e precomputed_sel_op_dc_7, e precomputed_sel_op_dc_8, e precomputed_sel_op_dc_9, e precomputed_sel_op_is_address_0_, e precomputed_sel_op_is_address_1_, e precomputed_sel_op_is_address_2_, e precomputed_sel_op_is_address_3_, e precomputed_sel_op_is_address_4_, e precomputed_sel_op_is_address_5_, e precomputed_sel_op_is_address_6_, e precomputed_sel_p_decomposition, e precomputed_sel_phase, e precomputed_sel_range_16, e precomputed_sel_range_8, e precomputed_sel_revertible_append_l2_l1_msg, e precomputed_sel_revertible_append_note_hash, e precomputed_sel_revertible_append_nullifier, e precomputed_sel_sha256_compression, e precomputed_sel_tag_check_reg_0_, e precomputed_sel_tag_check_reg_1_, e precomputed_sel_tag_check_reg_2_, e precomputed_sel_tag_check_reg_3_, e precomputed_sel_tag_check_reg_4_, e precomputed_sel_tag_check_reg_5_, e precomputed_sel_tag_is_op2, e precomputed_sel_tag_parameters, e precomputed_sel_to_radix_p_limb_counts, e precomputed_sha256_compression_round_constant, e precomputed_subtrace_id, e precomputed_subtrace_operation_id, e precomputed_tag_byte_length, e precomputed_tag_max_bits, e precomputed_tag_max_value, e precomputed_to_radix_num_limbs_for_p, e precomputed_to_radix_safe_limbs, e precomputed_zero, e public_inputs_sel +#define AVM2_PRECOMPUTED_ENTITIES_E(e) e precomputed_addressing_gas, e precomputed_bitwise_input_a, e precomputed_bitwise_input_b, e precomputed_bitwise_op_id, e precomputed_bitwise_output, e precomputed_clk, e precomputed_dyn_gas_id, e precomputed_envvar_pi_row_idx, e precomputed_exec_opcode, e precomputed_exec_opcode_base_da_gas, e precomputed_exec_opcode_dynamic_da_gas, e precomputed_exec_opcode_dynamic_l2_gas, e precomputed_exec_opcode_opcode_gas, e precomputed_expected_tag_reg_0_, e precomputed_expected_tag_reg_1_, e precomputed_expected_tag_reg_2_, e precomputed_expected_tag_reg_3_, e precomputed_expected_tag_reg_4_, e precomputed_expected_tag_reg_5_, e precomputed_first_row, e precomputed_instr_size, e precomputed_invalid_envvar_enum, e precomputed_is_address, e precomputed_is_class_id, e precomputed_is_cleanup, e precomputed_is_collect_fee, e precomputed_is_dagasleft, e precomputed_is_deployer, e precomputed_is_init_hash, e precomputed_is_isstaticcall, e precomputed_is_l2gasleft, e precomputed_is_public_call_request, e precomputed_is_revertible, e precomputed_is_sender, e precomputed_is_teardown, e precomputed_is_transactionfee, e precomputed_is_tree_padding, e precomputed_is_valid_member_enum, e precomputed_keccak_round_constant, e precomputed_next_phase_on_revert, e precomputed_opcode_out_of_range, e precomputed_out_tag, e precomputed_p_decomposition_limb, e precomputed_p_decomposition_limb_index, e precomputed_p_decomposition_radix, e precomputed_power_of_2, e precomputed_read_pi_length_offset, e precomputed_read_pi_start_offset, e precomputed_rw_reg_0_, e precomputed_rw_reg_1_, e precomputed_rw_reg_2_, e precomputed_rw_reg_3_, e precomputed_rw_reg_4_, e precomputed_rw_reg_5_, e precomputed_sel_addressing_gas, e precomputed_sel_bitwise, e precomputed_sel_envvar_pi_lookup_col0, e precomputed_sel_envvar_pi_lookup_col1, e precomputed_sel_exec_spec, e precomputed_sel_has_tag, e precomputed_sel_keccak, e precomputed_sel_mem_op_reg_0_, e precomputed_sel_mem_op_reg_1_, e precomputed_sel_mem_op_reg_2_, e precomputed_sel_mem_op_reg_3_, e precomputed_sel_mem_op_reg_4_, e precomputed_sel_mem_op_reg_5_, e precomputed_sel_mem_tag_out_of_range, e precomputed_sel_non_revertible_append_l2_l1_msg, e precomputed_sel_non_revertible_append_note_hash, e precomputed_sel_non_revertible_append_nullifier, e precomputed_sel_op_dc_0, e precomputed_sel_op_dc_1, e precomputed_sel_op_dc_10, e precomputed_sel_op_dc_11, e precomputed_sel_op_dc_12, e precomputed_sel_op_dc_13, e precomputed_sel_op_dc_14, e precomputed_sel_op_dc_15, e precomputed_sel_op_dc_16, e precomputed_sel_op_dc_17, e precomputed_sel_op_dc_2, e precomputed_sel_op_dc_3, e precomputed_sel_op_dc_4, e precomputed_sel_op_dc_5, e precomputed_sel_op_dc_6, e precomputed_sel_op_dc_7, e precomputed_sel_op_dc_8, e precomputed_sel_op_dc_9, e precomputed_sel_op_is_address_0_, e precomputed_sel_op_is_address_1_, e precomputed_sel_op_is_address_2_, e precomputed_sel_op_is_address_3_, e precomputed_sel_op_is_address_4_, e precomputed_sel_op_is_address_5_, e precomputed_sel_op_is_address_6_, e precomputed_sel_p_decomposition, e precomputed_sel_phase, e precomputed_sel_range_16, e precomputed_sel_range_8, e precomputed_sel_revertible_append_l2_l1_msg, e precomputed_sel_revertible_append_note_hash, e precomputed_sel_revertible_append_nullifier, e precomputed_sel_sha256_compression, e precomputed_sel_tag_check_reg_0_, e precomputed_sel_tag_check_reg_1_, e precomputed_sel_tag_check_reg_2_, e precomputed_sel_tag_check_reg_3_, e precomputed_sel_tag_check_reg_4_, e precomputed_sel_tag_check_reg_5_, e precomputed_sel_tag_is_op2, e precomputed_sel_tag_parameters, e precomputed_sel_to_radix_p_limb_counts, e precomputed_sha256_compression_round_constant, e precomputed_subtrace_id, e precomputed_subtrace_operation_id, e precomputed_tag_byte_length, e precomputed_tag_max_bits, e precomputed_tag_max_value, e precomputed_to_radix_num_limbs_for_p, e precomputed_to_radix_safe_limbs, e precomputed_zero, e public_inputs_sel #define AVM2_WIRE_ENTITIES_E(e) e public_inputs_cols_0_, e public_inputs_cols_1_, e public_inputs_cols_2_, e public_inputs_cols_3_, e address_derivation_address, e address_derivation_address_y, e address_derivation_class_id, e address_derivation_const_five, e address_derivation_const_four, e address_derivation_const_three, e address_derivation_const_two, e address_derivation_deployer_addr, e address_derivation_g1_x, e address_derivation_g1_y, e address_derivation_incoming_viewing_key_x, e address_derivation_incoming_viewing_key_y, e address_derivation_init_hash, e address_derivation_nullifier_key_x, e address_derivation_nullifier_key_y, e address_derivation_outgoing_viewing_key_x, e address_derivation_outgoing_viewing_key_y, e address_derivation_partial_address, e address_derivation_partial_address_domain_separator, e address_derivation_preaddress, e address_derivation_preaddress_domain_separator, e address_derivation_preaddress_public_key_x, e address_derivation_preaddress_public_key_y, e address_derivation_public_keys_hash, e address_derivation_public_keys_hash_domain_separator, e address_derivation_salt, e address_derivation_salted_init_hash, e address_derivation_sel, e address_derivation_tagging_key_x, e address_derivation_tagging_key_y, e alu_a_hi, e alu_a_hi_bits, e alu_a_lo, e alu_a_lo_bits, e alu_ab_diff_inv, e alu_ab_tags_diff_inv, e alu_b_hi, e alu_b_inv, e alu_b_lo, e alu_c_hi, e alu_cf, e alu_constant_64, e alu_gt_input_a, e alu_gt_input_b, e alu_gt_result_c, e alu_helper1, e alu_ia, e alu_ia_tag, e alu_ib, e alu_ib_tag, e alu_ic, e alu_ic_tag, e alu_max_bits, e alu_max_value, e alu_mid, e alu_mid_bits, e alu_op_id, e alu_sel, e alu_sel_ab_tag_mismatch, e alu_sel_decompose_a, e alu_sel_div_0_err, e alu_sel_div_no_err, e alu_sel_err, e alu_sel_ff_gt, e alu_sel_int_gt, e alu_sel_is_ff, e alu_sel_is_u128, e alu_sel_mul_div_u128, e alu_sel_mul_no_err_non_ff, e alu_sel_op_add, e alu_sel_op_div, e alu_sel_op_eq, e alu_sel_op_fdiv, e alu_sel_op_lt, e alu_sel_op_lte, e alu_sel_op_mul, e alu_sel_op_not, e alu_sel_op_shl, e alu_sel_op_shr, e alu_sel_op_sub, e alu_sel_op_truncate, e alu_sel_shift_ops_no_overflow, e alu_sel_tag_err, e alu_sel_trunc_gte_128, e alu_sel_trunc_lt_128, e alu_sel_trunc_non_trivial, e alu_sel_trunc_trivial, e alu_shift_lo_bits, e alu_tag_ff_diff_inv, e alu_tag_u128_diff_inv, e alu_two_pow_shift_lo_bits, e bc_decomposition_bytes_pc_plus_36, e bc_decomposition_bytes_rem_inv, e bc_decomposition_bytes_rem_min_one_inv, e bc_decomposition_bytes_to_read, e bc_decomposition_is_windows_eq_remaining, e bc_decomposition_last_of_contract, e bc_decomposition_next_packed_pc_min_pc_inv, e bc_decomposition_packed_field, e bc_decomposition_sel_packed_read_0_, e bc_decomposition_sel_packed_read_1_, e bc_decomposition_sel_packed_read_2_, e bc_decomposition_windows_min_remaining_inv, e bc_hashing_input_len, e bc_hashing_latch, e bc_hashing_output_hash, e bc_hashing_packed_fields_0, e bc_hashing_packed_fields_1, e bc_hashing_packed_fields_2, e bc_hashing_pc_at_final_field, e bc_hashing_pc_index_1, e bc_hashing_pc_index_2, e bc_hashing_sel_not_padding_1, e bc_hashing_sel_not_padding_2, e bc_hashing_sel_not_start, e bc_retrieval_address, e bc_retrieval_artifact_hash, e bc_retrieval_bytecode_id, e bc_retrieval_current_class_id, e bc_retrieval_error, e bc_retrieval_instance_exists, e bc_retrieval_is_new_class, e bc_retrieval_next_retrieved_bytecodes_tree_root, e bc_retrieval_next_retrieved_bytecodes_tree_size, e bc_retrieval_no_remaining_bytecodes, e bc_retrieval_nullifier_tree_root, e bc_retrieval_prev_retrieved_bytecodes_tree_root, e bc_retrieval_prev_retrieved_bytecodes_tree_size, e bc_retrieval_private_functions_root, e bc_retrieval_public_data_tree_root, e bc_retrieval_remaining_bytecodes_inv, e bc_retrieval_should_retrieve, e bitwise_ctr_inv, e bitwise_ctr_min_one_inv, e bitwise_err, e bitwise_ia_byte, e bitwise_ib_byte, e bitwise_ic_byte, e bitwise_last, e bitwise_sel, e bitwise_sel_get_ctr, e bitwise_sel_tag_ff_err, e bitwise_sel_tag_mismatch_err, e bitwise_start, e bitwise_start_keccak, e bitwise_start_sha256, e bitwise_tag_a, e bitwise_tag_a_inv, e bitwise_tag_ab_diff_inv, e bitwise_tag_b, e bitwise_tag_c, e calldata_diff_context_id, e calldata_hashing_index_1_, e calldata_hashing_index_2_, e calldata_hashing_input_0_, e calldata_hashing_input_1_, e calldata_hashing_input_2_, e calldata_hashing_input_len, e calldata_hashing_latch, e calldata_hashing_sel_not_padding_1, e calldata_hashing_sel_not_padding_2, e calldata_hashing_sel_not_start, e calldata_latch, e calldata_value, e class_id_derivation_artifact_hash, e class_id_derivation_class_id, e class_id_derivation_const_two, e class_id_derivation_gen_index_contract_class_id, e class_id_derivation_private_functions_root, e class_id_derivation_public_bytecode_commitment, e class_id_derivation_sel, e context_stack_bytecode_id, e context_stack_context_id, e context_stack_contract_address, e context_stack_entered_context_id, e context_stack_is_static, e context_stack_msg_sender, e context_stack_next_pc, e context_stack_note_hash_tree_root, e context_stack_note_hash_tree_size, e context_stack_nullifier_tree_root, e context_stack_nullifier_tree_size, e context_stack_num_l2_to_l1_messages, e context_stack_num_note_hashes_emitted, e context_stack_num_nullifiers_emitted, e context_stack_num_unencrypted_log_fields, e context_stack_parent_calldata_addr, e context_stack_parent_calldata_size, e context_stack_parent_da_gas_limit, e context_stack_parent_da_gas_used, e context_stack_parent_id, e context_stack_parent_l2_gas_limit, e context_stack_parent_l2_gas_used, e context_stack_public_data_tree_root, e context_stack_public_data_tree_size, e context_stack_sel, e context_stack_written_public_data_slots_tree_root, e context_stack_written_public_data_slots_tree_size, e contract_instance_retrieval_address, e contract_instance_retrieval_address_sub_one, e contract_instance_retrieval_current_class_id, e contract_instance_retrieval_deployer_addr, e contract_instance_retrieval_deployer_protocol_contract_address, e contract_instance_retrieval_derived_address, e contract_instance_retrieval_derived_address_pi_index, e contract_instance_retrieval_exists, e contract_instance_retrieval_incoming_viewing_key_x, e contract_instance_retrieval_incoming_viewing_key_y, e contract_instance_retrieval_init_hash, e contract_instance_retrieval_is_protocol_contract, e contract_instance_retrieval_max_protocol_contracts, e contract_instance_retrieval_nullifier_key_x, e contract_instance_retrieval_nullifier_key_y, e contract_instance_retrieval_nullifier_tree_root, e contract_instance_retrieval_original_class_id, e contract_instance_retrieval_outgoing_viewing_key_x, e contract_instance_retrieval_outgoing_viewing_key_y, e contract_instance_retrieval_protocol_contract_derived_address_inv, e contract_instance_retrieval_public_data_tree_root, e contract_instance_retrieval_salt, e contract_instance_retrieval_sel, e contract_instance_retrieval_should_check_for_update, e contract_instance_retrieval_should_check_nullifier, e contract_instance_retrieval_tagging_key_x, e contract_instance_retrieval_tagging_key_y, e data_copy_cd_copy_col_read, e data_copy_data_index_upper_bound, e data_copy_data_index_upper_bound_gt_offset, e data_copy_dst_out_of_range_err, e data_copy_err, e data_copy_is_top_level, e data_copy_mem_size, e data_copy_offset, e data_copy_offset_plus_size, e data_copy_offset_plus_size_is_gt, e data_copy_parent_id_inv, e data_copy_read_addr_plus_one, e data_copy_read_addr_upper_bound, e data_copy_reads_left_inv, e data_copy_sel_cd_copy_start, e data_copy_sel_end, e data_copy_sel_mem_read, e data_copy_sel_mem_write, e data_copy_sel_rd_copy_start, e data_copy_sel_start_no_err, e data_copy_sel_write_count_is_zero, e data_copy_src_addr, e data_copy_src_data_size, e data_copy_src_out_of_range_err, e data_copy_tag, e data_copy_value, e data_copy_write_addr_upper_bound, e data_copy_write_count_minus_one_inv, e data_copy_write_count_zero_inv, e ecc_add_mem_dst_addr_0_, e ecc_add_mem_dst_addr_1_, e ecc_add_mem_dst_addr_2_, e ecc_add_mem_err, e ecc_add_mem_execution_clk, e ecc_add_mem_max_mem_addr, e ecc_add_mem_p_is_inf, e ecc_add_mem_p_is_on_curve_eqn, e ecc_add_mem_p_is_on_curve_eqn_inv, e ecc_add_mem_p_x, e ecc_add_mem_p_y, e ecc_add_mem_q_is_inf, e ecc_add_mem_q_is_on_curve_eqn, e ecc_add_mem_q_is_on_curve_eqn_inv, e ecc_add_mem_q_x, e ecc_add_mem_q_y, e ecc_add_mem_res_is_inf, e ecc_add_mem_res_x, e ecc_add_mem_res_y, e ecc_add_mem_sel, e ecc_add_mem_sel_dst_out_of_range_err, e ecc_add_mem_sel_p_not_on_curve_err, e ecc_add_mem_sel_q_not_on_curve_err, e ecc_add_mem_sel_should_exec, e ecc_add_mem_space_id, e ecc_add_op, e ecc_double_op, e ecc_inv_2_p_y, e ecc_inv_x_diff, e ecc_inv_y_diff, e ecc_lambda, e ecc_p_is_inf, e ecc_p_x, e ecc_p_y, e ecc_q_is_inf, e ecc_q_x, e ecc_q_y, e ecc_r_is_inf, e ecc_r_x, e ecc_r_y, e ecc_result_infinity, e ecc_sel, e ecc_use_computed_result, e ecc_x_match, e ecc_y_match, e emit_unencrypted_log_discard, e emit_unencrypted_log_end, e emit_unencrypted_log_end_log_address_upper_bound, e emit_unencrypted_log_error, e emit_unencrypted_log_error_too_many_log_fields, e emit_unencrypted_log_error_too_many_logs_wrong_tag_is_static, e emit_unencrypted_log_expected_next_log_fields, e emit_unencrypted_log_is_static, e emit_unencrypted_log_log_size, e emit_unencrypted_log_max_mem_size, e emit_unencrypted_log_next_num_unencrypted_log_fields, e emit_unencrypted_log_prev_num_unencrypted_log_fields, e emit_unencrypted_log_public_inputs_value, e emit_unencrypted_log_public_logs_payload_length, e emit_unencrypted_log_remaining_rows_inv, e emit_unencrypted_log_sel_should_read_memory, e emit_unencrypted_log_tag, e emit_unencrypted_log_tag_inv, e emit_unencrypted_log_value, e execution_addressing_error_collection_inv, e execution_addressing_gas, e execution_base_address_tag, e execution_base_address_tag_diff_inv, e execution_base_address_val, e execution_base_da_gas, e execution_batched_tags_diff_inv, e execution_batched_tags_diff_inv_reg, e execution_da_gas_left, e execution_da_gas_used, e execution_dying_context_diff_inv, e execution_dying_context_id_inv, e execution_dyn_gas_id, e execution_dynamic_da_gas, e execution_dynamic_da_gas_factor, e execution_dynamic_l2_gas, e execution_dynamic_l2_gas_factor, e execution_enqueued_call_end, e execution_envvar_pi_row_idx, e execution_ex_opcode, e execution_expected_tag_reg_0_, e execution_expected_tag_reg_1_, e execution_expected_tag_reg_2_, e execution_expected_tag_reg_3_, e execution_expected_tag_reg_4_, e execution_expected_tag_reg_5_, e execution_has_parent_ctx, e execution_highest_address, e execution_indirect, e execution_instr_length, e execution_internal_call_return_id_inv, e execution_is_address, e execution_is_da_gas_left_gt_allocated, e execution_is_dagasleft, e execution_is_dying_context, e execution_is_isstaticcall, e execution_is_l2_gas_left_gt_allocated, e execution_is_l2gasleft, e execution_is_parent_id_inv, e execution_is_sender, e execution_is_transactionfee, e execution_l1_to_l2_msg_leaf_in_range, e execution_l1_to_l2_msg_tree_leaf_count, e execution_l2_gas_left, e execution_l2_gas_used, e execution_max_data_writes_reached, e execution_mem_tag_reg_0_, e execution_mem_tag_reg_1_, e execution_mem_tag_reg_2_, e execution_mem_tag_reg_3_, e execution_mem_tag_reg_4_, e execution_mem_tag_reg_5_, e execution_nested_exit_call, e execution_nested_failure, e execution_nested_return, e execution_next_pc, e execution_note_hash_leaf_in_range, e execution_note_hash_tree_leaf_count, e execution_note_hash_tree_root, e execution_note_hash_tree_size, e execution_nullifier_tree_root, e execution_nullifier_tree_size, e execution_num_l2_to_l1_messages, e execution_num_note_hashes_emitted, e execution_num_nullifiers_emitted, e execution_num_p_limbs, e execution_num_relative_operands_inv, e execution_num_unencrypted_log_fields, e execution_op_0_, e execution_op_1_, e execution_op_2_, e execution_op_3_, e execution_op_4_, e execution_op_5_, e execution_op_6_, e execution_op_after_relative_0_, e execution_op_after_relative_1_, e execution_op_after_relative_2_, e execution_op_after_relative_3_, e execution_op_after_relative_4_, e execution_op_after_relative_5_, e execution_op_after_relative_6_, e execution_opcode_gas, e execution_out_of_gas_da, e execution_out_of_gas_l2, e execution_public_data_tree_root, e execution_public_data_tree_size, e execution_public_inputs_index, e execution_register_0_, e execution_register_1_, e execution_register_2_, e execution_register_3_, e execution_register_4_, e execution_register_5_, e execution_remaining_data_writes_inv, e execution_remaining_l2_to_l1_msgs_inv, e execution_remaining_note_hashes_inv, e execution_remaining_nullifiers_inv, e execution_retrieved_bytecodes_tree_root, e execution_retrieved_bytecodes_tree_size, e execution_rop_0_, e execution_rop_1_, e execution_rop_2_, e execution_rop_3_, e execution_rop_4_, e execution_rop_5_, e execution_rop_6_, e execution_rop_tag_0_, e execution_rop_tag_1_, e execution_rop_tag_2_, e execution_rop_tag_3_, e execution_rop_tag_4_, e execution_rop_tag_5_, e execution_rop_tag_6_, e execution_rw_reg_0_, e execution_rw_reg_1_, e execution_rw_reg_2_, e execution_rw_reg_3_, e execution_rw_reg_4_, e execution_rw_reg_5_, e execution_sel_addressing_error, e execution_sel_base_address_failure, e execution_sel_bytecode_retrieval_failure, e execution_sel_bytecode_retrieval_success, e execution_sel_do_base_check, e execution_sel_enter_call, e execution_sel_envvar_pi_lookup_col0, e execution_sel_envvar_pi_lookup_col1, e execution_sel_error, e execution_sel_exec_dispatch_alu, e execution_sel_exec_dispatch_bitwise, e execution_sel_exec_dispatch_calldata_copy, e execution_sel_exec_dispatch_cast, e execution_sel_exec_dispatch_ecc_add, e execution_sel_exec_dispatch_emit_unencrypted_log, e execution_sel_exec_dispatch_execution, e execution_sel_exec_dispatch_get_contract_instance, e execution_sel_exec_dispatch_keccakf1600, e execution_sel_exec_dispatch_poseidon2_perm, e execution_sel_exec_dispatch_returndata_copy, e execution_sel_exec_dispatch_set, e execution_sel_exec_dispatch_sha256_compression, e execution_sel_exec_dispatch_to_radix, e execution_sel_execute_call, e execution_sel_execute_debug_log, e execution_sel_execute_emit_notehash, e execution_sel_execute_emit_nullifier, e execution_sel_execute_get_env_var, e execution_sel_execute_internal_call, e execution_sel_execute_internal_return, e execution_sel_execute_jump, e execution_sel_execute_jumpi, e execution_sel_execute_l1_to_l2_message_exists, e execution_sel_execute_mov, e execution_sel_execute_notehash_exists, e execution_sel_execute_nullifier_exists, e execution_sel_execute_return, e execution_sel_execute_returndata_size, e execution_sel_execute_revert, e execution_sel_execute_send_l2_to_l1_msg, e execution_sel_execute_sload, e execution_sel_execute_sstore, e execution_sel_execute_static_call, e execution_sel_execute_success_copy, e execution_sel_exit_call, e execution_sel_failure, e execution_sel_gas_bitwise, e execution_sel_gas_calldata_copy, e execution_sel_gas_emit_unencrypted_log, e execution_sel_gas_returndata_copy, e execution_sel_gas_sstore, e execution_sel_gas_to_radix, e execution_sel_instruction_fetching_failure, e execution_sel_instruction_fetching_success, e execution_sel_l2_to_l1_msg_limit_error, e execution_sel_lookup_num_p_limbs, e execution_sel_mem_op_reg_0_, e execution_sel_mem_op_reg_1_, e execution_sel_mem_op_reg_2_, e execution_sel_mem_op_reg_3_, e execution_sel_mem_op_reg_4_, e execution_sel_mem_op_reg_5_, e execution_sel_op_do_overflow_check_0_, e execution_sel_op_do_overflow_check_1_, e execution_sel_op_do_overflow_check_2_, e execution_sel_op_do_overflow_check_3_, e execution_sel_op_do_overflow_check_4_, e execution_sel_op_do_overflow_check_5_, e execution_sel_op_do_overflow_check_6_, e execution_sel_op_is_address_0_, e execution_sel_op_is_address_1_, e execution_sel_op_is_address_2_, e execution_sel_op_is_address_3_, e execution_sel_op_is_address_4_, e execution_sel_op_is_address_5_, e execution_sel_op_is_address_6_, e execution_sel_op_is_indirect_wire_0_, e execution_sel_op_is_indirect_wire_1_, e execution_sel_op_is_indirect_wire_2_, e execution_sel_op_is_indirect_wire_3_, e execution_sel_op_is_indirect_wire_4_, e execution_sel_op_is_indirect_wire_5_, e execution_sel_op_is_indirect_wire_6_, e execution_sel_op_is_indirect_wire_7_, e execution_sel_op_is_relative_wire_0_, e execution_sel_op_is_relative_wire_1_, e execution_sel_op_is_relative_wire_2_, e execution_sel_op_is_relative_wire_3_, e execution_sel_op_is_relative_wire_4_, e execution_sel_op_is_relative_wire_5_, e execution_sel_op_is_relative_wire_6_, e execution_sel_op_is_relative_wire_7_, e execution_sel_op_reg_effective_0_, e execution_sel_op_reg_effective_1_, e execution_sel_op_reg_effective_2_, e execution_sel_op_reg_effective_3_, e execution_sel_op_reg_effective_4_, e execution_sel_op_reg_effective_5_, e execution_sel_opcode_error, e execution_sel_out_of_gas, e execution_sel_radix_gt_256, e execution_sel_reached_max_note_hashes, e execution_sel_reached_max_nullifiers, e execution_sel_read_unwind_call_stack, e execution_sel_register_read_error, e execution_sel_relative_overflow_0_, e execution_sel_relative_overflow_1_, e execution_sel_relative_overflow_2_, e execution_sel_relative_overflow_3_, e execution_sel_relative_overflow_4_, e execution_sel_relative_overflow_5_, e execution_sel_relative_overflow_6_, e execution_sel_should_apply_indirection_0_, e execution_sel_should_apply_indirection_1_, e execution_sel_should_apply_indirection_2_, e execution_sel_should_apply_indirection_3_, e execution_sel_should_apply_indirection_4_, e execution_sel_should_apply_indirection_5_, e execution_sel_should_apply_indirection_6_, e execution_sel_should_check_gas, e execution_sel_should_execute_opcode, e execution_sel_should_read_registers, e execution_sel_should_write_registers, e execution_sel_some_final_check_failed, e execution_sel_tag_check_reg_0_, e execution_sel_tag_check_reg_1_, e execution_sel_tag_check_reg_2_, e execution_sel_tag_check_reg_3_, e execution_sel_tag_check_reg_4_, e execution_sel_tag_check_reg_5_, e execution_sel_use_num_limbs, e execution_sel_write_l2_to_l1_msg, e execution_sel_write_note_hash, e execution_sel_write_nullifier, e execution_sel_write_public_data, e execution_subtrace_id, e execution_subtrace_operation_id, e execution_total_gas_da, e execution_total_gas_l2, e execution_two_five_six, e execution_value_from_pi, e execution_written_public_data_slots_tree_root, e execution_written_public_data_slots_tree_size, e ff_gt_a, e ff_gt_b, e ff_gt_borrow, e ff_gt_cmp_rng_ctr_inv, e ff_gt_constant_128, e ff_gt_p_a_borrow, e ff_gt_p_b_borrow, e ff_gt_res_hi, e ff_gt_res_lo, e ff_gt_result, e ff_gt_sel_shift_rng, e get_contract_instance_clk, e get_contract_instance_contract_address, e get_contract_instance_dst_offset, e get_contract_instance_dst_offset_diff_max_inv, e get_contract_instance_exists_tag, e get_contract_instance_instance_exists, e get_contract_instance_is_class_id, e get_contract_instance_is_deployer, e get_contract_instance_is_init_hash, e get_contract_instance_is_valid_member_enum, e get_contract_instance_is_valid_writes_in_bounds, e get_contract_instance_member_enum, e get_contract_instance_member_tag, e get_contract_instance_member_write_offset, e get_contract_instance_nullifier_tree_root, e get_contract_instance_public_data_tree_root, e get_contract_instance_retrieved_class_id, e get_contract_instance_retrieved_deployer_addr, e get_contract_instance_retrieved_init_hash, e get_contract_instance_sel, e get_contract_instance_sel_error, e get_contract_instance_selected_member, e get_contract_instance_space_id, e gt_abs_diff, e gt_input_a, e gt_input_b, e gt_num_bits, e gt_res, e gt_sel, e gt_sel_addressing, e gt_sel_alu, e gt_sel_gas, e gt_sel_others, e gt_sel_sha256, e instr_fetching_bd0, e instr_fetching_bd1, e instr_fetching_bd10, e instr_fetching_bd11, e instr_fetching_bd12, e instr_fetching_bd13, e instr_fetching_bd14, e instr_fetching_bd15, e instr_fetching_bd16, e instr_fetching_bd17, e instr_fetching_bd18, e instr_fetching_bd19, e instr_fetching_bd2, e instr_fetching_bd20, e instr_fetching_bd21, e instr_fetching_bd22, e instr_fetching_bd23, e instr_fetching_bd24, e instr_fetching_bd25, e instr_fetching_bd26, e instr_fetching_bd27, e instr_fetching_bd28, e instr_fetching_bd29, e instr_fetching_bd3, e instr_fetching_bd30, e instr_fetching_bd31, e instr_fetching_bd32, e instr_fetching_bd33, e instr_fetching_bd34, e instr_fetching_bd35, e instr_fetching_bd36, e instr_fetching_bd4, e instr_fetching_bd5, e instr_fetching_bd6, e instr_fetching_bd7, e instr_fetching_bd8, e instr_fetching_bd9, e instr_fetching_bytecode_id, e instr_fetching_bytecode_size, e instr_fetching_bytes_to_read, e instr_fetching_exec_opcode, e instr_fetching_indirect, e instr_fetching_instr_abs_diff, e instr_fetching_instr_out_of_range, e instr_fetching_instr_size, e instr_fetching_op1, e instr_fetching_op2, e instr_fetching_op3, e instr_fetching_op4, e instr_fetching_op5, e instr_fetching_op6, e instr_fetching_op7, e instr_fetching_opcode_out_of_range, e instr_fetching_pc, e instr_fetching_pc_abs_diff, e instr_fetching_pc_out_of_range, e instr_fetching_pc_size_in_bits, e instr_fetching_sel, e instr_fetching_sel_has_tag, e instr_fetching_sel_op_dc_0, e instr_fetching_sel_op_dc_1, e instr_fetching_sel_op_dc_10, e instr_fetching_sel_op_dc_11, e instr_fetching_sel_op_dc_12, e instr_fetching_sel_op_dc_13, e instr_fetching_sel_op_dc_14, e instr_fetching_sel_op_dc_15, e instr_fetching_sel_op_dc_16, e instr_fetching_sel_op_dc_2, e instr_fetching_sel_op_dc_3, e instr_fetching_sel_op_dc_4, e instr_fetching_sel_op_dc_5, e instr_fetching_sel_op_dc_6, e instr_fetching_sel_op_dc_7, e instr_fetching_sel_op_dc_8, e instr_fetching_sel_op_dc_9, e instr_fetching_sel_parsing_err, e instr_fetching_sel_pc_in_range, e instr_fetching_sel_tag_is_op2, e instr_fetching_tag_out_of_range, e instr_fetching_tag_value, e internal_call_stack_context_id, e internal_call_stack_entered_call_id, e internal_call_stack_id, e internal_call_stack_return_id, e internal_call_stack_return_pc, e internal_call_stack_sel, e keccak_memory_ctr_end, e keccak_memory_ctr_inv, e keccak_memory_last, e keccak_memory_num_rounds, e keccak_memory_sel, e keccak_memory_single_tag_error, e keccak_memory_start_read, e keccak_memory_start_write, e keccak_memory_state_size_min_ctr_inv, e keccak_memory_tag, e keccak_memory_tag_min_u64_inv, e keccak_memory_val_24_, e keccakf1600_bitwise_and_op_id, e keccakf1600_bitwise_xor_op_id, e keccakf1600_dst_out_of_range_error, e keccakf1600_error, e keccakf1600_highest_slice_address, e keccakf1600_last, e keccakf1600_rot_64_min_len_01, e keccakf1600_rot_64_min_len_03, e keccakf1600_rot_64_min_len_11, e keccakf1600_rot_64_min_len_13, e keccakf1600_rot_64_min_len_20, e keccakf1600_rot_64_min_len_22, e keccakf1600_rot_64_min_len_24, e keccakf1600_rot_64_min_len_31, e keccakf1600_rot_64_min_len_34, e keccakf1600_rot_64_min_len_42, e keccakf1600_rot_len_02, e keccakf1600_rot_len_04, e keccakf1600_rot_len_10, e keccakf1600_rot_len_12, e keccakf1600_rot_len_14, e keccakf1600_rot_len_21, e keccakf1600_rot_len_23, e keccakf1600_rot_len_30, e keccakf1600_rot_len_32, e keccakf1600_rot_len_33, e keccakf1600_rot_len_40, e keccakf1600_rot_len_41, e keccakf1600_rot_len_43, e keccakf1600_rot_len_44, e keccakf1600_round_cst, e keccakf1600_round_inv, e keccakf1600_sel, e keccakf1600_sel_slice_read, e keccakf1600_sel_slice_write, e keccakf1600_src_addr, e keccakf1600_src_out_of_range_error, e keccakf1600_start, e keccakf1600_state_chi_00, e keccakf1600_state_chi_01, e keccakf1600_state_chi_02, e keccakf1600_state_chi_03, e keccakf1600_state_chi_04, e keccakf1600_state_chi_10, e keccakf1600_state_chi_11, e keccakf1600_state_chi_12, e keccakf1600_state_chi_13, e keccakf1600_state_chi_14, e keccakf1600_state_chi_20, e keccakf1600_state_chi_21, e keccakf1600_state_chi_22, e keccakf1600_state_chi_23, e keccakf1600_state_chi_24, e keccakf1600_state_chi_30, e keccakf1600_state_chi_31, e keccakf1600_state_chi_32, e keccakf1600_state_chi_33, e keccakf1600_state_chi_34, e keccakf1600_state_chi_40, e keccakf1600_state_chi_41, e keccakf1600_state_chi_42, e keccakf1600_state_chi_43, e keccakf1600_state_chi_44, e keccakf1600_state_iota_00, e keccakf1600_state_pi_and_00, e keccakf1600_state_pi_and_01, e keccakf1600_state_pi_and_02, e keccakf1600_state_pi_and_03, e keccakf1600_state_pi_and_04, e keccakf1600_state_pi_and_10, e keccakf1600_state_pi_and_11, e keccakf1600_state_pi_and_12, e keccakf1600_state_pi_and_13, e keccakf1600_state_pi_and_14, e keccakf1600_state_pi_and_20, e keccakf1600_state_pi_and_21, e keccakf1600_state_pi_and_22, e keccakf1600_state_pi_and_23, e keccakf1600_state_pi_and_24, e keccakf1600_state_pi_and_30, e keccakf1600_state_pi_and_31, e keccakf1600_state_pi_and_32, e keccakf1600_state_pi_and_33, e keccakf1600_state_pi_and_34, e keccakf1600_state_pi_and_40, e keccakf1600_state_pi_and_41, e keccakf1600_state_pi_and_42, e keccakf1600_state_pi_and_43, e keccakf1600_state_pi_and_44, e keccakf1600_state_pi_not_00, e keccakf1600_state_pi_not_01, e keccakf1600_state_pi_not_02, e keccakf1600_state_pi_not_03, e keccakf1600_state_pi_not_04, e keccakf1600_state_pi_not_10, e keccakf1600_state_pi_not_11, e keccakf1600_state_pi_not_12, e keccakf1600_state_pi_not_13, e keccakf1600_state_pi_not_14, e keccakf1600_state_pi_not_20, e keccakf1600_state_pi_not_21, e keccakf1600_state_pi_not_22, e keccakf1600_state_pi_not_23, e keccakf1600_state_pi_not_24, e keccakf1600_state_pi_not_30, e keccakf1600_state_pi_not_31, e keccakf1600_state_pi_not_32, e keccakf1600_state_pi_not_33, e keccakf1600_state_pi_not_34, e keccakf1600_state_pi_not_40, e keccakf1600_state_pi_not_41, e keccakf1600_state_pi_not_42, e keccakf1600_state_pi_not_43, e keccakf1600_state_pi_not_44, e keccakf1600_state_rho_01, e keccakf1600_state_rho_02, e keccakf1600_state_rho_03, e keccakf1600_state_rho_04, e keccakf1600_state_rho_10, e keccakf1600_state_rho_11, e keccakf1600_state_rho_12, e keccakf1600_state_rho_13, e keccakf1600_state_rho_14, e keccakf1600_state_rho_20, e keccakf1600_state_rho_21, e keccakf1600_state_rho_22, e keccakf1600_state_rho_23, e keccakf1600_state_rho_24, e keccakf1600_state_rho_30, e keccakf1600_state_rho_31, e keccakf1600_state_rho_32, e keccakf1600_state_rho_33, e keccakf1600_state_rho_34, e keccakf1600_state_rho_40, e keccakf1600_state_rho_41, e keccakf1600_state_rho_42, e keccakf1600_state_rho_43, e keccakf1600_state_rho_44, e keccakf1600_state_theta_00, e keccakf1600_state_theta_01, e keccakf1600_state_theta_02, e keccakf1600_state_theta_03, e keccakf1600_state_theta_04, e keccakf1600_state_theta_10, e keccakf1600_state_theta_11, e keccakf1600_state_theta_12, e keccakf1600_state_theta_13, e keccakf1600_state_theta_14, e keccakf1600_state_theta_20, e keccakf1600_state_theta_21, e keccakf1600_state_theta_22, e keccakf1600_state_theta_23, e keccakf1600_state_theta_24, e keccakf1600_state_theta_30, e keccakf1600_state_theta_31, e keccakf1600_state_theta_32, e keccakf1600_state_theta_33, e keccakf1600_state_theta_34, e keccakf1600_state_theta_40, e keccakf1600_state_theta_41, e keccakf1600_state_theta_42, e keccakf1600_state_theta_43, e keccakf1600_state_theta_44, e keccakf1600_state_theta_hi_01, e keccakf1600_state_theta_hi_02, e keccakf1600_state_theta_hi_03, e keccakf1600_state_theta_hi_04, e keccakf1600_state_theta_hi_10, e keccakf1600_state_theta_hi_11, e keccakf1600_state_theta_hi_12, e keccakf1600_state_theta_hi_13, e keccakf1600_state_theta_hi_14, e keccakf1600_state_theta_hi_20, e keccakf1600_state_theta_hi_21, e keccakf1600_state_theta_hi_22, e keccakf1600_state_theta_hi_23, e keccakf1600_state_theta_hi_24, e keccakf1600_state_theta_hi_30, e keccakf1600_state_theta_hi_31, e keccakf1600_state_theta_hi_32, e keccakf1600_state_theta_hi_33, e keccakf1600_state_theta_hi_34, e keccakf1600_state_theta_hi_40, e keccakf1600_state_theta_hi_41, e keccakf1600_state_theta_hi_42, e keccakf1600_state_theta_hi_43, e keccakf1600_state_theta_hi_44, e keccakf1600_state_theta_low_01, e keccakf1600_state_theta_low_02, e keccakf1600_state_theta_low_03, e keccakf1600_state_theta_low_04, e keccakf1600_state_theta_low_10, e keccakf1600_state_theta_low_11, e keccakf1600_state_theta_low_12, e keccakf1600_state_theta_low_13, e keccakf1600_state_theta_low_14, e keccakf1600_state_theta_low_20, e keccakf1600_state_theta_low_21, e keccakf1600_state_theta_low_22, e keccakf1600_state_theta_low_23, e keccakf1600_state_theta_low_24, e keccakf1600_state_theta_low_30, e keccakf1600_state_theta_low_31, e keccakf1600_state_theta_low_32, e keccakf1600_state_theta_low_33, e keccakf1600_state_theta_low_34, e keccakf1600_state_theta_low_40, e keccakf1600_state_theta_low_41, e keccakf1600_state_theta_low_42, e keccakf1600_state_theta_low_43, e keccakf1600_state_theta_low_44, e keccakf1600_tag_error, e keccakf1600_tag_u64, e keccakf1600_theta_combined_xor_0, e keccakf1600_theta_combined_xor_1, e keccakf1600_theta_combined_xor_2, e keccakf1600_theta_combined_xor_3, e keccakf1600_theta_combined_xor_4, e keccakf1600_theta_xor_01, e keccakf1600_theta_xor_02, e keccakf1600_theta_xor_03, e keccakf1600_theta_xor_11, e keccakf1600_theta_xor_12, e keccakf1600_theta_xor_13, e keccakf1600_theta_xor_21, e keccakf1600_theta_xor_22, e keccakf1600_theta_xor_23, e keccakf1600_theta_xor_31, e keccakf1600_theta_xor_32, e keccakf1600_theta_xor_33, e keccakf1600_theta_xor_41, e keccakf1600_theta_xor_42, e keccakf1600_theta_xor_43, e keccakf1600_theta_xor_row_0, e keccakf1600_theta_xor_row_1, e keccakf1600_theta_xor_row_2, e keccakf1600_theta_xor_row_3, e keccakf1600_theta_xor_row_4, e keccakf1600_theta_xor_row_low63_0, e keccakf1600_theta_xor_row_low63_1, e keccakf1600_theta_xor_row_low63_2, e keccakf1600_theta_xor_row_low63_3, e keccakf1600_theta_xor_row_low63_4, e keccakf1600_theta_xor_row_msb_0, e keccakf1600_theta_xor_row_msb_1, e keccakf1600_theta_xor_row_msb_2, e keccakf1600_theta_xor_row_msb_3, e keccakf1600_theta_xor_row_msb_4, e keccakf1600_theta_xor_row_rotl1_0, e keccakf1600_theta_xor_row_rotl1_1, e keccakf1600_theta_xor_row_rotl1_2, e keccakf1600_theta_xor_row_rotl1_3, e keccakf1600_theta_xor_row_rotl1_4, e l1_to_l2_message_tree_check_exists, e l1_to_l2_message_tree_check_l1_to_l2_message_tree_height, e l1_to_l2_message_tree_check_leaf_index, e l1_to_l2_message_tree_check_leaf_value, e l1_to_l2_message_tree_check_leaf_value_msg_hash_diff_inv, e l1_to_l2_message_tree_check_msg_hash, e l1_to_l2_message_tree_check_root, e l1_to_l2_message_tree_check_sel, e memory_address, e memory_clk, e memory_diff, e memory_glob_addr_diff_inv, e memory_last_access, e memory_limb_0_, e memory_limb_1_, e memory_limb_2_, e memory_max_bits, e memory_sel_addressing_base, e memory_sel_addressing_indirect_0_, e memory_sel_addressing_indirect_1_, e memory_sel_addressing_indirect_2_, e memory_sel_addressing_indirect_3_, e memory_sel_addressing_indirect_4_, e memory_sel_addressing_indirect_5_, e memory_sel_addressing_indirect_6_, e memory_sel_data_copy_read, e memory_sel_data_copy_write, e memory_sel_ecc_write_0_, e memory_sel_ecc_write_1_, e memory_sel_ecc_write_2_, e memory_sel_get_contract_instance_exists_write, e memory_sel_get_contract_instance_member_write, e memory_sel_keccak, e memory_sel_poseidon2_read_0_, e memory_sel_poseidon2_read_1_, e memory_sel_poseidon2_read_2_, e memory_sel_poseidon2_read_3_, e memory_sel_poseidon2_write_0_, e memory_sel_poseidon2_write_1_, e memory_sel_poseidon2_write_2_, e memory_sel_poseidon2_write_3_, e memory_sel_register_op_0_, e memory_sel_register_op_1_, e memory_sel_register_op_2_, e memory_sel_register_op_3_, e memory_sel_register_op_4_, e memory_sel_register_op_5_, e memory_sel_rng_chk, e memory_sel_rng_write, e memory_sel_sha256_op_0_, e memory_sel_sha256_op_1_, e memory_sel_sha256_op_2_, e memory_sel_sha256_op_3_, e memory_sel_sha256_op_4_, e memory_sel_sha256_op_5_, e memory_sel_sha256_op_6_, e memory_sel_sha256_op_7_, e memory_sel_sha256_read, e memory_sel_tag_is_ff, e memory_sel_to_radix_write, e memory_sel_unencrypted_log_read, e memory_space_id, e memory_tag_ff_diff_inv, e merkle_check_end, e merkle_check_index_is_even, e merkle_check_path_len_min_one_inv, e merkle_check_read_left_node, e merkle_check_read_output_hash, e merkle_check_read_right_node, e merkle_check_sibling, e merkle_check_start, e merkle_check_write_left_node, e merkle_check_write_output_hash, e merkle_check_write_right_node, e note_hash_tree_check_address, e note_hash_tree_check_discard, e note_hash_tree_check_exists, e note_hash_tree_check_first_nullifier, e note_hash_tree_check_first_nullifier_pi_index, e note_hash_tree_check_leaf_index, e note_hash_tree_check_next_leaf_value, e note_hash_tree_check_next_root, e note_hash_tree_check_nonce, e note_hash_tree_check_nonce_separator, e note_hash_tree_check_note_hash, e note_hash_tree_check_note_hash_index, e note_hash_tree_check_note_hash_tree_height, e note_hash_tree_check_prev_leaf_value, e note_hash_tree_check_prev_leaf_value_unique_note_hash_diff_inv, e note_hash_tree_check_prev_root, e note_hash_tree_check_public_inputs_index, e note_hash_tree_check_sel, e note_hash_tree_check_should_silo, e note_hash_tree_check_should_unique, e note_hash_tree_check_should_write_to_public_inputs, e note_hash_tree_check_siloed_note_hash, e note_hash_tree_check_siloing_separator, e note_hash_tree_check_unique_note_hash, e note_hash_tree_check_unique_note_hash_separator, e note_hash_tree_check_write, e nullifier_check_address, e nullifier_check_discard, e nullifier_check_exists, e nullifier_check_intermediate_root, e nullifier_check_leaf_not_exists, e nullifier_check_low_leaf_hash, e nullifier_check_low_leaf_index, e nullifier_check_low_leaf_next_index, e nullifier_check_low_leaf_next_nullifier, e nullifier_check_low_leaf_nullifier, e nullifier_check_new_leaf_hash, e nullifier_check_next_nullifier_inv, e nullifier_check_next_nullifier_is_nonzero, e nullifier_check_nullifier, e nullifier_check_nullifier_index, e nullifier_check_nullifier_low_leaf_nullifier_diff_inv, e nullifier_check_public_inputs_index, e nullifier_check_root, e nullifier_check_sel, e nullifier_check_should_insert, e nullifier_check_should_silo, e nullifier_check_should_write_to_public_inputs, e nullifier_check_siloed_nullifier, e nullifier_check_siloing_separator, e nullifier_check_tree_height, e nullifier_check_tree_size_before_write, e nullifier_check_updated_low_leaf_hash, e nullifier_check_updated_low_leaf_next_index, e nullifier_check_updated_low_leaf_next_nullifier, e nullifier_check_write, e nullifier_check_write_root, e poseidon2_hash_b_0, e poseidon2_hash_b_1, e poseidon2_hash_b_2, e poseidon2_hash_b_3, e poseidon2_hash_end, e poseidon2_hash_input_len, e poseidon2_hash_num_perm_rounds_rem_inv, e poseidon2_hash_padding, e poseidon2_perm_B_10_0, e poseidon2_perm_B_10_1, e poseidon2_perm_B_10_2, e poseidon2_perm_B_10_3, e poseidon2_perm_B_11_0, e poseidon2_perm_B_11_1, e poseidon2_perm_B_11_2, e poseidon2_perm_B_11_3, e poseidon2_perm_B_12_0, e poseidon2_perm_B_12_1, e poseidon2_perm_B_12_2, e poseidon2_perm_B_12_3, e poseidon2_perm_B_13_0, e poseidon2_perm_B_13_1, e poseidon2_perm_B_13_2, e poseidon2_perm_B_13_3, e poseidon2_perm_B_14_0, e poseidon2_perm_B_14_1, e poseidon2_perm_B_14_2, e poseidon2_perm_B_14_3, e poseidon2_perm_B_15_0, e poseidon2_perm_B_15_1, e poseidon2_perm_B_15_2, e poseidon2_perm_B_15_3, e poseidon2_perm_B_16_0, e poseidon2_perm_B_16_1, e poseidon2_perm_B_16_2, e poseidon2_perm_B_16_3, e poseidon2_perm_B_17_0, e poseidon2_perm_B_17_1, e poseidon2_perm_B_17_2, e poseidon2_perm_B_17_3, e poseidon2_perm_B_18_0, e poseidon2_perm_B_18_1, e poseidon2_perm_B_18_2, e poseidon2_perm_B_18_3, e poseidon2_perm_B_19_0, e poseidon2_perm_B_19_1, e poseidon2_perm_B_19_2, e poseidon2_perm_B_19_3, e poseidon2_perm_B_20_0, e poseidon2_perm_B_20_1, e poseidon2_perm_B_20_2, e poseidon2_perm_B_20_3, e poseidon2_perm_B_21_0, e poseidon2_perm_B_21_1, e poseidon2_perm_B_21_2, e poseidon2_perm_B_21_3, e poseidon2_perm_B_22_0, e poseidon2_perm_B_22_1, e poseidon2_perm_B_22_2, e poseidon2_perm_B_22_3, e poseidon2_perm_B_23_0, e poseidon2_perm_B_23_1, e poseidon2_perm_B_23_2, e poseidon2_perm_B_23_3, e poseidon2_perm_B_24_0, e poseidon2_perm_B_24_1, e poseidon2_perm_B_24_2, e poseidon2_perm_B_24_3, e poseidon2_perm_B_25_0, e poseidon2_perm_B_25_1, e poseidon2_perm_B_25_2, e poseidon2_perm_B_25_3, e poseidon2_perm_B_26_0, e poseidon2_perm_B_26_1, e poseidon2_perm_B_26_2, e poseidon2_perm_B_26_3, e poseidon2_perm_B_27_0, e poseidon2_perm_B_27_1, e poseidon2_perm_B_27_2, e poseidon2_perm_B_27_3, e poseidon2_perm_B_28_0, e poseidon2_perm_B_28_1, e poseidon2_perm_B_28_2, e poseidon2_perm_B_28_3, e poseidon2_perm_B_29_0, e poseidon2_perm_B_29_1, e poseidon2_perm_B_29_2, e poseidon2_perm_B_29_3, e poseidon2_perm_B_30_0, e poseidon2_perm_B_30_1, e poseidon2_perm_B_30_2, e poseidon2_perm_B_30_3, e poseidon2_perm_B_31_0, e poseidon2_perm_B_31_1, e poseidon2_perm_B_31_2, e poseidon2_perm_B_31_3, e poseidon2_perm_B_32_0, e poseidon2_perm_B_32_1, e poseidon2_perm_B_32_2, e poseidon2_perm_B_32_3, e poseidon2_perm_B_33_0, e poseidon2_perm_B_33_1, e poseidon2_perm_B_33_2, e poseidon2_perm_B_33_3, e poseidon2_perm_B_34_0, e poseidon2_perm_B_34_1, e poseidon2_perm_B_34_2, e poseidon2_perm_B_34_3, e poseidon2_perm_B_35_0, e poseidon2_perm_B_35_1, e poseidon2_perm_B_35_2, e poseidon2_perm_B_35_3, e poseidon2_perm_B_36_0, e poseidon2_perm_B_36_1, e poseidon2_perm_B_36_2, e poseidon2_perm_B_36_3, e poseidon2_perm_B_37_0, e poseidon2_perm_B_37_1, e poseidon2_perm_B_37_2, e poseidon2_perm_B_37_3, e poseidon2_perm_B_38_0, e poseidon2_perm_B_38_1, e poseidon2_perm_B_38_2, e poseidon2_perm_B_38_3, e poseidon2_perm_B_39_0, e poseidon2_perm_B_39_1, e poseidon2_perm_B_39_2, e poseidon2_perm_B_39_3, e poseidon2_perm_B_40_0, e poseidon2_perm_B_40_1, e poseidon2_perm_B_40_2, e poseidon2_perm_B_40_3, e poseidon2_perm_B_41_0, e poseidon2_perm_B_41_1, e poseidon2_perm_B_41_2, e poseidon2_perm_B_41_3, e poseidon2_perm_B_42_0, e poseidon2_perm_B_42_1, e poseidon2_perm_B_42_2, e poseidon2_perm_B_42_3, e poseidon2_perm_B_43_0, e poseidon2_perm_B_43_1, e poseidon2_perm_B_43_2, e poseidon2_perm_B_43_3, e poseidon2_perm_B_44_0, e poseidon2_perm_B_44_1, e poseidon2_perm_B_44_2, e poseidon2_perm_B_44_3, e poseidon2_perm_B_45_0, e poseidon2_perm_B_45_1, e poseidon2_perm_B_45_2, e poseidon2_perm_B_45_3, e poseidon2_perm_B_46_0, e poseidon2_perm_B_46_1, e poseidon2_perm_B_46_2, e poseidon2_perm_B_46_3, e poseidon2_perm_B_47_0, e poseidon2_perm_B_47_1, e poseidon2_perm_B_47_2, e poseidon2_perm_B_47_3, e poseidon2_perm_B_48_0, e poseidon2_perm_B_48_1, e poseidon2_perm_B_48_2, e poseidon2_perm_B_48_3, e poseidon2_perm_B_49_0, e poseidon2_perm_B_49_1, e poseidon2_perm_B_49_2, e poseidon2_perm_B_49_3, e poseidon2_perm_B_4_0, e poseidon2_perm_B_4_1, e poseidon2_perm_B_4_2, e poseidon2_perm_B_4_3, e poseidon2_perm_B_50_0, e poseidon2_perm_B_50_1, e poseidon2_perm_B_50_2, e poseidon2_perm_B_50_3, e poseidon2_perm_B_51_0, e poseidon2_perm_B_51_1, e poseidon2_perm_B_51_2, e poseidon2_perm_B_51_3, e poseidon2_perm_B_52_0, e poseidon2_perm_B_52_1, e poseidon2_perm_B_52_2, e poseidon2_perm_B_52_3, e poseidon2_perm_B_53_0, e poseidon2_perm_B_53_1, e poseidon2_perm_B_53_2, e poseidon2_perm_B_53_3, e poseidon2_perm_B_54_0, e poseidon2_perm_B_54_1, e poseidon2_perm_B_54_2, e poseidon2_perm_B_54_3, e poseidon2_perm_B_55_0, e poseidon2_perm_B_55_1, e poseidon2_perm_B_55_2, e poseidon2_perm_B_55_3, e poseidon2_perm_B_56_0, e poseidon2_perm_B_56_1, e poseidon2_perm_B_56_2, e poseidon2_perm_B_56_3, e poseidon2_perm_B_57_0, e poseidon2_perm_B_57_1, e poseidon2_perm_B_57_2, e poseidon2_perm_B_57_3, e poseidon2_perm_B_58_0, e poseidon2_perm_B_58_1, e poseidon2_perm_B_58_2, e poseidon2_perm_B_58_3, e poseidon2_perm_B_59_0, e poseidon2_perm_B_59_1, e poseidon2_perm_B_59_2, e poseidon2_perm_B_59_3, e poseidon2_perm_B_5_0, e poseidon2_perm_B_5_1, e poseidon2_perm_B_5_2, e poseidon2_perm_B_5_3, e poseidon2_perm_B_6_0, e poseidon2_perm_B_6_1, e poseidon2_perm_B_6_2, e poseidon2_perm_B_6_3, e poseidon2_perm_B_7_0, e poseidon2_perm_B_7_1, e poseidon2_perm_B_7_2, e poseidon2_perm_B_7_3, e poseidon2_perm_B_8_0, e poseidon2_perm_B_8_1, e poseidon2_perm_B_8_2, e poseidon2_perm_B_8_3, e poseidon2_perm_B_9_0, e poseidon2_perm_B_9_1, e poseidon2_perm_B_9_2, e poseidon2_perm_B_9_3, e poseidon2_perm_EXT_LAYER_4, e poseidon2_perm_EXT_LAYER_5, e poseidon2_perm_EXT_LAYER_6, e poseidon2_perm_EXT_LAYER_7, e poseidon2_perm_T_0_4, e poseidon2_perm_T_0_5, e poseidon2_perm_T_0_6, e poseidon2_perm_T_0_7, e poseidon2_perm_T_1_4, e poseidon2_perm_T_1_5, e poseidon2_perm_T_1_6, e poseidon2_perm_T_1_7, e poseidon2_perm_T_2_4, e poseidon2_perm_T_2_5, e poseidon2_perm_T_2_6, e poseidon2_perm_T_2_7, e poseidon2_perm_T_3_4, e poseidon2_perm_T_3_5, e poseidon2_perm_T_3_6, e poseidon2_perm_T_3_7, e poseidon2_perm_T_60_4, e poseidon2_perm_T_60_5, e poseidon2_perm_T_60_6, e poseidon2_perm_T_60_7, e poseidon2_perm_T_61_4, e poseidon2_perm_T_61_5, e poseidon2_perm_T_61_6, e poseidon2_perm_T_61_7, e poseidon2_perm_T_62_4, e poseidon2_perm_T_62_5, e poseidon2_perm_T_62_6, e poseidon2_perm_T_62_7, e poseidon2_perm_T_63_4, e poseidon2_perm_T_63_5, e poseidon2_perm_T_63_6, e poseidon2_perm_T_63_7, e poseidon2_perm_a_0, e poseidon2_perm_a_1, e poseidon2_perm_a_2, e poseidon2_perm_a_3, e poseidon2_perm_b_0, e poseidon2_perm_b_1, e poseidon2_perm_b_2, e poseidon2_perm_b_3, e poseidon2_perm_mem_batch_tag_inv, e poseidon2_perm_mem_err, e poseidon2_perm_mem_execution_clk, e poseidon2_perm_mem_input_0_, e poseidon2_perm_mem_input_1_, e poseidon2_perm_mem_input_2_, e poseidon2_perm_mem_input_3_, e poseidon2_perm_mem_input_tag_0_, e poseidon2_perm_mem_input_tag_1_, e poseidon2_perm_mem_input_tag_2_, e poseidon2_perm_mem_input_tag_3_, e poseidon2_perm_mem_max_mem_addr, e poseidon2_perm_mem_output_0_, e poseidon2_perm_mem_output_1_, e poseidon2_perm_mem_output_2_, e poseidon2_perm_mem_output_3_, e poseidon2_perm_mem_read_address_0_, e poseidon2_perm_mem_read_address_1_, e poseidon2_perm_mem_read_address_2_, e poseidon2_perm_mem_read_address_3_, e poseidon2_perm_mem_sel, e poseidon2_perm_mem_sel_dst_out_of_range_err, e poseidon2_perm_mem_sel_invalid_tag_err, e poseidon2_perm_mem_sel_should_exec, e poseidon2_perm_mem_sel_should_read_mem, e poseidon2_perm_mem_sel_src_out_of_range_err, e poseidon2_perm_mem_space_id, e poseidon2_perm_mem_write_address_0_, e poseidon2_perm_mem_write_address_1_, e poseidon2_perm_mem_write_address_2_, e poseidon2_perm_mem_write_address_3_, e poseidon2_perm_sel, e public_data_check_address, e public_data_check_clk_diff_hi, e public_data_check_clk_diff_lo, e public_data_check_const_two, e public_data_check_discard, e public_data_check_end, e public_data_check_final_value, e public_data_check_intermediate_root, e public_data_check_leaf_not_exists, e public_data_check_leaf_slot, e public_data_check_leaf_slot_low_leaf_slot_diff_inv, e public_data_check_length_pi_idx, e public_data_check_low_leaf_hash, e public_data_check_low_leaf_index, e public_data_check_low_leaf_next_index, e public_data_check_low_leaf_next_slot, e public_data_check_low_leaf_slot, e public_data_check_low_leaf_value, e public_data_check_new_leaf_hash, e public_data_check_next_slot_inv, e public_data_check_next_slot_is_nonzero, e public_data_check_non_discarded_write, e public_data_check_non_protocol_write, e public_data_check_not_end, e public_data_check_protocol_write, e public_data_check_public_data_writes_length, e public_data_check_root, e public_data_check_should_insert, e public_data_check_should_write_to_public_inputs, e public_data_check_siloing_separator, e public_data_check_slot, e public_data_check_tree_height, e public_data_check_tree_size_after_write, e public_data_check_tree_size_before_write, e public_data_check_updated_low_leaf_hash, e public_data_check_updated_low_leaf_next_index, e public_data_check_updated_low_leaf_next_slot, e public_data_check_updated_low_leaf_value, e public_data_check_value, e public_data_check_write, e public_data_check_write_root, e public_data_squash_check_clock, e public_data_squash_clk_diff_hi, e public_data_squash_clk_diff_lo, e public_data_squash_leaf_slot_increase, e public_data_squash_value, e range_check_dyn_diff, e range_check_dyn_rng_chk_bits, e range_check_dyn_rng_chk_pow_2, e range_check_is_lte_u112, e range_check_is_lte_u128, e range_check_is_lte_u16, e range_check_is_lte_u32, e range_check_is_lte_u48, e range_check_is_lte_u64, e range_check_is_lte_u80, e range_check_is_lte_u96, e range_check_rng_chk_bits, e range_check_sel, e range_check_sel_alu, e range_check_sel_gt, e range_check_sel_keccak, e range_check_sel_memory, e range_check_sel_r0_16_bit_rng_lookup, e range_check_sel_r1_16_bit_rng_lookup, e range_check_sel_r2_16_bit_rng_lookup, e range_check_sel_r3_16_bit_rng_lookup, e range_check_sel_r4_16_bit_rng_lookup, e range_check_sel_r5_16_bit_rng_lookup, e range_check_sel_r6_16_bit_rng_lookup, e range_check_u16_r0, e range_check_u16_r1, e range_check_u16_r2, e range_check_u16_r3, e range_check_u16_r4, e range_check_u16_r5, e range_check_u16_r6, e range_check_u16_r7, e range_check_value, e retrieved_bytecodes_tree_check_class_id, e retrieved_bytecodes_tree_check_class_id_low_leaf_class_id_diff_inv, e retrieved_bytecodes_tree_check_intermediate_root, e retrieved_bytecodes_tree_check_leaf_not_exists, e retrieved_bytecodes_tree_check_low_leaf_class_id, e retrieved_bytecodes_tree_check_low_leaf_hash, e retrieved_bytecodes_tree_check_low_leaf_index, e retrieved_bytecodes_tree_check_low_leaf_next_class_id, e retrieved_bytecodes_tree_check_low_leaf_next_index, e retrieved_bytecodes_tree_check_new_leaf_hash, e retrieved_bytecodes_tree_check_next_class_id_inv, e retrieved_bytecodes_tree_check_next_class_id_is_nonzero, e retrieved_bytecodes_tree_check_root, e retrieved_bytecodes_tree_check_sel, e retrieved_bytecodes_tree_check_should_insert, e retrieved_bytecodes_tree_check_tree_height, e retrieved_bytecodes_tree_check_tree_size_after_write, e retrieved_bytecodes_tree_check_tree_size_before_write, e retrieved_bytecodes_tree_check_updated_low_leaf_hash, e retrieved_bytecodes_tree_check_updated_low_leaf_next_class_id, e retrieved_bytecodes_tree_check_updated_low_leaf_next_index, e retrieved_bytecodes_tree_check_write, e retrieved_bytecodes_tree_check_write_root, e scalar_mul_bit, e scalar_mul_bit_radix, e scalar_mul_end, e scalar_mul_not_end, e scalar_mul_should_add, e sha256_a_and_b, e sha256_a_and_b_xor_a_and_c, e sha256_a_and_c, e sha256_a_rotr_13, e sha256_a_rotr_2, e sha256_a_rotr_22, e sha256_a_rotr_2_xor_a_rotr_13, e sha256_and_sel, e sha256_b_and_c, e sha256_batch_tag_inv, e sha256_ch, e sha256_computed_w_lhs, e sha256_computed_w_rhs, e sha256_e_and_f, e sha256_e_rotr_11, e sha256_e_rotr_25, e sha256_e_rotr_6, e sha256_e_rotr_6_xor_e_rotr_11, e sha256_err, e sha256_init_a, e sha256_init_b, e sha256_init_c, e sha256_init_d, e sha256_init_e, e sha256_init_f, e sha256_init_g, e sha256_init_h, e sha256_input, e sha256_input_addr, e sha256_input_rounds_rem_inv, e sha256_input_tag, e sha256_input_tag_diff_inv, e sha256_last, e sha256_latch, e sha256_lhs_a_13, e sha256_lhs_a_2, e sha256_lhs_a_22, e sha256_lhs_e_11, e sha256_lhs_e_25, e sha256_lhs_e_6, e sha256_lhs_w_10, e sha256_lhs_w_17, e sha256_lhs_w_18, e sha256_lhs_w_19, e sha256_lhs_w_3, e sha256_lhs_w_7, e sha256_maj, e sha256_max_input_addr, e sha256_max_mem_addr, e sha256_max_output_addr, e sha256_max_state_addr, e sha256_mem_out_of_range_err, e sha256_memory_address_0_, e sha256_memory_address_1_, e sha256_memory_address_2_, e sha256_memory_address_3_, e sha256_memory_address_4_, e sha256_memory_address_5_, e sha256_memory_address_6_, e sha256_memory_address_7_, e sha256_memory_register_0_, e sha256_memory_register_1_, e sha256_memory_register_2_, e sha256_memory_register_3_, e sha256_memory_register_4_, e sha256_memory_register_5_, e sha256_memory_register_6_, e sha256_memory_register_7_, e sha256_memory_tag_0_, e sha256_memory_tag_1_, e sha256_memory_tag_2_, e sha256_memory_tag_3_, e sha256_memory_tag_4_, e sha256_memory_tag_5_, e sha256_memory_tag_6_, e sha256_memory_tag_7_, e sha256_next_a_lhs, e sha256_next_a_rhs, e sha256_next_e_lhs, e sha256_next_e_rhs, e sha256_not_e, e sha256_not_e_and_g, e sha256_output_a_lhs, e sha256_output_a_rhs, e sha256_output_b_lhs, e sha256_output_b_rhs, e sha256_output_c_lhs, e sha256_output_c_rhs, e sha256_output_d_lhs, e sha256_output_d_rhs, e sha256_output_e_lhs, e sha256_output_e_rhs, e sha256_output_f_lhs, e sha256_output_f_rhs, e sha256_output_g_lhs, e sha256_output_g_rhs, e sha256_output_h_lhs, e sha256_output_h_rhs, e sha256_perform_round, e sha256_rhs_a_13, e sha256_rhs_a_2, e sha256_rhs_a_22, e sha256_rhs_e_11, e sha256_rhs_e_25, e sha256_rhs_e_6, e sha256_rhs_w_10, e sha256_rhs_w_17, e sha256_rhs_w_18, e sha256_rhs_w_19, e sha256_rhs_w_3, e sha256_rhs_w_7, e sha256_round_constant, e sha256_round_count, e sha256_rounds_remaining_inv, e sha256_rw, e sha256_s_0, e sha256_s_1, e sha256_sel_compute_w, e sha256_sel_input_out_of_range_err, e sha256_sel_invalid_input_row_tag_err, e sha256_sel_invalid_state_tag_err, e sha256_sel_mem_state_or_output, e sha256_sel_output_out_of_range_err, e sha256_sel_read_input_from_memory, e sha256_sel_state_out_of_range_err, e sha256_state_addr, e sha256_two_pow_10, e sha256_two_pow_11, e sha256_two_pow_13, e sha256_two_pow_17, e sha256_two_pow_18, e sha256_two_pow_19, e sha256_two_pow_2, e sha256_two_pow_22, e sha256_two_pow_25, e sha256_two_pow_3, e sha256_two_pow_32, e sha256_two_pow_6, e sha256_two_pow_7, e sha256_u32_tag, e sha256_w, e sha256_w_15_rotr_18, e sha256_w_15_rotr_7, e sha256_w_15_rotr_7_xor_w_15_rotr_18, e sha256_w_15_rshift_3, e sha256_w_2_rotr_17, e sha256_w_2_rotr_17_xor_w_2_rotr_19, e sha256_w_2_rotr_19, e sha256_w_2_rshift_10, e sha256_w_s_0, e sha256_w_s_1, e sha256_xor_sel, e to_radix_end, e to_radix_found, e to_radix_is_unsafe_limb, e to_radix_limb_p_diff, e to_radix_limb_radix_diff, e to_radix_mem_err, e to_radix_mem_input_validation_error, e to_radix_mem_last, e to_radix_mem_limb_index_to_lookup, e to_radix_mem_limb_value, e to_radix_mem_max_mem_size, e to_radix_mem_num_limbs_inv, e to_radix_mem_num_limbs_minus_one_inv, e to_radix_mem_output_tag, e to_radix_mem_sel_dst_out_of_range_err, e to_radix_mem_sel_invalid_bitwise_radix, e to_radix_mem_sel_invalid_num_limbs_err, e to_radix_mem_sel_num_limbs_is_zero, e to_radix_mem_sel_radix_gt_256_err, e to_radix_mem_sel_radix_lt_2_err, e to_radix_mem_sel_truncation_error, e to_radix_mem_sel_value_is_zero, e to_radix_mem_two, e to_radix_mem_two_five_six, e to_radix_mem_value_found, e to_radix_mem_value_inv, e to_radix_mem_write_addr_upper_bound, e to_radix_not_end, e to_radix_p_limb, e to_radix_rem_inverse, e to_radix_safety_diff_inverse, e tx_array_length_l2_to_l1_messages_pi_offset, e tx_array_length_note_hashes_pi_offset, e tx_array_length_nullifiers_pi_offset, e tx_calldata_hash, e tx_calldata_size, e tx_contract_addr, e tx_effective_fee_per_da_gas, e tx_effective_fee_per_l2_gas, e tx_end_phase, e tx_fee_juice_balance_slot, e tx_fee_juice_balances_slot_constant, e tx_fee_juice_contract_address, e tx_fee_payer, e tx_fee_payer_balance, e tx_fee_payer_new_balance, e tx_fee_payer_pi_offset, e tx_fields_length_unencrypted_logs_pi_offset, e tx_gas_limit_pi_offset, e tx_gas_used_pi_offset, e tx_is_cleanup, e tx_is_collect_fee, e tx_is_padded, e tx_is_public_call_request, e tx_is_static, e tx_is_tree_insert_phase, e tx_is_tree_padding, e tx_l1_l2_pi_offset, e tx_l2_l1_msg_content, e tx_l2_l1_msg_contract_address, e tx_l2_l1_msg_recipient, e tx_leaf_value, e tx_msg_sender, e tx_next_da_gas_used, e tx_next_da_gas_used_sent_to_enqueued_call, e tx_next_l2_gas_used, e tx_next_l2_gas_used_sent_to_enqueued_call, e tx_next_note_hash_tree_root, e tx_next_note_hash_tree_size, e tx_next_nullifier_tree_root, e tx_next_nullifier_tree_size, e tx_next_num_l2_to_l1_messages, e tx_next_num_note_hashes_emitted, e tx_next_num_nullifiers_emitted, e tx_next_num_unencrypted_log_fields, e tx_next_phase_on_revert, e tx_next_public_data_tree_root, e tx_next_public_data_tree_size, e tx_next_retrieved_bytecodes_tree_root, e tx_next_retrieved_bytecodes_tree_size, e tx_next_written_public_data_slots_tree_root, e tx_next_written_public_data_slots_tree_size, e tx_note_hash_pi_offset, e tx_nullifier_limit_error, e tx_nullifier_pi_offset, e tx_prev_da_gas_used_sent_to_enqueued_call, e tx_prev_l2_gas_used_sent_to_enqueued_call, e tx_public_data_pi_offset, e tx_read_pi_length_offset, e tx_read_pi_start_offset, e tx_remaining_phase_inv, e tx_remaining_phase_minus_one_inv, e tx_remaining_side_effects_inv, e tx_reverted_pi_offset, e tx_sel_non_revertible_append_l2_l1_msg, e tx_sel_non_revertible_append_note_hash, e tx_sel_non_revertible_append_nullifier, e tx_sel_read_phase_length, e tx_sel_read_trees_and_gas_used, e tx_sel_revertible_append_l2_l1_msg, e tx_sel_revertible_append_note_hash, e tx_sel_revertible_append_nullifier, e tx_setup_phase_value, e tx_should_l2_l1_msg_append, e tx_should_note_hash_append, e tx_should_nullifier_append, e tx_should_process_call_request, e tx_should_read_gas_limit, e tx_should_try_l2_l1_msg_append, e tx_should_try_note_hash_append, e tx_should_try_nullifier_append, e tx_uint32_max, e tx_write_pi_offset, e update_check_address, e update_check_current_class_id, e update_check_delayed_public_mutable_hash_slot, e update_check_delayed_public_mutable_slot, e update_check_deployer_protocol_contract_address, e update_check_hash_not_zero, e update_check_original_class_id, e update_check_public_data_tree_root, e update_check_public_leaf_index_domain_separator, e update_check_sel, e update_check_timestamp, e update_check_timestamp_is_lt_timestamp_of_change, e update_check_timestamp_of_change, e update_check_timestamp_of_change_bit_size, e update_check_timestamp_pi_offset, e update_check_update_hash, e update_check_update_hash_inv, e update_check_update_hi_metadata, e update_check_update_hi_metadata_bit_size, e update_check_update_post_class_id_is_zero, e update_check_update_post_class_inv, e update_check_update_pre_class_id_is_zero, e update_check_update_pre_class_inv, e update_check_update_preimage_metadata, e update_check_update_preimage_post_class_id, e update_check_update_preimage_pre_class_id, e update_check_updated_class_ids_slot, e written_public_data_slots_tree_check_address, e written_public_data_slots_tree_check_intermediate_root, e written_public_data_slots_tree_check_leaf_not_exists, e written_public_data_slots_tree_check_leaf_slot, e written_public_data_slots_tree_check_low_leaf_hash, e written_public_data_slots_tree_check_low_leaf_index, e written_public_data_slots_tree_check_low_leaf_next_index, e written_public_data_slots_tree_check_low_leaf_next_slot, e written_public_data_slots_tree_check_low_leaf_slot, e written_public_data_slots_tree_check_new_leaf_hash, e written_public_data_slots_tree_check_next_slot_inv, e written_public_data_slots_tree_check_next_slot_is_nonzero, e written_public_data_slots_tree_check_root, e written_public_data_slots_tree_check_sel, e written_public_data_slots_tree_check_should_insert, e written_public_data_slots_tree_check_siloing_separator, e written_public_data_slots_tree_check_slot, e written_public_data_slots_tree_check_slot_low_leaf_slot_diff_inv, e written_public_data_slots_tree_check_tree_height, e written_public_data_slots_tree_check_tree_size_after_write, e written_public_data_slots_tree_check_tree_size_before_write, e written_public_data_slots_tree_check_updated_low_leaf_hash, e written_public_data_slots_tree_check_updated_low_leaf_next_index, e written_public_data_slots_tree_check_updated_low_leaf_next_slot, e written_public_data_slots_tree_check_write, e written_public_data_slots_tree_check_write_root, e lookup_range_check_dyn_rng_chk_pow_2_counts, e lookup_range_check_dyn_diff_is_u16_counts, e lookup_range_check_r0_is_u16_counts, e lookup_range_check_r1_is_u16_counts, e lookup_range_check_r2_is_u16_counts, e lookup_range_check_r3_is_u16_counts, e lookup_range_check_r4_is_u16_counts, e lookup_range_check_r5_is_u16_counts, e lookup_range_check_r6_is_u16_counts, e lookup_range_check_r7_is_u16_counts, e lookup_ff_gt_a_lo_range_counts, e lookup_ff_gt_a_hi_range_counts, e lookup_gt_gt_range_counts, e lookup_alu_tag_max_bits_value_counts, e lookup_alu_range_check_decomposition_a_lo_counts, e lookup_alu_range_check_decomposition_a_hi_counts, e lookup_alu_range_check_decomposition_b_lo_counts, e lookup_alu_range_check_decomposition_b_hi_counts, e lookup_alu_range_check_mul_c_hi_counts, e lookup_alu_ff_gt_counts, e lookup_alu_int_gt_counts, e lookup_alu_shifts_two_pow_counts, e lookup_alu_large_trunc_canonical_dec_counts, e lookup_alu_range_check_trunc_mid_counts, e lookup_bitwise_integral_tag_length_counts, e lookup_bitwise_byte_operations_counts, e lookup_memory_range_check_limb_0_counts, e lookup_memory_range_check_limb_1_counts, e lookup_memory_range_check_limb_2_counts, e lookup_memory_tag_max_bits_counts, e lookup_memory_range_check_write_tagged_value_counts, e lookup_keccakf1600_theta_xor_01_counts, e lookup_keccakf1600_theta_xor_02_counts, e lookup_keccakf1600_theta_xor_03_counts, e lookup_keccakf1600_theta_xor_row_0_counts, e lookup_keccakf1600_theta_xor_11_counts, e lookup_keccakf1600_theta_xor_12_counts, e lookup_keccakf1600_theta_xor_13_counts, e lookup_keccakf1600_theta_xor_row_1_counts, e lookup_keccakf1600_theta_xor_21_counts, e lookup_keccakf1600_theta_xor_22_counts, e lookup_keccakf1600_theta_xor_23_counts, e lookup_keccakf1600_theta_xor_row_2_counts, e lookup_keccakf1600_theta_xor_31_counts, e lookup_keccakf1600_theta_xor_32_counts, e lookup_keccakf1600_theta_xor_33_counts, e lookup_keccakf1600_theta_xor_row_3_counts, e lookup_keccakf1600_theta_xor_41_counts, e lookup_keccakf1600_theta_xor_42_counts, e lookup_keccakf1600_theta_xor_43_counts, e lookup_keccakf1600_theta_xor_row_4_counts, e lookup_keccakf1600_theta_combined_xor_0_counts, e lookup_keccakf1600_theta_combined_xor_1_counts, e lookup_keccakf1600_theta_combined_xor_2_counts, e lookup_keccakf1600_theta_combined_xor_3_counts, e lookup_keccakf1600_theta_combined_xor_4_counts, e lookup_keccakf1600_state_theta_00_counts, e lookup_keccakf1600_state_theta_01_counts, e lookup_keccakf1600_state_theta_02_counts, e lookup_keccakf1600_state_theta_03_counts, e lookup_keccakf1600_state_theta_04_counts, e lookup_keccakf1600_state_theta_10_counts, e lookup_keccakf1600_state_theta_11_counts, e lookup_keccakf1600_state_theta_12_counts, e lookup_keccakf1600_state_theta_13_counts, e lookup_keccakf1600_state_theta_14_counts, e lookup_keccakf1600_state_theta_20_counts, e lookup_keccakf1600_state_theta_21_counts, e lookup_keccakf1600_state_theta_22_counts, e lookup_keccakf1600_state_theta_23_counts, e lookup_keccakf1600_state_theta_24_counts, e lookup_keccakf1600_state_theta_30_counts, e lookup_keccakf1600_state_theta_31_counts, e lookup_keccakf1600_state_theta_32_counts, e lookup_keccakf1600_state_theta_33_counts, e lookup_keccakf1600_state_theta_34_counts, e lookup_keccakf1600_state_theta_40_counts, e lookup_keccakf1600_state_theta_41_counts, e lookup_keccakf1600_state_theta_42_counts, e lookup_keccakf1600_state_theta_43_counts, e lookup_keccakf1600_state_theta_44_counts, e lookup_keccakf1600_theta_limb_02_range_counts, e lookup_keccakf1600_theta_limb_04_range_counts, e lookup_keccakf1600_theta_limb_10_range_counts, e lookup_keccakf1600_theta_limb_12_range_counts, e lookup_keccakf1600_theta_limb_14_range_counts, e lookup_keccakf1600_theta_limb_21_range_counts, e lookup_keccakf1600_theta_limb_23_range_counts, e lookup_keccakf1600_theta_limb_30_range_counts, e lookup_keccakf1600_theta_limb_32_range_counts, e lookup_keccakf1600_theta_limb_33_range_counts, e lookup_keccakf1600_theta_limb_40_range_counts, e lookup_keccakf1600_theta_limb_41_range_counts, e lookup_keccakf1600_theta_limb_43_range_counts, e lookup_keccakf1600_theta_limb_44_range_counts, e lookup_keccakf1600_theta_limb_01_range_counts, e lookup_keccakf1600_theta_limb_03_range_counts, e lookup_keccakf1600_theta_limb_11_range_counts, e lookup_keccakf1600_theta_limb_13_range_counts, e lookup_keccakf1600_theta_limb_20_range_counts, e lookup_keccakf1600_theta_limb_22_range_counts, e lookup_keccakf1600_theta_limb_24_range_counts, e lookup_keccakf1600_theta_limb_31_range_counts, e lookup_keccakf1600_theta_limb_34_range_counts, e lookup_keccakf1600_theta_limb_42_range_counts, e lookup_keccakf1600_state_pi_and_00_counts, e lookup_keccakf1600_state_pi_and_01_counts, e lookup_keccakf1600_state_pi_and_02_counts, e lookup_keccakf1600_state_pi_and_03_counts, e lookup_keccakf1600_state_pi_and_04_counts, e lookup_keccakf1600_state_pi_and_10_counts, e lookup_keccakf1600_state_pi_and_11_counts, e lookup_keccakf1600_state_pi_and_12_counts, e lookup_keccakf1600_state_pi_and_13_counts, e lookup_keccakf1600_state_pi_and_14_counts, e lookup_keccakf1600_state_pi_and_20_counts, e lookup_keccakf1600_state_pi_and_21_counts, e lookup_keccakf1600_state_pi_and_22_counts, e lookup_keccakf1600_state_pi_and_23_counts, e lookup_keccakf1600_state_pi_and_24_counts, e lookup_keccakf1600_state_pi_and_30_counts, e lookup_keccakf1600_state_pi_and_31_counts, e lookup_keccakf1600_state_pi_and_32_counts, e lookup_keccakf1600_state_pi_and_33_counts, e lookup_keccakf1600_state_pi_and_34_counts, e lookup_keccakf1600_state_pi_and_40_counts, e lookup_keccakf1600_state_pi_and_41_counts, e lookup_keccakf1600_state_pi_and_42_counts, e lookup_keccakf1600_state_pi_and_43_counts, e lookup_keccakf1600_state_pi_and_44_counts, e lookup_keccakf1600_state_chi_00_counts, e lookup_keccakf1600_state_chi_01_counts, e lookup_keccakf1600_state_chi_02_counts, e lookup_keccakf1600_state_chi_03_counts, e lookup_keccakf1600_state_chi_04_counts, e lookup_keccakf1600_state_chi_10_counts, e lookup_keccakf1600_state_chi_11_counts, e lookup_keccakf1600_state_chi_12_counts, e lookup_keccakf1600_state_chi_13_counts, e lookup_keccakf1600_state_chi_14_counts, e lookup_keccakf1600_state_chi_20_counts, e lookup_keccakf1600_state_chi_21_counts, e lookup_keccakf1600_state_chi_22_counts, e lookup_keccakf1600_state_chi_23_counts, e lookup_keccakf1600_state_chi_24_counts, e lookup_keccakf1600_state_chi_30_counts, e lookup_keccakf1600_state_chi_31_counts, e lookup_keccakf1600_state_chi_32_counts, e lookup_keccakf1600_state_chi_33_counts, e lookup_keccakf1600_state_chi_34_counts, e lookup_keccakf1600_state_chi_40_counts, e lookup_keccakf1600_state_chi_41_counts, e lookup_keccakf1600_state_chi_42_counts, e lookup_keccakf1600_state_chi_43_counts, e lookup_keccakf1600_state_chi_44_counts, e lookup_keccakf1600_round_cst_counts, e lookup_keccakf1600_state_iota_00_counts, e lookup_keccakf1600_src_out_of_range_toggle_counts, e lookup_keccakf1600_dst_out_of_range_toggle_counts, e lookup_sha256_range_comp_w_lhs_counts, e lookup_sha256_range_comp_w_rhs_counts, e lookup_sha256_range_rhs_w_7_counts, e lookup_sha256_range_rhs_w_18_counts, e lookup_sha256_range_rhs_w_3_counts, e lookup_sha256_w_s_0_xor_0_counts, e lookup_sha256_w_s_0_xor_1_counts, e lookup_sha256_range_rhs_w_17_counts, e lookup_sha256_range_rhs_w_19_counts, e lookup_sha256_range_rhs_w_10_counts, e lookup_sha256_w_s_1_xor_0_counts, e lookup_sha256_w_s_1_xor_1_counts, e lookup_sha256_range_rhs_e_6_counts, e lookup_sha256_range_rhs_e_11_counts, e lookup_sha256_range_rhs_e_25_counts, e lookup_sha256_s_1_xor_0_counts, e lookup_sha256_s_1_xor_1_counts, e lookup_sha256_ch_and_0_counts, e lookup_sha256_ch_and_1_counts, e lookup_sha256_ch_xor_counts, e lookup_sha256_round_constant_counts, e lookup_sha256_range_rhs_a_2_counts, e lookup_sha256_range_rhs_a_13_counts, e lookup_sha256_range_rhs_a_22_counts, e lookup_sha256_s_0_xor_0_counts, e lookup_sha256_s_0_xor_1_counts, e lookup_sha256_maj_and_0_counts, e lookup_sha256_maj_and_1_counts, e lookup_sha256_maj_and_2_counts, e lookup_sha256_maj_xor_0_counts, e lookup_sha256_maj_xor_1_counts, e lookup_sha256_range_comp_next_a_lhs_counts, e lookup_sha256_range_comp_next_a_rhs_counts, e lookup_sha256_range_comp_next_e_lhs_counts, e lookup_sha256_range_comp_next_e_rhs_counts, e lookup_sha256_range_comp_a_lhs_counts, e lookup_sha256_range_comp_a_rhs_counts, e lookup_sha256_range_comp_b_lhs_counts, e lookup_sha256_range_comp_b_rhs_counts, e lookup_sha256_range_comp_c_lhs_counts, e lookup_sha256_range_comp_c_rhs_counts, e lookup_sha256_range_comp_d_lhs_counts, e lookup_sha256_range_comp_d_rhs_counts, e lookup_sha256_range_comp_e_lhs_counts, e lookup_sha256_range_comp_e_rhs_counts, e lookup_sha256_range_comp_f_lhs_counts, e lookup_sha256_range_comp_f_rhs_counts, e lookup_sha256_range_comp_g_lhs_counts, e lookup_sha256_range_comp_g_rhs_counts, e lookup_sha256_range_comp_h_lhs_counts, e lookup_sha256_range_comp_h_rhs_counts, e lookup_sha256_mem_check_state_addr_in_range_counts, e lookup_sha256_mem_check_input_addr_in_range_counts, e lookup_sha256_mem_check_output_addr_in_range_counts, e lookup_ecc_mem_check_dst_addr_in_range_counts, e lookup_ecc_mem_input_output_ecc_add_counts, e lookup_poseidon2_mem_check_src_addr_in_range_counts, e lookup_poseidon2_mem_check_dst_addr_in_range_counts, e lookup_poseidon2_mem_input_output_poseidon2_perm_counts, e lookup_to_radix_limb_range_counts, e lookup_to_radix_limb_less_than_radix_range_counts, e lookup_to_radix_fetch_safe_limbs_counts, e lookup_to_radix_fetch_p_limb_counts, e lookup_to_radix_limb_p_diff_range_counts, e lookup_scalar_mul_to_radix_counts, e lookup_scalar_mul_double_counts, e lookup_scalar_mul_add_counts, e lookup_to_radix_mem_check_dst_addr_in_range_counts, e lookup_to_radix_mem_check_radix_lt_2_counts, e lookup_to_radix_mem_check_radix_gt_256_counts, e lookup_to_radix_mem_input_output_to_radix_counts, e lookup_context_ctx_stack_rollback_counts, e lookup_context_ctx_stack_return_counts, e lookup_poseidon2_hash_poseidon2_perm_counts, e lookup_calldata_hashing_get_calldata_field_0_counts, e lookup_calldata_hashing_get_calldata_field_1_counts, e lookup_calldata_hashing_get_calldata_field_2_counts, e lookup_calldata_hashing_check_final_size_counts, e lookup_calldata_hashing_poseidon2_hash_counts, e lookup_calldata_range_check_context_id_diff_counts, e lookup_data_copy_offset_plus_size_is_gt_data_size_counts, e lookup_data_copy_check_src_addr_in_range_counts, e lookup_data_copy_check_dst_addr_in_range_counts, e lookup_data_copy_data_index_upper_bound_gt_offset_counts, e lookup_data_copy_col_read_counts, e lookup_addressing_relative_overflow_result_0_counts, e lookup_addressing_relative_overflow_result_1_counts, e lookup_addressing_relative_overflow_result_2_counts, e lookup_addressing_relative_overflow_result_3_counts, e lookup_addressing_relative_overflow_result_4_counts, e lookup_addressing_relative_overflow_result_5_counts, e lookup_addressing_relative_overflow_result_6_counts, e lookup_gas_addressing_gas_read_counts, e lookup_gas_is_out_of_gas_l2_counts, e lookup_gas_is_out_of_gas_da_counts, e lookup_merkle_check_merkle_poseidon2_read_counts, e lookup_merkle_check_merkle_poseidon2_write_counts, e lookup_nullifier_check_silo_poseidon2_counts, e lookup_nullifier_check_low_leaf_poseidon2_counts, e lookup_nullifier_check_updated_low_leaf_poseidon2_counts, e lookup_nullifier_check_low_leaf_merkle_check_counts, e lookup_nullifier_check_low_leaf_nullifier_validation_counts, e lookup_nullifier_check_low_leaf_next_nullifier_validation_counts, e lookup_nullifier_check_new_leaf_poseidon2_counts, e lookup_nullifier_check_new_leaf_merkle_check_counts, e lookup_nullifier_check_write_nullifier_to_public_inputs_counts, e lookup_public_data_squash_leaf_slot_increase_ff_gt_counts, e lookup_public_data_squash_clk_diff_range_lo_counts, e lookup_public_data_squash_clk_diff_range_hi_counts, e lookup_public_data_check_clk_diff_range_lo_counts, e lookup_public_data_check_clk_diff_range_hi_counts, e lookup_public_data_check_silo_poseidon2_counts, e lookup_public_data_check_low_leaf_slot_validation_counts, e lookup_public_data_check_low_leaf_next_slot_validation_counts, e lookup_public_data_check_low_leaf_poseidon2_0_counts, e lookup_public_data_check_low_leaf_poseidon2_1_counts, e lookup_public_data_check_updated_low_leaf_poseidon2_0_counts, e lookup_public_data_check_updated_low_leaf_poseidon2_1_counts, e lookup_public_data_check_low_leaf_merkle_check_counts, e lookup_public_data_check_new_leaf_poseidon2_0_counts, e lookup_public_data_check_new_leaf_poseidon2_1_counts, e lookup_public_data_check_new_leaf_merkle_check_counts, e lookup_public_data_check_write_public_data_to_public_inputs_counts, e lookup_public_data_check_write_writes_length_to_public_inputs_counts, e lookup_written_public_data_slots_tree_check_silo_poseidon2_counts, e lookup_written_public_data_slots_tree_check_low_leaf_poseidon2_counts, e lookup_written_public_data_slots_tree_check_updated_low_leaf_poseidon2_counts, e lookup_written_public_data_slots_tree_check_low_leaf_merkle_check_counts, e lookup_written_public_data_slots_tree_check_low_leaf_slot_validation_counts, e lookup_written_public_data_slots_tree_check_low_leaf_next_slot_validation_counts, e lookup_written_public_data_slots_tree_check_new_leaf_poseidon2_counts, e lookup_written_public_data_slots_tree_check_new_leaf_merkle_check_counts, e lookup_l1_to_l2_message_tree_check_merkle_check_counts, e lookup_retrieved_bytecodes_tree_check_low_leaf_poseidon2_counts, e lookup_retrieved_bytecodes_tree_check_updated_low_leaf_poseidon2_counts, e lookup_retrieved_bytecodes_tree_check_low_leaf_merkle_check_counts, e lookup_retrieved_bytecodes_tree_check_low_leaf_class_id_validation_counts, e lookup_retrieved_bytecodes_tree_check_low_leaf_next_class_id_validation_counts, e lookup_retrieved_bytecodes_tree_check_new_leaf_poseidon2_counts, e lookup_retrieved_bytecodes_tree_check_new_leaf_merkle_check_counts, e lookup_address_derivation_salted_initialization_hash_poseidon2_0_counts, e lookup_address_derivation_salted_initialization_hash_poseidon2_1_counts, e lookup_address_derivation_partial_address_poseidon2_counts, e lookup_address_derivation_public_keys_hash_poseidon2_0_counts, e lookup_address_derivation_public_keys_hash_poseidon2_1_counts, e lookup_address_derivation_public_keys_hash_poseidon2_2_counts, e lookup_address_derivation_public_keys_hash_poseidon2_3_counts, e lookup_address_derivation_public_keys_hash_poseidon2_4_counts, e lookup_address_derivation_preaddress_poseidon2_counts, e lookup_address_derivation_preaddress_scalar_mul_counts, e lookup_address_derivation_address_ecadd_counts, e lookup_bc_decomposition_bytes_are_bytes_counts, e lookup_bc_hashing_check_final_bytes_remaining_counts, e lookup_bc_hashing_poseidon2_hash_counts, e lookup_update_check_timestamp_from_public_inputs_counts, e lookup_update_check_delayed_public_mutable_slot_poseidon2_counts, e lookup_update_check_update_hash_public_data_read_counts, e lookup_update_check_update_hash_poseidon2_counts, e lookup_update_check_update_hi_metadata_range_counts, e lookup_update_check_update_lo_metadata_range_counts, e lookup_update_check_timestamp_is_lt_timestamp_of_change_counts, e lookup_contract_instance_retrieval_check_protocol_address_range_counts, e lookup_contract_instance_retrieval_read_derived_address_from_public_inputs_counts, e lookup_contract_instance_retrieval_deployment_nullifier_read_counts, e lookup_contract_instance_retrieval_address_derivation_counts, e lookup_contract_instance_retrieval_update_check_counts, e lookup_bc_retrieval_contract_instance_retrieval_counts, e lookup_bc_retrieval_is_new_class_check_counts, e lookup_bc_retrieval_class_id_derivation_counts, e lookup_bc_retrieval_retrieved_bytecodes_insertion_counts, e lookup_instr_fetching_pc_abs_diff_positive_counts, e lookup_instr_fetching_instr_abs_diff_positive_counts, e lookup_instr_fetching_tag_value_validation_counts, e lookup_instr_fetching_bytecode_size_from_bc_dec_counts, e lookup_instr_fetching_bytes_from_bc_dec_counts, e lookup_instr_fetching_wire_instruction_info_counts, e lookup_class_id_derivation_class_id_poseidon2_0_counts, e lookup_class_id_derivation_class_id_poseidon2_1_counts, e lookup_get_env_var_precomputed_info_counts, e lookup_get_env_var_read_from_public_inputs_col0_counts, e lookup_get_env_var_read_from_public_inputs_col1_counts, e lookup_get_contract_instance_precomputed_info_counts, e lookup_get_contract_instance_contract_instance_retrieval_counts, e lookup_internal_call_unwind_call_stack_counts, e lookup_external_call_is_l2_gas_left_gt_allocated_counts, e lookup_external_call_is_da_gas_left_gt_allocated_counts, e lookup_sload_storage_read_counts, e lookup_sstore_record_written_storage_slot_counts, e lookup_note_hash_tree_check_silo_poseidon2_counts, e lookup_note_hash_tree_check_read_first_nullifier_counts, e lookup_note_hash_tree_check_nonce_computation_poseidon2_counts, e lookup_note_hash_tree_check_unique_note_hash_poseidon2_counts, e lookup_note_hash_tree_check_merkle_check_counts, e lookup_note_hash_tree_check_write_note_hash_to_public_inputs_counts, e lookup_notehash_exists_note_hash_leaf_index_in_range_counts, e lookup_notehash_exists_note_hash_read_counts, e lookup_emit_notehash_notehash_tree_write_counts, e lookup_l1_to_l2_message_exists_l1_to_l2_msg_leaf_index_in_range_counts, e lookup_l1_to_l2_message_exists_l1_to_l2_msg_read_counts, e lookup_nullifier_exists_nullifier_exists_check_counts, e lookup_emit_nullifier_write_nullifier_counts, e lookup_emit_unencrypted_log_check_memory_out_of_bounds_counts, e lookup_emit_unencrypted_log_check_log_fields_count_counts, e lookup_emit_unencrypted_log_write_data_to_public_inputs_counts, e lookup_send_l2_to_l1_msg_write_l2_to_l1_msg_counts, e lookup_execution_bytecode_retrieval_result_counts, e lookup_execution_instruction_fetching_result_counts, e lookup_execution_instruction_fetching_body_counts, e lookup_execution_exec_spec_read_counts, e lookup_execution_dyn_l2_factor_bitwise_counts, e lookup_execution_check_radix_gt_256_counts, e lookup_execution_get_p_limbs_counts, e lookup_execution_get_max_limbs_counts, e lookup_execution_check_written_storage_slot_counts, e lookup_execution_dispatch_to_alu_counts, e lookup_execution_dispatch_to_bitwise_counts, e lookup_execution_dispatch_to_cast_counts, e lookup_execution_dispatch_to_set_counts, e lookup_tx_context_public_inputs_note_hash_tree_counts, e lookup_tx_context_public_inputs_nullifier_tree_counts, e lookup_tx_context_public_inputs_public_data_tree_counts, e lookup_tx_context_public_inputs_l1_l2_tree_counts, e lookup_tx_context_public_inputs_gas_used_counts, e lookup_tx_context_public_inputs_read_gas_limit_counts, e lookup_tx_context_public_inputs_read_reverted_counts, e lookup_tx_context_restore_state_on_revert_counts, e lookup_tx_context_public_inputs_write_note_hash_count_counts, e lookup_tx_context_public_inputs_write_nullifier_count_counts, e lookup_tx_context_public_inputs_write_l2_to_l1_message_count_counts, e lookup_tx_context_public_inputs_write_unencrypted_log_count_counts, e lookup_tx_read_phase_spec_counts, e lookup_tx_read_phase_length_counts, e lookup_tx_read_public_call_request_phase_counts, e lookup_tx_read_tree_insert_value_counts, e lookup_tx_note_hash_append_counts, e lookup_tx_nullifier_append_counts, e lookup_tx_read_l2_l1_msg_counts, e lookup_tx_write_l2_l1_msg_counts, e lookup_tx_read_effective_fee_public_inputs_counts, e lookup_tx_read_fee_payer_public_inputs_counts, e lookup_tx_balance_slot_poseidon2_counts, e lookup_tx_balance_read_counts, e lookup_tx_balance_validation_counts, e lookup_tx_write_fee_public_inputs_counts, e bc_decomposition_bytes, e bc_decomposition_bytes_pc_plus_1, e bc_decomposition_bytes_pc_plus_10, e bc_decomposition_bytes_pc_plus_11, e bc_decomposition_bytes_pc_plus_12, e bc_decomposition_bytes_pc_plus_13, e bc_decomposition_bytes_pc_plus_14, e bc_decomposition_bytes_pc_plus_15, e bc_decomposition_bytes_pc_plus_16, e bc_decomposition_bytes_pc_plus_17, e bc_decomposition_bytes_pc_plus_18, e bc_decomposition_bytes_pc_plus_19, e bc_decomposition_bytes_pc_plus_2, e bc_decomposition_bytes_pc_plus_20, e bc_decomposition_bytes_pc_plus_21, e bc_decomposition_bytes_pc_plus_22, e bc_decomposition_bytes_pc_plus_23, e bc_decomposition_bytes_pc_plus_24, e bc_decomposition_bytes_pc_plus_25, e bc_decomposition_bytes_pc_plus_26, e bc_decomposition_bytes_pc_plus_27, e bc_decomposition_bytes_pc_plus_28, e bc_decomposition_bytes_pc_plus_29, e bc_decomposition_bytes_pc_plus_3, e bc_decomposition_bytes_pc_plus_30, e bc_decomposition_bytes_pc_plus_31, e bc_decomposition_bytes_pc_plus_32, e bc_decomposition_bytes_pc_plus_33, e bc_decomposition_bytes_pc_plus_34, e bc_decomposition_bytes_pc_plus_35, e bc_decomposition_bytes_pc_plus_4, e bc_decomposition_bytes_pc_plus_5, e bc_decomposition_bytes_pc_plus_6, e bc_decomposition_bytes_pc_plus_7, e bc_decomposition_bytes_pc_plus_8, e bc_decomposition_bytes_pc_plus_9, e bc_decomposition_bytes_remaining, e bc_decomposition_id, e bc_decomposition_next_packed_pc, e bc_decomposition_pc, e bc_decomposition_sel, e bc_decomposition_sel_packed, e bc_decomposition_sel_windows_gt_remaining, e bc_hashing_bytecode_id, e bc_hashing_pc_index, e bc_hashing_rounds_rem, e bc_hashing_sel, e bc_hashing_start, e bc_retrieval_sel, e bitwise_acc_ia, e bitwise_acc_ib, e bitwise_acc_ic, e bitwise_ctr, e bitwise_op_id, e calldata_context_id, e calldata_hashing_calldata_size, e calldata_hashing_context_id, e calldata_hashing_index_0_, e calldata_hashing_output_hash, e calldata_hashing_rounds_rem, e calldata_hashing_sel, e calldata_hashing_start, e calldata_index, e calldata_sel, e data_copy_clk, e data_copy_copy_size, e data_copy_dst_addr, e data_copy_dst_context_id, e data_copy_padding, e data_copy_read_addr, e data_copy_reads_left, e data_copy_sel, e data_copy_sel_cd_copy, e data_copy_sel_start, e data_copy_src_context_id, e emit_unencrypted_log_contract_address, e emit_unencrypted_log_correct_tag, e emit_unencrypted_log_error_out_of_bounds, e emit_unencrypted_log_error_tag_mismatch, e emit_unencrypted_log_execution_clk, e emit_unencrypted_log_is_write_contract_address, e emit_unencrypted_log_is_write_memory_value, e emit_unencrypted_log_log_address, e emit_unencrypted_log_public_inputs_index, e emit_unencrypted_log_remaining_rows, e emit_unencrypted_log_seen_wrong_tag, e emit_unencrypted_log_sel, e emit_unencrypted_log_sel_should_write_to_public_inputs, e emit_unencrypted_log_space_id, e emit_unencrypted_log_start, e execution_bytecode_id, e execution_context_id, e execution_contract_address, e execution_da_gas_limit, e execution_discard, e execution_dying_context_id, e execution_enqueued_call_start, e execution_internal_call_id, e execution_internal_call_return_id, e execution_is_static, e execution_l1_l2_tree_root, e execution_l2_gas_limit, e execution_last_child_id, e execution_last_child_returndata_addr, e execution_last_child_returndata_size, e execution_last_child_success, e execution_msg_sender, e execution_next_context_id, e execution_next_internal_call_id, e execution_parent_calldata_addr, e execution_parent_calldata_size, e execution_parent_da_gas_limit, e execution_parent_da_gas_used, e execution_parent_id, e execution_parent_l2_gas_limit, e execution_parent_l2_gas_used, e execution_pc, e execution_prev_da_gas_used, e execution_prev_l2_gas_used, e execution_prev_note_hash_tree_root, e execution_prev_note_hash_tree_size, e execution_prev_nullifier_tree_root, e execution_prev_nullifier_tree_size, e execution_prev_num_l2_to_l1_messages, e execution_prev_num_note_hashes_emitted, e execution_prev_num_nullifiers_emitted, e execution_prev_num_unencrypted_log_fields, e execution_prev_public_data_tree_root, e execution_prev_public_data_tree_size, e execution_prev_retrieved_bytecodes_tree_root, e execution_prev_retrieved_bytecodes_tree_size, e execution_prev_written_public_data_slots_tree_root, e execution_prev_written_public_data_slots_tree_size, e execution_sel, e execution_sel_first_row_in_context, e execution_transaction_fee, e ff_gt_a_hi, e ff_gt_a_lo, e ff_gt_b_hi, e ff_gt_b_lo, e ff_gt_cmp_rng_ctr, e ff_gt_p_sub_a_hi, e ff_gt_p_sub_a_lo, e ff_gt_p_sub_b_hi, e ff_gt_p_sub_b_lo, e ff_gt_sel, e ff_gt_sel_dec, e ff_gt_sel_gt, e keccak_memory_addr, e keccak_memory_clk, e keccak_memory_ctr, e keccak_memory_rw, e keccak_memory_space_id, e keccak_memory_tag_error, e keccak_memory_val_0_, e keccak_memory_val_10_, e keccak_memory_val_11_, e keccak_memory_val_12_, e keccak_memory_val_13_, e keccak_memory_val_14_, e keccak_memory_val_15_, e keccak_memory_val_16_, e keccak_memory_val_17_, e keccak_memory_val_18_, e keccak_memory_val_19_, e keccak_memory_val_1_, e keccak_memory_val_20_, e keccak_memory_val_21_, e keccak_memory_val_22_, e keccak_memory_val_23_, e keccak_memory_val_2_, e keccak_memory_val_3_, e keccak_memory_val_4_, e keccak_memory_val_5_, e keccak_memory_val_6_, e keccak_memory_val_7_, e keccak_memory_val_8_, e keccak_memory_val_9_, e keccakf1600_clk, e keccakf1600_dst_addr, e keccakf1600_round, e keccakf1600_sel_no_error, e keccakf1600_space_id, e keccakf1600_state_in_00, e keccakf1600_state_in_01, e keccakf1600_state_in_02, e keccakf1600_state_in_03, e keccakf1600_state_in_04, e keccakf1600_state_in_10, e keccakf1600_state_in_11, e keccakf1600_state_in_12, e keccakf1600_state_in_13, e keccakf1600_state_in_14, e keccakf1600_state_in_20, e keccakf1600_state_in_21, e keccakf1600_state_in_22, e keccakf1600_state_in_23, e keccakf1600_state_in_24, e keccakf1600_state_in_30, e keccakf1600_state_in_31, e keccakf1600_state_in_32, e keccakf1600_state_in_33, e keccakf1600_state_in_34, e keccakf1600_state_in_40, e keccakf1600_state_in_41, e keccakf1600_state_in_42, e keccakf1600_state_in_43, e keccakf1600_state_in_44, e memory_global_addr, e memory_rw, e memory_sel, e memory_tag, e memory_timestamp, e memory_value, e merkle_check_index, e merkle_check_path_len, e merkle_check_read_node, e merkle_check_read_root, e merkle_check_sel, e merkle_check_write, e merkle_check_write_node, e merkle_check_write_root, e poseidon2_hash_a_0, e poseidon2_hash_a_1, e poseidon2_hash_a_2, e poseidon2_hash_a_3, e poseidon2_hash_input_0, e poseidon2_hash_input_1, e poseidon2_hash_input_2, e poseidon2_hash_num_perm_rounds_rem, e poseidon2_hash_output, e poseidon2_hash_sel, e poseidon2_hash_start, e public_data_check_clk, e public_data_check_sel, e public_data_check_write_idx, e public_data_squash_clk, e public_data_squash_final_value, e public_data_squash_leaf_slot, e public_data_squash_sel, e public_data_squash_write_to_public_inputs, e scalar_mul_bit_idx, e scalar_mul_point_inf, e scalar_mul_point_x, e scalar_mul_point_y, e scalar_mul_res_inf, e scalar_mul_res_x, e scalar_mul_res_y, e scalar_mul_scalar, e scalar_mul_sel, e scalar_mul_start, e scalar_mul_temp_inf, e scalar_mul_temp_x, e scalar_mul_temp_y, e sha256_a, e sha256_b, e sha256_c, e sha256_d, e sha256_e, e sha256_execution_clk, e sha256_f, e sha256_g, e sha256_h, e sha256_helper_w0, e sha256_helper_w1, e sha256_helper_w10, e sha256_helper_w11, e sha256_helper_w12, e sha256_helper_w13, e sha256_helper_w14, e sha256_helper_w15, e sha256_helper_w2, e sha256_helper_w3, e sha256_helper_w4, e sha256_helper_w5, e sha256_helper_w6, e sha256_helper_w7, e sha256_helper_w8, e sha256_helper_w9, e sha256_input_rounds_rem, e sha256_output_addr, e sha256_rounds_remaining, e sha256_sel, e sha256_sel_invalid_input_tag_err, e sha256_sel_is_input_round, e sha256_space_id, e sha256_start, e to_radix_acc, e to_radix_acc_under_p, e to_radix_exponent, e to_radix_limb, e to_radix_limb_eq_p, e to_radix_limb_index, e to_radix_limb_lt_p, e to_radix_mem_dst_addr, e to_radix_mem_execution_clk, e to_radix_mem_is_output_bits, e to_radix_mem_num_limbs, e to_radix_mem_radix, e to_radix_mem_sel, e to_radix_mem_sel_should_decompose, e to_radix_mem_sel_should_write_mem, e to_radix_mem_space_id, e to_radix_mem_start, e to_radix_mem_value_to_decompose, e to_radix_not_padding_limb, e to_radix_radix, e to_radix_safe_limbs, e to_radix_sel, e to_radix_start, e to_radix_value, e tx_da_gas_limit, e tx_discard, e tx_fee, e tx_is_revertible, e tx_is_teardown, e tx_l1_l2_tree_root, e tx_l1_l2_tree_size, e tx_l2_gas_limit, e tx_next_context_id, e tx_phase_value, e tx_prev_da_gas_used, e tx_prev_l2_gas_used, e tx_prev_note_hash_tree_root, e tx_prev_note_hash_tree_size, e tx_prev_nullifier_tree_root, e tx_prev_nullifier_tree_size, e tx_prev_num_l2_to_l1_messages, e tx_prev_num_note_hashes_emitted, e tx_prev_num_nullifiers_emitted, e tx_prev_num_unencrypted_log_fields, e tx_prev_public_data_tree_root, e tx_prev_public_data_tree_size, e tx_prev_retrieved_bytecodes_tree_root, e tx_prev_retrieved_bytecodes_tree_size, e tx_prev_written_public_data_slots_tree_root, e tx_prev_written_public_data_slots_tree_size, e tx_read_pi_offset, e tx_remaining_phase_counter, e tx_reverted, e tx_sel, e tx_start_phase, e tx_start_tx, e tx_tx_reverted #define AVM2_DERIVED_WITNESS_ENTITIES_E(e) e perm_keccak_memory_slice_to_mem_inv, e perm_keccakf1600_read_to_slice_inv, e perm_keccakf1600_write_to_slice_inv, e perm_sha256_mem_mem_op_0_inv, e perm_sha256_mem_mem_op_1_inv, e perm_sha256_mem_mem_op_2_inv, e perm_sha256_mem_mem_op_3_inv, e perm_sha256_mem_mem_op_4_inv, e perm_sha256_mem_mem_op_5_inv, e perm_sha256_mem_mem_op_6_inv, e perm_sha256_mem_mem_op_7_inv, e perm_sha256_mem_mem_input_read_inv, e perm_ecc_mem_write_mem_0_inv, e perm_ecc_mem_write_mem_1_inv, e perm_ecc_mem_write_mem_2_inv, e perm_poseidon2_mem_pos_read_mem_0_inv, e perm_poseidon2_mem_pos_read_mem_1_inv, e perm_poseidon2_mem_pos_read_mem_2_inv, e perm_poseidon2_mem_pos_read_mem_3_inv, e perm_poseidon2_mem_pos_write_mem_0_inv, e perm_poseidon2_mem_pos_write_mem_1_inv, e perm_poseidon2_mem_pos_write_mem_2_inv, e perm_poseidon2_mem_pos_write_mem_3_inv, e perm_to_radix_mem_write_mem_inv, e perm_context_ctx_stack_call_inv, e perm_data_copy_mem_write_inv, e perm_data_copy_mem_read_inv, e perm_addressing_base_address_from_memory_inv, e perm_addressing_indirect_from_memory_0_inv, e perm_addressing_indirect_from_memory_1_inv, e perm_addressing_indirect_from_memory_2_inv, e perm_addressing_indirect_from_memory_3_inv, e perm_addressing_indirect_from_memory_4_inv, e perm_addressing_indirect_from_memory_5_inv, e perm_addressing_indirect_from_memory_6_inv, e perm_registers_mem_op_0_inv, e perm_registers_mem_op_1_inv, e perm_registers_mem_op_2_inv, e perm_registers_mem_op_3_inv, e perm_registers_mem_op_4_inv, e perm_registers_mem_op_5_inv, e perm_public_data_check_squashing_inv, e perm_bc_hashing_get_packed_field_0_inv, e perm_bc_hashing_get_packed_field_1_inv, e perm_bc_hashing_get_packed_field_2_inv, e perm_get_contract_instance_mem_write_contract_instance_exists_inv, e perm_get_contract_instance_mem_write_contract_instance_member_inv, e perm_internal_call_push_call_stack_inv, e perm_sstore_storage_write_inv, e perm_emit_unencrypted_log_read_mem_inv, e perm_execution_dispatch_to_cd_copy_inv, e perm_execution_dispatch_to_rd_copy_inv, e perm_execution_dispatch_to_get_contract_instance_inv, e perm_execution_dispatch_to_emit_unencrypted_log_inv, e perm_execution_dispatch_to_poseidon2_perm_inv, e perm_execution_dispatch_to_sha256_compression_inv, e perm_execution_dispatch_to_keccakf1600_inv, e perm_execution_dispatch_to_ecc_add_inv, e perm_execution_dispatch_to_to_radix_inv, e perm_tx_read_calldata_hash_inv, e perm_tx_dispatch_exec_start_inv, e perm_tx_dispatch_exec_end_inv, e perm_tx_balance_update_inv, e lookup_range_check_dyn_rng_chk_pow_2_inv, e lookup_range_check_dyn_diff_is_u16_inv, e lookup_range_check_r0_is_u16_inv, e lookup_range_check_r1_is_u16_inv, e lookup_range_check_r2_is_u16_inv, e lookup_range_check_r3_is_u16_inv, e lookup_range_check_r4_is_u16_inv, e lookup_range_check_r5_is_u16_inv, e lookup_range_check_r6_is_u16_inv, e lookup_range_check_r7_is_u16_inv, e lookup_ff_gt_a_lo_range_inv, e lookup_ff_gt_a_hi_range_inv, e lookup_gt_gt_range_inv, e lookup_alu_tag_max_bits_value_inv, e lookup_alu_range_check_decomposition_a_lo_inv, e lookup_alu_range_check_decomposition_a_hi_inv, e lookup_alu_range_check_decomposition_b_lo_inv, e lookup_alu_range_check_decomposition_b_hi_inv, e lookup_alu_range_check_mul_c_hi_inv, e lookup_alu_ff_gt_inv, e lookup_alu_int_gt_inv, e lookup_alu_shifts_two_pow_inv, e lookup_alu_large_trunc_canonical_dec_inv, e lookup_alu_range_check_trunc_mid_inv, e lookup_bitwise_integral_tag_length_inv, e lookup_bitwise_byte_operations_inv, e lookup_memory_range_check_limb_0_inv, e lookup_memory_range_check_limb_1_inv, e lookup_memory_range_check_limb_2_inv, e lookup_memory_tag_max_bits_inv, e lookup_memory_range_check_write_tagged_value_inv, e lookup_keccakf1600_theta_xor_01_inv, e lookup_keccakf1600_theta_xor_02_inv, e lookup_keccakf1600_theta_xor_03_inv, e lookup_keccakf1600_theta_xor_row_0_inv, e lookup_keccakf1600_theta_xor_11_inv, e lookup_keccakf1600_theta_xor_12_inv, e lookup_keccakf1600_theta_xor_13_inv, e lookup_keccakf1600_theta_xor_row_1_inv, e lookup_keccakf1600_theta_xor_21_inv, e lookup_keccakf1600_theta_xor_22_inv, e lookup_keccakf1600_theta_xor_23_inv, e lookup_keccakf1600_theta_xor_row_2_inv, e lookup_keccakf1600_theta_xor_31_inv, e lookup_keccakf1600_theta_xor_32_inv, e lookup_keccakf1600_theta_xor_33_inv, e lookup_keccakf1600_theta_xor_row_3_inv, e lookup_keccakf1600_theta_xor_41_inv, e lookup_keccakf1600_theta_xor_42_inv, e lookup_keccakf1600_theta_xor_43_inv, e lookup_keccakf1600_theta_xor_row_4_inv, e lookup_keccakf1600_theta_combined_xor_0_inv, e lookup_keccakf1600_theta_combined_xor_1_inv, e lookup_keccakf1600_theta_combined_xor_2_inv, e lookup_keccakf1600_theta_combined_xor_3_inv, e lookup_keccakf1600_theta_combined_xor_4_inv, e lookup_keccakf1600_state_theta_00_inv, e lookup_keccakf1600_state_theta_01_inv, e lookup_keccakf1600_state_theta_02_inv, e lookup_keccakf1600_state_theta_03_inv, e lookup_keccakf1600_state_theta_04_inv, e lookup_keccakf1600_state_theta_10_inv, e lookup_keccakf1600_state_theta_11_inv, e lookup_keccakf1600_state_theta_12_inv, e lookup_keccakf1600_state_theta_13_inv, e lookup_keccakf1600_state_theta_14_inv, e lookup_keccakf1600_state_theta_20_inv, e lookup_keccakf1600_state_theta_21_inv, e lookup_keccakf1600_state_theta_22_inv, e lookup_keccakf1600_state_theta_23_inv, e lookup_keccakf1600_state_theta_24_inv, e lookup_keccakf1600_state_theta_30_inv, e lookup_keccakf1600_state_theta_31_inv, e lookup_keccakf1600_state_theta_32_inv, e lookup_keccakf1600_state_theta_33_inv, e lookup_keccakf1600_state_theta_34_inv, e lookup_keccakf1600_state_theta_40_inv, e lookup_keccakf1600_state_theta_41_inv, e lookup_keccakf1600_state_theta_42_inv, e lookup_keccakf1600_state_theta_43_inv, e lookup_keccakf1600_state_theta_44_inv, e lookup_keccakf1600_theta_limb_02_range_inv, e lookup_keccakf1600_theta_limb_04_range_inv, e lookup_keccakf1600_theta_limb_10_range_inv, e lookup_keccakf1600_theta_limb_12_range_inv, e lookup_keccakf1600_theta_limb_14_range_inv, e lookup_keccakf1600_theta_limb_21_range_inv, e lookup_keccakf1600_theta_limb_23_range_inv, e lookup_keccakf1600_theta_limb_30_range_inv, e lookup_keccakf1600_theta_limb_32_range_inv, e lookup_keccakf1600_theta_limb_33_range_inv, e lookup_keccakf1600_theta_limb_40_range_inv, e lookup_keccakf1600_theta_limb_41_range_inv, e lookup_keccakf1600_theta_limb_43_range_inv, e lookup_keccakf1600_theta_limb_44_range_inv, e lookup_keccakf1600_theta_limb_01_range_inv, e lookup_keccakf1600_theta_limb_03_range_inv, e lookup_keccakf1600_theta_limb_11_range_inv, e lookup_keccakf1600_theta_limb_13_range_inv, e lookup_keccakf1600_theta_limb_20_range_inv, e lookup_keccakf1600_theta_limb_22_range_inv, e lookup_keccakf1600_theta_limb_24_range_inv, e lookup_keccakf1600_theta_limb_31_range_inv, e lookup_keccakf1600_theta_limb_34_range_inv, e lookup_keccakf1600_theta_limb_42_range_inv, e lookup_keccakf1600_state_pi_and_00_inv, e lookup_keccakf1600_state_pi_and_01_inv, e lookup_keccakf1600_state_pi_and_02_inv, e lookup_keccakf1600_state_pi_and_03_inv, e lookup_keccakf1600_state_pi_and_04_inv, e lookup_keccakf1600_state_pi_and_10_inv, e lookup_keccakf1600_state_pi_and_11_inv, e lookup_keccakf1600_state_pi_and_12_inv, e lookup_keccakf1600_state_pi_and_13_inv, e lookup_keccakf1600_state_pi_and_14_inv, e lookup_keccakf1600_state_pi_and_20_inv, e lookup_keccakf1600_state_pi_and_21_inv, e lookup_keccakf1600_state_pi_and_22_inv, e lookup_keccakf1600_state_pi_and_23_inv, e lookup_keccakf1600_state_pi_and_24_inv, e lookup_keccakf1600_state_pi_and_30_inv, e lookup_keccakf1600_state_pi_and_31_inv, e lookup_keccakf1600_state_pi_and_32_inv, e lookup_keccakf1600_state_pi_and_33_inv, e lookup_keccakf1600_state_pi_and_34_inv, e lookup_keccakf1600_state_pi_and_40_inv, e lookup_keccakf1600_state_pi_and_41_inv, e lookup_keccakf1600_state_pi_and_42_inv, e lookup_keccakf1600_state_pi_and_43_inv, e lookup_keccakf1600_state_pi_and_44_inv, e lookup_keccakf1600_state_chi_00_inv, e lookup_keccakf1600_state_chi_01_inv, e lookup_keccakf1600_state_chi_02_inv, e lookup_keccakf1600_state_chi_03_inv, e lookup_keccakf1600_state_chi_04_inv, e lookup_keccakf1600_state_chi_10_inv, e lookup_keccakf1600_state_chi_11_inv, e lookup_keccakf1600_state_chi_12_inv, e lookup_keccakf1600_state_chi_13_inv, e lookup_keccakf1600_state_chi_14_inv, e lookup_keccakf1600_state_chi_20_inv, e lookup_keccakf1600_state_chi_21_inv, e lookup_keccakf1600_state_chi_22_inv, e lookup_keccakf1600_state_chi_23_inv, e lookup_keccakf1600_state_chi_24_inv, e lookup_keccakf1600_state_chi_30_inv, e lookup_keccakf1600_state_chi_31_inv, e lookup_keccakf1600_state_chi_32_inv, e lookup_keccakf1600_state_chi_33_inv, e lookup_keccakf1600_state_chi_34_inv, e lookup_keccakf1600_state_chi_40_inv, e lookup_keccakf1600_state_chi_41_inv, e lookup_keccakf1600_state_chi_42_inv, e lookup_keccakf1600_state_chi_43_inv, e lookup_keccakf1600_state_chi_44_inv, e lookup_keccakf1600_round_cst_inv, e lookup_keccakf1600_state_iota_00_inv, e lookup_keccakf1600_src_out_of_range_toggle_inv, e lookup_keccakf1600_dst_out_of_range_toggle_inv, e lookup_sha256_range_comp_w_lhs_inv, e lookup_sha256_range_comp_w_rhs_inv, e lookup_sha256_range_rhs_w_7_inv, e lookup_sha256_range_rhs_w_18_inv, e lookup_sha256_range_rhs_w_3_inv, e lookup_sha256_w_s_0_xor_0_inv, e lookup_sha256_w_s_0_xor_1_inv, e lookup_sha256_range_rhs_w_17_inv, e lookup_sha256_range_rhs_w_19_inv, e lookup_sha256_range_rhs_w_10_inv, e lookup_sha256_w_s_1_xor_0_inv, e lookup_sha256_w_s_1_xor_1_inv, e lookup_sha256_range_rhs_e_6_inv, e lookup_sha256_range_rhs_e_11_inv, e lookup_sha256_range_rhs_e_25_inv, e lookup_sha256_s_1_xor_0_inv, e lookup_sha256_s_1_xor_1_inv, e lookup_sha256_ch_and_0_inv, e lookup_sha256_ch_and_1_inv, e lookup_sha256_ch_xor_inv, e lookup_sha256_round_constant_inv, e lookup_sha256_range_rhs_a_2_inv, e lookup_sha256_range_rhs_a_13_inv, e lookup_sha256_range_rhs_a_22_inv, e lookup_sha256_s_0_xor_0_inv, e lookup_sha256_s_0_xor_1_inv, e lookup_sha256_maj_and_0_inv, e lookup_sha256_maj_and_1_inv, e lookup_sha256_maj_and_2_inv, e lookup_sha256_maj_xor_0_inv, e lookup_sha256_maj_xor_1_inv, e lookup_sha256_range_comp_next_a_lhs_inv, e lookup_sha256_range_comp_next_a_rhs_inv, e lookup_sha256_range_comp_next_e_lhs_inv, e lookup_sha256_range_comp_next_e_rhs_inv, e lookup_sha256_range_comp_a_lhs_inv, e lookup_sha256_range_comp_a_rhs_inv, e lookup_sha256_range_comp_b_lhs_inv, e lookup_sha256_range_comp_b_rhs_inv, e lookup_sha256_range_comp_c_lhs_inv, e lookup_sha256_range_comp_c_rhs_inv, e lookup_sha256_range_comp_d_lhs_inv, e lookup_sha256_range_comp_d_rhs_inv, e lookup_sha256_range_comp_e_lhs_inv, e lookup_sha256_range_comp_e_rhs_inv, e lookup_sha256_range_comp_f_lhs_inv, e lookup_sha256_range_comp_f_rhs_inv, e lookup_sha256_range_comp_g_lhs_inv, e lookup_sha256_range_comp_g_rhs_inv, e lookup_sha256_range_comp_h_lhs_inv, e lookup_sha256_range_comp_h_rhs_inv, e lookup_sha256_mem_check_state_addr_in_range_inv, e lookup_sha256_mem_check_input_addr_in_range_inv, e lookup_sha256_mem_check_output_addr_in_range_inv, e lookup_ecc_mem_check_dst_addr_in_range_inv, e lookup_ecc_mem_input_output_ecc_add_inv, e lookup_poseidon2_mem_check_src_addr_in_range_inv, e lookup_poseidon2_mem_check_dst_addr_in_range_inv, e lookup_poseidon2_mem_input_output_poseidon2_perm_inv, e lookup_to_radix_limb_range_inv, e lookup_to_radix_limb_less_than_radix_range_inv, e lookup_to_radix_fetch_safe_limbs_inv, e lookup_to_radix_fetch_p_limb_inv, e lookup_to_radix_limb_p_diff_range_inv, e lookup_scalar_mul_to_radix_inv, e lookup_scalar_mul_double_inv, e lookup_scalar_mul_add_inv, e lookup_to_radix_mem_check_dst_addr_in_range_inv, e lookup_to_radix_mem_check_radix_lt_2_inv, e lookup_to_radix_mem_check_radix_gt_256_inv, e lookup_to_radix_mem_input_output_to_radix_inv, e lookup_context_ctx_stack_rollback_inv, e lookup_context_ctx_stack_return_inv, e lookup_poseidon2_hash_poseidon2_perm_inv, e lookup_calldata_hashing_get_calldata_field_0_inv, e lookup_calldata_hashing_get_calldata_field_1_inv, e lookup_calldata_hashing_get_calldata_field_2_inv, e lookup_calldata_hashing_check_final_size_inv, e lookup_calldata_hashing_poseidon2_hash_inv, e lookup_calldata_range_check_context_id_diff_inv, e lookup_data_copy_offset_plus_size_is_gt_data_size_inv, e lookup_data_copy_check_src_addr_in_range_inv, e lookup_data_copy_check_dst_addr_in_range_inv, e lookup_data_copy_data_index_upper_bound_gt_offset_inv, e lookup_data_copy_col_read_inv, e lookup_addressing_relative_overflow_result_0_inv, e lookup_addressing_relative_overflow_result_1_inv, e lookup_addressing_relative_overflow_result_2_inv, e lookup_addressing_relative_overflow_result_3_inv, e lookup_addressing_relative_overflow_result_4_inv, e lookup_addressing_relative_overflow_result_5_inv, e lookup_addressing_relative_overflow_result_6_inv, e lookup_gas_addressing_gas_read_inv, e lookup_gas_is_out_of_gas_l2_inv, e lookup_gas_is_out_of_gas_da_inv, e lookup_merkle_check_merkle_poseidon2_read_inv, e lookup_merkle_check_merkle_poseidon2_write_inv, e lookup_nullifier_check_silo_poseidon2_inv, e lookup_nullifier_check_low_leaf_poseidon2_inv, e lookup_nullifier_check_updated_low_leaf_poseidon2_inv, e lookup_nullifier_check_low_leaf_merkle_check_inv, e lookup_nullifier_check_low_leaf_nullifier_validation_inv, e lookup_nullifier_check_low_leaf_next_nullifier_validation_inv, e lookup_nullifier_check_new_leaf_poseidon2_inv, e lookup_nullifier_check_new_leaf_merkle_check_inv, e lookup_nullifier_check_write_nullifier_to_public_inputs_inv, e lookup_public_data_squash_leaf_slot_increase_ff_gt_inv, e lookup_public_data_squash_clk_diff_range_lo_inv, e lookup_public_data_squash_clk_diff_range_hi_inv, e lookup_public_data_check_clk_diff_range_lo_inv, e lookup_public_data_check_clk_diff_range_hi_inv, e lookup_public_data_check_silo_poseidon2_inv, e lookup_public_data_check_low_leaf_slot_validation_inv, e lookup_public_data_check_low_leaf_next_slot_validation_inv, e lookup_public_data_check_low_leaf_poseidon2_0_inv, e lookup_public_data_check_low_leaf_poseidon2_1_inv, e lookup_public_data_check_updated_low_leaf_poseidon2_0_inv, e lookup_public_data_check_updated_low_leaf_poseidon2_1_inv, e lookup_public_data_check_low_leaf_merkle_check_inv, e lookup_public_data_check_new_leaf_poseidon2_0_inv, e lookup_public_data_check_new_leaf_poseidon2_1_inv, e lookup_public_data_check_new_leaf_merkle_check_inv, e lookup_public_data_check_write_public_data_to_public_inputs_inv, e lookup_public_data_check_write_writes_length_to_public_inputs_inv, e lookup_written_public_data_slots_tree_check_silo_poseidon2_inv, e lookup_written_public_data_slots_tree_check_low_leaf_poseidon2_inv, e lookup_written_public_data_slots_tree_check_updated_low_leaf_poseidon2_inv, e lookup_written_public_data_slots_tree_check_low_leaf_merkle_check_inv, e lookup_written_public_data_slots_tree_check_low_leaf_slot_validation_inv, e lookup_written_public_data_slots_tree_check_low_leaf_next_slot_validation_inv, e lookup_written_public_data_slots_tree_check_new_leaf_poseidon2_inv, e lookup_written_public_data_slots_tree_check_new_leaf_merkle_check_inv, e lookup_l1_to_l2_message_tree_check_merkle_check_inv, e lookup_retrieved_bytecodes_tree_check_low_leaf_poseidon2_inv, e lookup_retrieved_bytecodes_tree_check_updated_low_leaf_poseidon2_inv, e lookup_retrieved_bytecodes_tree_check_low_leaf_merkle_check_inv, e lookup_retrieved_bytecodes_tree_check_low_leaf_class_id_validation_inv, e lookup_retrieved_bytecodes_tree_check_low_leaf_next_class_id_validation_inv, e lookup_retrieved_bytecodes_tree_check_new_leaf_poseidon2_inv, e lookup_retrieved_bytecodes_tree_check_new_leaf_merkle_check_inv, e lookup_address_derivation_salted_initialization_hash_poseidon2_0_inv, e lookup_address_derivation_salted_initialization_hash_poseidon2_1_inv, e lookup_address_derivation_partial_address_poseidon2_inv, e lookup_address_derivation_public_keys_hash_poseidon2_0_inv, e lookup_address_derivation_public_keys_hash_poseidon2_1_inv, e lookup_address_derivation_public_keys_hash_poseidon2_2_inv, e lookup_address_derivation_public_keys_hash_poseidon2_3_inv, e lookup_address_derivation_public_keys_hash_poseidon2_4_inv, e lookup_address_derivation_preaddress_poseidon2_inv, e lookup_address_derivation_preaddress_scalar_mul_inv, e lookup_address_derivation_address_ecadd_inv, e lookup_bc_decomposition_bytes_are_bytes_inv, e lookup_bc_hashing_check_final_bytes_remaining_inv, e lookup_bc_hashing_poseidon2_hash_inv, e lookup_update_check_timestamp_from_public_inputs_inv, e lookup_update_check_delayed_public_mutable_slot_poseidon2_inv, e lookup_update_check_update_hash_public_data_read_inv, e lookup_update_check_update_hash_poseidon2_inv, e lookup_update_check_update_hi_metadata_range_inv, e lookup_update_check_update_lo_metadata_range_inv, e lookup_update_check_timestamp_is_lt_timestamp_of_change_inv, e lookup_contract_instance_retrieval_check_protocol_address_range_inv, e lookup_contract_instance_retrieval_read_derived_address_from_public_inputs_inv, e lookup_contract_instance_retrieval_deployment_nullifier_read_inv, e lookup_contract_instance_retrieval_address_derivation_inv, e lookup_contract_instance_retrieval_update_check_inv, e lookup_bc_retrieval_contract_instance_retrieval_inv, e lookup_bc_retrieval_is_new_class_check_inv, e lookup_bc_retrieval_class_id_derivation_inv, e lookup_bc_retrieval_retrieved_bytecodes_insertion_inv, e lookup_instr_fetching_pc_abs_diff_positive_inv, e lookup_instr_fetching_instr_abs_diff_positive_inv, e lookup_instr_fetching_tag_value_validation_inv, e lookup_instr_fetching_bytecode_size_from_bc_dec_inv, e lookup_instr_fetching_bytes_from_bc_dec_inv, e lookup_instr_fetching_wire_instruction_info_inv, e lookup_class_id_derivation_class_id_poseidon2_0_inv, e lookup_class_id_derivation_class_id_poseidon2_1_inv, e lookup_get_env_var_precomputed_info_inv, e lookup_get_env_var_read_from_public_inputs_col0_inv, e lookup_get_env_var_read_from_public_inputs_col1_inv, e lookup_get_contract_instance_precomputed_info_inv, e lookup_get_contract_instance_contract_instance_retrieval_inv, e lookup_internal_call_unwind_call_stack_inv, e lookup_external_call_is_l2_gas_left_gt_allocated_inv, e lookup_external_call_is_da_gas_left_gt_allocated_inv, e lookup_sload_storage_read_inv, e lookup_sstore_record_written_storage_slot_inv, e lookup_note_hash_tree_check_silo_poseidon2_inv, e lookup_note_hash_tree_check_read_first_nullifier_inv, e lookup_note_hash_tree_check_nonce_computation_poseidon2_inv, e lookup_note_hash_tree_check_unique_note_hash_poseidon2_inv, e lookup_note_hash_tree_check_merkle_check_inv, e lookup_note_hash_tree_check_write_note_hash_to_public_inputs_inv, e lookup_notehash_exists_note_hash_leaf_index_in_range_inv, e lookup_notehash_exists_note_hash_read_inv, e lookup_emit_notehash_notehash_tree_write_inv, e lookup_l1_to_l2_message_exists_l1_to_l2_msg_leaf_index_in_range_inv, e lookup_l1_to_l2_message_exists_l1_to_l2_msg_read_inv, e lookup_nullifier_exists_nullifier_exists_check_inv, e lookup_emit_nullifier_write_nullifier_inv, e lookup_emit_unencrypted_log_check_memory_out_of_bounds_inv, e lookup_emit_unencrypted_log_check_log_fields_count_inv, e lookup_emit_unencrypted_log_write_data_to_public_inputs_inv, e lookup_send_l2_to_l1_msg_write_l2_to_l1_msg_inv, e lookup_execution_bytecode_retrieval_result_inv, e lookup_execution_instruction_fetching_result_inv, e lookup_execution_instruction_fetching_body_inv, e lookup_execution_exec_spec_read_inv, e lookup_execution_dyn_l2_factor_bitwise_inv, e lookup_execution_check_radix_gt_256_inv, e lookup_execution_get_p_limbs_inv, e lookup_execution_get_max_limbs_inv, e lookup_execution_check_written_storage_slot_inv, e lookup_execution_dispatch_to_alu_inv, e lookup_execution_dispatch_to_bitwise_inv, e lookup_execution_dispatch_to_cast_inv, e lookup_execution_dispatch_to_set_inv, e lookup_tx_context_public_inputs_note_hash_tree_inv, e lookup_tx_context_public_inputs_nullifier_tree_inv, e lookup_tx_context_public_inputs_public_data_tree_inv, e lookup_tx_context_public_inputs_l1_l2_tree_inv, e lookup_tx_context_public_inputs_gas_used_inv, e lookup_tx_context_public_inputs_read_gas_limit_inv, e lookup_tx_context_public_inputs_read_reverted_inv, e lookup_tx_context_restore_state_on_revert_inv, e lookup_tx_context_public_inputs_write_note_hash_count_inv, e lookup_tx_context_public_inputs_write_nullifier_count_inv, e lookup_tx_context_public_inputs_write_l2_to_l1_message_count_inv, e lookup_tx_context_public_inputs_write_unencrypted_log_count_inv, e lookup_tx_read_phase_spec_inv, e lookup_tx_read_phase_length_inv, e lookup_tx_read_public_call_request_phase_inv, e lookup_tx_read_tree_insert_value_inv, e lookup_tx_note_hash_append_inv, e lookup_tx_nullifier_append_inv, e lookup_tx_read_l2_l1_msg_inv, e lookup_tx_write_l2_l1_msg_inv, e lookup_tx_read_effective_fee_public_inputs_inv, e lookup_tx_read_fee_payer_public_inputs_inv, e lookup_tx_balance_slot_poseidon2_inv, e lookup_tx_balance_read_inv, e lookup_tx_balance_validation_inv, e lookup_tx_write_fee_public_inputs_inv #define AVM2_SHIFTED_ENTITIES_E(e) e bc_decomposition_bytes_shift, e bc_decomposition_bytes_pc_plus_1_shift, e bc_decomposition_bytes_pc_plus_10_shift, e bc_decomposition_bytes_pc_plus_11_shift, e bc_decomposition_bytes_pc_plus_12_shift, e bc_decomposition_bytes_pc_plus_13_shift, e bc_decomposition_bytes_pc_plus_14_shift, e bc_decomposition_bytes_pc_plus_15_shift, e bc_decomposition_bytes_pc_plus_16_shift, e bc_decomposition_bytes_pc_plus_17_shift, e bc_decomposition_bytes_pc_plus_18_shift, e bc_decomposition_bytes_pc_plus_19_shift, e bc_decomposition_bytes_pc_plus_2_shift, e bc_decomposition_bytes_pc_plus_20_shift, e bc_decomposition_bytes_pc_plus_21_shift, e bc_decomposition_bytes_pc_plus_22_shift, e bc_decomposition_bytes_pc_plus_23_shift, e bc_decomposition_bytes_pc_plus_24_shift, e bc_decomposition_bytes_pc_plus_25_shift, e bc_decomposition_bytes_pc_plus_26_shift, e bc_decomposition_bytes_pc_plus_27_shift, e bc_decomposition_bytes_pc_plus_28_shift, e bc_decomposition_bytes_pc_plus_29_shift, e bc_decomposition_bytes_pc_plus_3_shift, e bc_decomposition_bytes_pc_plus_30_shift, e bc_decomposition_bytes_pc_plus_31_shift, e bc_decomposition_bytes_pc_plus_32_shift, e bc_decomposition_bytes_pc_plus_33_shift, e bc_decomposition_bytes_pc_plus_34_shift, e bc_decomposition_bytes_pc_plus_35_shift, e bc_decomposition_bytes_pc_plus_4_shift, e bc_decomposition_bytes_pc_plus_5_shift, e bc_decomposition_bytes_pc_plus_6_shift, e bc_decomposition_bytes_pc_plus_7_shift, e bc_decomposition_bytes_pc_plus_8_shift, e bc_decomposition_bytes_pc_plus_9_shift, e bc_decomposition_bytes_remaining_shift, e bc_decomposition_id_shift, e bc_decomposition_next_packed_pc_shift, e bc_decomposition_pc_shift, e bc_decomposition_sel_shift, e bc_decomposition_sel_packed_shift, e bc_decomposition_sel_windows_gt_remaining_shift, e bc_hashing_bytecode_id_shift, e bc_hashing_pc_index_shift, e bc_hashing_rounds_rem_shift, e bc_hashing_sel_shift, e bc_hashing_start_shift, e bc_retrieval_sel_shift, e bitwise_acc_ia_shift, e bitwise_acc_ib_shift, e bitwise_acc_ic_shift, e bitwise_ctr_shift, e bitwise_op_id_shift, e calldata_context_id_shift, e calldata_hashing_calldata_size_shift, e calldata_hashing_context_id_shift, e calldata_hashing_index_0__shift, e calldata_hashing_output_hash_shift, e calldata_hashing_rounds_rem_shift, e calldata_hashing_sel_shift, e calldata_hashing_start_shift, e calldata_index_shift, e calldata_sel_shift, e data_copy_clk_shift, e data_copy_copy_size_shift, e data_copy_dst_addr_shift, e data_copy_dst_context_id_shift, e data_copy_padding_shift, e data_copy_read_addr_shift, e data_copy_reads_left_shift, e data_copy_sel_shift, e data_copy_sel_cd_copy_shift, e data_copy_sel_start_shift, e data_copy_src_context_id_shift, e emit_unencrypted_log_contract_address_shift, e emit_unencrypted_log_correct_tag_shift, e emit_unencrypted_log_error_out_of_bounds_shift, e emit_unencrypted_log_error_tag_mismatch_shift, e emit_unencrypted_log_execution_clk_shift, e emit_unencrypted_log_is_write_contract_address_shift, e emit_unencrypted_log_is_write_memory_value_shift, e emit_unencrypted_log_log_address_shift, e emit_unencrypted_log_public_inputs_index_shift, e emit_unencrypted_log_remaining_rows_shift, e emit_unencrypted_log_seen_wrong_tag_shift, e emit_unencrypted_log_sel_shift, e emit_unencrypted_log_sel_should_write_to_public_inputs_shift, e emit_unencrypted_log_space_id_shift, e emit_unencrypted_log_start_shift, e execution_bytecode_id_shift, e execution_context_id_shift, e execution_contract_address_shift, e execution_da_gas_limit_shift, e execution_discard_shift, e execution_dying_context_id_shift, e execution_enqueued_call_start_shift, e execution_internal_call_id_shift, e execution_internal_call_return_id_shift, e execution_is_static_shift, e execution_l1_l2_tree_root_shift, e execution_l2_gas_limit_shift, e execution_last_child_id_shift, e execution_last_child_returndata_addr_shift, e execution_last_child_returndata_size_shift, e execution_last_child_success_shift, e execution_msg_sender_shift, e execution_next_context_id_shift, e execution_next_internal_call_id_shift, e execution_parent_calldata_addr_shift, e execution_parent_calldata_size_shift, e execution_parent_da_gas_limit_shift, e execution_parent_da_gas_used_shift, e execution_parent_id_shift, e execution_parent_l2_gas_limit_shift, e execution_parent_l2_gas_used_shift, e execution_pc_shift, e execution_prev_da_gas_used_shift, e execution_prev_l2_gas_used_shift, e execution_prev_note_hash_tree_root_shift, e execution_prev_note_hash_tree_size_shift, e execution_prev_nullifier_tree_root_shift, e execution_prev_nullifier_tree_size_shift, e execution_prev_num_l2_to_l1_messages_shift, e execution_prev_num_note_hashes_emitted_shift, e execution_prev_num_nullifiers_emitted_shift, e execution_prev_num_unencrypted_log_fields_shift, e execution_prev_public_data_tree_root_shift, e execution_prev_public_data_tree_size_shift, e execution_prev_retrieved_bytecodes_tree_root_shift, e execution_prev_retrieved_bytecodes_tree_size_shift, e execution_prev_written_public_data_slots_tree_root_shift, e execution_prev_written_public_data_slots_tree_size_shift, e execution_sel_shift, e execution_sel_first_row_in_context_shift, e execution_transaction_fee_shift, e ff_gt_a_hi_shift, e ff_gt_a_lo_shift, e ff_gt_b_hi_shift, e ff_gt_b_lo_shift, e ff_gt_cmp_rng_ctr_shift, e ff_gt_p_sub_a_hi_shift, e ff_gt_p_sub_a_lo_shift, e ff_gt_p_sub_b_hi_shift, e ff_gt_p_sub_b_lo_shift, e ff_gt_sel_shift, e ff_gt_sel_dec_shift, e ff_gt_sel_gt_shift, e keccak_memory_addr_shift, e keccak_memory_clk_shift, e keccak_memory_ctr_shift, e keccak_memory_rw_shift, e keccak_memory_space_id_shift, e keccak_memory_tag_error_shift, e keccak_memory_val_0__shift, e keccak_memory_val_10__shift, e keccak_memory_val_11__shift, e keccak_memory_val_12__shift, e keccak_memory_val_13__shift, e keccak_memory_val_14__shift, e keccak_memory_val_15__shift, e keccak_memory_val_16__shift, e keccak_memory_val_17__shift, e keccak_memory_val_18__shift, e keccak_memory_val_19__shift, e keccak_memory_val_1__shift, e keccak_memory_val_20__shift, e keccak_memory_val_21__shift, e keccak_memory_val_22__shift, e keccak_memory_val_23__shift, e keccak_memory_val_2__shift, e keccak_memory_val_3__shift, e keccak_memory_val_4__shift, e keccak_memory_val_5__shift, e keccak_memory_val_6__shift, e keccak_memory_val_7__shift, e keccak_memory_val_8__shift, e keccak_memory_val_9__shift, e keccakf1600_clk_shift, e keccakf1600_dst_addr_shift, e keccakf1600_round_shift, e keccakf1600_sel_no_error_shift, e keccakf1600_space_id_shift, e keccakf1600_state_in_00_shift, e keccakf1600_state_in_01_shift, e keccakf1600_state_in_02_shift, e keccakf1600_state_in_03_shift, e keccakf1600_state_in_04_shift, e keccakf1600_state_in_10_shift, e keccakf1600_state_in_11_shift, e keccakf1600_state_in_12_shift, e keccakf1600_state_in_13_shift, e keccakf1600_state_in_14_shift, e keccakf1600_state_in_20_shift, e keccakf1600_state_in_21_shift, e keccakf1600_state_in_22_shift, e keccakf1600_state_in_23_shift, e keccakf1600_state_in_24_shift, e keccakf1600_state_in_30_shift, e keccakf1600_state_in_31_shift, e keccakf1600_state_in_32_shift, e keccakf1600_state_in_33_shift, e keccakf1600_state_in_34_shift, e keccakf1600_state_in_40_shift, e keccakf1600_state_in_41_shift, e keccakf1600_state_in_42_shift, e keccakf1600_state_in_43_shift, e keccakf1600_state_in_44_shift, e memory_global_addr_shift, e memory_rw_shift, e memory_sel_shift, e memory_tag_shift, e memory_timestamp_shift, e memory_value_shift, e merkle_check_index_shift, e merkle_check_path_len_shift, e merkle_check_read_node_shift, e merkle_check_read_root_shift, e merkle_check_sel_shift, e merkle_check_write_shift, e merkle_check_write_node_shift, e merkle_check_write_root_shift, e poseidon2_hash_a_0_shift, e poseidon2_hash_a_1_shift, e poseidon2_hash_a_2_shift, e poseidon2_hash_a_3_shift, e poseidon2_hash_input_0_shift, e poseidon2_hash_input_1_shift, e poseidon2_hash_input_2_shift, e poseidon2_hash_num_perm_rounds_rem_shift, e poseidon2_hash_output_shift, e poseidon2_hash_sel_shift, e poseidon2_hash_start_shift, e public_data_check_clk_shift, e public_data_check_sel_shift, e public_data_check_write_idx_shift, e public_data_squash_clk_shift, e public_data_squash_final_value_shift, e public_data_squash_leaf_slot_shift, e public_data_squash_sel_shift, e public_data_squash_write_to_public_inputs_shift, e scalar_mul_bit_idx_shift, e scalar_mul_point_inf_shift, e scalar_mul_point_x_shift, e scalar_mul_point_y_shift, e scalar_mul_res_inf_shift, e scalar_mul_res_x_shift, e scalar_mul_res_y_shift, e scalar_mul_scalar_shift, e scalar_mul_sel_shift, e scalar_mul_start_shift, e scalar_mul_temp_inf_shift, e scalar_mul_temp_x_shift, e scalar_mul_temp_y_shift, e sha256_a_shift, e sha256_b_shift, e sha256_c_shift, e sha256_d_shift, e sha256_e_shift, e sha256_execution_clk_shift, e sha256_f_shift, e sha256_g_shift, e sha256_h_shift, e sha256_helper_w0_shift, e sha256_helper_w1_shift, e sha256_helper_w10_shift, e sha256_helper_w11_shift, e sha256_helper_w12_shift, e sha256_helper_w13_shift, e sha256_helper_w14_shift, e sha256_helper_w15_shift, e sha256_helper_w2_shift, e sha256_helper_w3_shift, e sha256_helper_w4_shift, e sha256_helper_w5_shift, e sha256_helper_w6_shift, e sha256_helper_w7_shift, e sha256_helper_w8_shift, e sha256_helper_w9_shift, e sha256_input_rounds_rem_shift, e sha256_output_addr_shift, e sha256_rounds_remaining_shift, e sha256_sel_shift, e sha256_sel_invalid_input_tag_err_shift, e sha256_sel_is_input_round_shift, e sha256_space_id_shift, e sha256_start_shift, e to_radix_acc_shift, e to_radix_acc_under_p_shift, e to_radix_exponent_shift, e to_radix_limb_shift, e to_radix_limb_eq_p_shift, e to_radix_limb_index_shift, e to_radix_limb_lt_p_shift, e to_radix_mem_dst_addr_shift, e to_radix_mem_execution_clk_shift, e to_radix_mem_is_output_bits_shift, e to_radix_mem_num_limbs_shift, e to_radix_mem_radix_shift, e to_radix_mem_sel_shift, e to_radix_mem_sel_should_decompose_shift, e to_radix_mem_sel_should_write_mem_shift, e to_radix_mem_space_id_shift, e to_radix_mem_start_shift, e to_radix_mem_value_to_decompose_shift, e to_radix_not_padding_limb_shift, e to_radix_radix_shift, e to_radix_safe_limbs_shift, e to_radix_sel_shift, e to_radix_start_shift, e to_radix_value_shift, e tx_da_gas_limit_shift, e tx_discard_shift, e tx_fee_shift, e tx_is_revertible_shift, e tx_is_teardown_shift, e tx_l1_l2_tree_root_shift, e tx_l1_l2_tree_size_shift, e tx_l2_gas_limit_shift, e tx_next_context_id_shift, e tx_phase_value_shift, e tx_prev_da_gas_used_shift, e tx_prev_l2_gas_used_shift, e tx_prev_note_hash_tree_root_shift, e tx_prev_note_hash_tree_size_shift, e tx_prev_nullifier_tree_root_shift, e tx_prev_nullifier_tree_size_shift, e tx_prev_num_l2_to_l1_messages_shift, e tx_prev_num_note_hashes_emitted_shift, e tx_prev_num_nullifiers_emitted_shift, e tx_prev_num_unencrypted_log_fields_shift, e tx_prev_public_data_tree_root_shift, e tx_prev_public_data_tree_size_shift, e tx_prev_retrieved_bytecodes_tree_root_shift, e tx_prev_retrieved_bytecodes_tree_size_shift, e tx_prev_written_public_data_slots_tree_root_shift, e tx_prev_written_public_data_slots_tree_size_shift, e tx_read_pi_offset_shift, e tx_remaining_phase_counter_shift, e tx_reverted_shift, e tx_sel_shift, e tx_start_phase_shift, e tx_start_tx_shift, e tx_tx_reverted_shift @@ -36,16 +36,16 @@ enum class ColumnAndShifts { SENTINEL_DO_NOT_USE, }; -constexpr auto NUM_COLUMNS_WITH_SHIFTS = 3527; -constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 3183; -constexpr auto NUM_PRECOMPUTED_ENTITIES = 124; +constexpr auto NUM_COLUMNS_WITH_SHIFTS = 3526; +constexpr auto NUM_COLUMNS_WITHOUT_SHIFTS = 3182; +constexpr auto NUM_PRECOMPUTED_ENTITIES = 123; constexpr auto NUM_WIRE_ENTITIES = 2593; constexpr auto NUM_DERIVED_ENTITIES = 466; constexpr auto NUM_WITNESS_ENTITIES = NUM_WIRE_ENTITIES + NUM_DERIVED_ENTITIES; constexpr auto NUM_WIRES_TO_BE_SHIFTED = 344; constexpr auto NUM_SHIFTED_ENTITIES = 344; constexpr auto NUM_UNSHIFTED_ENTITIES = NUM_COLUMNS_WITHOUT_SHIFTS; -constexpr auto NUM_ALL_ENTITIES = 3527; +constexpr auto NUM_ALL_ENTITIES = 3526; /* * Layout for all entities is: diff --git a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp index c47635e9c738..9a76e4260059 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/generated/flavor_variables.hpp @@ -144,11 +144,11 @@ namespace bb::avm2 { struct AvmFlavorVariables { - static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 124; + static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 123; static constexpr size_t NUM_WITNESS_ENTITIES = 3059; static constexpr size_t NUM_SHIFTED_ENTITIES = 344; static constexpr size_t NUM_WIRES = 2593; - static constexpr size_t NUM_ALL_ENTITIES = 3527; + static constexpr size_t NUM_ALL_ENTITIES = 3526; // Need to be templated for recursive verifier template diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/emit_unencrypted_log_event.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/emit_unencrypted_log_event.hpp index dce9b63f3fc0..0e90d4a23bcf 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/events/emit_unencrypted_log_event.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/events/emit_unencrypted_log_event.hpp @@ -30,7 +30,6 @@ struct EmitUnencryptedLogWriteEvent { bool error_memory_out_of_bounds; bool error_too_many_log_fields; - bool error_is_static; bool error_tag_mismatch; bool operator==(const EmitUnencryptedLogWriteEvent& other) const = default; diff --git a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/contract_instance_manager.hpp b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/contract_instance_manager.hpp index c0fdb7e48ef4..3a8945adee2f 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/contract_instance_manager.hpp +++ b/barretenberg/cpp/src/barretenberg/vm2/simulation/gadgets/contract_instance_manager.hpp @@ -11,15 +11,6 @@ namespace bb::avm2::simulation { -struct ContractInstanceNotFoundError : public std::runtime_error { - ContractInstanceNotFoundError(AztecAddress address, const std::string& message) - : std::runtime_error(message) - , address(address) - {} - - AztecAddress address; -}; - class ContractInstanceManager : public ContractInstanceManagerInterface { public: ContractInstanceManager(ContractDBInterface& contract_db, diff --git a/barretenberg/cpp/src/barretenberg/vm2/tracegen/execution_trace.cpp b/barretenberg/cpp/src/barretenberg/vm2/tracegen/execution_trace.cpp index d774e9eb40e7..2f6984863b70 100644 --- a/barretenberg/cpp/src/barretenberg/vm2/tracegen/execution_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm2/tracegen/execution_trace.cpp @@ -589,6 +589,8 @@ void ExecutionTraceBuilder::process( trace.set(C::execution_sel_read_unwind_call_stack, row, 1); } } else if (*exec_opcode == ExecutionOpCode::SSTORE) { + // Equivalent to PIL's (MAX + INITIAL_SIZE - prev_written_public_data_slots_tree_size) + // since prev_size = counter + 1 and INITIAL_SIZE = 1. uint32_t remaining_data_writes = MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX - ex_event.before_context_event.tree_states.public_data_tree.counter; diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 9f06c760d9dd..c9a741f9b233 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -101,16 +101,11 @@ export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000; export const MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS = 3000; export const CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 23; export const CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_ADDITIONAL_FIELDS = 14; -export const CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE = - 14149211982683198966415397187677099530590983261208050372085833907509n; -export const CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = - 2889881020989534926461066592611988634597302675057895885580456197069n; -export const CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE = - 24399338136397901754495080759185489776044879232766421623673792970137n; -export const CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE = - 19558544958816189742429223939242700295084178455458336806004020892999n; -export const CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = - 1534834688047131268740281708431107902615560100979874281215533519862n; +export const CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE = 14149211982683198966415397187677099530590983261208050372085833907509n; +export const CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE = 2889881020989534926461066592611988634597302675057895885580456197069n; +export const CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE = 24399338136397901754495080759185489776044879232766421623673792970137n; +export const CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE = 19558544958816189742429223939242700295084178455458336806004020892999n; +export const CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE = 1534834688047131268740281708431107902615560100979874281215533519862n; export const MAX_PROTOCOL_CONTRACTS = 11; export const CANONICAL_AUTH_REGISTRY_ADDRESS = 1; export const CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 2; @@ -119,8 +114,7 @@ export const MULTI_CALL_ENTRYPOINT_ADDRESS = 4; export const FEE_JUICE_ADDRESS = 5; export const ROUTER_ADDRESS = 6; export const SIDE_EFFECT_MASKING_ADDRESS = 12; -export const NULL_MSG_SENDER_CONTRACT_ADDRESS = - 21888242871839275222246405745257275088548364400416034343698204186575808495616n; +export const NULL_MSG_SENDER_CONTRACT_ADDRESS = 21888242871839275222246405745257275088548364400416034343698204186575808495616n; export const CONTRACT_CLASS_REGISTRY_BYTECODE_CAPSULE_SLOT = 79025834455612; export const FEE_JUICE_BALANCES_SLOT = 1; export const UPDATED_CLASS_IDS_SLOT = 1; @@ -485,12 +479,10 @@ export const PROOF_TYPE_HN_TAIL = 8; export const PROOF_TYPE_CHONK = 9; export const TWO_POW_64 = 18446744073709551616n; export const AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_HEIGHT = 6; -export const AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_INITIAL_ROOT = - 18291678969210913367302010540259942201271604198321103848479209155223586227821n; +export const AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_INITIAL_ROOT = 18291678969210913367302010540259942201271604198321103848479209155223586227821n; export const AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_INITIAL_SIZE = 1; export const AVM_RETRIEVED_BYTECODES_TREE_HEIGHT = 5; -export const AVM_RETRIEVED_BYTECODES_TREE_INITIAL_ROOT = - 7257575663883662864904159007845791361042428565864275462740313586853981161757n; +export const AVM_RETRIEVED_BYTECODES_TREE_INITIAL_ROOT = 7257575663883662864904159007845791361042428565864275462740313586853981161757n; export const AVM_RETRIEVED_BYTECODES_TREE_INITIAL_SIZE = 1; export const TIMESTAMP_OF_CHANGE_BIT_SIZE = 32; export const DEFAULT_UPDATE_DELAY = 86400; @@ -542,4 +534,4 @@ export enum GeneratorIndex { SECRET_HASH = 20, TX_NULLIFIER = 32, SIGNATURE_PAYLOAD = 34, -} +} \ No newline at end of file diff --git a/yarn-project/simulator/src/public/fuzzing/avm_simulator_bin.ts b/yarn-project/simulator/src/public/fuzzing/avm_simulator_bin.ts index a0713245297b..808f50298941 100644 --- a/yarn-project/simulator/src/public/fuzzing/avm_simulator_bin.ts +++ b/yarn-project/simulator/src/public/fuzzing/avm_simulator_bin.ts @@ -9,11 +9,23 @@ import { import { GlobalVariables, TreeSnapshots } from '@aztec/stdlib/tx'; import { NativeWorldStateService } from '@aztec/world-state'; -import { writeSync } from 'fs'; import { createInterface } from 'readline'; import { AvmFuzzerSimulator, FuzzerSimulationRequest } from './avm_fuzzer_simulator.js'; +/** Write data to stdout, letting Node handle buffering. */ +function writeOutput(data: string): Promise { + return new Promise((resolve, reject) => { + process.stdout.write(data, err => { + if (err) { + reject(err); + } else { + resolve(); + } + }); + }); +} + // This cache holds opened world states to avoid reopening them for each invocation. // It's a map so that in the future we could support multiple world states (if we had multiple fuzzers). const worldStateCache = new Map(); @@ -96,16 +108,17 @@ async function execute(base64Line: string): Promise { revertReason: result.revertReason ?? '', endTreeSnapshots: result.publicInputs.endTreeSnapshots, }); - writeSync(process.stdout.fd, resultBuffer.toString('base64') + '\n'); + const base64Response = resultBuffer.toString('base64') + '\n'; + await writeOutput(base64Response); } catch (error: any) { // If we error, treat as reverted const errorResult = serializeWithMessagePack({ reverted: true, - output: [] as string[], + output: [] as Fr[], revertReason: `Unexpected Error ${error.message}`, endTreeSnapshots: TreeSnapshots.empty(), }); - writeSync(process.stdout.fd, errorResult.toString('base64') + '\n'); + await writeOutput(errorResult.toString('base64') + '\n'); } }