@aztec/simulator 0.76.4 → 0.77.0-testnet-ignition.21
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 +3 -3
- package/dest/client.d.ts +5 -0
- package/dest/client.d.ts.map +1 -0
- package/dest/client.js +3 -0
- package/dest/{public → common}/db_interfaces.d.ts +8 -33
- package/dest/common/db_interfaces.d.ts.map +1 -0
- package/dest/common/db_interfaces.js +1 -0
- package/dest/common/debug_fn_name.d.ts +3 -2
- package/dest/common/debug_fn_name.d.ts.map +1 -1
- package/dest/common/debug_fn_name.js +2 -5
- package/dest/common/errors.d.ts +4 -4
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +30 -39
- package/dest/common/index.d.ts +2 -1
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +2 -2
- package/dest/common/message_load_oracle_inputs.d.ts +2 -2
- package/dest/common/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/common/message_load_oracle_inputs.js +8 -8
- package/dest/common/stats/index.d.ts.map +1 -0
- package/dest/{stats → common/stats}/stats.d.ts +2 -2
- package/dest/common/stats/stats.d.ts.map +1 -0
- package/dest/common/stats/stats.js +10 -0
- package/dest/{acvm → private/acvm}/acvm.d.ts +4 -4
- package/dest/private/acvm/acvm.d.ts.map +1 -0
- package/dest/private/acvm/acvm.js +70 -0
- package/dest/{acvm → private/acvm}/acvm_types.d.ts +1 -1
- package/dest/private/acvm/acvm_types.d.ts.map +1 -0
- package/dest/private/acvm/acvm_types.js +3 -0
- package/dest/{acvm → private/acvm}/deserialize.d.ts +2 -2
- package/dest/private/acvm/deserialize.d.ts.map +1 -0
- package/dest/private/acvm/deserialize.js +42 -0
- package/dest/private/acvm/index.d.ts.map +1 -0
- package/dest/private/acvm/index.js +5 -0
- package/dest/{acvm → private/acvm}/oracle/index.d.ts +1 -1
- package/dest/private/acvm/oracle/index.d.ts.map +1 -0
- package/dest/private/acvm/oracle/index.js +2 -0
- package/dest/{acvm → private/acvm}/oracle/oracle.d.ts +4 -3
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -0
- package/dest/private/acvm/oracle/oracle.js +263 -0
- package/dest/{acvm → private/acvm}/oracle/typed_oracle.d.ts +12 -6
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -0
- package/dest/private/acvm/oracle/typed_oracle.js +132 -0
- package/dest/{acvm → private/acvm}/serialize.d.ts +7 -3
- package/dest/private/acvm/serialize.d.ts.map +1 -0
- package/dest/private/acvm/serialize.js +46 -0
- package/dest/{client → private}/client_execution_context.d.ts +20 -17
- package/dest/private/client_execution_context.d.ts.map +1 -0
- package/dest/private/client_execution_context.js +378 -0
- package/dest/{client → private}/db_oracle.d.ts +19 -7
- package/dest/private/db_oracle.d.ts.map +1 -0
- package/dest/private/db_oracle.js +14 -0
- package/dest/{client → private}/execution_note_cache.d.ts +2 -2
- package/dest/private/execution_note_cache.d.ts.map +1 -0
- package/dest/private/execution_note_cache.js +180 -0
- package/dest/{common → private}/hashed_values_cache.d.ts +2 -2
- package/dest/private/hashed_values_cache.d.ts.map +1 -0
- package/dest/private/hashed_values_cache.js +46 -0
- package/dest/private/index.d.ts +13 -0
- package/dest/private/index.d.ts.map +1 -0
- package/dest/private/index.js +12 -0
- package/dest/{client → private}/pick_notes.d.ts +1 -1
- package/dest/private/pick_notes.d.ts.map +1 -0
- package/dest/private/pick_notes.js +51 -0
- package/dest/private/private_execution.d.ts +24 -0
- package/dest/private/private_execution.d.ts.map +1 -0
- package/dest/private/private_execution.js +90 -0
- package/dest/{providers → private/providers}/acvm_native.d.ts +5 -5
- package/dest/private/providers/acvm_native.d.ts.map +1 -0
- package/dest/private/providers/acvm_native.js +139 -0
- package/dest/{providers → private/providers}/acvm_wasm.d.ts +4 -4
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -0
- package/dest/private/providers/acvm_wasm.js +62 -0
- package/dest/{providers → private/providers}/acvm_wasm_with_blobs.d.ts +5 -5
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -0
- package/dest/{providers → private/providers}/acvm_wasm_with_blobs.js +3 -6
- package/dest/{providers → private/providers}/factory.d.ts +1 -1
- package/dest/private/providers/factory.d.ts.map +1 -0
- package/dest/private/providers/factory.js +27 -0
- package/dest/{common → private/providers}/simulation_provider.d.ts +5 -5
- package/dest/private/providers/simulation_provider.d.ts.map +1 -0
- package/dest/private/providers/simulation_provider.js +24 -0
- package/dest/private/simulator.d.ts +36 -0
- package/dest/private/simulator.d.ts.map +1 -0
- package/dest/private/simulator.js +78 -0
- package/dest/{client → private}/unconstrained_execution.d.ts +5 -5
- package/dest/private/unconstrained_execution.d.ts.map +1 -0
- package/dest/private/unconstrained_execution.js +27 -0
- package/dest/{client → private}/view_data_oracle.d.ts +15 -7
- package/dest/private/view_data_oracle.d.ts.map +1 -0
- package/dest/private/view_data_oracle.js +260 -0
- package/dest/{avm → public/avm}/avm_context.d.ts +7 -5
- package/dest/public/avm/avm_context.d.ts.map +1 -0
- package/dest/public/avm/avm_context.js +44 -0
- package/dest/{avm → public/avm}/avm_contract_call_result.d.ts +5 -5
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -0
- package/dest/public/avm/avm_contract_call_result.js +50 -0
- package/dest/{avm → public/avm}/avm_execution_environment.d.ts +2 -2
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -0
- package/dest/public/avm/avm_execution_environment.js +31 -0
- package/dest/public/avm/avm_gas.d.ts.map +1 -0
- package/dest/public/avm/avm_gas.js +202 -0
- package/dest/{avm → public/avm}/avm_machine_state.d.ts +2 -2
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -0
- package/dest/public/avm/avm_machine_state.js +106 -0
- package/dest/{avm → public/avm}/avm_memory_types.d.ts +2 -2
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -0
- package/dest/public/avm/avm_memory_types.js +340 -0
- package/dest/{avm → public/avm}/avm_simulator.d.ts +5 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator.js +202 -0
- package/dest/public/avm/bytecode_utils.d.ts.map +1 -0
- package/dest/public/avm/bytecode_utils.js +17 -0
- package/dest/{avm → public/avm}/errors.d.ts +5 -4
- package/dest/public/avm/errors.d.ts.map +1 -0
- package/dest/public/avm/errors.js +179 -0
- package/dest/{avm → public/avm}/fixtures/avm_simulation_tester.d.ts +6 -6
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.js +76 -0
- package/dest/{avm → public/avm}/fixtures/base_avm_simulation_tester.d.ts +13 -12
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -0
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +83 -0
- package/dest/{avm → public/avm}/fixtures/index.d.ts +24 -7
- package/dest/public/avm/fixtures/index.d.ts.map +1 -0
- package/dest/public/avm/fixtures/index.js +175 -0
- package/dest/{avm → public/avm}/fixtures/simple_contract_data_source.d.ts +10 -6
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/avm/fixtures/simple_contract_data_source.js +74 -0
- package/dest/public/avm/index.d.ts +4 -0
- package/dest/public/avm/index.d.ts.map +1 -0
- package/dest/{avm/index.d.ts → public/avm/index.js} +1 -2
- package/dest/public/avm/journal/index.d.ts.map +1 -0
- package/dest/{avm → public/avm}/journal/journal.d.ts +51 -18
- package/dest/public/avm/journal/journal.d.ts.map +1 -0
- package/dest/public/avm/journal/journal.js +486 -0
- package/dest/{avm → public/avm}/journal/nullifiers.d.ts +8 -6
- package/dest/public/avm/journal/nullifiers.d.ts.map +1 -0
- package/dest/public/avm/journal/nullifiers.js +97 -0
- package/dest/{avm → public/avm}/journal/public_storage.d.ts +2 -2
- package/dest/public/avm/journal/public_storage.d.ts.map +1 -0
- package/dest/public/avm/journal/public_storage.js +145 -0
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -0
- package/dest/public/avm/opcodes/accrued_substate.js +252 -0
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -0
- package/dest/public/avm/opcodes/addressing_mode.js +74 -0
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -0
- package/dest/public/avm/opcodes/arithmetic.js +73 -0
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -0
- package/dest/public/avm/opcodes/bitwise.js +106 -0
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -0
- package/dest/public/avm/opcodes/comparators.js +43 -0
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -0
- package/dest/public/avm/opcodes/contract.js +66 -0
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -0
- package/dest/public/avm/opcodes/control_flow.js +105 -0
- package/dest/{avm → public/avm}/opcodes/conversion.d.ts +1 -1
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -0
- package/dest/public/avm/opcodes/conversion.js +69 -0
- package/dest/{avm → public/avm}/opcodes/ec_add.d.ts +1 -1
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -0
- package/dest/public/avm/opcodes/ec_add.js +84 -0
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -0
- package/dest/public/avm/opcodes/environment_getters.js +79 -0
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -0
- package/dest/public/avm/opcodes/external_calls.js +180 -0
- package/dest/{avm → public/avm}/opcodes/hashing.d.ts +1 -1
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -0
- package/dest/public/avm/opcodes/hashing.js +114 -0
- package/dest/public/avm/opcodes/index.d.ts.map +1 -0
- package/dest/{avm → public/avm}/opcodes/instruction.d.ts +2 -2
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -0
- package/dest/public/avm/opcodes/instruction.js +91 -0
- package/dest/public/avm/opcodes/instruction_impl.d.ts.map +1 -0
- package/dest/public/avm/opcodes/instruction_impl.js +30 -0
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -0
- package/dest/public/avm/opcodes/memory.js +253 -0
- package/dest/{avm → public/avm}/opcodes/misc.d.ts +1 -1
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -0
- package/dest/public/avm/opcodes/misc.js +48 -0
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -0
- package/dest/public/avm/opcodes/storage.js +66 -0
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -0
- package/dest/public/avm/serialization/buffer_cursor.js +99 -0
- package/dest/{avm → public/avm}/serialization/bytecode_serialization.d.ts +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -0
- package/dest/public/avm/serialization/bytecode_serialization.js +328 -0
- package/dest/{avm → public/avm}/serialization/instruction_serialization.d.ts +1 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -0
- package/dest/public/avm/serialization/instruction_serialization.js +225 -0
- package/dest/{avm → public/avm}/test_utils.d.ts +6 -4
- package/dest/public/avm/test_utils.d.ts.map +1 -0
- package/dest/public/avm/test_utils.js +52 -0
- package/dest/public/bytecode_errors.js +1 -2
- package/dest/public/execution.d.ts +8 -2
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +4 -5
- package/dest/public/executor_metrics.js +16 -12
- package/dest/public/fixtures/index.js +0 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +15 -9
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +54 -53
- package/dest/public/fixtures/utils.d.ts +7 -11
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +92 -32
- package/dest/public/index.d.ts +5 -4
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +5 -5
- package/dest/public/public_db_sources.d.ts +82 -34
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +171 -196
- package/dest/public/{public_processor.d.ts → public_processor/public_processor.d.ts} +10 -8
- package/dest/public/public_processor/public_processor.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor.js +379 -0
- package/dest/public/{public_processor_metrics.d.ts → public_processor/public_processor_metrics.d.ts} +3 -3
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -0
- package/dest/public/public_processor/public_processor_metrics.js +125 -0
- package/dest/public/{public_tx_context.d.ts → public_tx_simulator/public_tx_context.d.ts} +14 -8
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_context.js +320 -0
- package/dest/public/{public_tx_simulator.d.ts → public_tx_simulator/public_tx_simulator.d.ts} +10 -7
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator/public_tx_simulator.js +325 -0
- package/dest/public/side_effect_errors.js +1 -2
- package/dest/public/side_effect_trace.d.ts +16 -10
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +82 -149
- package/dest/public/side_effect_trace_interface.d.ts +9 -7
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/side_effect_trace_interface.js +1 -2
- package/dest/public/tx_contract_cache.d.ts +41 -0
- package/dest/public/tx_contract_cache.d.ts.map +1 -0
- package/dest/public/tx_contract_cache.js +49 -0
- package/dest/public/unique_class_ids.js +23 -28
- package/dest/public/utils.d.ts +2 -2
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +17 -12
- package/dest/server.d.ts +4 -4
- package/dest/server.d.ts.map +1 -1
- package/dest/server.js +3 -5
- package/dest/test/utils.d.ts +3 -2
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +9 -7
- package/package.json +19 -21
- package/src/client.ts +4 -0
- package/src/{public → common}/db_interfaces.ts +8 -40
- package/src/common/debug_fn_name.ts +4 -2
- package/src/common/errors.ts +5 -5
- package/src/common/index.ts +2 -1
- package/src/common/message_load_oracle_inputs.ts +2 -2
- package/src/common/stats/index.ts +1 -0
- package/src/{stats → common/stats}/stats.ts +2 -2
- package/src/{acvm → private/acvm}/acvm.ts +5 -5
- package/src/{acvm → private/acvm}/acvm_types.ts +1 -1
- package/src/{acvm → private/acvm}/deserialize.ts +2 -2
- package/src/{acvm → private/acvm}/oracle/index.ts +1 -1
- package/src/{acvm → private/acvm}/oracle/oracle.ts +22 -12
- package/src/{acvm → private/acvm}/oracle/typed_oracle.ts +50 -55
- package/src/{acvm → private/acvm}/serialize.ts +10 -3
- package/src/{client → private}/client_execution_context.ts +54 -37
- package/src/{client → private}/db_oracle.ts +20 -20
- package/src/{client → private}/execution_note_cache.ts +3 -3
- package/src/{common → private}/hashed_values_cache.ts +2 -2
- package/src/private/index.ts +12 -0
- package/src/{client → private}/pick_notes.ts +1 -1
- package/src/{client → private}/private_execution.ts +46 -14
- package/src/{providers → private/providers}/acvm_native.ts +6 -6
- package/src/{providers → private/providers}/acvm_wasm.ts +4 -4
- package/src/{providers → private/providers}/acvm_wasm_with_blobs.ts +5 -5
- package/src/{providers → private/providers}/factory.ts +1 -1
- package/src/{common → private/providers}/simulation_provider.ts +5 -5
- package/src/{client → private}/simulator.ts +31 -123
- package/src/{client → private}/unconstrained_execution.ts +7 -7
- package/src/{client → private}/view_data_oracle.ts +25 -28
- package/src/{avm → public/avm}/avm_context.ts +12 -7
- package/src/{avm → public/avm}/avm_contract_call_result.ts +6 -6
- package/src/{avm → public/avm}/avm_execution_environment.ts +2 -2
- package/src/{avm → public/avm}/avm_gas.ts +1 -3
- package/src/{avm → public/avm}/avm_machine_state.ts +2 -2
- package/src/{avm → public/avm}/avm_memory_types.ts +4 -4
- package/src/{avm → public/avm}/avm_simulator.ts +12 -6
- package/src/{avm → public/avm}/errors.ts +5 -4
- package/src/{avm → public/avm}/fixtures/avm_simulation_tester.ts +16 -15
- package/src/{avm → public/avm}/fixtures/base_avm_simulation_tester.ts +45 -40
- package/src/{avm → public/avm}/fixtures/index.ts +77 -12
- package/src/{avm → public/avm}/fixtures/simple_contract_data_source.ts +26 -19
- package/src/{avm → public/avm}/index.ts +1 -1
- package/src/public/avm/journal/index.ts +1 -0
- package/src/{avm → public/avm}/journal/journal.ts +330 -305
- package/src/{avm → public/avm}/journal/nullifiers.ts +20 -19
- package/src/{avm → public/avm}/journal/public_storage.ts +2 -2
- package/src/{avm → public/avm}/opcodes/contract.ts +1 -1
- package/src/{avm → public/avm}/opcodes/control_flow.ts +1 -1
- package/src/{avm → public/avm}/opcodes/conversion.ts +1 -1
- package/src/{avm → public/avm}/opcodes/ec_add.ts +2 -2
- package/src/{avm → public/avm}/opcodes/external_calls.ts +5 -6
- package/src/{avm → public/avm}/opcodes/hashing.ts +1 -1
- package/src/public/avm/opcodes/index.ts +15 -0
- package/src/{avm → public/avm}/opcodes/instruction.ts +2 -2
- package/src/{avm → public/avm}/opcodes/misc.ts +1 -1
- package/src/public/avm/serialization/bytecode_serialization.ts +204 -0
- package/src/{avm → public/avm}/serialization/instruction_serialization.ts +0 -1
- package/src/{avm → public/avm}/test_utils.ts +10 -7
- package/src/public/execution.ts +9 -12
- package/src/public/fixtures/public_tx_simulation_tester.ts +66 -72
- package/src/public/fixtures/utils.ts +122 -33
- package/src/public/index.ts +5 -4
- package/src/public/public_db_sources.ts +216 -222
- package/src/public/{public_processor.ts → public_processor/public_processor.ts} +78 -53
- package/src/public/{public_processor_metrics.ts → public_processor/public_processor_metrics.ts} +3 -3
- package/src/public/{public_tx_context.ts → public_tx_simulator/public_tx_context.ts} +70 -75
- package/src/public/{public_tx_simulator.ts → public_tx_simulator/public_tx_simulator.ts} +104 -91
- package/src/public/side_effect_trace.ts +85 -160
- package/src/public/side_effect_trace_interface.ts +10 -23
- package/src/public/tx_contract_cache.ts +69 -0
- package/src/public/unique_class_ids.ts +1 -1
- package/src/public/utils.ts +2 -2
- package/src/server.ts +4 -4
- package/src/test/utils.ts +5 -3
- package/dest/acvm/acvm.d.ts.map +0 -1
- package/dest/acvm/acvm.js +0 -73
- package/dest/acvm/acvm_types.d.ts.map +0 -1
- package/dest/acvm/acvm_types.js +0 -2
- package/dest/acvm/deserialize.d.ts.map +0 -1
- package/dest/acvm/deserialize.js +0 -46
- package/dest/acvm/index.d.ts.map +0 -1
- package/dest/acvm/index.js +0 -6
- package/dest/acvm/oracle/index.d.ts.map +0 -1
- package/dest/acvm/oracle/index.js +0 -3
- package/dest/acvm/oracle/oracle.d.ts.map +0 -1
- package/dest/acvm/oracle/oracle.js +0 -230
- package/dest/acvm/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/acvm/oracle/typed_oracle.js +0 -131
- package/dest/acvm/serialize.d.ts.map +0 -1
- package/dest/acvm/serialize.js +0 -48
- package/dest/avm/avm_context.d.ts.map +0 -1
- package/dest/avm/avm_context.js +0 -44
- package/dest/avm/avm_contract_call_result.d.ts.map +0 -1
- package/dest/avm/avm_contract_call_result.js +0 -45
- package/dest/avm/avm_execution_environment.d.ts.map +0 -1
- package/dest/avm/avm_execution_environment.js +0 -28
- package/dest/avm/avm_gas.d.ts.map +0 -1
- package/dest/avm/avm_gas.js +0 -170
- package/dest/avm/avm_machine_state.d.ts.map +0 -1
- package/dest/avm/avm_machine_state.js +0 -112
- package/dest/avm/avm_memory_types.d.ts.map +0 -1
- package/dest/avm/avm_memory_types.js +0 -327
- package/dest/avm/avm_simulator.d.ts.map +0 -1
- package/dest/avm/avm_simulator.js +0 -193
- package/dest/avm/avm_tree.d.ts +0 -282
- package/dest/avm/avm_tree.d.ts.map +0 -1
- package/dest/avm/avm_tree.js +0 -684
- package/dest/avm/bytecode_utils.d.ts.map +0 -1
- package/dest/avm/bytecode_utils.js +0 -15
- package/dest/avm/errors.d.ts.map +0 -1
- package/dest/avm/errors.js +0 -196
- package/dest/avm/fixtures/avm_simulation_tester.d.ts.map +0 -1
- package/dest/avm/fixtures/avm_simulation_tester.js +0 -73
- package/dest/avm/fixtures/base_avm_simulation_tester.d.ts.map +0 -1
- package/dest/avm/fixtures/base_avm_simulation_tester.js +0 -76
- package/dest/avm/fixtures/index.d.ts.map +0 -1
- package/dest/avm/fixtures/index.js +0 -134
- package/dest/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
- package/dest/avm/fixtures/simple_contract_data_source.js +0 -75
- package/dest/avm/index.d.ts.map +0 -1
- package/dest/avm/index.js +0 -4
- package/dest/avm/journal/index.d.ts.map +0 -1
- package/dest/avm/journal/index.js +0 -2
- package/dest/avm/journal/journal.d.ts.map +0 -1
- package/dest/avm/journal/journal.js +0 -499
- package/dest/avm/journal/nullifiers.d.ts.map +0 -1
- package/dest/avm/journal/nullifiers.js +0 -99
- package/dest/avm/journal/public_storage.d.ts.map +0 -1
- package/dest/avm/journal/public_storage.js +0 -159
- package/dest/avm/opcodes/accrued_substate.d.ts.map +0 -1
- package/dest/avm/opcodes/accrued_substate.js +0 -215
- package/dest/avm/opcodes/addressing_mode.d.ts.map +0 -1
- package/dest/avm/opcodes/addressing_mode.js +0 -81
- package/dest/avm/opcodes/arithmetic.d.ts.map +0 -1
- package/dest/avm/opcodes/arithmetic.js +0 -70
- package/dest/avm/opcodes/bitwise.d.ts.map +0 -1
- package/dest/avm/opcodes/bitwise.js +0 -90
- package/dest/avm/opcodes/comparators.d.ts.map +0 -1
- package/dest/avm/opcodes/comparators.js +0 -40
- package/dest/avm/opcodes/contract.d.ts.map +0 -1
- package/dest/avm/opcodes/contract.js +0 -63
- package/dest/avm/opcodes/control_flow.d.ts.map +0 -1
- package/dest/avm/opcodes/control_flow.js +0 -97
- package/dest/avm/opcodes/conversion.d.ts.map +0 -1
- package/dest/avm/opcodes/conversion.js +0 -64
- package/dest/avm/opcodes/ec_add.d.ts.map +0 -1
- package/dest/avm/opcodes/ec_add.js +0 -82
- package/dest/avm/opcodes/environment_getters.d.ts.map +0 -1
- package/dest/avm/opcodes/environment_getters.js +0 -78
- package/dest/avm/opcodes/external_calls.d.ts.map +0 -1
- package/dest/avm/opcodes/external_calls.js +0 -169
- package/dest/avm/opcodes/hashing.d.ts.map +0 -1
- package/dest/avm/opcodes/hashing.js +0 -103
- package/dest/avm/opcodes/index.d.ts.map +0 -1
- package/dest/avm/opcodes/index.js +0 -16
- package/dest/avm/opcodes/instruction.d.ts.map +0 -1
- package/dest/avm/opcodes/instruction.js +0 -100
- package/dest/avm/opcodes/instruction_impl.d.ts.map +0 -1
- package/dest/avm/opcodes/instruction_impl.js +0 -33
- package/dest/avm/opcodes/memory.d.ts.map +0 -1
- package/dest/avm/opcodes/memory.js +0 -226
- package/dest/avm/opcodes/misc.d.ts.map +0 -1
- package/dest/avm/opcodes/misc.js +0 -45
- package/dest/avm/opcodes/multi_scalar_mul.d.ts +0 -16
- package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +0 -1
- package/dest/avm/opcodes/multi_scalar_mul.js +0 -112
- package/dest/avm/opcodes/storage.d.ts.map +0 -1
- package/dest/avm/opcodes/storage.js +0 -61
- package/dest/avm/serialization/buffer_cursor.d.ts.map +0 -1
- package/dest/avm/serialization/buffer_cursor.js +0 -99
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +0 -1
- package/dest/avm/serialization/bytecode_serialization.js +0 -132
- package/dest/avm/serialization/instruction_serialization.d.ts.map +0 -1
- package/dest/avm/serialization/instruction_serialization.js +0 -187
- package/dest/avm/test_utils.d.ts.map +0 -1
- package/dest/avm/test_utils.js +0 -52
- package/dest/client/client_execution_context.d.ts.map +0 -1
- package/dest/client/client_execution_context.js +0 -392
- package/dest/client/db_oracle.d.ts.map +0 -1
- package/dest/client/db_oracle.js +0 -17
- package/dest/client/execution_note_cache.d.ts.map +0 -1
- package/dest/client/execution_note_cache.js +0 -181
- package/dest/client/index.d.ts +0 -16
- package/dest/client/index.d.ts.map +0 -1
- package/dest/client/index.js +0 -15
- package/dest/client/pick_notes.d.ts.map +0 -1
- package/dest/client/pick_notes.js +0 -54
- package/dest/client/private_execution.d.ts +0 -19
- package/dest/client/private_execution.d.ts.map +0 -1
- package/dest/client/private_execution.js +0 -72
- package/dest/client/simulator.d.ts +0 -60
- package/dest/client/simulator.d.ts.map +0 -1
- package/dest/client/simulator.js +0 -136
- package/dest/client/unconstrained_execution.d.ts.map +0 -1
- package/dest/client/unconstrained_execution.js +0 -30
- package/dest/client/view_data_oracle.d.ts.map +0 -1
- package/dest/client/view_data_oracle.js +0 -268
- package/dest/common/hashed_values_cache.d.ts.map +0 -1
- package/dest/common/hashed_values_cache.js +0 -50
- package/dest/common/simulation_provider.d.ts.map +0 -1
- package/dest/common/simulation_provider.js +0 -27
- package/dest/common.d.ts +0 -2
- package/dest/common.d.ts.map +0 -1
- package/dest/common.js +0 -2
- package/dest/providers/acvm_native.d.ts.map +0 -1
- package/dest/providers/acvm_native.js +0 -125
- package/dest/providers/acvm_wasm.d.ts.map +0 -1
- package/dest/providers/acvm_wasm.js +0 -54
- package/dest/providers/acvm_wasm_with_blobs.d.ts.map +0 -1
- package/dest/providers/factory.d.ts.map +0 -1
- package/dest/providers/factory.js +0 -27
- package/dest/providers/index.d.ts +0 -5
- package/dest/providers/index.d.ts.map +0 -1
- package/dest/providers/index.js +0 -5
- package/dest/public/db_interfaces.d.ts.map +0 -1
- package/dest/public/db_interfaces.js +0 -2
- package/dest/public/fee_payment.d.ts +0 -11
- package/dest/public/fee_payment.d.ts.map +0 -1
- package/dest/public/fee_payment.js +0 -21
- package/dest/public/public_processor.d.ts.map +0 -1
- package/dest/public/public_processor.js +0 -352
- package/dest/public/public_processor_metrics.d.ts.map +0 -1
- package/dest/public/public_processor_metrics.js +0 -106
- package/dest/public/public_tx_context.d.ts.map +0 -1
- package/dest/public/public_tx_context.js +0 -341
- package/dest/public/public_tx_simulator.d.ts.map +0 -1
- package/dest/public/public_tx_simulator.js +0 -333
- package/dest/stats/index.d.ts.map +0 -1
- package/dest/stats/index.js +0 -2
- package/dest/stats/stats.d.ts.map +0 -1
- package/dest/stats/stats.js +0 -11
- package/src/avm/avm_tree.ts +0 -887
- package/src/avm/opcodes/multi_scalar_mul.ts +0 -121
- package/src/avm/serialization/bytecode_serialization.ts +0 -212
- package/src/client/index.ts +0 -15
- package/src/common.ts +0 -1
- package/src/providers/index.ts +0 -4
- package/src/public/fee_payment.ts +0 -23
- /package/dest/{stats → common/stats}/index.d.ts +0 -0
- /package/{src/stats/index.ts → dest/common/stats/index.js} +0 -0
- /package/dest/{acvm → private/acvm}/index.d.ts +0 -0
- /package/dest/{avm → public/avm}/avm_gas.d.ts +0 -0
- /package/dest/{avm → public/avm}/bytecode_utils.d.ts +0 -0
- /package/dest/{avm → public/avm}/journal/index.d.ts +0 -0
- /package/{src/avm/journal/index.ts → dest/public/avm/journal/index.js} +0 -0
- /package/dest/{avm → public/avm}/opcodes/accrued_substate.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/addressing_mode.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/arithmetic.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/bitwise.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/comparators.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/contract.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/control_flow.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/environment_getters.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/external_calls.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/index.d.ts +0 -0
- /package/{src/avm/opcodes/index.ts → dest/public/avm/opcodes/index.js} +0 -0
- /package/dest/{avm → public/avm}/opcodes/instruction_impl.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/memory.d.ts +0 -0
- /package/dest/{avm → public/avm}/opcodes/storage.d.ts +0 -0
- /package/dest/{avm → public/avm}/serialization/buffer_cursor.d.ts +0 -0
- /package/src/{acvm → private/acvm}/index.ts +0 -0
- /package/src/{avm → public/avm}/bytecode_utils.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/.eslintrc.cjs +0 -0
- /package/src/{avm → public/avm}/opcodes/accrued_substate.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/addressing_mode.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/arithmetic.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/bitwise.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/comparators.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/environment_getters.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/instruction_impl.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/memory.ts +0 -0
- /package/src/{avm → public/avm}/opcodes/storage.ts +0 -0
- /package/src/{avm → public/avm}/serialization/buffer_cursor.ts +0 -0
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { type DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
6
|
+
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
7
|
+
import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
|
|
8
|
+
import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
9
|
+
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
10
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
12
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
13
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
14
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
1
15
|
import {
|
|
2
16
|
type FailedTx,
|
|
3
|
-
|
|
4
|
-
type MerkleTreeWriteOperations,
|
|
17
|
+
GlobalVariables,
|
|
5
18
|
NestedProcessReturnValues,
|
|
6
19
|
type ProcessedTx,
|
|
7
20
|
Tx,
|
|
@@ -9,23 +22,7 @@ import {
|
|
|
9
22
|
type TxValidator,
|
|
10
23
|
makeProcessedTxFromPrivateOnlyTx,
|
|
11
24
|
makeProcessedTxFromTxWithPublicCalls,
|
|
12
|
-
} from '@aztec/
|
|
13
|
-
import {
|
|
14
|
-
type AztecAddress,
|
|
15
|
-
type ContractDataSource,
|
|
16
|
-
Fr,
|
|
17
|
-
Gas,
|
|
18
|
-
type GlobalVariables,
|
|
19
|
-
MAX_NOTE_HASHES_PER_TX,
|
|
20
|
-
MAX_NULLIFIERS_PER_TX,
|
|
21
|
-
NULLIFIER_SUBTREE_HEIGHT,
|
|
22
|
-
PublicDataWrite,
|
|
23
|
-
} from '@aztec/circuits.js';
|
|
24
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
25
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
26
|
-
import { type DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
27
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
28
|
-
import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
|
|
25
|
+
} from '@aztec/stdlib/tx';
|
|
29
26
|
import {
|
|
30
27
|
Attributes,
|
|
31
28
|
type TelemetryClient,
|
|
@@ -34,11 +31,11 @@ import {
|
|
|
34
31
|
getTelemetryClient,
|
|
35
32
|
trackSpan,
|
|
36
33
|
} from '@aztec/telemetry-client';
|
|
34
|
+
import { ForkCheckpoint } from '@aztec/world-state/native';
|
|
37
35
|
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
36
|
+
import { WorldStateDB } from '../public_db_sources.js';
|
|
37
|
+
import { PublicTxSimulator } from '../public_tx_simulator/public_tx_simulator.js';
|
|
40
38
|
import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
41
|
-
import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
42
39
|
|
|
43
40
|
/**
|
|
44
41
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
@@ -54,13 +51,13 @@ export class PublicProcessorFactory {
|
|
|
54
51
|
* Creates a new instance of a PublicProcessor.
|
|
55
52
|
* @param historicalHeader - The header of a block previous to the one in which the tx is included.
|
|
56
53
|
* @param globalVariables - The global variables for the block being processed.
|
|
57
|
-
* @param
|
|
54
|
+
* @param skipFeeEnforcement - Allows disabling balance checks for fee estimations.
|
|
58
55
|
* @returns A new instance of a PublicProcessor.
|
|
59
56
|
*/
|
|
60
57
|
public create(
|
|
61
58
|
merkleTree: MerkleTreeWriteOperations,
|
|
62
59
|
globalVariables: GlobalVariables,
|
|
63
|
-
|
|
60
|
+
skipFeeEnforcement: boolean,
|
|
64
61
|
): PublicProcessor {
|
|
65
62
|
const worldStateDB = new WorldStateDB(merkleTree, this.contractDataSource);
|
|
66
63
|
const publicTxSimulator = this.createPublicTxSimulator(
|
|
@@ -68,7 +65,7 @@ export class PublicProcessorFactory {
|
|
|
68
65
|
worldStateDB,
|
|
69
66
|
globalVariables,
|
|
70
67
|
/*doMerkleOperations=*/ true,
|
|
71
|
-
|
|
68
|
+
skipFeeEnforcement,
|
|
72
69
|
this.telemetryClient,
|
|
73
70
|
);
|
|
74
71
|
|
|
@@ -87,7 +84,7 @@ export class PublicProcessorFactory {
|
|
|
87
84
|
worldStateDB: WorldStateDB,
|
|
88
85
|
globalVariables: GlobalVariables,
|
|
89
86
|
doMerkleOperations: boolean,
|
|
90
|
-
|
|
87
|
+
skipFeeEnforcement: boolean,
|
|
91
88
|
telemetryClient: TelemetryClient,
|
|
92
89
|
) {
|
|
93
90
|
return new PublicTxSimulator(
|
|
@@ -95,7 +92,7 @@ export class PublicProcessorFactory {
|
|
|
95
92
|
worldStateDB,
|
|
96
93
|
globalVariables,
|
|
97
94
|
doMerkleOperations,
|
|
98
|
-
|
|
95
|
+
skipFeeEnforcement,
|
|
99
96
|
telemetryClient,
|
|
100
97
|
);
|
|
101
98
|
}
|
|
@@ -222,6 +219,11 @@ export class PublicProcessor implements Traceable {
|
|
|
222
219
|
}
|
|
223
220
|
}
|
|
224
221
|
|
|
222
|
+
// We checkpoint the transaction here, then within the try/catch we
|
|
223
|
+
// 1. Revert the checkpoint if the tx fails or needs to be discarded for any reason
|
|
224
|
+
// 2. Commit the transaction in the finally block. Note that by using the ForkCheckpoint lifecycle only the first commit/revert takes effect
|
|
225
|
+
const checkpoint = await ForkCheckpoint.new(this.worldStateDB);
|
|
226
|
+
|
|
225
227
|
try {
|
|
226
228
|
const [processedTx, returnValues] = await this.processTx(tx, deadline);
|
|
227
229
|
|
|
@@ -234,6 +236,8 @@ export class PublicProcessor implements Traceable {
|
|
|
234
236
|
totalSizeInBytes,
|
|
235
237
|
maxBlockSize,
|
|
236
238
|
});
|
|
239
|
+
// Need to revert the checkpoint here and don't go any further
|
|
240
|
+
await checkpoint.revert();
|
|
237
241
|
continue;
|
|
238
242
|
}
|
|
239
243
|
|
|
@@ -249,14 +253,24 @@ export class PublicProcessor implements Traceable {
|
|
|
249
253
|
const reason = result.reason.join(', ');
|
|
250
254
|
this.log.error(`Rejecting tx ${processedTx.hash} after processing: ${reason}.`);
|
|
251
255
|
failed.push({ tx, error: new Error(`Tx failed post-process validation: ${reason}`) });
|
|
256
|
+
// Need to revert the checkpoint here and don't go any further
|
|
257
|
+
await checkpoint.revert();
|
|
252
258
|
continue;
|
|
253
259
|
} else {
|
|
254
|
-
this.log.trace(`Tx ${
|
|
260
|
+
this.log.trace(`Tx ${txHash.toString()} is valid post processing.`);
|
|
255
261
|
}
|
|
256
262
|
}
|
|
257
263
|
|
|
258
|
-
|
|
259
|
-
|
|
264
|
+
if (!tx.hasPublicCalls()) {
|
|
265
|
+
// If there are no public calls, perform all tree insertions for side effects from private
|
|
266
|
+
// When there are public calls, the PublicTxSimulator & AVM handle tree insertions.
|
|
267
|
+
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
268
|
+
// Add any contracts registered/deployed in this private-only tx to the block-level cache
|
|
269
|
+
// (add to tx-level cache and then commit to block-level cache)
|
|
270
|
+
await this.worldStateDB.addNewContracts(tx);
|
|
271
|
+
this.worldStateDB.commitContractsForTx();
|
|
272
|
+
}
|
|
273
|
+
|
|
260
274
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
|
|
261
275
|
result.push(processedTx);
|
|
262
276
|
returns = returns.concat(returnValues);
|
|
@@ -265,15 +279,22 @@ export class PublicProcessor implements Traceable {
|
|
|
265
279
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
266
280
|
totalSizeInBytes += txSize;
|
|
267
281
|
} catch (err: any) {
|
|
282
|
+
// Roll back state to start of TX before proceeding to next TX
|
|
283
|
+
await checkpoint.revert();
|
|
268
284
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
269
285
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
270
286
|
break;
|
|
271
287
|
}
|
|
272
288
|
const errorMessage = err instanceof Error ? err.message : 'Unknown error';
|
|
273
|
-
this.log.warn(`Failed to process tx ${
|
|
289
|
+
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
274
290
|
|
|
275
291
|
failed.push({ tx, error: err instanceof Error ? err : new Error(errorMessage) });
|
|
276
292
|
returns.push(new NestedProcessReturnValues([]));
|
|
293
|
+
} finally {
|
|
294
|
+
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was reverted
|
|
295
|
+
await checkpoint.commit();
|
|
296
|
+
// The tx-level contracts cache should not live on to the next tx
|
|
297
|
+
this.worldStateDB.clearContractsForTx();
|
|
277
298
|
}
|
|
278
299
|
}
|
|
279
300
|
|
|
@@ -281,7 +302,7 @@ export class PublicProcessor implements Traceable {
|
|
|
281
302
|
const rate = duration > 0 ? totalPublicGas.l2Gas / duration : 0;
|
|
282
303
|
this.metrics.recordAllTxs(totalPublicGas, rate);
|
|
283
304
|
|
|
284
|
-
this.log.info(`Processed ${result.length} successful txs and ${failed.length} txs in ${duration}s`, {
|
|
305
|
+
this.log.info(`Processed ${result.length} successful txs and ${failed.length} failed txs in ${duration}s`, {
|
|
285
306
|
duration,
|
|
286
307
|
rate,
|
|
287
308
|
totalPublicGas,
|
|
@@ -309,7 +330,7 @@ export class PublicProcessor implements Traceable {
|
|
|
309
330
|
publicDataWriteCount: processedTx.txEffect.publicDataWrites.length,
|
|
310
331
|
nullifierCount: processedTx.txEffect.nullifiers.length,
|
|
311
332
|
noteHashCount: processedTx.txEffect.noteHashes.length,
|
|
312
|
-
contractClassLogCount: processedTx.txEffect.contractClassLogs.
|
|
333
|
+
contractClassLogCount: processedTx.txEffect.contractClassLogs.length,
|
|
313
334
|
publicLogCount: processedTx.txEffect.publicLogs.length,
|
|
314
335
|
privateLogCount: processedTx.txEffect.privateLogs.length,
|
|
315
336
|
l2ToL1MessageCount: processedTx.txEffect.l2ToL1Msgs.length,
|
|
@@ -320,10 +341,11 @@ export class PublicProcessor implements Traceable {
|
|
|
320
341
|
return [processedTx, returnValues ?? []];
|
|
321
342
|
}
|
|
322
343
|
|
|
323
|
-
private async
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
344
|
+
private async doTreeInsertionsForPrivateOnlyTx(
|
|
345
|
+
processedTx: ProcessedTx,
|
|
346
|
+
txValidator?: TxValidator<ProcessedTx>,
|
|
347
|
+
): Promise<void> {
|
|
348
|
+
const treeInsertionStart = process.hrtime.bigint();
|
|
327
349
|
|
|
328
350
|
// Update the state so that the next tx in the loop has the correct .startState
|
|
329
351
|
// NB: before this change, all .startStates were actually incorrect, but the issue was never caught because we either:
|
|
@@ -331,7 +353,6 @@ export class PublicProcessor implements Traceable {
|
|
|
331
353
|
// b) always had a txHandler with the same db passed to it as this.db, which updated the db in buildBaseRollupHints in this loop
|
|
332
354
|
// To see how this ^ happens, move back to one shared db in test_context and run orchestrator_multi_public_functions.test.ts
|
|
333
355
|
// The below is taken from buildBaseRollupHints:
|
|
334
|
-
const treeInsertionStart = process.hrtime.bigint();
|
|
335
356
|
await this.db.appendLeaves(
|
|
336
357
|
MerkleTreeId.NOTE_HASH_TREE,
|
|
337
358
|
padArrayEnd(processedTx.txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
|
|
@@ -352,6 +373,7 @@ export class PublicProcessor implements Traceable {
|
|
|
352
373
|
}
|
|
353
374
|
}
|
|
354
375
|
|
|
376
|
+
// The only public data write should be for fee payment
|
|
355
377
|
await this.db.sequentialInsert(
|
|
356
378
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
357
379
|
processedTx.txEffect.publicDataWrites.map(x => x.toBuffer()),
|
|
@@ -397,12 +419,7 @@ export class PublicProcessor implements Traceable {
|
|
|
397
419
|
* This is used in private only txs, since for txs with public calls
|
|
398
420
|
* the avm handles the fee payment itself.
|
|
399
421
|
*/
|
|
400
|
-
private async getFeePaymentPublicDataWrite(txFee: Fr, feePayer: AztecAddress): Promise<PublicDataWrite
|
|
401
|
-
if (feePayer.isZero()) {
|
|
402
|
-
this.log.debug(`No one is paying the fee of ${txFee.toBigInt()}`);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
|
|
422
|
+
private async getFeePaymentPublicDataWrite(txFee: Fr, feePayer: AztecAddress): Promise<PublicDataWrite> {
|
|
406
423
|
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
407
424
|
const balanceSlot = await computeFeePayerBalanceStorageSlot(feePayer);
|
|
408
425
|
const leafSlot = await computeFeePayerBalanceLeafSlot(feePayer);
|
|
@@ -439,11 +456,15 @@ export class PublicProcessor implements Traceable {
|
|
|
439
456
|
this.globalVariables,
|
|
440
457
|
);
|
|
441
458
|
|
|
459
|
+
const siloedContractClassLogs = await tx.filterContractClassLogs(
|
|
460
|
+
tx.data.getNonEmptyContractClassLogsHashes(),
|
|
461
|
+
true,
|
|
462
|
+
);
|
|
463
|
+
|
|
442
464
|
this.metrics.recordClassRegistration(
|
|
443
|
-
...
|
|
444
|
-
.
|
|
445
|
-
.
|
|
446
|
-
.map(log => ContractClassRegisteredEvent.fromLog(log.data)),
|
|
465
|
+
...siloedContractClassLogs
|
|
466
|
+
.filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log))
|
|
467
|
+
.map(log => ContractClassRegisteredEvent.fromLog(log)),
|
|
447
468
|
);
|
|
448
469
|
return [processedTx, undefined];
|
|
449
470
|
}
|
|
@@ -463,18 +484,22 @@ export class PublicProcessor implements Traceable {
|
|
|
463
484
|
}
|
|
464
485
|
|
|
465
486
|
processedPhases.forEach(phase => {
|
|
466
|
-
if (phase.
|
|
487
|
+
if (phase.reverted) {
|
|
467
488
|
this.metrics.recordRevertedPhase(phase.phase);
|
|
468
489
|
} else {
|
|
469
490
|
this.metrics.recordPhaseDuration(phase.phase, phase.durationMs);
|
|
470
491
|
}
|
|
471
492
|
});
|
|
472
493
|
|
|
494
|
+
const siloedContractClassLogs = await tx.filterContractClassLogs(
|
|
495
|
+
tx.data.getNonEmptyContractClassLogsHashes(),
|
|
496
|
+
true,
|
|
497
|
+
);
|
|
498
|
+
|
|
473
499
|
this.metrics.recordClassRegistration(
|
|
474
|
-
...
|
|
475
|
-
.
|
|
476
|
-
.
|
|
477
|
-
.map(log => ContractClassRegisteredEvent.fromLog(log.data)),
|
|
500
|
+
...siloedContractClassLogs
|
|
501
|
+
.filter(log => ContractClassRegisteredEvent.isContractClassRegisteredEvent(log))
|
|
502
|
+
.map(log => ContractClassRegisteredEvent.fromLog(log)),
|
|
478
503
|
);
|
|
479
504
|
|
|
480
505
|
const phaseCount = processedPhases.length;
|
package/src/public/{public_processor_metrics.ts → public_processor/public_processor_metrics.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
|
|
2
|
+
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
|
+
import type { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
import {
|
|
5
5
|
Attributes,
|
|
6
6
|
type Gauge,
|
|
@@ -1,50 +1,54 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type AvmProvingRequest,
|
|
3
|
-
MerkleTreeId,
|
|
4
|
-
type MerkleTreeReadOperations,
|
|
5
|
-
ProvingRequestType,
|
|
6
|
-
type PublicExecutionRequest,
|
|
7
|
-
type SimulationError,
|
|
8
|
-
type Tx,
|
|
9
|
-
TxExecutionPhase,
|
|
10
|
-
type TxHash,
|
|
11
|
-
} from '@aztec/circuit-types';
|
|
12
|
-
import {
|
|
13
|
-
AvmCircuitInputs,
|
|
14
|
-
type AvmCircuitPublicInputs,
|
|
15
|
-
type AztecAddress,
|
|
16
|
-
Fr,
|
|
17
|
-
Gas,
|
|
18
|
-
type GasSettings,
|
|
19
|
-
type GlobalVariables,
|
|
20
2
|
MAX_L2_GAS_PER_TX_PUBLIC_PORTION,
|
|
21
3
|
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
22
4
|
MAX_NOTE_HASHES_PER_TX,
|
|
23
5
|
MAX_NULLIFIERS_PER_TX,
|
|
24
6
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
7
|
+
NULLIFIER_SUBTREE_HEIGHT,
|
|
8
|
+
} from '@aztec/constants';
|
|
9
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
10
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
11
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
12
|
+
import { assertLength } from '@aztec/foundation/serialize';
|
|
13
|
+
import {
|
|
14
|
+
AvmCircuitInputs,
|
|
15
|
+
type AvmCircuitPublicInputs,
|
|
16
|
+
type AvmProvingRequest,
|
|
17
|
+
PublicDataWrite,
|
|
18
|
+
RevertCode,
|
|
19
|
+
} from '@aztec/stdlib/avm';
|
|
20
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import type { SimulationError } from '@aztec/stdlib/errors';
|
|
22
|
+
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
23
|
+
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
24
|
+
import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
25
|
+
import {
|
|
25
26
|
PrivateToAvmAccumulatedData,
|
|
26
27
|
PrivateToAvmAccumulatedDataArrayLengths,
|
|
27
28
|
type PrivateToPublicAccumulatedData,
|
|
28
29
|
PublicCallRequest,
|
|
29
|
-
PublicDataWrite,
|
|
30
|
-
RevertCode,
|
|
31
|
-
type StateReference,
|
|
32
|
-
TreeSnapshots,
|
|
33
|
-
computeTransactionFee,
|
|
34
30
|
countAccumulatedItems,
|
|
35
31
|
mergeAccumulatedData,
|
|
36
|
-
} from '@aztec/
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
32
|
+
} from '@aztec/stdlib/kernel';
|
|
33
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
34
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
35
|
+
import {
|
|
36
|
+
type GlobalVariables,
|
|
37
|
+
type PublicExecutionRequest,
|
|
38
|
+
type StateReference,
|
|
39
|
+
TreeSnapshots,
|
|
40
|
+
type Tx,
|
|
41
|
+
TxExecutionPhase,
|
|
42
|
+
type TxHash,
|
|
43
|
+
} from '@aztec/stdlib/tx';
|
|
40
44
|
|
|
41
45
|
import { strict as assert } from 'assert';
|
|
42
46
|
import { inspect } from 'util';
|
|
43
47
|
|
|
44
48
|
import { AvmPersistableStateManager } from '../avm/index.js';
|
|
45
|
-
import {
|
|
46
|
-
import { SideEffectArrayLengths, SideEffectTrace } from '
|
|
47
|
-
import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '
|
|
49
|
+
import type { WorldStateDB } from '../public_db_sources.js';
|
|
50
|
+
import { SideEffectArrayLengths, SideEffectTrace } from '../side_effect_trace.js';
|
|
51
|
+
import { getCallRequestsByPhase, getExecutionRequestsByPhase } from '../utils.js';
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* The transaction-level context for public execution.
|
|
@@ -111,12 +115,7 @@ export class PublicTxContext {
|
|
|
111
115
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
112
116
|
|
|
113
117
|
// Transaction level state manager that will be forked for revertible phases.
|
|
114
|
-
const txStateManager =
|
|
115
|
-
worldStateDB,
|
|
116
|
-
trace,
|
|
117
|
-
doMerkleOperations,
|
|
118
|
-
firstNullifier,
|
|
119
|
-
);
|
|
118
|
+
const txStateManager = AvmPersistableStateManager.create(worldStateDB, trace, doMerkleOperations, firstNullifier);
|
|
120
119
|
|
|
121
120
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
122
121
|
const gasUsedByPrivate = tx.data.gasUsed;
|
|
@@ -149,9 +148,9 @@ export class PublicTxContext {
|
|
|
149
148
|
* All phases have been processed.
|
|
150
149
|
* Actual transaction fee and actual total consumed gas can now be queried.
|
|
151
150
|
*/
|
|
152
|
-
halt() {
|
|
151
|
+
async halt() {
|
|
153
152
|
if (this.state.isForked()) {
|
|
154
|
-
this.state.mergeForkedState();
|
|
153
|
+
await this.state.mergeForkedState();
|
|
155
154
|
}
|
|
156
155
|
this.halted = true;
|
|
157
156
|
}
|
|
@@ -325,37 +324,7 @@ export class PublicTxContext {
|
|
|
325
324
|
*/
|
|
326
325
|
private async generateAvmCircuitPublicInputs(endStateReference: StateReference): Promise<AvmCircuitPublicInputs> {
|
|
327
326
|
assert(this.halted, 'Can only get AvmCircuitPublicInputs after tx execution ends');
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
const noteHashTree = await ephemeralTrees.getTreeSnapshot(MerkleTreeId.NOTE_HASH_TREE);
|
|
331
|
-
const nullifierTree = await ephemeralTrees.getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE);
|
|
332
|
-
const publicDataTree = await ephemeralTrees.getTreeSnapshot(MerkleTreeId.PUBLIC_DATA_TREE);
|
|
333
|
-
|
|
334
|
-
// Pad the note hash and nullifier trees
|
|
335
|
-
const paddedNoteHashTreeSize =
|
|
336
|
-
this.startStateReference.partial.noteHashTree.nextAvailableLeafIndex + MAX_NOTE_HASHES_PER_TX;
|
|
337
|
-
if (noteHashTree.nextAvailableLeafIndex > paddedNoteHashTreeSize) {
|
|
338
|
-
throw new Error(
|
|
339
|
-
`Inserted too many leaves in note hash tree: ${noteHashTree.nextAvailableLeafIndex} > ${paddedNoteHashTreeSize}`,
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
noteHashTree.nextAvailableLeafIndex = paddedNoteHashTreeSize;
|
|
343
|
-
|
|
344
|
-
const paddedNullifierTreeSize =
|
|
345
|
-
this.startStateReference.partial.nullifierTree.nextAvailableLeafIndex + MAX_NULLIFIERS_PER_TX;
|
|
346
|
-
if (nullifierTree.nextAvailableLeafIndex > paddedNullifierTreeSize) {
|
|
347
|
-
throw new Error(
|
|
348
|
-
`Inserted too many leaves in nullifier tree: ${nullifierTree.nextAvailableLeafIndex} > ${paddedNullifierTreeSize}`,
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
nullifierTree.nextAvailableLeafIndex = paddedNullifierTreeSize;
|
|
352
|
-
|
|
353
|
-
const endTreeSnapshots = new TreeSnapshots(
|
|
354
|
-
endStateReference.l1ToL2MessageTree,
|
|
355
|
-
noteHashTree,
|
|
356
|
-
nullifierTree,
|
|
357
|
-
publicDataTree,
|
|
358
|
-
);
|
|
327
|
+
const stateManager = this.state.getActiveStateManager();
|
|
359
328
|
|
|
360
329
|
const startTreeSnapshots = new TreeSnapshots(
|
|
361
330
|
this.startStateReference.l1ToL2MessageTree,
|
|
@@ -364,6 +333,14 @@ export class PublicTxContext {
|
|
|
364
333
|
this.startStateReference.partial.publicDataTree,
|
|
365
334
|
);
|
|
366
335
|
|
|
336
|
+
// Will be patched/padded at the end of this fn
|
|
337
|
+
const endTreeSnapshots = new TreeSnapshots(
|
|
338
|
+
endStateReference.l1ToL2MessageTree,
|
|
339
|
+
endStateReference.partial.noteHashTree,
|
|
340
|
+
endStateReference.partial.nullifierTree,
|
|
341
|
+
endStateReference.partial.publicDataTree,
|
|
342
|
+
);
|
|
343
|
+
|
|
367
344
|
const avmCircuitPublicInputs = this.trace.toAvmCircuitPublicInputs(
|
|
368
345
|
this.globalVariables,
|
|
369
346
|
startTreeSnapshots,
|
|
@@ -427,6 +404,24 @@ export class PublicTxContext {
|
|
|
427
404
|
PublicDataWrite.empty(),
|
|
428
405
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
429
406
|
);
|
|
407
|
+
const numNoteHashesToPad =
|
|
408
|
+
MAX_NOTE_HASHES_PER_TX - countAccumulatedItems(avmCircuitPublicInputs.accumulatedData.noteHashes);
|
|
409
|
+
await stateManager.db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd([], Fr.ZERO, numNoteHashesToPad));
|
|
410
|
+
const numNullifiersToPad =
|
|
411
|
+
MAX_NULLIFIERS_PER_TX - countAccumulatedItems(avmCircuitPublicInputs.accumulatedData.nullifiers);
|
|
412
|
+
await stateManager.db.batchInsert(
|
|
413
|
+
MerkleTreeId.NULLIFIER_TREE,
|
|
414
|
+
padArrayEnd([], Fr.ZERO, numNullifiersToPad).map(nullifier => nullifier.toBuffer()),
|
|
415
|
+
NULLIFIER_SUBTREE_HEIGHT,
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
const paddedState = await stateManager.db.getStateReference();
|
|
419
|
+
avmCircuitPublicInputs.endTreeSnapshots = new TreeSnapshots(
|
|
420
|
+
paddedState.l1ToL2MessageTree,
|
|
421
|
+
paddedState.partial.noteHashTree,
|
|
422
|
+
paddedState.partial.nullifierTree,
|
|
423
|
+
paddedState.partial.publicDataTree,
|
|
424
|
+
);
|
|
430
425
|
|
|
431
426
|
return avmCircuitPublicInputs;
|
|
432
427
|
}
|
|
@@ -467,10 +462,10 @@ class PhaseStateManager {
|
|
|
467
462
|
this.log = createLogger(`simulator:public_phase_state_manager`);
|
|
468
463
|
}
|
|
469
464
|
|
|
470
|
-
fork() {
|
|
465
|
+
async fork() {
|
|
471
466
|
assert(!this.currentlyActiveStateManager, 'Cannot fork when already forked');
|
|
472
467
|
this.log.debug(`Forking phase state manager`);
|
|
473
|
-
this.currentlyActiveStateManager = this.txStateManager.fork();
|
|
468
|
+
this.currentlyActiveStateManager = await this.txStateManager.fork();
|
|
474
469
|
}
|
|
475
470
|
|
|
476
471
|
getActiveStateManager() {
|
|
@@ -481,18 +476,18 @@ class PhaseStateManager {
|
|
|
481
476
|
return !!this.currentlyActiveStateManager;
|
|
482
477
|
}
|
|
483
478
|
|
|
484
|
-
mergeForkedState() {
|
|
479
|
+
async mergeForkedState() {
|
|
485
480
|
assert(this.currentlyActiveStateManager, 'No forked state to merge');
|
|
486
481
|
this.log.debug(`Merging in forked state`);
|
|
487
|
-
this.txStateManager.merge(this.currentlyActiveStateManager!);
|
|
482
|
+
await this.txStateManager.merge(this.currentlyActiveStateManager!);
|
|
488
483
|
// Drop the forked state manager now that it is merged
|
|
489
484
|
this.currentlyActiveStateManager = undefined;
|
|
490
485
|
}
|
|
491
486
|
|
|
492
|
-
discardForkedState() {
|
|
487
|
+
async discardForkedState() {
|
|
493
488
|
this.log.debug(`Discarding forked state`);
|
|
494
489
|
assert(this.currentlyActiveStateManager, 'No forked state to discard');
|
|
495
|
-
this.txStateManager.reject(this.currentlyActiveStateManager!);
|
|
490
|
+
await this.txStateManager.reject(this.currentlyActiveStateManager!);
|
|
496
491
|
// Drop the forked state manager. We don't want it!
|
|
497
492
|
this.currentlyActiveStateManager = undefined;
|
|
498
493
|
}
|