@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,6 +1,6 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { WorldStateDB } from '../../public_db_sources.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A class to manage new nullifier staging and existence checks during a contract call's AVM simulation.
|
|
@@ -10,7 +10,7 @@ import type { CommitmentsDB } from '../../server.js';
|
|
|
10
10
|
export class NullifierManager {
|
|
11
11
|
constructor(
|
|
12
12
|
/** Reference to node storage. Checked on parent cache-miss. */
|
|
13
|
-
private readonly hostNullifiers:
|
|
13
|
+
private readonly hostNullifiers: WorldStateDB,
|
|
14
14
|
/** Cache of siloed nullifiers. */
|
|
15
15
|
private cache: Set<bigint> = new Set(),
|
|
16
16
|
/** Parent nullifier manager to fall back on */
|
|
@@ -50,24 +50,25 @@ export class NullifierManager {
|
|
|
50
50
|
*
|
|
51
51
|
* @param siloedNullifier - the nullifier to check for
|
|
52
52
|
* @returns exists: whether the nullifier exists at all,
|
|
53
|
-
*
|
|
54
|
-
* leafIndex: the nullifier's leaf index if it exists and is not pending (comes from host state).
|
|
53
|
+
* cacheHit: whether the nullifier was found in a cache,
|
|
55
54
|
*/
|
|
56
|
-
public async checkExists(
|
|
57
|
-
siloedNullifier: Fr,
|
|
58
|
-
): Promise<[/*exists=*/ boolean, /*isPending=*/ boolean, /*leafIndex=*/ Fr]> {
|
|
55
|
+
public async checkExists(siloedNullifier: Fr): Promise<{ exists: boolean; cacheHit: boolean }> {
|
|
59
56
|
// Check this cache and parent's (recursively)
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
//
|
|
66
|
-
|
|
57
|
+
const cacheHit = this.checkExistsHereOrParent(siloedNullifier);
|
|
58
|
+
let existsInTree = false;
|
|
59
|
+
if (!cacheHit) {
|
|
60
|
+
// Finally try the host's Aztec state (a trip to the database)
|
|
61
|
+
//const leafOrLowLeafIndex = await this.hostNullifiers.db.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, siloedNullifier.toBigInt());
|
|
62
|
+
//assert(
|
|
63
|
+
// leafOrLowLeafIndex !== undefined,
|
|
64
|
+
// `${MerkleTreeId[MerkleTreeId.NULLIFIER_TREE]} low leaf index should always be found (even if target leaf does not exist)`,
|
|
65
|
+
//);
|
|
66
|
+
//existsInTree = leafOrLowLeafIndex.alreadyPresent;
|
|
67
|
+
const leafIndex = await this.hostNullifiers.getNullifierIndex(siloedNullifier);
|
|
68
|
+
existsInTree = leafIndex !== undefined;
|
|
67
69
|
}
|
|
68
|
-
const exists =
|
|
69
|
-
|
|
70
|
-
return Promise.resolve([exists, existsAsPending, new Fr(leafIndex)]);
|
|
70
|
+
const exists = cacheHit || existsInTree;
|
|
71
|
+
return Promise.resolve({ exists, cacheHit });
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
/**
|
|
@@ -76,7 +77,7 @@ export class NullifierManager {
|
|
|
76
77
|
* @param siloedNullifier - the nullifier to stage
|
|
77
78
|
*/
|
|
78
79
|
public async append(siloedNullifier: Fr) {
|
|
79
|
-
const
|
|
80
|
+
const { exists } = await this.checkExists(siloedNullifier);
|
|
80
81
|
if (exists) {
|
|
81
82
|
throw new NullifierCollisionError(`Siloed nullifier ${siloedNullifier} already exists in parent cache or host.`);
|
|
82
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type AztecAddress } from '@aztec/circuits.js';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
|
|
4
|
-
import type { PublicStateDB } from '
|
|
4
|
+
import type { PublicStateDB } from '../../../common/db_interfaces.js';
|
|
5
5
|
|
|
6
6
|
type PublicStorageReadResult = {
|
|
7
7
|
value: Fr;
|
|
@@ -58,7 +58,7 @@ export class GetContractInstance extends Instruction {
|
|
|
58
58
|
memberValue = new Field(instance.deployer.toField());
|
|
59
59
|
break;
|
|
60
60
|
case ContractInstanceMember.CLASS_ID:
|
|
61
|
-
memberValue = new Field(instance.
|
|
61
|
+
memberValue = new Field(instance.currentContractClassId.toField());
|
|
62
62
|
break;
|
|
63
63
|
case ContractInstanceMember.INIT_HASH:
|
|
64
64
|
memberValue = new Field(instance.initializationHash);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AvmContext } from '../avm_context.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { IntegralValue } from '../avm_memory_types.js';
|
|
3
3
|
import { InstructionExecutionError } from '../errors.js';
|
|
4
4
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
5
5
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AvmContext } from '../avm_context.js';
|
|
2
2
|
import { TypeTag, Uint1, Uint8 } from '../avm_memory_types.js';
|
|
3
3
|
import { InvalidToRadixInputsError } from '../errors.js';
|
|
4
4
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Grumpkin } from '@aztec/
|
|
1
|
+
import { Grumpkin } from '@aztec/foundation/crypto';
|
|
2
2
|
import { Point } from '@aztec/foundation/fields';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { AvmContext } from '../avm_context.js';
|
|
5
5
|
import { Field, TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
6
6
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
7
7
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { AvmContext } from '../avm_context.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { AvmContractCallResult } from '../avm_contract_call_result.js';
|
|
3
3
|
import { type Field, TypeTag, Uint1 } from '../avm_memory_types.js';
|
|
4
|
-
import { AvmSimulator } from '../avm_simulator.js';
|
|
5
4
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
6
5
|
import { Addressing } from './addressing_mode.js';
|
|
7
6
|
import { Instruction } from './instruction.js';
|
|
@@ -60,9 +59,9 @@ abstract class ExternalCall extends Instruction {
|
|
|
60
59
|
context.machineState.consumeGas(allocatedGas);
|
|
61
60
|
|
|
62
61
|
const aztecAddress = callAddress.toAztecAddress();
|
|
63
|
-
const nestedContext = context.createNestedContractCallContext(aztecAddress, calldata, allocatedGas, callType);
|
|
62
|
+
const nestedContext = await context.createNestedContractCallContext(aztecAddress, calldata, allocatedGas, callType);
|
|
64
63
|
|
|
65
|
-
const simulator = await
|
|
64
|
+
const simulator = await context.provideSimulator!(nestedContext);
|
|
66
65
|
const nestedCallResults: AvmContractCallResult = await simulator.execute();
|
|
67
66
|
const success = !nestedCallResults.reverted;
|
|
68
67
|
|
|
@@ -90,9 +89,9 @@ abstract class ExternalCall extends Instruction {
|
|
|
90
89
|
|
|
91
90
|
// Merge nested call's state and trace based on whether it succeeded.
|
|
92
91
|
if (success) {
|
|
93
|
-
context.persistableState.merge(nestedContext.persistableState);
|
|
92
|
+
await context.persistableState.merge(nestedContext.persistableState);
|
|
94
93
|
} else {
|
|
95
|
-
context.persistableState.reject(nestedContext.persistableState);
|
|
94
|
+
await context.persistableState.reject(nestedContext.persistableState);
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { keccakf1600, poseidon2Permutation, sha256Compression } from '@aztec/foundation/crypto';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { AvmContext } from '../avm_context.js';
|
|
4
4
|
import { Field, TypeTag, Uint32, Uint64 } from '../avm_memory_types.js';
|
|
5
5
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
6
6
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './arithmetic.js';
|
|
2
|
+
export * from './bitwise.js';
|
|
3
|
+
export * from './control_flow.js';
|
|
4
|
+
export * from './contract.js';
|
|
5
|
+
export * from './conversion.js';
|
|
6
|
+
export * from './instruction.js';
|
|
7
|
+
export * from './comparators.js';
|
|
8
|
+
export * from './memory.js';
|
|
9
|
+
export * from './misc.js';
|
|
10
|
+
export * from './storage.js';
|
|
11
|
+
export * from './external_calls.js';
|
|
12
|
+
export * from './environment_getters.js';
|
|
13
|
+
export * from './accrued_substate.js';
|
|
14
|
+
export * from './hashing.js';
|
|
15
|
+
export * from './ec_add.js';
|
|
@@ -2,8 +2,8 @@ import { strict as assert } from 'assert';
|
|
|
2
2
|
|
|
3
3
|
import type { AvmContext } from '../avm_context.js';
|
|
4
4
|
import { type Gas, getBaseGasCost, getDynamicGasCost, mulGas, sumGas } from '../avm_gas.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import type { BufferCursor } from '../serialization/buffer_cursor.js';
|
|
6
|
+
import type { Serializable } from '../serialization/bytecode_serialization.js';
|
|
7
7
|
import { Opcode, type OperandType, deserialize, serializeAs } from '../serialization/instruction_serialization.js';
|
|
8
8
|
|
|
9
9
|
type InstructionConstructor = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { AvmContext } from '../avm_context.js';
|
|
4
4
|
import { TypeTag } from '../avm_memory_types.js';
|
|
5
5
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
6
6
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { AvmExecutionError, AvmParsingError, InvalidOpcodeError, InvalidProgramCounterError } from '../errors.js';
|
|
2
|
+
import {
|
|
3
|
+
Add,
|
|
4
|
+
And,
|
|
5
|
+
Call,
|
|
6
|
+
CalldataCopy,
|
|
7
|
+
Cast,
|
|
8
|
+
DebugLog,
|
|
9
|
+
Div,
|
|
10
|
+
EcAdd,
|
|
11
|
+
EmitNoteHash,
|
|
12
|
+
EmitNullifier,
|
|
13
|
+
EmitUnencryptedLog,
|
|
14
|
+
Eq,
|
|
15
|
+
FieldDiv,
|
|
16
|
+
GetContractInstance,
|
|
17
|
+
GetEnvVar,
|
|
18
|
+
Instruction,
|
|
19
|
+
InternalCall,
|
|
20
|
+
InternalReturn,
|
|
21
|
+
Jump,
|
|
22
|
+
JumpI,
|
|
23
|
+
KeccakF1600,
|
|
24
|
+
L1ToL2MessageExists,
|
|
25
|
+
Lt,
|
|
26
|
+
Lte,
|
|
27
|
+
Mov,
|
|
28
|
+
Mul,
|
|
29
|
+
Not,
|
|
30
|
+
NoteHashExists,
|
|
31
|
+
NullifierExists,
|
|
32
|
+
Or,
|
|
33
|
+
Poseidon2,
|
|
34
|
+
Return,
|
|
35
|
+
ReturndataCopy,
|
|
36
|
+
ReturndataSize,
|
|
37
|
+
Revert,
|
|
38
|
+
SLoad,
|
|
39
|
+
SStore,
|
|
40
|
+
SendL2ToL1Message,
|
|
41
|
+
Set,
|
|
42
|
+
Sha256Compression,
|
|
43
|
+
Shl,
|
|
44
|
+
Shr,
|
|
45
|
+
StaticCall,
|
|
46
|
+
Sub,
|
|
47
|
+
ToRadixBE,
|
|
48
|
+
Xor,
|
|
49
|
+
} from '../opcodes/index.js';
|
|
50
|
+
import { BufferCursor } from './buffer_cursor.js';
|
|
51
|
+
import { MAX_OPCODE_VALUE, Opcode } from './instruction_serialization.js';
|
|
52
|
+
|
|
53
|
+
export type InstructionDeserializer = (buf: BufferCursor | Buffer) => Instruction;
|
|
54
|
+
|
|
55
|
+
export interface Serializable {
|
|
56
|
+
serialize(): Buffer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Deserializable {
|
|
60
|
+
deserialize: InstructionDeserializer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type InstructionSet = Map<Opcode, InstructionDeserializer>;
|
|
64
|
+
export const INSTRUCTION_SET = new Map<Opcode, InstructionDeserializer>([
|
|
65
|
+
[Opcode.ADD_8, Add.as(Add.wireFormat8).deserialize],
|
|
66
|
+
[Opcode.ADD_16, Add.as(Add.wireFormat16).deserialize],
|
|
67
|
+
[Opcode.SUB_8, Sub.as(Sub.wireFormat8).deserialize],
|
|
68
|
+
[Opcode.SUB_16, Sub.as(Sub.wireFormat16).deserialize],
|
|
69
|
+
[Opcode.MUL_8, Mul.as(Mul.wireFormat8).deserialize],
|
|
70
|
+
[Opcode.MUL_16, Mul.as(Mul.wireFormat16).deserialize],
|
|
71
|
+
[Opcode.DIV_8, Div.as(Div.wireFormat8).deserialize],
|
|
72
|
+
[Opcode.DIV_16, Div.as(Div.wireFormat16).deserialize],
|
|
73
|
+
[Opcode.FDIV_8, FieldDiv.as(FieldDiv.wireFormat8).deserialize],
|
|
74
|
+
[Opcode.FDIV_16, FieldDiv.as(FieldDiv.wireFormat16).deserialize],
|
|
75
|
+
[Opcode.EQ_8, Eq.as(Eq.wireFormat8).deserialize],
|
|
76
|
+
[Opcode.EQ_16, Eq.as(Eq.wireFormat16).deserialize],
|
|
77
|
+
[Opcode.LT_8, Lt.as(Lt.wireFormat8).deserialize],
|
|
78
|
+
[Opcode.LT_16, Lt.as(Lt.wireFormat16).deserialize],
|
|
79
|
+
[Opcode.LTE_8, Lte.as(Lte.wireFormat8).deserialize],
|
|
80
|
+
[Opcode.LTE_16, Lte.as(Lte.wireFormat16).deserialize],
|
|
81
|
+
[Opcode.AND_8, And.as(And.wireFormat8).deserialize],
|
|
82
|
+
[Opcode.AND_16, And.as(And.wireFormat16).deserialize],
|
|
83
|
+
[Opcode.OR_8, Or.as(Or.wireFormat8).deserialize],
|
|
84
|
+
[Opcode.OR_16, Or.as(Or.wireFormat16).deserialize],
|
|
85
|
+
[Opcode.XOR_8, Xor.as(Xor.wireFormat8).deserialize],
|
|
86
|
+
[Opcode.XOR_16, Xor.as(Xor.wireFormat16).deserialize],
|
|
87
|
+
[Opcode.NOT_8, Not.as(Not.wireFormat8).deserialize],
|
|
88
|
+
[Opcode.NOT_16, Not.as(Not.wireFormat16).deserialize],
|
|
89
|
+
[Opcode.SHL_8, Shl.as(Shl.wireFormat8).deserialize],
|
|
90
|
+
[Opcode.SHL_16, Shl.as(Shl.wireFormat16).deserialize],
|
|
91
|
+
[Opcode.SHR_8, Shr.as(Shr.wireFormat8).deserialize],
|
|
92
|
+
[Opcode.SHR_16, Shr.as(Shr.wireFormat16).deserialize],
|
|
93
|
+
[Opcode.CAST_8, Cast.as(Cast.wireFormat8).deserialize],
|
|
94
|
+
[Opcode.CAST_16, Cast.as(Cast.wireFormat16).deserialize],
|
|
95
|
+
// Execution Environment
|
|
96
|
+
[Opcode.GETENVVAR_16, GetEnvVar.as(GetEnvVar.wireFormat16).deserialize],
|
|
97
|
+
[CalldataCopy.opcode, Instruction.deserialize.bind(CalldataCopy)],
|
|
98
|
+
[Opcode.RETURNDATASIZE, Instruction.deserialize.bind(ReturndataSize)],
|
|
99
|
+
[Opcode.RETURNDATACOPY, Instruction.deserialize.bind(ReturndataCopy)],
|
|
100
|
+
|
|
101
|
+
// Machine State - Internal Control Flow
|
|
102
|
+
[Jump.opcode, Instruction.deserialize.bind(Jump)],
|
|
103
|
+
[JumpI.opcode, Instruction.deserialize.bind(JumpI)],
|
|
104
|
+
[InternalCall.opcode, Instruction.deserialize.bind(InternalCall)],
|
|
105
|
+
[InternalReturn.opcode, Instruction.deserialize.bind(InternalReturn)],
|
|
106
|
+
[Opcode.SET_8, Set.as(Set.wireFormat8).deserialize],
|
|
107
|
+
[Opcode.SET_16, Set.as(Set.wireFormat16).deserialize],
|
|
108
|
+
[Opcode.SET_32, Set.as(Set.wireFormat32).deserialize],
|
|
109
|
+
[Opcode.SET_64, Set.as(Set.wireFormat64).deserialize],
|
|
110
|
+
[Opcode.SET_128, Set.as(Set.wireFormat128).deserialize],
|
|
111
|
+
[Opcode.SET_FF, Set.as(Set.wireFormatFF).deserialize],
|
|
112
|
+
[Opcode.MOV_8, Mov.as(Mov.wireFormat8).deserialize],
|
|
113
|
+
[Opcode.MOV_16, Mov.as(Mov.wireFormat16).deserialize],
|
|
114
|
+
|
|
115
|
+
// World State
|
|
116
|
+
[SLoad.opcode, Instruction.deserialize.bind(SLoad)], // Public Storage
|
|
117
|
+
[SStore.opcode, Instruction.deserialize.bind(SStore)], // Public Storage
|
|
118
|
+
[NoteHashExists.opcode, Instruction.deserialize.bind(NoteHashExists)], // Notes & Nullifiers
|
|
119
|
+
[EmitNoteHash.opcode, Instruction.deserialize.bind(EmitNoteHash)], // Notes & Nullifiers
|
|
120
|
+
[NullifierExists.opcode, Instruction.deserialize.bind(NullifierExists)], // Notes & Nullifiers
|
|
121
|
+
[EmitNullifier.opcode, Instruction.deserialize.bind(EmitNullifier)], // Notes & Nullifiers
|
|
122
|
+
[L1ToL2MessageExists.opcode, Instruction.deserialize.bind(L1ToL2MessageExists)], // Messages
|
|
123
|
+
|
|
124
|
+
// Accrued Substate
|
|
125
|
+
[EmitUnencryptedLog.opcode, Instruction.deserialize.bind(EmitUnencryptedLog)],
|
|
126
|
+
[SendL2ToL1Message.opcode, Instruction.deserialize.bind(SendL2ToL1Message)],
|
|
127
|
+
[GetContractInstance.opcode, Instruction.deserialize.bind(GetContractInstance)],
|
|
128
|
+
|
|
129
|
+
// Control Flow - Contract Calls
|
|
130
|
+
[Call.opcode, Instruction.deserialize.bind(Call)],
|
|
131
|
+
[StaticCall.opcode, Instruction.deserialize.bind(StaticCall)],
|
|
132
|
+
[Return.opcode, Instruction.deserialize.bind(Return)],
|
|
133
|
+
[Opcode.REVERT_8, Revert.as(Revert.wireFormat8).deserialize],
|
|
134
|
+
[Opcode.REVERT_16, Revert.as(Revert.wireFormat16).deserialize],
|
|
135
|
+
|
|
136
|
+
// Misc
|
|
137
|
+
[DebugLog.opcode, Instruction.deserialize.bind(DebugLog)],
|
|
138
|
+
|
|
139
|
+
// Gadgets
|
|
140
|
+
[EcAdd.opcode, Instruction.deserialize.bind(EcAdd)],
|
|
141
|
+
[Poseidon2.opcode, Instruction.deserialize.bind(Poseidon2)],
|
|
142
|
+
[Sha256Compression.opcode, Instruction.deserialize.bind(Sha256Compression)],
|
|
143
|
+
[KeccakF1600.opcode, Instruction.deserialize.bind(KeccakF1600)],
|
|
144
|
+
|
|
145
|
+
// Conversions
|
|
146
|
+
[ToRadixBE.opcode, Instruction.deserialize.bind(ToRadixBE)],
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Serializes an array of instructions to bytecode.
|
|
151
|
+
*/
|
|
152
|
+
export function encodeToBytecode(instructions: Serializable[]): Buffer {
|
|
153
|
+
return Buffer.concat(instructions.map(i => i.serialize()));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// For testing only
|
|
157
|
+
export function decodeFromBytecode(bytecode: Buffer, instructionSet: InstructionSet = INSTRUCTION_SET): Instruction[] {
|
|
158
|
+
const instructions: Instruction[] = [];
|
|
159
|
+
let pc = 0;
|
|
160
|
+
while (pc < bytecode.length) {
|
|
161
|
+
const [instruction, bytesConsumed] = decodeInstructionFromBytecode(bytecode, pc, instructionSet);
|
|
162
|
+
instructions.push(instruction);
|
|
163
|
+
pc += bytesConsumed;
|
|
164
|
+
}
|
|
165
|
+
return instructions;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Returns the instruction and the number of bytes consumed.
|
|
169
|
+
export function decodeInstructionFromBytecode(
|
|
170
|
+
bytecode: Buffer,
|
|
171
|
+
pc: number,
|
|
172
|
+
instructionSet: InstructionSet = INSTRUCTION_SET,
|
|
173
|
+
): [Instruction, number] {
|
|
174
|
+
if (pc >= bytecode.length) {
|
|
175
|
+
throw new InvalidProgramCounterError(pc, bytecode.length);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
const cursor = new BufferCursor(bytecode, pc);
|
|
180
|
+
const startingPosition = cursor.position();
|
|
181
|
+
const opcode: number = cursor.bufferAtPosition().readUint8(); // peek.
|
|
182
|
+
|
|
183
|
+
if (opcode > MAX_OPCODE_VALUE) {
|
|
184
|
+
throw new InvalidOpcodeError(
|
|
185
|
+
`Opcode ${opcode} (0x${opcode.toString(16)}) value is not in the range of valid opcodes.`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const instructionDeserializerOrUndef = instructionSet.get(opcode);
|
|
190
|
+
if (instructionDeserializerOrUndef === undefined) {
|
|
191
|
+
throw new InvalidOpcodeError(`Opcode ${Opcode[opcode]} (0x${opcode.toString(16)}) is not implemented`);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const instructionDeserializer: InstructionDeserializer = instructionDeserializerOrUndef;
|
|
195
|
+
const instruction = instructionDeserializer(cursor);
|
|
196
|
+
return [instruction, cursor.position() - startingPosition];
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (error instanceof InvalidOpcodeError || error instanceof AvmExecutionError) {
|
|
199
|
+
throw error;
|
|
200
|
+
} else {
|
|
201
|
+
throw new AvmParsingError(`${error}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
1
2
|
import {
|
|
2
3
|
type ContractClassPublic,
|
|
3
4
|
type ContractInstanceWithAddress,
|
|
4
|
-
Fr,
|
|
5
5
|
computePublicBytecodeCommitment,
|
|
6
|
-
} from '@aztec/
|
|
6
|
+
} from '@aztec/stdlib/contract';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import type { jest } from '@jest/globals';
|
|
9
9
|
import { mock } from 'jest-mock-extended';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import type { WorldStateDB } from '../../public/public_db_sources.js';
|
|
12
|
+
import type { PublicSideEffectTraceInterface } from '../side_effect_trace_interface.js';
|
|
13
13
|
|
|
14
14
|
export async function mockGetBytecode(worldStateDB: WorldStateDB, bytecode: Buffer) {
|
|
15
15
|
const commitment = await computePublicBytecodeCommitment(bytecode);
|
|
16
|
-
(worldStateDB as jest.Mocked<WorldStateDB>).getBytecode.mockResolvedValue(bytecode);
|
|
17
16
|
(worldStateDB as jest.Mocked<WorldStateDB>).getBytecodeCommitment.mockResolvedValue(commitment);
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -37,6 +36,10 @@ export function mockStorageReadWithMap(worldStateDB: WorldStateDB, mockedStorage
|
|
|
37
36
|
);
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
export function mockGetBytecodeCommitment(worldStateDB: WorldStateDB, commitment: Fr) {
|
|
40
|
+
(worldStateDB as jest.Mocked<WorldStateDB>).getBytecodeCommitment.mockResolvedValue(commitment);
|
|
41
|
+
}
|
|
42
|
+
|
|
40
43
|
export function mockNoteHashExists(worldStateDB: WorldStateDB, _leafIndex: Fr, value?: Fr) {
|
|
41
44
|
(worldStateDB as jest.Mocked<WorldStateDB>).getCommitmentValue.mockImplementation((index: bigint) => {
|
|
42
45
|
if (index == _leafIndex.toBigInt()) {
|
|
@@ -48,7 +51,7 @@ export function mockNoteHashExists(worldStateDB: WorldStateDB, _leafIndex: Fr, v
|
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
export function
|
|
54
|
+
export function mockGetNullifierIndex(worldStateDB: WorldStateDB, leafIndex: Fr, _ignoredValue?: Fr) {
|
|
52
55
|
(worldStateDB as jest.Mocked<WorldStateDB>).getNullifierIndex.mockResolvedValue(leafIndex.toBigInt());
|
|
53
56
|
}
|
|
54
57
|
|
package/src/public/execution.ts
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import {
|
|
3
3
|
type AvmExecutionHints,
|
|
4
4
|
type ContractStorageRead,
|
|
5
5
|
type ContractStorageUpdateRequest,
|
|
6
|
-
type Fr,
|
|
7
|
-
Gas,
|
|
8
|
-
type L2ToL1Message,
|
|
9
|
-
type NoteHash,
|
|
10
|
-
type Nullifier,
|
|
11
6
|
PublicCallStackItemCompressed,
|
|
12
7
|
type PublicDataUpdateRequest,
|
|
13
8
|
PublicInnerCallRequest,
|
|
14
|
-
type PublicLog,
|
|
15
|
-
type ReadRequest,
|
|
16
9
|
RevertCode,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} from '@aztec/
|
|
20
|
-
import { computeVarArgsHash } from '@aztec/
|
|
10
|
+
} from '@aztec/stdlib/avm';
|
|
11
|
+
import type { SimulationError } from '@aztec/stdlib/errors';
|
|
12
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
13
|
+
import { computeVarArgsHash } from '@aztec/stdlib/hash';
|
|
14
|
+
import type { NoteHash, Nullifier, ReadRequest, TreeLeafReadRequest } from '@aztec/stdlib/kernel';
|
|
15
|
+
import type { PublicLog } from '@aztec/stdlib/logs';
|
|
16
|
+
import type { L2ToL1Message, ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
17
|
+
import type { PublicExecutionRequest } from '@aztec/stdlib/tx';
|
|
21
18
|
|
|
22
19
|
export interface PublicSideEffects {
|
|
23
20
|
/** The contract storage update requests performed. */
|