@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.b655e406
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 +5 -5
- package/dest/bin/check_oracle_version.d.ts +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +39 -0
- package/dest/config/index.d.ts +10 -15
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +11 -20
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +56 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +301 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +274 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_data_provider.js +14 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +93 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +183 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +14 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +12 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +15 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +25 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +42 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +22 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +49 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +57 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +328 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +48 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +236 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +417 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +154 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +265 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +51 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.js +62 -0
- package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_node.js +27 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +122 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -0
- package/dest/contract_function_simulator/pxe_oracle_interface.js +701 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +18 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +17 -11
- package/dest/entrypoints/{client/pxe_creation_options.d.ts → pxe_creation_options.d.ts} +4 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +5 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -3
- package/dest/entrypoints/server/utils.d.ts +7 -15
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +34 -28
- package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
- package/dest/oracle_version.d.ts +3 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +10 -0
- package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +6 -6
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
- package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +8 -8
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
- package/dest/pxe.d.ts +233 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +789 -0
- package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +14 -5
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +85 -24
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +12 -47
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +92 -70
- package/dest/storage/contract_data_provider/index.d.ts +0 -1
- package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
- package/dest/storage/index.d.ts +2 -3
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +2 -3
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_data_provider/note_dao.d.ts +16 -22
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_dao.js +16 -20
- package/dest/storage/note_data_provider/note_data_provider.d.ts +71 -8
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +133 -74
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +43 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +104 -0
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +2 -4
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +2 -5
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +48 -24
- package/dest/synchronizer/synchronizer.d.ts +7 -9
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +17 -19
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +2 -0
- package/dest/tagging/index.d.ts +7 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +5 -0
- package/dest/tagging/siloed_tag.d.ts +14 -0
- package/dest/tagging/siloed_tag.d.ts.map +1 -0
- package/dest/tagging/siloed_tag.js +20 -0
- package/dest/tagging/tag.d.ts +12 -0
- package/dest/tagging/tag.d.ts.map +1 -0
- package/dest/tagging/tag.js +17 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +24 -0
- package/package.json +34 -32
- package/src/bin/check_oracle_version.ts +50 -0
- package/src/config/index.ts +20 -33
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +548 -0
- package/src/contract_function_simulator/execution_data_provider.ts +343 -0
- package/src/contract_function_simulator/execution_note_cache.ts +222 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +13 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +27 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +52 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +52 -0
- package/src/contract_function_simulator/oracle/oracle.ts +575 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +207 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +625 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +358 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +66 -0
- package/src/contract_function_simulator/proxied_node.ts +33 -0
- package/src/contract_function_simulator/pxe_oracle_interface.ts +1019 -0
- package/src/entrypoints/client/bundle/index.ts +4 -2
- package/src/entrypoints/client/bundle/utils.ts +36 -36
- package/src/entrypoints/client/lazy/index.ts +4 -2
- package/src/entrypoints/client/lazy/utils.ts +36 -31
- package/src/entrypoints/{client/pxe_creation_options.ts → pxe_creation_options.ts} +4 -1
- package/src/entrypoints/server/index.ts +5 -3
- package/src/entrypoints/server/utils.ts +69 -47
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
- package/src/oracle_version.ts +11 -0
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +158 -142
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +436 -0
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +30 -15
- package/src/pxe.ts +1113 -0
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +97 -30
- package/src/storage/contract_data_provider/contract_data_provider.ts +114 -81
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
- package/src/storage/index.ts +2 -4
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_data_provider/note_dao.ts +19 -27
- package/src/storage/note_data_provider/note_data_provider.ts +161 -113
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +148 -0
- package/src/storage/sync_data_provider/sync_data_provider.ts +4 -10
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +58 -30
- package/src/synchronizer/synchronizer.ts +21 -22
- package/src/tagging/constants.ts +2 -0
- package/src/tagging/index.ts +6 -0
- package/src/tagging/siloed_tag.ts +22 -0
- package/src/tagging/tag.ts +16 -0
- package/src/tagging/utils.ts +31 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -28
- package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
- package/dest/kernel_prover/hints/index.d.ts +0 -2
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/kernel_prover.js +0 -217
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/pxe_http/index.d.ts +0 -2
- package/dest/pxe_http/index.d.ts.map +0 -1
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +0 -16
- package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
- package/dest/pxe_http/pxe_http_server.js +0 -27
- package/dest/pxe_oracle_interface/index.d.ts +0 -159
- package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/index.js +0 -692
- package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
- package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -111
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/pxe_service/pxe_service.js +0 -664
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -38
- package/src/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/pxe_http/index.ts +0 -1
- package/src/pxe_http/pxe_http_server.ts +0 -29
- package/src/pxe_oracle_interface/index.ts +0 -925
- package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/pxe_service/pxe_service.ts +0 -949
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- package/src/storage/data_provider.ts +0 -3
- package/src/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
import { type FunctionAbi, FunctionSelector, type NoteSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
7
|
+
import type { ContractClassLog, PreTag } from '@aztec/stdlib/logs';
|
|
8
|
+
import { type NoteStatus } from '@aztec/stdlib/note';
|
|
9
|
+
import { type BlockHeader, CallContext, Capsule, CountedContractClassLog, NoteAndSlot, PrivateCallExecutionResult, type TxContext } from '@aztec/stdlib/tx';
|
|
10
|
+
import { Tag } from '../../tagging/tag.js';
|
|
11
|
+
import type { ExecutionDataProvider } from '../execution_data_provider.js';
|
|
12
|
+
import type { ExecutionNoteCache } from '../execution_note_cache.js';
|
|
13
|
+
import { ExecutionTaggingIndexCache } from '../execution_tagging_index_cache.js';
|
|
14
|
+
import type { HashedValuesCache } from '../hashed_values_cache.js';
|
|
15
|
+
import type { IPrivateExecutionOracle, NoteData } from './interfaces.js';
|
|
16
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
17
|
+
/**
|
|
18
|
+
* The execution oracle for the private part of a transaction.
|
|
19
|
+
*/
|
|
20
|
+
export declare class PrivateExecutionOracle extends UtilityExecutionOracle implements IPrivateExecutionOracle {
|
|
21
|
+
#private;
|
|
22
|
+
private readonly argsHash;
|
|
23
|
+
private readonly txContext;
|
|
24
|
+
private readonly callContext;
|
|
25
|
+
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
26
|
+
protected readonly anchorBlockHeader: BlockHeader;
|
|
27
|
+
private readonly executionCache;
|
|
28
|
+
private readonly noteCache;
|
|
29
|
+
private readonly taggingIndexCache;
|
|
30
|
+
private totalPublicCalldataCount;
|
|
31
|
+
protected sideEffectCounter: number;
|
|
32
|
+
private senderForTags?;
|
|
33
|
+
private simulator?;
|
|
34
|
+
isPrivate: true;
|
|
35
|
+
/**
|
|
36
|
+
* New notes created during this execution.
|
|
37
|
+
* It's possible that a note in this list has been nullified (in the same or other executions) and doesn't exist in
|
|
38
|
+
* the ExecutionNoteCache and the final proof data. But we still include those notes in the execution result because
|
|
39
|
+
* their commitments are still in the public inputs of this execution.
|
|
40
|
+
* This information is only for references (currently used for tests), and is not used for any sort of constrains.
|
|
41
|
+
* Users can also use this to get a clearer idea of what's happened during a simulation.
|
|
42
|
+
*/
|
|
43
|
+
private newNotes;
|
|
44
|
+
/**
|
|
45
|
+
* Notes from previous transactions that are returned to the oracle call `getNotes` during this execution.
|
|
46
|
+
* The mapping maps from the unique siloed note hash to the index for notes created in private executions.
|
|
47
|
+
* It maps from siloed note hash to the index for notes created by public functions.
|
|
48
|
+
*
|
|
49
|
+
* They are not part of the ExecutionNoteCache and being forwarded to nested contexts via `extend()`
|
|
50
|
+
* because these notes are meant to be maintained on a per-call basis
|
|
51
|
+
* They should act as references for the read requests output by an app circuit via public inputs.
|
|
52
|
+
*/
|
|
53
|
+
private noteHashLeafIndexMap;
|
|
54
|
+
private noteHashNullifierCounterMap;
|
|
55
|
+
private contractClassLogs;
|
|
56
|
+
private offchainEffects;
|
|
57
|
+
private nestedExecutionResults;
|
|
58
|
+
constructor(argsHash: Fr, txContext: TxContext, callContext: CallContext,
|
|
59
|
+
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
60
|
+
anchorBlockHeader: BlockHeader,
|
|
61
|
+
/** List of transient auth witnesses to be used during this simulation */
|
|
62
|
+
authWitnesses: AuthWitness[], capsules: Capsule[], executionCache: HashedValuesCache, noteCache: ExecutionNoteCache, taggingIndexCache: ExecutionTaggingIndexCache, executionDataProvider: ExecutionDataProvider, totalPublicCalldataCount?: number, sideEffectCounter?: number, log?: import("@aztec/foundation/log").Logger, scopes?: AztecAddress[], senderForTags?: AztecAddress | undefined, simulator?: CircuitSimulator | undefined);
|
|
63
|
+
getPrivateContextInputs(): PrivateContextInputs;
|
|
64
|
+
/**
|
|
65
|
+
* Writes the function inputs to the initial witness.
|
|
66
|
+
* @param abi - The function ABI.
|
|
67
|
+
* @returns The initial witness.
|
|
68
|
+
*/
|
|
69
|
+
getInitialWitness(abi: FunctionAbi): Map<number, string>;
|
|
70
|
+
/**
|
|
71
|
+
* The KernelProver will use this to fully populate witnesses and provide hints to the kernel circuit
|
|
72
|
+
* regarding which note hash each settled read request corresponds to.
|
|
73
|
+
*/
|
|
74
|
+
getNoteHashLeafIndexMap(): Map<bigint, bigint>;
|
|
75
|
+
/**
|
|
76
|
+
* Get the data for the newly created notes.
|
|
77
|
+
*/
|
|
78
|
+
getNewNotes(): NoteAndSlot[];
|
|
79
|
+
getNoteHashNullifierCounterMap(): Map<number, number>;
|
|
80
|
+
/**
|
|
81
|
+
* Return the contract class logs emitted during this execution.
|
|
82
|
+
*/
|
|
83
|
+
getContractClassLogs(): CountedContractClassLog[];
|
|
84
|
+
/**
|
|
85
|
+
* Return the offchain effects emitted during this execution.
|
|
86
|
+
*/
|
|
87
|
+
getOffchainEffects(): {
|
|
88
|
+
data: Fr[];
|
|
89
|
+
}[];
|
|
90
|
+
/**
|
|
91
|
+
* Returns the pre tags that were used in this execution (and that need to be stored in the db).
|
|
92
|
+
*/
|
|
93
|
+
getUsedPreTags(): PreTag[];
|
|
94
|
+
/**
|
|
95
|
+
* Return the nested execution results during this execution.
|
|
96
|
+
*/
|
|
97
|
+
getNestedExecutionResults(): PrivateCallExecutionResult[];
|
|
98
|
+
/**
|
|
99
|
+
* Get the sender for tags.
|
|
100
|
+
*
|
|
101
|
+
* This unconstrained value is used as the sender when computing an unconstrained shared secret
|
|
102
|
+
* for a tag in order to emit a log. Constrained tagging should not use this as there is no
|
|
103
|
+
* guarantee that the recipient knows about the sender, and hence about the shared secret.
|
|
104
|
+
*
|
|
105
|
+
* The value persists through nested calls, meaning all calls down the stack will use the same
|
|
106
|
+
* 'senderForTags' value (unless it is replaced).
|
|
107
|
+
*/
|
|
108
|
+
privateGetSenderForTags(): Promise<AztecAddress | undefined>;
|
|
109
|
+
/**
|
|
110
|
+
* Set the sender for tags.
|
|
111
|
+
*
|
|
112
|
+
* This unconstrained value is used as the sender when computing an unconstrained shared secret
|
|
113
|
+
* for a tag in order to emit a log. Constrained tagging should not use this as there is no
|
|
114
|
+
* guarantee that the recipient knows about the sender, and hence about the shared secret.
|
|
115
|
+
*
|
|
116
|
+
* Account contracts typically set this value before calling other contracts. The value persists
|
|
117
|
+
* through nested calls, meaning all calls down the stack will use the same 'senderForTags'
|
|
118
|
+
* value (unless it is replaced by another call to this setter).
|
|
119
|
+
*/
|
|
120
|
+
privateSetSenderForTags(senderForTags: AztecAddress): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Returns the next app tag for a given sender and recipient pair.
|
|
123
|
+
* @param sender - The address sending the log
|
|
124
|
+
* @param recipient - The address receiving the log
|
|
125
|
+
* @returns An app tag to be used in a log.
|
|
126
|
+
*/
|
|
127
|
+
privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
|
|
128
|
+
/**
|
|
129
|
+
* Store values in the execution cache.
|
|
130
|
+
* @param values - Values to store.
|
|
131
|
+
* @returns The hash of the values.
|
|
132
|
+
*/
|
|
133
|
+
privateStoreInExecutionCache(values: Fr[], hash: Fr): void;
|
|
134
|
+
/**
|
|
135
|
+
* Gets values from the execution cache.
|
|
136
|
+
* @param hash - Hash of the values.
|
|
137
|
+
* @returns The values.
|
|
138
|
+
*/
|
|
139
|
+
privateLoadFromExecutionCache(hash: Fr): Promise<Fr[]>;
|
|
140
|
+
utilityCheckNullifierExists(innerNullifier: Fr): Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* Gets some notes for a storage slot.
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* Check for pending notes with matching slot.
|
|
146
|
+
* Real notes coming from DB will have a leafIndex which
|
|
147
|
+
* represents their index in the note hash tree.
|
|
148
|
+
*
|
|
149
|
+
* @param storageSlot - The storage slot.
|
|
150
|
+
* @param numSelects - The number of valid selects in selectBy and selectValues.
|
|
151
|
+
* @param selectBy - An array of indices of the fields to selects.
|
|
152
|
+
* @param selectValues - The values to match.
|
|
153
|
+
* @param selectComparators - The comparators to match by.
|
|
154
|
+
* @param sortBy - An array of indices of the fields to sort.
|
|
155
|
+
* @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
|
|
156
|
+
* @param limit - The number of notes to retrieve per query.
|
|
157
|
+
* @param offset - The starting index for pagination.
|
|
158
|
+
* @param status - The status of notes to fetch.
|
|
159
|
+
* @returns Array of note data.
|
|
160
|
+
*/
|
|
161
|
+
utilityGetNotes(storageSlot: Fr, numSelects: number, selectByIndexes: number[], selectByOffsets: number[], selectByLengths: number[], selectValues: Fr[], selectComparators: number[], sortByIndexes: number[], sortByOffsets: number[], sortByLengths: number[], sortOrder: number[], limit: number, offset: number, status: NoteStatus): Promise<NoteData[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Keep track of the new note created during execution.
|
|
164
|
+
* It can be used in subsequent calls (or transactions when chaining txs is possible).
|
|
165
|
+
* @param contractAddress - The contract address.
|
|
166
|
+
* @param storageSlot - The storage slot.
|
|
167
|
+
* @param noteTypeId - The type ID of the note.
|
|
168
|
+
* @param noteItems - The items to be included in a Note.
|
|
169
|
+
* @param noteHash - A hash of the new note.
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
172
|
+
privateNotifyCreatedNote(storageSlot: Fr, noteTypeId: NoteSelector, noteItems: Fr[], noteHash: Fr, counter: number): void;
|
|
173
|
+
/**
|
|
174
|
+
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
175
|
+
* within the current transaction/execution.
|
|
176
|
+
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
177
|
+
* @param noteHash - A hash of the new note.
|
|
178
|
+
*/
|
|
179
|
+
privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
182
|
+
* within the current transaction/execution.
|
|
183
|
+
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
184
|
+
* @param noteHash - A hash of the new note.
|
|
185
|
+
*/
|
|
186
|
+
privateNotifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Emit a contract class log.
|
|
189
|
+
* This fn exists because we only carry a poseidon hash through the kernels, and need to
|
|
190
|
+
* keep the preimage in ts for later.
|
|
191
|
+
* @param log - The contract class log to be emitted.
|
|
192
|
+
* @param counter - The contract class log's counter.
|
|
193
|
+
*/
|
|
194
|
+
privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
|
|
195
|
+
/**
|
|
196
|
+
* Calls a private function as a nested execution.
|
|
197
|
+
* @param targetContractAddress - The address of the contract to call.
|
|
198
|
+
* @param functionSelector - The function selector of the function to call.
|
|
199
|
+
* @param argsHash - The arguments hash to pass to the function.
|
|
200
|
+
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
201
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
202
|
+
* @returns The execution result.
|
|
203
|
+
*/
|
|
204
|
+
privateCallPrivateFunction(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, argsHash: Fr, sideEffectCounter: number, isStaticCall: boolean): Promise<{
|
|
205
|
+
endSideEffectCounter: Fr;
|
|
206
|
+
returnsHash: Fr;
|
|
207
|
+
}>;
|
|
208
|
+
/**
|
|
209
|
+
* Verify relevant information when a public function is enqueued.
|
|
210
|
+
* @param targetContractAddress - The address of the contract to call.
|
|
211
|
+
* @param calldataHash - The hash of the function selector and arguments.
|
|
212
|
+
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
213
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
214
|
+
*/
|
|
215
|
+
privateNotifyEnqueuedPublicFunctionCall(_targetContractAddress: AztecAddress, calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Verify relevant information when a public teardown function is set.
|
|
218
|
+
* @param targetContractAddress - The address of the contract to call.
|
|
219
|
+
* @param argsHash - The arguments hash to pass to the function.
|
|
220
|
+
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
221
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
222
|
+
*/
|
|
223
|
+
privateNotifySetPublicTeardownFunctionCall(_targetContractAddress: AztecAddress, calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
|
|
224
|
+
privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* Derives the call context for a nested execution.
|
|
227
|
+
* @param targetContractAddress - The address of the contract being called.
|
|
228
|
+
* @param targetArtifact - The artifact of the function being called.
|
|
229
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
230
|
+
* @returns The derived call context.
|
|
231
|
+
*/
|
|
232
|
+
private deriveCallContext;
|
|
233
|
+
getDebugFunctionName(): Promise<string>;
|
|
234
|
+
utilityEmitOffchainEffect(data: Fr[]): Promise<void>;
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=private_execution_oracle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_execution_oracle.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/oracle/private_execution_oracle.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import { toACVMWitness } from '@aztec/simulator/client';
|
|
6
|
+
import { FunctionSelector, countArgumentsSize } from '@aztec/stdlib/abi';
|
|
7
|
+
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
8
|
+
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
9
|
+
import { Note } from '@aztec/stdlib/note';
|
|
10
|
+
import { CallContext, CountedContractClassLog, NoteAndSlot } from '@aztec/stdlib/tx';
|
|
11
|
+
import { Tag } from '../../tagging/tag.js';
|
|
12
|
+
import { pickNotes } from '../pick_notes.js';
|
|
13
|
+
import { executePrivateFunction, verifyCurrentClassId } from './private_execution.js';
|
|
14
|
+
import { UtilityExecutionOracle } from './utility_execution_oracle.js';
|
|
15
|
+
/**
|
|
16
|
+
* The execution oracle for the private part of a transaction.
|
|
17
|
+
*/ export class PrivateExecutionOracle extends UtilityExecutionOracle {
|
|
18
|
+
argsHash;
|
|
19
|
+
txContext;
|
|
20
|
+
callContext;
|
|
21
|
+
anchorBlockHeader;
|
|
22
|
+
executionCache;
|
|
23
|
+
noteCache;
|
|
24
|
+
taggingIndexCache;
|
|
25
|
+
totalPublicCalldataCount;
|
|
26
|
+
sideEffectCounter;
|
|
27
|
+
senderForTags;
|
|
28
|
+
simulator;
|
|
29
|
+
isPrivate;
|
|
30
|
+
/**
|
|
31
|
+
* New notes created during this execution.
|
|
32
|
+
* It's possible that a note in this list has been nullified (in the same or other executions) and doesn't exist in
|
|
33
|
+
* the ExecutionNoteCache and the final proof data. But we still include those notes in the execution result because
|
|
34
|
+
* their commitments are still in the public inputs of this execution.
|
|
35
|
+
* This information is only for references (currently used for tests), and is not used for any sort of constrains.
|
|
36
|
+
* Users can also use this to get a clearer idea of what's happened during a simulation.
|
|
37
|
+
*/ newNotes;
|
|
38
|
+
/**
|
|
39
|
+
* Notes from previous transactions that are returned to the oracle call `getNotes` during this execution.
|
|
40
|
+
* The mapping maps from the unique siloed note hash to the index for notes created in private executions.
|
|
41
|
+
* It maps from siloed note hash to the index for notes created by public functions.
|
|
42
|
+
*
|
|
43
|
+
* They are not part of the ExecutionNoteCache and being forwarded to nested contexts via `extend()`
|
|
44
|
+
* because these notes are meant to be maintained on a per-call basis
|
|
45
|
+
* They should act as references for the read requests output by an app circuit via public inputs.
|
|
46
|
+
*/ noteHashLeafIndexMap;
|
|
47
|
+
noteHashNullifierCounterMap;
|
|
48
|
+
contractClassLogs;
|
|
49
|
+
offchainEffects;
|
|
50
|
+
nestedExecutionResults;
|
|
51
|
+
constructor(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ anchorBlockHeader, /** List of transient auth witnesses to be used during this simulation */ authWitnesses, capsules, executionCache, noteCache, taggingIndexCache, executionDataProvider, totalPublicCalldataCount = 0, sideEffectCounter = 0, log = createLogger('simulator:client_execution_context'), scopes, senderForTags, simulator){
|
|
52
|
+
super(callContext.contractAddress, authWitnesses, capsules, executionDataProvider, log, scopes), this.argsHash = argsHash, this.txContext = txContext, this.callContext = callContext, this.anchorBlockHeader = anchorBlockHeader, this.executionCache = executionCache, this.noteCache = noteCache, this.taggingIndexCache = taggingIndexCache, this.totalPublicCalldataCount = totalPublicCalldataCount, this.sideEffectCounter = sideEffectCounter, this.senderForTags = senderForTags, this.simulator = simulator, this.isPrivate = true, this.newNotes = [], this.noteHashLeafIndexMap = new Map(), this.noteHashNullifierCounterMap = new Map(), this.contractClassLogs = [], this.offchainEffects = [], this.nestedExecutionResults = [];
|
|
53
|
+
}
|
|
54
|
+
getPrivateContextInputs() {
|
|
55
|
+
return new PrivateContextInputs(this.callContext, this.anchorBlockHeader, this.txContext, this.sideEffectCounter);
|
|
56
|
+
}
|
|
57
|
+
// We still need this function until we can get user-defined ordering of structs for fn arguments
|
|
58
|
+
// TODO When that is sorted out on noir side, we can use instead the utilities in serialize.ts
|
|
59
|
+
/**
|
|
60
|
+
* Writes the function inputs to the initial witness.
|
|
61
|
+
* @param abi - The function ABI.
|
|
62
|
+
* @returns The initial witness.
|
|
63
|
+
*/ getInitialWitness(abi) {
|
|
64
|
+
const argumentsSize = countArgumentsSize(abi);
|
|
65
|
+
const args = this.executionCache.getPreimage(this.argsHash);
|
|
66
|
+
if (args?.length !== argumentsSize) {
|
|
67
|
+
throw new Error(`Invalid arguments size: expected ${argumentsSize}, got ${args?.length}`);
|
|
68
|
+
}
|
|
69
|
+
const privateContextInputsAsFields = this.getPrivateContextInputs().toFields();
|
|
70
|
+
if (privateContextInputsAsFields.length !== PRIVATE_CONTEXT_INPUTS_LENGTH) {
|
|
71
|
+
throw new Error('Invalid private context inputs size');
|
|
72
|
+
}
|
|
73
|
+
const fields = [
|
|
74
|
+
...privateContextInputsAsFields,
|
|
75
|
+
...args
|
|
76
|
+
];
|
|
77
|
+
return toACVMWitness(0, fields);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The KernelProver will use this to fully populate witnesses and provide hints to the kernel circuit
|
|
81
|
+
* regarding which note hash each settled read request corresponds to.
|
|
82
|
+
*/ getNoteHashLeafIndexMap() {
|
|
83
|
+
return this.noteHashLeafIndexMap;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the data for the newly created notes.
|
|
87
|
+
*/ getNewNotes() {
|
|
88
|
+
return this.newNotes;
|
|
89
|
+
}
|
|
90
|
+
getNoteHashNullifierCounterMap() {
|
|
91
|
+
return this.noteHashNullifierCounterMap;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Return the contract class logs emitted during this execution.
|
|
95
|
+
*/ getContractClassLogs() {
|
|
96
|
+
return this.contractClassLogs;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Return the offchain effects emitted during this execution.
|
|
100
|
+
*/ getOffchainEffects() {
|
|
101
|
+
return this.offchainEffects;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the pre tags that were used in this execution (and that need to be stored in the db).
|
|
105
|
+
*/ getUsedPreTags() {
|
|
106
|
+
return this.taggingIndexCache.getUsedPreTags();
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Return the nested execution results during this execution.
|
|
110
|
+
*/ getNestedExecutionResults() {
|
|
111
|
+
return this.nestedExecutionResults;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get the sender for tags.
|
|
115
|
+
*
|
|
116
|
+
* This unconstrained value is used as the sender when computing an unconstrained shared secret
|
|
117
|
+
* for a tag in order to emit a log. Constrained tagging should not use this as there is no
|
|
118
|
+
* guarantee that the recipient knows about the sender, and hence about the shared secret.
|
|
119
|
+
*
|
|
120
|
+
* The value persists through nested calls, meaning all calls down the stack will use the same
|
|
121
|
+
* 'senderForTags' value (unless it is replaced).
|
|
122
|
+
*/ privateGetSenderForTags() {
|
|
123
|
+
return Promise.resolve(this.senderForTags);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Set the sender for tags.
|
|
127
|
+
*
|
|
128
|
+
* This unconstrained value is used as the sender when computing an unconstrained shared secret
|
|
129
|
+
* for a tag in order to emit a log. Constrained tagging should not use this as there is no
|
|
130
|
+
* guarantee that the recipient knows about the sender, and hence about the shared secret.
|
|
131
|
+
*
|
|
132
|
+
* Account contracts typically set this value before calling other contracts. The value persists
|
|
133
|
+
* through nested calls, meaning all calls down the stack will use the same 'senderForTags'
|
|
134
|
+
* value (unless it is replaced by another call to this setter).
|
|
135
|
+
*/ privateSetSenderForTags(senderForTags) {
|
|
136
|
+
this.senderForTags = senderForTags;
|
|
137
|
+
return Promise.resolve();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns the next app tag for a given sender and recipient pair.
|
|
141
|
+
* @param sender - The address sending the log
|
|
142
|
+
* @param recipient - The address receiving the log
|
|
143
|
+
* @returns An app tag to be used in a log.
|
|
144
|
+
*/ async privateGetNextAppTagAsSender(sender, recipient) {
|
|
145
|
+
const secret = await this.executionDataProvider.calculateDirectionalAppTaggingSecret(this.contractAddress, sender, recipient);
|
|
146
|
+
const index = await this.#getIndexToUseForSecret(secret);
|
|
147
|
+
this.log.debug(`Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`);
|
|
148
|
+
this.taggingIndexCache.setLastUsedIndex(secret, index);
|
|
149
|
+
return Tag.compute({
|
|
150
|
+
secret,
|
|
151
|
+
index
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async #getIndexToUseForSecret(secret) {
|
|
155
|
+
// If we have the tagging index in the cache, we use it. If not we obtain it from the execution data provider.
|
|
156
|
+
const lastUsedIndexInTx = this.taggingIndexCache.getLastUsedIndex(secret);
|
|
157
|
+
if (lastUsedIndexInTx !== undefined) {
|
|
158
|
+
return lastUsedIndexInTx + 1;
|
|
159
|
+
} else {
|
|
160
|
+
// This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
|
|
161
|
+
// are up to date. We do this here because this store is not synced as part of the global sync because
|
|
162
|
+
// that'd be wasteful as most tagging secrets are not used in each tx.
|
|
163
|
+
await this.executionDataProvider.syncTaggedLogsAsSender(secret, this.contractAddress);
|
|
164
|
+
const lastUsedIndex = await this.executionDataProvider.getLastUsedIndexAsSender(secret);
|
|
165
|
+
// If lastUsedIndex is undefined, we've never used this secret, so start from 0
|
|
166
|
+
// Otherwise, the next index to use is one past the last used index
|
|
167
|
+
return lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Store values in the execution cache.
|
|
172
|
+
* @param values - Values to store.
|
|
173
|
+
* @returns The hash of the values.
|
|
174
|
+
*/ privateStoreInExecutionCache(values, hash) {
|
|
175
|
+
return this.executionCache.store(values, hash);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Gets values from the execution cache.
|
|
179
|
+
* @param hash - Hash of the values.
|
|
180
|
+
* @returns The values.
|
|
181
|
+
*/ privateLoadFromExecutionCache(hash) {
|
|
182
|
+
const preimage = this.executionCache.getPreimage(hash);
|
|
183
|
+
if (!preimage) {
|
|
184
|
+
throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
|
|
185
|
+
}
|
|
186
|
+
return Promise.resolve(preimage);
|
|
187
|
+
}
|
|
188
|
+
async utilityCheckNullifierExists(innerNullifier) {
|
|
189
|
+
// This oracle must be overridden because while utility execution can only meaningfully check if a nullifier exists
|
|
190
|
+
// in the synched block, during private execution there's also the possibility of it being pending, i.e. created
|
|
191
|
+
// in the current transaction.
|
|
192
|
+
this.log.debug(`Checking existence of inner nullifier ${innerNullifier}`, {
|
|
193
|
+
contractAddress: this.contractAddress
|
|
194
|
+
});
|
|
195
|
+
const nullifier = (await siloNullifier(this.contractAddress, innerNullifier)).toBigInt();
|
|
196
|
+
return this.noteCache.getNullifiers(this.contractAddress).has(nullifier) || await super.utilityCheckNullifierExists(innerNullifier);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Gets some notes for a storage slot.
|
|
200
|
+
*
|
|
201
|
+
* @remarks
|
|
202
|
+
* Check for pending notes with matching slot.
|
|
203
|
+
* Real notes coming from DB will have a leafIndex which
|
|
204
|
+
* represents their index in the note hash tree.
|
|
205
|
+
*
|
|
206
|
+
* @param storageSlot - The storage slot.
|
|
207
|
+
* @param numSelects - The number of valid selects in selectBy and selectValues.
|
|
208
|
+
* @param selectBy - An array of indices of the fields to selects.
|
|
209
|
+
* @param selectValues - The values to match.
|
|
210
|
+
* @param selectComparators - The comparators to match by.
|
|
211
|
+
* @param sortBy - An array of indices of the fields to sort.
|
|
212
|
+
* @param sortOrder - The order of the corresponding index in sortBy. (1: DESC, 2: ASC, 0: Do nothing)
|
|
213
|
+
* @param limit - The number of notes to retrieve per query.
|
|
214
|
+
* @param offset - The starting index for pagination.
|
|
215
|
+
* @param status - The status of notes to fetch.
|
|
216
|
+
* @returns Array of note data.
|
|
217
|
+
*/ async utilityGetNotes(storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status) {
|
|
218
|
+
// Nullified pending notes are already removed from the list.
|
|
219
|
+
const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, storageSlot);
|
|
220
|
+
const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
|
|
221
|
+
const dbNotes = await this.executionDataProvider.getNotes(this.callContext.contractAddress, storageSlot, status, this.scopes);
|
|
222
|
+
const dbNotesFiltered = dbNotes.filter((n)=>!pendingNullifiers.has(n.siloedNullifier.value));
|
|
223
|
+
const notes = pickNotes([
|
|
224
|
+
...dbNotesFiltered,
|
|
225
|
+
...pendingNotes
|
|
226
|
+
], {
|
|
227
|
+
selects: selectByIndexes.slice(0, numSelects).map((index, i)=>({
|
|
228
|
+
selector: {
|
|
229
|
+
index,
|
|
230
|
+
offset: selectByOffsets[i],
|
|
231
|
+
length: selectByLengths[i]
|
|
232
|
+
},
|
|
233
|
+
value: selectValues[i],
|
|
234
|
+
comparator: selectComparators[i]
|
|
235
|
+
})),
|
|
236
|
+
sorts: sortByIndexes.map((index, i)=>({
|
|
237
|
+
selector: {
|
|
238
|
+
index,
|
|
239
|
+
offset: sortByOffsets[i],
|
|
240
|
+
length: sortByLengths[i]
|
|
241
|
+
},
|
|
242
|
+
order: sortOrder[i]
|
|
243
|
+
})),
|
|
244
|
+
limit,
|
|
245
|
+
offset
|
|
246
|
+
});
|
|
247
|
+
this.log.debug(`Returning ${notes.length} notes for ${this.callContext.contractAddress} at ${storageSlot}: ${notes.map((n)=>`${n.noteNonce.toString()}:[${n.note.items.map((i)=>i.toString()).join(',')}]`).join(', ')}`);
|
|
248
|
+
const noteHashesAndIndexes = await Promise.all(notes.map(async (n)=>{
|
|
249
|
+
if (n.index !== undefined) {
|
|
250
|
+
const siloedNoteHash = await siloNoteHash(n.contractAddress, n.noteHash);
|
|
251
|
+
const uniqueNoteHash = await computeUniqueNoteHash(n.noteNonce, siloedNoteHash);
|
|
252
|
+
return {
|
|
253
|
+
hash: uniqueNoteHash,
|
|
254
|
+
index: n.index
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}));
|
|
258
|
+
noteHashesAndIndexes.filter((n)=>n !== undefined).forEach((n)=>{
|
|
259
|
+
this.noteHashLeafIndexMap.set(n.hash.toBigInt(), n.index);
|
|
260
|
+
});
|
|
261
|
+
return notes;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Keep track of the new note created during execution.
|
|
265
|
+
* It can be used in subsequent calls (or transactions when chaining txs is possible).
|
|
266
|
+
* @param contractAddress - The contract address.
|
|
267
|
+
* @param storageSlot - The storage slot.
|
|
268
|
+
* @param noteTypeId - The type ID of the note.
|
|
269
|
+
* @param noteItems - The items to be included in a Note.
|
|
270
|
+
* @param noteHash - A hash of the new note.
|
|
271
|
+
* @returns
|
|
272
|
+
*/ privateNotifyCreatedNote(storageSlot, noteTypeId, noteItems, noteHash, counter) {
|
|
273
|
+
this.log.debug(`Notified of new note with inner hash ${noteHash}`, {
|
|
274
|
+
contractAddress: this.callContext.contractAddress,
|
|
275
|
+
storageSlot,
|
|
276
|
+
noteTypeId,
|
|
277
|
+
counter
|
|
278
|
+
});
|
|
279
|
+
const note = new Note(noteItems);
|
|
280
|
+
this.noteCache.addNewNote({
|
|
281
|
+
contractAddress: this.callContext.contractAddress,
|
|
282
|
+
storageSlot,
|
|
283
|
+
noteNonce: Fr.ZERO,
|
|
284
|
+
note,
|
|
285
|
+
siloedNullifier: undefined,
|
|
286
|
+
noteHash
|
|
287
|
+
}, counter);
|
|
288
|
+
this.newNotes.push(new NoteAndSlot(note, storageSlot, noteTypeId));
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
292
|
+
* within the current transaction/execution.
|
|
293
|
+
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
294
|
+
* @param noteHash - A hash of the new note.
|
|
295
|
+
*/ async privateNotifyNullifiedNote(innerNullifier, noteHash, counter) {
|
|
296
|
+
const nullifiedNoteHashCounter = await this.noteCache.nullifyNote(this.callContext.contractAddress, innerNullifier, noteHash);
|
|
297
|
+
if (nullifiedNoteHashCounter !== undefined) {
|
|
298
|
+
this.noteHashNullifierCounterMap.set(nullifiedNoteHashCounter, counter);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Adding a siloed nullifier into the current set of all pending nullifiers created
|
|
303
|
+
* within the current transaction/execution.
|
|
304
|
+
* @param innerNullifier - The pending nullifier to add in the list (not yet siloed by contract address).
|
|
305
|
+
* @param noteHash - A hash of the new note.
|
|
306
|
+
*/ privateNotifyCreatedNullifier(innerNullifier) {
|
|
307
|
+
this.log.debug(`Notified of new inner nullifier ${innerNullifier}`, {
|
|
308
|
+
contractAddress: this.contractAddress
|
|
309
|
+
});
|
|
310
|
+
return this.noteCache.nullifierCreated(this.callContext.contractAddress, innerNullifier);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Emit a contract class log.
|
|
314
|
+
* This fn exists because we only carry a poseidon hash through the kernels, and need to
|
|
315
|
+
* keep the preimage in ts for later.
|
|
316
|
+
* @param log - The contract class log to be emitted.
|
|
317
|
+
* @param counter - The contract class log's counter.
|
|
318
|
+
*/ privateNotifyCreatedContractClassLog(log, counter) {
|
|
319
|
+
this.contractClassLogs.push(new CountedContractClassLog(log, counter));
|
|
320
|
+
const text = log.toBuffer().toString('hex');
|
|
321
|
+
this.log.verbose(`Emitted log from ContractClassRegistry: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`);
|
|
322
|
+
}
|
|
323
|
+
#checkValidStaticCall(childExecutionResult) {
|
|
324
|
+
if (childExecutionResult.publicInputs.noteHashes.claimedLength > 0 || childExecutionResult.publicInputs.nullifiers.claimedLength > 0 || childExecutionResult.publicInputs.l2ToL1Msgs.claimedLength > 0 || childExecutionResult.publicInputs.privateLogs.claimedLength > 0 || childExecutionResult.publicInputs.contractClassLogsHashes.claimedLength > 0) {
|
|
325
|
+
throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Calls a private function as a nested execution.
|
|
330
|
+
* @param targetContractAddress - The address of the contract to call.
|
|
331
|
+
* @param functionSelector - The function selector of the function to call.
|
|
332
|
+
* @param argsHash - The arguments hash to pass to the function.
|
|
333
|
+
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
334
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
335
|
+
* @returns The execution result.
|
|
336
|
+
*/ async privateCallPrivateFunction(targetContractAddress, functionSelector, argsHash, sideEffectCounter, isStaticCall) {
|
|
337
|
+
if (!this.simulator) {
|
|
338
|
+
// In practice it is only when creating inline private contexts in a Noir test using TXE that we create an
|
|
339
|
+
// instance of this class without a simulator.
|
|
340
|
+
throw new Error('No simulator provided, cannot perform a nested private call');
|
|
341
|
+
}
|
|
342
|
+
const simulatorSetupTimer = new Timer();
|
|
343
|
+
this.log.debug(`Calling private function ${targetContractAddress}:${functionSelector} from ${this.callContext.contractAddress}`);
|
|
344
|
+
isStaticCall = isStaticCall || this.callContext.isStaticCall;
|
|
345
|
+
await verifyCurrentClassId(targetContractAddress, this.executionDataProvider, this.anchorBlockHeader);
|
|
346
|
+
const targetArtifact = await this.executionDataProvider.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
347
|
+
const derivedTxContext = this.txContext.clone();
|
|
348
|
+
const derivedCallContext = await this.deriveCallContext(targetContractAddress, targetArtifact, isStaticCall);
|
|
349
|
+
const privateExecutionOracle = new PrivateExecutionOracle(argsHash, derivedTxContext, derivedCallContext, this.anchorBlockHeader, this.authWitnesses, this.capsules, this.executionCache, this.noteCache, this.taggingIndexCache, this.executionDataProvider, this.totalPublicCalldataCount, sideEffectCounter, this.log, this.scopes, this.senderForTags, this.simulator);
|
|
350
|
+
const setupTime = simulatorSetupTimer.ms();
|
|
351
|
+
const childExecutionResult = await executePrivateFunction(this.simulator, privateExecutionOracle, targetArtifact, targetContractAddress, functionSelector);
|
|
352
|
+
if (isStaticCall) {
|
|
353
|
+
this.#checkValidStaticCall(childExecutionResult);
|
|
354
|
+
}
|
|
355
|
+
this.nestedExecutionResults.push(childExecutionResult);
|
|
356
|
+
const publicInputs = childExecutionResult.publicInputs;
|
|
357
|
+
// Add simulator overhead to this call
|
|
358
|
+
if (childExecutionResult.profileResult) {
|
|
359
|
+
childExecutionResult.profileResult.timings.witgen += setupTime;
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
endSideEffectCounter: publicInputs.endSideEffectCounter,
|
|
363
|
+
returnsHash: publicInputs.returnsHash
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
#onNewPublicFunctionCall(calldataHash) {
|
|
367
|
+
const calldata = this.executionCache.getPreimage(calldataHash);
|
|
368
|
+
if (!calldata) {
|
|
369
|
+
throw new Error('Calldata for public call not found in cache');
|
|
370
|
+
}
|
|
371
|
+
this.totalPublicCalldataCount += calldata.length;
|
|
372
|
+
if (this.totalPublicCalldataCount > MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS) {
|
|
373
|
+
throw new Error(`Too many total args to all enqueued public calls! (> ${MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS})`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Verify relevant information when a public function is enqueued.
|
|
378
|
+
* @param targetContractAddress - The address of the contract to call.
|
|
379
|
+
* @param calldataHash - The hash of the function selector and arguments.
|
|
380
|
+
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
381
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
382
|
+
*/ privateNotifyEnqueuedPublicFunctionCall(_targetContractAddress, calldataHash, _sideEffectCounter, _isStaticCall) {
|
|
383
|
+
this.#onNewPublicFunctionCall(calldataHash);
|
|
384
|
+
return Promise.resolve();
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Verify relevant information when a public teardown function is set.
|
|
388
|
+
* @param targetContractAddress - The address of the contract to call.
|
|
389
|
+
* @param argsHash - The arguments hash to pass to the function.
|
|
390
|
+
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
391
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
392
|
+
*/ privateNotifySetPublicTeardownFunctionCall(_targetContractAddress, calldataHash, _sideEffectCounter, _isStaticCall) {
|
|
393
|
+
this.#onNewPublicFunctionCall(calldataHash);
|
|
394
|
+
return Promise.resolve();
|
|
395
|
+
}
|
|
396
|
+
privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter) {
|
|
397
|
+
return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Derives the call context for a nested execution.
|
|
401
|
+
* @param targetContractAddress - The address of the contract being called.
|
|
402
|
+
* @param targetArtifact - The artifact of the function being called.
|
|
403
|
+
* @param isStaticCall - Whether the call is a static call.
|
|
404
|
+
* @returns The derived call context.
|
|
405
|
+
*/ async deriveCallContext(targetContractAddress, targetArtifact, isStaticCall = false) {
|
|
406
|
+
return new CallContext(this.contractAddress, targetContractAddress, await FunctionSelector.fromNameAndParameters(targetArtifact.name, targetArtifact.parameters), isStaticCall);
|
|
407
|
+
}
|
|
408
|
+
getDebugFunctionName() {
|
|
409
|
+
return this.executionDataProvider.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
|
|
410
|
+
}
|
|
411
|
+
utilityEmitOffchainEffect(data) {
|
|
412
|
+
this.offchainEffects.push({
|
|
413
|
+
data
|
|
414
|
+
});
|
|
415
|
+
return Promise.resolve();
|
|
416
|
+
}
|
|
417
|
+
}
|