@aztec/simulator 0.0.0-test.1 → 0.0.1-commit.24de95ac
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} +9 -10
- package/dest/private/acvm_native.d.ts.map +1 -0
- package/dest/private/{providers/acvm_native.js → acvm_native.js} +26 -20
- 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 +3 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +7 -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 +23 -35
- 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 +6 -30
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +7 -57
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +5 -4
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +12 -14
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +6 -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 +37 -14
- 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 +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +28 -25
- 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 +46 -26
- 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 +267 -3
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +6 -6
- 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 +17 -19
- 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 -34
- 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 +23 -19
- 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 +2 -1
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +41 -16
- 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 +13 -4
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +70 -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 +16 -24
- 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 +326 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +12 -0
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tester.js +29 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +9 -0
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -0
- package/dest/public/fixtures/custom_bytecode_tests.js +109 -0
- package/dest/public/fixtures/index.d.ts +7 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +7 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts +10 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -0
- package/dest/public/fixtures/minimal_public_tx.js +29 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +35 -13
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +96 -71
- 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 +70 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +297 -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 +151 -67
- package/dest/public/public_errors.d.ts +12 -0
- package/dest/public/public_errors.d.ts.map +1 -0
- package/dest/public/public_errors.js +13 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +49 -0
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -0
- package/dest/public/public_processor/guarded_merkle_tree.js +108 -0
- package/dest/public/public_processor/public_processor.d.ts +25 -30
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +141 -96
- 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/cpp_public_tx_simulator.d.ts +41 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +89 -0
- package/dest/public/public_tx_simulator/index.d.ts +4 -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 +24 -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 +51 -0
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +19 -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 +63 -91
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +45 -47
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +209 -184
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +9 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.js +1 -0
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +21 -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_errors.d.ts +41 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/side_effect_errors.js +70 -1
- package/dest/public/side_effect_trace.d.ts +20 -65
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +71 -121
- package/dest/public/side_effect_trace_interface.d.ts +11 -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 -5
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -0
- package/dest/public/{avm/journal → state_manager}/nullifiers.js +3 -8
- 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} +42 -85
- package/dest/public/state_manager/state_manager.d.ts.map +1 -0
- package/dest/public/state_manager/state_manager.js +391 -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 +36 -31
- 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} +47 -24
- 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 +10 -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 +44 -54
- package/src/public/avm/avm_simulator_interface.ts +8 -0
- package/src/public/avm/errors.ts +8 -77
- package/src/public/avm/fixtures/avm_simulation_tester.ts +23 -20
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +45 -12
- package/src/public/avm/fixtures/initializers.ts +104 -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 +64 -29
- package/src/public/avm/opcodes/addressing_mode.ts +56 -32
- 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 +27 -3
- package/src/public/avm/opcodes/ec_add.ts +9 -6
- package/src/public/avm/opcodes/environment_getters.ts +27 -22
- package/src/public/avm/opcodes/external_calls.ts +61 -29
- package/src/public/avm/opcodes/hashing.ts +28 -8
- package/src/public/avm/opcodes/instruction.ts +31 -21
- package/src/public/avm/opcodes/memory.ts +71 -32
- package/src/public/avm/opcodes/misc.ts +60 -18
- 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 +75 -34
- package/src/public/avm/test_utils.ts +24 -41
- 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 +169 -0
- package/src/public/fixtures/custom_bytecode_tester.ts +49 -0
- package/src/public/fixtures/custom_bytecode_tests.ts +135 -0
- package/src/public/fixtures/index.ts +7 -0
- package/src/public/fixtures/minimal_public_tx.ts +36 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +158 -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 +505 -0
- package/src/public/index.ts +9 -8
- package/src/public/public_db_sources.ts +196 -97
- package/src/public/public_errors.ts +14 -0
- package/src/public/public_processor/guarded_merkle_tree.ts +153 -0
- package/src/public/public_processor/public_processor.ts +191 -153
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +128 -0
- package/src/public/public_tx_simulator/index.ts +3 -0
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +109 -0
- package/src/public/public_tx_simulator/public_tx_context.ts +160 -193
- package/src/public/public_tx_simulator/public_tx_simulator.ts +294 -220
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +11 -0
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +63 -0
- package/src/public/side_effect_errors.ts +91 -1
- package/src/public/side_effect_trace.ts +94 -320
- package/src/public/side_effect_trace_interface.ts +10 -58
- package/src/public/state_manager/index.ts +1 -0
- package/src/public/{avm/journal → state_manager}/nullifiers.ts +5 -11
- package/src/public/{avm/journal → state_manager}/public_storage.ts +2 -2
- package/src/public/state_manager/state_manager.ts +560 -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/bytecode_errors.d.ts +0 -4
- package/dest/public/bytecode_errors.d.ts.map +0 -1
- package/dest/public/bytecode_errors.js +0 -6
- package/dest/public/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/bytecode_errors.ts +0 -6
- 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
|
@@ -2,16 +2,18 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
2
2
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
|
-
import type {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
|
+
import { TreeSnapshots, type Tx } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
9
|
+
import type { PublicContractsDBInterface, PublicStateDBInterface } from './db_interfaces.js';
|
|
8
10
|
/**
|
|
9
|
-
* Implements the
|
|
11
|
+
* Implements the PublicContractsDBInterface using a ContractDataSource.
|
|
10
12
|
* Progressively records contracts in transaction as they are processed in a block.
|
|
11
13
|
* Separates block-level contract information (from processed/included txs) from the
|
|
12
14
|
* current tx's contract information (which may be cleared on tx revert/death).
|
|
13
15
|
*/
|
|
14
|
-
export declare class
|
|
16
|
+
export declare class PublicContractsDB implements PublicContractsDBInterface {
|
|
15
17
|
private dataSource;
|
|
16
18
|
private currentTxNonRevertibleCache;
|
|
17
19
|
private currentTxRevertibleCache;
|
|
@@ -81,49 +83,38 @@ export declare class ContractsDataSourcePublicDB implements PublicContractsDB {
|
|
|
81
83
|
* Then, clears the tx cache.
|
|
82
84
|
*/
|
|
83
85
|
commitContractsForTx(onlyNonRevertibles?: boolean): void;
|
|
84
|
-
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
86
|
+
getContractInstance(address: AztecAddress, timestamp: UInt64): Promise<ContractInstanceWithAddress | undefined>;
|
|
85
87
|
getContractClass(contractClassId: Fr): Promise<ContractClassPublic | undefined>;
|
|
86
88
|
getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined>;
|
|
87
89
|
getDebugFunctionName(address: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
|
|
88
90
|
}
|
|
89
91
|
/**
|
|
90
|
-
* A
|
|
92
|
+
* A high-level class that provides access to the merkle trees.
|
|
93
|
+
*
|
|
94
|
+
* This class is just a helper wrapper around a merkle db. Anything that you can do with it
|
|
95
|
+
* can also be done directly with the merkle db. This class should NOT be exposed or used
|
|
96
|
+
* outside of `simulator/src/public`.
|
|
97
|
+
*
|
|
98
|
+
* NOTE: This class is currently written in such a way that it would generate the
|
|
99
|
+
* necessary hints if used with a hinting merkle db. This is a bit of a leak of concepts.
|
|
100
|
+
* Eventually we can have everything depend on a config/factory at the TxSimulator level
|
|
101
|
+
* to decide whether to use hints or not (same with tracing, etc).
|
|
91
102
|
*/
|
|
92
|
-
export declare class
|
|
93
|
-
db
|
|
103
|
+
export declare class PublicTreesDB implements PublicStateDBInterface {
|
|
104
|
+
private readonly db;
|
|
94
105
|
private logger;
|
|
95
|
-
constructor(db: MerkleTreeWriteOperations
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
constructor(db: MerkleTreeWriteOperations);
|
|
107
|
+
storageRead(contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
108
|
+
storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<void>;
|
|
109
|
+
getL1ToL2LeafValue(leafIndex: bigint): Promise<Fr>;
|
|
110
|
+
getNoteHash(leafIndex: bigint): Promise<Fr>;
|
|
111
|
+
writeNoteHash(noteHash: Fr): Promise<void>;
|
|
112
|
+
checkNullifierExists(nullifier: Fr): Promise<boolean>;
|
|
113
|
+
writeNullifier(siloedNullifier: Fr): Promise<void>;
|
|
114
|
+
padTree(treeId: MerkleTreeId, leavesToInsert: number): Promise<void>;
|
|
99
115
|
createCheckpoint(): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Commits the current checkpoint
|
|
102
|
-
*/
|
|
103
116
|
commitCheckpoint(): Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Reverts the current checkpoint
|
|
106
|
-
*/
|
|
107
117
|
revertCheckpoint(): Promise<void>;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Reads a value from public storage, returning zero if none.
|
|
111
|
-
* @param contract - Owner of the storage.
|
|
112
|
-
* @param slot - Slot to read in the contract storage.
|
|
113
|
-
* @returns The current value in the storage slot.
|
|
114
|
-
*/
|
|
115
|
-
storageRead(contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
116
|
-
/**
|
|
117
|
-
* Records a write to public storage.
|
|
118
|
-
* @param contract - Owner of the storage.
|
|
119
|
-
* @param slot - Slot to read in the contract storage.
|
|
120
|
-
* @param newValue - The new value to store.
|
|
121
|
-
* @returns The slot of the written leaf in the public data tree.
|
|
122
|
-
*/
|
|
123
|
-
storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<void>;
|
|
124
|
-
getL1ToL2LeafValue(leafIndex: bigint): Promise<Fr | undefined>;
|
|
125
|
-
getCommitmentValue(leafIndex: bigint): Promise<Fr | undefined>;
|
|
126
|
-
getNullifierIndex(nullifier: Fr): Promise<bigint | undefined>;
|
|
118
|
+
getTreeSnapshots(): Promise<TreeSnapshots>;
|
|
127
119
|
}
|
|
128
|
-
export declare function readPublicState(db: MerkleTreeReadOperations, contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
129
120
|
//# sourceMappingURL=public_db_sources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_db_sources.d.ts","sourceRoot":"","sources":["../../src/public/public_db_sources.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public_db_sources.d.ts","sourceRoot":"","sources":["../../src/public/public_db_sources.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,EACL,YAAY,EAKb,MAAM,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AF_COUNT, NULLIFIER_SUBTREE_HEIGHT, PUBLIC_DATA_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
6
|
+
import { ContractInstancePublishedEvent } from '@aztec/protocol-contracts/instance-registry';
|
|
6
7
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
7
8
|
import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
8
9
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
9
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
10
|
+
import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf, getTreeName } from '@aztec/stdlib/trees';
|
|
11
|
+
import { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
12
|
+
import { strict as assert } from 'assert';
|
|
13
|
+
import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from './side_effect_errors.js';
|
|
10
14
|
import { TxContractCache } from './tx_contract_cache.js';
|
|
11
15
|
/**
|
|
12
|
-
* Implements the
|
|
16
|
+
* Implements the PublicContractsDBInterface using a ContractDataSource.
|
|
13
17
|
* Progressively records contracts in transaction as they are processed in a block.
|
|
14
18
|
* Separates block-level contract information (from processed/included txs) from the
|
|
15
19
|
* current tx's contract information (which may be cleared on tx revert/death).
|
|
16
|
-
*/ export class
|
|
20
|
+
*/ export class PublicContractsDB {
|
|
17
21
|
dataSource;
|
|
18
22
|
// Two caching layers for contract classes and instances.
|
|
19
23
|
// Tx-level cache:
|
|
@@ -64,7 +68,7 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
64
68
|
* For private-only txs, this will be all contract classes (found in tx.data.forPublic)
|
|
65
69
|
* @param tx - The transaction to add non-revertible contract classes from.
|
|
66
70
|
*/ async addNonRevertibleContractClasses(tx) {
|
|
67
|
-
const siloedContractClassLogs = tx.data.forPublic ?
|
|
71
|
+
const siloedContractClassLogs = tx.data.forPublic ? tx.getSplitContractClassLogs(false) : tx.getContractClassLogs();
|
|
68
72
|
await this.addContractClassesFromLogs(siloedContractClassLogs, this.currentTxNonRevertibleCache, 'non-revertible');
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
@@ -72,7 +76,7 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
72
76
|
* None for private-only txs.
|
|
73
77
|
* @param tx - The transaction to add revertible contract classes from.
|
|
74
78
|
*/ async addRevertibleContractClasses(tx) {
|
|
75
|
-
const siloedContractClassLogs = tx.data.forPublic ?
|
|
79
|
+
const siloedContractClassLogs = tx.data.forPublic ? tx.getSplitContractClassLogs(true) : [];
|
|
76
80
|
await this.addContractClassesFromLogs(siloedContractClassLogs, this.currentTxRevertibleCache, 'revertible');
|
|
77
81
|
}
|
|
78
82
|
/**
|
|
@@ -97,7 +101,7 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
97
101
|
* @param cache - The cache to store the contract classes in
|
|
98
102
|
* @param cacheType - Type of cache (for logging)
|
|
99
103
|
*/ async addContractClassesFromLogs(siloedContractClassLogs, cache, cacheType) {
|
|
100
|
-
const contractClassEvents = siloedContractClassLogs.filter((log)=>
|
|
104
|
+
const contractClassEvents = siloedContractClassLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log));
|
|
101
105
|
// Cache contract classes
|
|
102
106
|
await Promise.all(contractClassEvents.map(async (event)=>{
|
|
103
107
|
this.log.debug(`Adding class ${event.contractClassId.toString()} to contract's ${cacheType} tx cache`);
|
|
@@ -111,7 +115,7 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
111
115
|
* @param cache - The cache to store the contract instances in
|
|
112
116
|
* @param cacheType - Type of cache (for logging)
|
|
113
117
|
*/ addContractInstancesFromLogs(contractInstanceLogs, cache, cacheType) {
|
|
114
|
-
const contractInstanceEvents = contractInstanceLogs.filter((log)=>
|
|
118
|
+
const contractInstanceEvents = contractInstanceLogs.filter((log)=>ContractInstancePublishedEvent.isContractInstancePublishedEvent(log)).map((log)=>ContractInstancePublishedEvent.fromLog(log));
|
|
115
119
|
// Cache contract instances
|
|
116
120
|
contractInstanceEvents.forEach((e)=>{
|
|
117
121
|
this.log.debug(`Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to ${cacheType} tx contract cache`);
|
|
@@ -139,9 +143,18 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
139
143
|
this.currentTxNonRevertibleCache.clear();
|
|
140
144
|
this.currentTxRevertibleCache.clear();
|
|
141
145
|
}
|
|
142
|
-
|
|
146
|
+
// TODO(fcarreiro/alvaro): This method currently needs a blockNumber. Since this class
|
|
147
|
+
// is only ever used for a given block, it should be possible to construct it with the
|
|
148
|
+
// block number and then forget about it. However, since this class (and interface) is
|
|
149
|
+
// currently more externally exposed than we'd want to, Facundo preferred to not add it
|
|
150
|
+
// to the constructor right now. If we can make this class more private, we should
|
|
151
|
+
// reconsider this. A litmus test is in how many places we need to initialize with a
|
|
152
|
+
// dummy block number (tests or not) and pass block numbers to `super`.
|
|
153
|
+
// Note: Block number got changed to timestamp so this comment ^ is outdated. Keeping
|
|
154
|
+
// the comment as is as I am not part of the AVM cabal.
|
|
155
|
+
async getContractInstance(address, timestamp) {
|
|
143
156
|
// Check caches in order: tx revertible -> tx non-revertible -> block -> data source
|
|
144
|
-
return this.currentTxRevertibleCache.getInstance(address) ?? this.currentTxNonRevertibleCache.getInstance(address) ?? this.blockCache.getInstance(address) ?? await this.dataSource.getContract(address);
|
|
157
|
+
return this.currentTxRevertibleCache.getInstance(address) ?? this.currentTxNonRevertibleCache.getInstance(address) ?? this.blockCache.getInstance(address) ?? await this.dataSource.getContract(address, timestamp);
|
|
145
158
|
}
|
|
146
159
|
async getContractClass(contractClassId) {
|
|
147
160
|
// Check caches in order: tx revertible -> tx non-revertible -> block -> data source
|
|
@@ -170,95 +183,166 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
170
183
|
return value;
|
|
171
184
|
}
|
|
172
185
|
async getDebugFunctionName(address, selector) {
|
|
173
|
-
return await this.dataSource.
|
|
186
|
+
return await this.dataSource.getDebugFunctionName(address, selector);
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
189
|
/**
|
|
177
|
-
* A
|
|
178
|
-
|
|
190
|
+
* A high-level class that provides access to the merkle trees.
|
|
191
|
+
*
|
|
192
|
+
* This class is just a helper wrapper around a merkle db. Anything that you can do with it
|
|
193
|
+
* can also be done directly with the merkle db. This class should NOT be exposed or used
|
|
194
|
+
* outside of `simulator/src/public`.
|
|
195
|
+
*
|
|
196
|
+
* NOTE: This class is currently written in such a way that it would generate the
|
|
197
|
+
* necessary hints if used with a hinting merkle db. This is a bit of a leak of concepts.
|
|
198
|
+
* Eventually we can have everything depend on a config/factory at the TxSimulator level
|
|
199
|
+
* to decide whether to use hints or not (same with tracing, etc).
|
|
200
|
+
*/ export class PublicTreesDB {
|
|
179
201
|
db;
|
|
180
202
|
logger;
|
|
181
|
-
constructor(db
|
|
182
|
-
|
|
203
|
+
constructor(db){
|
|
204
|
+
this.db = db;
|
|
205
|
+
this.logger = createLogger('simulator:public-trees-db');
|
|
183
206
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
await this.db.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
await this.db.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Reads a value from public storage, returning zero if none.
|
|
204
|
-
* @param contract - Owner of the storage.
|
|
205
|
-
* @param slot - Slot to read in the contract storage.
|
|
206
|
-
* @returns The current value in the storage slot.
|
|
207
|
-
*/ async storageRead(contract, slot) {
|
|
208
|
-
return await readPublicState(this.db, contract, slot);
|
|
207
|
+
async storageRead(contract, slot) {
|
|
208
|
+
const timer = new Timer();
|
|
209
|
+
const leafSlot = (await computePublicDataTreeLeafSlot(contract, slot)).toBigInt();
|
|
210
|
+
const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
|
|
211
|
+
if (!lowLeafResult) {
|
|
212
|
+
throw new Error('Low leaf not found');
|
|
213
|
+
}
|
|
214
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
215
|
+
await this.db.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
216
|
+
// Unconditionally fetching the preimage for the hints. Move it to the hinting layer?
|
|
217
|
+
const preimage = await this.db.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
218
|
+
const result = lowLeafResult.alreadyPresent ? preimage.leaf.value : Fr.ZERO;
|
|
219
|
+
this.logger.debug(`Storage read (contract=${contract}, slot=${slot}, value=${result})`, {
|
|
220
|
+
eventName: 'public-db-access',
|
|
221
|
+
duration: timer.ms(),
|
|
222
|
+
operation: 'storage-read'
|
|
223
|
+
});
|
|
224
|
+
return result;
|
|
209
225
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
* @param contract - Owner of the storage.
|
|
213
|
-
* @param slot - Slot to read in the contract storage.
|
|
214
|
-
* @param newValue - The new value to store.
|
|
215
|
-
* @returns The slot of the written leaf in the public data tree.
|
|
216
|
-
*/ async storageWrite(contract, slot, newValue) {
|
|
226
|
+
async storageWrite(contract, slot, newValue) {
|
|
227
|
+
const timer = new Timer();
|
|
217
228
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
218
229
|
const publicDataWrite = new PublicDataWrite(leafSlot, newValue);
|
|
219
230
|
await this.db.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
|
|
220
231
|
publicDataWrite.toBuffer()
|
|
221
232
|
]);
|
|
233
|
+
this.logger.debug(`Storage write (contract=${contract}, slot=${slot}, value=${newValue})`, {
|
|
234
|
+
eventName: 'public-db-access',
|
|
235
|
+
duration: timer.ms(),
|
|
236
|
+
operation: 'storage-write'
|
|
237
|
+
});
|
|
222
238
|
}
|
|
223
239
|
async getL1ToL2LeafValue(leafIndex) {
|
|
224
240
|
const timer = new Timer();
|
|
241
|
+
if (leafIndex > L1_TO_L2_MSG_TREE_LEAF_COUNT) {
|
|
242
|
+
throw new L1ToL2MessageIndexOutOfRangeError(Number(leafIndex));
|
|
243
|
+
}
|
|
225
244
|
const leafValue = await this.db.getLeafValue(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
226
|
-
|
|
245
|
+
assert(leafValue !== undefined, 'Unexpected null response from l1 to l2 message tree');
|
|
246
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
247
|
+
await this.db.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
248
|
+
this.logger.debug(`Fetched L1 to L2 message leaf value (leafIndex=${leafIndex}, value=${leafValue})`, {
|
|
227
249
|
eventName: 'public-db-access',
|
|
228
250
|
duration: timer.ms(),
|
|
229
251
|
operation: 'get-l1-to-l2-message-leaf-value'
|
|
230
252
|
});
|
|
231
253
|
return leafValue;
|
|
232
254
|
}
|
|
233
|
-
async
|
|
255
|
+
async getNoteHash(leafIndex) {
|
|
234
256
|
const timer = new Timer();
|
|
257
|
+
if (leafIndex > NOTE_HASH_TREE_LEAF_COUNT) {
|
|
258
|
+
throw new NoteHashIndexOutOfRangeError(Number(leafIndex));
|
|
259
|
+
}
|
|
235
260
|
const leafValue = await this.db.getLeafValue(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
236
|
-
|
|
261
|
+
assert(leafValue !== undefined, 'Unexpected null response from note hash tree');
|
|
262
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
263
|
+
await this.db.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
264
|
+
this.logger.debug(`Fetched note hash leaf value (leafIndex=${leafIndex}, value=${leafValue})`, {
|
|
237
265
|
eventName: 'public-db-access',
|
|
238
266
|
duration: timer.ms(),
|
|
239
|
-
operation: 'get-
|
|
267
|
+
operation: 'get-note-hash'
|
|
240
268
|
});
|
|
241
269
|
return leafValue;
|
|
242
270
|
}
|
|
243
|
-
async
|
|
271
|
+
async writeNoteHash(noteHash) {
|
|
244
272
|
const timer = new Timer();
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
])
|
|
248
|
-
this.logger.debug(`
|
|
273
|
+
await this.db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, [
|
|
274
|
+
noteHash
|
|
275
|
+
]);
|
|
276
|
+
this.logger.debug(`Wrote note hash (noteHash=${noteHash})`, {
|
|
249
277
|
eventName: 'public-db-access',
|
|
250
278
|
duration: timer.ms(),
|
|
251
|
-
operation: '
|
|
279
|
+
operation: 'write-note-hash'
|
|
252
280
|
});
|
|
253
|
-
return index;
|
|
254
281
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
282
|
+
async checkNullifierExists(nullifier) {
|
|
283
|
+
const timer = new Timer();
|
|
284
|
+
const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
285
|
+
if (!lowLeafResult) {
|
|
286
|
+
throw new Error('Low leaf not found');
|
|
287
|
+
}
|
|
288
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
289
|
+
await this.db.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
|
|
290
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
291
|
+
await this.db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
|
|
292
|
+
const exists = lowLeafResult.alreadyPresent;
|
|
293
|
+
this.logger.debug(`Checked nullifier exists (nullifier=${nullifier}, exists=${exists})`, {
|
|
294
|
+
eventName: 'public-db-access',
|
|
295
|
+
duration: timer.ms(),
|
|
296
|
+
operation: 'check-nullifier-exists'
|
|
297
|
+
});
|
|
298
|
+
return exists;
|
|
299
|
+
}
|
|
300
|
+
async writeNullifier(siloedNullifier) {
|
|
301
|
+
const timer = new Timer();
|
|
302
|
+
await this.db.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
|
|
303
|
+
siloedNullifier.toBuffer()
|
|
304
|
+
]);
|
|
305
|
+
this.logger.debug(`Wrote nullifier (nullifier=${siloedNullifier})`, {
|
|
306
|
+
eventName: 'public-db-access',
|
|
307
|
+
duration: timer.ms(),
|
|
308
|
+
operation: 'write-nullifier'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async padTree(treeId, leavesToInsert) {
|
|
312
|
+
const timer = new Timer();
|
|
313
|
+
switch(treeId){
|
|
314
|
+
// Indexed trees.
|
|
315
|
+
case MerkleTreeId.NULLIFIER_TREE:
|
|
316
|
+
await this.db.batchInsert(treeId, Array(leavesToInsert).fill(NullifierLeaf.empty().toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
317
|
+
break;
|
|
318
|
+
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
319
|
+
await this.db.batchInsert(treeId, Array(leavesToInsert).fill(PublicDataTreeLeaf.empty().toBuffer()), PUBLIC_DATA_SUBTREE_HEIGHT);
|
|
320
|
+
break;
|
|
321
|
+
// Append-only trees.
|
|
322
|
+
case MerkleTreeId.L1_TO_L2_MESSAGE_TREE:
|
|
323
|
+
case MerkleTreeId.NOTE_HASH_TREE:
|
|
324
|
+
await this.db.appendLeaves(treeId, Array(leavesToInsert).fill(Fr.ZERO));
|
|
325
|
+
break;
|
|
326
|
+
default:
|
|
327
|
+
throw new Error(`Padding not supported for tree ${treeId}`);
|
|
328
|
+
}
|
|
329
|
+
this.logger.debug(`Padded tree (tree=${getTreeName(treeId)}, leavesToInsert=${leavesToInsert})`, {
|
|
330
|
+
eventName: 'public-db-access',
|
|
331
|
+
duration: timer.ms(),
|
|
332
|
+
operation: 'pad-tree'
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
async createCheckpoint() {
|
|
336
|
+
await this.db.createCheckpoint();
|
|
337
|
+
}
|
|
338
|
+
async commitCheckpoint() {
|
|
339
|
+
await this.db.commitCheckpoint();
|
|
340
|
+
}
|
|
341
|
+
async revertCheckpoint() {
|
|
342
|
+
await this.db.revertCheckpoint();
|
|
343
|
+
}
|
|
344
|
+
async getTreeSnapshots() {
|
|
345
|
+
const stateReference = await this.db.getStateReference();
|
|
346
|
+
return new TreeSnapshots(stateReference.l1ToL2MessageTree, stateReference.partial.noteHashTree, stateReference.partial.nullifierTree, stateReference.partial.publicDataTree);
|
|
261
347
|
}
|
|
262
|
-
const preimage = await db.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
263
|
-
return preimage.value;
|
|
264
348
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any known (and checked) error that can be thrown during public execution.
|
|
3
|
+
* Includes AvmExecutionErrors and SideEffectErrors.
|
|
4
|
+
*
|
|
5
|
+
* AvmSimulator catches any checked errors before returning a boolean "reverted".
|
|
6
|
+
* Unchecked errors are generally the result of a bug. They are propagated and
|
|
7
|
+
* ultimately will be the resonsibility of PublicProcessor to handle.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class CheckedPublicExecutionError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=public_errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_errors.d.ts","sourceRoot":"","sources":["../../src/public/public_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,8BAAsB,2BAA4B,SAAQ,KAAK;gBACjD,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any known (and checked) error that can be thrown during public execution.
|
|
3
|
+
* Includes AvmExecutionErrors and SideEffectErrors.
|
|
4
|
+
*
|
|
5
|
+
* AvmSimulator catches any checked errors before returning a boolean "reverted".
|
|
6
|
+
* Unchecked errors are generally the result of a bug. They are propagated and
|
|
7
|
+
* ultimately will be the resonsibility of PublicProcessor to handle.
|
|
8
|
+
*/ export class CheckedPublicExecutionError extends Error {
|
|
9
|
+
constructor(message){
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'CheckedPublicExecutionError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
2
|
+
import type { BatchInsertionResult, IndexedTreeId, MerkleTreeId, MerkleTreeLeafType, MerkleTreeWriteOperations, SequentialInsertionResult, TreeHeights, TreeInfo } from '@aztec/stdlib/trees';
|
|
3
|
+
import type { BlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { WorldStateRevision } from '@aztec/stdlib/world-state';
|
|
5
|
+
/**
|
|
6
|
+
* Wraps an instance of `MerkleTreeWriteOperations` to allow the sequencer to gate access.
|
|
7
|
+
* If transactions execution goes past the deadline, the simulator will continue to execute and update the world state
|
|
8
|
+
* The public processor however requires that the world state remain constant after the deadline in order to finalize the block
|
|
9
|
+
* The public processor provides this implementation of MerkleTreeWriteOperations to the simulator
|
|
10
|
+
*/
|
|
11
|
+
export declare class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
12
|
+
private target;
|
|
13
|
+
private isStopped;
|
|
14
|
+
private serialQueue;
|
|
15
|
+
constructor(target: MerkleTreeWriteOperations);
|
|
16
|
+
private guard;
|
|
17
|
+
private guardAndPush;
|
|
18
|
+
getUnderlyingFork(): MerkleTreeWriteOperations;
|
|
19
|
+
stop(): Promise<void>;
|
|
20
|
+
appendLeaves<ID extends MerkleTreeId>(treeId: ID, leaves: MerkleTreeLeafType<ID>[]): Promise<void>;
|
|
21
|
+
updateArchive(header: BlockHeader): Promise<void>;
|
|
22
|
+
batchInsert<TreeHeight extends number, SubtreeSiblingPathHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[], subtreeHeight: number): Promise<BatchInsertionResult<TreeHeight, SubtreeSiblingPathHeight>>;
|
|
23
|
+
sequentialInsert<TreeHeight extends number, ID extends IndexedTreeId>(treeId: ID, leaves: Buffer[]): Promise<SequentialInsertionResult<TreeHeight>>;
|
|
24
|
+
close(): Promise<void>;
|
|
25
|
+
getTreeInfo(treeId: MerkleTreeId): Promise<TreeInfo>;
|
|
26
|
+
getStateReference(): Promise<StateReference>;
|
|
27
|
+
getInitialHeader(): BlockHeader;
|
|
28
|
+
getRevision(): WorldStateRevision;
|
|
29
|
+
getSiblingPath<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<SiblingPath<TreeHeights[ID]>>;
|
|
30
|
+
getPreviousValueIndex<ID extends IndexedTreeId>(treeId: ID, value: bigint): Promise<{
|
|
31
|
+
index: bigint;
|
|
32
|
+
alreadyPresent: boolean;
|
|
33
|
+
} | undefined>;
|
|
34
|
+
getLeafPreimage<ID extends IndexedTreeId>(treeId: ID, index: bigint): Promise<IndexedTreeLeafPreimage | undefined>;
|
|
35
|
+
findLeafIndices<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<(bigint | undefined)[]>;
|
|
36
|
+
findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
|
|
37
|
+
getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
|
|
38
|
+
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(treeId: ID, leafIndices: bigint[]): Promise<(bigint | undefined)[]>;
|
|
39
|
+
createCheckpoint(): Promise<void>;
|
|
40
|
+
commitCheckpoint(): Promise<void>;
|
|
41
|
+
revertCheckpoint(): Promise<void>;
|
|
42
|
+
commitAllCheckpoints(): Promise<void>;
|
|
43
|
+
revertAllCheckpoints(): Promise<void>;
|
|
44
|
+
findSiblingPaths<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<({
|
|
45
|
+
path: SiblingPath<TreeHeights[ID]>;
|
|
46
|
+
index: bigint;
|
|
47
|
+
} | undefined)[]>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=guarded_merkle_tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guarded_merkle_tree.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/guarded_merkle_tree.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;GAKG;AAEH,qBAAa,2BAA4B,YAAW,yBAAyB;IAI/D,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAqB;gBAEpB,MAAM,EAAE,yBAAyB;IAIrD,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,YAAY;IAQb,iBAAiB,IAAI,yBAAyB;IAK/C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,YAAY,CAAC,EAAE,SAAS,YAAY,EAAE,MAAM,EAAE,EAA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} from '@aztec/foundation/queue';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an instance of `MerkleTreeWriteOperations` to allow the sequencer to gate access.
|
|
4
|
+
* If transactions execution goes past the deadline, the simulator will continue to execute and update the world state
|
|
5
|
+
* The public processor however requires that the world state remain constant after the deadline in order to finalize the block
|
|
6
|
+
* The public processor provides this implementation of MerkleTreeWriteOperations to the simulator
|
|
7
|
+
*/ export class GuardedMerkleTreeOperations {
|
|
8
|
+
target;
|
|
9
|
+
isStopped;
|
|
10
|
+
serialQueue;
|
|
11
|
+
constructor(target){
|
|
12
|
+
this.target = target;
|
|
13
|
+
this.isStopped = false;
|
|
14
|
+
this.serialQueue = new SerialQueue();
|
|
15
|
+
this.serialQueue.start();
|
|
16
|
+
}
|
|
17
|
+
guard() {
|
|
18
|
+
if (this.isStopped) {
|
|
19
|
+
throw new Error('Merkle tree access has been stopped');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Executes the provided function only if the guard is not stopped.
|
|
23
|
+
guardAndPush(fn) {
|
|
24
|
+
this.guard();
|
|
25
|
+
return this.serialQueue.put(()=>{
|
|
26
|
+
this.guard();
|
|
27
|
+
return fn();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getUnderlyingFork() {
|
|
31
|
+
return this.target;
|
|
32
|
+
}
|
|
33
|
+
// Stops all further access to the merkle trees via this object
|
|
34
|
+
async stop() {
|
|
35
|
+
await this.serialQueue.put(()=>{
|
|
36
|
+
this.isStopped = true;
|
|
37
|
+
return Promise.resolve();
|
|
38
|
+
});
|
|
39
|
+
return this.serialQueue.end();
|
|
40
|
+
}
|
|
41
|
+
// Proxy all methods to the target
|
|
42
|
+
appendLeaves(treeId, leaves) {
|
|
43
|
+
return this.guardAndPush(()=>this.target.appendLeaves(treeId, leaves));
|
|
44
|
+
}
|
|
45
|
+
updateArchive(header) {
|
|
46
|
+
return this.guardAndPush(()=>this.target.updateArchive(header));
|
|
47
|
+
}
|
|
48
|
+
batchInsert(treeId, leaves, subtreeHeight) {
|
|
49
|
+
return this.guardAndPush(()=>this.target.batchInsert(treeId, leaves, subtreeHeight));
|
|
50
|
+
}
|
|
51
|
+
sequentialInsert(treeId, leaves) {
|
|
52
|
+
return this.guardAndPush(()=>this.target.sequentialInsert(treeId, leaves));
|
|
53
|
+
}
|
|
54
|
+
close() {
|
|
55
|
+
return this.guardAndPush(()=>this.target.close());
|
|
56
|
+
}
|
|
57
|
+
getTreeInfo(treeId) {
|
|
58
|
+
return this.guardAndPush(()=>this.target.getTreeInfo(treeId));
|
|
59
|
+
}
|
|
60
|
+
getStateReference() {
|
|
61
|
+
return this.guardAndPush(()=>this.target.getStateReference());
|
|
62
|
+
}
|
|
63
|
+
getInitialHeader() {
|
|
64
|
+
return this.target.getInitialHeader();
|
|
65
|
+
}
|
|
66
|
+
getRevision() {
|
|
67
|
+
return this.target.getRevision();
|
|
68
|
+
}
|
|
69
|
+
getSiblingPath(treeId, index) {
|
|
70
|
+
return this.guardAndPush(()=>this.target.getSiblingPath(treeId, index));
|
|
71
|
+
}
|
|
72
|
+
getPreviousValueIndex(treeId, value) {
|
|
73
|
+
return this.guardAndPush(()=>this.target.getPreviousValueIndex(treeId, value));
|
|
74
|
+
}
|
|
75
|
+
getLeafPreimage(treeId, index) {
|
|
76
|
+
return this.guardAndPush(()=>this.target.getLeafPreimage(treeId, index));
|
|
77
|
+
}
|
|
78
|
+
findLeafIndices(treeId, values) {
|
|
79
|
+
return this.guardAndPush(()=>this.target.findLeafIndices(treeId, values));
|
|
80
|
+
}
|
|
81
|
+
findLeafIndicesAfter(treeId, values, startIndex) {
|
|
82
|
+
return this.guardAndPush(()=>this.target.findLeafIndicesAfter(treeId, values, startIndex));
|
|
83
|
+
}
|
|
84
|
+
getLeafValue(treeId, index) {
|
|
85
|
+
return this.guardAndPush(()=>this.target.getLeafValue(treeId, index));
|
|
86
|
+
}
|
|
87
|
+
getBlockNumbersForLeafIndices(treeId, leafIndices) {
|
|
88
|
+
return this.guardAndPush(()=>this.target.getBlockNumbersForLeafIndices(treeId, leafIndices));
|
|
89
|
+
}
|
|
90
|
+
createCheckpoint() {
|
|
91
|
+
return this.guardAndPush(()=>this.target.createCheckpoint());
|
|
92
|
+
}
|
|
93
|
+
commitCheckpoint() {
|
|
94
|
+
return this.guardAndPush(()=>this.target.commitCheckpoint());
|
|
95
|
+
}
|
|
96
|
+
revertCheckpoint() {
|
|
97
|
+
return this.guardAndPush(()=>this.target.revertCheckpoint());
|
|
98
|
+
}
|
|
99
|
+
commitAllCheckpoints() {
|
|
100
|
+
return this.guardAndPush(()=>this.target.commitAllCheckpoints());
|
|
101
|
+
}
|
|
102
|
+
revertAllCheckpoints() {
|
|
103
|
+
return this.guardAndPush(()=>this.target.revertAllCheckpoints());
|
|
104
|
+
}
|
|
105
|
+
findSiblingPaths(treeId, values) {
|
|
106
|
+
return this.guardAndPush(()=>this.target.findSiblingPaths(treeId, values));
|
|
107
|
+
}
|
|
108
|
+
}
|