@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
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS, MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_PUBLIC_LOGS_PER_TX, PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, PUBLIC_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import {
|
|
7
|
-
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
6
|
+
import { PublicDataUpdateRequest } from '@aztec/stdlib/avm';
|
|
8
7
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
9
|
-
import { NoteHash, Nullifier
|
|
8
|
+
import { NoteHash, Nullifier } from '@aztec/stdlib/kernel';
|
|
10
9
|
import { PublicLog } from '@aztec/stdlib/logs';
|
|
11
|
-
import { L2ToL1Message
|
|
12
|
-
import { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
10
|
+
import { L2ToL1Message } from '@aztec/stdlib/messaging';
|
|
13
11
|
import { strict as assert } from 'assert';
|
|
14
12
|
import { SideEffectLimitReachedError } from './side_effect_errors.js';
|
|
15
13
|
import { UniqueClassIds } from './unique_class_ids.js';
|
|
16
|
-
const emptyPublicDataPath = ()=>new Array(PUBLIC_DATA_TREE_HEIGHT).fill(Fr.zero());
|
|
17
|
-
const emptyNoteHashPath = ()=>new Array(NOTE_HASH_TREE_HEIGHT).fill(Fr.zero());
|
|
18
|
-
const emptyNullifierPath = ()=>new Array(NULLIFIER_TREE_HEIGHT).fill(Fr.zero());
|
|
19
|
-
const emptyL1ToL2MessagePath = ()=>new Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.zero());
|
|
20
14
|
export class SideEffectArrayLengths {
|
|
21
15
|
publicDataWrites;
|
|
22
16
|
protocolPublicDataWrites;
|
|
@@ -42,9 +36,9 @@ export class SideEffectArrayLengths {
|
|
|
42
36
|
startSideEffectCounter;
|
|
43
37
|
previousSideEffectArrayLengths;
|
|
44
38
|
uniqueClassIds;
|
|
39
|
+
writtenPublicDataSlots;
|
|
45
40
|
log;
|
|
46
41
|
/** The side effect counter increments with every call to the trace. */ sideEffectCounter;
|
|
47
|
-
enqueuedCalls;
|
|
48
42
|
publicDataWrites;
|
|
49
43
|
protocolPublicDataWritesLength;
|
|
50
44
|
userPublicDataWritesLength;
|
|
@@ -52,16 +46,15 @@ export class SideEffectArrayLengths {
|
|
|
52
46
|
nullifiers;
|
|
53
47
|
l2ToL1Messages;
|
|
54
48
|
publicLogs;
|
|
55
|
-
avmCircuitHints;
|
|
56
49
|
/** Make sure a forked trace is never merged twice. */ alreadyMergedIntoParent;
|
|
57
50
|
constructor(/** The counter of this trace's first side effect. */ startSideEffectCounter = 0, /** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
|
|
58
51
|
* otherwise the public kernel can fail to prove because TX limits are breached.
|
|
59
|
-
*/ previousSideEffectArrayLengths = SideEffectArrayLengths.empty(), /** We need to track the set of class IDs used, to enforce limits. */ uniqueClassIds = new UniqueClassIds()){
|
|
52
|
+
*/ previousSideEffectArrayLengths = SideEffectArrayLengths.empty(), /** We need to track the set of class IDs used, to enforce limits. */ uniqueClassIds = new UniqueClassIds(), writtenPublicDataSlots = new Set()){
|
|
60
53
|
this.startSideEffectCounter = startSideEffectCounter;
|
|
61
54
|
this.previousSideEffectArrayLengths = previousSideEffectArrayLengths;
|
|
62
55
|
this.uniqueClassIds = uniqueClassIds;
|
|
56
|
+
this.writtenPublicDataSlots = writtenPublicDataSlots;
|
|
63
57
|
this.log = createLogger('simulator:side_effect_trace');
|
|
64
|
-
this.enqueuedCalls = [];
|
|
65
58
|
this.publicDataWrites = [];
|
|
66
59
|
this.protocolPublicDataWritesLength = 0;
|
|
67
60
|
this.userPublicDataWritesLength = 0;
|
|
@@ -71,38 +64,28 @@ export class SideEffectArrayLengths {
|
|
|
71
64
|
this.publicLogs = [];
|
|
72
65
|
this.alreadyMergedIntoParent = false;
|
|
73
66
|
this.sideEffectCounter = startSideEffectCounter;
|
|
74
|
-
this.avmCircuitHints = AvmExecutionHints.empty();
|
|
75
67
|
}
|
|
76
68
|
fork() {
|
|
77
|
-
return new SideEffectTrace(this.sideEffectCounter, new SideEffectArrayLengths(this.previousSideEffectArrayLengths.publicDataWrites + this.userPublicDataWritesLength, this.previousSideEffectArrayLengths.protocolPublicDataWrites + this.protocolPublicDataWritesLength, this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length, this.previousSideEffectArrayLengths.nullifiers + this.nullifiers.length, this.previousSideEffectArrayLengths.l2ToL1Msgs + this.l2ToL1Messages.length, this.previousSideEffectArrayLengths.publicLogs + this.publicLogs.length), this.uniqueClassIds.fork());
|
|
69
|
+
return new SideEffectTrace(this.sideEffectCounter, new SideEffectArrayLengths(this.previousSideEffectArrayLengths.publicDataWrites + this.userPublicDataWritesLength, this.previousSideEffectArrayLengths.protocolPublicDataWrites + this.protocolPublicDataWritesLength, this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length, this.previousSideEffectArrayLengths.nullifiers + this.nullifiers.length, this.previousSideEffectArrayLengths.l2ToL1Msgs + this.l2ToL1Messages.length, this.previousSideEffectArrayLengths.publicLogs + this.publicLogs.length), this.uniqueClassIds.fork(), new Set(this.writtenPublicDataSlots));
|
|
78
70
|
}
|
|
79
71
|
merge(forkedTrace, reverted = false) {
|
|
80
72
|
// sanity check to avoid merging the same forked trace twice
|
|
81
73
|
assert(!forkedTrace.alreadyMergedIntoParent, 'Bug! Cannot merge a forked trace that has already been merged into its parent!');
|
|
82
74
|
forkedTrace.alreadyMergedIntoParent = true;
|
|
83
75
|
this.sideEffectCounter = forkedTrace.sideEffectCounter;
|
|
84
|
-
this.
|
|
76
|
+
this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
|
|
85
77
|
if (!reverted) {
|
|
86
78
|
this.publicDataWrites.push(...forkedTrace.publicDataWrites);
|
|
87
79
|
this.noteHashes.push(...forkedTrace.noteHashes);
|
|
88
80
|
this.nullifiers.push(...forkedTrace.nullifiers);
|
|
89
81
|
this.l2ToL1Messages.push(...forkedTrace.l2ToL1Messages);
|
|
90
82
|
this.publicLogs.push(...forkedTrace.publicLogs);
|
|
83
|
+
this.userPublicDataWritesLength += forkedTrace.userPublicDataWritesLength;
|
|
84
|
+
this.protocolPublicDataWritesLength += forkedTrace.protocolPublicDataWritesLength;
|
|
85
|
+
for (const slot of forkedTrace.writtenPublicDataSlots){
|
|
86
|
+
this.writtenPublicDataSlots.add(slot);
|
|
87
|
+
}
|
|
91
88
|
}
|
|
92
|
-
this.mergeHints(forkedTrace);
|
|
93
|
-
}
|
|
94
|
-
mergeHints(forkedTrace) {
|
|
95
|
-
this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
|
|
96
|
-
this.avmCircuitHints.enqueuedCalls.push(...forkedTrace.avmCircuitHints.enqueuedCalls);
|
|
97
|
-
this.avmCircuitHints.contractInstances.push(...forkedTrace.avmCircuitHints.contractInstances);
|
|
98
|
-
this.avmCircuitHints.contractClasses.push(...forkedTrace.avmCircuitHints.contractClasses);
|
|
99
|
-
this.avmCircuitHints.publicDataReads.push(...forkedTrace.avmCircuitHints.publicDataReads);
|
|
100
|
-
this.avmCircuitHints.publicDataWrites.push(...forkedTrace.avmCircuitHints.publicDataWrites);
|
|
101
|
-
this.avmCircuitHints.nullifierReads.push(...forkedTrace.avmCircuitHints.nullifierReads);
|
|
102
|
-
this.avmCircuitHints.nullifierWrites.push(...forkedTrace.avmCircuitHints.nullifierWrites);
|
|
103
|
-
this.avmCircuitHints.noteHashReads.push(...forkedTrace.avmCircuitHints.noteHashReads);
|
|
104
|
-
this.avmCircuitHints.noteHashWrites.push(...forkedTrace.avmCircuitHints.noteHashWrites);
|
|
105
|
-
this.avmCircuitHints.l1ToL2MessageReads.push(...forkedTrace.avmCircuitHints.l1ToL2MessageReads);
|
|
106
89
|
}
|
|
107
90
|
getCounter() {
|
|
108
91
|
return this.sideEffectCounter;
|
|
@@ -113,73 +96,55 @@ export class SideEffectArrayLengths {
|
|
|
113
96
|
getNoteHashCount() {
|
|
114
97
|
return this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length;
|
|
115
98
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
throw new SideEffectLimitReachedError('public data (contract storage) write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
99
|
+
async tracePublicStorageWrite(contractAddress, slot, value, protocolWrite) {
|
|
100
|
+
// Only increment counts if the storage slot has not been written to before.
|
|
101
|
+
if (this.isStorageCold(contractAddress, slot)) {
|
|
102
|
+
if (protocolWrite) {
|
|
103
|
+
if (this.protocolPublicDataWritesLength + this.previousSideEffectArrayLengths.protocolPublicDataWrites >= PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
|
|
104
|
+
throw new SideEffectLimitReachedError('protocol public data (contract storage) write', PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
105
|
+
}
|
|
106
|
+
this.protocolPublicDataWritesLength++;
|
|
107
|
+
} else {
|
|
108
|
+
if (this.userPublicDataWritesLength + this.previousSideEffectArrayLengths.publicDataWrites >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
|
|
109
|
+
throw new SideEffectLimitReachedError('public data (contract storage) write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
110
|
+
}
|
|
111
|
+
this.userPublicDataWritesLength++;
|
|
130
112
|
}
|
|
131
|
-
this.userPublicDataWritesLength++;
|
|
132
113
|
}
|
|
133
114
|
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
134
115
|
this.publicDataWrites.push(new PublicDataUpdateRequest(leafSlot, value, this.sideEffectCounter));
|
|
135
|
-
// New hinting
|
|
136
|
-
const readHint = new AvmPublicDataReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath);
|
|
137
|
-
this.avmCircuitHints.publicDataWrites.push(new AvmPublicDataWriteTreeHint(readHint, newLeafPreimage, insertionPath));
|
|
138
116
|
this.log.trace(`Traced public data write (address=${contractAddress}, slot=${slot}): value=${value} (counter=${this.sideEffectCounter}, isProtocol:${protocolWrite})`);
|
|
139
117
|
this.incrementSideEffectCounter();
|
|
118
|
+
this.writtenPublicDataSlots.add(this.computePublicDataSlotKey(contractAddress, slot));
|
|
140
119
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// New Hinting
|
|
144
|
-
this.avmCircuitHints.noteHashReads.push(new AvmAppendTreeHint(leafIndex, noteHash, path));
|
|
145
|
-
// NOTE: counter does not increment for note hash checks (because it doesn't rely on pending note hashes)
|
|
146
|
-
this.log.trace(`Tracing note hash check (counter=${this.sideEffectCounter})`);
|
|
120
|
+
computePublicDataSlotKey(contractAddress, slot) {
|
|
121
|
+
return `${contractAddress.toString()}:${slot.toString()}`;
|
|
147
122
|
}
|
|
148
|
-
|
|
123
|
+
isStorageCold(contractAddress, slot) {
|
|
124
|
+
return !this.writtenPublicDataSlots.has(this.computePublicDataSlotKey(contractAddress, slot));
|
|
125
|
+
}
|
|
126
|
+
traceNewNoteHash(noteHash) {
|
|
149
127
|
if (this.noteHashes.length + this.previousSideEffectArrayLengths.noteHashes >= MAX_NOTE_HASHES_PER_TX) {
|
|
150
128
|
throw new SideEffectLimitReachedError('note hash', MAX_NOTE_HASHES_PER_TX);
|
|
151
129
|
}
|
|
152
130
|
this.noteHashes.push(new NoteHash(noteHash, this.sideEffectCounter));
|
|
153
|
-
this.avmCircuitHints.noteHashWrites.push(new AvmAppendTreeHint(leafIndex, noteHash, path));
|
|
154
131
|
this.log.trace(`Tracing new note hash (counter=${this.sideEffectCounter})`);
|
|
155
132
|
this.incrementSideEffectCounter();
|
|
156
133
|
}
|
|
157
|
-
|
|
158
|
-
this.avmCircuitHints.nullifierReads.push(new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath));
|
|
159
|
-
this.log.trace(`Tracing nullifier check (counter=${this.sideEffectCounter})`);
|
|
160
|
-
this.incrementSideEffectCounter();
|
|
161
|
-
}
|
|
162
|
-
traceNewNullifier(siloedNullifier, lowLeafPreimage = NullifierLeafPreimage.empty(), lowLeafIndex = Fr.zero(), lowLeafPath = emptyNullifierPath(), insertionPath = emptyNullifierPath()) {
|
|
134
|
+
traceNewNullifier(siloedNullifier) {
|
|
163
135
|
if (this.nullifiers.length + this.previousSideEffectArrayLengths.nullifiers >= MAX_NULLIFIERS_PER_TX) {
|
|
164
136
|
throw new SideEffectLimitReachedError('nullifier', MAX_NULLIFIERS_PER_TX);
|
|
165
137
|
}
|
|
166
138
|
this.nullifiers.push(new Nullifier(siloedNullifier, this.sideEffectCounter, /*noteHash=*/ Fr.ZERO));
|
|
167
|
-
const lowLeafReadHint = new AvmNullifierReadTreeHint(lowLeafPreimage, lowLeafIndex, lowLeafPath);
|
|
168
|
-
this.avmCircuitHints.nullifierWrites.push(new AvmNullifierWriteTreeHint(lowLeafReadHint, insertionPath));
|
|
169
139
|
this.log.trace(`Tracing new nullifier (counter=${this.sideEffectCounter})`);
|
|
170
140
|
this.incrementSideEffectCounter();
|
|
171
141
|
}
|
|
172
|
-
// TODO(8287): _exists can be removed once we have the vm properly handling the equality check
|
|
173
|
-
traceL1ToL2MessageCheck(_contractAddress, msgHash, msgLeafIndex, _exists, path = emptyL1ToL2MessagePath()) {
|
|
174
|
-
this.avmCircuitHints.l1ToL2MessageReads.push(new AvmAppendTreeHint(msgLeafIndex, msgHash, path));
|
|
175
|
-
this.log.trace(`Tracing l1 to l2 message check (counter=${this.sideEffectCounter})`);
|
|
176
|
-
}
|
|
177
142
|
traceNewL2ToL1Message(contractAddress, recipient, content) {
|
|
178
143
|
if (this.l2ToL1Messages.length + this.previousSideEffectArrayLengths.l2ToL1Msgs >= MAX_L2_TO_L1_MSGS_PER_TX) {
|
|
179
144
|
throw new SideEffectLimitReachedError('l2 to l1 message', MAX_L2_TO_L1_MSGS_PER_TX);
|
|
180
145
|
}
|
|
181
146
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
182
|
-
this.l2ToL1Messages.push(new L2ToL1Message(recipientAddress, content
|
|
147
|
+
this.l2ToL1Messages.push(new L2ToL1Message(recipientAddress, content).scope(contractAddress));
|
|
183
148
|
this.log.trace(`Tracing new l2 to l1 message (counter=${this.sideEffectCounter})`);
|
|
184
149
|
this.incrementSideEffectCounter();
|
|
185
150
|
}
|
|
@@ -187,43 +152,28 @@ export class SideEffectArrayLengths {
|
|
|
187
152
|
if (this.publicLogs.length + this.previousSideEffectArrayLengths.publicLogs >= MAX_PUBLIC_LOGS_PER_TX) {
|
|
188
153
|
throw new SideEffectLimitReachedError('public log', MAX_PUBLIC_LOGS_PER_TX);
|
|
189
154
|
}
|
|
190
|
-
if (log.length >
|
|
191
|
-
throw new Error(`Emitted public log is too large, max: ${
|
|
155
|
+
if (log.length > PUBLIC_LOG_SIZE_IN_FIELDS) {
|
|
156
|
+
throw new Error(`Emitted public log is too large, max: ${PUBLIC_LOG_SIZE_IN_FIELDS}, passed: ${log.length}`);
|
|
192
157
|
}
|
|
193
|
-
const publicLog = new PublicLog(contractAddress, padArrayEnd(log, Fr.ZERO,
|
|
158
|
+
const publicLog = new PublicLog(contractAddress, padArrayEnd(log, Fr.ZERO, PUBLIC_LOG_SIZE_IN_FIELDS), log.length);
|
|
194
159
|
this.publicLogs.push(publicLog);
|
|
195
160
|
this.log.trace(`Tracing new public log (counter=${this.sideEffectCounter})`);
|
|
196
161
|
this.incrementSideEffectCounter();
|
|
197
162
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this.
|
|
201
|
-
this.incrementSideEffectCounter();
|
|
202
|
-
}
|
|
203
|
-
traceGetContractClass(contractClassId, exists, contractClass) {
|
|
204
|
-
if (!exists) {
|
|
205
|
-
this.avmCircuitHints.contractClasses.push(new AvmContractClassHint(contractClassId, exists, Fr.zero(), Fr.zero(), Fr.zero(), Buffer.alloc(0)));
|
|
206
|
-
} else if (!this.uniqueClassIds.has(contractClassId.toString())) {
|
|
163
|
+
traceGetContractClass(contractClassId, exists) {
|
|
164
|
+
// We limit the number of unique contract class IDs due to hashing and the trace length limit.
|
|
165
|
+
if (exists && !this.uniqueClassIds.has(contractClassId.toString())) {
|
|
207
166
|
if (this.uniqueClassIds.size() >= MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS) {
|
|
208
167
|
this.log.debug(`Bytecode retrieval failure for contract class ID ${contractClassId} (limit reached)`);
|
|
209
168
|
throw new SideEffectLimitReachedError('contract calls to unique class IDs', MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS);
|
|
210
169
|
}
|
|
170
|
+
this.log.trace(`Adding contract class ID ${contractClassId} (counter=${this.sideEffectCounter})`);
|
|
211
171
|
this.uniqueClassIds.add(contractClassId.toString());
|
|
212
|
-
this.avmCircuitHints.contractClasses.push(new AvmContractClassHint(contractClassId, exists, contractClass.artifactHash, contractClass.privateFunctionsRoot, contractClass.publicBytecodeCommitment, contractClass.packedBytecode));
|
|
213
172
|
this.incrementSideEffectCounter();
|
|
214
173
|
}
|
|
215
174
|
}
|
|
216
|
-
/**
|
|
217
|
-
* Trace an enqueued call.
|
|
218
|
-
* Accept some results from a finished call's trace into this one.
|
|
219
|
-
*/ traceEnqueuedCall(/** The call request from private that enqueued this call. */ publicCallRequest, /** The call's calldata */ calldata, /** Did the call revert? */ _reverted) {
|
|
220
|
-
// TODO(4805): check if some threshold is reached for max enqueued or nested calls (to unique contracts?)
|
|
221
|
-
this.enqueuedCalls.push(publicCallRequest);
|
|
222
|
-
this.avmCircuitHints.enqueuedCalls.push(new AvmEnqueuedCallHint(publicCallRequest.contractAddress, calldata));
|
|
223
|
-
}
|
|
224
175
|
getSideEffects() {
|
|
225
176
|
return {
|
|
226
|
-
enqueuedCalls: this.enqueuedCalls,
|
|
227
177
|
publicDataWrites: this.publicDataWrites,
|
|
228
178
|
noteHashes: this.noteHashes,
|
|
229
179
|
nullifiers: this.nullifiers,
|
|
@@ -231,19 +181,4 @@ export class SideEffectArrayLengths {
|
|
|
231
181
|
publicLogs: this.publicLogs
|
|
232
182
|
};
|
|
233
183
|
}
|
|
234
|
-
toAvmCircuitPublicInputs(/** Globals. */ globalVariables, /** Start tree snapshots. */ startTreeSnapshots, /** Gas used at start of TX. */ startGasUsed, /** How much gas was available for this public execution. */ gasLimits, /** Address of the fee payer. */ feePayer, /** Call requests for setup phase. */ publicSetupCallRequests, /** Call requests for app logic phase. */ publicAppLogicCallRequests, /** Call request for teardown phase. */ publicTeardownCallRequest, /** End tree snapshots. */ endTreeSnapshots, /**
|
|
235
|
-
* Gas used by the whole transaction, assuming entire teardown limit is used.
|
|
236
|
-
* This is the gas used when computing transaction fee.
|
|
237
|
-
*/ endGasUsed, /** Transaction fee. */ transactionFee, /** The call's results */ reverted) {
|
|
238
|
-
return new AvmCircuitPublicInputs(globalVariables, startTreeSnapshots, startGasUsed, gasLimits, feePayer, padArrayEnd(publicSetupCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), padArrayEnd(publicAppLogicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX), publicTeardownCallRequest, /*previousNonRevertibleAccumulatedDataArrayLengths=*/ PrivateToAvmAccumulatedDataArrayLengths.empty(), /*previousRevertibleAccumulatedDataArrayLengths=*/ PrivateToAvmAccumulatedDataArrayLengths.empty(), /*previousNonRevertibleAccumulatedDataArray=*/ PrivateToAvmAccumulatedData.empty(), /*previousRevertibleAccumulatedDataArray=*/ PrivateToAvmAccumulatedData.empty(), endTreeSnapshots, endGasUsed, /*accumulatedData=*/ this.getAvmAccumulatedData(), transactionFee, reverted);
|
|
239
|
-
}
|
|
240
|
-
getPublicLogs() {
|
|
241
|
-
return this.publicLogs;
|
|
242
|
-
}
|
|
243
|
-
getAvmCircuitHints() {
|
|
244
|
-
return this.avmCircuitHints;
|
|
245
|
-
}
|
|
246
|
-
getAvmAccumulatedData() {
|
|
247
|
-
return new AvmAccumulatedData(padArrayEnd(this.noteHashes.map((n)=>n.value), Fr.zero(), MAX_NOTE_HASHES_PER_TX), padArrayEnd(this.nullifiers.map((n)=>n.value), Fr.zero(), MAX_NULLIFIERS_PER_TX), padArrayEnd(this.l2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX), padArrayEnd(this.publicLogs, PublicLog.empty(), MAX_PUBLIC_LOGS_PER_TX), padArrayEnd(this.publicDataWrites.map((w)=>new PublicDataWrite(w.leafSlot, w.newValue)), PublicDataWrite.empty(), MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX));
|
|
248
|
-
}
|
|
249
184
|
}
|
|
@@ -1,34 +1,17 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type { AvmPublicDataReadTreeHint } from '@aztec/stdlib/avm';
|
|
3
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { ContractClassWithCommitment, SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
5
|
-
import type { PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
6
|
-
import type { PublicLog } from '@aztec/stdlib/logs';
|
|
7
|
-
import type { NullifierLeafPreimage, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
8
3
|
export interface PublicSideEffectTraceInterface {
|
|
9
4
|
fork(): PublicSideEffectTraceInterface;
|
|
10
5
|
merge(nestedTrace: PublicSideEffectTraceInterface, reverted?: boolean): void;
|
|
11
6
|
getCounter(): number;
|
|
12
|
-
tracePublicStorageRead(contractAddress: AztecAddress, slot: Fr, value: Fr, leafPreimage?: PublicDataTreeLeafPreimage, leafIndex?: Fr, path?: Fr[]): void;
|
|
13
7
|
tracePublicStorageWrite(contractAddress: AztecAddress, slot: Fr, // This is the storage slot not the computed leaf slot
|
|
14
|
-
value: Fr, protocolWrite: boolean
|
|
15
|
-
|
|
16
|
-
traceNewNoteHash(uniqueNoteHash: Fr
|
|
8
|
+
value: Fr, protocolWrite: boolean): Promise<void>;
|
|
9
|
+
isStorageCold(contractAddress: AztecAddress, slot: Fr): boolean;
|
|
10
|
+
traceNewNoteHash(uniqueNoteHash: Fr): void;
|
|
17
11
|
getNoteHashCount(): number;
|
|
18
|
-
|
|
19
|
-
traceNewNullifier(siloedNullifier: Fr, lowLeafPreimage?: NullifierLeafPreimage, lowLeafIndex?: Fr, lowLeafPath?: Fr[], insertionPath?: Fr[]): void;
|
|
20
|
-
traceL1ToL2MessageCheck(contractAddress: AztecAddress, msgHash: Fr, msgLeafIndex: Fr, exists: boolean, path?: Fr[]): void;
|
|
12
|
+
traceNewNullifier(siloedNullifier: Fr): void;
|
|
21
13
|
traceNewL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
|
|
22
14
|
tracePublicLog(contractAddress: AztecAddress, log: Fr[]): void;
|
|
23
|
-
|
|
24
|
-
traceGetContractClass(contractClassId: Fr, exists: boolean, contractClass?: ContractClassWithCommitment): void;
|
|
25
|
-
traceEnqueuedCall(
|
|
26
|
-
/** The call request from private that enqueued this call. */
|
|
27
|
-
publicCallRequest: PublicCallRequest,
|
|
28
|
-
/** The call's calldata */
|
|
29
|
-
calldata: Fr[],
|
|
30
|
-
/** Did the call revert? */
|
|
31
|
-
reverted: boolean): void;
|
|
32
|
-
getPublicLogs(): PublicLog[];
|
|
15
|
+
traceGetContractClass(contractClassId: Fr, exists: boolean): void;
|
|
33
16
|
}
|
|
34
17
|
//# sourceMappingURL=side_effect_trace_interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side_effect_trace_interface.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_trace_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"side_effect_trace_interface.d.ts","sourceRoot":"","sources":["../../src/public/side_effect_trace_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,WAAW,8BAA8B;IAC7C,IAAI,IAAI,8BAA8B,CAAC;IACvC,KAAK,CAAC,WAAW,EAAE,8BAA8B,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7E,UAAU,IAAI,MAAM,CAAC;IAErB,uBAAuB,CACrB,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,EAAE,EAAE,sDAAsD;IAChE,KAAK,EAAE,EAAE,EACT,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC;IAChE,gBAAgB,CAAC,cAAc,EAAE,EAAE,GAAG,IAAI,CAAC;IAC3C,gBAAgB,IAAI,MAAM,CAAC;IAC3B,iBAAiB,CAAC,eAAe,EAAE,EAAE,GAAG,IAAI,CAAC;IAC7C,qBAAqB,CAAC,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC;IACvF,cAAc,CAAC,eAAe,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;IAC/D,qBAAqB,CAAC,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './state_manager.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
3
3
|
/**
|
|
4
4
|
* A class to manage new nullifier staging and existence checks during a contract call's AVM simulation.
|
|
5
5
|
* Maintains a siloed nullifier cache, and ensures that existence checks fall back to the correct source.
|
|
@@ -14,7 +14,7 @@ export declare class NullifierManager {
|
|
|
14
14
|
private readonly parent?;
|
|
15
15
|
constructor(
|
|
16
16
|
/** Reference to node storage. Checked on parent cache-miss. */
|
|
17
|
-
hostNullifiers:
|
|
17
|
+
hostNullifiers: PublicTreesDB,
|
|
18
18
|
/** Cache of siloed nullifiers. */
|
|
19
19
|
cache?: Set<bigint>,
|
|
20
20
|
/** Parent nullifier manager to fall back on */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullifiers.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/nullifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;GAIG;AACH,qBAAa,gBAAgB;IAEzB,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,kCAAkC;IAClC,OAAO,CAAC,KAAK;IACb,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;;IALxB,+DAA+D;IAC9C,cAAc,EAAE,aAAa;IAC9C,kCAAkC;IAC1B,KAAK,GAAE,GAAG,CAAC,MAAM,CAAa;IACtC,+CAA+C;IAC9B,MAAM,CAAC,EAAE,gBAAgB,YAAA;IAG5C;;OAEG;IACI,IAAI;IAIX;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAW/B;;;;;;;;;;OAUG;IACU,WAAW,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAmB9F;;;;OAIG;IACU,MAAM,CAAC,eAAe,EAAE,EAAE;IAQvC;;;;OAIG;IACI,cAAc,CAAC,kBAAkB,EAAE,gBAAgB;CAU3D;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;CAI5C"}
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
// `${MerkleTreeId[MerkleTreeId.NULLIFIER_TREE]} low leaf index should always be found (even if target leaf does not exist)`,
|
|
54
54
|
//);
|
|
55
55
|
//existsInTree = leafOrLowLeafIndex.alreadyPresent;
|
|
56
|
-
const
|
|
57
|
-
existsInTree =
|
|
56
|
+
const exists = await this.hostNullifiers.checkNullifierExists(siloedNullifier);
|
|
57
|
+
existsInTree = exists;
|
|
58
58
|
}
|
|
59
59
|
const exists = cacheHit || existsInTree;
|
|
60
60
|
return Promise.resolve({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PublicStateDBInterface } from '../db_interfaces.js';
|
|
4
4
|
type PublicStorageReadResult = {
|
|
5
5
|
value: Fr;
|
|
6
6
|
cached: boolean;
|
|
@@ -19,7 +19,7 @@ export declare class PublicStorage {
|
|
|
19
19
|
private readonly cache;
|
|
20
20
|
constructor(
|
|
21
21
|
/** Reference to node storage. Checked on parent cache-miss. */
|
|
22
|
-
hostPublicStorage:
|
|
22
|
+
hostPublicStorage: PublicStateDBInterface,
|
|
23
23
|
/** Parent's storage. Checked on this' cache-miss. */
|
|
24
24
|
parent?: PublicStorage | undefined);
|
|
25
25
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_storage.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/public_storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,EAAE,CAAC;IACV,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,aAAa;IAKtB,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAP1B,6BAA6B;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;;IAGzC,+DAA+D;IAC9C,iBAAiB,EAAE,sBAAsB;IAC1D,qDAAqD;IACpC,MAAM,CAAC,EAAE,aAAa,YAAA;IAKzC;;OAEG;IACI,IAAI;IAIX;;;;;;;OAOG;IACI,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,SAAS;IAWhF;;;;;;;;;;OAUG;IACU,IAAI,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmB5F;;;;;;OAMG;IACI,KAAK,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE;IAI/D;;;;OAIG;IACI,cAAc,CAAC,qBAAqB,EAAE,aAAa;CAG3D"}
|
|
@@ -1,28 +1,17 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import type { IndexedTreeLeafPreimage } from '@aztec/foundation/trees';
|
|
5
|
-
import { AvmPublicDataReadTreeHint } from '@aztec/stdlib/avm';
|
|
6
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { ContractClassPublicWithCommitment } from '@aztec/stdlib/contract';
|
|
7
4
|
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import type {
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
5
|
+
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
6
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
|
+
import type { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
9
|
+
import type { AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
10
|
+
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
11
|
+
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
12
|
+
import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
|
|
15
13
|
import { NullifierManager } from './nullifiers.js';
|
|
16
14
|
import { PublicStorage } from './public_storage.js';
|
|
17
|
-
/**
|
|
18
|
-
* The result of fetching a leaf from an indexed tree. Contains the preimage and wether the leaf was already present
|
|
19
|
-
* or it's a low leaf.
|
|
20
|
-
*/
|
|
21
|
-
type GetLeafResult<T extends IndexedTreeLeafPreimage> = {
|
|
22
|
-
preimage: T;
|
|
23
|
-
leafOrLowLeafIndex: bigint;
|
|
24
|
-
alreadyPresent: boolean;
|
|
25
|
-
};
|
|
26
15
|
/**
|
|
27
16
|
* A class to manage persistable AVM state for contract calls.
|
|
28
17
|
* Maintains a cache of the current world state,
|
|
@@ -32,49 +21,37 @@ type GetLeafResult<T extends IndexedTreeLeafPreimage> = {
|
|
|
32
21
|
*
|
|
33
22
|
* Manages merging of successful/reverted child state into current state.
|
|
34
23
|
*/
|
|
35
|
-
export declare class
|
|
36
|
-
|
|
37
|
-
private readonly
|
|
38
|
-
|
|
39
|
-
readonly
|
|
40
|
-
|
|
24
|
+
export declare class PublicPersistableStateManager {
|
|
25
|
+
private readonly treesDB;
|
|
26
|
+
private readonly contractsDB;
|
|
27
|
+
private readonly trace;
|
|
28
|
+
private readonly firstNullifier;
|
|
29
|
+
private readonly timestamp;
|
|
30
|
+
private readonly doMerkleOperations;
|
|
41
31
|
private readonly publicStorage;
|
|
42
|
-
/** Nullifier set, including cached/recently-emitted nullifiers */
|
|
43
32
|
private readonly nullifiers;
|
|
44
|
-
private readonly doMerkleOperations;
|
|
45
|
-
/** DB interface for merkle tree operations */
|
|
46
|
-
db: MerkleTreeWriteOperations;
|
|
47
|
-
readonly firstNullifier: Fr;
|
|
48
33
|
private readonly log;
|
|
49
34
|
/** Make sure a forked state is never merged twice. */
|
|
50
35
|
private alreadyMergedIntoParent;
|
|
51
|
-
constructor(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** Side effect trace */
|
|
55
|
-
trace: PublicSideEffectTraceInterface,
|
|
56
|
-
/** Public storage, including cached writes */
|
|
57
|
-
publicStorage: PublicStorage,
|
|
58
|
-
/** Nullifier set, including cached/recently-emitted nullifiers */
|
|
59
|
-
nullifiers: NullifierManager, doMerkleOperations: boolean,
|
|
60
|
-
/** DB interface for merkle tree operations */
|
|
61
|
-
db: MerkleTreeWriteOperations, firstNullifier: Fr);
|
|
36
|
+
constructor(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, trace: PublicSideEffectTraceInterface, firstNullifier: Fr, // Needed for note hashes.
|
|
37
|
+
timestamp: UInt64, // Needed for contract updates.
|
|
38
|
+
doMerkleOperations?: boolean, publicStorage?: PublicStorage, nullifiers?: NullifierManager);
|
|
62
39
|
/**
|
|
63
40
|
* Create a new state manager
|
|
64
41
|
*/
|
|
65
|
-
static create(
|
|
42
|
+
static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, trace: PublicSideEffectTraceInterface, doMerkleOperations: boolean | undefined, firstNullifier: Fr, timestamp: UInt64): PublicPersistableStateManager;
|
|
66
43
|
/**
|
|
67
44
|
* Create a new state manager forked from this one
|
|
68
45
|
*/
|
|
69
|
-
fork(): Promise<
|
|
46
|
+
fork(): Promise<PublicPersistableStateManager>;
|
|
70
47
|
/**
|
|
71
48
|
* Accept forked world state modifications & traced side effects / hints
|
|
72
49
|
*/
|
|
73
|
-
merge(forkedState:
|
|
50
|
+
merge(forkedState: PublicPersistableStateManager): Promise<void>;
|
|
74
51
|
/**
|
|
75
52
|
* Reject forked world state modifications & traced side effects, keep traced hints
|
|
76
53
|
*/
|
|
77
|
-
reject(forkedState:
|
|
54
|
+
reject(forkedState: PublicPersistableStateManager): Promise<void>;
|
|
78
55
|
private _merge;
|
|
79
56
|
/**
|
|
80
57
|
* Write to public storage, journal/trace the write.
|
|
@@ -84,28 +61,15 @@ export declare class AvmPersistableStateManager {
|
|
|
84
61
|
* @param value - the value being written to the slot
|
|
85
62
|
*/
|
|
86
63
|
writeStorage(contractAddress: AztecAddress, slot: Fr, value: Fr, protocolWrite?: boolean): Promise<void>;
|
|
64
|
+
isStorageCold(contractAddress: AztecAddress, slot: Fr): boolean;
|
|
87
65
|
/**
|
|
88
|
-
* Read from public storage
|
|
66
|
+
* Read from public storage.
|
|
89
67
|
*
|
|
90
68
|
* @param contractAddress - the address of the contract whose storage is being read from
|
|
91
69
|
* @param slot - the slot in the contract's storage being read from
|
|
92
70
|
* @returns the latest value written to slot, or 0 if never written to before
|
|
93
71
|
*/
|
|
94
72
|
readStorage(contractAddress: AztecAddress, slot: Fr): Promise<Fr>;
|
|
95
|
-
getPublicDataMembership(contractAddress: AztecAddress, slot: Fr): Promise<{
|
|
96
|
-
value: Fr;
|
|
97
|
-
leafPreimage: PublicDataTreeLeafPreimage;
|
|
98
|
-
leafIndex: Fr;
|
|
99
|
-
leafPath: Fr[];
|
|
100
|
-
}>;
|
|
101
|
-
/**
|
|
102
|
-
* Read from public storage, don't trace the read.
|
|
103
|
-
*
|
|
104
|
-
* @param contractAddress - the address of the contract whose storage is being read from
|
|
105
|
-
* @param slot - the slot in the contract's storage being read from
|
|
106
|
-
* @returns the latest value written to slot, or 0 if never written to before
|
|
107
|
-
*/
|
|
108
|
-
peekStorage(contractAddress: AztecAddress, slot: Fr): Promise<Fr>;
|
|
109
73
|
/**
|
|
110
74
|
* Check if a note hash exists at the given leaf index, trace the check.
|
|
111
75
|
*
|
|
@@ -114,7 +78,7 @@ export declare class AvmPersistableStateManager {
|
|
|
114
78
|
* @param leafIndex - the leaf index being checked
|
|
115
79
|
* @returns true if the note hash exists at the given leaf index, false otherwise
|
|
116
80
|
*/
|
|
117
|
-
checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex:
|
|
81
|
+
checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex: bigint): Promise<boolean>;
|
|
118
82
|
/**
|
|
119
83
|
* Write a raw note hash, silo it and make it unique, then trace the write.
|
|
120
84
|
* @param noteHash - the unsiloed note hash to write
|
|
@@ -137,18 +101,6 @@ export declare class AvmPersistableStateManager {
|
|
|
137
101
|
* @returns exists - whether the nullifier exists in the nullifier set
|
|
138
102
|
*/
|
|
139
103
|
checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean>;
|
|
140
|
-
/**
|
|
141
|
-
* Helper to get membership information for a siloed nullifier when checking its existence.
|
|
142
|
-
* Optionally trace the nullifier check.
|
|
143
|
-
*
|
|
144
|
-
* @param siloedNullifier - the siloed nullifier to get membership information for
|
|
145
|
-
* @returns
|
|
146
|
-
* - exists - whether the nullifier exists in the nullifier set
|
|
147
|
-
* - leafOrLowLeafPreimage - the preimage of the nullifier leaf or its low-leaf if it doesn't exist
|
|
148
|
-
* - leafOrLowLeafIndex - the leaf index of the nullifier leaf or its low-leaf if it doesn't exist
|
|
149
|
-
* - leafOrLowLeafPath - the sibling path of the nullifier leaf or its low-leaf if it doesn't exist
|
|
150
|
-
*/
|
|
151
|
-
private getNullifierMembership;
|
|
152
104
|
/**
|
|
153
105
|
* Write a nullifier to the nullifier set, trace the write.
|
|
154
106
|
* @param contractAddress - address of the contract that the nullifier is associated with
|
|
@@ -160,14 +112,13 @@ export declare class AvmPersistableStateManager {
|
|
|
160
112
|
* @param siloedNullifier - the siloed nullifier to write
|
|
161
113
|
*/
|
|
162
114
|
writeSiloedNullifier(siloedNullifier: Fr): Promise<void>;
|
|
163
|
-
writeSiloedNullifiersFromPrivate(siloedNullifiers: Fr[]): Promise<void>;
|
|
164
115
|
/**
|
|
165
116
|
* Check if an L1 to L2 message exists, trace the check.
|
|
166
117
|
* @param msgHash - the message hash to check existence of
|
|
167
118
|
* @param msgLeafIndex - the message leaf index to use in the check
|
|
168
119
|
* @returns exists - whether the message exists in the L1 to L2 Messages tree
|
|
169
120
|
*/
|
|
170
|
-
checkL1ToL2MessageExists(
|
|
121
|
+
checkL1ToL2MessageExists(msgHash: Fr, msgLeafIndex: Fr): Promise<boolean>;
|
|
171
122
|
/**
|
|
172
123
|
* Write an L2 to L1 message.
|
|
173
124
|
* @param contractAddress - L2 contract address that created this message
|
|
@@ -175,6 +126,11 @@ export declare class AvmPersistableStateManager {
|
|
|
175
126
|
* @param content - Message content.
|
|
176
127
|
*/
|
|
177
128
|
writeL2ToL1Message(contractAddress: AztecAddress, recipient: Fr, content: Fr): void;
|
|
129
|
+
/**
|
|
130
|
+
* Write a scoped L2 to L1 message.
|
|
131
|
+
* @param l2ToL1Message - The L2 to L1 message to write.
|
|
132
|
+
*/
|
|
133
|
+
writeScopedL2ToL1Message(l2ToL1Message: ScopedL2ToL1Message): void;
|
|
178
134
|
/**
|
|
179
135
|
* Write a public log
|
|
180
136
|
* @param contractAddress - address of the contract that emitted the log
|
|
@@ -187,23 +143,19 @@ export declare class AvmPersistableStateManager {
|
|
|
187
143
|
* @returns the contract instance or undefined if it does not exist.
|
|
188
144
|
*/
|
|
189
145
|
getContractInstance(contractAddress: AztecAddress): Promise<SerializableContractInstance | undefined>;
|
|
146
|
+
private checkContractUpdateInformation;
|
|
190
147
|
/**
|
|
191
148
|
* Get a contract class.
|
|
192
149
|
* @param classId - class id to retrieve.
|
|
193
150
|
* @returns the contract class or undefined if it does not exist.
|
|
194
151
|
*/
|
|
195
|
-
getContractClass(classId: Fr): Promise<
|
|
152
|
+
getContractClass(classId: Fr): Promise<ContractClassPublicWithCommitment | undefined>;
|
|
196
153
|
/**
|
|
197
154
|
* Get a contract's bytecode from the contracts DB, also trace the contract class and instance indirectly.
|
|
198
155
|
*/
|
|
199
156
|
getBytecode(contractAddress: AztecAddress): Promise<Buffer | undefined>;
|
|
200
|
-
getContractUpdateHints(contractAddress: AztecAddress): Promise<{
|
|
201
|
-
updateMembership: AvmPublicDataReadTreeHint;
|
|
202
|
-
updatePreimage: Fr[];
|
|
203
|
-
}>;
|
|
204
|
-
traceEnqueuedCall(publicCallRequest: PublicCallRequest, calldata: Fr[], reverted: boolean): void;
|
|
205
157
|
getPublicFunctionDebugName(avmEnvironment: AvmExecutionEnvironment): Promise<string>;
|
|
206
|
-
|
|
158
|
+
padTree(treeId: MerkleTreeId, leavesToInsert: number): Promise<void>;
|
|
159
|
+
getTreeSnapshots(): Promise<TreeSnapshots>;
|
|
207
160
|
}
|
|
208
|
-
|
|
209
|
-
//# sourceMappingURL=journal.d.ts.map
|
|
161
|
+
//# sourceMappingURL=state_manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state_manager.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/state_manager.ts"],"names":[],"mappings":"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"}
|