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