@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,207 @@
|
|
|
1
|
+
import { PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, 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 { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
|
+
import {
|
|
7
|
+
type ACVMWitness,
|
|
8
|
+
type CircuitSimulator,
|
|
9
|
+
ExecutionError,
|
|
10
|
+
extractCallStack,
|
|
11
|
+
resolveAssertionMessageFromError,
|
|
12
|
+
witnessMapToFields,
|
|
13
|
+
} from '@aztec/simulator/client';
|
|
14
|
+
import {
|
|
15
|
+
type FunctionArtifact,
|
|
16
|
+
type FunctionArtifactWithContractName,
|
|
17
|
+
type FunctionSelector,
|
|
18
|
+
countArgumentsSize,
|
|
19
|
+
} from '@aztec/stdlib/abi';
|
|
20
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
22
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
23
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
24
|
+
import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
25
|
+
import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
26
|
+
import { BlockHeader, PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
27
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
28
|
+
|
|
29
|
+
import type { ExecutionDataProvider } from '../execution_data_provider.js';
|
|
30
|
+
import { Oracle } from './oracle.js';
|
|
31
|
+
import type { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Execute a private function and return the execution result.
|
|
35
|
+
* This does not execute any kernel circuits; only the user functions.
|
|
36
|
+
*
|
|
37
|
+
* If this private function execution results in any nested private function calls,
|
|
38
|
+
* those nested calls are made via oracle calls to the `privateCallPrivateFunction` oracle,
|
|
39
|
+
* which in turn makes corresponding further calls to this function.
|
|
40
|
+
*/
|
|
41
|
+
export async function executePrivateFunction(
|
|
42
|
+
simulator: CircuitSimulator,
|
|
43
|
+
privateExecutionOracle: PrivateExecutionOracle,
|
|
44
|
+
artifact: FunctionArtifactWithContractName,
|
|
45
|
+
contractAddress: AztecAddress,
|
|
46
|
+
functionSelector: FunctionSelector,
|
|
47
|
+
log = createLogger('simulator:private_execution'),
|
|
48
|
+
): Promise<PrivateCallExecutionResult> {
|
|
49
|
+
const functionName = await privateExecutionOracle.getDebugFunctionName();
|
|
50
|
+
log.verbose(`Executing private function ${functionName}`, { contract: contractAddress });
|
|
51
|
+
const initialWitness = privateExecutionOracle.getInitialWitness(artifact);
|
|
52
|
+
const acvmCallback = new Oracle(privateExecutionOracle);
|
|
53
|
+
const timer = new Timer();
|
|
54
|
+
const acirExecutionResult = await simulator
|
|
55
|
+
.executeUserCircuit(initialWitness, artifact, acvmCallback.toACIRCallback())
|
|
56
|
+
.catch((err: Error) => {
|
|
57
|
+
err.message = resolveAssertionMessageFromError(err, artifact);
|
|
58
|
+
throw new ExecutionError(
|
|
59
|
+
err.message,
|
|
60
|
+
{
|
|
61
|
+
contractAddress,
|
|
62
|
+
functionSelector,
|
|
63
|
+
},
|
|
64
|
+
extractCallStack(err, artifact.debug),
|
|
65
|
+
{ cause: err },
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
const duration = timer.ms();
|
|
69
|
+
const partialWitness = acirExecutionResult.partialWitness;
|
|
70
|
+
const publicInputs = extractPrivateCircuitPublicInputs(artifact, partialWitness);
|
|
71
|
+
|
|
72
|
+
// TODO (alexg) estimate this size
|
|
73
|
+
const initialWitnessSize = witnessMapToFields(initialWitness).length * Fr.SIZE_IN_BYTES;
|
|
74
|
+
log.debug(`Ran external function ${contractAddress.toString()}:${functionSelector}`, {
|
|
75
|
+
circuitName: 'app-circuit',
|
|
76
|
+
duration,
|
|
77
|
+
eventName: 'circuit-witness-generation',
|
|
78
|
+
inputSize: initialWitnessSize,
|
|
79
|
+
outputSize: publicInputs.toBuffer().length,
|
|
80
|
+
appCircuitName: functionName,
|
|
81
|
+
} satisfies CircuitWitnessGenerationStats);
|
|
82
|
+
|
|
83
|
+
const contractClassLogs = privateExecutionOracle.getContractClassLogs();
|
|
84
|
+
|
|
85
|
+
const rawReturnValues = await privateExecutionOracle.privateLoadFromExecutionCache(publicInputs.returnsHash);
|
|
86
|
+
|
|
87
|
+
const noteHashLeafIndexMap = privateExecutionOracle.getNoteHashLeafIndexMap();
|
|
88
|
+
const newNotes = privateExecutionOracle.getNewNotes();
|
|
89
|
+
const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
|
|
90
|
+
const offchainEffects = privateExecutionOracle.getOffchainEffects();
|
|
91
|
+
const preTags = privateExecutionOracle.getUsedPreTags();
|
|
92
|
+
const nestedExecutionResults = privateExecutionOracle.getNestedExecutionResults();
|
|
93
|
+
|
|
94
|
+
let timerSubtractionList = nestedExecutionResults;
|
|
95
|
+
let witgenTime = duration;
|
|
96
|
+
|
|
97
|
+
// Due to the recursive nature of execution, we have to subtract the time taken by nested calls
|
|
98
|
+
while (timerSubtractionList.length > 0) {
|
|
99
|
+
witgenTime -= timerSubtractionList.reduce((acc, nested) => acc + (nested.profileResult?.timings.witgen ?? 0), 0);
|
|
100
|
+
timerSubtractionList = timerSubtractionList.flatMap(nested => nested.nestedExecutionResults ?? []);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
|
|
104
|
+
|
|
105
|
+
return new PrivateCallExecutionResult(
|
|
106
|
+
artifact.bytecode,
|
|
107
|
+
Buffer.from(artifact.verificationKey!, 'base64'),
|
|
108
|
+
partialWitness,
|
|
109
|
+
publicInputs,
|
|
110
|
+
noteHashLeafIndexMap,
|
|
111
|
+
newNotes,
|
|
112
|
+
noteHashNullifierCounterMap,
|
|
113
|
+
rawReturnValues,
|
|
114
|
+
offchainEffects,
|
|
115
|
+
preTags,
|
|
116
|
+
nestedExecutionResults,
|
|
117
|
+
contractClassLogs,
|
|
118
|
+
{
|
|
119
|
+
timings: {
|
|
120
|
+
witgen: witgenTime,
|
|
121
|
+
oracles: acirExecutionResult.oracles,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get the private circuit public inputs from the partial witness.
|
|
129
|
+
* @param artifact - The function artifact
|
|
130
|
+
* @param partialWitness - The partial witness, result of simulating the function.
|
|
131
|
+
* @returns - The public inputs.
|
|
132
|
+
*/
|
|
133
|
+
export function extractPrivateCircuitPublicInputs(
|
|
134
|
+
artifact: FunctionArtifact,
|
|
135
|
+
partialWitness: ACVMWitness,
|
|
136
|
+
): PrivateCircuitPublicInputs {
|
|
137
|
+
const parametersSize = countArgumentsSize(artifact) + PRIVATE_CONTEXT_INPUTS_LENGTH;
|
|
138
|
+
const returnsSize = PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH;
|
|
139
|
+
const returnData = [];
|
|
140
|
+
// Return values always appear in the witness after arguments.
|
|
141
|
+
for (let i = parametersSize; i < parametersSize + returnsSize; i++) {
|
|
142
|
+
const returnedField = partialWitness.get(i);
|
|
143
|
+
if (returnedField === undefined) {
|
|
144
|
+
throw new Error(`Missing return value for index ${i}`);
|
|
145
|
+
}
|
|
146
|
+
returnData.push(Fr.fromString(returnedField));
|
|
147
|
+
}
|
|
148
|
+
return PrivateCircuitPublicInputs.fromFields(returnData);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
153
|
+
* from the instance is used.
|
|
154
|
+
* @param contractAddress - The address of the contract to read the class id for.
|
|
155
|
+
* @param instance - The instance of the contract.
|
|
156
|
+
* @param executionDataProvider - The execution data provider.
|
|
157
|
+
* @param blockNumber - The block number at which to load the DelayedPublicMutable storing the class id.
|
|
158
|
+
* @param timestamp - The timestamp at which to obtain the class id from the DelayedPublicMutable.
|
|
159
|
+
* @returns The current class id.
|
|
160
|
+
*/
|
|
161
|
+
export async function readCurrentClassId(
|
|
162
|
+
contractAddress: AztecAddress,
|
|
163
|
+
instance: ContractInstance,
|
|
164
|
+
executionDataProvider: ExecutionDataProvider | AztecNode,
|
|
165
|
+
blockNumber: number,
|
|
166
|
+
timestamp: UInt64,
|
|
167
|
+
) {
|
|
168
|
+
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
169
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
170
|
+
executionDataProvider.getPublicStorageAt(blockNumber, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
171
|
+
);
|
|
172
|
+
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
173
|
+
if (currentClassId.isZero()) {
|
|
174
|
+
currentClassId = instance.originalContractClassId;
|
|
175
|
+
}
|
|
176
|
+
return currentClassId;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in the execution data
|
|
181
|
+
* provider (i.e. PXE).
|
|
182
|
+
* @param contractAddress - The address of the contract to verify class id for.
|
|
183
|
+
* @param executionDataProvider - The execution data provider.
|
|
184
|
+
* @param header - The header of the block at which to verify the current class id. If not provided, the anchor block
|
|
185
|
+
* header of the execution data provider is used.
|
|
186
|
+
*/
|
|
187
|
+
export async function verifyCurrentClassId(
|
|
188
|
+
contractAddress: AztecAddress,
|
|
189
|
+
executionDataProvider: ExecutionDataProvider,
|
|
190
|
+
header?: BlockHeader,
|
|
191
|
+
) {
|
|
192
|
+
header = header ?? (await executionDataProvider.getAnchorBlockHeader());
|
|
193
|
+
|
|
194
|
+
const instance = await executionDataProvider.getContractInstance(contractAddress);
|
|
195
|
+
const currentClassId = await readCurrentClassId(
|
|
196
|
+
contractAddress,
|
|
197
|
+
instance,
|
|
198
|
+
executionDataProvider,
|
|
199
|
+
header.globalVariables.blockNumber,
|
|
200
|
+
header.globalVariables.timestamp,
|
|
201
|
+
);
|
|
202
|
+
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
}
|