@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,49 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
// TS equivalent of the `NoteMetadata::from_raw_data` function in `aztec/src/note/note_metadata.nr`
|
|
3
|
+
function fromRawData(nonzeroNoteHashCounter, maybeNoteNonce) {
|
|
4
|
+
if (nonzeroNoteHashCounter) {
|
|
5
|
+
if (maybeNoteNonce.equals(Fr.ZERO)) {
|
|
6
|
+
return {
|
|
7
|
+
stage: 1,
|
|
8
|
+
maybeNoteNonce
|
|
9
|
+
}; // PENDING_SAME_PHASE
|
|
10
|
+
} else {
|
|
11
|
+
return {
|
|
12
|
+
stage: 2,
|
|
13
|
+
maybeNoteNonce
|
|
14
|
+
}; // PENDING_PREVIOUS_PHASE
|
|
15
|
+
}
|
|
16
|
+
} else if (!maybeNoteNonce.equals(Fr.ZERO)) {
|
|
17
|
+
return {
|
|
18
|
+
stage: 3,
|
|
19
|
+
maybeNoteNonce
|
|
20
|
+
}; // SETTLED
|
|
21
|
+
} else {
|
|
22
|
+
throw new Error('Note has a zero note hash counter and no nonce - existence cannot be proven');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Packs a note in a format that is compatible with the default Packable implementation of the retrieved note.
|
|
27
|
+
*
|
|
28
|
+
* @dev Unlike the default Packable implementation, this function first constructs the note metadata from the inputs
|
|
29
|
+
* and only after that it packs the retrieved note. Hence it doesn't map one to one with `RetrievedNote::pack()`.
|
|
30
|
+
*
|
|
31
|
+
* @param contractAddress - The address of the contract that owns the note
|
|
32
|
+
* @param noteNonce - The nonce injected into the note hash preimage by kernels.
|
|
33
|
+
* @param index - Optional index in the note hash tree. If undefined, indicates a transient note
|
|
34
|
+
* @param note - The note content containing the actual note data
|
|
35
|
+
* @returns The packed note as an array of field elements
|
|
36
|
+
*/ export function packAsRetrievedNote({ contractAddress, noteNonce, index, note }) {
|
|
37
|
+
// If index is undefined, the note is transient which implies that the nonzero_note_hash_counter has to be true
|
|
38
|
+
const noteIsTransient = index === undefined;
|
|
39
|
+
const nonzeroNoteHashCounter = noteIsTransient ? true : false;
|
|
40
|
+
// To pack the note as retrieved note we first need to reconstruct the note metadata.
|
|
41
|
+
const noteMetadata = fromRawData(nonzeroNoteHashCounter, noteNonce);
|
|
42
|
+
// Pack metadata first (stage and maybe_note_nonce), followed by the rest
|
|
43
|
+
return [
|
|
44
|
+
...note.items,
|
|
45
|
+
contractAddress,
|
|
46
|
+
new Fr(noteMetadata.stage),
|
|
47
|
+
noteMetadata.maybeNoteNonce
|
|
48
|
+
];
|
|
49
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ACIRCallback, type ACVMField } from '@aztec/simulator/client';
|
|
2
|
+
import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
|
|
3
|
+
export declare class UnavailableOracleError extends Error {
|
|
4
|
+
constructor(oracleName: string);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A data source that has all the apis required by Aztec.nr.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Oracle {
|
|
10
|
+
private handler;
|
|
11
|
+
constructor(handler: IMiscOracle | IUtilityExecutionOracle | IPrivateExecutionOracle);
|
|
12
|
+
private handlerAsMisc;
|
|
13
|
+
private handlerAsUtility;
|
|
14
|
+
private handlerAsPrivate;
|
|
15
|
+
toACIRCallback(): ACIRCallback;
|
|
16
|
+
utilityAssertCompatibleOracleVersion([version]: ACVMField[]): Promise<never[]>;
|
|
17
|
+
utilityGetRandomField(): Promise<ACVMField[]>;
|
|
18
|
+
privateStoreInExecutionCache(_length: ACVMField[], values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]>;
|
|
19
|
+
privateLoadFromExecutionCache([returnsHash]: ACVMField[]): Promise<ACVMField[][]>;
|
|
20
|
+
utilityGetUtilityContext(): Promise<(ACVMField | ACVMField[])[]>;
|
|
21
|
+
utilityGetKeyValidationRequest([pkMHash]: ACVMField[]): Promise<ACVMField[]>;
|
|
22
|
+
utilityGetContractInstance([address]: ACVMField[]): Promise<ACVMField[]>;
|
|
23
|
+
utilityGetMembershipWitness([blockNumber]: ACVMField[], [treeId]: ACVMField[], [leafValue]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
24
|
+
utilityGetNullifierMembershipWitness([blockNumber]: ACVMField[], [nullifier]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
25
|
+
utilityGetLowNullifierMembershipWitness([blockNumber]: ACVMField[], [nullifier]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
26
|
+
utilityGetPublicDataWitness([blockNumber]: ACVMField[], [leafSlot]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
27
|
+
utilityGetBlockHeader([blockNumber]: ACVMField[]): Promise<ACVMField[]>;
|
|
28
|
+
utilityGetAuthWitness([messageHash]: ACVMField[]): Promise<ACVMField[][]>;
|
|
29
|
+
utilityGetPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<ACVMField[][]>;
|
|
30
|
+
utilityGetNotes([storageSlot]: ACVMField[], [numSelects]: ACVMField[], selectByIndexes: ACVMField[], selectByOffsets: ACVMField[], selectByLengths: ACVMField[], selectValues: ACVMField[], selectComparators: ACVMField[], sortByIndexes: ACVMField[], sortByOffsets: ACVMField[], sortByLengths: ACVMField[], sortOrder: ACVMField[], [limit]: ACVMField[], [offset]: ACVMField[], [status]: ACVMField[], [maxNotes]: ACVMField[], [packedRetrievedNoteLength]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
31
|
+
privateNotifyCreatedNote([storageSlot]: ACVMField[], [noteTypeId]: ACVMField[], note: ACVMField[], [noteHash]: ACVMField[], [counter]: ACVMField[]): Promise<ACVMField[]>;
|
|
32
|
+
privateNotifyNullifiedNote([innerNullifier]: ACVMField[], [noteHash]: ACVMField[], [counter]: ACVMField[]): Promise<ACVMField[]>;
|
|
33
|
+
privateNotifyCreatedNullifier([innerNullifier]: ACVMField[]): Promise<ACVMField[]>;
|
|
34
|
+
utilityCheckNullifierExists([innerNullifier]: ACVMField[]): Promise<ACVMField[]>;
|
|
35
|
+
utilityGetL1ToL2MembershipWitness([contractAddress]: ACVMField[], [messageHash]: ACVMField[], [secret]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
36
|
+
utilityStorageRead([contractAddress]: ACVMField[], [startStorageSlot]: ACVMField[], [blockNumber]: ACVMField[], [numberOfElements]: ACVMField[]): Promise<ACVMField[][]>;
|
|
37
|
+
privateNotifyCreatedContractClassLog([contractAddress]: ACVMField[], message: ACVMField[], [length]: ACVMField[], [counter]: ACVMField[]): Promise<ACVMField[]>;
|
|
38
|
+
utilityDebugLog(level: ACVMField[], message: ACVMField[], _ignoredFieldsSize: ACVMField[], fields: ACVMField[]): Promise<ACVMField[]>;
|
|
39
|
+
privateCallPrivateFunction([contractAddress]: ACVMField[], [functionSelector]: ACVMField[], [argsHash]: ACVMField[], [sideEffectCounter]: ACVMField[], [isStaticCall]: ACVMField[]): Promise<ACVMField[][]>;
|
|
40
|
+
privateNotifyEnqueuedPublicFunctionCall([contractAddress]: ACVMField[], [calldataHash]: ACVMField[], [sideEffectCounter]: ACVMField[], [isStaticCall]: ACVMField[]): Promise<ACVMField[]>;
|
|
41
|
+
privateNotifySetPublicTeardownFunctionCall([contractAddress]: ACVMField[], [calldataHash]: ACVMField[], [sideEffectCounter]: ACVMField[], [isStaticCall]: ACVMField[]): Promise<ACVMField[]>;
|
|
42
|
+
privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]: ACVMField[]): Promise<ACVMField[]>;
|
|
43
|
+
privateGetNextAppTagAsSender([sender]: ACVMField[], [recipient]: ACVMField[]): Promise<ACVMField[]>;
|
|
44
|
+
utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]>;
|
|
45
|
+
utilityValidateEnqueuedNotesAndEvents([contractAddress]: ACVMField[], [noteValidationRequestsArrayBaseSlot]: ACVMField[], [eventValidationRequestsArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]>;
|
|
46
|
+
utilityBulkRetrieveLogs([contractAddress]: ACVMField[], [logRetrievalRequestsArrayBaseSlot]: ACVMField[], [logRetrievalResponsesArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]>;
|
|
47
|
+
utilityStoreCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[], capsule: ACVMField[]): Promise<ACVMField[]>;
|
|
48
|
+
utilityLoadCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[], [tSize]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
49
|
+
utilityDeleteCapsule([contractAddress]: ACVMField[], [slot]: ACVMField[]): Promise<ACVMField[]>;
|
|
50
|
+
utilityCopyCapsule([contractAddress]: ACVMField[], [srcSlot]: ACVMField[], [dstSlot]: ACVMField[], [numEntries]: ACVMField[]): Promise<ACVMField[]>;
|
|
51
|
+
utilityAes128Decrypt(ciphertextBVecStorage: ACVMField[], [ciphertextLength]: ACVMField[], iv: ACVMField[], symKey: ACVMField[]): Promise<(ACVMField | ACVMField[])[]>;
|
|
52
|
+
utilityGetSharedSecret([address]: ACVMField[], [ephPKField0]: ACVMField[], [ephPKField1]: ACVMField[], [ephPKField2]: ACVMField[]): Promise<ACVMField[]>;
|
|
53
|
+
utilityEmitOffchainEffect(data: ACVMField[]): Promise<never[]>;
|
|
54
|
+
privateGetSenderForTags(): Promise<ACVMField[]>;
|
|
55
|
+
privateSetSenderForTags([senderForTags]: ACVMField[]): Promise<ACVMField[]>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=oracle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/oracle/oracle.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAMf,MAAM,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGrG,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,UAAU,EAAE,MAAM;CAG/B;AAED;;GAEG;AACH,qBAAa,MAAM;IACL,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,WAAW,GAAG,uBAAuB,GAAG,uBAAuB;IAE5F,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,gBAAgB;IAQxB,cAAc,IAAI,YAAY;IAsC9B,oCAAoC,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE;IAK3D,qBAAqB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAM7C,4BAA4B,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAK5G,6BAA6B,CAAC,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;IAKjF,wBAAwB,IAAI,OAAO,CAAC,CAAC,SAAS,GAAG,SA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,328 @@
|
|
|
1
|
+
import { Fr, Point } from '@aztec/foundation/fields';
|
|
2
|
+
import { arrayOfArraysToBoundedVecOfArrays, bufferToBoundedVec, fromUintArray, fromUintBoundedVec, toACVMField } from '@aztec/simulator/client';
|
|
3
|
+
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
6
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
|
+
import { packAsRetrievedNote } from './note_packing_utils.js';
|
|
8
|
+
export class UnavailableOracleError extends Error {
|
|
9
|
+
constructor(oracleName){
|
|
10
|
+
super(`${oracleName} oracles not available with the current handler`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A data source that has all the apis required by Aztec.nr.
|
|
15
|
+
*/ export class Oracle {
|
|
16
|
+
handler;
|
|
17
|
+
constructor(handler){
|
|
18
|
+
this.handler = handler;
|
|
19
|
+
}
|
|
20
|
+
handlerAsMisc() {
|
|
21
|
+
if (!('isMisc' in this.handler)) {
|
|
22
|
+
throw new UnavailableOracleError('Misc');
|
|
23
|
+
}
|
|
24
|
+
return this.handler;
|
|
25
|
+
}
|
|
26
|
+
handlerAsUtility() {
|
|
27
|
+
if (!('isUtility' in this.handler)) {
|
|
28
|
+
throw new UnavailableOracleError('Utility');
|
|
29
|
+
}
|
|
30
|
+
return this.handler;
|
|
31
|
+
}
|
|
32
|
+
handlerAsPrivate() {
|
|
33
|
+
if (!('isPrivate' in this.handler)) {
|
|
34
|
+
throw new UnavailableOracleError('Private');
|
|
35
|
+
}
|
|
36
|
+
return this.handler;
|
|
37
|
+
}
|
|
38
|
+
toACIRCallback() {
|
|
39
|
+
const excludedProps = [
|
|
40
|
+
'handler',
|
|
41
|
+
'constructor',
|
|
42
|
+
'toACIRCallback',
|
|
43
|
+
'handlerAsMisc',
|
|
44
|
+
'handlerAsUtility',
|
|
45
|
+
'handlerAsPrivate'
|
|
46
|
+
];
|
|
47
|
+
// Get all the oracle function names
|
|
48
|
+
const oracleNames = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>!excludedProps.includes(name));
|
|
49
|
+
// Validate oracle names - these must be prefixed with either "private" or "utility" to indicate their scope
|
|
50
|
+
// and must correspond to a function on the Oracle class.
|
|
51
|
+
oracleNames.forEach((name)=>{
|
|
52
|
+
if (!name.startsWith('private') && !name.startsWith('utility')) {
|
|
53
|
+
throw new Error(`Oracle function "${name}" must be prefixed with either "private" or "utility" to indicate its scope`);
|
|
54
|
+
}
|
|
55
|
+
const method = this[name];
|
|
56
|
+
if (typeof method !== 'function') {
|
|
57
|
+
throw new Error(`Oracle property "${name}" must be a function`);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
// Build callback object and return it
|
|
61
|
+
return oracleNames.reduce((acc, name)=>{
|
|
62
|
+
const method = this[name];
|
|
63
|
+
acc[name] = method.bind(this);
|
|
64
|
+
return acc;
|
|
65
|
+
}, {});
|
|
66
|
+
}
|
|
67
|
+
utilityAssertCompatibleOracleVersion([version]) {
|
|
68
|
+
this.handlerAsMisc().utilityAssertCompatibleOracleVersion(Fr.fromString(version).toNumber());
|
|
69
|
+
return Promise.resolve([]);
|
|
70
|
+
}
|
|
71
|
+
utilityGetRandomField() {
|
|
72
|
+
const val = this.handlerAsMisc().utilityGetRandomField();
|
|
73
|
+
return Promise.resolve([
|
|
74
|
+
toACVMField(val)
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
// Since the argument is a slice, noir automatically adds a length field to oracle call.
|
|
78
|
+
privateStoreInExecutionCache(_length, values, [hash]) {
|
|
79
|
+
this.handlerAsPrivate().privateStoreInExecutionCache(values.map(Fr.fromString), Fr.fromString(hash));
|
|
80
|
+
return Promise.resolve([]);
|
|
81
|
+
}
|
|
82
|
+
async privateLoadFromExecutionCache([returnsHash]) {
|
|
83
|
+
const values = await this.handlerAsPrivate().privateLoadFromExecutionCache(Fr.fromString(returnsHash));
|
|
84
|
+
return [
|
|
85
|
+
values.map(toACVMField)
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
async utilityGetUtilityContext() {
|
|
89
|
+
const context = await this.handlerAsUtility().utilityGetUtilityContext();
|
|
90
|
+
return context.toNoirRepresentation();
|
|
91
|
+
}
|
|
92
|
+
async utilityGetKeyValidationRequest([pkMHash]) {
|
|
93
|
+
const keyValidationRequest = await this.handlerAsUtility().utilityGetKeyValidationRequest(Fr.fromString(pkMHash));
|
|
94
|
+
return keyValidationRequest.toFields().map(toACVMField);
|
|
95
|
+
}
|
|
96
|
+
async utilityGetContractInstance([address]) {
|
|
97
|
+
const instance = await this.handlerAsUtility().utilityGetContractInstance(AztecAddress.fromField(Fr.fromString(address)));
|
|
98
|
+
return [
|
|
99
|
+
instance.salt,
|
|
100
|
+
instance.deployer,
|
|
101
|
+
instance.currentContractClassId,
|
|
102
|
+
instance.initializationHash,
|
|
103
|
+
...instance.publicKeys.toFields()
|
|
104
|
+
].map(toACVMField);
|
|
105
|
+
}
|
|
106
|
+
async utilityGetMembershipWitness([blockNumber], [treeId], [leafValue]) {
|
|
107
|
+
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
108
|
+
const parsedTreeId = Fr.fromString(treeId).toNumber();
|
|
109
|
+
const parsedLeafValue = Fr.fromString(leafValue);
|
|
110
|
+
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(parsedBlockNumber, parsedTreeId, parsedLeafValue);
|
|
111
|
+
if (!witness) {
|
|
112
|
+
throw new Error(`Leaf ${leafValue} not found in the tree ${MerkleTreeId[parsedTreeId]} at block ${parsedBlockNumber}.`);
|
|
113
|
+
}
|
|
114
|
+
return [
|
|
115
|
+
toACVMField(witness[0]),
|
|
116
|
+
witness.slice(1).map(toACVMField)
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
async utilityGetNullifierMembershipWitness([blockNumber], [nullifier]) {
|
|
120
|
+
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
121
|
+
const parsedNullifier = Fr.fromString(nullifier);
|
|
122
|
+
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(parsedBlockNumber, parsedNullifier);
|
|
123
|
+
if (!witness) {
|
|
124
|
+
throw new Error(`Nullifier witness not found for nullifier ${parsedNullifier} at block ${parsedBlockNumber}.`);
|
|
125
|
+
}
|
|
126
|
+
return witness.toNoirRepresentation();
|
|
127
|
+
}
|
|
128
|
+
async utilityGetLowNullifierMembershipWitness([blockNumber], [nullifier]) {
|
|
129
|
+
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
130
|
+
const parsedNullifier = Fr.fromString(nullifier);
|
|
131
|
+
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(parsedBlockNumber, parsedNullifier);
|
|
132
|
+
if (!witness) {
|
|
133
|
+
throw new Error(`Low nullifier witness not found for nullifier ${parsedNullifier} at block ${parsedBlockNumber}.`);
|
|
134
|
+
}
|
|
135
|
+
return witness.toNoirRepresentation();
|
|
136
|
+
}
|
|
137
|
+
async utilityGetPublicDataWitness([blockNumber], [leafSlot]) {
|
|
138
|
+
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
139
|
+
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
140
|
+
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockNumber, parsedLeafSlot);
|
|
141
|
+
if (!witness) {
|
|
142
|
+
throw new Error(`Public data witness not found for slot ${parsedLeafSlot} at block ${parsedBlockNumber}.`);
|
|
143
|
+
}
|
|
144
|
+
return witness.toNoirRepresentation();
|
|
145
|
+
}
|
|
146
|
+
async utilityGetBlockHeader([blockNumber]) {
|
|
147
|
+
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
148
|
+
const header = await this.handlerAsUtility().utilityGetBlockHeader(parsedBlockNumber);
|
|
149
|
+
if (!header) {
|
|
150
|
+
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
151
|
+
}
|
|
152
|
+
return header.toFields().map(toACVMField);
|
|
153
|
+
}
|
|
154
|
+
async utilityGetAuthWitness([messageHash]) {
|
|
155
|
+
const messageHashField = Fr.fromString(messageHash);
|
|
156
|
+
const witness = await this.handlerAsUtility().utilityGetAuthWitness(messageHashField);
|
|
157
|
+
if (!witness) {
|
|
158
|
+
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
159
|
+
}
|
|
160
|
+
return [
|
|
161
|
+
witness.map(toACVMField)
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
async utilityGetPublicKeysAndPartialAddress([address]) {
|
|
165
|
+
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
166
|
+
const { publicKeys, partialAddress } = await this.handlerAsUtility().utilityGetPublicKeysAndPartialAddress(parsedAddress);
|
|
167
|
+
return [
|
|
168
|
+
[
|
|
169
|
+
...publicKeys.toFields(),
|
|
170
|
+
partialAddress
|
|
171
|
+
].map(toACVMField)
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
async utilityGetNotes([storageSlot], [numSelects], selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, [limit], [offset], [status], [maxNotes], [packedRetrievedNoteLength]) {
|
|
175
|
+
const noteDatas = await this.handlerAsUtility().utilityGetNotes(Fr.fromString(storageSlot), +numSelects, selectByIndexes.map((s)=>+s), selectByOffsets.map((s)=>+s), selectByLengths.map((s)=>+s), selectValues.map(Fr.fromString), selectComparators.map((s)=>+s), sortByIndexes.map((s)=>+s), sortByOffsets.map((s)=>+s), sortByLengths.map((s)=>+s), sortOrder.map((s)=>+s), +limit, +offset, +status);
|
|
176
|
+
const returnDataAsArrayOfPackedRetrievedNotes = noteDatas.map(packAsRetrievedNote);
|
|
177
|
+
// Now we convert each sub-array to an array of ACVMField
|
|
178
|
+
const returnDataAsArrayOfACVMFieldArrays = returnDataAsArrayOfPackedRetrievedNotes.map((subArray)=>subArray.map(toACVMField));
|
|
179
|
+
// At last we convert the array of arrays to a bounded vec of arrays
|
|
180
|
+
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedRetrievedNoteLength);
|
|
181
|
+
}
|
|
182
|
+
privateNotifyCreatedNote([storageSlot], [noteTypeId], note, [noteHash], [counter]) {
|
|
183
|
+
this.handlerAsPrivate().privateNotifyCreatedNote(Fr.fromString(storageSlot), NoteSelector.fromField(Fr.fromString(noteTypeId)), note.map(Fr.fromString), Fr.fromString(noteHash), +counter);
|
|
184
|
+
return Promise.resolve([]);
|
|
185
|
+
}
|
|
186
|
+
async privateNotifyNullifiedNote([innerNullifier], [noteHash], [counter]) {
|
|
187
|
+
await this.handlerAsPrivate().privateNotifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
async privateNotifyCreatedNullifier([innerNullifier]) {
|
|
191
|
+
await this.handlerAsPrivate().privateNotifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
async utilityCheckNullifierExists([innerNullifier]) {
|
|
195
|
+
const exists = await this.handlerAsUtility().utilityCheckNullifierExists(Fr.fromString(innerNullifier));
|
|
196
|
+
return [
|
|
197
|
+
toACVMField(exists)
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
async utilityGetL1ToL2MembershipWitness([contractAddress], [messageHash], [secret]) {
|
|
201
|
+
const message = await this.handlerAsUtility().utilityGetL1ToL2MembershipWitness(AztecAddress.fromString(contractAddress), Fr.fromString(messageHash), Fr.fromString(secret));
|
|
202
|
+
return message.toNoirRepresentation();
|
|
203
|
+
}
|
|
204
|
+
async utilityStorageRead([contractAddress], [startStorageSlot], [blockNumber], [numberOfElements]) {
|
|
205
|
+
const values = await this.handlerAsUtility().utilityStorageRead(new AztecAddress(Fr.fromString(contractAddress)), Fr.fromString(startStorageSlot), +blockNumber, +numberOfElements);
|
|
206
|
+
return [
|
|
207
|
+
values.map(toACVMField)
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
privateNotifyCreatedContractClassLog([contractAddress], message, [length], [counter]) {
|
|
211
|
+
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
212
|
+
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
213
|
+
this.handlerAsPrivate().privateNotifyCreatedContractClassLog(log, +counter);
|
|
214
|
+
return Promise.resolve([]);
|
|
215
|
+
}
|
|
216
|
+
utilityDebugLog(level, message, _ignoredFieldsSize, fields) {
|
|
217
|
+
const levelFr = Fr.fromString(level[0]);
|
|
218
|
+
const messageStr = message.map((acvmField)=>String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
219
|
+
const fieldsFr = fields.map(Fr.fromString);
|
|
220
|
+
this.handlerAsMisc().utilityDebugLog(levelFr.toNumber(), messageStr, fieldsFr);
|
|
221
|
+
return Promise.resolve([]);
|
|
222
|
+
}
|
|
223
|
+
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
224
|
+
// change the name here.
|
|
225
|
+
async privateCallPrivateFunction([contractAddress], [functionSelector], [argsHash], [sideEffectCounter], [isStaticCall]) {
|
|
226
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().privateCallPrivateFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), Fr.fromString(argsHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
227
|
+
return [
|
|
228
|
+
[
|
|
229
|
+
endSideEffectCounter,
|
|
230
|
+
returnsHash
|
|
231
|
+
].map(toACVMField)
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
async privateNotifyEnqueuedPublicFunctionCall([contractAddress], [calldataHash], [sideEffectCounter], [isStaticCall]) {
|
|
235
|
+
await this.handlerAsPrivate().privateNotifyEnqueuedPublicFunctionCall(AztecAddress.fromString(contractAddress), Fr.fromString(calldataHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
async privateNotifySetPublicTeardownFunctionCall([contractAddress], [calldataHash], [sideEffectCounter], [isStaticCall]) {
|
|
239
|
+
await this.handlerAsPrivate().privateNotifySetPublicTeardownFunctionCall(AztecAddress.fromString(contractAddress), Fr.fromString(calldataHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]) {
|
|
243
|
+
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
244
|
+
return Promise.resolve([]);
|
|
245
|
+
}
|
|
246
|
+
async privateGetNextAppTagAsSender([sender], [recipient]) {
|
|
247
|
+
const tag = await this.handlerAsPrivate().privateGetNextAppTagAsSender(AztecAddress.fromString(sender), AztecAddress.fromString(recipient));
|
|
248
|
+
return [
|
|
249
|
+
toACVMField(tag.value)
|
|
250
|
+
];
|
|
251
|
+
}
|
|
252
|
+
async utilityFetchTaggedLogs([pendingTaggedLogArrayBaseSlot]) {
|
|
253
|
+
await this.handlerAsUtility().utilityFetchTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot));
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
async utilityValidateEnqueuedNotesAndEvents([contractAddress], [noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot]) {
|
|
257
|
+
await this.handlerAsUtility().utilityValidateEnqueuedNotesAndEvents(AztecAddress.fromString(contractAddress), Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot));
|
|
258
|
+
return [];
|
|
259
|
+
}
|
|
260
|
+
async utilityBulkRetrieveLogs([contractAddress], [logRetrievalRequestsArrayBaseSlot], [logRetrievalResponsesArrayBaseSlot]) {
|
|
261
|
+
await this.handlerAsUtility().utilityBulkRetrieveLogs(AztecAddress.fromString(contractAddress), Fr.fromString(logRetrievalRequestsArrayBaseSlot), Fr.fromString(logRetrievalResponsesArrayBaseSlot));
|
|
262
|
+
return [];
|
|
263
|
+
}
|
|
264
|
+
async utilityStoreCapsule([contractAddress], [slot], capsule) {
|
|
265
|
+
await this.handlerAsUtility().utilityStoreCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), capsule.map(Fr.fromString));
|
|
266
|
+
return [];
|
|
267
|
+
}
|
|
268
|
+
async utilityLoadCapsule([contractAddress], [slot], [tSize]) {
|
|
269
|
+
const values = await this.handlerAsUtility().utilityLoadCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot));
|
|
270
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
271
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
272
|
+
if (values === null) {
|
|
273
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
274
|
+
return [
|
|
275
|
+
toACVMField(0),
|
|
276
|
+
Array(Fr.fromString(tSize).toNumber()).fill(toACVMField(0))
|
|
277
|
+
];
|
|
278
|
+
} else {
|
|
279
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
280
|
+
return [
|
|
281
|
+
toACVMField(1),
|
|
282
|
+
values.map(toACVMField)
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async utilityDeleteCapsule([contractAddress], [slot]) {
|
|
287
|
+
await this.handlerAsUtility().utilityDeleteCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot));
|
|
288
|
+
return [];
|
|
289
|
+
}
|
|
290
|
+
async utilityCopyCapsule([contractAddress], [srcSlot], [dstSlot], [numEntries]) {
|
|
291
|
+
await this.handlerAsUtility().utilityCopyCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(srcSlot), Fr.fromString(dstSlot), Fr.fromString(numEntries).toNumber());
|
|
292
|
+
return [];
|
|
293
|
+
}
|
|
294
|
+
async utilityAes128Decrypt(ciphertextBVecStorage, [ciphertextLength], iv, symKey) {
|
|
295
|
+
const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
|
|
296
|
+
const ivBuffer = fromUintArray(iv, 8);
|
|
297
|
+
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
298
|
+
const plaintext = await this.handlerAsUtility().utilityAes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
|
|
299
|
+
return bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
300
|
+
}
|
|
301
|
+
async utilityGetSharedSecret([address], [ephPKField0], [ephPKField1], [ephPKField2]) {
|
|
302
|
+
const secret = await this.handlerAsUtility().utilityGetSharedSecret(AztecAddress.fromField(Fr.fromString(address)), Point.fromFields([
|
|
303
|
+
ephPKField0,
|
|
304
|
+
ephPKField1,
|
|
305
|
+
ephPKField2
|
|
306
|
+
].map(Fr.fromString)));
|
|
307
|
+
return secret.toFields().map(toACVMField);
|
|
308
|
+
}
|
|
309
|
+
async utilityEmitOffchainEffect(data) {
|
|
310
|
+
await this.handlerAsPrivate().utilityEmitOffchainEffect(data.map(Fr.fromString));
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
async privateGetSenderForTags() {
|
|
314
|
+
const sender = await this.handlerAsPrivate().privateGetSenderForTags();
|
|
315
|
+
// Return [1, address] for Some(address), [0, 0] for None
|
|
316
|
+
return sender ? [
|
|
317
|
+
toACVMField(1n),
|
|
318
|
+
toACVMField(sender)
|
|
319
|
+
] : [
|
|
320
|
+
toACVMField(0n),
|
|
321
|
+
toACVMField(0n)
|
|
322
|
+
];
|
|
323
|
+
}
|
|
324
|
+
async privateSetSenderForTags([senderForTags]) {
|
|
325
|
+
await this.handlerAsPrivate().privateSetSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
|
|
326
|
+
return [];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type ACVMWitness, type CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
import { type FunctionArtifact, type FunctionArtifactWithContractName, type FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
|
+
import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
8
|
+
import { BlockHeader, PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
9
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
10
|
+
import type { ExecutionDataProvider } from '../execution_data_provider.js';
|
|
11
|
+
import type { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
12
|
+
/**
|
|
13
|
+
* Execute a private function and return the execution result.
|
|
14
|
+
* This does not execute any kernel circuits; only the user functions.
|
|
15
|
+
*
|
|
16
|
+
* If this private function execution results in any nested private function calls,
|
|
17
|
+
* those nested calls are made via oracle calls to the `privateCallPrivateFunction` oracle,
|
|
18
|
+
* which in turn makes corresponding further calls to this function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function executePrivateFunction(simulator: CircuitSimulator, privateExecutionOracle: PrivateExecutionOracle, artifact: FunctionArtifactWithContractName, contractAddress: AztecAddress, functionSelector: FunctionSelector, log?: import("@aztec/foundation/log").Logger): Promise<PrivateCallExecutionResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Get the private circuit public inputs from the partial witness.
|
|
23
|
+
* @param artifact - The function artifact
|
|
24
|
+
* @param partialWitness - The partial witness, result of simulating the function.
|
|
25
|
+
* @returns - The public inputs.
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractPrivateCircuitPublicInputs(artifact: FunctionArtifact, partialWitness: ACVMWitness): PrivateCircuitPublicInputs;
|
|
28
|
+
/**
|
|
29
|
+
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
30
|
+
* from the instance is used.
|
|
31
|
+
* @param contractAddress - The address of the contract to read the class id for.
|
|
32
|
+
* @param instance - The instance of the contract.
|
|
33
|
+
* @param executionDataProvider - The execution data provider.
|
|
34
|
+
* @param blockNumber - The block number at which to load the DelayedPublicMutable storing the class id.
|
|
35
|
+
* @param timestamp - The timestamp at which to obtain the class id from the DelayedPublicMutable.
|
|
36
|
+
* @returns The current class id.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readCurrentClassId(contractAddress: AztecAddress, instance: ContractInstance, executionDataProvider: ExecutionDataProvider | AztecNode, blockNumber: number, timestamp: UInt64): Promise<Fr>;
|
|
39
|
+
/**
|
|
40
|
+
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in the execution data
|
|
41
|
+
* provider (i.e. PXE).
|
|
42
|
+
* @param contractAddress - The address of the contract to verify class id for.
|
|
43
|
+
* @param executionDataProvider - The execution data provider.
|
|
44
|
+
* @param header - The header of the block at which to verify the current class id. If not provided, the anchor block
|
|
45
|
+
* header of the execution data provider is used.
|
|
46
|
+
*/
|
|
47
|
+
export declare function verifyCurrentClassId(contractAddress: AztecAddress, executionDataProvider: ExecutionDataProvider, header?: BlockHeader): Promise<void>;
|
|
48
|
+
//# sourceMappingURL=private_execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_execution.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/oracle/private_execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,EACL,KAAK,WAAW,EAChB,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,qBAAqB,EAAE,qBAAqB,EAC5C,MAAM,CAAC,EAAE,WAAW,iBAiBrB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
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 { ExecutionError, extractCallStack, resolveAssertionMessageFromError, witnessMapToFields } from '@aztec/simulator/client';
|
|
7
|
+
import { countArgumentsSize } from '@aztec/stdlib/abi';
|
|
8
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
9
|
+
import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
10
|
+
import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
11
|
+
import { Oracle } from './oracle.js';
|
|
12
|
+
/**
|
|
13
|
+
* Execute a private function and return the execution result.
|
|
14
|
+
* This does not execute any kernel circuits; only the user functions.
|
|
15
|
+
*
|
|
16
|
+
* If this private function execution results in any nested private function calls,
|
|
17
|
+
* those nested calls are made via oracle calls to the `privateCallPrivateFunction` oracle,
|
|
18
|
+
* which in turn makes corresponding further calls to this function.
|
|
19
|
+
*/ export async function executePrivateFunction(simulator, privateExecutionOracle, artifact, contractAddress, functionSelector, log = createLogger('simulator:private_execution')) {
|
|
20
|
+
const functionName = await privateExecutionOracle.getDebugFunctionName();
|
|
21
|
+
log.verbose(`Executing private function ${functionName}`, {
|
|
22
|
+
contract: contractAddress
|
|
23
|
+
});
|
|
24
|
+
const initialWitness = privateExecutionOracle.getInitialWitness(artifact);
|
|
25
|
+
const acvmCallback = new Oracle(privateExecutionOracle);
|
|
26
|
+
const timer = new Timer();
|
|
27
|
+
const acirExecutionResult = await simulator.executeUserCircuit(initialWitness, artifact, acvmCallback.toACIRCallback()).catch((err)=>{
|
|
28
|
+
err.message = resolveAssertionMessageFromError(err, artifact);
|
|
29
|
+
throw new ExecutionError(err.message, {
|
|
30
|
+
contractAddress,
|
|
31
|
+
functionSelector
|
|
32
|
+
}, extractCallStack(err, artifact.debug), {
|
|
33
|
+
cause: err
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const duration = timer.ms();
|
|
37
|
+
const partialWitness = acirExecutionResult.partialWitness;
|
|
38
|
+
const publicInputs = extractPrivateCircuitPublicInputs(artifact, partialWitness);
|
|
39
|
+
// TODO (alexg) estimate this size
|
|
40
|
+
const initialWitnessSize = witnessMapToFields(initialWitness).length * Fr.SIZE_IN_BYTES;
|
|
41
|
+
log.debug(`Ran external function ${contractAddress.toString()}:${functionSelector}`, {
|
|
42
|
+
circuitName: 'app-circuit',
|
|
43
|
+
duration,
|
|
44
|
+
eventName: 'circuit-witness-generation',
|
|
45
|
+
inputSize: initialWitnessSize,
|
|
46
|
+
outputSize: publicInputs.toBuffer().length,
|
|
47
|
+
appCircuitName: functionName
|
|
48
|
+
});
|
|
49
|
+
const contractClassLogs = privateExecutionOracle.getContractClassLogs();
|
|
50
|
+
const rawReturnValues = await privateExecutionOracle.privateLoadFromExecutionCache(publicInputs.returnsHash);
|
|
51
|
+
const noteHashLeafIndexMap = privateExecutionOracle.getNoteHashLeafIndexMap();
|
|
52
|
+
const newNotes = privateExecutionOracle.getNewNotes();
|
|
53
|
+
const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
|
|
54
|
+
const offchainEffects = privateExecutionOracle.getOffchainEffects();
|
|
55
|
+
const preTags = privateExecutionOracle.getUsedPreTags();
|
|
56
|
+
const nestedExecutionResults = privateExecutionOracle.getNestedExecutionResults();
|
|
57
|
+
let timerSubtractionList = nestedExecutionResults;
|
|
58
|
+
let witgenTime = duration;
|
|
59
|
+
// Due to the recursive nature of execution, we have to subtract the time taken by nested calls
|
|
60
|
+
while(timerSubtractionList.length > 0){
|
|
61
|
+
witgenTime -= timerSubtractionList.reduce((acc, nested)=>acc + (nested.profileResult?.timings.witgen ?? 0), 0);
|
|
62
|
+
timerSubtractionList = timerSubtractionList.flatMap((nested)=>nested.nestedExecutionResults ?? []);
|
|
63
|
+
}
|
|
64
|
+
log.debug(`Returning from call to ${contractAddress.toString()}:${functionSelector}`);
|
|
65
|
+
return new PrivateCallExecutionResult(artifact.bytecode, Buffer.from(artifact.verificationKey, 'base64'), partialWitness, publicInputs, noteHashLeafIndexMap, newNotes, noteHashNullifierCounterMap, rawReturnValues, offchainEffects, preTags, nestedExecutionResults, contractClassLogs, {
|
|
66
|
+
timings: {
|
|
67
|
+
witgen: witgenTime,
|
|
68
|
+
oracles: acirExecutionResult.oracles
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the private circuit public inputs from the partial witness.
|
|
74
|
+
* @param artifact - The function artifact
|
|
75
|
+
* @param partialWitness - The partial witness, result of simulating the function.
|
|
76
|
+
* @returns - The public inputs.
|
|
77
|
+
*/ export function extractPrivateCircuitPublicInputs(artifact, partialWitness) {
|
|
78
|
+
const parametersSize = countArgumentsSize(artifact) + PRIVATE_CONTEXT_INPUTS_LENGTH;
|
|
79
|
+
const returnsSize = PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH;
|
|
80
|
+
const returnData = [];
|
|
81
|
+
// Return values always appear in the witness after arguments.
|
|
82
|
+
for(let i = parametersSize; i < parametersSize + returnsSize; i++){
|
|
83
|
+
const returnedField = partialWitness.get(i);
|
|
84
|
+
if (returnedField === undefined) {
|
|
85
|
+
throw new Error(`Missing return value for index ${i}`);
|
|
86
|
+
}
|
|
87
|
+
returnData.push(Fr.fromString(returnedField));
|
|
88
|
+
}
|
|
89
|
+
return PrivateCircuitPublicInputs.fromFields(returnData);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
93
|
+
* from the instance is used.
|
|
94
|
+
* @param contractAddress - The address of the contract to read the class id for.
|
|
95
|
+
* @param instance - The instance of the contract.
|
|
96
|
+
* @param executionDataProvider - The execution data provider.
|
|
97
|
+
* @param blockNumber - The block number at which to load the DelayedPublicMutable storing the class id.
|
|
98
|
+
* @param timestamp - The timestamp at which to obtain the class id from the DelayedPublicMutable.
|
|
99
|
+
* @returns The current class id.
|
|
100
|
+
*/ export async function readCurrentClassId(contractAddress, instance, executionDataProvider, blockNumber, timestamp) {
|
|
101
|
+
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
102
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, (slot)=>executionDataProvider.getPublicStorageAt(blockNumber, ProtocolContractAddress.ContractInstanceRegistry, slot));
|
|
103
|
+
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
104
|
+
if (currentClassId.isZero()) {
|
|
105
|
+
currentClassId = instance.originalContractClassId;
|
|
106
|
+
}
|
|
107
|
+
return currentClassId;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in the execution data
|
|
111
|
+
* provider (i.e. PXE).
|
|
112
|
+
* @param contractAddress - The address of the contract to verify class id for.
|
|
113
|
+
* @param executionDataProvider - The execution data provider.
|
|
114
|
+
* @param header - The header of the block at which to verify the current class id. If not provided, the anchor block
|
|
115
|
+
* header of the execution data provider is used.
|
|
116
|
+
*/ export async function verifyCurrentClassId(contractAddress, executionDataProvider, header) {
|
|
117
|
+
header = header ?? await executionDataProvider.getAnchorBlockHeader();
|
|
118
|
+
const instance = await executionDataProvider.getContractInstance(contractAddress);
|
|
119
|
+
const currentClassId = await readCurrentClassId(contractAddress, instance, executionDataProvider, header.globalVariables.blockNumber, header.globalVariables.timestamp);
|
|
120
|
+
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
121
|
+
throw new Error(`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`);
|
|
122
|
+
}
|
|
123
|
+
}
|