@aztec/simulator 0.0.0-test.1 → 0.0.1-fake-ceab37513c
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 -0
- package/dest/client.d.ts +5 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +4 -2
- package/dest/common/errors.d.ts +4 -7
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +51 -32
- package/dest/common/index.d.ts +0 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +0 -1
- package/dest/private/acvm/acvm.d.ts +11 -5
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +10 -16
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/acvm_types.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.d.ts +17 -18
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +31 -23
- package/dest/private/acvm/index.d.ts +0 -1
- package/dest/private/acvm/index.d.ts.map +1 -1
- package/dest/private/acvm/index.js +0 -1
- package/dest/private/acvm/serialize.d.ts +19 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +53 -0
- package/dest/private/{providers/acvm_native.d.ts → acvm_native.d.ts} +10 -10
- package/dest/private/acvm_native.d.ts.map +1 -0
- package/dest/private/{providers/acvm_native.js → acvm_native.js} +11 -7
- package/dest/private/acvm_wasm.d.ts +15 -0
- package/dest/private/acvm_wasm.d.ts.map +1 -0
- package/dest/private/{providers/acvm_wasm.js → acvm_wasm.js} +22 -19
- package/dest/private/acvm_wasm_with_blobs.d.ts +20 -0
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/acvm_wasm_with_blobs.js +35 -0
- package/dest/private/circuit_recording/circuit_recorder.d.ts +108 -0
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/circuit_recorder.js +209 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +31 -0
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/file_circuit_recorder.js +135 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +5 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -0
- package/dest/private/circuit_recording/memory_circuit_recorder.js +9 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +21 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -0
- package/dest/private/circuit_recording/simulator_recorder_wrapper.js +44 -0
- package/dest/private/circuit_simulator.d.ts +35 -0
- package/dest/private/circuit_simulator.d.ts.map +1 -0
- package/dest/private/circuit_simulator.js +43 -0
- package/dest/private/factory.d.ts +12 -0
- package/dest/private/factory.d.ts.map +1 -0
- package/dest/private/{providers/factory.js → factory.js} +2 -2
- package/dest/public/avm/avm_context.d.ts +5 -5
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +4 -2
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +11 -7
- package/dest/public/avm/avm_execution_environment.d.ts +2 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +4 -2
- package/dest/public/avm/avm_gas.d.ts +4 -20
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +27 -35
- package/dest/public/avm/avm_machine_state.d.ts +2 -0
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +2 -0
- package/dest/public/avm/avm_memory_types.d.ts +98 -87
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_memory_types.js +17 -6
- package/dest/public/avm/avm_simulator.d.ts +4 -5
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +13 -18
- package/dest/public/avm/avm_simulator_interface.d.ts +9 -0
- package/dest/public/avm/avm_simulator_interface.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator_interface.js +3 -0
- package/dest/public/avm/errors.d.ts +1 -16
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +0 -37
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +3 -3
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +10 -11
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +4 -4
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +16 -15
- package/dest/public/avm/fixtures/initializers.d.ts +43 -0
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -0
- package/dest/public/avm/fixtures/initializers.js +42 -0
- package/dest/public/avm/fixtures/utils.d.ts +38 -0
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -0
- package/dest/public/avm/fixtures/utils.js +95 -0
- package/dest/public/avm/index.d.ts +0 -2
- package/dest/public/avm/index.d.ts.map +1 -1
- package/dest/public/avm/index.js +0 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +22 -19
- package/dest/public/avm/opcodes/addressing_mode.d.ts +11 -7
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +48 -27
- package/dest/public/avm/opcodes/arithmetic.d.ts +11 -1
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +16 -2
- package/dest/public/avm/opcodes/bitwise.d.ts +5 -13
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +19 -26
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +3 -3
- package/dest/public/avm/opcodes/contract.d.ts +1 -2
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +9 -10
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +10 -8
- package/dest/public/avm/opcodes/conversion.d.ts +1 -0
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +264 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +12 -12
- package/dest/public/avm/opcodes/external_calls.d.ts +8 -7
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +39 -33
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +6 -6
- package/dest/public/avm/opcodes/instruction.d.ts +14 -10
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +18 -13
- package/dest/public/avm/opcodes/memory.d.ts +4 -4
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +37 -33
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +17 -12
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +7 -5
- package/dest/public/avm/revert_reason.d.ts +18 -0
- package/dest/public/avm/revert_reason.d.ts.map +1 -0
- package/dest/public/avm/revert_reason.js +38 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +2 -6
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +70 -69
- package/dest/public/avm/serialization/instruction_serialization.d.ts +5 -4
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +60 -35
- package/dest/public/avm/test_utils.d.ts +10 -13
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +12 -17
- package/dest/public/db_interfaces.d.ts +56 -0
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +3 -0
- package/dest/public/debug_fn_name.d.ts +5 -0
- package/dest/public/debug_fn_name.d.ts.map +1 -0
- package/dest/public/debug_fn_name.js +9 -0
- package/dest/public/executor_metrics.d.ts +10 -3
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +37 -6
- package/dest/public/executor_metrics_interface.d.ts +9 -0
- package/dest/public/executor_metrics_interface.d.ts.map +1 -0
- package/dest/public/executor_metrics_interface.js +1 -0
- package/dest/public/fixtures/amm_test.d.ts +10 -0
- package/dest/public/fixtures/amm_test.d.ts.map +1 -0
- package/dest/public/fixtures/amm_test.js +213 -0
- package/dest/public/fixtures/bulk_test.d.ts +6 -0
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -0
- package/dest/public/fixtures/bulk_test.js +393 -0
- package/dest/public/fixtures/index.d.ts +6 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +6 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts +9 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
- package/dest/public/fixtures/minimal_public_tx.js +43 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +33 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +90 -70
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.d.ts +6 -6
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.js +31 -10
- package/dest/public/fixtures/token_test.d.ts +8 -0
- package/dest/public/fixtures/token_test.d.ts.map +1 -0
- package/dest/public/fixtures/token_test.js +95 -0
- package/dest/public/fixtures/utils.d.ts +16 -3
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +100 -58
- package/dest/public/hinting_db_sources.d.ts +68 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +294 -0
- package/dest/public/index.d.ts +4 -8
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +4 -7
- package/dest/public/public_db_sources.d.ts +30 -39
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +141 -67
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +47 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
- package/dest/public/public_processor/guarded_merkle_tree.js +105 -0
- package/dest/public/public_processor/public_processor.d.ts +19 -29
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +133 -94
- 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 +1 -1
- package/dest/public/public_tx_simulator/index.d.ts +3 -0
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/index.js +2 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +23 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +52 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +17 -29
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +59 -91
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +27 -42
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +128 -171
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +20 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +39 -0
- package/dest/public/side_effect_trace.d.ts +10 -62
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +43 -108
- package/dest/public/side_effect_trace_interface.d.ts +5 -22
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/state_manager/index.d.ts +2 -0
- package/dest/public/state_manager/index.d.ts.map +1 -0
- package/dest/public/state_manager/index.js +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.d.ts +2 -2
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.js +2 -2
- package/dest/public/{avm/journal → state_manager}/public_storage.d.ts +2 -2
- package/dest/public/state_manager/public_storage.d.ts.map +1 -0
- package/dest/public/{avm/journal/journal.d.ts → state_manager/state_manager.d.ts} +37 -85
- package/dest/public/state_manager/state_manager.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.js +352 -0
- package/dest/public/test_executor_metrics.d.ts +54 -0
- package/dest/public/test_executor_metrics.d.ts.map +1 -0
- package/dest/public/test_executor_metrics.js +306 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +2 -4
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +4 -21
- package/dest/server.d.ts +6 -3
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +5 -2
- package/dest/testing.d.ts +2 -0
- package/dest/testing.d.ts.map +1 -0
- package/dest/testing.js +1 -0
- package/package.json +31 -30
- package/src/client.ts +5 -3
- package/src/common/errors.ts +79 -44
- package/src/common/index.ts +0 -1
- package/src/private/acvm/acvm.ts +17 -32
- package/src/private/acvm/acvm_types.ts +1 -1
- package/src/private/acvm/deserialize.ts +35 -29
- package/src/private/acvm/index.ts +0 -1
- package/src/private/acvm/serialize.ts +63 -0
- package/src/private/{providers/acvm_native.ts → acvm_native.ts} +31 -15
- package/src/private/acvm_wasm.ts +72 -0
- package/src/private/acvm_wasm_with_blobs.ts +54 -0
- package/src/private/circuit_recording/circuit_recorder.ts +260 -0
- package/src/private/circuit_recording/file_circuit_recorder.ts +158 -0
- package/src/private/circuit_recording/memory_circuit_recorder.ts +11 -0
- package/src/private/circuit_recording/simulator_recorder_wrapper.ts +91 -0
- package/src/private/circuit_simulator.ts +90 -0
- package/src/private/{providers/factory.ts → factory.ts} +6 -6
- package/src/public/avm/avm_context.ts +4 -4
- package/src/public/avm/avm_contract_call_result.ts +17 -5
- package/src/public/avm/avm_execution_environment.ts +7 -1
- package/src/public/avm/avm_gas.ts +23 -35
- package/src/public/avm/avm_machine_state.ts +5 -0
- package/src/public/avm/avm_memory_types.ts +19 -6
- package/src/public/avm/avm_simulator.ts +30 -29
- package/src/public/avm/avm_simulator_interface.ts +8 -0
- package/src/public/avm/errors.ts +1 -53
- package/src/public/avm/fixtures/avm_simulation_tester.ts +19 -18
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +15 -14
- package/src/public/avm/fixtures/initializers.ts +103 -0
- package/src/public/avm/fixtures/utils.ts +150 -0
- package/src/public/avm/index.ts +0 -2
- package/src/public/avm/opcodes/accrued_substate.ts +62 -27
- package/src/public/avm/opcodes/addressing_mode.ts +57 -33
- package/src/public/avm/opcodes/arithmetic.ts +24 -2
- package/src/public/avm/opcodes/bitwise.ts +33 -29
- package/src/public/avm/opcodes/comparators.ts +6 -3
- package/src/public/avm/opcodes/contract.ts +10 -7
- package/src/public/avm/opcodes/control_flow.ts +19 -10
- package/src/public/avm/opcodes/conversion.ts +23 -3
- package/src/public/avm/opcodes/ec_add.ts +5 -2
- package/src/public/avm/opcodes/environment_getters.ts +22 -15
- package/src/public/avm/opcodes/external_calls.ts +61 -28
- package/src/public/avm/opcodes/hashing.ts +28 -8
- package/src/public/avm/opcodes/instruction.ts +23 -15
- package/src/public/avm/opcodes/memory.ts +71 -32
- package/src/public/avm/opcodes/misc.ts +24 -16
- package/src/public/avm/opcodes/storage.ts +22 -6
- package/src/public/avm/revert_reason.ts +55 -0
- package/src/public/avm/serialization/buffer_cursor.ts +4 -1
- package/src/public/avm/serialization/bytecode_serialization.ts +72 -74
- package/src/public/avm/serialization/instruction_serialization.ts +63 -34
- package/src/public/avm/test_utils.ts +23 -32
- package/src/public/db_interfaces.ts +61 -0
- package/src/{common → public}/debug_fn_name.ts +7 -7
- package/src/public/executor_metrics.ts +55 -6
- package/src/public/executor_metrics_interface.ts +14 -0
- package/src/public/fixtures/amm_test.ts +331 -0
- package/src/public/fixtures/bulk_test.ts +151 -0
- package/src/public/fixtures/index.ts +6 -0
- package/src/public/fixtures/minimal_public_tx.ts +59 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +154 -113
- package/src/public/{avm/fixtures → fixtures}/simple_contract_data_source.ts +36 -18
- package/src/public/fixtures/token_test.ts +140 -0
- package/src/public/fixtures/utils.ts +141 -68
- package/src/public/hinting_db_sources.ts +500 -0
- package/src/public/index.ts +4 -8
- package/src/public/public_db_sources.ts +179 -96
- package/src/public/public_processor/guarded_merkle_tree.ts +149 -0
- package/src/public/public_processor/public_processor.ts +179 -139
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/index.ts +2 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +106 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +153 -193
- package/src/public/public_tx_simulator/public_tx_simulator.ts +167 -211
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +72 -0
- package/src/public/side_effect_trace.ts +52 -303
- package/src/public/side_effect_trace_interface.ts +4 -58
- package/src/public/state_manager/index.ts +1 -0
- package/src/public/{avm/journal → state_manager}/nullifiers.ts +4 -4
- package/src/public/{avm/journal → state_manager}/public_storage.ts +2 -2
- package/src/public/state_manager/state_manager.ts +512 -0
- package/src/public/test_executor_metrics.ts +395 -0
- package/src/public/utils.ts +5 -21
- package/src/server.ts +6 -3
- package/src/testing.ts +1 -0
- package/dest/common/db_interfaces.d.ts +0 -80
- package/dest/common/db_interfaces.d.ts.map +0 -1
- package/dest/common/db_interfaces.js +0 -1
- package/dest/common/debug_fn_name.d.ts +0 -5
- package/dest/common/debug_fn_name.d.ts.map +0 -1
- package/dest/common/debug_fn_name.js +0 -6
- package/dest/common/message_load_oracle_inputs.d.ts +0 -15
- package/dest/common/message_load_oracle_inputs.d.ts.map +0 -1
- package/dest/common/message_load_oracle_inputs.js +0 -15
- package/dest/private/acvm/oracle/index.d.ts +0 -14
- package/dest/private/acvm/oracle/index.d.ts.map +0 -1
- package/dest/private/acvm/oracle/index.js +0 -2
- package/dest/private/acvm/oracle/oracle.d.ts +0 -49
- package/dest/private/acvm/oracle/oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/oracle.js +0 -263
- package/dest/private/acvm/oracle/typed_oracle.d.ts +0 -83
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/private/acvm/oracle/typed_oracle.js +0 -132
- package/dest/private/execution_data_provider.d.ts +0 -261
- package/dest/private/execution_data_provider.d.ts.map +0 -1
- package/dest/private/execution_data_provider.js +0 -14
- package/dest/private/execution_note_cache.d.ts +0 -93
- package/dest/private/execution_note_cache.d.ts.map +0 -1
- package/dest/private/execution_note_cache.js +0 -180
- package/dest/private/hashed_values_cache.d.ts +0 -28
- package/dest/private/hashed_values_cache.d.ts.map +0 -1
- package/dest/private/hashed_values_cache.js +0 -46
- package/dest/private/index.d.ts +0 -13
- package/dest/private/index.d.ts.map +0 -1
- package/dest/private/index.js +0 -12
- package/dest/private/pick_notes.d.ts +0 -85
- package/dest/private/pick_notes.d.ts.map +0 -1
- package/dest/private/pick_notes.js +0 -51
- package/dest/private/private_execution.d.ts +0 -25
- package/dest/private/private_execution.d.ts.map +0 -1
- package/dest/private/private_execution.js +0 -92
- package/dest/private/private_execution_oracle.d.ts +0 -215
- package/dest/private/private_execution_oracle.d.ts.map +0 -1
- package/dest/private/private_execution_oracle.js +0 -382
- package/dest/private/providers/acvm_native.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm.d.ts +0 -15
- package/dest/private/providers/acvm_wasm.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +0 -19
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +0 -32
- package/dest/private/providers/factory.d.ts +0 -12
- package/dest/private/providers/factory.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.d.ts +0 -19
- package/dest/private/providers/simulation_provider.d.ts.map +0 -1
- package/dest/private/providers/simulation_provider.js +0 -24
- package/dest/private/simulator.d.ts +0 -34
- package/dest/private/simulator.d.ts.map +0 -1
- package/dest/private/simulator.js +0 -76
- package/dest/private/unconstrained_execution.d.ts +0 -10
- package/dest/private/unconstrained_execution.d.ts.map +0 -1
- package/dest/private/unconstrained_execution.js +0 -27
- package/dest/private/unconstrained_execution_oracle.d.ts +0 -161
- package/dest/private/unconstrained_execution_oracle.d.ts.map +0 -1
- package/dest/private/unconstrained_execution_oracle.js +0 -258
- package/dest/public/avm/bytecode_utils.d.ts +0 -5
- package/dest/public/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/public/avm/bytecode_utils.js +0 -17
- package/dest/public/avm/fixtures/index.d.ts +0 -84
- package/dest/public/avm/fixtures/index.d.ts.map +0 -1
- package/dest/public/avm/fixtures/index.js +0 -175
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
- package/dest/public/avm/journal/index.d.ts +0 -2
- package/dest/public/avm/journal/index.d.ts.map +0 -1
- package/dest/public/avm/journal/index.js +0 -1
- package/dest/public/avm/journal/journal.d.ts.map +0 -1
- package/dest/public/avm/journal/journal.js +0 -486
- package/dest/public/avm/journal/nullifiers.d.ts.map +0 -1
- package/dest/public/avm/journal/public_storage.d.ts.map +0 -1
- package/dest/public/execution.d.ts +0 -108
- package/dest/public/execution.d.ts.map +0 -1
- package/dest/public/execution.js +0 -9
- package/dest/test/utils.d.ts +0 -13
- package/dest/test/utils.d.ts.map +0 -1
- package/dest/test/utils.js +0 -22
- package/src/common/db_interfaces.ts +0 -94
- package/src/common/message_load_oracle_inputs.ts +0 -15
- package/src/private/acvm/oracle/index.ts +0 -16
- package/src/private/acvm/oracle/oracle.ts +0 -455
- package/src/private/acvm/oracle/typed_oracle.ts +0 -259
- package/src/private/execution_data_provider.ts +0 -323
- package/src/private/execution_note_cache.ts +0 -217
- package/src/private/hashed_values_cache.ts +0 -55
- package/src/private/index.ts +0 -16
- package/src/private/pick_notes.ts +0 -141
- package/src/private/private_execution.ts +0 -151
- package/src/private/private_execution_oracle.ts +0 -614
- package/src/private/providers/acvm_wasm.ts +0 -63
- package/src/private/providers/acvm_wasm_with_blobs.ts +0 -50
- package/src/private/providers/simulation_provider.ts +0 -45
- package/src/private/simulator.ts +0 -147
- package/src/private/unconstrained_execution.ts +0 -50
- package/src/private/unconstrained_execution_oracle.ts +0 -373
- package/src/public/avm/bytecode_utils.ts +0 -17
- package/src/public/avm/fixtures/index.ts +0 -296
- package/src/public/avm/journal/index.ts +0 -1
- package/src/public/avm/journal/journal.ts +0 -742
- package/src/public/avm/opcodes/.eslintrc.cjs +0 -8
- package/src/public/execution.ts +0 -140
- package/src/test/utils.ts +0 -36
- /package/dest/public/{avm/journal → state_manager}/public_storage.js +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
+
import type { Gas } from '@aztec/stdlib/gas';
|
|
4
|
+
import type { AvmSimulationStats } from '@aztec/stdlib/stats';
|
|
5
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
6
|
+
import { type GlobalVariables, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
7
|
+
|
|
8
|
+
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
9
|
+
import type { ExecutorMetricsInterface } from '../executor_metrics_interface.js';
|
|
10
|
+
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
11
|
+
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
12
|
+
import { PublicTxContext } from './public_tx_context.js';
|
|
13
|
+
import { type ProcessedPhase, type PublicTxResult, PublicTxSimulator } from './public_tx_simulator.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A public tx simulator that tracks miscellaneous simulation metrics without telemetry.
|
|
17
|
+
*/
|
|
18
|
+
export class MeasuredPublicTxSimulator extends PublicTxSimulator {
|
|
19
|
+
constructor(
|
|
20
|
+
merkleTree: MerkleTreeWriteOperations,
|
|
21
|
+
contractsDB: PublicContractsDB,
|
|
22
|
+
globalVariables: GlobalVariables,
|
|
23
|
+
doMerkleOperations: boolean = false,
|
|
24
|
+
skipFeeEnforcement: boolean = false,
|
|
25
|
+
clientInitiatedSimulation: boolean = false,
|
|
26
|
+
protected readonly metrics: ExecutorMetricsInterface,
|
|
27
|
+
) {
|
|
28
|
+
super(merkleTree, contractsDB, globalVariables, doMerkleOperations, skipFeeEnforcement, clientInitiatedSimulation);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
32
|
+
this.metrics.startRecordingTxSimulation(txLabel);
|
|
33
|
+
let avmResult: PublicTxResult | undefined;
|
|
34
|
+
try {
|
|
35
|
+
avmResult = await super.simulate(tx);
|
|
36
|
+
} finally {
|
|
37
|
+
this.metrics.stopRecordingTxSimulation(txLabel, avmResult?.revertCode);
|
|
38
|
+
}
|
|
39
|
+
return avmResult;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected override async insertNonRevertiblesFromPrivate(context: PublicTxContext, tx: Tx) {
|
|
43
|
+
const timer = new Timer();
|
|
44
|
+
await super.insertNonRevertiblesFromPrivate(context, tx);
|
|
45
|
+
this.metrics.recordPrivateEffectsInsertion(timer.us(), 'non-revertible');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected override async insertRevertiblesFromPrivate(context: PublicTxContext, tx: Tx): Promise<boolean> {
|
|
49
|
+
const timer = new Timer();
|
|
50
|
+
const result = await super.insertRevertiblesFromPrivate(context, tx);
|
|
51
|
+
this.metrics.recordPrivateEffectsInsertion(timer.us(), 'revertible');
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected override async simulatePhase(phase: TxExecutionPhase, context: PublicTxContext): Promise<ProcessedPhase> {
|
|
56
|
+
const timer = new Timer();
|
|
57
|
+
const result = await super.simulatePhase(phase, context);
|
|
58
|
+
result.durationMs = timer.ms();
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected override async simulateEnqueuedCallInternal(
|
|
63
|
+
stateManager: PublicPersistableStateManager,
|
|
64
|
+
callRequest: PublicCallRequestWithCalldata,
|
|
65
|
+
allocatedGas: Gas,
|
|
66
|
+
transactionFee: Fr,
|
|
67
|
+
fnName: string,
|
|
68
|
+
): Promise<AvmFinalizedCallResult> {
|
|
69
|
+
const timer = new Timer();
|
|
70
|
+
const result = await super.simulateEnqueuedCallInternal(
|
|
71
|
+
stateManager,
|
|
72
|
+
callRequest,
|
|
73
|
+
allocatedGas,
|
|
74
|
+
transactionFee,
|
|
75
|
+
fnName,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
this.log.verbose(
|
|
79
|
+
result.reverted
|
|
80
|
+
? `Simulation of enqueued public call ${fnName} reverted with reason ${result.revertReason?.message}.`
|
|
81
|
+
: `Simulation of enqueued public call ${fnName} completed successfully.`,
|
|
82
|
+
{
|
|
83
|
+
eventName: 'avm-simulation',
|
|
84
|
+
appCircuitName: fnName,
|
|
85
|
+
duration: timer.ms(),
|
|
86
|
+
} satisfies AvmSimulationStats,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (result.reverted) {
|
|
90
|
+
this.metrics.recordEnqueuedCallSimulationFailure(
|
|
91
|
+
fnName,
|
|
92
|
+
timer.ms(),
|
|
93
|
+
allocatedGas.sub(result.gasLeft).l2Gas,
|
|
94
|
+
result.totalInstructions,
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
this.metrics.recordEnqueuedCallSimulation(
|
|
98
|
+
fnName,
|
|
99
|
+
timer.ms(),
|
|
100
|
+
allocatedGas.sub(result.gasLeft).l2Gas,
|
|
101
|
+
result.totalInstructions,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
MAX_ENQUEUED_CALLS_PER_TX,
|
|
3
3
|
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
4
4
|
MAX_NOTE_HASHES_PER_TX,
|
|
5
5
|
MAX_NULLIFIERS_PER_TX,
|
|
6
|
+
MAX_PUBLIC_LOGS_PER_TX,
|
|
6
7
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
7
|
-
NULLIFIER_SUBTREE_HEIGHT,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
9
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
10
10
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
11
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
12
|
-
import { assertLength } from '@aztec/foundation/serialize';
|
|
13
12
|
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
AvmAccumulatedData,
|
|
14
|
+
AvmAccumulatedDataArrayLengths,
|
|
15
|
+
AvmCircuitPublicInputs,
|
|
17
16
|
PublicDataWrite,
|
|
18
17
|
RevertCode,
|
|
19
18
|
} from '@aztec/stdlib/avm';
|
|
20
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
20
|
import type { SimulationError } from '@aztec/stdlib/errors';
|
|
22
|
-
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
21
|
+
import { computeEffectiveGasFees, computeTransactionFee } from '@aztec/stdlib/fees';
|
|
23
22
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
24
|
-
import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
25
23
|
import {
|
|
26
24
|
PrivateToAvmAccumulatedData,
|
|
27
25
|
PrivateToAvmAccumulatedDataArrayLengths,
|
|
28
|
-
|
|
26
|
+
PrivateToPublicAccumulatedData,
|
|
29
27
|
PublicCallRequest,
|
|
28
|
+
PublicCallRequestArrayLengths,
|
|
30
29
|
countAccumulatedItems,
|
|
31
|
-
mergeAccumulatedData,
|
|
32
30
|
} from '@aztec/stdlib/kernel';
|
|
33
|
-
import {
|
|
31
|
+
import { PublicLog } from '@aztec/stdlib/logs';
|
|
32
|
+
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
34
33
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
35
34
|
import {
|
|
36
35
|
type GlobalVariables,
|
|
37
|
-
|
|
38
|
-
type StateReference,
|
|
36
|
+
PublicCallRequestWithCalldata,
|
|
39
37
|
TreeSnapshots,
|
|
40
38
|
type Tx,
|
|
41
39
|
TxExecutionPhase,
|
|
@@ -45,10 +43,11 @@ import {
|
|
|
45
43
|
import { strict as assert } from 'assert';
|
|
46
44
|
import { inspect } from 'util';
|
|
47
45
|
|
|
48
|
-
import {
|
|
49
|
-
import type {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
46
|
+
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
47
|
+
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
48
|
+
import { SideEffectTrace } from '../side_effect_trace.js';
|
|
49
|
+
import { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
50
|
+
import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
53
|
* The transaction-level context for public execution.
|
|
@@ -67,75 +66,66 @@ export class PublicTxContext {
|
|
|
67
66
|
private revertCode: RevertCode = RevertCode.OK;
|
|
68
67
|
/* What caused a revert (if one occurred)? */
|
|
69
68
|
public revertReason: SimulationError | undefined;
|
|
70
|
-
|
|
71
|
-
public avmProvingRequest: AvmProvingRequest | undefined; // FIXME(dbanks12): remove
|
|
72
|
-
|
|
73
|
-
constructor(
|
|
69
|
+
private constructor(
|
|
74
70
|
public readonly txHash: TxHash,
|
|
75
71
|
public readonly state: PhaseStateManager,
|
|
72
|
+
private readonly startTreeSnapshots: TreeSnapshots,
|
|
76
73
|
private readonly globalVariables: GlobalVariables,
|
|
77
|
-
private readonly startStateReference: StateReference,
|
|
78
74
|
private readonly gasSettings: GasSettings,
|
|
79
75
|
private readonly gasUsedByPrivate: Gas,
|
|
80
76
|
private readonly gasAllocatedToPublic: Gas,
|
|
81
|
-
private readonly
|
|
82
|
-
private readonly
|
|
83
|
-
private readonly
|
|
84
|
-
private readonly
|
|
85
|
-
private readonly appLogicExecutionRequests: PublicExecutionRequest[],
|
|
86
|
-
private readonly teardownExecutionRequests: PublicExecutionRequest[],
|
|
77
|
+
private readonly gasAllocatedToPublicTeardown: Gas,
|
|
78
|
+
private readonly setupCallRequests: PublicCallRequestWithCalldata[],
|
|
79
|
+
private readonly appLogicCallRequests: PublicCallRequestWithCalldata[],
|
|
80
|
+
private readonly teardownCallRequests: PublicCallRequestWithCalldata[],
|
|
87
81
|
public readonly nonRevertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
|
|
88
82
|
public readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
|
|
89
83
|
public readonly feePayer: AztecAddress,
|
|
90
|
-
|
|
84
|
+
private readonly trace: SideEffectTrace,
|
|
91
85
|
) {
|
|
92
86
|
this.log = createLogger(`simulator:public_tx_context`);
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
public static async create(
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
treesDB: PublicTreesDB,
|
|
91
|
+
contractsDB: PublicContractsDBInterface,
|
|
98
92
|
tx: Tx,
|
|
99
93
|
globalVariables: GlobalVariables,
|
|
100
94
|
doMerkleOperations: boolean,
|
|
101
95
|
) {
|
|
102
96
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic!.nonRevertibleAccumulatedData;
|
|
103
97
|
|
|
104
|
-
const
|
|
105
|
-
/*publicDataWrites*/ 0,
|
|
106
|
-
/*protocolPublicDataWrites*/ 0,
|
|
107
|
-
/*noteHashes*/ 0,
|
|
108
|
-
/*nullifiers=*/ 0,
|
|
109
|
-
countAccumulatedItems(nonRevertibleAccumulatedDataFromPrivate.l2ToL1Msgs),
|
|
110
|
-
/*publicLogs*/ 0,
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
const trace = new SideEffectTrace(/*startSideEffectCounter=*/ 0, previousAccumulatedDataArrayLengths);
|
|
98
|
+
const trace = new SideEffectTrace();
|
|
114
99
|
|
|
115
100
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
116
101
|
|
|
117
102
|
// Transaction level state manager that will be forked for revertible phases.
|
|
118
|
-
const txStateManager =
|
|
103
|
+
const txStateManager = PublicPersistableStateManager.create(
|
|
104
|
+
treesDB,
|
|
105
|
+
contractsDB,
|
|
106
|
+
trace,
|
|
107
|
+
doMerkleOperations,
|
|
108
|
+
firstNullifier,
|
|
109
|
+
globalVariables.timestamp,
|
|
110
|
+
);
|
|
119
111
|
|
|
120
112
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
121
113
|
const gasUsedByPrivate = tx.data.gasUsed;
|
|
122
|
-
|
|
123
|
-
const
|
|
114
|
+
const gasAllocatedToPublic = gasSettings.gasLimits.sub(gasUsedByPrivate);
|
|
115
|
+
const gasAllocatedToPublicTeardown = gasSettings.teardownGasLimits;
|
|
124
116
|
|
|
125
117
|
return new PublicTxContext(
|
|
126
|
-
|
|
118
|
+
tx.getTxHash(),
|
|
127
119
|
new PhaseStateManager(txStateManager),
|
|
120
|
+
await txStateManager.getTreeSnapshots(),
|
|
128
121
|
globalVariables,
|
|
129
|
-
await db.getStateReference(),
|
|
130
122
|
gasSettings,
|
|
131
123
|
gasUsedByPrivate,
|
|
132
124
|
gasAllocatedToPublic,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
getExecutionRequestsByPhase(tx, TxExecutionPhase.APP_LOGIC),
|
|
138
|
-
getExecutionRequestsByPhase(tx, TxExecutionPhase.TEARDOWN),
|
|
125
|
+
gasAllocatedToPublicTeardown,
|
|
126
|
+
getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.SETUP),
|
|
127
|
+
getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.APP_LOGIC),
|
|
128
|
+
getCallRequestsWithCalldataByPhase(tx, TxExecutionPhase.TEARDOWN),
|
|
139
129
|
tx.data.forPublic!.nonRevertibleAccumulatedData,
|
|
140
130
|
tx.data.forPublic!.revertibleAccumulatedData,
|
|
141
131
|
tx.data.feePayer,
|
|
@@ -148,10 +138,8 @@ export class PublicTxContext {
|
|
|
148
138
|
* All phases have been processed.
|
|
149
139
|
* Actual transaction fee and actual total consumed gas can now be queried.
|
|
150
140
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
await this.state.mergeForkedState();
|
|
154
|
-
}
|
|
141
|
+
halt() {
|
|
142
|
+
assert(!this.state.isForked(), 'Cannot halt when state is forked');
|
|
155
143
|
this.halted = true;
|
|
156
144
|
}
|
|
157
145
|
|
|
@@ -161,7 +149,7 @@ export class PublicTxContext {
|
|
|
161
149
|
* NOTE: this does not "halt" the entire transaction execution.
|
|
162
150
|
*/
|
|
163
151
|
revert(phase: TxExecutionPhase, revertReason: SimulationError | undefined = undefined, culprit = '') {
|
|
164
|
-
this.log.warn(`${TxExecutionPhase[phase]} phase reverted! ${culprit} failed with reason: ${revertReason}`);
|
|
152
|
+
this.log.warn(`${TxExecutionPhase[phase]} phase reverted! ${culprit} failed with reason: ${revertReason?.message}`);
|
|
165
153
|
|
|
166
154
|
if (revertReason && !this.revertReason) {
|
|
167
155
|
// don't override revertReason
|
|
@@ -170,11 +158,6 @@ export class PublicTxContext {
|
|
|
170
158
|
}
|
|
171
159
|
if (phase === TxExecutionPhase.SETUP) {
|
|
172
160
|
this.log.warn(`Setup phase reverted! The transaction will be thrown out.`);
|
|
173
|
-
if (revertReason) {
|
|
174
|
-
throw revertReason;
|
|
175
|
-
} else {
|
|
176
|
-
throw new Error(`Setup phase reverted! The transaction will be thrown out. ${culprit} failed`);
|
|
177
|
-
}
|
|
178
161
|
} else if (phase === TxExecutionPhase.APP_LOGIC) {
|
|
179
162
|
this.revertCode = RevertCode.APP_LOGIC_REVERTED;
|
|
180
163
|
} else if (phase === TxExecutionPhase.TEARDOWN) {
|
|
@@ -212,7 +195,7 @@ export class PublicTxContext {
|
|
|
212
195
|
/**
|
|
213
196
|
* Get the call requests for the specified phase (including args hashes).
|
|
214
197
|
*/
|
|
215
|
-
getCallRequestsForPhase(phase: TxExecutionPhase):
|
|
198
|
+
getCallRequestsForPhase(phase: TxExecutionPhase): PublicCallRequestWithCalldata[] {
|
|
216
199
|
switch (phase) {
|
|
217
200
|
case TxExecutionPhase.SETUP:
|
|
218
201
|
return this.setupCallRequests;
|
|
@@ -223,26 +206,13 @@ export class PublicTxContext {
|
|
|
223
206
|
}
|
|
224
207
|
}
|
|
225
208
|
|
|
226
|
-
/**
|
|
227
|
-
* Get the call requests for the specified phase (including actual args).
|
|
228
|
-
*/
|
|
229
|
-
getExecutionRequestsForPhase(phase: TxExecutionPhase): PublicExecutionRequest[] {
|
|
230
|
-
switch (phase) {
|
|
231
|
-
case TxExecutionPhase.SETUP:
|
|
232
|
-
return this.setupExecutionRequests;
|
|
233
|
-
case TxExecutionPhase.APP_LOGIC:
|
|
234
|
-
return this.appLogicExecutionRequests;
|
|
235
|
-
case TxExecutionPhase.TEARDOWN:
|
|
236
|
-
return this.teardownExecutionRequests;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
209
|
/**
|
|
241
210
|
* How much gas is left as of the specified phase?
|
|
242
211
|
*/
|
|
243
212
|
getGasLeftAtPhase(phase: TxExecutionPhase): Gas {
|
|
244
213
|
if (phase === TxExecutionPhase.TEARDOWN) {
|
|
245
|
-
|
|
214
|
+
const gasLeftForPublicTeardown = this.gasAllocatedToPublicTeardown.sub(this.teardownGasUsed);
|
|
215
|
+
return gasLeftForPublicTeardown;
|
|
246
216
|
} else {
|
|
247
217
|
const gasLeftForPublic = this.gasAllocatedToPublic.sub(this.gasUsedByPublic);
|
|
248
218
|
return gasLeftForPublic;
|
|
@@ -322,124 +292,124 @@ export class PublicTxContext {
|
|
|
322
292
|
/**
|
|
323
293
|
* Generate the public inputs for the AVM circuit.
|
|
324
294
|
*/
|
|
325
|
-
|
|
295
|
+
public async generateAvmCircuitPublicInputs(): Promise<AvmCircuitPublicInputs> {
|
|
326
296
|
assert(this.halted, 'Can only get AvmCircuitPublicInputs after tx execution ends');
|
|
327
297
|
const stateManager = this.state.getActiveStateManager();
|
|
328
298
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
299
|
+
// We get the side effects from the AVM.
|
|
300
|
+
// The AVM will already have handled the conditional insertion of most private side-effects.
|
|
301
|
+
// (depending on the revert code of each stage). Only l2ToL1Msgs and publicLogs still need to be "merged".
|
|
302
|
+
const {
|
|
303
|
+
publicDataWrites: avmPublicDataWrites,
|
|
304
|
+
noteHashes: avmNoteHashes,
|
|
305
|
+
nullifiers: avmNullifiers,
|
|
306
|
+
l2ToL1Msgs: avmL2ToL1Msgs,
|
|
307
|
+
publicLogs: avmPublicLogs,
|
|
308
|
+
} = this.trace.getSideEffects();
|
|
309
|
+
|
|
310
|
+
// Private generates PrivateLogs, and public execution generates PublicLogs.
|
|
311
|
+
// Since these are two different categories, they should not be merged.
|
|
312
|
+
const finalPublicLogs = avmPublicLogs;
|
|
313
|
+
|
|
314
|
+
// We squash public data writes.
|
|
315
|
+
// Maps slot to value. Maps in TS are iterable in insertion order, which is exactly what we want for
|
|
316
|
+
// squashing "to the left", where the first occurrence of a slot uses the value of the last write to it,
|
|
317
|
+
// and the rest occurrences are omitted.
|
|
318
|
+
// Note: you can't write public state from private, so we only squash what we got from the AVM.
|
|
319
|
+
const finalPublicDataWrites = (() => {
|
|
320
|
+
const squashedPublicDataWrites: Map<bigint, Fr> = new Map();
|
|
321
|
+
for (const publicDataWrite of avmPublicDataWrites) {
|
|
322
|
+
squashedPublicDataWrites.set(publicDataWrite.leafSlot.toBigInt(), publicDataWrite.newValue);
|
|
323
|
+
}
|
|
324
|
+
return Array.from(squashedPublicDataWrites.entries()).map(
|
|
325
|
+
([slot, value]) => new PublicDataWrite(new Fr(slot), value),
|
|
326
|
+
);
|
|
327
|
+
})();
|
|
328
|
+
|
|
329
|
+
// Count before padding.
|
|
330
|
+
const accumulatedDataArrayLengths = new AvmAccumulatedDataArrayLengths(
|
|
331
|
+
avmNoteHashes.length,
|
|
332
|
+
avmNullifiers.length,
|
|
333
|
+
avmL2ToL1Msgs.length,
|
|
334
|
+
finalPublicLogs.length,
|
|
335
|
+
finalPublicDataWrites.length,
|
|
334
336
|
);
|
|
335
337
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
338
|
+
const accumulatedData = new AvmAccumulatedData(
|
|
339
|
+
/*noteHashes=*/ padArrayEnd(
|
|
340
|
+
avmNoteHashes.map(n => n.value),
|
|
341
|
+
Fr.zero(),
|
|
342
|
+
MAX_NOTE_HASHES_PER_TX,
|
|
343
|
+
),
|
|
344
|
+
/*nullifiers=*/ padArrayEnd(
|
|
345
|
+
avmNullifiers.map(n => n.value),
|
|
346
|
+
Fr.zero(),
|
|
347
|
+
MAX_NULLIFIERS_PER_TX,
|
|
348
|
+
),
|
|
349
|
+
/*l2ToL1Msgs=*/ padArrayEnd(avmL2ToL1Msgs, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
|
|
350
|
+
/*publicLogs=*/ padArrayEnd(finalPublicLogs, PublicLog.empty(), MAX_PUBLIC_LOGS_PER_TX),
|
|
351
|
+
/*publicDataWrites=*/ padArrayEnd(
|
|
352
|
+
finalPublicDataWrites,
|
|
353
|
+
PublicDataWrite.empty(),
|
|
354
|
+
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
355
|
+
),
|
|
342
356
|
);
|
|
343
357
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
/*teardownCallRequest=*/ this.teardownCallRequests.length
|
|
353
|
-
? this.teardownCallRequests[0]
|
|
354
|
-
: PublicCallRequest.empty(),
|
|
355
|
-
endTreeSnapshots,
|
|
356
|
-
/*endGasUsed=*/ this.getTotalGasUsed(),
|
|
357
|
-
/*transactionFee=*/ this.getTransactionFeeUnsafe(),
|
|
358
|
-
/*reverted=*/ !this.revertCode.isOK(),
|
|
359
|
-
);
|
|
358
|
+
// Now we finally have enough information to pad the trees.
|
|
359
|
+
// NOTE(fcarreiro): a bit weird that a method that generates the PIs does this,
|
|
360
|
+
// but we do need the end tree snapshots. We can consider moving things to the caller.
|
|
361
|
+
const numNoteHashesToPad = MAX_NOTE_HASHES_PER_TX - avmNoteHashes.length;
|
|
362
|
+
const numNullifiersToPad = MAX_NULLIFIERS_PER_TX - avmNullifiers.length;
|
|
363
|
+
await stateManager.padTree(MerkleTreeId.NOTE_HASH_TREE, numNoteHashesToPad);
|
|
364
|
+
await stateManager.padTree(MerkleTreeId.NULLIFIER_TREE, numNullifiersToPad);
|
|
365
|
+
const endTreeSnapshots = await stateManager.getTreeSnapshots();
|
|
360
366
|
|
|
361
|
-
|
|
367
|
+
// This converts the private accumulated data to the avm accumulated data format.
|
|
368
|
+
const convertAccumulatedData = (from: PrivateToPublicAccumulatedData) =>
|
|
369
|
+
new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs);
|
|
370
|
+
const getPreviousAccumulatedDataArrayLengths = (from: PrivateToPublicAccumulatedData) =>
|
|
362
371
|
new PrivateToAvmAccumulatedDataArrayLengths(
|
|
363
372
|
countAccumulatedItems(from.noteHashes),
|
|
364
373
|
countAccumulatedItems(from.nullifiers),
|
|
365
374
|
countAccumulatedItems(from.l2ToL1Msgs),
|
|
366
375
|
);
|
|
367
|
-
const convertAccumulatedData = (from: PrivateToPublicAccumulatedData) =>
|
|
368
|
-
new PrivateToAvmAccumulatedData(from.noteHashes, from.nullifiers, from.l2ToL1Msgs);
|
|
369
|
-
// Temporary overrides as these entries aren't yet populated in trace
|
|
370
|
-
avmCircuitPublicInputs.previousNonRevertibleAccumulatedDataArrayLengths = getArrayLengths(
|
|
371
|
-
this.nonRevertibleAccumulatedDataFromPrivate,
|
|
372
|
-
);
|
|
373
|
-
avmCircuitPublicInputs.previousRevertibleAccumulatedDataArrayLengths = getArrayLengths(
|
|
374
|
-
this.revertibleAccumulatedDataFromPrivate,
|
|
375
|
-
);
|
|
376
|
-
avmCircuitPublicInputs.previousNonRevertibleAccumulatedData = convertAccumulatedData(
|
|
377
|
-
this.nonRevertibleAccumulatedDataFromPrivate,
|
|
378
|
-
);
|
|
379
|
-
avmCircuitPublicInputs.previousRevertibleAccumulatedData = convertAccumulatedData(
|
|
380
|
-
this.revertibleAccumulatedDataFromPrivate,
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
const msgsFromPrivate = this.revertCode.isOK()
|
|
384
|
-
? mergeAccumulatedData(
|
|
385
|
-
avmCircuitPublicInputs.previousNonRevertibleAccumulatedData.l2ToL1Msgs,
|
|
386
|
-
avmCircuitPublicInputs.previousRevertibleAccumulatedData.l2ToL1Msgs,
|
|
387
|
-
)
|
|
388
|
-
: avmCircuitPublicInputs.previousNonRevertibleAccumulatedData.l2ToL1Msgs;
|
|
389
|
-
avmCircuitPublicInputs.accumulatedData.l2ToL1Msgs = assertLength(
|
|
390
|
-
mergeAccumulatedData(msgsFromPrivate, avmCircuitPublicInputs.accumulatedData.l2ToL1Msgs),
|
|
391
|
-
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
// Maps slot to value. Maps in TS are iterable in insertion order, which is exactly what we want for
|
|
395
|
-
// squashing "to the left", where the first occurrence of a slot uses the value of the last write to it,
|
|
396
|
-
// and the rest occurrences are omitted
|
|
397
|
-
const squashedPublicDataWrites: Map<bigint, Fr> = new Map();
|
|
398
|
-
for (const publicDataWrite of avmCircuitPublicInputs.accumulatedData.publicDataWrites) {
|
|
399
|
-
squashedPublicDataWrites.set(publicDataWrite.leafSlot.toBigInt(), publicDataWrite.value);
|
|
400
|
-
}
|
|
401
376
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
padArrayEnd(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
paddedState.partial.publicDataTree,
|
|
424
|
-
);
|
|
425
|
-
|
|
426
|
-
return avmCircuitPublicInputs;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Generate the proving request for the AVM circuit.
|
|
431
|
-
*/
|
|
432
|
-
async generateProvingRequest(endStateReference: StateReference): Promise<AvmProvingRequest> {
|
|
433
|
-
const hints = this.trace.getAvmCircuitHints();
|
|
434
|
-
return {
|
|
435
|
-
type: ProvingRequestType.PUBLIC_VM,
|
|
436
|
-
inputs: new AvmCircuitInputs(
|
|
437
|
-
'public_dispatch',
|
|
438
|
-
[],
|
|
439
|
-
hints,
|
|
440
|
-
await this.generateAvmCircuitPublicInputs(endStateReference),
|
|
377
|
+
return new AvmCircuitPublicInputs(
|
|
378
|
+
this.globalVariables,
|
|
379
|
+
this.startTreeSnapshots,
|
|
380
|
+
/*startGasUsed=*/ this.gasUsedByPrivate,
|
|
381
|
+
this.gasSettings,
|
|
382
|
+
computeEffectiveGasFees(this.globalVariables.gasFees, this.gasSettings),
|
|
383
|
+
this.feePayer,
|
|
384
|
+
/*publicCallRequestArrayLengths=*/ new PublicCallRequestArrayLengths(
|
|
385
|
+
this.setupCallRequests.length,
|
|
386
|
+
this.appLogicCallRequests.length,
|
|
387
|
+
this.teardownCallRequests.length > 0,
|
|
388
|
+
),
|
|
389
|
+
/*publicSetupCallRequests=*/ padArrayEnd(
|
|
390
|
+
this.setupCallRequests.map(r => r.request),
|
|
391
|
+
PublicCallRequest.empty(),
|
|
392
|
+
MAX_ENQUEUED_CALLS_PER_TX,
|
|
393
|
+
),
|
|
394
|
+
/*publicAppLogicCallRequests=*/ padArrayEnd(
|
|
395
|
+
this.appLogicCallRequests.map(r => r.request),
|
|
396
|
+
PublicCallRequest.empty(),
|
|
397
|
+
MAX_ENQUEUED_CALLS_PER_TX,
|
|
441
398
|
),
|
|
442
|
-
|
|
399
|
+
/*publicTeardownCallRequests=*/ this.teardownCallRequests.length > 0
|
|
400
|
+
? this.teardownCallRequests[0].request
|
|
401
|
+
: PublicCallRequest.empty(),
|
|
402
|
+
getPreviousAccumulatedDataArrayLengths(this.nonRevertibleAccumulatedDataFromPrivate),
|
|
403
|
+
getPreviousAccumulatedDataArrayLengths(this.revertibleAccumulatedDataFromPrivate),
|
|
404
|
+
convertAccumulatedData(this.nonRevertibleAccumulatedDataFromPrivate),
|
|
405
|
+
convertAccumulatedData(this.revertibleAccumulatedDataFromPrivate),
|
|
406
|
+
endTreeSnapshots,
|
|
407
|
+
this.getTotalGasUsed(),
|
|
408
|
+
accumulatedDataArrayLengths,
|
|
409
|
+
accumulatedData,
|
|
410
|
+
/*transactionFee=*/ this.getTransactionFeeUnsafe(),
|
|
411
|
+
/*isReverted=*/ !this.revertCode.isOK(),
|
|
412
|
+
);
|
|
443
413
|
}
|
|
444
414
|
}
|
|
445
415
|
|
|
@@ -456,9 +426,9 @@ export class PublicTxContext {
|
|
|
456
426
|
class PhaseStateManager {
|
|
457
427
|
private log: Logger;
|
|
458
428
|
|
|
459
|
-
private currentlyActiveStateManager:
|
|
429
|
+
private currentlyActiveStateManager: PublicPersistableStateManager | undefined;
|
|
460
430
|
|
|
461
|
-
constructor(private readonly txStateManager:
|
|
431
|
+
constructor(private readonly txStateManager: PublicPersistableStateManager) {
|
|
462
432
|
this.log = createLogger(`simulator:public_phase_state_manager`);
|
|
463
433
|
}
|
|
464
434
|
|
|
@@ -492,13 +462,3 @@ class PhaseStateManager {
|
|
|
492
462
|
this.currentlyActiveStateManager = undefined;
|
|
493
463
|
}
|
|
494
464
|
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Apply L2 gas maximum.
|
|
498
|
-
*/
|
|
499
|
-
function applyMaxToAvailableGas(availableGas: Gas) {
|
|
500
|
-
return new Gas(
|
|
501
|
-
/*daGas=*/ availableGas.daGas,
|
|
502
|
-
/*l2Gas=*/ Math.min(availableGas.l2Gas, MAX_L2_GAS_PER_TX_PUBLIC_PORTION),
|
|
503
|
-
);
|
|
504
|
-
}
|