@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,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
L1_TO_L2_MSG_TREE_LEAF_COUNT,
|
|
3
|
+
NOTE_HASH_TREE_LEAF_COUNT,
|
|
4
|
+
NULLIFIER_SUBTREE_HEIGHT,
|
|
5
|
+
PUBLIC_DATA_SUBTREE_HEIGHT,
|
|
6
|
+
} from '@aztec/constants';
|
|
7
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
8
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
4
9
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
10
|
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
6
11
|
import { ContractInstancePublishedEvent } from '@aztec/protocol-contracts/instance-registry';
|
|
@@ -8,14 +13,15 @@ import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
|
8
13
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
9
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
15
|
import {
|
|
16
|
+
AllContractDeploymentData,
|
|
11
17
|
type ContractClassPublic,
|
|
12
18
|
type ContractDataSource,
|
|
19
|
+
type ContractDeploymentData,
|
|
13
20
|
type ContractInstanceWithAddress,
|
|
14
21
|
computePublicBytecodeCommitment,
|
|
15
22
|
} from '@aztec/stdlib/contract';
|
|
16
23
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
17
24
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
18
|
-
import { ContractClassLog, PrivateLog } from '@aztec/stdlib/logs';
|
|
19
25
|
import type { PublicDBAccessStats } from '@aztec/stdlib/stats';
|
|
20
26
|
import {
|
|
21
27
|
MerkleTreeId,
|
|
@@ -27,181 +33,96 @@ import {
|
|
|
27
33
|
import { TreeSnapshots, type Tx } from '@aztec/stdlib/tx';
|
|
28
34
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
29
35
|
|
|
36
|
+
import { strict as assert } from 'assert';
|
|
37
|
+
|
|
38
|
+
import { ContractsDbCheckpoint } from './contracts_db_checkpoint.js';
|
|
30
39
|
import type { PublicContractsDBInterface, PublicStateDBInterface } from './db_interfaces.js';
|
|
31
|
-
import {
|
|
40
|
+
import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from './side_effect_errors.js';
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
43
|
* Implements the PublicContractsDBInterface using a ContractDataSource.
|
|
35
|
-
*
|
|
36
|
-
* Separates block-level contract information (from processed/included txs) from the
|
|
37
|
-
* current tx's contract information (which may be cleared on tx revert/death).
|
|
44
|
+
* Uses a stack-based checkpoint model for managing contract state.
|
|
38
45
|
*/
|
|
39
46
|
export class PublicContractsDB implements PublicContractsDBInterface {
|
|
40
|
-
|
|
41
|
-
// Tx-level cache:
|
|
42
|
-
// - The current tx's new contract information is cached
|
|
43
|
-
// in currentTxNonRevertibleCache and currentTxRevertibleCache.
|
|
44
|
-
// Block-level cache:
|
|
45
|
-
// - Contract information from earlier in the block, usable by later txs.
|
|
46
|
-
// When a tx succeeds, that tx's caches are merged into the block cache and cleared.
|
|
47
|
-
private currentTxNonRevertibleCache = new TxContractCache();
|
|
48
|
-
private currentTxRevertibleCache = new TxContractCache();
|
|
49
|
-
private blockCache = new TxContractCache();
|
|
50
|
-
// Separate flat cache for bytecode commitments.
|
|
51
|
-
private bytecodeCommitmentCache = new Map<string, Fr>();
|
|
52
|
-
|
|
53
|
-
private log = createLogger('simulator:contracts-data-source');
|
|
54
|
-
|
|
55
|
-
constructor(private dataSource: ContractDataSource) {}
|
|
47
|
+
private contractStateStack: ContractsDbCheckpoint[] = [new ContractsDbCheckpoint()];
|
|
56
48
|
|
|
57
|
-
|
|
58
|
-
* Add new contracts from a transaction
|
|
59
|
-
* @param tx - The transaction to add contracts from.
|
|
60
|
-
*/
|
|
61
|
-
public async addNewContracts(tx: Tx): Promise<void> {
|
|
62
|
-
await this.addNonRevertibleContractClasses(tx);
|
|
63
|
-
await this.addRevertibleContractClasses(tx);
|
|
64
|
-
this.addNonRevertibleContractInstances(tx);
|
|
65
|
-
this.addRevertibleContractInstances(tx);
|
|
66
|
-
}
|
|
49
|
+
private log: Logger;
|
|
67
50
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
await this.addNonRevertibleContractClasses(tx);
|
|
74
|
-
this.addNonRevertibleContractInstances(tx);
|
|
51
|
+
constructor(
|
|
52
|
+
private dataSource: ContractDataSource,
|
|
53
|
+
bindings?: LoggerBindings,
|
|
54
|
+
) {
|
|
55
|
+
this.log = createLogger('simulator:contracts-data-source', bindings);
|
|
75
56
|
}
|
|
76
57
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* @param tx - The transaction to add revertible contracts from.
|
|
80
|
-
*/
|
|
81
|
-
public async addNewRevertibleContracts(tx: Tx) {
|
|
82
|
-
await this.addRevertibleContractClasses(tx);
|
|
83
|
-
this.addRevertibleContractInstances(tx);
|
|
84
|
-
}
|
|
58
|
+
public async addContracts(contractDeploymentData: ContractDeploymentData): Promise<void> {
|
|
59
|
+
const currentState = this.getCurrentState();
|
|
85
60
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
private async addNonRevertibleContractClasses(tx: Tx) {
|
|
92
|
-
const siloedContractClassLogs = tx.data.forPublic
|
|
93
|
-
? tx.getSplitContractClassLogs(false /* revertible */)
|
|
94
|
-
: tx.getContractClassLogs();
|
|
95
|
-
await this.addContractClassesFromLogs(siloedContractClassLogs, this.currentTxNonRevertibleCache, 'non-revertible');
|
|
96
|
-
}
|
|
61
|
+
await this.addContractClassesFromEvents(
|
|
62
|
+
ContractClassPublishedEvent.extractContractClassEvents(contractDeploymentData.getContractClassLogs()),
|
|
63
|
+
currentState,
|
|
64
|
+
);
|
|
97
65
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*/
|
|
103
|
-
private async addRevertibleContractClasses(tx: Tx) {
|
|
104
|
-
const siloedContractClassLogs = tx.data.forPublic ? tx.getSplitContractClassLogs(true /* revertible */) : [];
|
|
105
|
-
await this.addContractClassesFromLogs(siloedContractClassLogs, this.currentTxRevertibleCache, 'revertible');
|
|
66
|
+
this.addContractInstancesFromEvents(
|
|
67
|
+
ContractInstancePublishedEvent.extractContractInstanceEvents(contractDeploymentData.getPrivateLogs()),
|
|
68
|
+
currentState,
|
|
69
|
+
);
|
|
106
70
|
}
|
|
107
71
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*/
|
|
113
|
-
private addNonRevertibleContractInstances(tx: Tx) {
|
|
114
|
-
const contractInstanceLogs = tx.data.forPublic
|
|
115
|
-
? tx.data.forPublic!.nonRevertibleAccumulatedData.privateLogs.filter(l => !l.isEmpty())
|
|
116
|
-
: tx.data.forRollup!.end.privateLogs.filter(l => !l.isEmpty());
|
|
117
|
-
|
|
118
|
-
this.addContractInstancesFromLogs(contractInstanceLogs, this.currentTxNonRevertibleCache, 'non-revertible');
|
|
72
|
+
public async addNewContracts(tx: Tx): Promise<void> {
|
|
73
|
+
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
74
|
+
await this.addContracts(contractDeploymentData.getNonRevertibleContractDeploymentData());
|
|
75
|
+
await this.addContracts(contractDeploymentData.getRevertibleContractDeploymentData());
|
|
119
76
|
}
|
|
120
77
|
|
|
121
78
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @param tx - The transaction to add revertible contract instances from.
|
|
79
|
+
* Creates a new checkpoint, copying the current state for upcoming modifications,
|
|
80
|
+
* and enabling rollbacks to current state in case of a revert.
|
|
125
81
|
*/
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this.addContractInstancesFromLogs(contractInstanceLogs, this.currentTxRevertibleCache, 'revertible');
|
|
82
|
+
public createCheckpoint(): void {
|
|
83
|
+
const currentState = this.getCurrentState();
|
|
84
|
+
const newState = currentState.deepCopy();
|
|
85
|
+
this.contractStateStack.push(newState);
|
|
132
86
|
}
|
|
133
87
|
|
|
134
88
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @param siloedContractClassLogs - Contract class logs to process
|
|
137
|
-
* @param cache - The cache to store the contract classes in
|
|
138
|
-
* @param cacheType - Type of cache (for logging)
|
|
89
|
+
* Commits the current checkpoint, accepting its state latest.
|
|
139
90
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.filter((log: ContractClassLog) => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
|
|
147
|
-
.map((log: ContractClassLog) => ContractClassPublishedEvent.fromLog(log));
|
|
148
|
-
|
|
149
|
-
// Cache contract classes
|
|
150
|
-
await Promise.all(
|
|
151
|
-
contractClassEvents.map(async (event: ContractClassPublishedEvent) => {
|
|
152
|
-
this.log.debug(`Adding class ${event.contractClassId.toString()} to contract's ${cacheType} tx cache`);
|
|
153
|
-
const contractClass = await event.toContractClassPublic();
|
|
154
|
-
|
|
155
|
-
cache.addClass(event.contractClassId, contractClass);
|
|
156
|
-
}),
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Given a tx's contract instance logs, add the contract instances to the cache
|
|
162
|
-
* @param contractInstanceLogs - Contract instance logs to process
|
|
163
|
-
* @param cache - The cache to store the contract instances in
|
|
164
|
-
* @param cacheType - Type of cache (for logging)
|
|
165
|
-
*/
|
|
166
|
-
private addContractInstancesFromLogs(contractInstanceLogs: PrivateLog[], cache: TxContractCache, cacheType: string) {
|
|
167
|
-
const contractInstanceEvents = contractInstanceLogs
|
|
168
|
-
.filter(log => ContractInstancePublishedEvent.isContractInstancePublishedEvent(log))
|
|
169
|
-
.map(log => ContractInstancePublishedEvent.fromLog(log));
|
|
170
|
-
|
|
171
|
-
// Cache contract instances
|
|
172
|
-
contractInstanceEvents.forEach(e => {
|
|
173
|
-
this.log.debug(
|
|
174
|
-
`Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to ${cacheType} tx contract cache`,
|
|
175
|
-
);
|
|
176
|
-
cache.addInstance(e.address, e.toContractInstance());
|
|
177
|
-
});
|
|
91
|
+
public commitCheckpoint(): void {
|
|
92
|
+
if (this.contractStateStack.length <= 1) {
|
|
93
|
+
throw new Error('No checkpoint to commit');
|
|
94
|
+
}
|
|
95
|
+
const topState = this.contractStateStack.pop()!;
|
|
96
|
+
this.contractStateStack[this.contractStateStack.length - 1] = topState;
|
|
178
97
|
}
|
|
179
98
|
|
|
180
99
|
/**
|
|
181
|
-
*
|
|
100
|
+
* Commits the current checkpoint, not erroring if there is no checkpoint
|
|
101
|
+
* to commit. This is useful to do a sanity commit at the end of tx execution,
|
|
102
|
+
* doing nothing if the checkpoint was already reverted, but truly committing
|
|
103
|
+
* otherwise.
|
|
182
104
|
*/
|
|
183
|
-
public
|
|
184
|
-
this.
|
|
185
|
-
|
|
186
|
-
|
|
105
|
+
public commitCheckpointOkIfNone(): void {
|
|
106
|
+
if (this.contractStateStack.length <= 1) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const topState = this.contractStateStack.pop()!;
|
|
110
|
+
this.contractStateStack[this.contractStateStack.length - 1] = topState;
|
|
187
111
|
}
|
|
188
112
|
|
|
189
113
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
114
|
+
* Reverts the current checkpoint, discarding its state and rolling back
|
|
115
|
+
* to the state as of the latest checkpoint.
|
|
192
116
|
*/
|
|
193
|
-
public
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (!onlyNonRevertibles) {
|
|
198
|
-
// Merge revertible tx cache into block cache
|
|
199
|
-
this.blockCache.mergeFrom(this.currentTxRevertibleCache);
|
|
117
|
+
public revertCheckpoint(): void {
|
|
118
|
+
if (this.contractStateStack.length <= 1) {
|
|
119
|
+
throw new Error('No checkpoint to revert');
|
|
200
120
|
}
|
|
121
|
+
this.contractStateStack.pop();
|
|
122
|
+
}
|
|
201
123
|
|
|
202
|
-
|
|
203
|
-
this.
|
|
204
|
-
this.currentTxRevertibleCache.clear();
|
|
124
|
+
private getCurrentState(): ContractsDbCheckpoint {
|
|
125
|
+
return this.contractStateStack[this.contractStateStack.length - 1];
|
|
205
126
|
}
|
|
206
127
|
|
|
207
128
|
// TODO(fcarreiro/alvaro): This method currently needs a blockNumber. Since this class
|
|
@@ -217,53 +138,66 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
217
138
|
address: AztecAddress,
|
|
218
139
|
timestamp: UInt64,
|
|
219
140
|
): Promise<ContractInstanceWithAddress | undefined> {
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
this.currentTxRevertibleCache.getInstance(address) ??
|
|
223
|
-
this.currentTxNonRevertibleCache.getInstance(address) ??
|
|
224
|
-
this.blockCache.getInstance(address) ??
|
|
225
|
-
(await this.dataSource.getContract(address, timestamp))
|
|
226
|
-
);
|
|
141
|
+
const currentState = this.getCurrentState();
|
|
142
|
+
return currentState.getInstance(address) ?? (await this.dataSource.getContract(address, timestamp));
|
|
227
143
|
}
|
|
228
144
|
|
|
229
145
|
public async getContractClass(contractClassId: Fr): Promise<ContractClassPublic | undefined> {
|
|
230
|
-
|
|
231
|
-
return (
|
|
232
|
-
this.currentTxRevertibleCache.getClass(contractClassId) ??
|
|
233
|
-
this.currentTxNonRevertibleCache.getClass(contractClassId) ??
|
|
234
|
-
this.blockCache.getClass(contractClassId) ??
|
|
235
|
-
(await this.dataSource.getContractClass(contractClassId))
|
|
236
|
-
);
|
|
146
|
+
const currentState = this.getCurrentState();
|
|
147
|
+
return currentState.getClass(contractClassId) ?? (await this.dataSource.getContractClass(contractClassId));
|
|
237
148
|
}
|
|
238
149
|
|
|
239
150
|
public async getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined> {
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// Now try from the store
|
|
247
|
-
const fromStore = await this.dataSource.getBytecodeCommitment(contractClassId);
|
|
248
|
-
if (fromStore !== undefined) {
|
|
249
|
-
this.bytecodeCommitmentCache.set(key, fromStore);
|
|
250
|
-
return fromStore;
|
|
151
|
+
const currentState = this.getCurrentState();
|
|
152
|
+
const commitment =
|
|
153
|
+
currentState.getBytecodeCommitment(contractClassId) ??
|
|
154
|
+
(await this.dataSource.getBytecodeCommitment(contractClassId));
|
|
155
|
+
if (commitment !== undefined) {
|
|
156
|
+
return commitment;
|
|
251
157
|
}
|
|
252
|
-
|
|
253
|
-
//
|
|
158
|
+
// Not in the current state or the store, compute it here
|
|
159
|
+
// Get the contract class
|
|
254
160
|
const contractClass = await this.getContractClass(contractClassId);
|
|
161
|
+
|
|
255
162
|
if (contractClass === undefined) {
|
|
163
|
+
// cannot compute bytecode commitment if contract class is not found
|
|
256
164
|
return undefined;
|
|
257
165
|
}
|
|
258
166
|
|
|
259
167
|
const value = await computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
260
|
-
|
|
168
|
+
// Add to cache (current checkpoint state) so we don't compute again
|
|
169
|
+
currentState.addBytecodeCommitment(contractClassId, value);
|
|
261
170
|
return value;
|
|
262
171
|
}
|
|
263
172
|
|
|
264
173
|
public async getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
|
|
265
174
|
return await this.dataSource.getDebugFunctionName(address, selector);
|
|
266
175
|
}
|
|
176
|
+
|
|
177
|
+
private async addContractClassesFromEvents(
|
|
178
|
+
contractClassEvents: ContractClassPublishedEvent[],
|
|
179
|
+
state: ContractsDbCheckpoint,
|
|
180
|
+
) {
|
|
181
|
+
await Promise.all(
|
|
182
|
+
contractClassEvents.map(async (event: ContractClassPublishedEvent) => {
|
|
183
|
+
this.log.debug(`Adding class ${event.contractClassId.toString()} to contract state`);
|
|
184
|
+
const contractClass = await event.toContractClassPublic();
|
|
185
|
+
state.addClass(event.contractClassId, contractClass);
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private addContractInstancesFromEvents(
|
|
191
|
+
contractInstanceEvents: ContractInstancePublishedEvent[],
|
|
192
|
+
state: ContractsDbCheckpoint,
|
|
193
|
+
) {
|
|
194
|
+
contractInstanceEvents.forEach(e => {
|
|
195
|
+
this.log.debug(
|
|
196
|
+
`Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to contract state`,
|
|
197
|
+
);
|
|
198
|
+
state.addInstance(e.address, e.toContractInstance());
|
|
199
|
+
});
|
|
200
|
+
}
|
|
267
201
|
}
|
|
268
202
|
|
|
269
203
|
/**
|
|
@@ -279,9 +213,14 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
279
213
|
* to decide whether to use hints or not (same with tracing, etc).
|
|
280
214
|
*/
|
|
281
215
|
export class PublicTreesDB implements PublicStateDBInterface {
|
|
282
|
-
private logger
|
|
216
|
+
private logger: Logger;
|
|
283
217
|
|
|
284
|
-
constructor(
|
|
218
|
+
constructor(
|
|
219
|
+
private readonly db: MerkleTreeWriteOperations,
|
|
220
|
+
bindings?: LoggerBindings,
|
|
221
|
+
) {
|
|
222
|
+
this.logger = createLogger('simulator:public-trees-db', bindings);
|
|
223
|
+
}
|
|
285
224
|
|
|
286
225
|
public async storageRead(contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
287
226
|
const timer = new Timer();
|
|
@@ -323,9 +262,13 @@ export class PublicTreesDB implements PublicStateDBInterface {
|
|
|
323
262
|
} satisfies PublicDBAccessStats);
|
|
324
263
|
}
|
|
325
264
|
|
|
326
|
-
public async getL1ToL2LeafValue(leafIndex: bigint): Promise<Fr
|
|
265
|
+
public async getL1ToL2LeafValue(leafIndex: bigint): Promise<Fr> {
|
|
327
266
|
const timer = new Timer();
|
|
267
|
+
if (leafIndex > L1_TO_L2_MSG_TREE_LEAF_COUNT) {
|
|
268
|
+
throw new L1ToL2MessageIndexOutOfRangeError(Number(leafIndex));
|
|
269
|
+
}
|
|
328
270
|
const leafValue = await this.db.getLeafValue(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
271
|
+
assert(leafValue !== undefined, 'Unexpected null response from l1 to l2 message tree');
|
|
329
272
|
// TODO: We need this for the hints. See class comment for more details.
|
|
330
273
|
await this.db.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
331
274
|
|
|
@@ -337,9 +280,13 @@ export class PublicTreesDB implements PublicStateDBInterface {
|
|
|
337
280
|
return leafValue;
|
|
338
281
|
}
|
|
339
282
|
|
|
340
|
-
public async getNoteHash(leafIndex: bigint): Promise<Fr
|
|
283
|
+
public async getNoteHash(leafIndex: bigint): Promise<Fr> {
|
|
341
284
|
const timer = new Timer();
|
|
285
|
+
if (leafIndex > NOTE_HASH_TREE_LEAF_COUNT) {
|
|
286
|
+
throw new NoteHashIndexOutOfRangeError(Number(leafIndex));
|
|
287
|
+
}
|
|
342
288
|
const leafValue = await this.db.getLeafValue(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
289
|
+
assert(leafValue !== undefined, 'Unexpected null response from note hash tree');
|
|
343
290
|
// TODO: We need this for the hints. See class comment for more details.
|
|
344
291
|
await this.db.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
345
292
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any known (and checked) error that can be thrown during public execution.
|
|
3
|
+
* Includes AvmExecutionErrors and SideEffectErrors.
|
|
4
|
+
*
|
|
5
|
+
* AvmSimulator catches any checked errors before returning a boolean "reverted".
|
|
6
|
+
* Unchecked errors are generally the result of a bug. They are propagated and
|
|
7
|
+
* ultimately will be the resonsibility of PublicProcessor to handle.
|
|
8
|
+
*/
|
|
9
|
+
export abstract class CheckedPublicExecutionError extends Error {
|
|
10
|
+
constructor(message: string) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'CheckedPublicExecutionError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
2
3
|
import type { IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
3
4
|
import type {
|
|
@@ -11,6 +12,7 @@ import type {
|
|
|
11
12
|
TreeInfo,
|
|
12
13
|
} from '@aztec/stdlib/trees';
|
|
13
14
|
import type { BlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
15
|
+
import type { WorldStateRevision, WorldStateRevisionWithHandle } from '@aztec/stdlib/world-state';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Wraps an instance of `MerkleTreeWriteOperations` to allow the sequencer to gate access.
|
|
@@ -79,6 +81,10 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
79
81
|
close(): Promise<void> {
|
|
80
82
|
return this.guardAndPush(() => this.target.close());
|
|
81
83
|
}
|
|
84
|
+
|
|
85
|
+
async [Symbol.asyncDispose](): Promise<void> {
|
|
86
|
+
await this.close();
|
|
87
|
+
}
|
|
82
88
|
getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo> {
|
|
83
89
|
return this.guardAndPush(() => this.target.getTreeInfo(treeId));
|
|
84
90
|
}
|
|
@@ -88,6 +94,9 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
88
94
|
getInitialHeader(): BlockHeader {
|
|
89
95
|
return this.target.getInitialHeader();
|
|
90
96
|
}
|
|
97
|
+
public getRevision(): WorldStateRevision | WorldStateRevisionWithHandle {
|
|
98
|
+
return this.target.getRevision();
|
|
99
|
+
}
|
|
91
100
|
getSiblingPath<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<SiblingPath<TreeHeights[ID]>> {
|
|
92
101
|
return this.guardAndPush(() => this.target.getSiblingPath(treeId, index));
|
|
93
102
|
}
|
|
@@ -122,7 +131,7 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
122
131
|
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(
|
|
123
132
|
treeId: ID,
|
|
124
133
|
leafIndices: bigint[],
|
|
125
|
-
): Promise<(
|
|
134
|
+
): Promise<(BlockNumber | undefined)[]> {
|
|
126
135
|
return this.guardAndPush(() => this.target.getBlockNumbersForLeafIndices(treeId, leafIndices));
|
|
127
136
|
}
|
|
128
137
|
createCheckpoint(): Promise<void> {
|