@aztec/simulator 0.0.1-commit.b655e406 → 0.0.1-commit.b9865e97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dest/client.d.ts +1 -1
- package/dest/common/errors.d.ts +2 -2
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/index.d.ts +1 -1
- package/dest/common/stats/index.d.ts +1 -1
- package/dest/common/stats/stats.d.ts +1 -1
- package/dest/private/acvm/acvm.d.ts +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- package/dest/private/acvm/acvm_types.d.ts +1 -1
- package/dest/private/acvm/deserialize.d.ts +2 -2
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +1 -1
- package/dest/private/acvm/index.d.ts +1 -1
- package/dest/private/acvm/serialize.d.ts +2 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +1 -1
- package/dest/private/acvm_native.d.ts +5 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +8 -6
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +7 -5
- package/dest/private/acvm_wasm_with_blobs.d.ts +1 -1
- package/dest/private/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +23 -20
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/private/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/circuit_simulator.d.ts +1 -1
- package/dest/private/factory.d.ts +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/testing/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/testing/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/testing/account_proof_fetcher.js +152 -0
- package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.d.ts +3 -2
- package/dest/public/avm/testing/base_avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/{fixtures → testing}/base_avm_simulation_tester.js +18 -3
- package/dest/public/avm/{fixtures → testing}/utils.d.ts +4 -10
- package/dest/public/avm/testing/utils.d.ts.map +1 -0
- package/dest/public/avm/{fixtures → testing}/utils.js +6 -35
- package/dest/public/contracts_db_checkpoint.d.ts +16 -0
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -0
- package/dest/public/contracts_db_checkpoint.js +30 -0
- package/dest/public/db_interfaces.d.ts +14 -2
- package/dest/public/db_interfaces.d.ts.map +1 -1
- package/dest/public/executor_metrics.d.ts +3 -2
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +13 -34
- package/dest/public/executor_metrics_interface.d.ts +3 -2
- package/dest/public/executor_metrics_interface.d.ts.map +1 -1
- package/dest/public/fixtures/amm_test.d.ts +1 -1
- package/dest/public/fixtures/amm_test.js +4 -4
- package/dest/public/fixtures/bulk_test.d.ts +3 -3
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +36 -73
- package/dest/public/fixtures/custom_bytecode_tester.d.ts +29 -7
- package/dest/public/fixtures/custom_bytecode_tester.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tester.js +36 -12
- package/dest/public/fixtures/index.d.ts +2 -3
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -2
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +30 -11
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +98 -31
- package/dest/public/fixtures/simple_contract_data_source.d.ts +5 -4
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/fixtures/simple_contract_data_source.js +5 -5
- package/dest/public/fixtures/token_test.d.ts +6 -2
- package/dest/public/fixtures/token_test.d.ts.map +1 -1
- package/dest/public/fixtures/token_test.js +13 -12
- package/dest/public/fixtures/utils.d.ts +3 -3
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +23 -23
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts +62 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_fuzzer_simulator.js +176 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts +2 -0
- package/dest/public/fuzzing/avm_simulator_bin.d.ts.map +1 -0
- package/dest/public/fuzzing/avm_simulator_bin.js +118 -0
- package/dest/public/index.d.ts +3 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/public_db_sources.d.ts +29 -66
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +83 -134
- package/dest/public/public_errors.d.ts +1 -1
- package/dest/public/public_errors.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +8 -5
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +12 -4
- package/dest/public/public_processor/public_processor.d.ts +19 -21
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +553 -123
- package/dest/public/public_processor/public_processor_metrics.d.ts +5 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +36 -45
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +19 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +99 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts +23 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/dumping_public_tx_simulator.js +52 -0
- package/dest/public/public_tx_simulator/factories.d.ts +14 -0
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/factories.js +28 -0
- package/dest/public/public_tx_simulator/index.d.ts +5 -3
- package/dest/public/public_tx_simulator/index.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/index.js +3 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +42 -89
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +101 -334
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts +22 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_base.js +28 -0
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts +25 -2
- package/dest/public/public_tx_simulator/public_tx_simulator_interface.d.ts.map +1 -1
- package/dest/public/side_effect_errors.d.ts +1 -1
- package/dest/public/side_effect_errors.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.d.ts +11 -4
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +29 -6
- package/dest/public/unique_class_ids.d.ts +1 -1
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/public/utils.d.ts +1 -1
- package/dest/server.d.ts +1 -1
- package/dest/testing.d.ts +1 -1
- package/package.json +22 -22
- package/src/common/errors.ts +1 -1
- package/src/private/acvm/acvm.ts +4 -3
- package/src/private/acvm/deserialize.ts +1 -1
- package/src/private/acvm/serialize.ts +1 -1
- package/src/private/acvm_native.ts +11 -5
- package/src/private/acvm_wasm.ts +11 -4
- package/src/private/circuit_recording/circuit_recorder.ts +24 -21
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/factory.ts +7 -4
- package/src/public/avm/testing/account_proof.json +553 -0
- package/src/public/avm/testing/account_proof_fetcher.ts +166 -0
- package/src/public/avm/{fixtures → testing}/base_avm_simulation_tester.ts +23 -3
- package/src/public/avm/{fixtures → testing}/utils.ts +6 -41
- package/src/public/contracts_db_checkpoint.ts +41 -0
- package/src/public/db_interfaces.ts +16 -1
- package/src/public/executor_metrics.ts +11 -34
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/amm_test.ts +4 -4
- package/src/public/fixtures/bulk_test.ts +38 -13
- package/src/public/fixtures/custom_bytecode_tester.ts +54 -20
- package/src/public/fixtures/index.ts +5 -2
- package/src/public/fixtures/public_tx_simulation_tester.ts +129 -27
- package/src/public/fixtures/simple_contract_data_source.ts +9 -10
- package/src/public/fixtures/token_test.ts +18 -10
- package/src/public/fixtures/utils.ts +28 -25
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +285 -0
- package/src/public/fuzzing/avm_simulator_bin.ts +173 -0
- package/src/public/index.ts +4 -2
- package/src/public/public_db_sources.ts +112 -174
- package/src/public/public_processor/guarded_merkle_tree.ts +14 -6
- package/src/public/public_processor/public_processor.ts +225 -136
- package/src/public/public_processor/public_processor_metrics.ts +28 -44
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +125 -0
- package/src/public/public_tx_simulator/dumping_public_tx_simulator.ts +83 -0
- package/src/public/public_tx_simulator/factories.ts +44 -0
- package/src/public/public_tx_simulator/index.ts +4 -2
- package/src/public/public_tx_simulator/public_tx_simulator.ts +153 -500
- package/src/public/public_tx_simulator/public_tx_simulator_base.ts +35 -0
- package/src/public/public_tx_simulator/public_tx_simulator_interface.ts +24 -2
- package/src/public/test_executor_metrics.ts +34 -8
- package/dest/public/avm/avm_context.d.ts +0 -41
- package/dest/public/avm/avm_context.d.ts.map +0 -1
- package/dest/public/avm/avm_context.js +0 -44
- package/dest/public/avm/avm_contract_call_result.d.ts +0 -32
- package/dest/public/avm/avm_contract_call_result.d.ts.map +0 -1
- package/dest/public/avm/avm_contract_call_result.js +0 -54
- package/dest/public/avm/avm_execution_environment.d.ts +0 -23
- package/dest/public/avm/avm_execution_environment.d.ts.map +0 -1
- package/dest/public/avm/avm_execution_environment.js +0 -36
- package/dest/public/avm/avm_gas.d.ts +0 -44
- package/dest/public/avm/avm_gas.d.ts.map +0 -1
- package/dest/public/avm/avm_gas.js +0 -195
- package/dest/public/avm/avm_machine_state.d.ts +0 -97
- package/dest/public/avm/avm_machine_state.d.ts.map +0 -1
- package/dest/public/avm/avm_machine_state.js +0 -109
- package/dest/public/avm/avm_memory_types.d.ts +0 -275
- package/dest/public/avm/avm_memory_types.d.ts.map +0 -1
- package/dest/public/avm/avm_memory_types.js +0 -351
- package/dest/public/avm/avm_simulator.d.ts +0 -39
- package/dest/public/avm/avm_simulator.d.ts.map +0 -1
- package/dest/public/avm/avm_simulator.js +0 -190
- package/dest/public/avm/avm_simulator_interface.d.ts +0 -9
- package/dest/public/avm/avm_simulator_interface.d.ts.map +0 -1
- package/dest/public/avm/avm_simulator_interface.js +0 -3
- package/dest/public/avm/errors.d.ts +0 -98
- package/dest/public/avm/errors.d.ts.map +0 -1
- package/dest/public/avm/errors.js +0 -129
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +0 -22
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +0 -74
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
- package/dest/public/avm/fixtures/initializers.d.ts +0 -43
- package/dest/public/avm/fixtures/initializers.d.ts.map +0 -1
- package/dest/public/avm/fixtures/initializers.js +0 -42
- package/dest/public/avm/fixtures/utils.d.ts.map +0 -1
- package/dest/public/avm/index.d.ts +0 -2
- package/dest/public/avm/index.d.ts.map +0 -1
- package/dest/public/avm/index.js +0 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +0 -75
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +0 -1
- package/dest/public/avm/opcodes/accrued_substate.js +0 -255
- package/dest/public/avm/opcodes/addressing_mode.d.ts +0 -31
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +0 -1
- package/dest/public/avm/opcodes/addressing_mode.js +0 -94
- package/dest/public/avm/opcodes/arithmetic.d.ts +0 -47
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +0 -1
- package/dest/public/avm/opcodes/arithmetic.js +0 -87
- package/dest/public/avm/opcodes/bitwise.d.ts +0 -42
- package/dest/public/avm/opcodes/bitwise.d.ts.map +0 -1
- package/dest/public/avm/opcodes/bitwise.js +0 -99
- package/dest/public/avm/opcodes/comparators.d.ts +0 -25
- package/dest/public/avm/opcodes/comparators.d.ts.map +0 -1
- package/dest/public/avm/opcodes/comparators.js +0 -43
- package/dest/public/avm/opcodes/contract.d.ts +0 -20
- package/dest/public/avm/opcodes/contract.d.ts.map +0 -1
- package/dest/public/avm/opcodes/contract.js +0 -65
- package/dest/public/avm/opcodes/control_flow.d.ts +0 -41
- package/dest/public/avm/opcodes/control_flow.d.ts.map +0 -1
- package/dest/public/avm/opcodes/control_flow.js +0 -107
- package/dest/public/avm/opcodes/conversion.d.ts +0 -18
- package/dest/public/avm/opcodes/conversion.d.ts.map +0 -1
- package/dest/public/avm/opcodes/conversion.js +0 -333
- package/dest/public/avm/opcodes/ec_add.d.ts +0 -19
- package/dest/public/avm/opcodes/ec_add.d.ts.map +0 -1
- package/dest/public/avm/opcodes/ec_add.js +0 -84
- package/dest/public/avm/opcodes/environment_getters.d.ts +0 -28
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +0 -1
- package/dest/public/avm/opcodes/environment_getters.js +0 -77
- package/dest/public/avm/opcodes/external_calls.d.ts +0 -59
- package/dest/public/avm/opcodes/external_calls.d.ts.map +0 -1
- package/dest/public/avm/opcodes/external_calls.js +0 -209
- package/dest/public/avm/opcodes/hashing.d.ts +0 -36
- package/dest/public/avm/opcodes/hashing.d.ts.map +0 -1
- package/dest/public/avm/opcodes/hashing.js +0 -114
- package/dest/public/avm/opcodes/index.d.ts +0 -16
- package/dest/public/avm/opcodes/index.d.ts.map +0 -1
- package/dest/public/avm/opcodes/index.js +0 -15
- package/dest/public/avm/opcodes/instruction.d.ts +0 -74
- package/dest/public/avm/opcodes/instruction.d.ts.map +0 -1
- package/dest/public/avm/opcodes/instruction.js +0 -95
- package/dest/public/avm/opcodes/instruction_impl.d.ts +0 -19
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +0 -1
- package/dest/public/avm/opcodes/instruction_impl.js +0 -30
- package/dest/public/avm/opcodes/memory.d.ts +0 -74
- package/dest/public/avm/opcodes/memory.d.ts.map +0 -1
- package/dest/public/avm/opcodes/memory.js +0 -257
- package/dest/public/avm/opcodes/misc.d.ts +0 -18
- package/dest/public/avm/opcodes/misc.d.ts.map +0 -1
- package/dest/public/avm/opcodes/misc.js +0 -73
- package/dest/public/avm/opcodes/storage.d.ts +0 -24
- package/dest/public/avm/opcodes/storage.d.ts.map +0 -1
- package/dest/public/avm/opcodes/storage.js +0 -68
- package/dest/public/avm/revert_reason.d.ts +0 -18
- package/dest/public/avm/revert_reason.d.ts.map +0 -1
- package/dest/public/avm/revert_reason.js +0 -38
- package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -26
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +0 -1
- package/dest/public/avm/serialization/buffer_cursor.js +0 -99
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -17
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +0 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +0 -333
- package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -114
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +0 -1
- package/dest/public/avm/serialization/instruction_serialization.js +0 -261
- package/dest/public/avm/test_utils.d.ts +0 -15
- package/dest/public/avm/test_utils.d.ts.map +0 -1
- package/dest/public/avm/test_utils.js +0 -44
- package/dest/public/debug_fn_name.d.ts +0 -5
- package/dest/public/debug_fn_name.d.ts.map +0 -1
- package/dest/public/debug_fn_name.js +0 -9
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +0 -9
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +0 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +0 -109
- package/dest/public/fixtures/minimal_public_tx.d.ts +0 -10
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +0 -1
- package/dest/public/fixtures/minimal_public_tx.js +0 -29
- package/dest/public/hinting_db_sources.d.ts +0 -70
- package/dest/public/hinting_db_sources.d.ts.map +0 -1
- package/dest/public/hinting_db_sources.js +0 -297
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +0 -41
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +0 -89
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -24
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -51
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +0 -127
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +0 -292
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +0 -21
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +0 -39
- package/dest/public/side_effect_trace.d.ts +0 -87
- package/dest/public/side_effect_trace.d.ts.map +0 -1
- package/dest/public/side_effect_trace.js +0 -199
- package/dest/public/side_effect_trace_interface.d.ts +0 -23
- package/dest/public/side_effect_trace_interface.d.ts.map +0 -1
- package/dest/public/side_effect_trace_interface.js +0 -1
- package/dest/public/state_manager/index.d.ts +0 -2
- package/dest/public/state_manager/index.d.ts.map +0 -1
- package/dest/public/state_manager/index.js +0 -1
- package/dest/public/state_manager/nullifiers.d.ts +0 -61
- package/dest/public/state_manager/nullifiers.d.ts.map +0 -1
- package/dest/public/state_manager/nullifiers.js +0 -92
- package/dest/public/state_manager/public_storage.d.ts +0 -66
- package/dest/public/state_manager/public_storage.d.ts.map +0 -1
- package/dest/public/state_manager/public_storage.js +0 -145
- package/dest/public/state_manager/state_manager.d.ts +0 -166
- package/dest/public/state_manager/state_manager.d.ts.map +0 -1
- package/dest/public/state_manager/state_manager.js +0 -391
- package/dest/public/tx_contract_cache.d.ts +0 -41
- package/dest/public/tx_contract_cache.d.ts.map +0 -1
- package/dest/public/tx_contract_cache.js +0 -49
- package/src/public/avm/avm_context.ts +0 -61
- package/src/public/avm/avm_contract_call_result.ts +0 -67
- package/src/public/avm/avm_execution_environment.ts +0 -48
- package/src/public/avm/avm_gas.ts +0 -183
- package/src/public/avm/avm_machine_state.ts +0 -169
- package/src/public/avm/avm_memory_types.ts +0 -436
- package/src/public/avm/avm_simulator.ts +0 -274
- package/src/public/avm/avm_simulator_interface.ts +0 -8
- package/src/public/avm/errors.ts +0 -163
- package/src/public/avm/fixtures/avm_simulation_tester.ts +0 -108
- package/src/public/avm/fixtures/initializers.ts +0 -104
- package/src/public/avm/index.ts +0 -1
- package/src/public/avm/opcodes/accrued_substate.ts +0 -288
- package/src/public/avm/opcodes/addressing_mode.ts +0 -111
- package/src/public/avm/opcodes/arithmetic.ts +0 -117
- package/src/public/avm/opcodes/bitwise.ts +0 -113
- package/src/public/avm/opcodes/comparators.ts +0 -55
- package/src/public/avm/opcodes/contract.ts +0 -75
- package/src/public/avm/opcodes/control_flow.ts +0 -123
- package/src/public/avm/opcodes/conversion.ts +0 -104
- package/src/public/avm/opcodes/ec_add.ts +0 -96
- package/src/public/avm/opcodes/environment_getters.ts +0 -87
- package/src/public/avm/opcodes/external_calls.ts +0 -260
- package/src/public/avm/opcodes/hashing.ts +0 -145
- package/src/public/avm/opcodes/index.ts +0 -15
- package/src/public/avm/opcodes/instruction.ts +0 -136
- package/src/public/avm/opcodes/instruction_impl.ts +0 -36
- package/src/public/avm/opcodes/memory.ts +0 -293
- package/src/public/avm/opcodes/misc.ts +0 -102
- package/src/public/avm/opcodes/storage.ts +0 -87
- package/src/public/avm/revert_reason.ts +0 -55
- package/src/public/avm/serialization/buffer_cursor.ts +0 -118
- package/src/public/avm/serialization/bytecode_serialization.ts +0 -204
- package/src/public/avm/serialization/instruction_serialization.ts +0 -249
- package/src/public/avm/test_utils.ts +0 -64
- package/src/public/debug_fn_name.ts +0 -18
- package/src/public/fixtures/custom_bytecode_tests.ts +0 -135
- package/src/public/fixtures/minimal_public_tx.ts +0 -36
- package/src/public/hinting_db_sources.ts +0 -505
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +0 -128
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -109
- package/src/public/public_tx_simulator/public_tx_context.ts +0 -471
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +0 -63
- package/src/public/side_effect_trace.ts +0 -290
- package/src/public/side_effect_trace_interface.ts +0 -28
- package/src/public/state_manager/index.ts +0 -1
- package/src/public/state_manager/nullifiers.ts +0 -103
- package/src/public/state_manager/public_storage.ts +0 -174
- package/src/public/state_manager/state_manager.ts +0 -560
- package/src/public/tx_contract_cache.ts +0 -69
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
|
-
import { DateProvider, Timer, elapsed,
|
|
6
|
+
import { DateProvider, Timer, elapsed, execWithSignal } from '@aztec/foundation/timer';
|
|
7
7
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
8
8
|
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
9
9
|
import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
AvmCircuitInputs,
|
|
12
|
+
AvmCircuitPublicInputs,
|
|
13
|
+
AvmExecutionHints,
|
|
14
|
+
type AvmProvingRequest,
|
|
15
|
+
PublicDataWrite,
|
|
16
|
+
PublicSimulatorConfig,
|
|
17
|
+
} from '@aztec/stdlib/avm';
|
|
11
18
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
19
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
13
20
|
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
@@ -18,6 +25,8 @@ import type {
|
|
|
18
25
|
PublicProcessorValidator,
|
|
19
26
|
SequencerConfig,
|
|
20
27
|
} from '@aztec/stdlib/interfaces/server';
|
|
28
|
+
import { type DebugLog, type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
29
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
21
30
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
22
31
|
import {
|
|
23
32
|
type FailedTx,
|
|
@@ -26,7 +35,6 @@ import {
|
|
|
26
35
|
type ProcessedTx,
|
|
27
36
|
StateReference,
|
|
28
37
|
Tx,
|
|
29
|
-
TxExecutionPhase,
|
|
30
38
|
makeProcessedTxFromPrivateOnlyTx,
|
|
31
39
|
makeProcessedTxFromTxWithPublicCalls,
|
|
32
40
|
} from '@aztec/stdlib/tx';
|
|
@@ -44,8 +52,8 @@ import { AssertionError } from 'assert';
|
|
|
44
52
|
|
|
45
53
|
import { PublicContractsDB, PublicTreesDB } from '../public_db_sources.js';
|
|
46
54
|
import {
|
|
47
|
-
type PublicTxSimulator,
|
|
48
55
|
type PublicTxSimulatorConfig,
|
|
56
|
+
type PublicTxSimulatorInterface,
|
|
49
57
|
TelemetryPublicTxSimulator,
|
|
50
58
|
} from '../public_tx_simulator/index.js';
|
|
51
59
|
import { GuardedMerkleTreeOperations } from './guarded_merkle_tree.js';
|
|
@@ -55,38 +63,30 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
55
63
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
56
64
|
*/
|
|
57
65
|
export class PublicProcessorFactory {
|
|
66
|
+
private log: Logger;
|
|
58
67
|
constructor(
|
|
59
68
|
private contractDataSource: ContractDataSource,
|
|
60
69
|
private dateProvider: DateProvider = new DateProvider(),
|
|
61
70
|
protected telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
62
|
-
|
|
71
|
+
bindings?: LoggerBindings,
|
|
72
|
+
) {
|
|
73
|
+
this.log = createLogger('simulator:public-processor-factory', bindings);
|
|
74
|
+
}
|
|
63
75
|
|
|
64
76
|
/**
|
|
65
77
|
* Creates a new instance of a PublicProcessor.
|
|
66
78
|
* @param globalVariables - The global variables for the block being processed.
|
|
67
|
-
* @param
|
|
79
|
+
* @param contractsDB - Optional pre-populated contracts DB; a fresh one is constructed if omitted.
|
|
68
80
|
* @returns A new instance of a PublicProcessor.
|
|
69
81
|
*/
|
|
70
82
|
public create(
|
|
71
83
|
merkleTree: MerkleTreeWriteOperations,
|
|
72
84
|
globalVariables: GlobalVariables,
|
|
73
|
-
config:
|
|
74
|
-
|
|
75
|
-
clientInitiatedSimulation: boolean;
|
|
76
|
-
proverId?: Fr;
|
|
77
|
-
maxDebugLogMemoryReads?: number;
|
|
78
|
-
},
|
|
85
|
+
config: PublicSimulatorConfig,
|
|
86
|
+
contractsDB: PublicContractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings()),
|
|
79
87
|
): PublicProcessor {
|
|
80
|
-
const contractsDB = new PublicContractsDB(this.contractDataSource);
|
|
81
|
-
|
|
82
88
|
const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
|
|
83
|
-
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables,
|
|
84
|
-
proverId: config.proverId,
|
|
85
|
-
doMerkleOperations: true,
|
|
86
|
-
skipFeeEnforcement: config.skipFeeEnforcement,
|
|
87
|
-
clientInitiatedSimulation: config.clientInitiatedSimulation,
|
|
88
|
-
maxDebugLogMemoryReads: config.maxDebugLogMemoryReads,
|
|
89
|
-
});
|
|
89
|
+
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
|
|
90
90
|
|
|
91
91
|
return new PublicProcessor(
|
|
92
92
|
globalVariables,
|
|
@@ -95,6 +95,7 @@ export class PublicProcessorFactory {
|
|
|
95
95
|
publicTxSimulator,
|
|
96
96
|
this.dateProvider,
|
|
97
97
|
this.telemetryClient,
|
|
98
|
+
createLogger('simulator:public-processor', this.log.getBindings()),
|
|
98
99
|
);
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -103,8 +104,15 @@ export class PublicProcessorFactory {
|
|
|
103
104
|
contractsDB: PublicContractsDB,
|
|
104
105
|
globalVariables: GlobalVariables,
|
|
105
106
|
config?: Partial<PublicTxSimulatorConfig>,
|
|
106
|
-
):
|
|
107
|
-
return new TelemetryPublicTxSimulator(
|
|
107
|
+
): PublicTxSimulatorInterface {
|
|
108
|
+
return new TelemetryPublicTxSimulator(
|
|
109
|
+
merkleTree,
|
|
110
|
+
contractsDB,
|
|
111
|
+
globalVariables,
|
|
112
|
+
this.telemetryClient,
|
|
113
|
+
config,
|
|
114
|
+
this.log.getBindings(),
|
|
115
|
+
);
|
|
108
116
|
}
|
|
109
117
|
}
|
|
110
118
|
|
|
@@ -115,22 +123,33 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
125
|
|
|
126
|
+
class PublicProcessorAbortError extends Error {
|
|
127
|
+
constructor(message: string = 'Aborted while processing tx') {
|
|
128
|
+
super(message);
|
|
129
|
+
this.name = 'PublicProcessorAbortError';
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function isPublicProcessorInterruptError(err: any) {
|
|
134
|
+
return err?.name === 'PublicProcessorTimeoutError' || err?.name === 'PublicProcessorAbortError';
|
|
135
|
+
}
|
|
136
|
+
|
|
118
137
|
/**
|
|
119
138
|
* Converts Txs lifted from the P2P module into ProcessedTx objects by executing
|
|
120
139
|
* any public function calls in them. Txs with private calls only are unaffected.
|
|
121
140
|
*/
|
|
122
141
|
export class PublicProcessor implements Traceable {
|
|
123
142
|
private metrics: PublicProcessorMetrics;
|
|
124
|
-
|
|
125
143
|
constructor(
|
|
126
144
|
protected globalVariables: GlobalVariables,
|
|
127
145
|
private guardedMerkleTree: GuardedMerkleTreeOperations,
|
|
128
146
|
protected contractsDB: PublicContractsDB,
|
|
129
|
-
protected publicTxSimulator:
|
|
147
|
+
protected publicTxSimulator: PublicTxSimulatorInterface,
|
|
130
148
|
private dateProvider: DateProvider,
|
|
131
149
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
132
|
-
private log
|
|
133
|
-
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs'> = {},
|
|
150
|
+
private log: Logger,
|
|
151
|
+
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'> = {},
|
|
152
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
134
153
|
) {
|
|
135
154
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
136
155
|
}
|
|
@@ -150,12 +169,13 @@ export class PublicProcessor implements Traceable {
|
|
|
150
169
|
txs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
151
170
|
limits: PublicProcessorLimits = {},
|
|
152
171
|
validator: PublicProcessorValidator = {},
|
|
153
|
-
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[]]> {
|
|
154
|
-
const { maxTransactions,
|
|
172
|
+
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]> {
|
|
173
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal, signal } = limits;
|
|
155
174
|
const { preprocessValidator, nullifierCache } = validator;
|
|
156
175
|
const result: ProcessedTx[] = [];
|
|
157
176
|
const usedTxs: Tx[] = [];
|
|
158
177
|
const failed: FailedTx[] = [];
|
|
178
|
+
const debugLogs: DebugLog[] = [];
|
|
159
179
|
const timer = new Timer();
|
|
160
180
|
|
|
161
181
|
let totalSizeInBytes = 0;
|
|
@@ -163,36 +183,43 @@ export class PublicProcessor implements Traceable {
|
|
|
163
183
|
let totalPublicGas = new Gas(0, 0);
|
|
164
184
|
let totalBlockGas = new Gas(0, 0);
|
|
165
185
|
let totalBlobFields = 0;
|
|
186
|
+
let silentlySkippedCount = 0;
|
|
187
|
+
let totalSilentlySkippedDurationMs = 0;
|
|
166
188
|
|
|
167
|
-
for await (const
|
|
189
|
+
for await (const tx of txs) {
|
|
168
190
|
// Only process up to the max tx limit
|
|
169
191
|
if (maxTransactions !== undefined && result.length >= maxTransactions) {
|
|
170
192
|
this.log.debug(`Stopping tx processing due to reaching the max tx limit.`);
|
|
171
193
|
break;
|
|
172
194
|
}
|
|
173
195
|
|
|
174
|
-
// Bail if we've hit the deadline
|
|
196
|
+
// Bail if we've hit the deadline or have been interrupted.
|
|
175
197
|
if (deadline && this.dateProvider.now() > +deadline) {
|
|
176
198
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
177
199
|
break;
|
|
178
200
|
}
|
|
201
|
+
if (signal?.aborted) {
|
|
202
|
+
this.log.warn(`Stopping tx processing due to abort signal.`);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
179
205
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
206
|
+
const txHash = tx.getTxHash().toString();
|
|
207
|
+
|
|
208
|
+
// Skip this tx if its estimated blob fields would exceed the limit.
|
|
209
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
210
|
+
const txBlobFields = tx.getPrivateTxEffectsSizeInFields();
|
|
211
|
+
if (isBuildingProposal && maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
212
|
+
this.log.warn(
|
|
213
|
+
`Skipping tx ${txHash} with ${txBlobFields} fields from private side effects due to blob fields limit`,
|
|
214
|
+
{ txHash, txBlobFields, totalBlobFields, maxBlobFields },
|
|
215
|
+
);
|
|
190
216
|
continue;
|
|
191
217
|
}
|
|
192
218
|
|
|
193
|
-
// Skip this tx if its gas limit would exceed the block gas limit
|
|
194
|
-
|
|
195
|
-
|
|
219
|
+
// Skip this tx if its gas limit would exceed the block gas limit (either da or l2).
|
|
220
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
221
|
+
const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
222
|
+
if (isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
196
223
|
this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
|
|
197
224
|
txHash,
|
|
198
225
|
txGasLimit,
|
|
@@ -202,9 +229,6 @@ export class PublicProcessor implements Traceable {
|
|
|
202
229
|
continue;
|
|
203
230
|
}
|
|
204
231
|
|
|
205
|
-
// The processor modifies the tx objects in place, so we need to clone them.
|
|
206
|
-
const tx = Tx.clone(origTx);
|
|
207
|
-
|
|
208
232
|
// We validate the tx before processing it, to avoid unnecessary work.
|
|
209
233
|
if (preprocessValidator) {
|
|
210
234
|
const result = await preprocessValidator.validateTx(tx);
|
|
@@ -215,11 +239,6 @@ export class PublicProcessor implements Traceable {
|
|
|
215
239
|
failed.push({ tx, error: new Error(`Tx failed preprocess validation: ${reason}`) });
|
|
216
240
|
returns.push(new NestedProcessReturnValues([]));
|
|
217
241
|
continue;
|
|
218
|
-
} else if (result.result === 'skipped') {
|
|
219
|
-
const reason = result.reason.join(', ');
|
|
220
|
-
this.log.debug(`Skipping tx ${txHash.toString()} due to pre-process validation: ${reason}`);
|
|
221
|
-
returns.push(new NestedProcessReturnValues([]));
|
|
222
|
-
continue;
|
|
223
242
|
} else {
|
|
224
243
|
this.log.trace(`Tx ${txHash.toString()} is valid before processing.`);
|
|
225
244
|
}
|
|
@@ -232,26 +251,24 @@ export class PublicProcessor implements Traceable {
|
|
|
232
251
|
// Note: We use the underlying fork here not the guarded one, this ensures that it's not impacted by stopping the guarded version
|
|
233
252
|
const checkpoint = await ForkCheckpoint.new(this.guardedMerkleTree.getUnderlyingFork());
|
|
234
253
|
const startStateReference = await this.guardedMerkleTree.getUnderlyingFork().getStateReference();
|
|
254
|
+
this.contractsDB.createCheckpoint();
|
|
235
255
|
|
|
236
256
|
try {
|
|
237
|
-
const [processedTx, returnValues] = await
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
totalSizeInBytes,
|
|
246
|
-
maxBlockSize,
|
|
247
|
-
});
|
|
248
|
-
// Need to revert the checkpoint here and don't go any further
|
|
249
|
-
await checkpoint.revert();
|
|
250
|
-
continue;
|
|
257
|
+
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(() =>
|
|
258
|
+
this.processTx(tx, deadline, signal),
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
// Inject a fake processing failure after N txs if requested
|
|
262
|
+
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
263
|
+
if (fakeThrowAfter !== undefined && result.length + failed.length + 1 >= fakeThrowAfter) {
|
|
264
|
+
throw new Error(`Fake error after processing ${fakeThrowAfter} txs`);
|
|
251
265
|
}
|
|
252
266
|
|
|
253
|
-
|
|
254
|
-
const
|
|
267
|
+
const txBlobFields = processedTx.txEffect.getNumBlobFields();
|
|
268
|
+
const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
|
|
269
|
+
|
|
270
|
+
// If the actual blob fields of this tx would exceed the limit, skip it.
|
|
271
|
+
// Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
|
|
255
272
|
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
256
273
|
this.log.debug(
|
|
257
274
|
`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`,
|
|
@@ -260,43 +277,76 @@ export class PublicProcessor implements Traceable {
|
|
|
260
277
|
txBlobFields,
|
|
261
278
|
totalBlobFields,
|
|
262
279
|
maxBlobFields,
|
|
280
|
+
txProcessingTimeMs,
|
|
263
281
|
},
|
|
264
282
|
);
|
|
283
|
+
silentlySkippedCount += 1;
|
|
284
|
+
totalSilentlySkippedDurationMs += txProcessingTimeMs;
|
|
285
|
+
this.metrics.recordSilentlySkipped(txProcessingTimeMs);
|
|
265
286
|
// Need to revert the checkpoint here and don't go any further
|
|
266
287
|
await checkpoint.revert();
|
|
288
|
+
this.contractsDB.revertCheckpoint();
|
|
267
289
|
continue;
|
|
268
290
|
}
|
|
269
291
|
|
|
292
|
+
// During re-execution, check if the actual gas used by this tx would push the block over the gas limit.
|
|
293
|
+
// Unlike the proposal-building check (which uses declared gas limits pessimistically before processing),
|
|
294
|
+
// this uses actual gas and stops processing when the limit is exceeded.
|
|
295
|
+
if (
|
|
296
|
+
!isBuildingProposal &&
|
|
297
|
+
maxBlockGas !== undefined &&
|
|
298
|
+
totalBlockGas.add(processedTx.gasUsed.totalGas).gtAny(maxBlockGas)
|
|
299
|
+
) {
|
|
300
|
+
this.log.warn(`Stopping re-execution since tx ${txHash} would push block gas over limit`, {
|
|
301
|
+
txHash,
|
|
302
|
+
txGas: processedTx.gasUsed.totalGas,
|
|
303
|
+
totalBlockGas,
|
|
304
|
+
maxBlockGas,
|
|
305
|
+
});
|
|
306
|
+
await checkpoint.revert();
|
|
307
|
+
this.contractsDB.revertCheckpoint();
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
|
|
270
311
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
271
312
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
272
313
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
|
|
273
314
|
result.push(processedTx);
|
|
274
315
|
usedTxs.push(tx);
|
|
275
316
|
returns = returns.concat(returnValues);
|
|
317
|
+
debugLogs.push(...txDebugLogs);
|
|
318
|
+
|
|
319
|
+
this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
|
|
276
320
|
|
|
277
321
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
278
322
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
279
323
|
totalSizeInBytes += txSize;
|
|
280
324
|
totalBlobFields += txBlobFields;
|
|
325
|
+
|
|
326
|
+
// Commit the tx-level contracts checkpoint on success
|
|
327
|
+
this.contractsDB.commitCheckpoint();
|
|
281
328
|
} catch (err: any) {
|
|
282
|
-
if (err
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
//
|
|
329
|
+
if (isPublicProcessorInterruptError(err)) {
|
|
330
|
+
const interruptReason = err.name === 'PublicProcessorTimeoutError' ? 'timeout' : 'abort signal';
|
|
331
|
+
this.log.warn(`Stopping tx processing due to ${interruptReason}.`);
|
|
332
|
+
// The tx may still be executing on a worker thread (C++ via NAPI).
|
|
333
|
+
// Signal cancellation AND WAIT for the simulation to actually stop before touching fork checkpoints.
|
|
334
|
+
await this.publicTxSimulator.cancel?.();
|
|
335
|
+
|
|
336
|
+
// Now stop the guarded fork to prevent any further TS-side access to the world state.
|
|
286
337
|
await this.guardedMerkleTree.stop();
|
|
287
338
|
|
|
288
339
|
// We now know there can't be any further access to world state. The fork is in a state where there is:
|
|
289
340
|
// 1. At least one outstanding checkpoint that has not been committed (the one created before we processed the tx).
|
|
290
341
|
// 2. Possible state updates on that checkpoint or any others created during execution.
|
|
291
342
|
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
await checkpoint.
|
|
343
|
+
// Revert all checkpoints at or above this checkpoint's depth (inclusive), destroying any outstanding state
|
|
344
|
+
// updates from this tx and any nested checkpoints created during execution. This preserves any checkpoints
|
|
345
|
+
// created by callers below our depth.
|
|
346
|
+
await checkpoint.revertToCheckpoint();
|
|
296
347
|
|
|
297
|
-
//
|
|
298
|
-
|
|
299
|
-
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
348
|
+
// Revert any contracts added to the DB for the tx.
|
|
349
|
+
this.contractsDB.revertCheckpoint();
|
|
300
350
|
|
|
301
351
|
// Ensure we're at the same state as when we started processing this tx.
|
|
302
352
|
await this.checkWorldStateUnchanged(startStateReference, txHash, err);
|
|
@@ -305,9 +355,10 @@ export class PublicProcessor implements Traceable {
|
|
|
305
355
|
break;
|
|
306
356
|
}
|
|
307
357
|
|
|
308
|
-
// Roll back state to start of TX before proceeding to next TX
|
|
309
|
-
|
|
310
|
-
await
|
|
358
|
+
// Roll back state to start of TX before proceeding to next TX.
|
|
359
|
+
// Reverts all checkpoints at or above this checkpoint's depth, preserving any caller checkpoints below.
|
|
360
|
+
await checkpoint.revertToCheckpoint();
|
|
361
|
+
this.contractsDB.revertCheckpoint();
|
|
311
362
|
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
312
363
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
313
364
|
failed.push({ tx, error: err instanceof Error ? err : new Error(errorMessage) });
|
|
@@ -318,8 +369,6 @@ export class PublicProcessor implements Traceable {
|
|
|
318
369
|
} finally {
|
|
319
370
|
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was previously reverted
|
|
320
371
|
await checkpoint.commit();
|
|
321
|
-
// The tx-level contracts cache should not live on to the next tx
|
|
322
|
-
this.contractsDB.clearContractsForTx();
|
|
323
372
|
}
|
|
324
373
|
}
|
|
325
374
|
|
|
@@ -327,15 +376,26 @@ export class PublicProcessor implements Traceable {
|
|
|
327
376
|
const rate = duration > 0 ? totalPublicGas.l2Gas / duration : 0;
|
|
328
377
|
this.metrics.recordAllTxs(totalPublicGas, rate);
|
|
329
378
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
379
|
+
const silentlySkippedDurationMs = Math.round(totalSilentlySkippedDurationMs);
|
|
380
|
+
this.log.info(
|
|
381
|
+
`Processed ${result.length} successful txs and ${failed.length} failed txs ` +
|
|
382
|
+
`(${silentlySkippedCount} silently skipped, ${silentlySkippedDurationMs}ms wasted) ` +
|
|
383
|
+
`in ${duration}s`,
|
|
384
|
+
{
|
|
385
|
+
blockNumber: this.globalVariables.blockNumber,
|
|
386
|
+
successfulCount: result.length,
|
|
387
|
+
failedCount: failed.length,
|
|
388
|
+
duration,
|
|
389
|
+
rate,
|
|
390
|
+
totalPublicGas,
|
|
391
|
+
totalBlockGas,
|
|
392
|
+
totalSizeInBytes,
|
|
393
|
+
silentlySkippedCount,
|
|
394
|
+
silentlySkippedDurationMs,
|
|
395
|
+
},
|
|
396
|
+
);
|
|
337
397
|
|
|
338
|
-
return [result, failed, usedTxs, returns];
|
|
398
|
+
return [result, failed, usedTxs, returns, debugLogs];
|
|
339
399
|
}
|
|
340
400
|
|
|
341
401
|
private async checkWorldStateUnchanged(
|
|
@@ -355,8 +415,14 @@ export class PublicProcessor implements Traceable {
|
|
|
355
415
|
}
|
|
356
416
|
|
|
357
417
|
@trackSpan('PublicProcessor.processTx', tx => ({ [Attributes.TX_HASH]: tx.getTxHash().toString() }))
|
|
358
|
-
private async processTx(
|
|
359
|
-
|
|
418
|
+
private async processTx(
|
|
419
|
+
tx: Tx,
|
|
420
|
+
deadline: Date | undefined,
|
|
421
|
+
signal: AbortSignal | undefined,
|
|
422
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
423
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
|
|
424
|
+
this.processTxWithinDeadline(tx, deadline, signal),
|
|
425
|
+
);
|
|
360
426
|
|
|
361
427
|
this.log.verbose(
|
|
362
428
|
!tx.hasPublicCalls()
|
|
@@ -379,7 +445,7 @@ export class PublicProcessor implements Traceable {
|
|
|
379
445
|
},
|
|
380
446
|
);
|
|
381
447
|
|
|
382
|
-
return [processedTx, returnValues ?? []];
|
|
448
|
+
return [processedTx, returnValues ?? [], debugLogs];
|
|
383
449
|
}
|
|
384
450
|
|
|
385
451
|
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
|
|
@@ -409,14 +475,14 @@ export class PublicProcessor implements Traceable {
|
|
|
409
475
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
|
410
476
|
}
|
|
411
477
|
|
|
412
|
-
/** Processes the given tx within deadline
|
|
478
|
+
/** Processes the given tx within deadline or until the signal is aborted. */
|
|
413
479
|
private async processTxWithinDeadline(
|
|
414
480
|
tx: Tx,
|
|
415
481
|
deadline: Date | undefined,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
: () => this.processPrivateOnlyTx(tx);
|
|
482
|
+
signal: AbortSignal | undefined,
|
|
483
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
|
|
484
|
+
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
|
|
485
|
+
tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
|
|
420
486
|
|
|
421
487
|
// Fake a delay per tx if instructed (used for tests)
|
|
422
488
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -430,27 +496,38 @@ export class PublicProcessor implements Traceable {
|
|
|
430
496
|
}
|
|
431
497
|
: innerProcessFn;
|
|
432
498
|
|
|
433
|
-
|
|
499
|
+
const processingSignal = this.getProcessingSignal(tx, deadline, signal);
|
|
500
|
+
if (!processingSignal) {
|
|
434
501
|
return await processFn();
|
|
435
502
|
}
|
|
436
503
|
|
|
437
|
-
|
|
504
|
+
return await execWithSignal(
|
|
505
|
+
() => processFn(),
|
|
506
|
+
processingSignal,
|
|
507
|
+
signal =>
|
|
508
|
+
signal.reason?.name === 'TimeoutError' ? new PublicProcessorTimeoutError() : new PublicProcessorAbortError(),
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
private getProcessingSignal(tx: Tx, deadline: Date | undefined, signal: AbortSignal | undefined) {
|
|
513
|
+
if (!deadline) {
|
|
514
|
+
return signal;
|
|
515
|
+
}
|
|
516
|
+
|
|
438
517
|
const timeout = +deadline - this.dateProvider.now();
|
|
439
518
|
if (timeout <= 0) {
|
|
440
519
|
throw new PublicProcessorTimeoutError();
|
|
441
520
|
}
|
|
442
521
|
|
|
522
|
+
const txHash = tx.getTxHash();
|
|
443
523
|
this.log.debug(`Processing tx ${txHash.toString()} within ${timeout}ms`, {
|
|
444
524
|
deadline: deadline.toISOString(),
|
|
445
525
|
now: new Date(this.dateProvider.now()).toISOString(),
|
|
446
526
|
txHash,
|
|
447
527
|
});
|
|
448
528
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
timeout,
|
|
452
|
-
() => new PublicProcessorTimeoutError(),
|
|
453
|
-
);
|
|
529
|
+
const timeoutSignal = AbortSignal.timeout(timeout);
|
|
530
|
+
return signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
454
531
|
}
|
|
455
532
|
|
|
456
533
|
/**
|
|
@@ -484,7 +561,7 @@ export class PublicProcessor implements Traceable {
|
|
|
484
561
|
@trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
|
|
485
562
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
486
563
|
}))
|
|
487
|
-
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
|
|
564
|
+
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
|
|
488
565
|
const gasFees = this.globalVariables.gasFees;
|
|
489
566
|
const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
|
|
490
567
|
|
|
@@ -507,35 +584,20 @@ export class PublicProcessor implements Traceable {
|
|
|
507
584
|
// Fee payment insertion has already been done. Do the rest.
|
|
508
585
|
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
509
586
|
|
|
510
|
-
|
|
511
|
-
// (add to tx-level cache and then commit to block-level cache)
|
|
512
|
-
await this.contractsDB.addNewContracts(tx);
|
|
513
|
-
this.contractsDB.commitContractsForTx();
|
|
587
|
+
this.contractsDB.addNewContracts(tx);
|
|
514
588
|
|
|
515
|
-
return [processedTx, undefined];
|
|
589
|
+
return [processedTx, undefined, []];
|
|
516
590
|
}
|
|
517
591
|
|
|
518
592
|
@trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
|
|
519
593
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
520
594
|
}))
|
|
521
|
-
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
595
|
+
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
522
596
|
const timer = new Timer();
|
|
523
597
|
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (!avmProvingRequest) {
|
|
528
|
-
this.metrics.recordFailedTx();
|
|
529
|
-
throw new Error('Avm proving result was not generated.');
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
processedPhases.forEach(phase => {
|
|
533
|
-
if (phase.reverted) {
|
|
534
|
-
this.metrics.recordRevertedPhase(phase.phase);
|
|
535
|
-
} else {
|
|
536
|
-
this.metrics.recordPhaseDuration(phase.phase, phase.durationMs ?? 0);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
598
|
+
const result = await this.publicTxSimulator.simulate(tx);
|
|
599
|
+
// TODO: use the callStackMetadata here to extract more data about public execution
|
|
600
|
+
const { hints, publicInputs, publicTxEffect, gasUsed, revertCode /*callStackMetadata*/ } = result;
|
|
539
601
|
|
|
540
602
|
const contractClassLogs = revertCode.isOK()
|
|
541
603
|
? tx.getContractClassLogs()
|
|
@@ -546,14 +608,41 @@ export class PublicProcessor implements Traceable {
|
|
|
546
608
|
.map(log => ContractClassPublishedEvent.fromLog(log)),
|
|
547
609
|
);
|
|
548
610
|
|
|
549
|
-
|
|
611
|
+
// TODO(fcarreiro): remove phase count metric.
|
|
550
612
|
const durationMs = timer.ms();
|
|
551
|
-
this.metrics.recordTx(phaseCount, durationMs, gasUsed.publicGas);
|
|
613
|
+
this.metrics.recordTx(/*phaseCount=*/ 1, durationMs, gasUsed.publicGas);
|
|
552
614
|
|
|
553
|
-
|
|
615
|
+
// Extract the return values from the call stack metadata.
|
|
616
|
+
const appLogicReturnValues: NestedProcessReturnValues[] = result.getAppLogicReturnValues();
|
|
617
|
+
// Extract the revert reason from the call stack metadata.
|
|
618
|
+
const revertReason = result.findRevertReason();
|
|
619
|
+
// Create proving request if we have hints and public inputs.
|
|
620
|
+
const avmProvingRequest =
|
|
621
|
+
hints && publicInputs ? PublicProcessor.generateProvingRequest(publicInputs, hints) : undefined;
|
|
554
622
|
|
|
555
|
-
const
|
|
623
|
+
const processedTx = makeProcessedTxFromTxWithPublicCalls(
|
|
624
|
+
tx,
|
|
625
|
+
this.globalVariables,
|
|
626
|
+
avmProvingRequest,
|
|
627
|
+
publicTxEffect,
|
|
628
|
+
gasUsed,
|
|
629
|
+
revertCode,
|
|
630
|
+
revertReason,
|
|
631
|
+
);
|
|
556
632
|
|
|
557
|
-
return [processedTx,
|
|
633
|
+
return [processedTx, appLogicReturnValues, result.logs ?? []];
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Generate the proving request for the AVM circuit.
|
|
638
|
+
*/
|
|
639
|
+
private static generateProvingRequest(
|
|
640
|
+
publicInputs: AvmCircuitPublicInputs,
|
|
641
|
+
hints: AvmExecutionHints = AvmExecutionHints.empty(),
|
|
642
|
+
): AvmProvingRequest {
|
|
643
|
+
return {
|
|
644
|
+
type: ProvingRequestType.PUBLIC_VM,
|
|
645
|
+
inputs: new AvmCircuitInputs(hints, publicInputs),
|
|
646
|
+
};
|
|
558
647
|
}
|
|
559
648
|
}
|