@aztec/simulator 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client.d.ts +1 -1
- package/dest/common/errors.d.ts +2 -8
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/index.d.ts +1 -1
- package/dest/common/stats/index.d.ts +1 -1
- package/dest/common/stats/stats.d.ts +1 -1
- package/dest/private/acvm/acvm.d.ts +1 -1
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/deserialize.d.ts +2 -2
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +1 -1
- package/dest/private/acvm/index.d.ts +1 -1
- package/dest/private/acvm/serialize.d.ts +2 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +1 -1
- package/dest/private/acvm_native.d.ts +2 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +15 -13
- package/dest/private/acvm_wasm.d.ts +1 -1
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +16 -15
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +2 -2
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_simulator.d.ts +1 -1
- package/dest/private/factory.d.ts +1 -1
- package/dest/public/avm/avm_context.d.ts +2 -2
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +2 -2
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.d.ts +5 -4
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +5 -5
- package/dest/public/avm/avm_gas.d.ts +2 -2
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +2 -2
- package/dest/public/avm/avm_machine_state.d.ts +2 -2
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.d.ts +20 -14
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +10 -3
- package/dest/public/avm/avm_simulator.d.ts +4 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +19 -25
- package/dest/public/avm/avm_simulator_interface.d.ts +1 -1
- package/dest/public/avm/errors.d.ts +13 -16
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +21 -22
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +3 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +14 -6
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +4 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +23 -1
- package/dest/public/avm/fixtures/initializers.d.ts +2 -3
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +6 -4
- package/dest/public/avm/fixtures/utils.d.ts +4 -3
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +3 -2
- package/dest/public/avm/index.d.ts +1 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +3 -3
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +8 -8
- package/dest/public/avm/opcodes/addressing_mode.d.ts +1 -1
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +4 -5
- package/dest/public/avm/opcodes/arithmetic.d.ts +10 -8
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +11 -1
- package/dest/public/avm/opcodes/bitwise.d.ts +5 -5
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.d.ts +4 -4
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +1 -1
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.d.ts +1 -1
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +3 -0
- package/dest/public/avm/opcodes/ec_add.d.ts +2 -2
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +6 -6
- package/dest/public/avm/opcodes/environment_getters.d.ts +3 -3
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +7 -9
- package/dest/public/avm/opcodes/external_calls.d.ts +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +1 -1
- package/dest/public/avm/opcodes/hashing.d.ts +2 -2
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +9 -4
- package/dest/public/avm/opcodes/index.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction.d.ts +2 -2
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +5 -6
- package/dest/public/avm/opcodes/instruction_impl.d.ts +1 -1
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.d.ts +2 -2
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +1 -1
- package/dest/public/avm/opcodes/misc.d.ts +3 -2
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +28 -8
- package/dest/public/avm/opcodes/storage.d.ts +3 -3
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/revert_reason.d.ts +2 -2
- package/dest/public/avm/revert_reason.d.ts.map +1 -1
- package/dest/public/avm/revert_reason.js +3 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts +1 -1
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +9 -6
- package/dest/public/avm/serialization/instruction_serialization.d.ts +9 -1
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +11 -1
- package/dest/public/avm/test_utils.d.ts +4 -4
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +7 -10
- package/dest/public/contracts_db_checkpoint.d.ts +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +14 -2
- package/dest/public/db_interfaces.d.ts.map +1 -1
- package/dest/public/debug_fn_name.d.ts +15 -2
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +28 -2
- package/dest/public/executor_metrics.d.ts +3 -2
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +1 -1
- package/dest/public/executor_metrics_interface.d.ts +3 -2
- package/dest/public/executor_metrics_interface.d.ts.map +1 -1
- package/dest/public/fixtures/amm_test.d.ts +1 -1
- package/dest/public/fixtures/amm_test.js +2 -2
- package/dest/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +59 -177
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +34 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +53 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +174 -0
- package/dest/public/fixtures/index.d.ts +5 -2
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +4 -1
- package/dest/public/fixtures/minimal_public_tx.d.ts +4 -9
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +8 -32
- package/dest/public/fixtures/opcode_spammer.d.ts +123 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1681 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +25 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +63 -17
- package/dest/public/fixtures/simple_contract_data_source.d.ts +5 -4
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/fixtures/simple_contract_data_source.js +4 -4
- package/dest/public/fixtures/token_test.d.ts +6 -2
- package/dest/public/fixtures/token_test.d.ts.map +1 -1
- package/dest/public/fixtures/token_test.js +13 -12
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +7 -6
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +46 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +139 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_simulator_bin.js +100 -0
- package/dest/public/hinting_db_sources.d.ts +16 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +74 -13
- package/dest/public/index.d.ts +3 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +24 -65
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +85 -132
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +6 -2
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +8 -0
- package/dest/public/public_processor/public_processor.d.ts +11 -13
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +477 -70
- package/dest/public/public_processor/public_processor_metrics.d.ts +1 -1
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +18 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +98 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +53 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +131 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +42 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +86 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +30 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +171 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +22 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +52 -0
- package/dest/public/public_tx_simulator/factories.d.ts +13 -0
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/factories.js +28 -0
- package/dest/public/public_tx_simulator/index.d.ts +6 -1
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +3 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +16 -8
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +7 -8
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +9 -4
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +22 -10
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +22 -29
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +178 -127
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +32 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +4 -3
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +396 -20
- package/dest/public/side_effect_errors.d.ts +42 -2
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +70 -1
- package/dest/public/side_effect_trace.d.ts +13 -7
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +36 -21
- package/dest/public/side_effect_trace_interface.d.ts +9 -4
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +1 -1
- package/dest/public/state_manager/nullifiers.d.ts +2 -5
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/nullifiers.js +1 -6
- package/dest/public/state_manager/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.js +1 -1
- package/dest/public/state_manager/state_manager.d.ts +16 -13
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +64 -21
- package/dest/public/test_executor_metrics.d.ts +4 -3
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +5 -4
- package/dest/public/unique_class_ids.d.ts +1 -1
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +1 -1
- package/dest/server.d.ts +1 -1
- package/dest/testing.d.ts +1 -1
- package/package.json +24 -19
- package/src/common/errors.ts +1 -1
- package/src/private/acvm/deserialize.ts +1 -1
- package/src/private/acvm/serialize.ts +1 -1
- package/src/private/acvm_native.ts +18 -11
- package/src/private/circuit_recording/circuit_recorder.ts +17 -16
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +1 -1
- package/src/public/avm/avm_context.ts +1 -1
- package/src/public/avm/avm_contract_call_result.ts +1 -1
- package/src/public/avm/avm_execution_environment.ts +4 -3
- package/src/public/avm/avm_gas.ts +5 -5
- package/src/public/avm/avm_machine_state.ts +1 -1
- package/src/public/avm/avm_memory_types.ts +12 -3
- package/src/public/avm/avm_simulator.ts +24 -33
- package/src/public/avm/errors.ts +24 -27
- package/src/public/avm/fixtures/avm_simulation_tester.ts +14 -4
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +33 -1
- package/src/public/avm/fixtures/initializers.ts +7 -8
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +5 -5
- package/src/public/avm/opcodes/addressing_mode.ts +5 -5
- package/src/public/avm/opcodes/arithmetic.ts +13 -1
- package/src/public/avm/opcodes/conversion.ts +4 -0
- package/src/public/avm/opcodes/ec_add.ts +6 -6
- package/src/public/avm/opcodes/environment_getters.ts +10 -12
- package/src/public/avm/opcodes/external_calls.ts +1 -1
- package/src/public/avm/opcodes/hashing.ts +10 -4
- package/src/public/avm/opcodes/instruction.ts +8 -6
- package/src/public/avm/opcodes/memory.ts +1 -1
- package/src/public/avm/opcodes/misc.ts +41 -7
- package/src/public/avm/revert_reason.ts +6 -3
- package/src/public/avm/serialization/bytecode_serialization.ts +17 -6
- package/src/public/avm/serialization/instruction_serialization.ts +13 -1
- package/src/public/avm/test_utils.ts +7 -15
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +16 -1
- package/src/public/debug_fn_name.ts +35 -3
- package/src/public/executor_metrics.ts +2 -1
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/amm_test.ts +2 -2
- package/src/public/fixtures/bulk_test.ts +39 -26
- package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +219 -0
- package/src/public/fixtures/index.ts +8 -1
- package/src/public/fixtures/minimal_public_tx.ts +9 -42
- package/src/public/fixtures/opcode_spammer.ts +1638 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +90 -22
- package/src/public/fixtures/simple_contract_data_source.ts +8 -9
- package/src/public/fixtures/token_test.ts +18 -10
- package/src/public/fixtures/utils.ts +5 -6
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +240 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +140 -0
- package/src/public/hinting_db_sources.ts +117 -10
- package/src/public/index.ts +8 -1
- package/src/public/public_db_sources.ts +112 -175
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +10 -1
- package/src/public/public_processor/public_processor.ts +112 -79
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +121 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +200 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +132 -0
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +237 -0
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +81 -0
- package/src/public/public_tx_simulator/factories.ts +41 -0
- package/src/public/public_tx_simulator/index.ts +5 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +13 -14
- package/src/public/public_tx_simulator/public_tx_context.ts +20 -7
- package/src/public/public_tx_simulator/public_tx_simulator.ts +265 -179
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +33 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +4 -13
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +49 -24
- package/src/public/side_effect_trace_interface.ts +7 -1
- package/src/public/state_manager/nullifiers.ts +2 -8
- package/src/public/state_manager/public_storage.ts +1 -1
- package/src/public/state_manager/state_manager.ts +87 -39
- package/src/public/test_executor_metrics.ts +7 -5
- package/dest/public/bytecode_errors.d.ts +0 -4
- package/dest/public/bytecode_errors.d.ts.map +0 -1
- package/dest/public/bytecode_errors.js +0 -6
- package/dest/public/tx_contract_cache.d.ts +0 -41
- package/dest/public/tx_contract_cache.d.ts.map +0 -1
- package/dest/public/tx_contract_cache.js +0 -49
- package/src/public/bytecode_errors.ts +0 -6
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -1,6 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
L1_TO_L2_MSG_TREE_LEAF_COUNT,
|
|
3
|
+
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
4
|
+
MAX_NOTE_HASHES_PER_TX,
|
|
5
|
+
MAX_NULLIFIERS_PER_TX,
|
|
6
|
+
MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS,
|
|
7
|
+
NOTE_HASH_TREE_LEAF_COUNT,
|
|
8
|
+
} from '@aztec/constants';
|
|
9
|
+
|
|
10
|
+
import { CheckedPublicExecutionError } from './public_errors.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Any error that can be thrown during side effect insertion in public.
|
|
14
|
+
* Includes SideEffectLimitReachedError and NullifierCollisionError.
|
|
15
|
+
*/
|
|
16
|
+
export abstract class SideEffectError extends CheckedPublicExecutionError {
|
|
17
|
+
constructor(message: string) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'SideEffectInsertionError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class SideEffectLimitReachedError extends SideEffectError {
|
|
2
24
|
constructor(sideEffectType: string, limit: number) {
|
|
3
25
|
super(`Reached the limit (${limit}) on number of '${sideEffectType}' per tx`);
|
|
4
26
|
this.name = 'SideEffectLimitReachedError';
|
|
5
27
|
}
|
|
6
28
|
}
|
|
29
|
+
|
|
30
|
+
export class MaxCallsToUniqueContractClassIdsError extends SideEffectLimitReachedError {
|
|
31
|
+
constructor() {
|
|
32
|
+
super('contract calls to unique class IDs', MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS);
|
|
33
|
+
this.name = 'MaxCallsToUniqueContractClassIdsError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class NullifierLimitReachedError extends SideEffectLimitReachedError {
|
|
38
|
+
constructor() {
|
|
39
|
+
super('nullifier', MAX_NULLIFIERS_PER_TX);
|
|
40
|
+
this.name = 'NullifierLimitReachedError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class NoteHashLimitReachedError extends SideEffectLimitReachedError {
|
|
45
|
+
constructor() {
|
|
46
|
+
super('note hash', MAX_NOTE_HASHES_PER_TX);
|
|
47
|
+
this.name = 'NoteHashLimitReachedError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class L2ToL1MessageLimitReachedError extends SideEffectLimitReachedError {
|
|
52
|
+
constructor() {
|
|
53
|
+
super('l2 to l1 message', MAX_L2_TO_L1_MSGS_PER_TX);
|
|
54
|
+
this.name = 'L2ToL1MessageLimitReachedError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class NullifierCollisionError extends SideEffectError {
|
|
59
|
+
constructor(message: string) {
|
|
60
|
+
super(`Nullifier collision: ${message}`);
|
|
61
|
+
this.name = 'NullifierCollisionError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Any error that can be thrown during side effect reads in public.
|
|
67
|
+
* Note: Thrown at state manager level and unknown by simulation, hence NOT considered
|
|
68
|
+
* CheckedPublicExecutionErrors. Currently only includes append-only tree reads.
|
|
69
|
+
*/
|
|
70
|
+
export abstract class SideEffectReadError extends Error {
|
|
71
|
+
constructor(message: string) {
|
|
72
|
+
super(message);
|
|
73
|
+
this.name = 'SideEffectReadError';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class IndexOutOfRangeError extends SideEffectReadError {
|
|
78
|
+
constructor(tree: string, index: number, limit: number) {
|
|
79
|
+
super(`Attempting to read index ${index} of ${tree} tree with maximum ${limit} leaves`);
|
|
80
|
+
this.name = 'IndexOutOfRangeError';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export class NoteHashIndexOutOfRangeError extends IndexOutOfRangeError {
|
|
85
|
+
constructor(index: number) {
|
|
86
|
+
super('note hash', index, NOTE_HASH_TREE_LEAF_COUNT);
|
|
87
|
+
this.name = 'NoteHashIndexOutOfRangeError';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class L1ToL2MessageIndexOutOfRangeError extends IndexOutOfRangeError {
|
|
92
|
+
constructor(index: number) {
|
|
93
|
+
super('l1 to l2 message', index, L1_TO_L2_MSG_TREE_LEAF_COUNT);
|
|
94
|
+
this.name = 'L1ToL2MessageIndexOutOfRangeError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH,
|
|
2
3
|
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
3
4
|
MAX_NOTE_HASHES_PER_TX,
|
|
4
5
|
MAX_NULLIFIERS_PER_TX,
|
|
5
6
|
MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS,
|
|
6
7
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
7
|
-
MAX_PUBLIC_LOGS_PER_TX,
|
|
8
8
|
PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
9
|
-
PUBLIC_LOG_SIZE_IN_FIELDS,
|
|
10
9
|
} from '@aztec/constants';
|
|
11
|
-
import {
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
13
|
-
import {
|
|
14
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
12
|
+
import { type LogLevel, createLogger } from '@aztec/foundation/log';
|
|
15
13
|
import { PublicDataUpdateRequest } from '@aztec/stdlib/avm';
|
|
16
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
17
15
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
18
16
|
import { NoteHash, Nullifier } from '@aztec/stdlib/kernel';
|
|
19
|
-
import { PublicLog } from '@aztec/stdlib/logs';
|
|
17
|
+
import { DebugLog, PublicLog } from '@aztec/stdlib/logs';
|
|
20
18
|
import { L2ToL1Message, ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
21
19
|
|
|
22
20
|
import { strict as assert } from 'assert';
|
|
23
21
|
|
|
24
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
L2ToL1MessageLimitReachedError,
|
|
24
|
+
MaxCallsToUniqueContractClassIdsError,
|
|
25
|
+
NoteHashLimitReachedError,
|
|
26
|
+
NullifierLimitReachedError,
|
|
27
|
+
SideEffectLimitReachedError,
|
|
28
|
+
} from './side_effect_errors.js';
|
|
25
29
|
import type { PublicSideEffectTraceInterface } from './side_effect_trace_interface.js';
|
|
26
30
|
import { UniqueClassIds } from './unique_class_ids.js';
|
|
27
31
|
|
|
@@ -45,7 +49,7 @@ export class SideEffectArrayLengths {
|
|
|
45
49
|
public readonly noteHashes: number,
|
|
46
50
|
public readonly nullifiers: number,
|
|
47
51
|
public readonly l2ToL1Msgs: number,
|
|
48
|
-
public readonly
|
|
52
|
+
public readonly publicLogFields: number,
|
|
49
53
|
) {}
|
|
50
54
|
|
|
51
55
|
static empty() {
|
|
@@ -69,7 +73,6 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
69
73
|
private nullifiers: Nullifier[] = [];
|
|
70
74
|
private l2ToL1Messages: ScopedL2ToL1Message[] = [];
|
|
71
75
|
private publicLogs: PublicLog[] = [];
|
|
72
|
-
|
|
73
76
|
/** Make sure a forked trace is never merged twice. */
|
|
74
77
|
private alreadyMergedIntoParent = false;
|
|
75
78
|
|
|
@@ -83,6 +86,8 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
83
86
|
/** We need to track the set of class IDs used, to enforce limits. */
|
|
84
87
|
private uniqueClassIds: UniqueClassIds = new UniqueClassIds(),
|
|
85
88
|
private writtenPublicDataSlots: Set<string> = new Set(),
|
|
89
|
+
private debugLogs: DebugLog[] = [],
|
|
90
|
+
private debugLogMemoryReads: number = 0,
|
|
86
91
|
) {
|
|
87
92
|
this.sideEffectCounter = startSideEffectCounter;
|
|
88
93
|
}
|
|
@@ -96,10 +101,13 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
96
101
|
this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length,
|
|
97
102
|
this.previousSideEffectArrayLengths.nullifiers + this.nullifiers.length,
|
|
98
103
|
this.previousSideEffectArrayLengths.l2ToL1Msgs + this.l2ToL1Messages.length,
|
|
99
|
-
this.previousSideEffectArrayLengths.
|
|
104
|
+
this.previousSideEffectArrayLengths.publicLogFields +
|
|
105
|
+
this.publicLogs.reduce((acc, log) => acc + log.sizeInFields(), 0),
|
|
100
106
|
),
|
|
101
107
|
this.uniqueClassIds.fork(),
|
|
102
108
|
new Set(this.writtenPublicDataSlots),
|
|
109
|
+
this.debugLogs.slice(),
|
|
110
|
+
this.debugLogMemoryReads,
|
|
103
111
|
);
|
|
104
112
|
}
|
|
105
113
|
|
|
@@ -113,6 +121,8 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
113
121
|
|
|
114
122
|
this.sideEffectCounter = forkedTrace.sideEffectCounter;
|
|
115
123
|
this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
|
|
124
|
+
this.debugLogs = forkedTrace.debugLogs;
|
|
125
|
+
this.debugLogMemoryReads = forkedTrace.debugLogMemoryReads;
|
|
116
126
|
|
|
117
127
|
if (!reverted) {
|
|
118
128
|
this.publicDataWrites.push(...forkedTrace.publicDataWrites);
|
|
@@ -193,7 +203,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
193
203
|
|
|
194
204
|
public traceNewNoteHash(noteHash: Fr) {
|
|
195
205
|
if (this.noteHashes.length + this.previousSideEffectArrayLengths.noteHashes >= MAX_NOTE_HASHES_PER_TX) {
|
|
196
|
-
throw new
|
|
206
|
+
throw new NoteHashLimitReachedError();
|
|
197
207
|
}
|
|
198
208
|
|
|
199
209
|
this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter));
|
|
@@ -203,10 +213,10 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
203
213
|
|
|
204
214
|
public traceNewNullifier(siloedNullifier: Fr) {
|
|
205
215
|
if (this.nullifiers.length + this.previousSideEffectArrayLengths.nullifiers >= MAX_NULLIFIERS_PER_TX) {
|
|
206
|
-
throw new
|
|
216
|
+
throw new NullifierLimitReachedError();
|
|
207
217
|
}
|
|
208
218
|
|
|
209
|
-
this.nullifiers.push(new Nullifier(siloedNullifier,
|
|
219
|
+
this.nullifiers.push(new Nullifier(siloedNullifier, /*noteHash=*/ Fr.ZERO, this.sideEffectCounter));
|
|
210
220
|
|
|
211
221
|
this.log.trace(`Tracing new nullifier (counter=${this.sideEffectCounter})`);
|
|
212
222
|
this.incrementSideEffectCounter();
|
|
@@ -214,7 +224,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
214
224
|
|
|
215
225
|
public traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr) {
|
|
216
226
|
if (this.l2ToL1Messages.length + this.previousSideEffectArrayLengths.l2ToL1Msgs >= MAX_L2_TO_L1_MSGS_PER_TX) {
|
|
217
|
-
throw new
|
|
227
|
+
throw new L2ToL1MessageLimitReachedError();
|
|
218
228
|
}
|
|
219
229
|
|
|
220
230
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
@@ -224,28 +234,43 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
224
234
|
}
|
|
225
235
|
|
|
226
236
|
public tracePublicLog(contractAddress: AztecAddress, log: Fr[]) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
const previouslyEmittedPublicLogFieldsCount =
|
|
238
|
+
this.previousSideEffectArrayLengths.publicLogFields +
|
|
239
|
+
this.publicLogs.reduce((acc, log) => acc + log.sizeInFields(), 0);
|
|
240
|
+
|
|
241
|
+
const publicLog = new PublicLog(contractAddress, log);
|
|
230
242
|
|
|
231
|
-
if (
|
|
232
|
-
throw new
|
|
243
|
+
if (previouslyEmittedPublicLogFieldsCount + publicLog.sizeInFields() > FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH) {
|
|
244
|
+
throw new SideEffectLimitReachedError('public log fields', FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH);
|
|
233
245
|
}
|
|
234
|
-
|
|
246
|
+
|
|
235
247
|
this.publicLogs.push(publicLog);
|
|
236
248
|
this.log.trace(`Tracing new public log (counter=${this.sideEffectCounter})`);
|
|
237
249
|
this.incrementSideEffectCounter();
|
|
238
250
|
}
|
|
239
251
|
|
|
252
|
+
public traceDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]) {
|
|
253
|
+
this.debugLogs.push(new DebugLog(contractAddress, level, message, fields));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public getDebugLogs() {
|
|
257
|
+
return this.debugLogs;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public getDebugLogMemoryReads() {
|
|
261
|
+
return this.debugLogMemoryReads;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
public traceDebugLogMemoryReads(memoryReads: number) {
|
|
265
|
+
this.debugLogMemoryReads += memoryReads;
|
|
266
|
+
}
|
|
267
|
+
|
|
240
268
|
public traceGetContractClass(contractClassId: Fr, exists: boolean) {
|
|
241
269
|
// We limit the number of unique contract class IDs due to hashing and the trace length limit.
|
|
242
270
|
if (exists && !this.uniqueClassIds.has(contractClassId.toString())) {
|
|
243
271
|
if (this.uniqueClassIds.size() >= MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS) {
|
|
244
272
|
this.log.debug(`Bytecode retrieval failure for contract class ID ${contractClassId} (limit reached)`);
|
|
245
|
-
throw new
|
|
246
|
-
'contract calls to unique class IDs',
|
|
247
|
-
MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS,
|
|
248
|
-
);
|
|
273
|
+
throw new MaxCallsToUniqueContractClassIdsError();
|
|
249
274
|
}
|
|
250
275
|
this.log.trace(`Adding contract class ID ${contractClassId} (counter=${this.sideEffectCounter})`);
|
|
251
276
|
this.uniqueClassIds.add(contractClassId.toString());
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { LogLevel } from '@aztec/foundation/log';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
3
5
|
|
|
4
6
|
export interface PublicSideEffectTraceInterface {
|
|
5
7
|
fork(): PublicSideEffectTraceInterface;
|
|
@@ -18,5 +20,9 @@ export interface PublicSideEffectTraceInterface {
|
|
|
18
20
|
traceNewNullifier(siloedNullifier: Fr): void;
|
|
19
21
|
traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
|
|
20
22
|
tracePublicLog(contractAddress: AztecAddress, log: Fr[]): void;
|
|
23
|
+
traceDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]): void;
|
|
24
|
+
getDebugLogs(): DebugLog[];
|
|
25
|
+
getDebugLogMemoryReads(): number;
|
|
26
|
+
traceDebugLogMemoryReads(memoryReads: number): void;
|
|
21
27
|
traceGetContractClass(contractClassId: Fr, exists: boolean): void;
|
|
22
28
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
|
|
3
3
|
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
4
|
+
import { NullifierCollisionError } from '../side_effect_errors.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A class to manage new nullifier staging and existence checks during a contract call's AVM simulation.
|
|
@@ -100,10 +101,3 @@ export class NullifierManager {
|
|
|
100
101
|
this.cache = new Set([...this.cache, ...incomingNullifiers.cache]);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
export class NullifierCollisionError extends Error {
|
|
105
|
-
constructor(message: string, ...rest: any[]) {
|
|
106
|
-
super(message, ...rest);
|
|
107
|
-
this.name = 'NullifierCollisionError';
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -6,16 +6,18 @@ import {
|
|
|
6
6
|
MULTI_CALL_ENTRYPOINT_ADDRESS,
|
|
7
7
|
ROUTER_ADDRESS,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
9
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
12
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
12
|
+
import { type LogLevel, createLogger } from '@aztec/foundation/log';
|
|
13
13
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
14
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
14
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
16
|
import type { ContractClassPublicWithCommitment, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
17
|
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
17
18
|
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
18
19
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
20
|
+
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
19
21
|
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
20
22
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
21
23
|
import type { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
@@ -25,10 +27,16 @@ import { strict as assert } from 'assert';
|
|
|
25
27
|
|
|
26
28
|
import type { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
27
29
|
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
28
|
-
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
30
|
+
import { getPublicFunctionDebugName, getPublicFunctionSelectorAndName } from '../debug_fn_name.js';
|
|
29
31
|
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
32
|
+
import {
|
|
33
|
+
L1ToL2MessageIndexOutOfRangeError,
|
|
34
|
+
MaxCallsToUniqueContractClassIdsError,
|
|
35
|
+
NoteHashIndexOutOfRangeError,
|
|
36
|
+
NullifierCollisionError,
|
|
37
|
+
} from '../side_effect_errors.js';
|
|
30
38
|
import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
|
|
31
|
-
import {
|
|
39
|
+
import { NullifierManager } from './nullifiers.js';
|
|
32
40
|
import { PublicStorage } from './public_storage.js';
|
|
33
41
|
|
|
34
42
|
/**
|
|
@@ -52,7 +60,7 @@ export class PublicPersistableStateManager {
|
|
|
52
60
|
private readonly trace: PublicSideEffectTraceInterface,
|
|
53
61
|
private readonly firstNullifier: Fr, // Needed for note hashes.
|
|
54
62
|
private readonly timestamp: UInt64, // Needed for contract updates.
|
|
55
|
-
private readonly doMerkleOperations: boolean =
|
|
63
|
+
private readonly doMerkleOperations: boolean = true,
|
|
56
64
|
private readonly publicStorage: PublicStorage = new PublicStorage(treesDB),
|
|
57
65
|
private readonly nullifiers: NullifierManager = new NullifierManager(treesDB),
|
|
58
66
|
) {}
|
|
@@ -64,18 +72,10 @@ export class PublicPersistableStateManager {
|
|
|
64
72
|
treesDB: PublicTreesDB,
|
|
65
73
|
contractsDB: PublicContractsDBInterface,
|
|
66
74
|
trace: PublicSideEffectTraceInterface,
|
|
67
|
-
doMerkleOperations: boolean = false,
|
|
68
75
|
firstNullifier: Fr,
|
|
69
76
|
timestamp: UInt64,
|
|
70
77
|
): PublicPersistableStateManager {
|
|
71
|
-
return new PublicPersistableStateManager(
|
|
72
|
-
treesDB,
|
|
73
|
-
contractsDB,
|
|
74
|
-
trace,
|
|
75
|
-
firstNullifier,
|
|
76
|
-
timestamp,
|
|
77
|
-
doMerkleOperations,
|
|
78
|
-
);
|
|
78
|
+
return new PublicPersistableStateManager(treesDB, contractsDB, trace, firstNullifier, timestamp);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -164,7 +164,6 @@ export class PublicPersistableStateManager {
|
|
|
164
164
|
if (this.doMerkleOperations) {
|
|
165
165
|
return await this.treesDB.storageRead(contractAddress, slot);
|
|
166
166
|
} else {
|
|
167
|
-
// TODO(fcarreiro): I don't get this. PublicStorage CAN end up reading the tree. Why is it in the "dont do merkle operations" branch?
|
|
168
167
|
const read = await this.publicStorage.read(contractAddress, slot);
|
|
169
168
|
this.log.trace(
|
|
170
169
|
`Storage read results (address=${contractAddress}, slot=${slot}): value=${read.value}, cached=${read.cached}`,
|
|
@@ -183,12 +182,21 @@ export class PublicPersistableStateManager {
|
|
|
183
182
|
* @returns true if the note hash exists at the given leaf index, false otherwise
|
|
184
183
|
*/
|
|
185
184
|
public async checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex: bigint): Promise<boolean> {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
try {
|
|
186
|
+
const gotLeafValue = await this.treesDB.getNoteHash(leafIndex);
|
|
187
|
+
const exists = gotLeafValue.equals(noteHash);
|
|
188
|
+
this.log.trace(
|
|
189
|
+
`noteHashes(${contractAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`,
|
|
190
|
+
);
|
|
191
|
+
return Promise.resolve(exists);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
// If the index is out of range, note_hash_leaf_in_range = 0 and the circuit returns false:
|
|
194
|
+
if (error instanceof NoteHashIndexOutOfRangeError) {
|
|
195
|
+
return Promise.resolve(false);
|
|
196
|
+
}
|
|
197
|
+
// Otherwise, unknown error. This is a bug.
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
192
200
|
}
|
|
193
201
|
|
|
194
202
|
/**
|
|
@@ -288,12 +296,21 @@ export class PublicPersistableStateManager {
|
|
|
288
296
|
* @returns exists - whether the message exists in the L1 to L2 Messages tree
|
|
289
297
|
*/
|
|
290
298
|
public async checkL1ToL2MessageExists(msgHash: Fr, msgLeafIndex: Fr): Promise<boolean> {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
299
|
+
try {
|
|
300
|
+
const valueAtIndex = await this.treesDB.getL1ToL2LeafValue(msgLeafIndex.toBigInt());
|
|
301
|
+
const exists = valueAtIndex.equals(msgHash);
|
|
302
|
+
this.log.trace(
|
|
303
|
+
`l1ToL2Messages(@${msgLeafIndex}) ?? exists: ${exists}, expected: ${msgHash}, found: ${valueAtIndex}.`,
|
|
304
|
+
);
|
|
305
|
+
return Promise.resolve(exists);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
// If the index is out of range, l1_to_l2_msg_leaf_in_range = 0 and the circuit returns false:
|
|
308
|
+
if (error instanceof L1ToL2MessageIndexOutOfRangeError) {
|
|
309
|
+
return Promise.resolve(false);
|
|
310
|
+
}
|
|
311
|
+
// Otherwise, unknown error. This is a bug.
|
|
312
|
+
throw error;
|
|
313
|
+
}
|
|
297
314
|
}
|
|
298
315
|
|
|
299
316
|
/**
|
|
@@ -319,6 +336,22 @@ export class PublicPersistableStateManager {
|
|
|
319
336
|
);
|
|
320
337
|
}
|
|
321
338
|
|
|
339
|
+
public writeDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]) {
|
|
340
|
+
this.trace.traceDebugLog(contractAddress, level, message, fields);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public writeDebugLogMemoryReads(memoryReads: number) {
|
|
344
|
+
this.trace.traceDebugLogMemoryReads(memoryReads);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
public getDebugLogMemoryReads() {
|
|
348
|
+
return this.trace.getDebugLogMemoryReads();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public getLogs(): DebugLog[] {
|
|
352
|
+
return this.trace.getDebugLogs();
|
|
353
|
+
}
|
|
354
|
+
|
|
322
355
|
/**
|
|
323
356
|
* Write a public log
|
|
324
357
|
* @param contractAddress - address of the contract that emitted the log
|
|
@@ -368,7 +401,7 @@ export class PublicPersistableStateManager {
|
|
|
368
401
|
|
|
369
402
|
this.log.trace(`Got contract instance (address=${contractAddress}): instance=${jsonStringify(instance!)}`);
|
|
370
403
|
|
|
371
|
-
// All that is left is
|
|
404
|
+
// All that is left is to check that the contract updatability information is correct.
|
|
372
405
|
// That is, that the current and original contract class ids are correct.
|
|
373
406
|
await this.checkContractUpdateInformation(instanceWithAddress);
|
|
374
407
|
|
|
@@ -389,13 +422,15 @@ export class PublicPersistableStateManager {
|
|
|
389
422
|
//
|
|
390
423
|
// However, we will also be checking the hash of the delayed public mutable values.
|
|
391
424
|
// This is a bit of a leak of information, since the circuit will use it to prove
|
|
392
|
-
// one public read
|
|
425
|
+
// one public read instead of N of the delayed public mutable values.
|
|
393
426
|
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
|
|
394
427
|
await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(instance.address);
|
|
395
428
|
const readDeployerStorage = async (storageSlot: Fr) =>
|
|
396
429
|
await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
397
430
|
|
|
398
431
|
const hash = await readDeployerStorage(delayedPublicMutableHashSlot);
|
|
432
|
+
// NOTE: The below reads are either not performed (if hash.isZero()) or only performed in unconstrained in c++ simulation.
|
|
433
|
+
// See UpdateCheck::check_current_class_id documentation - this means if we generate hints from the merkle db, they are unused:
|
|
399
434
|
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
|
|
400
435
|
delayedPublicMutableSlot,
|
|
401
436
|
readDeployerStorage,
|
|
@@ -438,7 +473,7 @@ export class PublicPersistableStateManager {
|
|
|
438
473
|
* @param classId - class id to retrieve.
|
|
439
474
|
* @returns the contract class or undefined if it does not exist.
|
|
440
475
|
*/
|
|
441
|
-
|
|
476
|
+
private async getContractClass(classId: Fr): Promise<ContractClassPublicWithCommitment | undefined> {
|
|
442
477
|
this.log.trace(`Getting contract class for id ${classId}`);
|
|
443
478
|
const contractClass = await this.contractsDB.getContractClass(classId);
|
|
444
479
|
const exists = contractClass !== undefined;
|
|
@@ -459,7 +494,7 @@ export class PublicPersistableStateManager {
|
|
|
459
494
|
publicBytecodeCommitment: bytecodeCommitment,
|
|
460
495
|
};
|
|
461
496
|
} else {
|
|
462
|
-
this.log.debug(`Contract
|
|
497
|
+
this.log.debug(`Contract class NOT FOUND (id=${classId})`);
|
|
463
498
|
}
|
|
464
499
|
|
|
465
500
|
// TODO(dbanks12): does this need to be moved to before the DB accesses as was done with writeNullifier?
|
|
@@ -478,19 +513,32 @@ export class PublicPersistableStateManager {
|
|
|
478
513
|
return undefined;
|
|
479
514
|
}
|
|
480
515
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
516
|
+
try {
|
|
517
|
+
const contractClass = await this.getContractClass(contractInstance.currentContractClassId);
|
|
518
|
+
assert(
|
|
519
|
+
contractClass,
|
|
520
|
+
`Contract class not found in DB, but a contract instance was found with this class ID (${contractInstance.currentContractClassId}). This should not happen!`,
|
|
521
|
+
);
|
|
522
|
+
return contractClass.packedBytecode;
|
|
523
|
+
} catch (error) {
|
|
524
|
+
if (error instanceof MaxCallsToUniqueContractClassIdsError) {
|
|
525
|
+
return undefined;
|
|
526
|
+
}
|
|
527
|
+
// Otherwise, unknown error. This is a bug.
|
|
528
|
+
throw error;
|
|
529
|
+
}
|
|
488
530
|
}
|
|
489
531
|
|
|
490
532
|
public async getPublicFunctionDebugName(avmEnvironment: AvmExecutionEnvironment): Promise<string> {
|
|
491
533
|
return await getPublicFunctionDebugName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
|
|
492
534
|
}
|
|
493
535
|
|
|
536
|
+
public async getPublicFunctionSelectorAndName(
|
|
537
|
+
avmEnvironment: AvmExecutionEnvironment,
|
|
538
|
+
): Promise<{ functionSelector?: FunctionSelector; functionName?: string }> {
|
|
539
|
+
return await getPublicFunctionSelectorAndName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
|
|
540
|
+
}
|
|
541
|
+
|
|
494
542
|
public async padTree(treeId: MerkleTreeId, leavesToInsert: number): Promise<void> {
|
|
495
543
|
await this.treesDB.padTree(treeId, leavesToInsert);
|
|
496
544
|
}
|
|
@@ -2,6 +2,7 @@ import { sum } from '@aztec/foundation/collection';
|
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
5
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
5
6
|
|
|
6
7
|
import { strict as assert } from 'assert';
|
|
7
8
|
|
|
@@ -18,7 +19,7 @@ export interface PublicEnqueuedCallMetrics {
|
|
|
18
19
|
export interface PublicTxMetrics {
|
|
19
20
|
// TS simulation
|
|
20
21
|
totalDurationMs: number;
|
|
21
|
-
manaUsed: number;
|
|
22
|
+
manaUsed: number | undefined;
|
|
22
23
|
totalInstructionsExecuted: number;
|
|
23
24
|
nonRevertiblePrivateInsertionsUs: number | undefined;
|
|
24
25
|
revertiblePrivateInsertionsUs: number | undefined;
|
|
@@ -99,7 +100,7 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
99
100
|
this.txTimer = new Timer();
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
stopRecordingTxSimulation(txLabel: string, revertedCode?: RevertCode) {
|
|
103
|
+
stopRecordingTxSimulation(txLabel: string, gasUsed?: GasUsed, revertedCode?: RevertCode) {
|
|
103
104
|
assert(this.currentTxLabel === txLabel, 'Cannot stop recording metrics for tx when another is live');
|
|
104
105
|
|
|
105
106
|
const txMetrics = this.txMetrics.get(txLabel)!;
|
|
@@ -109,7 +110,7 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
109
110
|
this.logger.debug(`Public TX simulation of ${txLabel} took ${txMetrics.totalDurationMs}ms`);
|
|
110
111
|
|
|
111
112
|
// add manaUsed across all enqueued calls
|
|
112
|
-
txMetrics.manaUsed =
|
|
113
|
+
txMetrics.manaUsed = gasUsed?.publicGas.l2Gas;
|
|
113
114
|
// add totalInstructionsExecuted across all enqueued calls
|
|
114
115
|
txMetrics.totalInstructionsExecuted = sum(txMetrics.enqueuedCalls.map(call => call.totalInstructionsExecuted));
|
|
115
116
|
txMetrics.revertedCode = revertedCode;
|
|
@@ -202,8 +203,9 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
202
203
|
pretty += `${INDENT0}Total duration: ${fmtNum(txMetrics.totalDurationMs, 'ms')}\n`;
|
|
203
204
|
}
|
|
204
205
|
if (filter === PublicTxMetricsFilter.TOTALS || filter === PublicTxMetricsFilter.ALL) {
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
const manaUsed = txMetrics.manaUsed || 0;
|
|
207
|
+
pretty += `${INDENT0}Total mana used: ${fmtNum(manaUsed)}\n`;
|
|
208
|
+
const manaPerSecond = Math.round((manaUsed * 1000) / txMetrics.totalDurationMs);
|
|
207
209
|
pretty += `${INDENT0}Mana per second: ${fmtNum(manaPerSecond)}\n`;
|
|
208
210
|
}
|
|
209
211
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bytecode_errors.d.ts","sourceRoot":"","sources":["../../src/public/bytecode_errors.ts"],"names":[],"mappings":"AAAA,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,eAAe,EAAE,MAAM;CAIpC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
|
-
/**
|
|
5
|
-
* A cache for contract classes and instances for a single transaction.
|
|
6
|
-
* Useful for tracking/retrieving contracts for a tx while leaving
|
|
7
|
-
* the option to clear them if the tx is reverted.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TxContractCache {
|
|
10
|
-
private instanceCache;
|
|
11
|
-
private classCache;
|
|
12
|
-
/**
|
|
13
|
-
* Add a contract instance to the cache
|
|
14
|
-
*/
|
|
15
|
-
addInstance(address: AztecAddress, instance: ContractInstanceWithAddress): void;
|
|
16
|
-
/**
|
|
17
|
-
* Add a contract class to the cache
|
|
18
|
-
*/
|
|
19
|
-
addClass(classId: Fr, contractClass: ContractClassPublic): void;
|
|
20
|
-
/**
|
|
21
|
-
* Get a contract instance from the cache
|
|
22
|
-
*/
|
|
23
|
-
getInstance(address: AztecAddress): ContractInstanceWithAddress | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Get a contract class from the cache
|
|
26
|
-
*/
|
|
27
|
-
getClass(classId: Fr): ContractClassPublic | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Check if the cache has a contract class
|
|
30
|
-
*/
|
|
31
|
-
hasClass(classId: Fr): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Clear all entries from the cache
|
|
34
|
-
*/
|
|
35
|
-
clear(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Merge another cache into this one
|
|
38
|
-
*/
|
|
39
|
-
mergeFrom(other: TxContractCache): void;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=tx_contract_cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tx_contract_cache.d.ts","sourceRoot":"","sources":["../../src/public/tx_contract_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE/F;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAkD;IACvE,OAAO,CAAC,UAAU,CAA0C;IAE5D;;OAEG;IACI,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAItF;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE,mBAAmB,GAAG,IAAI;IAItE;;OAEG;IACI,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,2BAA2B,GAAG,SAAS;IAIlF;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,mBAAmB,GAAG,SAAS;IAI7D;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO;IAIrC;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;CAS/C"}
|