@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,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, type Logger, type LoggerBindings, 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() {
|
|
@@ -57,7 +61,7 @@ export class SideEffectArrayLengths {
|
|
|
57
61
|
* Trace side effects for an enqueued public call's execution.
|
|
58
62
|
*/
|
|
59
63
|
export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
60
|
-
public log
|
|
64
|
+
public log: Logger;
|
|
61
65
|
|
|
62
66
|
/** The side effect counter increments with every call to the trace. */
|
|
63
67
|
private sideEffectCounter: number;
|
|
@@ -69,13 +73,13 @@ 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
|
|
|
76
79
|
constructor(
|
|
77
80
|
/** The counter of this trace's first side effect. */
|
|
78
81
|
public readonly startSideEffectCounter: number = 0,
|
|
82
|
+
bindings?: LoggerBindings,
|
|
79
83
|
/** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
|
|
80
84
|
* otherwise the public kernel can fail to prove because TX limits are breached.
|
|
81
85
|
*/
|
|
@@ -83,23 +87,30 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
83
87
|
/** We need to track the set of class IDs used, to enforce limits. */
|
|
84
88
|
private uniqueClassIds: UniqueClassIds = new UniqueClassIds(),
|
|
85
89
|
private writtenPublicDataSlots: Set<string> = new Set(),
|
|
90
|
+
private debugLogs: DebugLog[] = [],
|
|
91
|
+
private debugLogMemoryReads: number = 0,
|
|
86
92
|
) {
|
|
87
93
|
this.sideEffectCounter = startSideEffectCounter;
|
|
94
|
+
this.log = createLogger('simulator:side_effect_trace', bindings);
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
public fork() {
|
|
91
98
|
return new SideEffectTrace(
|
|
92
99
|
this.sideEffectCounter,
|
|
100
|
+
this.log.getBindings(),
|
|
93
101
|
new SideEffectArrayLengths(
|
|
94
102
|
this.previousSideEffectArrayLengths.publicDataWrites + this.userPublicDataWritesLength,
|
|
95
103
|
this.previousSideEffectArrayLengths.protocolPublicDataWrites + this.protocolPublicDataWritesLength,
|
|
96
104
|
this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length,
|
|
97
105
|
this.previousSideEffectArrayLengths.nullifiers + this.nullifiers.length,
|
|
98
106
|
this.previousSideEffectArrayLengths.l2ToL1Msgs + this.l2ToL1Messages.length,
|
|
99
|
-
this.previousSideEffectArrayLengths.
|
|
107
|
+
this.previousSideEffectArrayLengths.publicLogFields +
|
|
108
|
+
this.publicLogs.reduce((acc, log) => acc + log.sizeInFields(), 0),
|
|
100
109
|
),
|
|
101
110
|
this.uniqueClassIds.fork(),
|
|
102
111
|
new Set(this.writtenPublicDataSlots),
|
|
112
|
+
this.debugLogs.slice(),
|
|
113
|
+
this.debugLogMemoryReads,
|
|
103
114
|
);
|
|
104
115
|
}
|
|
105
116
|
|
|
@@ -113,6 +124,8 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
113
124
|
|
|
114
125
|
this.sideEffectCounter = forkedTrace.sideEffectCounter;
|
|
115
126
|
this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
|
|
127
|
+
this.debugLogs = forkedTrace.debugLogs;
|
|
128
|
+
this.debugLogMemoryReads = forkedTrace.debugLogMemoryReads;
|
|
116
129
|
|
|
117
130
|
if (!reverted) {
|
|
118
131
|
this.publicDataWrites.push(...forkedTrace.publicDataWrites);
|
|
@@ -193,7 +206,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
193
206
|
|
|
194
207
|
public traceNewNoteHash(noteHash: Fr) {
|
|
195
208
|
if (this.noteHashes.length + this.previousSideEffectArrayLengths.noteHashes >= MAX_NOTE_HASHES_PER_TX) {
|
|
196
|
-
throw new
|
|
209
|
+
throw new NoteHashLimitReachedError();
|
|
197
210
|
}
|
|
198
211
|
|
|
199
212
|
this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter));
|
|
@@ -203,10 +216,10 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
203
216
|
|
|
204
217
|
public traceNewNullifier(siloedNullifier: Fr) {
|
|
205
218
|
if (this.nullifiers.length + this.previousSideEffectArrayLengths.nullifiers >= MAX_NULLIFIERS_PER_TX) {
|
|
206
|
-
throw new
|
|
219
|
+
throw new NullifierLimitReachedError();
|
|
207
220
|
}
|
|
208
221
|
|
|
209
|
-
this.nullifiers.push(new Nullifier(siloedNullifier,
|
|
222
|
+
this.nullifiers.push(new Nullifier(siloedNullifier, /*noteHash=*/ Fr.ZERO, this.sideEffectCounter));
|
|
210
223
|
|
|
211
224
|
this.log.trace(`Tracing new nullifier (counter=${this.sideEffectCounter})`);
|
|
212
225
|
this.incrementSideEffectCounter();
|
|
@@ -214,7 +227,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
214
227
|
|
|
215
228
|
public traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr) {
|
|
216
229
|
if (this.l2ToL1Messages.length + this.previousSideEffectArrayLengths.l2ToL1Msgs >= MAX_L2_TO_L1_MSGS_PER_TX) {
|
|
217
|
-
throw new
|
|
230
|
+
throw new L2ToL1MessageLimitReachedError();
|
|
218
231
|
}
|
|
219
232
|
|
|
220
233
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
@@ -224,28 +237,43 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
224
237
|
}
|
|
225
238
|
|
|
226
239
|
public tracePublicLog(contractAddress: AztecAddress, log: Fr[]) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
240
|
+
const previouslyEmittedPublicLogFieldsCount =
|
|
241
|
+
this.previousSideEffectArrayLengths.publicLogFields +
|
|
242
|
+
this.publicLogs.reduce((acc, log) => acc + log.sizeInFields(), 0);
|
|
243
|
+
|
|
244
|
+
const publicLog = new PublicLog(contractAddress, log);
|
|
230
245
|
|
|
231
|
-
if (
|
|
232
|
-
throw new
|
|
246
|
+
if (previouslyEmittedPublicLogFieldsCount + publicLog.sizeInFields() > FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH) {
|
|
247
|
+
throw new SideEffectLimitReachedError('public log fields', FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH);
|
|
233
248
|
}
|
|
234
|
-
|
|
249
|
+
|
|
235
250
|
this.publicLogs.push(publicLog);
|
|
236
251
|
this.log.trace(`Tracing new public log (counter=${this.sideEffectCounter})`);
|
|
237
252
|
this.incrementSideEffectCounter();
|
|
238
253
|
}
|
|
239
254
|
|
|
255
|
+
public traceDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]) {
|
|
256
|
+
this.debugLogs.push(new DebugLog(contractAddress, level, message, fields));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public getDebugLogs() {
|
|
260
|
+
return this.debugLogs;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public getDebugLogMemoryReads() {
|
|
264
|
+
return this.debugLogMemoryReads;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public traceDebugLogMemoryReads(memoryReads: number) {
|
|
268
|
+
this.debugLogMemoryReads += memoryReads;
|
|
269
|
+
}
|
|
270
|
+
|
|
240
271
|
public traceGetContractClass(contractClassId: Fr, exists: boolean) {
|
|
241
272
|
// We limit the number of unique contract class IDs due to hashing and the trace length limit.
|
|
242
273
|
if (exists && !this.uniqueClassIds.has(contractClassId.toString())) {
|
|
243
274
|
if (this.uniqueClassIds.size() >= MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS) {
|
|
244
275
|
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
|
-
);
|
|
276
|
+
throw new MaxCallsToUniqueContractClassIdsError();
|
|
249
277
|
}
|
|
250
278
|
this.log.trace(`Adding contract class ID ${contractClassId} (counter=${this.sideEffectCounter})`);
|
|
251
279
|
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
|
-
}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
5
|
-
FEE_JUICE_ADDRESS,
|
|
6
|
-
MULTI_CALL_ENTRYPOINT_ADDRESS,
|
|
7
|
-
ROUTER_ADDRESS,
|
|
8
|
-
} from '@aztec/constants';
|
|
9
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PROTOCOL_CONTRACTS } from '@aztec/constants';
|
|
2
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
12
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
13
6
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
7
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
14
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
9
|
import type { ContractClassPublicWithCommitment, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
10
|
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
17
11
|
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
18
12
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
13
|
+
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
19
14
|
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
20
15
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
21
16
|
import type { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
@@ -25,10 +20,16 @@ import { strict as assert } from 'assert';
|
|
|
25
20
|
|
|
26
21
|
import type { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
27
22
|
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
28
|
-
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
23
|
+
import { getPublicFunctionDebugName, getPublicFunctionSelectorAndName } from '../debug_fn_name.js';
|
|
29
24
|
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
25
|
+
import {
|
|
26
|
+
L1ToL2MessageIndexOutOfRangeError,
|
|
27
|
+
MaxCallsToUniqueContractClassIdsError,
|
|
28
|
+
NoteHashIndexOutOfRangeError,
|
|
29
|
+
NullifierCollisionError,
|
|
30
|
+
} from '../side_effect_errors.js';
|
|
30
31
|
import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
|
|
31
|
-
import {
|
|
32
|
+
import { NullifierManager } from './nullifiers.js';
|
|
32
33
|
import { PublicStorage } from './public_storage.js';
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -41,7 +42,7 @@ import { PublicStorage } from './public_storage.js';
|
|
|
41
42
|
* Manages merging of successful/reverted child state into current state.
|
|
42
43
|
*/
|
|
43
44
|
export class PublicPersistableStateManager {
|
|
44
|
-
private readonly log
|
|
45
|
+
private readonly log: Logger;
|
|
45
46
|
|
|
46
47
|
/** Make sure a forked state is never merged twice. */
|
|
47
48
|
private alreadyMergedIntoParent = false;
|
|
@@ -52,10 +53,13 @@ export class PublicPersistableStateManager {
|
|
|
52
53
|
private readonly trace: PublicSideEffectTraceInterface,
|
|
53
54
|
private readonly firstNullifier: Fr, // Needed for note hashes.
|
|
54
55
|
private readonly timestamp: UInt64, // Needed for contract updates.
|
|
55
|
-
private readonly doMerkleOperations: boolean =
|
|
56
|
+
private readonly doMerkleOperations: boolean = true,
|
|
56
57
|
private readonly publicStorage: PublicStorage = new PublicStorage(treesDB),
|
|
57
58
|
private readonly nullifiers: NullifierManager = new NullifierManager(treesDB),
|
|
58
|
-
|
|
59
|
+
bindings?: LoggerBindings,
|
|
60
|
+
) {
|
|
61
|
+
this.log = createLogger('simulator:state_manager', bindings);
|
|
62
|
+
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
65
|
* Create a new state manager
|
|
@@ -64,9 +68,9 @@ export class PublicPersistableStateManager {
|
|
|
64
68
|
treesDB: PublicTreesDB,
|
|
65
69
|
contractsDB: PublicContractsDBInterface,
|
|
66
70
|
trace: PublicSideEffectTraceInterface,
|
|
67
|
-
doMerkleOperations: boolean = false,
|
|
68
71
|
firstNullifier: Fr,
|
|
69
72
|
timestamp: UInt64,
|
|
73
|
+
bindings?: LoggerBindings,
|
|
70
74
|
): PublicPersistableStateManager {
|
|
71
75
|
return new PublicPersistableStateManager(
|
|
72
76
|
treesDB,
|
|
@@ -74,7 +78,10 @@ export class PublicPersistableStateManager {
|
|
|
74
78
|
trace,
|
|
75
79
|
firstNullifier,
|
|
76
80
|
timestamp,
|
|
77
|
-
|
|
81
|
+
undefined,
|
|
82
|
+
undefined,
|
|
83
|
+
undefined,
|
|
84
|
+
bindings,
|
|
78
85
|
);
|
|
79
86
|
}
|
|
80
87
|
|
|
@@ -92,6 +99,7 @@ export class PublicPersistableStateManager {
|
|
|
92
99
|
this.doMerkleOperations,
|
|
93
100
|
this.publicStorage.fork(),
|
|
94
101
|
this.nullifiers.fork(),
|
|
102
|
+
this.log.getBindings(),
|
|
95
103
|
);
|
|
96
104
|
}
|
|
97
105
|
|
|
@@ -164,7 +172,6 @@ export class PublicPersistableStateManager {
|
|
|
164
172
|
if (this.doMerkleOperations) {
|
|
165
173
|
return await this.treesDB.storageRead(contractAddress, slot);
|
|
166
174
|
} 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
175
|
const read = await this.publicStorage.read(contractAddress, slot);
|
|
169
176
|
this.log.trace(
|
|
170
177
|
`Storage read results (address=${contractAddress}, slot=${slot}): value=${read.value}, cached=${read.cached}`,
|
|
@@ -183,12 +190,21 @@ export class PublicPersistableStateManager {
|
|
|
183
190
|
* @returns true if the note hash exists at the given leaf index, false otherwise
|
|
184
191
|
*/
|
|
185
192
|
public async checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex: bigint): Promise<boolean> {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
try {
|
|
194
|
+
const gotLeafValue = await this.treesDB.getNoteHash(leafIndex);
|
|
195
|
+
const exists = gotLeafValue.equals(noteHash);
|
|
196
|
+
this.log.trace(
|
|
197
|
+
`noteHashes(${contractAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`,
|
|
198
|
+
);
|
|
199
|
+
return Promise.resolve(exists);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
// If the index is out of range, note_hash_leaf_in_range = 0 and the circuit returns false:
|
|
202
|
+
if (error instanceof NoteHashIndexOutOfRangeError) {
|
|
203
|
+
return Promise.resolve(false);
|
|
204
|
+
}
|
|
205
|
+
// Otherwise, unknown error. This is a bug.
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
192
208
|
}
|
|
193
209
|
|
|
194
210
|
/**
|
|
@@ -232,7 +248,15 @@ export class PublicPersistableStateManager {
|
|
|
232
248
|
public async checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean> {
|
|
233
249
|
this.log.trace(`Checking existence of nullifier (address=${contractAddress}, nullifier=${nullifier})`);
|
|
234
250
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
251
|
+
return this.checkSiloedNullifierExists(siloedNullifier);
|
|
252
|
+
}
|
|
235
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Check if a siloed nullifier exists.
|
|
256
|
+
* @param siloedNullifier - the siloed nullifier to check
|
|
257
|
+
* @returns exists - whether the nullifier exists in the nullifier set
|
|
258
|
+
*/
|
|
259
|
+
public async checkSiloedNullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
236
260
|
if (this.doMerkleOperations) {
|
|
237
261
|
const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
|
|
238
262
|
this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists})`);
|
|
@@ -288,12 +312,21 @@ export class PublicPersistableStateManager {
|
|
|
288
312
|
* @returns exists - whether the message exists in the L1 to L2 Messages tree
|
|
289
313
|
*/
|
|
290
314
|
public async checkL1ToL2MessageExists(msgHash: Fr, msgLeafIndex: Fr): Promise<boolean> {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
315
|
+
try {
|
|
316
|
+
const valueAtIndex = await this.treesDB.getL1ToL2LeafValue(msgLeafIndex.toBigInt());
|
|
317
|
+
const exists = valueAtIndex.equals(msgHash);
|
|
318
|
+
this.log.trace(
|
|
319
|
+
`l1ToL2Messages(@${msgLeafIndex}) ?? exists: ${exists}, expected: ${msgHash}, found: ${valueAtIndex}.`,
|
|
320
|
+
);
|
|
321
|
+
return Promise.resolve(exists);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
// If the index is out of range, l1_to_l2_msg_leaf_in_range = 0 and the circuit returns false:
|
|
324
|
+
if (error instanceof L1ToL2MessageIndexOutOfRangeError) {
|
|
325
|
+
return Promise.resolve(false);
|
|
326
|
+
}
|
|
327
|
+
// Otherwise, unknown error. This is a bug.
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
297
330
|
}
|
|
298
331
|
|
|
299
332
|
/**
|
|
@@ -319,6 +352,22 @@ export class PublicPersistableStateManager {
|
|
|
319
352
|
);
|
|
320
353
|
}
|
|
321
354
|
|
|
355
|
+
public writeDebugLog(contractAddress: AztecAddress, level: LogLevel, message: string, fields: Fr[]) {
|
|
356
|
+
this.trace.traceDebugLog(contractAddress, level, message, fields);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
public writeDebugLogMemoryReads(memoryReads: number) {
|
|
360
|
+
this.trace.traceDebugLogMemoryReads(memoryReads);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
public getDebugLogMemoryReads() {
|
|
364
|
+
return this.trace.getDebugLogMemoryReads();
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
public getLogs(): DebugLog[] {
|
|
368
|
+
return this.trace.getDebugLogs();
|
|
369
|
+
}
|
|
370
|
+
|
|
322
371
|
/**
|
|
323
372
|
* Write a public log
|
|
324
373
|
* @param contractAddress - address of the contract that emitted the log
|
|
@@ -368,7 +417,7 @@ export class PublicPersistableStateManager {
|
|
|
368
417
|
|
|
369
418
|
this.log.trace(`Got contract instance (address=${contractAddress}): instance=${jsonStringify(instance!)}`);
|
|
370
419
|
|
|
371
|
-
// All that is left is
|
|
420
|
+
// All that is left is to check that the contract updatability information is correct.
|
|
372
421
|
// That is, that the current and original contract class ids are correct.
|
|
373
422
|
await this.checkContractUpdateInformation(instanceWithAddress);
|
|
374
423
|
|
|
@@ -389,13 +438,15 @@ export class PublicPersistableStateManager {
|
|
|
389
438
|
//
|
|
390
439
|
// However, we will also be checking the hash of the delayed public mutable values.
|
|
391
440
|
// This is a bit of a leak of information, since the circuit will use it to prove
|
|
392
|
-
// one public read
|
|
441
|
+
// one public read instead of N of the delayed public mutable values.
|
|
393
442
|
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
|
|
394
443
|
await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(instance.address);
|
|
395
444
|
const readDeployerStorage = async (storageSlot: Fr) =>
|
|
396
445
|
await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
397
446
|
|
|
398
447
|
const hash = await readDeployerStorage(delayedPublicMutableHashSlot);
|
|
448
|
+
// NOTE: The below reads are either not performed (if hash.isZero()) or only performed in unconstrained in c++ simulation.
|
|
449
|
+
// See UpdateCheck::check_current_class_id documentation - this means if we generate hints from the merkle db, they are unused:
|
|
399
450
|
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
|
|
400
451
|
delayedPublicMutableSlot,
|
|
401
452
|
readDeployerStorage,
|
|
@@ -438,7 +489,7 @@ export class PublicPersistableStateManager {
|
|
|
438
489
|
* @param classId - class id to retrieve.
|
|
439
490
|
* @returns the contract class or undefined if it does not exist.
|
|
440
491
|
*/
|
|
441
|
-
|
|
492
|
+
private async getContractClass(classId: Fr): Promise<ContractClassPublicWithCommitment | undefined> {
|
|
442
493
|
this.log.trace(`Getting contract class for id ${classId}`);
|
|
443
494
|
const contractClass = await this.contractsDB.getContractClass(classId);
|
|
444
495
|
const exists = contractClass !== undefined;
|
|
@@ -459,7 +510,7 @@ export class PublicPersistableStateManager {
|
|
|
459
510
|
publicBytecodeCommitment: bytecodeCommitment,
|
|
460
511
|
};
|
|
461
512
|
} else {
|
|
462
|
-
this.log.debug(`Contract
|
|
513
|
+
this.log.debug(`Contract class NOT FOUND (id=${classId})`);
|
|
463
514
|
}
|
|
464
515
|
|
|
465
516
|
// TODO(dbanks12): does this need to be moved to before the DB accesses as was done with writeNullifier?
|
|
@@ -478,19 +529,32 @@ export class PublicPersistableStateManager {
|
|
|
478
529
|
return undefined;
|
|
479
530
|
}
|
|
480
531
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
532
|
+
try {
|
|
533
|
+
const contractClass = await this.getContractClass(contractInstance.currentContractClassId);
|
|
534
|
+
assert(
|
|
535
|
+
contractClass,
|
|
536
|
+
`Contract class not found in DB, but a contract instance was found with this class ID (${contractInstance.currentContractClassId}). This should not happen!`,
|
|
537
|
+
);
|
|
538
|
+
return contractClass.packedBytecode;
|
|
539
|
+
} catch (error) {
|
|
540
|
+
if (error instanceof MaxCallsToUniqueContractClassIdsError) {
|
|
541
|
+
return undefined;
|
|
542
|
+
}
|
|
543
|
+
// Otherwise, unknown error. This is a bug.
|
|
544
|
+
throw error;
|
|
545
|
+
}
|
|
488
546
|
}
|
|
489
547
|
|
|
490
548
|
public async getPublicFunctionDebugName(avmEnvironment: AvmExecutionEnvironment): Promise<string> {
|
|
491
549
|
return await getPublicFunctionDebugName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
|
|
492
550
|
}
|
|
493
551
|
|
|
552
|
+
public async getPublicFunctionSelectorAndName(
|
|
553
|
+
avmEnvironment: AvmExecutionEnvironment,
|
|
554
|
+
): Promise<{ functionSelector?: FunctionSelector; functionName?: string }> {
|
|
555
|
+
return await getPublicFunctionSelectorAndName(this.contractsDB, avmEnvironment.address, avmEnvironment.calldata);
|
|
556
|
+
}
|
|
557
|
+
|
|
494
558
|
public async padTree(treeId: MerkleTreeId, leavesToInsert: number): Promise<void> {
|
|
495
559
|
await this.treesDB.padTree(treeId, leavesToInsert);
|
|
496
560
|
}
|
|
@@ -501,12 +565,5 @@ export class PublicPersistableStateManager {
|
|
|
501
565
|
}
|
|
502
566
|
|
|
503
567
|
function contractAddressIsCanonical(contractAddress: AztecAddress): boolean {
|
|
504
|
-
return (
|
|
505
|
-
contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) ||
|
|
506
|
-
contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) ||
|
|
507
|
-
contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) ||
|
|
508
|
-
contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) ||
|
|
509
|
-
contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) ||
|
|
510
|
-
contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS))
|
|
511
|
-
);
|
|
568
|
+
return contractAddress.toBigInt() >= 1 && contractAddress.toBigInt() <= MAX_PROTOCOL_CONTRACTS;
|
|
512
569
|
}
|