@aztec/simulator 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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/README.md +6 -4
- package/dest/client.d.ts +1 -1
- package/dest/common/errors.d.ts +2 -2
- 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 +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- 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 +6 -5
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +23 -19
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +4 -4
- 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 +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +21 -18
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- 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 +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/avm_context.d.ts +3 -3
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +3 -3
- package/dest/public/avm/avm_execution_environment.d.ts +9 -7
- 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 +3 -3
- package/dest/public/avm/avm_machine_state.d.ts +7 -6
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +3 -2
- package/dest/public/avm/avm_memory_types.d.ts +14 -14
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +4 -1
- package/dest/public/avm/avm_simulator.d.ts +5 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +24 -29
- package/dest/public/avm/avm_simulator_interface.d.ts +1 -1
- package/dest/public/avm/calldata.d.ts +51 -0
- package/dest/public/avm/calldata.d.ts.map +1 -0
- package/dest/public/avm/calldata.js +63 -0
- 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/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
- 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 +17 -8
- 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 +7 -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 +18 -19
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +47 -48
- 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 +3 -1
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +12 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +3 -3
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +5 -5
- package/dest/public/avm/opcodes/comparators.d.ts +1 -1
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts +3 -3
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +8 -8
- package/dest/public/avm/opcodes/control_flow.d.ts +3 -3
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +4 -4
- package/dest/public/avm/opcodes/conversion.d.ts +3 -3
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +7 -4
- package/dest/public/avm/opcodes/ec_add.d.ts +3 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +20 -11
- package/dest/public/avm/opcodes/environment_getters.d.ts +5 -5
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +11 -13
- package/dest/public/avm/opcodes/external_calls.d.ts +9 -9
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +23 -23
- package/dest/public/avm/opcodes/hashing.d.ts +7 -7
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +21 -16
- 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 +4 -4
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction_impl.js +4 -4
- package/dest/public/avm/opcodes/memory.d.ts +13 -13
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +26 -26
- package/dest/public/avm/opcodes/misc.d.ts +4 -3
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +30 -10
- package/dest/public/avm/opcodes/storage.d.ts +14 -13
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +34 -24
- 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 +12 -9
- package/dest/public/avm/serialization/instruction_serialization.d.ts +10 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +12 -2
- 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 +16 -3
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +31 -3
- 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 +13 -34
- 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 +4 -4
- package/dest/public/fixtures/bulk_test.d.ts +3 -3
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +63 -194
- 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 +10 -34
- package/dest/public/fixtures/opcode_spammer.d.ts +122 -0
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -0
- package/dest/public/fixtures/opcode_spammer.js +1653 -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 +11 -10
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +60 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +171 -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 +118 -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 +27 -67
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +89 -136
- 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 +16 -15
- 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 +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +28 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +19 -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 +132 -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 +23 -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 +14 -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 +11 -5
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +26 -14
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +26 -31
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +186 -130
- 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 +15 -8
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +38 -23
- 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 +22 -13
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +75 -25
- package/dest/public/test_executor_metrics.d.ts +6 -4
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +7 -6
- 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/acvm.ts +4 -3
- package/src/private/acvm/deserialize.ts +1 -1
- package/src/private/acvm/serialize.ts +1 -1
- package/src/private/acvm_native.ts +29 -16
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +22 -19
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +1 -1
- package/src/private/factory.ts +7 -4
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_contract_call_result.ts +8 -6
- package/src/public/avm/avm_execution_environment.ts +13 -7
- package/src/public/avm/avm_gas.ts +5 -5
- package/src/public/avm/avm_machine_state.ts +7 -6
- package/src/public/avm/avm_memory_types.ts +5 -1
- package/src/public/avm/avm_simulator.ts +32 -38
- package/src/public/avm/calldata.ts +100 -0
- package/src/public/avm/errors.ts +24 -27
- package/src/public/avm/fixtures/account_proof.json +553 -0
- package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +22 -6
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +33 -1
- package/src/public/avm/fixtures/initializers.ts +9 -9
- package/src/public/avm/fixtures/utils.ts +3 -2
- package/src/public/avm/opcodes/accrued_substate.ts +35 -38
- package/src/public/avm/opcodes/addressing_mode.ts +5 -5
- package/src/public/avm/opcodes/arithmetic.ts +14 -2
- package/src/public/avm/opcodes/bitwise.ts +3 -3
- package/src/public/avm/opcodes/comparators.ts +1 -1
- package/src/public/avm/opcodes/contract.ts +4 -7
- package/src/public/avm/opcodes/control_flow.ts +2 -2
- package/src/public/avm/opcodes/conversion.ts +7 -3
- package/src/public/avm/opcodes/ec_add.ts +18 -9
- package/src/public/avm/opcodes/environment_getters.ts +13 -15
- package/src/public/avm/opcodes/external_calls.ts +17 -16
- package/src/public/avm/opcodes/hashing.ts +16 -10
- package/src/public/avm/opcodes/instruction.ts +8 -6
- package/src/public/avm/opcodes/instruction_impl.ts +2 -2
- package/src/public/avm/opcodes/memory.ts +20 -20
- package/src/public/avm/opcodes/misc.ts +43 -9
- package/src/public/avm/opcodes/storage.ts +30 -22
- package/src/public/avm/revert_reason.ts +6 -3
- package/src/public/avm/serialization/bytecode_serialization.ts +19 -8
- package/src/public/avm/serialization/instruction_serialization.ts +14 -2
- 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 +39 -5
- package/src/public/executor_metrics.ts +11 -34
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +46 -28
- package/src/public/fixtures/custom_bytecode_tester.ts +83 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +228 -0
- package/src/public/fixtures/index.ts +8 -1
- package/src/public/fixtures/minimal_public_tx.ts +11 -44
- package/src/public/fixtures/opcode_spammer.ts +1717 -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 +9 -10
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +288 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +175 -0
- package/src/public/hinting_db_sources.ts +117 -10
- package/src/public/index.ts +8 -1
- package/src/public/public_db_sources.ts +126 -179
- 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 +123 -79
- package/src/public/public_processor/public_processor_metrics.ts +16 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +124 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +211 -0
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +134 -0
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +239 -0
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +83 -0
- package/src/public/public_tx_simulator/factories.ts +43 -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 +33 -13
- package/src/public/public_tx_simulator/public_tx_simulator.ts +281 -184
- 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 +53 -25
- 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 +107 -50
- package/src/public/test_executor_metrics.ts +10 -8
- 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,131 +1,160 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
|
+
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
4
4
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
5
|
-
import {
|
|
5
|
+
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
|
|
6
6
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
7
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
8
7
|
import { NestedProcessReturnValues, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
8
|
+
import { strict as assert } from 'assert';
|
|
9
|
+
import { CallDataArray } from '../avm/calldata.js';
|
|
9
10
|
import { AvmSimulator } from '../avm/index.js';
|
|
10
11
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
11
12
|
import { HintingMerkleWriteOperations, HintingPublicContractsDB } from '../hinting_db_sources.js';
|
|
12
13
|
import { PublicTreesDB } from '../public_db_sources.js';
|
|
14
|
+
import { L2ToL1MessageLimitReachedError, NoteHashLimitReachedError, NullifierCollisionError, NullifierLimitReachedError } from '../side_effect_errors.js';
|
|
13
15
|
import { PublicTxContext } from './public_tx_context.js';
|
|
16
|
+
// The errors below are only thrown here in the public tx simulator,
|
|
17
|
+
// and only during revertible phases (revertible insertions, app logic and teardown).
|
|
18
|
+
// These are strictly "checked" errors (not exported and never propagated).
|
|
19
|
+
// They are used internally for control flow to trigger rollbacks to the post-setup state.
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when public tx simulation reverts in a known/checked way during revertible insertions.
|
|
22
|
+
*/ class TxSimRevertibleInsertionsRevert extends Error {
|
|
23
|
+
constructor(){
|
|
24
|
+
super('Public Tx Simulation reverted during Revertible Insertions');
|
|
25
|
+
this.name = 'TxSimRevertibleInsertionsRevert';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when public tx simulation reverts during app logic.
|
|
30
|
+
*/ class TxSimAppLogicRevert extends Error {
|
|
31
|
+
constructor(){
|
|
32
|
+
super('Public Tx Simulation reverted during App Logic');
|
|
33
|
+
this.name = 'TxSimAppLogicRevert';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown when public tx simulation reverts during teardown.
|
|
38
|
+
*/ class TxSimTeardownRevert extends Error {
|
|
39
|
+
constructor(){
|
|
40
|
+
super('Public Tx Simulation reverted during Teardown');
|
|
41
|
+
this.name = 'TxSimTeardownRevert';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
14
44
|
export class PublicTxSimulator {
|
|
15
45
|
merkleTree;
|
|
16
46
|
contractsDB;
|
|
17
47
|
globalVariables;
|
|
18
|
-
|
|
19
|
-
skipFeeEnforcement;
|
|
20
|
-
clientInitiatedSimulation;
|
|
48
|
+
protocolContracts;
|
|
21
49
|
log;
|
|
22
|
-
|
|
50
|
+
config;
|
|
51
|
+
bindings;
|
|
52
|
+
constructor(merkleTree, contractsDB, globalVariables, config, protocolContracts = ProtocolContractsList, bindings){
|
|
23
53
|
this.merkleTree = merkleTree;
|
|
24
54
|
this.contractsDB = contractsDB;
|
|
25
55
|
this.globalVariables = globalVariables;
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.log = createLogger(`simulator:public_tx_simulator
|
|
56
|
+
this.protocolContracts = protocolContracts;
|
|
57
|
+
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
58
|
+
this.bindings = bindings;
|
|
59
|
+
this.log = createLogger(`simulator:public_tx_simulator`, bindings);
|
|
30
60
|
}
|
|
31
61
|
/**
|
|
32
62
|
* Simulate a transaction's public portion including all of its phases.
|
|
33
63
|
* @param tx - The transaction to simulate.
|
|
34
64
|
* @returns The result of the transaction's public execution.
|
|
35
65
|
*/ async simulate(tx) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
const txHash = this.computeTxHash(tx);
|
|
67
|
+
this.log.debug(`Simulating ${tx.publicFunctionCalldata.length} public calls for tx ${txHash}`, {
|
|
68
|
+
txHash
|
|
69
|
+
});
|
|
70
|
+
// Create hinting DBs.
|
|
71
|
+
const hints = new AvmExecutionHints(this.globalVariables, AvmTxHint.fromTx(tx, this.globalVariables.gasFees), this.protocolContracts);
|
|
72
|
+
const hintingMerkleTree = await HintingMerkleWriteOperations.create(this.merkleTree, hints);
|
|
73
|
+
const hintingTreesDB = new PublicTreesDB(hintingMerkleTree);
|
|
74
|
+
const hintingContractsDB = new HintingPublicContractsDB(this.contractsDB, hints);
|
|
75
|
+
const context = await PublicTxContext.create(hintingTreesDB, hintingContractsDB, tx, this.globalVariables, this.protocolContracts, this.config.proverId, this.bindings);
|
|
76
|
+
// This will throw if there is a nullifier collision.
|
|
77
|
+
// In that case the transaction will be thrown out.
|
|
78
|
+
await this.insertNonRevertiblesFromPrivate(context);
|
|
79
|
+
const processedPhases = [];
|
|
80
|
+
if (context.hasPhase(TxExecutionPhase.SETUP)) {
|
|
81
|
+
// This will throw if the setup phase reverts.
|
|
48
82
|
// In that case the transaction will be thrown out.
|
|
49
|
-
await this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// This will throw if the setup phase reverts.
|
|
53
|
-
// In that case the transaction will be thrown out.
|
|
54
|
-
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
55
|
-
if (setupResult.reverted) {
|
|
56
|
-
throw new Error(`Setup phase reverted! The transaction will be thrown out. ${setupResult.revertReason?.message}`);
|
|
57
|
-
}
|
|
58
|
-
processedPhases.push(setupResult);
|
|
83
|
+
const setupResult = await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
84
|
+
if (setupResult.reverted) {
|
|
85
|
+
throw new Error(`[SETUP] UNRECOVERABLE ERROR! The transaction will be thrown out. ${setupResult.revertReason?.message}`);
|
|
59
86
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
processedPhases.push(setupResult);
|
|
88
|
+
}
|
|
89
|
+
// The checkpoint we should go back to if anything from now on reverts.
|
|
90
|
+
await context.state.fork();
|
|
91
|
+
hintingContractsDB.createCheckpoint();
|
|
92
|
+
try {
|
|
93
|
+
// This will throw if there is a nullifier collision or other insertion error (limit reached).
|
|
94
|
+
await this.insertRevertiblesFromPrivate(context);
|
|
95
|
+
// Only proceed with app logic if there was no revert during revertible insertion.
|
|
96
|
+
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
97
|
+
const appLogicResult = await this.simulatePhase(TxExecutionPhase.APP_LOGIC, context);
|
|
98
|
+
processedPhases.push(appLogicResult);
|
|
99
|
+
if (appLogicResult.reverted) {
|
|
100
|
+
throw new TxSimAppLogicRevert();
|
|
72
101
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
102
|
+
}
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (e instanceof TxSimRevertibleInsertionsRevert || e instanceof TxSimAppLogicRevert) {
|
|
75
105
|
// We revert to the post-setup state.
|
|
76
106
|
await context.state.discardForkedState();
|
|
107
|
+
hintingContractsDB.revertCheckpoint();
|
|
77
108
|
// But we also create a new fork so that the teardown phase can transparently
|
|
78
109
|
// commit or rollback at the end of teardown.
|
|
79
110
|
await context.state.fork();
|
|
111
|
+
hintingContractsDB.createCheckpoint();
|
|
112
|
+
} else {
|
|
113
|
+
// Unchecked/unknown error - re-throw as-is
|
|
114
|
+
throw e;
|
|
80
115
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
if (context.hasPhase(TxExecutionPhase.TEARDOWN)) {
|
|
119
|
+
const teardownResult = await this.simulatePhase(TxExecutionPhase.TEARDOWN, context);
|
|
120
|
+
processedPhases.push(teardownResult);
|
|
121
|
+
if (teardownResult.reverted) {
|
|
122
|
+
throw new TxSimTeardownRevert();
|
|
88
123
|
}
|
|
89
|
-
// We commit the forked state and we are done.
|
|
90
|
-
await context.state.mergeForkedState();
|
|
91
|
-
} catch (e) {
|
|
92
|
-
this.log.debug(String(e));
|
|
93
|
-
// We rollback to the post-setup state.
|
|
94
|
-
await context.state.discardForkedState();
|
|
95
124
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
125
|
+
// We commit the forked state and we are done.
|
|
126
|
+
await context.state.mergeForkedState();
|
|
127
|
+
hintingContractsDB.commitCheckpoint();
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if (e instanceof TxSimTeardownRevert) {
|
|
130
|
+
// We revert to the post-setup state and we are done.
|
|
131
|
+
await context.state.discardForkedState();
|
|
132
|
+
hintingContractsDB.revertCheckpoint();
|
|
133
|
+
} else {
|
|
134
|
+
// Unchecked/unknown error - re-throw as-is
|
|
135
|
+
throw e;
|
|
99
136
|
}
|
|
100
|
-
await this.payFee(context);
|
|
101
|
-
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
102
|
-
const avmProvingRequest = PublicTxSimulator.generateProvingRequest(publicInputs, hints);
|
|
103
|
-
const revertCode = context.getFinalRevertCode();
|
|
104
|
-
// Commit contracts from this TX to the block-level cache and clear tx cache
|
|
105
|
-
// If the tx reverted, only commit non-revertible contracts
|
|
106
|
-
// NOTE: You can't create contracts in public, so this is only relevant for private-created contracts
|
|
107
|
-
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
108
|
-
// However things should work as they are now because the hinted db would still pick up the new contracts.
|
|
109
|
-
this.contractsDB.commitContractsForTx(/*onlyNonRevertibles=*/ !revertCode.isOK());
|
|
110
|
-
return {
|
|
111
|
-
avmProvingRequest,
|
|
112
|
-
gasUsed: {
|
|
113
|
-
totalGas: context.getActualGasUsed(),
|
|
114
|
-
teardownGas: context.teardownGasUsed,
|
|
115
|
-
publicGas: context.getActualPublicGasUsed(),
|
|
116
|
-
billedGas: context.getTotalGasUsed()
|
|
117
|
-
},
|
|
118
|
-
revertCode,
|
|
119
|
-
revertReason: context.revertReason,
|
|
120
|
-
processedPhases: processedPhases
|
|
121
|
-
};
|
|
122
|
-
} finally{
|
|
123
|
-
// Make sure there are no new contracts in the tx-level cache.
|
|
124
|
-
// They should either be committed to block-level cache or cleared.
|
|
125
|
-
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
126
|
-
// However things should work as they are now because the hinted db would still pick up the new contracts.
|
|
127
|
-
this.contractsDB.clearContractsForTx();
|
|
128
137
|
}
|
|
138
|
+
context.halt();
|
|
139
|
+
// Such transactions should be filtered by GasTxValidator.
|
|
140
|
+
assert(context.getActualGasUsed().l2Gas <= AVM_MAX_PROCESSABLE_L2_GAS, `Transaction consumes ${context.getActualGasUsed().l2Gas} L2 gas, which exceeds the AVM maximum processable gas of ${AVM_MAX_PROCESSABLE_L2_GAS}`);
|
|
141
|
+
await this.payFee(context);
|
|
142
|
+
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
143
|
+
const revertCode = context.getFinalRevertCode();
|
|
144
|
+
// We only return the app logic phase information, and only 1 per phase.
|
|
145
|
+
const appLogicReturnValues = processedPhases.find(({ phase })=>phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
146
|
+
// TODO(fcarreiro): This is a temporary backwards compatibility layer until we migrate to the C++ simulator.
|
|
147
|
+
if (context.revertReason !== undefined) {
|
|
148
|
+
appLogicReturnValues.revertReason = context.revertReason;
|
|
149
|
+
}
|
|
150
|
+
// Create PublicTxEffect from PublicInputs.
|
|
151
|
+
const publicTxEffect = new PublicTxEffect(publicInputs.transactionFee, publicInputs.accumulatedData.noteHashes.filter((h)=>!h.isEmpty()), publicInputs.accumulatedData.nullifiers.filter((n)=>!n.isEmpty()), publicInputs.accumulatedData.l2ToL1Msgs.filter((m)=>!m.isEmpty()), publicInputs.accumulatedData.publicLogs.toLogs(), publicInputs.accumulatedData.publicDataWrites.filter((w)=>!w.isEmpty()));
|
|
152
|
+
return new PublicTxResult(/*gasUsed=*/ {
|
|
153
|
+
totalGas: context.getActualGasUsed(),
|
|
154
|
+
teardownGas: context.teardownGasUsed,
|
|
155
|
+
publicGas: context.getActualPublicGasUsed(),
|
|
156
|
+
billedGas: context.getTotalGasUsed()
|
|
157
|
+
}, /*revertCode=*/ revertCode, /*publicTxEffect=*/ publicTxEffect, /*callStackMetadata=*/ appLogicReturnValues, /*logs=*/ context.state.getActiveStateManager().getLogs(), /*hints=*/ hints, /*publicInputs=*/ publicInputs);
|
|
129
158
|
}
|
|
130
159
|
computeTxHash(tx) {
|
|
131
160
|
return tx.getTxHash();
|
|
@@ -150,7 +179,7 @@ export class PublicTxSimulator {
|
|
|
150
179
|
}
|
|
151
180
|
const callRequest = callRequests[i];
|
|
152
181
|
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest);
|
|
153
|
-
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
182
|
+
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output.bestEffortReadAll()));
|
|
154
183
|
if (enqueuedCallResult.reverted) {
|
|
155
184
|
reverted = true;
|
|
156
185
|
revertReason = enqueuedCallResult.revertReason;
|
|
@@ -172,14 +201,14 @@ export class PublicTxSimulator {
|
|
|
172
201
|
*/ async simulateEnqueuedCall(phase, context, callRequest) {
|
|
173
202
|
const stateManager = context.state.getActiveStateManager();
|
|
174
203
|
const contractAddress = callRequest.request.contractAddress;
|
|
175
|
-
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, callRequest.calldata);
|
|
204
|
+
const fnName = await getPublicFunctionDebugName(this.contractsDB, contractAddress, new CallDataArray(callRequest.calldata));
|
|
176
205
|
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
177
206
|
const result = await this.simulateEnqueuedCallInternal(stateManager, callRequest, allocatedGas, /*transactionFee=*/ context.getTransactionFee(phase), fnName);
|
|
178
207
|
const gasUsed = allocatedGas.sub(result.gasLeft); // by enqueued call
|
|
179
208
|
context.consumeGas(phase, gasUsed);
|
|
180
209
|
this.log.debug(`Simulated enqueued public call (${fnName}) consumed ${gasUsed.l2Gas} L2 gas ending with ${result.gasLeft.l2Gas} L2 gas left.`);
|
|
181
210
|
if (result.reverted) {
|
|
182
|
-
const culprit = `${contractAddress}:${
|
|
211
|
+
const culprit = `${contractAddress}:${fnName}`;
|
|
183
212
|
context.revert(phase, result.revertReason, culprit);
|
|
184
213
|
}
|
|
185
214
|
return result;
|
|
@@ -200,13 +229,13 @@ export class PublicTxSimulator {
|
|
|
200
229
|
const address = request.contractAddress;
|
|
201
230
|
const sender = request.msgSender;
|
|
202
231
|
this.log.debug(`Executing enqueued public call to external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`);
|
|
203
|
-
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, calldata, allocatedGas, this.
|
|
232
|
+
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, request.isStaticCall, new CallDataArray(calldata), allocatedGas, this.config);
|
|
204
233
|
const avmCallResult = await simulator.execute();
|
|
205
234
|
return avmCallResult.finalize();
|
|
206
235
|
}
|
|
207
236
|
/**
|
|
208
237
|
* Insert the non-revertible accumulated data from private into the public state.
|
|
209
|
-
*/ async insertNonRevertiblesFromPrivate(context
|
|
238
|
+
*/ async insertNonRevertiblesFromPrivate(context) {
|
|
210
239
|
const stateManager = context.state.getActiveStateManager();
|
|
211
240
|
for (const siloedNullifier of context.nonRevertibleAccumulatedDataFromPrivate.nullifiers.filter((n)=>!n.isEmpty())){
|
|
212
241
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
@@ -221,46 +250,81 @@ export class PublicTxSimulator {
|
|
|
221
250
|
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
222
251
|
}
|
|
223
252
|
}
|
|
224
|
-
// add new contracts to the contracts db so that their
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
|
|
253
|
+
// add new contracts to the contracts db so that their code may be found and called
|
|
254
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
255
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
256
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
257
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
258
|
+
await this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
229
259
|
}
|
|
230
260
|
/**
|
|
231
261
|
* Insert the revertible accumulated data from private into the public state.
|
|
232
|
-
*
|
|
233
|
-
|
|
262
|
+
* Throws TxSimRevertibleInsertionsRevert if there is some checked error during revertible insertions.
|
|
263
|
+
* This function checks for the following errors:
|
|
264
|
+
* - NullifierLimitReachedError
|
|
265
|
+
* - NullifierCollisionError
|
|
266
|
+
* - NoteHashLimitReachedError
|
|
267
|
+
* - L2ToL1MessageLimitReachedError
|
|
268
|
+
*/ async insertRevertiblesFromPrivate(context) {
|
|
234
269
|
const stateManager = context.state.getActiveStateManager();
|
|
235
270
|
try {
|
|
236
271
|
for (const siloedNullifier of context.revertibleAccumulatedDataFromPrivate.nullifiers.filter((n)=>!n.isEmpty())){
|
|
237
272
|
await stateManager.writeSiloedNullifier(siloedNullifier);
|
|
238
273
|
}
|
|
239
274
|
} catch (e) {
|
|
240
|
-
|
|
241
|
-
|
|
275
|
+
if (e instanceof NullifierLimitReachedError || e instanceof NullifierCollisionError) {
|
|
276
|
+
context.revert(TxExecutionPhase.APP_LOGIC, new SimulationError(`Error encountered when inserting revertible nullifiers from private.\nDetails: ${e.message}`, []));
|
|
277
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
278
|
+
} else {
|
|
279
|
+
// Unchecked/unknown error - re-throw as-is
|
|
280
|
+
throw e;
|
|
281
|
+
}
|
|
242
282
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
283
|
+
try {
|
|
284
|
+
for (const noteHash of context.revertibleAccumulatedDataFromPrivate.noteHashes){
|
|
285
|
+
if (!noteHash.isEmpty()) {
|
|
286
|
+
// Revertible note hashes from private are not hashed with nonce, since private can't know their final position, only we can.
|
|
287
|
+
await stateManager.writeSiloedNoteHash(noteHash);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
} catch (e) {
|
|
291
|
+
if (e instanceof NoteHashLimitReachedError) {
|
|
292
|
+
context.revert(TxExecutionPhase.APP_LOGIC, new SimulationError(`Error encountered when inserting revertible note hashes from private.\nDetails: ${e.message}`, []));
|
|
293
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
294
|
+
} else {
|
|
295
|
+
// Unchecked/unknown error - re-throw as-is
|
|
296
|
+
throw e;
|
|
247
297
|
}
|
|
248
298
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
299
|
+
try {
|
|
300
|
+
for (const l2ToL1Message of context.revertibleAccumulatedDataFromPrivate.l2ToL1Msgs){
|
|
301
|
+
if (!l2ToL1Message.isEmpty()) {
|
|
302
|
+
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
} catch (e) {
|
|
306
|
+
if (e instanceof L2ToL1MessageLimitReachedError) {
|
|
307
|
+
context.revert(TxExecutionPhase.APP_LOGIC, new SimulationError(`Error encountered when inserting revertible L2-to-L1 messages from private.\nDetails: ${e.message}`, []));
|
|
308
|
+
throw new TxSimRevertibleInsertionsRevert();
|
|
309
|
+
} else {
|
|
310
|
+
// Unchecked/unknown error - re-throw as-is
|
|
311
|
+
throw e;
|
|
252
312
|
}
|
|
253
313
|
}
|
|
254
314
|
// add new contracts to the contracts db so that their functions may be found and called
|
|
255
|
-
// FIXME(fcarreiro): this should conceptually use the
|
|
256
|
-
// However things
|
|
257
|
-
|
|
258
|
-
|
|
315
|
+
// FIXME(fcarreiro): this should conceptually use the hinting contracts db.
|
|
316
|
+
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
317
|
+
// will pick up the new contracts and will generate the necessary hints.
|
|
318
|
+
// So, a consumer of the hints will always see the new contracts.
|
|
319
|
+
await this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
259
320
|
}
|
|
260
321
|
async payFee(context) {
|
|
261
322
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
262
323
|
if (context.feePayer.isZero()) {
|
|
263
|
-
|
|
324
|
+
// Real transactions are enforced by private kernel to have nonzero fee payer.
|
|
325
|
+
// Real transactions cannot skip fee enforcement (skipping fee enforcement makes them unprovable).
|
|
326
|
+
assert(this.config.skipFeeEnforcement, 'Fee payer cannot be 0 unless skipping fee enforcement for simulation');
|
|
327
|
+
this.log.debug(`Fee payer is 0. Skipping fee enforcement. No one is paying the fee of ${txFee.toBigInt()}`);
|
|
264
328
|
return;
|
|
265
329
|
}
|
|
266
330
|
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
@@ -271,21 +335,13 @@ export class PublicTxSimulator {
|
|
|
271
335
|
// We allow to fake the balance of the fee payer to allow fee estimation
|
|
272
336
|
// When mocking the balance of the fee payer, the circuit should not be able to prove the simulation
|
|
273
337
|
if (currentBalance.lt(txFee)) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
338
|
+
// Without "skipFeeEnforcement", such transactions should be filtered by GasTxValidator.
|
|
339
|
+
assert(this.config.skipFeeEnforcement, `Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`);
|
|
340
|
+
this.log.debug(`Fee payer balance insufficient, but we're skipping fee enforcement`);
|
|
341
|
+
// We still proceed and perform the storage write to minimize deviation from normal execution.
|
|
342
|
+
currentBalance = txFee;
|
|
279
343
|
}
|
|
280
344
|
const updatedBalance = currentBalance.sub(txFee);
|
|
281
345
|
await stateManager.writeStorage(feeJuiceAddress, balanceSlot, updatedBalance, true);
|
|
282
346
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Generate the proving request for the AVM circuit.
|
|
285
|
-
*/ static generateProvingRequest(publicInputs, hints) {
|
|
286
|
-
return {
|
|
287
|
-
type: ProvingRequestType.PUBLIC_VM,
|
|
288
|
-
inputs: new AvmCircuitInputs(hints, publicInputs)
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
347
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PublicTxResult } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
export interface PublicTxSimulatorInterface {
|
|
4
|
+
simulate(tx: Tx): Promise<PublicTxResult>;
|
|
5
|
+
/**
|
|
6
|
+
* Cancel the current simulation if one is in progress.
|
|
7
|
+
* This signals the underlying simulator (e.g., C++) to stop at the next safe point.
|
|
8
|
+
* Safe to call even if no simulation is in progress.
|
|
9
|
+
* Optional - not all implementations support cancellation.
|
|
10
|
+
*
|
|
11
|
+
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
12
|
+
* This is important because signaling cancellation doesn't immediately stop C++ -
|
|
13
|
+
* it only sets a flag that C++ checks at certain points. If C++ is in the middle
|
|
14
|
+
* of a slow operation (e.g., pad_trees), it won't stop until that completes.
|
|
15
|
+
* @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
|
|
16
|
+
*/
|
|
17
|
+
cancel?(waitTimeoutMs?: number): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface MeasuredPublicTxSimulatorInterface {
|
|
20
|
+
simulate(tx: Tx, txLabel: string): Promise<PublicTxResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Cancel the current simulation if one is in progress.
|
|
23
|
+
* This signals the underlying simulator (e.g., C++) to stop at the next safe point.
|
|
24
|
+
* Safe to call even if no simulation is in progress.
|
|
25
|
+
* Optional - not all implementations support cancellation.
|
|
26
|
+
*
|
|
27
|
+
* @param waitTimeoutMs - If provided, wait up to this many ms for the simulation to actually stop.
|
|
28
|
+
* @returns Promise that resolves when cancellation is signaled (and optionally when simulation stops)
|
|
29
|
+
*/
|
|
30
|
+
cancel?(waitTimeoutMs?: number): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X3NpbXVsYXRvcl9pbnRlcmZhY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci9wdWJsaWNfdHhfc2ltdWxhdG9yX2ludGVyZmFjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUzQyxNQUFNLFdBQVcsMEJBQTBCO0lBQ3pDLFFBQVEsQ0FBQyxFQUFFLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQyxjQUFjLENBQUMsQ0FBQztJQUMxQzs7Ozs7Ozs7Ozs7T0FXRztJQUNILE1BQU0sQ0FBQyxDQUFDLGFBQWEsQ0FBQyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUM7Q0FDaEQ7QUFFRCxNQUFNLFdBQVcsa0NBQWtDO0lBQ2pELFFBQVEsQ0FBQyxFQUFFLEVBQUUsRUFBRSxFQUFFLE9BQU8sRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLGNBQWMsQ0FBQyxDQUFDO0lBQzNEOzs7Ozs7OztPQVFHO0lBQ0gsTUFBTSxDQUFDLENBQUMsYUFBYSxDQUFDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztDQUNoRCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_tx_simulator_interface.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC1C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3D;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
2
3
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
4
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
4
5
|
import { type GlobalVariables, PublicCallRequestWithCalldata, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
@@ -13,8 +14,8 @@ import { PublicTxContext } from './public_tx_context.js';
|
|
|
13
14
|
*/
|
|
14
15
|
export declare class TelemetryPublicTxSimulator extends MeasuredPublicTxSimulator {
|
|
15
16
|
readonly tracer: Tracer;
|
|
16
|
-
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables,
|
|
17
|
+
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, telemetryClient?: TelemetryClient, config?: Partial<PublicSimulatorConfig>);
|
|
17
18
|
protected simulateEnqueuedCall(phase: TxExecutionPhase, context: PublicTxContext, callRequest: PublicCallRequestWithCalldata): Promise<AvmFinalizedCallResult>;
|
|
18
19
|
protected simulateEnqueuedCallInternal(stateManager: PublicPersistableStateManager, callRequest: PublicCallRequestWithCalldata, allocatedGas: Gas, transactionFee: Fr, fnName: string): Promise<AvmFinalizedCallResult>;
|
|
19
20
|
}
|
|
20
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVsZW1ldHJ5X3B1YmxpY190eF9zaW11bGF0b3IuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci90ZWxlbWV0cnlfcHVibGljX3R4X3NpbXVsYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQy9ELE9BQU8sS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQzdDLE9BQU8sS0FBSyxFQUFFLHlCQUF5QixFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckUsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUFFLDZCQUE2QixFQUFFLGdCQUFnQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDekcsT0FBTyxFQUFjLEtBQUssZUFBZSxFQUFFLEtBQUssTUFBTSxFQUFpQyxNQUFNLHlCQUF5QixDQUFDO0FBRXZILE9BQU8sS0FBSyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFFakYsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSw2QkFBNkIsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQ3ZGLE9BQU8sRUFBRSx5QkFBeUIsRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBQzlFLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUV6RDs7R0FFRztBQUNILHFCQUFhLDBCQUEyQixTQUFRLHlCQUF5QjtJQUV2RSxTQUFnQixNQUFNLEVBQUUsTUFBTSxDQUFDO0lBRS9CLFlBQ0UsVUFBVSxFQUFFLHlCQUF5QixFQUNyQyxXQUFXLEVBQUUsaUJBQWlCLEVBQzlCLGVBQWUsRUFBRSxlQUFlLEVBQ2hDLGVBQWUsR0FBRSxlQUFzQyxFQUN2RCxNQUFNLENBQUMsRUFBRSxPQUFPLENBQUMscUJBQXFCLENBQUMsRUFLeEM7SUFFRCxVQU15QixvQkFBb0IsQ0FDM0MsS0FBSyxFQUFFLGdCQUFnQixFQUN2QixPQUFPLEVBQUUsZUFBZSxFQUN4QixXQUFXLEVBQUUsNkJBQTZCLEdBQ3pDLE9BQU8sQ0FBQyxzQkFBc0IsQ0FBQyxDQUVqQztJQUVELFVBTXlCLDRCQUE0QixDQUNuRCxZQUFZLEVBQUUsNkJBQTZCLEVBQzNDLFdBQVcsRUFBRSw2QkFBNkIsRUFDMUMsWUFBWSxFQUFFLEdBQUcsRUFDakIsY0FBYyxFQUFFLEVBQUUsRUFDbEIsTUFBTSxFQUFFLE1BQU0sR0FDYixPQUFPLENBQUMsc0JBQXNCLENBQUMsQ0FFakM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/telemetry_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"telemetry_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/telemetry_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzG,OAAO,EAAc,KAAK,eAAe,EAAE,KAAK,MAAM,EAAiC,MAAM,yBAAyB,CAAC;AAEvH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,yBAAyB;IAEvE,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,YACE,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAChC,eAAe,GAAE,eAAsC,EACvD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAKxC;IAED,UAMyB,oBAAoB,CAC3C,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,6BAA6B,GACzC,OAAO,CAAC,sBAAsB,CAAC,CAEjC;IAED,UAMyB,4BAA4B,CACnD,YAAY,EAAE,6BAA6B,EAC3C,WAAW,EAAE,6BAA6B,EAC1C,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC,CAEjC;CACF"}
|