@aztec/simulator 0.0.0-test.0
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 +49 -0
- package/dest/client.d.ts +5 -0
- package/dest/client.d.ts.map +1 -0
- package/dest/client.js +3 -0
- package/dest/common/db_interfaces.d.ts +80 -0
- package/dest/common/db_interfaces.d.ts.map +1 -0
- package/dest/common/db_interfaces.js +1 -0
- package/dest/common/debug_fn_name.d.ts +5 -0
- package/dest/common/debug_fn_name.d.ts.map +1 -0
- package/dest/common/debug_fn_name.js +6 -0
- package/dest/common/errors.d.ts +54 -0
- package/dest/common/errors.d.ts.map +1 -0
- package/dest/common/errors.js +135 -0
- package/dest/common/index.d.ts +4 -0
- package/dest/common/index.d.ts.map +1 -0
- package/dest/common/index.js +3 -0
- package/dest/common/message_load_oracle_inputs.d.ts +15 -0
- package/dest/common/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/common/message_load_oracle_inputs.js +15 -0
- package/dest/common/stats/index.d.ts +2 -0
- package/dest/common/stats/index.d.ts.map +1 -0
- package/dest/common/stats/index.js +1 -0
- package/dest/common/stats/stats.d.ts +4 -0
- package/dest/common/stats/stats.d.ts.map +1 -0
- package/dest/common/stats/stats.js +10 -0
- package/dest/private/acvm/acvm.d.ts +35 -0
- package/dest/private/acvm/acvm.d.ts.map +1 -0
- package/dest/private/acvm/acvm.js +70 -0
- package/dest/private/acvm/acvm_types.d.ts +10 -0
- package/dest/private/acvm/acvm_types.d.ts.map +1 -0
- package/dest/private/acvm/acvm_types.js +3 -0
- package/dest/private/acvm/deserialize.d.ts +36 -0
- package/dest/private/acvm/deserialize.d.ts.map +1 -0
- package/dest/private/acvm/deserialize.js +42 -0
- package/dest/private/acvm/index.d.ts +6 -0
- package/dest/private/acvm/index.d.ts.map +1 -0
- package/dest/private/acvm/index.js +5 -0
- package/dest/private/acvm/oracle/index.d.ts +14 -0
- package/dest/private/acvm/oracle/index.d.ts.map +1 -0
- package/dest/private/acvm/oracle/index.js +2 -0
- package/dest/private/acvm/oracle/oracle.d.ts +49 -0
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -0
- package/dest/private/acvm/oracle/oracle.js +263 -0
- package/dest/private/acvm/oracle/typed_oracle.d.ts +83 -0
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -0
- package/dest/private/acvm/oracle/typed_oracle.js +132 -0
- package/dest/private/acvm/serialize.d.ts +24 -0
- package/dest/private/acvm/serialize.d.ts.map +1 -0
- package/dest/private/acvm/serialize.js +46 -0
- package/dest/private/execution_data_provider.d.ts +261 -0
- package/dest/private/execution_data_provider.d.ts.map +1 -0
- package/dest/private/execution_data_provider.js +14 -0
- package/dest/private/execution_note_cache.d.ts +93 -0
- package/dest/private/execution_note_cache.d.ts.map +1 -0
- package/dest/private/execution_note_cache.js +180 -0
- package/dest/private/hashed_values_cache.d.ts +28 -0
- package/dest/private/hashed_values_cache.d.ts.map +1 -0
- package/dest/private/hashed_values_cache.js +46 -0
- package/dest/private/index.d.ts +13 -0
- package/dest/private/index.d.ts.map +1 -0
- package/dest/private/index.js +12 -0
- package/dest/private/pick_notes.d.ts +85 -0
- package/dest/private/pick_notes.d.ts.map +1 -0
- package/dest/private/pick_notes.js +51 -0
- package/dest/private/private_execution.d.ts +25 -0
- package/dest/private/private_execution.d.ts.map +1 -0
- package/dest/private/private_execution.js +92 -0
- package/dest/private/private_execution_oracle.d.ts +215 -0
- package/dest/private/private_execution_oracle.d.ts.map +1 -0
- package/dest/private/private_execution_oracle.js +382 -0
- package/dest/private/providers/acvm_native.d.ts +40 -0
- package/dest/private/providers/acvm_native.d.ts.map +1 -0
- package/dest/private/providers/acvm_native.js +139 -0
- package/dest/private/providers/acvm_wasm.d.ts +15 -0
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -0
- package/dest/private/providers/acvm_wasm.js +62 -0
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +19 -0
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/private/providers/acvm_wasm_with_blobs.js +32 -0
- package/dest/private/providers/factory.d.ts +12 -0
- package/dest/private/providers/factory.d.ts.map +1 -0
- package/dest/private/providers/factory.js +27 -0
- package/dest/private/providers/simulation_provider.d.ts +19 -0
- package/dest/private/providers/simulation_provider.d.ts.map +1 -0
- package/dest/private/providers/simulation_provider.js +24 -0
- package/dest/private/simulator.d.ts +34 -0
- package/dest/private/simulator.d.ts.map +1 -0
- package/dest/private/simulator.js +76 -0
- package/dest/private/unconstrained_execution.d.ts +10 -0
- package/dest/private/unconstrained_execution.d.ts.map +1 -0
- package/dest/private/unconstrained_execution.js +27 -0
- package/dest/private/unconstrained_execution_oracle.d.ts +161 -0
- package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -0
- package/dest/private/unconstrained_execution_oracle.js +258 -0
- package/dest/public/avm/avm_context.d.ts +41 -0
- package/dest/public/avm/avm_context.d.ts.map +1 -0
- package/dest/public/avm/avm_context.js +44 -0
- package/dest/public/avm/avm_contract_call_result.d.ts +30 -0
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -0
- package/dest/public/avm/avm_contract_call_result.js +50 -0
- package/dest/public/avm/avm_execution_environment.d.ts +21 -0
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -0
- package/dest/public/avm/avm_execution_environment.js +31 -0
- package/dest/public/avm/avm_gas.d.ts +60 -0
- package/dest/public/avm/avm_gas.d.ts.map +1 -0
- package/dest/public/avm/avm_gas.js +203 -0
- package/dest/public/avm/avm_machine_state.d.ts +95 -0
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -0
- package/dest/public/avm/avm_machine_state.js +107 -0
- package/dest/public/avm/avm_memory_types.d.ts +264 -0
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -0
- package/dest/public/avm/avm_memory_types.js +340 -0
- package/dest/public/avm/avm_simulator.d.ts +40 -0
- package/dest/public/avm/avm_simulator.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator.js +202 -0
- package/dest/public/avm/bytecode_utils.d.ts +5 -0
- package/dest/public/avm/bytecode_utils.d.ts.map +1 -0
- package/dest/public/avm/bytecode_utils.js +17 -0
- package/dest/public/avm/errors.d.ts +122 -0
- package/dest/public/avm/errors.d.ts.map +1 -0
- package/dest/public/avm/errors.js +179 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +21 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.js +76 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +36 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +83 -0
- package/dest/public/avm/fixtures/index.d.ts +84 -0
- package/dest/public/avm/fixtures/index.d.ts.map +1 -0
- package/dest/public/avm/fixtures/index.js +175 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +35 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.js +74 -0
- package/dest/public/avm/index.d.ts +4 -0
- package/dest/public/avm/index.d.ts.map +1 -0
- package/dest/public/avm/index.js +3 -0
- package/dest/public/avm/journal/index.d.ts +2 -0
- package/dest/public/avm/journal/index.d.ts.map +1 -0
- package/dest/public/avm/journal/index.js +1 -0
- package/dest/public/avm/journal/journal.d.ts +209 -0
- package/dest/public/avm/journal/journal.d.ts.map +1 -0
- package/dest/public/avm/journal/journal.js +486 -0
- package/dest/public/avm/journal/nullifiers.d.ts +64 -0
- package/dest/public/avm/journal/nullifiers.d.ts.map +1 -0
- package/dest/public/avm/journal/nullifiers.js +97 -0
- package/dest/public/avm/journal/public_storage.d.ts +66 -0
- package/dest/public/avm/journal/public_storage.d.ts.map +1 -0
- package/dest/public/avm/journal/public_storage.js +145 -0
- package/dest/public/avm/opcodes/accrued_substate.d.ts +75 -0
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -0
- package/dest/public/avm/opcodes/accrued_substate.js +252 -0
- package/dest/public/avm/opcodes/addressing_mode.d.ts +27 -0
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -0
- package/dest/public/avm/opcodes/addressing_mode.js +74 -0
- package/dest/public/avm/opcodes/arithmetic.d.ts +37 -0
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -0
- package/dest/public/avm/opcodes/arithmetic.js +73 -0
- package/dest/public/avm/opcodes/bitwise.d.ts +50 -0
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -0
- package/dest/public/avm/opcodes/bitwise.js +106 -0
- package/dest/public/avm/opcodes/comparators.d.ts +25 -0
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -0
- package/dest/public/avm/opcodes/comparators.js +43 -0
- package/dest/public/avm/opcodes/contract.d.ts +21 -0
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -0
- package/dest/public/avm/opcodes/contract.js +66 -0
- package/dest/public/avm/opcodes/control_flow.d.ts +41 -0
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -0
- package/dest/public/avm/opcodes/control_flow.js +105 -0
- package/dest/public/avm/opcodes/conversion.d.ts +17 -0
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -0
- package/dest/public/avm/opcodes/conversion.js +69 -0
- package/dest/public/avm/opcodes/ec_add.d.ts +19 -0
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -0
- package/dest/public/avm/opcodes/ec_add.js +84 -0
- package/dest/public/avm/opcodes/environment_getters.d.ts +28 -0
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -0
- package/dest/public/avm/opcodes/environment_getters.js +79 -0
- package/dest/public/avm/opcodes/external_calls.d.ts +58 -0
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -0
- package/dest/public/avm/opcodes/external_calls.js +204 -0
- package/dest/public/avm/opcodes/hashing.d.ts +36 -0
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -0
- package/dest/public/avm/opcodes/hashing.js +114 -0
- package/dest/public/avm/opcodes/index.d.ts +16 -0
- package/dest/public/avm/opcodes/index.d.ts.map +1 -0
- package/dest/public/avm/opcodes/index.js +15 -0
- package/dest/public/avm/opcodes/instruction.d.ts +70 -0
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -0
- package/dest/public/avm/opcodes/instruction.js +91 -0
- package/dest/public/avm/opcodes/instruction_impl.d.ts +19 -0
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -0
- package/dest/public/avm/opcodes/instruction_impl.js +30 -0
- package/dest/public/avm/opcodes/memory.d.ts +74 -0
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -0
- package/dest/public/avm/opcodes/memory.js +253 -0
- package/dest/public/avm/opcodes/misc.d.ts +17 -0
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -0
- package/dest/public/avm/opcodes/misc.js +48 -0
- package/dest/public/avm/opcodes/storage.d.ts +24 -0
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -0
- package/dest/public/avm/opcodes/storage.js +66 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts +28 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -0
- package/dest/public/avm/serialization/buffer_cursor.js +99 -0
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +21 -0
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -0
- package/dest/public/avm/serialization/bytecode_serialization.js +332 -0
- package/dest/public/avm/serialization/instruction_serialization.d.ts +105 -0
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -0
- package/dest/public/avm/serialization/instruction_serialization.js +226 -0
- package/dest/public/avm/test_utils.d.ts +18 -0
- package/dest/public/avm/test_utils.d.ts.map +1 -0
- package/dest/public/avm/test_utils.js +52 -0
- package/dest/public/bytecode_errors.d.ts +4 -0
- package/dest/public/bytecode_errors.d.ts.map +1 -0
- package/dest/public/bytecode_errors.js +6 -0
- package/dest/public/execution.d.ts +108 -0
- package/dest/public/execution.d.ts.map +1 -0
- package/dest/public/execution.js +9 -0
- package/dest/public/executor_metrics.d.ts +13 -0
- package/dest/public/executor_metrics.d.ts.map +1 -0
- package/dest/public/executor_metrics.js +54 -0
- package/dest/public/fixtures/index.d.ts +3 -0
- package/dest/public/fixtures/index.d.ts.map +1 -0
- package/dest/public/fixtures/index.js +2 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +32 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -0
- package/dest/public/fixtures/public_tx_simulation_tester.js +93 -0
- package/dest/public/fixtures/utils.d.ts +13 -0
- package/dest/public/fixtures/utils.d.ts.map +1 -0
- package/dest/public/fixtures/utils.js +126 -0
- package/dest/public/index.d.ts +10 -0
- package/dest/public/index.d.ts.map +1 -0
- package/dest/public/index.js +8 -0
- package/dest/public/public_db_sources.d.ts +129 -0
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +264 -0
- package/dest/public/public_processor/public_processor.d.ts +74 -0
- package/dest/public/public_processor/public_processor.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor.js +379 -0
- package/dest/public/public_processor/public_processor_metrics.d.ts +27 -0
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor_metrics.js +125 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +137 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_context.js +320 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +102 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.js +334 -0
- package/dest/public/side_effect_errors.d.ts +4 -0
- package/dest/public/side_effect_errors.d.ts.map +1 -0
- package/dest/public/side_effect_errors.js +6 -0
- package/dest/public/side_effect_trace.d.ts +132 -0
- package/dest/public/side_effect_trace.d.ts.map +1 -0
- package/dest/public/side_effect_trace.js +249 -0
- package/dest/public/side_effect_trace_interface.d.ts +34 -0
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -0
- package/dest/public/side_effect_trace_interface.js +1 -0
- package/dest/public/tx_contract_cache.d.ts +41 -0
- package/dest/public/tx_contract_cache.d.ts.map +1 -0
- package/dest/public/tx_contract_cache.js +49 -0
- package/dest/public/unique_class_ids.d.ts +37 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -0
- package/dest/public/unique_class_ids.js +61 -0
- package/dest/public/utils.d.ts +5 -0
- package/dest/public/utils.d.ts.map +1 -0
- package/dest/public/utils.js +35 -0
- package/dest/server.d.ts +6 -0
- package/dest/server.d.ts.map +1 -0
- package/dest/server.js +4 -0
- package/dest/test/utils.d.ts +13 -0
- package/dest/test/utils.d.ts.map +1 -0
- package/dest/test/utils.js +22 -0
- package/package.json +104 -0
- package/src/client.ts +4 -0
- package/src/common/db_interfaces.ts +94 -0
- package/src/common/debug_fn_name.ts +18 -0
- package/src/common/errors.ts +183 -0
- package/src/common/index.ts +3 -0
- package/src/common/message_load_oracle_inputs.ts +15 -0
- package/src/common/stats/index.ts +1 -0
- package/src/common/stats/stats.ts +20 -0
- package/src/private/acvm/acvm.ts +127 -0
- package/src/private/acvm/acvm_types.ts +11 -0
- package/src/private/acvm/deserialize.ts +52 -0
- package/src/private/acvm/index.ts +5 -0
- package/src/private/acvm/oracle/index.ts +16 -0
- package/src/private/acvm/oracle/oracle.ts +455 -0
- package/src/private/acvm/oracle/typed_oracle.ts +259 -0
- package/src/private/acvm/serialize.ts +60 -0
- package/src/private/execution_data_provider.ts +323 -0
- package/src/private/execution_note_cache.ts +217 -0
- package/src/private/hashed_values_cache.ts +55 -0
- package/src/private/index.ts +16 -0
- package/src/private/pick_notes.ts +141 -0
- package/src/private/private_execution.ts +151 -0
- package/src/private/private_execution_oracle.ts +614 -0
- package/src/private/providers/acvm_native.ts +171 -0
- package/src/private/providers/acvm_wasm.ts +63 -0
- package/src/private/providers/acvm_wasm_with_blobs.ts +50 -0
- package/src/private/providers/factory.ts +38 -0
- package/src/private/providers/simulation_provider.ts +45 -0
- package/src/private/simulator.ts +147 -0
- package/src/private/unconstrained_execution.ts +50 -0
- package/src/private/unconstrained_execution_oracle.ts +373 -0
- package/src/public/avm/avm_context.ts +61 -0
- package/src/public/avm/avm_contract_call_result.ts +55 -0
- package/src/public/avm/avm_execution_environment.ts +39 -0
- package/src/public/avm/avm_gas.ts +195 -0
- package/src/public/avm/avm_machine_state.ts +164 -0
- package/src/public/avm/avm_memory_types.ts +423 -0
- package/src/public/avm/avm_simulator.ts +284 -0
- package/src/public/avm/bytecode_utils.ts +17 -0
- package/src/public/avm/errors.ts +232 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +105 -0
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +109 -0
- package/src/public/avm/fixtures/index.ts +296 -0
- package/src/public/avm/fixtures/simple_contract_data_source.ts +105 -0
- package/src/public/avm/index.ts +3 -0
- package/src/public/avm/journal/index.ts +1 -0
- package/src/public/avm/journal/journal.ts +742 -0
- package/src/public/avm/journal/nullifiers.ts +109 -0
- package/src/public/avm/journal/public_storage.ts +174 -0
- package/src/public/avm/opcodes/.eslintrc.cjs +8 -0
- package/src/public/avm/opcodes/accrued_substate.ts +253 -0
- package/src/public/avm/opcodes/addressing_mode.ts +87 -0
- package/src/public/avm/opcodes/arithmetic.ts +95 -0
- package/src/public/avm/opcodes/bitwise.ts +109 -0
- package/src/public/avm/opcodes/comparators.ts +52 -0
- package/src/public/avm/opcodes/contract.ts +72 -0
- package/src/public/avm/opcodes/control_flow.ts +114 -0
- package/src/public/avm/opcodes/conversion.ts +80 -0
- package/src/public/avm/opcodes/ec_add.ts +93 -0
- package/src/public/avm/opcodes/environment_getters.ts +82 -0
- package/src/public/avm/opcodes/external_calls.ts +228 -0
- package/src/public/avm/opcodes/hashing.ts +125 -0
- package/src/public/avm/opcodes/index.ts +15 -0
- package/src/public/avm/opcodes/instruction.ts +126 -0
- package/src/public/avm/opcodes/instruction_impl.ts +36 -0
- package/src/public/avm/opcodes/memory.ts +254 -0
- package/src/public/avm/opcodes/misc.ts +60 -0
- package/src/public/avm/opcodes/storage.ts +71 -0
- package/src/public/avm/serialization/buffer_cursor.ts +115 -0
- package/src/public/avm/serialization/bytecode_serialization.ts +206 -0
- package/src/public/avm/serialization/instruction_serialization.ts +208 -0
- package/src/public/avm/test_utils.ts +81 -0
- package/src/public/bytecode_errors.ts +6 -0
- package/src/public/execution.ts +140 -0
- package/src/public/executor_metrics.ts +71 -0
- package/src/public/fixtures/index.ts +2 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +179 -0
- package/src/public/fixtures/utils.ts +199 -0
- package/src/public/index.ts +9 -0
- package/src/public/public_db_sources.ts +369 -0
- package/src/public/public_processor/public_processor.ts +521 -0
- package/src/public/public_processor/public_processor_metrics.ts +154 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +504 -0
- package/src/public/public_tx_simulator/public_tx_simulator.ts +474 -0
- package/src/public/side_effect_errors.ts +6 -0
- package/src/public/side_effect_trace.ts +516 -0
- package/src/public/side_effect_trace_interface.ts +76 -0
- package/src/public/tx_contract_cache.ts +69 -0
- package/src/public/unique_class_ids.ts +80 -0
- package/src/public/utils.ts +32 -0
- package/src/server.ts +5 -0
- package/src/test/utils.ts +36 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
}
|
|
7
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
8
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
9
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
10
|
+
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
11
|
+
import { SimulationError } from '@aztec/stdlib/errors';
|
|
12
|
+
import { NestedProcessReturnValues, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
13
|
+
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
14
|
+
import { strict as assert } from 'assert';
|
|
15
|
+
import { getPublicFunctionDebugName } from '../../common/debug_fn_name.js';
|
|
16
|
+
import { AvmSimulator } from '../avm/index.js';
|
|
17
|
+
import { NullifierCollisionError } from '../avm/journal/nullifiers.js';
|
|
18
|
+
import { ExecutorMetrics } from '../executor_metrics.js';
|
|
19
|
+
import { PublicTxContext } from './public_tx_context.js';
|
|
20
|
+
export class PublicTxSimulator {
|
|
21
|
+
db;
|
|
22
|
+
worldStateDB;
|
|
23
|
+
globalVariables;
|
|
24
|
+
doMerkleOperations;
|
|
25
|
+
skipFeeEnforcement;
|
|
26
|
+
metrics;
|
|
27
|
+
log;
|
|
28
|
+
constructor(db, worldStateDB, globalVariables, doMerkleOperations = false, skipFeeEnforcement = false, telemetryClient = getTelemetryClient()){
|
|
29
|
+
this.db = db;
|
|
30
|
+
this.worldStateDB = worldStateDB;
|
|
31
|
+
this.globalVariables = globalVariables;
|
|
32
|
+
this.doMerkleOperations = doMerkleOperations;
|
|
33
|
+
this.skipFeeEnforcement = skipFeeEnforcement;
|
|
34
|
+
this.log = createLogger(`simulator:public_tx_simulator`);
|
|
35
|
+
this.metrics = new ExecutorMetrics(telemetryClient, 'PublicTxSimulator');
|
|
36
|
+
}
|
|
37
|
+
get tracer() {
|
|
38
|
+
return this.metrics.tracer;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Simulate a transaction's public portion including all of its phases.
|
|
42
|
+
* @param tx - The transaction to simulate.
|
|
43
|
+
* @returns The result of the transaction's public execution.
|
|
44
|
+
*/ async simulate(tx) {
|
|
45
|
+
try {
|
|
46
|
+
const startTime = process.hrtime.bigint();
|
|
47
|
+
const txHash = await tx.getTxHash();
|
|
48
|
+
this.log.debug(`Simulating ${tx.enqueuedPublicFunctionCalls.length} public calls for tx ${txHash}`, {
|
|
49
|
+
txHash
|
|
50
|
+
});
|
|
51
|
+
const context = await PublicTxContext.create(this.db, this.worldStateDB, tx, this.globalVariables, this.doMerkleOperations);
|
|
52
|
+
const nonRevertStart = process.hrtime.bigint();
|
|
53
|
+
await this.insertNonRevertiblesFromPrivate(context);
|
|
54
|
+
// add new contracts to the contracts db so that their functions may be found and called
|
|
55
|
+
// TODO(#6464): Should we allow emitting contracts in the private setup phase?
|
|
56
|
+
await this.worldStateDB.addNewNonRevertibleContracts(tx);
|
|
57
|
+
const nonRevertEnd = process.hrtime.bigint();
|
|
58
|
+
this.metrics.recordPrivateEffectsInsertion(Number(nonRevertEnd - nonRevertStart) / 1_000, 'non-revertible');
|
|
59
|
+
const processedPhases = [];
|
|
60
|
+
if (context.hasPhase(TxExecutionPhase.SETUP)) {
|
|
61
|
+
const setupResult = await this.simulateSetupPhase(context);
|
|
62
|
+
processedPhases.push(setupResult);
|
|
63
|
+
}
|
|
64
|
+
const revertStart = process.hrtime.bigint();
|
|
65
|
+
const success = await this.insertRevertiblesFromPrivate(context);
|
|
66
|
+
if (success) {
|
|
67
|
+
// add new contracts to the contracts db so that their functions may be found and called
|
|
68
|
+
await this.worldStateDB.addNewRevertibleContracts(tx);
|
|
69
|
+
const revertEnd = process.hrtime.bigint();
|
|
70
|
+
this.metrics.recordPrivateEffectsInsertion(Number(revertEnd - revertStart) / 1_000, 'revertible');
|
|
71
|
+
// Only proceed with app logic if there was no revert during revertible insertion
|
|
72
|
+
if (context.hasPhase(TxExecutionPhase.APP_LOGIC)) {
|
|
73
|
+
const appLogicResult = await this.simulateAppLogicPhase(context);
|
|
74
|
+
processedPhases.push(appLogicResult);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
this.log.debug(`Revertible insertions failed. Skipping app logic.`);
|
|
78
|
+
}
|
|
79
|
+
if (context.hasPhase(TxExecutionPhase.TEARDOWN)) {
|
|
80
|
+
const teardownResult = await this.simulateTeardownPhase(context);
|
|
81
|
+
processedPhases.push(teardownResult);
|
|
82
|
+
}
|
|
83
|
+
await context.halt();
|
|
84
|
+
await this.payFee(context);
|
|
85
|
+
const endStateReference = await this.db.getStateReference();
|
|
86
|
+
const avmProvingRequest = await context.generateProvingRequest(endStateReference);
|
|
87
|
+
const revertCode = context.getFinalRevertCode();
|
|
88
|
+
if (!revertCode.isOK()) {
|
|
89
|
+
await tx.filterRevertedLogs();
|
|
90
|
+
}
|
|
91
|
+
// Commit contracts from this TX to the block-level cache and clear tx cache
|
|
92
|
+
// If the tx reverted, only commit non-revertible contracts
|
|
93
|
+
// NOTE: You can't create contracts in public, so this is only relevant for private-created contracts
|
|
94
|
+
this.worldStateDB.commitContractsForTx(/*onlyNonRevertibles=*/ !revertCode.isOK());
|
|
95
|
+
const endTime = process.hrtime.bigint();
|
|
96
|
+
this.log.debug(`Public TX simulator took ${Number(endTime - startTime) / 1_000_000} ms\n`);
|
|
97
|
+
return {
|
|
98
|
+
avmProvingRequest,
|
|
99
|
+
gasUsed: {
|
|
100
|
+
totalGas: context.getActualGasUsed(),
|
|
101
|
+
teardownGas: context.teardownGasUsed,
|
|
102
|
+
publicGas: context.getActualPublicGasUsed(),
|
|
103
|
+
billedGas: context.getTotalGasUsed()
|
|
104
|
+
},
|
|
105
|
+
revertCode,
|
|
106
|
+
revertReason: context.revertReason,
|
|
107
|
+
processedPhases: processedPhases
|
|
108
|
+
};
|
|
109
|
+
} finally{
|
|
110
|
+
// Make sure there are no new contracts in the tx-level cache.
|
|
111
|
+
// They should either be committed to block-level cache or cleared.
|
|
112
|
+
this.worldStateDB.clearContractsForTx();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Simulate the setup phase of a transaction's public execution.
|
|
117
|
+
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
118
|
+
* @returns The phase result.
|
|
119
|
+
*/ async simulateSetupPhase(context) {
|
|
120
|
+
return await this.simulatePhase(TxExecutionPhase.SETUP, context);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Simulate the app logic phase of a transaction's public execution.
|
|
124
|
+
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
125
|
+
* @returns The phase result.
|
|
126
|
+
*/ async simulateAppLogicPhase(context) {
|
|
127
|
+
assert(context.state.isForked(), 'App logic phase should operate with forked state.');
|
|
128
|
+
const result = await this.simulatePhase(TxExecutionPhase.APP_LOGIC, context);
|
|
129
|
+
if (result.reverted) {
|
|
130
|
+
// Drop the currently active forked state manager and rollback to end of setup.
|
|
131
|
+
await context.state.discardForkedState();
|
|
132
|
+
} else {
|
|
133
|
+
if (!context.hasPhase(TxExecutionPhase.TEARDOWN)) {
|
|
134
|
+
// Nothing to do after this (no teardown), so merge state updates now instead of letting teardown handle it.
|
|
135
|
+
await context.state.mergeForkedState();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Simulate the teardown phase of a transaction's public execution.
|
|
142
|
+
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
143
|
+
* @returns The phase result.
|
|
144
|
+
*/ async simulateTeardownPhase(context) {
|
|
145
|
+
if (!context.state.isForked()) {
|
|
146
|
+
// If state isn't forked (app logic reverted), fork now
|
|
147
|
+
// so we can rollback to the end of setup if teardown reverts.
|
|
148
|
+
await context.state.fork();
|
|
149
|
+
}
|
|
150
|
+
const result = await this.simulatePhase(TxExecutionPhase.TEARDOWN, context);
|
|
151
|
+
if (result.reverted) {
|
|
152
|
+
// Drop the currently active forked state manager and rollback to end of setup.
|
|
153
|
+
await context.state.discardForkedState();
|
|
154
|
+
} else {
|
|
155
|
+
// Merge state updates from teardown,
|
|
156
|
+
await context.state.mergeForkedState();
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Simulate a phase of a transaction's public execution.
|
|
162
|
+
* @param phase - The current phase
|
|
163
|
+
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
164
|
+
* @returns The phase result.
|
|
165
|
+
*/ async simulatePhase(phase, context) {
|
|
166
|
+
const callRequests = context.getCallRequestsForPhase(phase);
|
|
167
|
+
const executionRequests = context.getExecutionRequestsForPhase(phase);
|
|
168
|
+
this.log.debug(`Processing phase ${TxExecutionPhase[phase]} for tx ${context.txHash}`, {
|
|
169
|
+
txHash: context.txHash.toString(),
|
|
170
|
+
phase: TxExecutionPhase[phase],
|
|
171
|
+
callRequests: callRequests.length,
|
|
172
|
+
executionRequests: executionRequests.length
|
|
173
|
+
});
|
|
174
|
+
const returnValues = [];
|
|
175
|
+
let reverted = false;
|
|
176
|
+
let revertReason;
|
|
177
|
+
const phaseTimer = new Timer();
|
|
178
|
+
for(let i = callRequests.length - 1; i >= 0; i--){
|
|
179
|
+
if (reverted) {
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
const callRequest = callRequests[i];
|
|
183
|
+
const executionRequest = executionRequests[i];
|
|
184
|
+
const enqueuedCallResult = await this.simulateEnqueuedCall(phase, context, callRequest, executionRequest);
|
|
185
|
+
returnValues.push(new NestedProcessReturnValues(enqueuedCallResult.output));
|
|
186
|
+
if (enqueuedCallResult.reverted) {
|
|
187
|
+
reverted = true;
|
|
188
|
+
revertReason = enqueuedCallResult.revertReason;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
phase,
|
|
193
|
+
durationMs: phaseTimer.ms(),
|
|
194
|
+
returnValues,
|
|
195
|
+
reverted,
|
|
196
|
+
revertReason
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Simulate an enqueued public call.
|
|
201
|
+
* @param phase - The current phase of public execution
|
|
202
|
+
* @param context - WILL BE MUTATED. The context of the currently executing public transaction portion
|
|
203
|
+
* @param callRequest - The enqueued call to execute
|
|
204
|
+
* @param executionRequest - The execution request (includes args)
|
|
205
|
+
* @returns The result of execution.
|
|
206
|
+
*/ async simulateEnqueuedCall(phase, context, callRequest, executionRequest) {
|
|
207
|
+
const stateManager = context.state.getActiveStateManager();
|
|
208
|
+
const address = executionRequest.callContext.contractAddress;
|
|
209
|
+
const fnName = await getPublicFunctionDebugName(this.worldStateDB, address, executionRequest.args);
|
|
210
|
+
const allocatedGas = context.getGasLeftAtPhase(phase);
|
|
211
|
+
const result = await this.simulateEnqueuedCallInternal(context.state.getActiveStateManager(), executionRequest, allocatedGas, /*transactionFee=*/ context.getTransactionFee(phase), fnName);
|
|
212
|
+
const gasUsed = allocatedGas.sub(result.gasLeft); // by enqueued call
|
|
213
|
+
context.consumeGas(phase, gasUsed);
|
|
214
|
+
this.log.debug(`Simulated enqueued public call (${fnName}) consumed ${gasUsed.l2Gas} L2 gas ending with ${result.gasLeft.l2Gas} L2 gas left.`);
|
|
215
|
+
stateManager.traceEnqueuedCall(callRequest, executionRequest.args, result.reverted);
|
|
216
|
+
if (result.reverted) {
|
|
217
|
+
const culprit = `${executionRequest.callContext.contractAddress}:${executionRequest.callContext.functionSelector}`;
|
|
218
|
+
context.revert(phase, result.revertReason, culprit); // throws if in setup (non-revertible) phase
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Simulate an enqueued public call, without modifying the context (PublicTxContext).
|
|
224
|
+
* Resulting modifications to the context can be applied by the caller.
|
|
225
|
+
*
|
|
226
|
+
* This function can be mocked for testing to skip actual AVM simulation
|
|
227
|
+
* while still simulating phases and generating a proving request.
|
|
228
|
+
*
|
|
229
|
+
* @param stateManager - The state manager for AvmSimulation
|
|
230
|
+
* @param context - The context of the currently executing public transaction portion
|
|
231
|
+
* @param executionRequest - The execution request (includes args)
|
|
232
|
+
* @param allocatedGas - The gas allocated to the enqueued call
|
|
233
|
+
* @param fnName - The name of the function
|
|
234
|
+
* @returns The result of execution.
|
|
235
|
+
*/ async simulateEnqueuedCallInternal(stateManager, executionRequest, allocatedGas, transactionFee, fnName) {
|
|
236
|
+
const address = executionRequest.callContext.contractAddress;
|
|
237
|
+
const sender = executionRequest.callContext.msgSender;
|
|
238
|
+
this.log.debug(`Executing enqueued public call to external function ${fnName}@${address} with ${allocatedGas.l2Gas} allocated L2 gas.`);
|
|
239
|
+
const timer = new Timer();
|
|
240
|
+
const simulator = await AvmSimulator.create(stateManager, address, sender, transactionFee, this.globalVariables, executionRequest.callContext.isStaticCall, executionRequest.args, allocatedGas);
|
|
241
|
+
const avmCallResult = await simulator.execute();
|
|
242
|
+
const result = avmCallResult.finalize();
|
|
243
|
+
this.log.verbose(result.reverted ? `Simulation of enqueued public call ${fnName} reverted with reason ${result.revertReason}.` : `Simulation of enqueued public call ${fnName} completed successfully.`, {
|
|
244
|
+
eventName: 'avm-simulation',
|
|
245
|
+
appCircuitName: fnName,
|
|
246
|
+
duration: timer.ms()
|
|
247
|
+
});
|
|
248
|
+
if (result.reverted) {
|
|
249
|
+
this.metrics.recordFunctionSimulationFailure();
|
|
250
|
+
} else {
|
|
251
|
+
this.metrics.recordFunctionSimulation(timer.ms(), allocatedGas.sub(result.gasLeft).l2Gas, fnName);
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Insert the non-revertible accumulated data from private into the public state.
|
|
257
|
+
*/ async insertNonRevertiblesFromPrivate(context) {
|
|
258
|
+
const stateManager = context.state.getActiveStateManager();
|
|
259
|
+
try {
|
|
260
|
+
await stateManager.writeSiloedNullifiersFromPrivate(context.nonRevertibleAccumulatedDataFromPrivate.nullifiers);
|
|
261
|
+
} catch (e) {
|
|
262
|
+
if (e instanceof NullifierCollisionError) {
|
|
263
|
+
throw new NullifierCollisionError(`Nullifier collision encountered when inserting non-revertible nullifiers from private.\nDetails: ${e.message}\nStack:${e.stack}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const noteHash of context.nonRevertibleAccumulatedDataFromPrivate.noteHashes){
|
|
267
|
+
if (!noteHash.isEmpty()) {
|
|
268
|
+
await stateManager.writeUniqueNoteHash(noteHash);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Insert the revertible accumulated data from private into the public state.
|
|
274
|
+
* Start by forking state so we can rollback to the end of setup if app logic or teardown reverts.
|
|
275
|
+
*/ async insertRevertiblesFromPrivate(context) {
|
|
276
|
+
// Fork the state manager so we can rollback to end of setup if app logic reverts.
|
|
277
|
+
await context.state.fork();
|
|
278
|
+
const stateManager = context.state.getActiveStateManager();
|
|
279
|
+
try {
|
|
280
|
+
await stateManager.writeSiloedNullifiersFromPrivate(context.revertibleAccumulatedDataFromPrivate.nullifiers);
|
|
281
|
+
} catch (e) {
|
|
282
|
+
if (e instanceof NullifierCollisionError) {
|
|
283
|
+
// Instead of throwing, revert the app_logic phase
|
|
284
|
+
context.revert(TxExecutionPhase.APP_LOGIC, new SimulationError(`Nullifier collision encountered when inserting revertible nullifiers from private\nDetails: ${e.message}\nError stack: ${e.stack}`, []), /*culprit=*/ 'insertRevertiblesFromPrivate');
|
|
285
|
+
return /*success=*/ false;
|
|
286
|
+
} else {
|
|
287
|
+
throw e;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for (const noteHash of context.revertibleAccumulatedDataFromPrivate.noteHashes){
|
|
291
|
+
if (!noteHash.isEmpty()) {
|
|
292
|
+
// Revertible note hashes from private are not hashed with nonce, since private can't know their final position, only we can.
|
|
293
|
+
await stateManager.writeSiloedNoteHash(noteHash);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return /*success=*/ true;
|
|
297
|
+
}
|
|
298
|
+
async payFee(context) {
|
|
299
|
+
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
300
|
+
if (context.feePayer.isZero()) {
|
|
301
|
+
this.log.debug(`No one is paying the fee of ${txFee.toBigInt()}`);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
305
|
+
const balanceSlot = await computeFeePayerBalanceStorageSlot(context.feePayer);
|
|
306
|
+
this.log.debug(`Deducting ${txFee.toBigInt()} balance in Fee Juice for ${context.feePayer}`);
|
|
307
|
+
const stateManager = context.state.getActiveStateManager();
|
|
308
|
+
let currentBalance = await stateManager.readStorage(feeJuiceAddress, balanceSlot);
|
|
309
|
+
// We allow to fake the balance of the fee payer to allow fee estimation
|
|
310
|
+
// When mocking the balance of the fee payer, the circuit should not be able to prove the simulation
|
|
311
|
+
if (currentBalance.lt(txFee)) {
|
|
312
|
+
if (!this.skipFeeEnforcement) {
|
|
313
|
+
throw new Error(`Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`);
|
|
314
|
+
} else {
|
|
315
|
+
currentBalance = txFee;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const updatedBalance = currentBalance.sub(txFee);
|
|
319
|
+
await stateManager.writeStorage(feeJuiceAddress, balanceSlot, updatedBalance, true);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
_ts_decorate([
|
|
323
|
+
trackSpan('PublicTxSimulator.simulateEnqueuedCall', (phase, context, _callRequest, executionRequest)=>({
|
|
324
|
+
[Attributes.TX_HASH]: context.txHash.toString(),
|
|
325
|
+
[Attributes.TARGET_ADDRESS]: executionRequest.callContext.contractAddress.toString(),
|
|
326
|
+
[Attributes.SENDER_ADDRESS]: executionRequest.callContext.msgSender.toString(),
|
|
327
|
+
[Attributes.SIMULATOR_PHASE]: TxExecutionPhase[phase].toString()
|
|
328
|
+
}))
|
|
329
|
+
], PublicTxSimulator.prototype, "simulateEnqueuedCall", null);
|
|
330
|
+
_ts_decorate([
|
|
331
|
+
trackSpan('PublicTxSimulator.simulateEnqueuedCallInternal', (_stateManager, _executionRequest, _allocatedGas, _transactionFee, fnName)=>({
|
|
332
|
+
[Attributes.APP_CIRCUIT_NAME]: fnName
|
|
333
|
+
}))
|
|
334
|
+
], PublicTxSimulator.prototype, "simulateEnqueuedCallInternal", null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side_effect_errors.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_errors.ts"],"names":[],"mappings":"AAAA,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAIlD"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { AvmCircuitPublicInputs, AvmExecutionHints, AvmPublicDataReadTreeHint, PublicDataUpdateRequest } from '@aztec/stdlib/avm';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { type ContractClassWithCommitment, SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
5
|
+
import type { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
6
|
+
import { NoteHash, Nullifier, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
7
|
+
import { PublicLog } from '@aztec/stdlib/logs';
|
|
8
|
+
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
9
|
+
import { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
10
|
+
import type { GlobalVariables, TreeSnapshots } from '@aztec/stdlib/tx';
|
|
11
|
+
import type { PublicSideEffectTraceInterface } from './side_effect_trace_interface.js';
|
|
12
|
+
import { UniqueClassIds } from './unique_class_ids.js';
|
|
13
|
+
/**
|
|
14
|
+
* A struct containing just the side effects as regular arrays
|
|
15
|
+
* as opposed to "Tuple" arrays used by circuit public inputs.
|
|
16
|
+
* This struct is helpful for testing and checking array lengths.
|
|
17
|
+
**/
|
|
18
|
+
export type SideEffects = {
|
|
19
|
+
enqueuedCalls: PublicCallRequest[];
|
|
20
|
+
publicDataWrites: PublicDataUpdateRequest[];
|
|
21
|
+
noteHashes: NoteHash[];
|
|
22
|
+
nullifiers: Nullifier[];
|
|
23
|
+
l2ToL1Msgs: ScopedL2ToL1Message[];
|
|
24
|
+
publicLogs: PublicLog[];
|
|
25
|
+
};
|
|
26
|
+
export declare class SideEffectArrayLengths {
|
|
27
|
+
readonly publicDataWrites: number;
|
|
28
|
+
readonly protocolPublicDataWrites: number;
|
|
29
|
+
readonly noteHashes: number;
|
|
30
|
+
readonly nullifiers: number;
|
|
31
|
+
readonly l2ToL1Msgs: number;
|
|
32
|
+
readonly publicLogs: number;
|
|
33
|
+
constructor(publicDataWrites: number, protocolPublicDataWrites: number, noteHashes: number, nullifiers: number, l2ToL1Msgs: number, publicLogs: number);
|
|
34
|
+
static empty(): SideEffectArrayLengths;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Trace side effects for an enqueued public call's execution.
|
|
38
|
+
*/
|
|
39
|
+
export declare class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
40
|
+
/** The counter of this trace's first side effect. */
|
|
41
|
+
readonly startSideEffectCounter: number;
|
|
42
|
+
/** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
|
|
43
|
+
* otherwise the public kernel can fail to prove because TX limits are breached.
|
|
44
|
+
*/
|
|
45
|
+
private readonly previousSideEffectArrayLengths;
|
|
46
|
+
/** We need to track the set of class IDs used, to enforce limits. */
|
|
47
|
+
private uniqueClassIds;
|
|
48
|
+
log: import("@aztec/foundation/log").Logger;
|
|
49
|
+
/** The side effect counter increments with every call to the trace. */
|
|
50
|
+
private sideEffectCounter;
|
|
51
|
+
private enqueuedCalls;
|
|
52
|
+
private publicDataWrites;
|
|
53
|
+
private protocolPublicDataWritesLength;
|
|
54
|
+
private userPublicDataWritesLength;
|
|
55
|
+
private noteHashes;
|
|
56
|
+
private nullifiers;
|
|
57
|
+
private l2ToL1Messages;
|
|
58
|
+
private publicLogs;
|
|
59
|
+
private avmCircuitHints;
|
|
60
|
+
/** Make sure a forked trace is never merged twice. */
|
|
61
|
+
private alreadyMergedIntoParent;
|
|
62
|
+
constructor(
|
|
63
|
+
/** The counter of this trace's first side effect. */
|
|
64
|
+
startSideEffectCounter?: number,
|
|
65
|
+
/** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
|
|
66
|
+
* otherwise the public kernel can fail to prove because TX limits are breached.
|
|
67
|
+
*/
|
|
68
|
+
previousSideEffectArrayLengths?: SideEffectArrayLengths,
|
|
69
|
+
/** We need to track the set of class IDs used, to enforce limits. */
|
|
70
|
+
uniqueClassIds?: UniqueClassIds);
|
|
71
|
+
fork(): SideEffectTrace;
|
|
72
|
+
merge(forkedTrace: this, reverted?: boolean): void;
|
|
73
|
+
private mergeHints;
|
|
74
|
+
getCounter(): number;
|
|
75
|
+
private incrementSideEffectCounter;
|
|
76
|
+
getNoteHashCount(): number;
|
|
77
|
+
tracePublicStorageRead(contractAddress: AztecAddress, slot: Fr, value: Fr, leafPreimage?: PublicDataTreeLeafPreimage, leafIndex?: Fr, path?: Fr[]): void;
|
|
78
|
+
tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, value: Fr, protocolWrite: boolean, lowLeafPreimage?: PublicDataTreeLeafPreimage, lowLeafIndex?: Fr, lowLeafPath?: Fr[], newLeafPreimage?: PublicDataTreeLeafPreimage, insertionPath?: Fr[]): Promise<void>;
|
|
79
|
+
traceNoteHashCheck(_contractAddress: AztecAddress, noteHash: Fr, leafIndex: Fr, _exists: boolean, path?: Fr[]): void;
|
|
80
|
+
traceNewNoteHash(noteHash: Fr, leafIndex?: Fr, path?: Fr[]): void;
|
|
81
|
+
traceNullifierCheck(_siloedNullifier: Fr, _exists: boolean, lowLeafPreimage?: NullifierLeafPreimage, lowLeafIndex?: Fr, lowLeafPath?: Fr[]): void;
|
|
82
|
+
traceNewNullifier(siloedNullifier: Fr, lowLeafPreimage?: NullifierLeafPreimage, lowLeafIndex?: Fr, lowLeafPath?: Fr[], insertionPath?: Fr[]): void;
|
|
83
|
+
traceL1ToL2MessageCheck(_contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, _exists: boolean, path?: Fr[]): void;
|
|
84
|
+
traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
|
|
85
|
+
tracePublicLog(contractAddress: AztecAddress, log: Fr[]): void;
|
|
86
|
+
traceGetContractInstance(contractAddress: AztecAddress, exists: boolean, instance?: SerializableContractInstance, updateMembershipHint?: AvmPublicDataReadTreeHint, updatePreimage?: Fr[]): void;
|
|
87
|
+
traceGetContractClass(contractClassId: Fr, exists: boolean, contractClass?: ContractClassWithCommitment): void;
|
|
88
|
+
/**
|
|
89
|
+
* Trace an enqueued call.
|
|
90
|
+
* Accept some results from a finished call's trace into this one.
|
|
91
|
+
*/
|
|
92
|
+
traceEnqueuedCall(
|
|
93
|
+
/** The call request from private that enqueued this call. */
|
|
94
|
+
publicCallRequest: PublicCallRequest,
|
|
95
|
+
/** The call's calldata */
|
|
96
|
+
calldata: Fr[],
|
|
97
|
+
/** Did the call revert? */
|
|
98
|
+
_reverted: boolean): void;
|
|
99
|
+
getSideEffects(): SideEffects;
|
|
100
|
+
toAvmCircuitPublicInputs(
|
|
101
|
+
/** Globals. */
|
|
102
|
+
globalVariables: GlobalVariables,
|
|
103
|
+
/** Start tree snapshots. */
|
|
104
|
+
startTreeSnapshots: TreeSnapshots,
|
|
105
|
+
/** Gas used at start of TX. */
|
|
106
|
+
startGasUsed: Gas,
|
|
107
|
+
/** How much gas was available for this public execution. */
|
|
108
|
+
gasLimits: GasSettings,
|
|
109
|
+
/** Address of the fee payer. */
|
|
110
|
+
feePayer: AztecAddress,
|
|
111
|
+
/** Call requests for setup phase. */
|
|
112
|
+
publicSetupCallRequests: PublicCallRequest[],
|
|
113
|
+
/** Call requests for app logic phase. */
|
|
114
|
+
publicAppLogicCallRequests: PublicCallRequest[],
|
|
115
|
+
/** Call request for teardown phase. */
|
|
116
|
+
publicTeardownCallRequest: PublicCallRequest,
|
|
117
|
+
/** End tree snapshots. */
|
|
118
|
+
endTreeSnapshots: TreeSnapshots,
|
|
119
|
+
/**
|
|
120
|
+
* Gas used by the whole transaction, assuming entire teardown limit is used.
|
|
121
|
+
* This is the gas used when computing transaction fee.
|
|
122
|
+
*/
|
|
123
|
+
endGasUsed: Gas,
|
|
124
|
+
/** Transaction fee. */
|
|
125
|
+
transactionFee: Fr,
|
|
126
|
+
/** The call's results */
|
|
127
|
+
reverted: boolean): AvmCircuitPublicInputs;
|
|
128
|
+
getPublicLogs(): PublicLog[];
|
|
129
|
+
getAvmCircuitHints(): AvmExecutionHints;
|
|
130
|
+
private getAvmAccumulatedData;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=side_effect_trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side_effect_trace.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_trace.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAGL,sBAAsB,EAItB,iBAAiB,EAGjB,yBAAyB,EAEzB,uBAAuB,EAExB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,KAAK,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACxG,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EACL,QAAQ,EACR,SAAS,EAGT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM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