@aztec/pxe 0.0.1-commit.fffb133c → 0.0.1-dev
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/dest/bin/check_oracle_version.js +5 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts +10 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +30 -6
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -31
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +214 -75
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -6
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -10
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +66 -47
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +78 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +363 -114
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +56 -86
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +123 -98
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +145 -70
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +435 -145
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +45 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +150 -0
- package/dest/contract_sync/helpers.d.ts +27 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +16 -17
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -18
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +24 -9
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +25 -10
- package/dest/entrypoints/pxe_creation_options.d.ts +8 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- 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 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +31 -11
- package/dest/events/event_service.d.ts +16 -8
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +46 -14
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/hooks/authorize_utility_call.d.ts +37 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +42 -0
- package/dest/hooks/execution_hooks.d.ts.map +1 -0
- package/dest/hooks/execution_hooks.js +9 -0
- package/dest/hooks/index.d.ts +4 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +1 -0
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +10 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +50 -85
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +38 -0
- package/dest/notes/note_service.d.ts +29 -8
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +89 -65
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +4 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +38 -19
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +26 -20
- package/dest/pxe.d.ts +87 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +178 -119
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +9 -2
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +588 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +42 -36
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +160 -73
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +13 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +147 -107
- package/dest/storage/open_pxe_stores.d.ts +31 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +26 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +87 -61
- package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
- package/dest/storage/private_event_store/stored_private_event.js +2 -2
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
- package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +20 -3
- package/dest/tagging/index.d.ts +6 -5
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +4 -3
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +158 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -9
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +30 -13
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +41 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +26 -16
- package/src/bin/check_oracle_version.ts +5 -5
- package/src/block_synchronizer/block_synchronizer.ts +45 -21
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +389 -134
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +101 -62
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +464 -151
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +152 -191
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +709 -200
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +208 -0
- package/src/contract_sync/{index.ts → helpers.ts} +17 -29
- package/src/debug/pxe_debug_utils.ts +63 -19
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +19 -18
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +20 -18
- package/src/entrypoints/pxe_creation_options.ts +13 -1
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +25 -29
- package/src/events/event_service.ts +70 -24
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +40 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +88 -141
- package/src/messages/message_context_service.ts +45 -0
- package/src/notes/note_service.ts +124 -91
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +53 -22
- package/src/private_kernel/private_kernel_oracle.ts +36 -26
- package/src/pxe.ts +351 -168
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +42 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +707 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +52 -34
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +193 -81
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +166 -132
- package/src/storage/open_pxe_stores.ts +47 -0
- package/src/storage/private_event_store/private_event_store.ts +106 -81
- package/src/storage/private_event_store/stored_private_event.ts +3 -3
- package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
- package/src/tagging/get_all_logs_by_tags.ts +35 -7
- package/src/tagging/index.ts +5 -4
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +236 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +54 -18
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -14
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +30 -29
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -15
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -32
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { ARCHIVE_HEIGHT, MAX_CONTRACT_CLASS_LOGS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
|
|
1
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
2
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
6
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
7
|
import { arrayOfArraysToBoundedVecOfArrays, bufferToBoundedVec, fromUintArray, fromUintBoundedVec, toACVMField } from '@aztec/simulator/client';
|
|
5
8
|
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
9
|
+
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
6
10
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import {
|
|
8
|
-
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
11
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
12
|
+
import { ContractClassLog, ContractClassLogFields, FlatPublicLogs, PrivateLog } from '@aztec/stdlib/logs';
|
|
13
|
+
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
14
|
+
import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
|
|
15
|
+
import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
|
|
9
16
|
import { packAsHintedNote } from './note_packing_utils.js';
|
|
10
17
|
export class UnavailableOracleError extends Error {
|
|
11
18
|
constructor(oracleName){
|
|
@@ -14,6 +21,25 @@ export class UnavailableOracleError extends Error {
|
|
|
14
21
|
}
|
|
15
22
|
/**
|
|
16
23
|
* A data source that has all the apis required by Aztec.nr.
|
|
24
|
+
*
|
|
25
|
+
* ## Oracle naming conventions
|
|
26
|
+
*
|
|
27
|
+
* We try to keep oracle naming consistent, please see below the conventions we adhere to.
|
|
28
|
+
*
|
|
29
|
+
* Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
|
|
30
|
+
*
|
|
31
|
+
* - **Scope prefix** indicates the execution context required:
|
|
32
|
+
* - `aztec_prv_` — available only during private function execution.
|
|
33
|
+
* - `aztec_utl_` — available during both utility and private execution.
|
|
34
|
+
*
|
|
35
|
+
* - **Verb** signals the operation's semantics (verb-first, then object):
|
|
36
|
+
* - `get` — read / lookup / get data from oracle into contract.
|
|
37
|
+
* - `does`/`is`/`has` — predicate (returns boolean).
|
|
38
|
+
* - `emit`/`notify` — propagate data from contract to oracle.
|
|
39
|
+
* - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
|
|
40
|
+
* - `call` — trigger nested execution (control flow).
|
|
41
|
+
* - `assert` — validate a condition, throw on failure.
|
|
42
|
+
* - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
|
|
17
43
|
*/ export class Oracle {
|
|
18
44
|
handler;
|
|
19
45
|
constructor(handler){
|
|
@@ -48,11 +74,11 @@ export class UnavailableOracleError extends Error {
|
|
|
48
74
|
];
|
|
49
75
|
// Get all the oracle function names
|
|
50
76
|
const oracleNames = Object.getOwnPropertyNames(Oracle.prototype).filter((name)=>!excludedProps.includes(name));
|
|
51
|
-
// Validate oracle names - these must be prefixed with either "
|
|
77
|
+
// Validate oracle names - these must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate their scope
|
|
52
78
|
// and must correspond to a function on the Oracle class.
|
|
53
79
|
oracleNames.forEach((name)=>{
|
|
54
|
-
if (!name.startsWith('
|
|
55
|
-
throw new Error(`Oracle function "${name}" must be prefixed with either "
|
|
80
|
+
if (!name.startsWith('aztec_prv_') && !name.startsWith('aztec_utl_')) {
|
|
81
|
+
throw new Error(`Oracle function "${name}" must be prefixed with either "aztec_prv_" or "aztec_utl_" to indicate its scope`);
|
|
56
82
|
}
|
|
57
83
|
const method = this[name];
|
|
58
84
|
if (typeof method !== 'function') {
|
|
@@ -60,42 +86,78 @@ export class UnavailableOracleError extends Error {
|
|
|
60
86
|
}
|
|
61
87
|
});
|
|
62
88
|
// Build callback object and return it
|
|
63
|
-
|
|
89
|
+
const callback = oracleNames.reduce((acc, name)=>{
|
|
64
90
|
const method = this[name];
|
|
65
91
|
acc[name] = method.bind(this);
|
|
66
92
|
return acc;
|
|
67
93
|
}, {});
|
|
94
|
+
const allCallbacks = {
|
|
95
|
+
...callback,
|
|
96
|
+
...buildLegacyOracleCallbacks(this)
|
|
97
|
+
};
|
|
98
|
+
// Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
|
|
99
|
+
// contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
|
|
100
|
+
// minor version).
|
|
101
|
+
const handler = this.handler;
|
|
102
|
+
return new Proxy(allCallbacks, {
|
|
103
|
+
get (target, prop) {
|
|
104
|
+
if (prop in target) {
|
|
105
|
+
return target[prop];
|
|
106
|
+
}
|
|
107
|
+
// Return a function that throws with an enhanced error message if applicable
|
|
108
|
+
return ()=>{
|
|
109
|
+
let contractVersion = undefined;
|
|
110
|
+
if ('nonOracleFunctionGetContractOracleVersion' in handler) {
|
|
111
|
+
contractVersion = handler.nonOracleFunctionGetContractOracleVersion();
|
|
112
|
+
}
|
|
113
|
+
if (!contractVersion) {
|
|
114
|
+
throw new Error(`Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` + `was not called before '${prop}'). This usually means the contract was not compiled with the ` + `#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` + `external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` + `is called before any other oracle calls. See https://docs.aztec.network/errors/8`);
|
|
115
|
+
} else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
|
|
116
|
+
throw new Error(`Oracle '${prop}' not found.` + ` This usually means the contract requires a newer private execution environment than you have.` + ` Upgrade your private execution environment to a compatible version. The contract was compiled with` + ` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` + ` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` + ` See https://docs.aztec.network/errors/8`);
|
|
117
|
+
} else {
|
|
118
|
+
throw new Error(`Oracle '${prop}' not found.` + ` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` + ` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` + ` standard oracles should be available. This could mean the contract was compiled against a modified` + ` version of Aztec.nr, or that it references an oracle that does not exist.` + ` See https://docs.aztec.network/errors/8`);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
});
|
|
68
123
|
}
|
|
69
|
-
|
|
70
|
-
|
|
124
|
+
// eslint-disable-next-line camelcase
|
|
125
|
+
aztec_utl_assertCompatibleOracleVersionV2([major], [minor]) {
|
|
126
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(Fr.fromString(major).toNumber(), Fr.fromString(minor).toNumber());
|
|
71
127
|
return Promise.resolve([]);
|
|
72
128
|
}
|
|
73
|
-
|
|
74
|
-
|
|
129
|
+
// eslint-disable-next-line camelcase
|
|
130
|
+
aztec_utl_getRandomField() {
|
|
131
|
+
const val = this.handlerAsMisc().getRandomField();
|
|
75
132
|
return Promise.resolve([
|
|
76
133
|
toACVMField(val)
|
|
77
134
|
]);
|
|
78
135
|
}
|
|
79
|
-
|
|
80
|
-
|
|
136
|
+
// eslint-disable-next-line camelcase
|
|
137
|
+
aztec_prv_setHashPreimage(values, [hash]) {
|
|
138
|
+
this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
|
|
81
139
|
return Promise.resolve([]);
|
|
82
140
|
}
|
|
83
|
-
|
|
84
|
-
|
|
141
|
+
// eslint-disable-next-line camelcase
|
|
142
|
+
async aztec_prv_getHashPreimage([returnsHash]) {
|
|
143
|
+
const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
|
|
85
144
|
return [
|
|
86
145
|
values.map(toACVMField)
|
|
87
146
|
];
|
|
88
147
|
}
|
|
89
|
-
|
|
90
|
-
|
|
148
|
+
// eslint-disable-next-line camelcase
|
|
149
|
+
aztec_utl_getUtilityContext() {
|
|
150
|
+
const context = this.handlerAsUtility().getUtilityContext();
|
|
91
151
|
return Promise.resolve(context.toNoirRepresentation());
|
|
92
152
|
}
|
|
93
|
-
|
|
94
|
-
|
|
153
|
+
// eslint-disable-next-line camelcase
|
|
154
|
+
async aztec_utl_getKeyValidationRequest([pkMHash]) {
|
|
155
|
+
const keyValidationRequest = await this.handlerAsUtility().getKeyValidationRequest(Fr.fromString(pkMHash));
|
|
95
156
|
return keyValidationRequest.toFields().map(toACVMField);
|
|
96
157
|
}
|
|
97
|
-
|
|
98
|
-
|
|
158
|
+
// eslint-disable-next-line camelcase
|
|
159
|
+
async aztec_utl_getContractInstance([address]) {
|
|
160
|
+
const instance = await this.handlerAsUtility().getContractInstance(AztecAddress.fromField(Fr.fromString(address)));
|
|
99
161
|
return [
|
|
100
162
|
instance.salt,
|
|
101
163
|
instance.deployer,
|
|
@@ -104,62 +166,82 @@ export class UnavailableOracleError extends Error {
|
|
|
104
166
|
...instance.publicKeys.toFields()
|
|
105
167
|
].map(toACVMField);
|
|
106
168
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
const
|
|
169
|
+
// eslint-disable-next-line camelcase
|
|
170
|
+
async aztec_utl_getNoteHashMembershipWitness([anchorBlockHash], [noteHash]) {
|
|
171
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
172
|
+
const parsedNoteHash = Fr.fromString(noteHash);
|
|
173
|
+
const witness = await this.handlerAsUtility().getNoteHashMembershipWitness(parsedAnchorBlockHash, parsedNoteHash);
|
|
111
174
|
if (!witness) {
|
|
112
|
-
throw new Error(`
|
|
175
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at anchor block hash ${parsedAnchorBlockHash.toString()}.`);
|
|
113
176
|
}
|
|
114
177
|
return witness.toNoirRepresentation();
|
|
115
178
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
179
|
+
// TODO(https://linear.app/aztec-labs/issue/F-651): drop this
|
|
180
|
+
// eslint-disable-next-line camelcase
|
|
181
|
+
async aztec_utl_getBlockHashMembershipWitness([anchorBlockHash], [blockHash]) {
|
|
182
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
183
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
184
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
120
185
|
if (!witness) {
|
|
121
|
-
throw new Error(`
|
|
186
|
+
throw new Error(`Block hash ${parsedBlockHash.toString()} not found in the archive tree at anchor block ${parsedAnchorBlockHash.toString()}.`);
|
|
122
187
|
}
|
|
123
188
|
return witness.toNoirRepresentation();
|
|
124
189
|
}
|
|
125
|
-
|
|
126
|
-
|
|
190
|
+
// TODO(https://linear.app/aztec-labs/issue/F-651): rename to aztec_utl_getBlockHashMembershipWitness
|
|
191
|
+
// eslint-disable-next-line camelcase
|
|
192
|
+
async aztec_utl_getBlockHashMembershipWitnessV2([anchorBlockHash], [blockHash]) {
|
|
193
|
+
const parsedAnchorBlockHash = BlockHash.fromString(anchorBlockHash);
|
|
194
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
195
|
+
const witness = await this.handlerAsUtility().getBlockHashMembershipWitness(parsedAnchorBlockHash, parsedBlockHash);
|
|
196
|
+
const effective = witness ?? MembershipWitness.empty(ARCHIVE_HEIGHT);
|
|
197
|
+
return [
|
|
198
|
+
toACVMField(witness !== undefined ? 1 : 0),
|
|
199
|
+
...effective.toNoirRepresentation()
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
// eslint-disable-next-line camelcase
|
|
203
|
+
async aztec_utl_getNullifierMembershipWitness([blockHash], [nullifier]) {
|
|
204
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
127
205
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
128
|
-
const witness = await this.handlerAsUtility().
|
|
206
|
+
const witness = await this.handlerAsUtility().getNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
129
207
|
if (!witness) {
|
|
130
208
|
throw new Error(`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
|
|
131
209
|
}
|
|
132
210
|
return witness.toNoirRepresentation();
|
|
133
211
|
}
|
|
134
|
-
|
|
135
|
-
|
|
212
|
+
// eslint-disable-next-line camelcase
|
|
213
|
+
async aztec_utl_getLowNullifierMembershipWitness([blockHash], [nullifier]) {
|
|
214
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
136
215
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
137
|
-
const witness = await this.handlerAsUtility().
|
|
216
|
+
const witness = await this.handlerAsUtility().getLowNullifierMembershipWitness(parsedBlockHash, parsedNullifier);
|
|
138
217
|
if (!witness) {
|
|
139
218
|
throw new Error(`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`);
|
|
140
219
|
}
|
|
141
220
|
return witness.toNoirRepresentation();
|
|
142
221
|
}
|
|
143
|
-
|
|
144
|
-
|
|
222
|
+
// eslint-disable-next-line camelcase
|
|
223
|
+
async aztec_utl_getPublicDataWitness([blockHash], [leafSlot]) {
|
|
224
|
+
const parsedBlockHash = BlockHash.fromString(blockHash);
|
|
145
225
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
146
|
-
const witness = await this.handlerAsUtility().
|
|
226
|
+
const witness = await this.handlerAsUtility().getPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
147
227
|
if (!witness) {
|
|
148
228
|
throw new Error(`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`);
|
|
149
229
|
}
|
|
150
230
|
return witness.toNoirRepresentation();
|
|
151
231
|
}
|
|
152
|
-
|
|
232
|
+
// eslint-disable-next-line camelcase
|
|
233
|
+
async aztec_utl_getBlockHeader([blockNumber]) {
|
|
153
234
|
const parsedBlockNumber = Fr.fromString(blockNumber).toNumber();
|
|
154
|
-
const header = await this.handlerAsUtility().
|
|
235
|
+
const header = await this.handlerAsUtility().getBlockHeader(BlockNumber(parsedBlockNumber));
|
|
155
236
|
if (!header) {
|
|
156
237
|
throw new Error(`Block header not found for block ${parsedBlockNumber}.`);
|
|
157
238
|
}
|
|
158
239
|
return header.toFields().map(toACVMField);
|
|
159
240
|
}
|
|
160
|
-
|
|
241
|
+
// eslint-disable-next-line camelcase
|
|
242
|
+
async aztec_utl_getAuthWitness([messageHash]) {
|
|
161
243
|
const messageHashField = Fr.fromString(messageHash);
|
|
162
|
-
const witness = await this.handlerAsUtility().
|
|
244
|
+
const witness = await this.handlerAsUtility().getAuthWitness(messageHashField);
|
|
163
245
|
if (!witness) {
|
|
164
246
|
throw new Error(`Unknown auth witness for message hash ${messageHashField}`);
|
|
165
247
|
}
|
|
@@ -167,20 +249,34 @@ export class UnavailableOracleError extends Error {
|
|
|
167
249
|
witness.map(toACVMField)
|
|
168
250
|
];
|
|
169
251
|
}
|
|
170
|
-
|
|
252
|
+
// eslint-disable-next-line camelcase
|
|
253
|
+
async aztec_utl_getPublicKeysAndPartialAddress([address]) {
|
|
171
254
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
172
|
-
const
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
255
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
256
|
+
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
257
|
+
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
258
|
+
if (result === undefined) {
|
|
259
|
+
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
260
|
+
return [
|
|
261
|
+
toACVMField(0),
|
|
262
|
+
Array(13).fill(toACVMField(0))
|
|
263
|
+
];
|
|
264
|
+
} else {
|
|
265
|
+
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
266
|
+
return [
|
|
267
|
+
toACVMField(1),
|
|
268
|
+
[
|
|
269
|
+
...result.publicKeys.toFields(),
|
|
270
|
+
result.partialAddress
|
|
271
|
+
].map(toACVMField)
|
|
272
|
+
];
|
|
273
|
+
}
|
|
179
274
|
}
|
|
180
|
-
|
|
275
|
+
// eslint-disable-next-line camelcase
|
|
276
|
+
async aztec_utl_getNotes([ownerSome], [ownerValue], [storageSlot], [numSelects], selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, [limit], [offset], [status], [maxNotes], [packedHintedNoteLength]) {
|
|
181
277
|
// Parse Option<AztecAddress>: ownerSome is 0 for None, 1 for Some
|
|
182
278
|
const owner = Fr.fromString(ownerSome).toNumber() === 1 ? AztecAddress.fromString(ownerValue) : undefined;
|
|
183
|
-
const noteDatas = await this.handlerAsUtility().
|
|
279
|
+
const noteDatas = await this.handlerAsUtility().getNotes(owner, 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);
|
|
184
280
|
const returnDataAsArrayOfPackedHintedNotes = noteDatas.map((noteData)=>packAsHintedNote({
|
|
185
281
|
contractAddress: noteData.contractAddress,
|
|
186
282
|
owner: noteData.owner,
|
|
@@ -195,57 +291,74 @@ export class UnavailableOracleError extends Error {
|
|
|
195
291
|
// At last we convert the array of arrays to a bounded vec of arrays
|
|
196
292
|
return arrayOfArraysToBoundedVecOfArrays(returnDataAsArrayOfACVMFieldArrays, +maxNotes, +packedHintedNoteLength);
|
|
197
293
|
}
|
|
198
|
-
|
|
199
|
-
|
|
294
|
+
// eslint-disable-next-line camelcase
|
|
295
|
+
aztec_prv_notifyCreatedNote([owner], [storageSlot], [randomness], [noteTypeId], note, [noteHash], [counter]) {
|
|
296
|
+
this.handlerAsPrivate().notifyCreatedNote(AztecAddress.fromString(owner), Fr.fromString(storageSlot), Fr.fromString(randomness), NoteSelector.fromField(Fr.fromString(noteTypeId)), note.map(Fr.fromString), Fr.fromString(noteHash), +counter);
|
|
200
297
|
return Promise.resolve([]);
|
|
201
298
|
}
|
|
202
|
-
|
|
203
|
-
|
|
299
|
+
// eslint-disable-next-line camelcase
|
|
300
|
+
async aztec_prv_notifyNullifiedNote([innerNullifier], [noteHash], [counter]) {
|
|
301
|
+
await this.handlerAsPrivate().notifyNullifiedNote(Fr.fromString(innerNullifier), Fr.fromString(noteHash), +counter);
|
|
204
302
|
return [];
|
|
205
303
|
}
|
|
206
|
-
|
|
207
|
-
|
|
304
|
+
// eslint-disable-next-line camelcase
|
|
305
|
+
async aztec_prv_notifyCreatedNullifier([innerNullifier]) {
|
|
306
|
+
await this.handlerAsPrivate().notifyCreatedNullifier(Fr.fromString(innerNullifier));
|
|
208
307
|
return [];
|
|
209
308
|
}
|
|
210
|
-
|
|
211
|
-
|
|
309
|
+
// eslint-disable-next-line camelcase
|
|
310
|
+
async aztec_prv_isNullifierPending([innerNullifier], [contractAddress]) {
|
|
311
|
+
const isPending = await this.handlerAsPrivate().isNullifierPending(Fr.fromString(innerNullifier), AztecAddress.fromString(contractAddress));
|
|
212
312
|
return [
|
|
213
313
|
toACVMField(isPending)
|
|
214
314
|
];
|
|
215
315
|
}
|
|
216
|
-
|
|
217
|
-
|
|
316
|
+
// eslint-disable-next-line camelcase
|
|
317
|
+
async aztec_utl_doesNullifierExist([innerNullifier]) {
|
|
318
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
|
|
218
319
|
return [
|
|
219
320
|
toACVMField(exists)
|
|
220
321
|
];
|
|
221
322
|
}
|
|
222
|
-
|
|
223
|
-
|
|
323
|
+
// eslint-disable-next-line camelcase
|
|
324
|
+
async aztec_utl_getL1ToL2MembershipWitness([contractAddress], [messageHash], [secret]) {
|
|
325
|
+
const message = await this.handlerAsUtility().getL1ToL2MembershipWitness(AztecAddress.fromString(contractAddress), Fr.fromString(messageHash), Fr.fromString(secret));
|
|
224
326
|
return message.toNoirRepresentation();
|
|
225
327
|
}
|
|
226
|
-
|
|
227
|
-
|
|
328
|
+
// eslint-disable-next-line camelcase
|
|
329
|
+
async aztec_utl_getFromPublicStorage([blockHash], [contractAddress], [startStorageSlot], [numberOfElements]) {
|
|
330
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(BlockHash.fromString(blockHash), new AztecAddress(Fr.fromString(contractAddress)), Fr.fromString(startStorageSlot), +numberOfElements);
|
|
228
331
|
return [
|
|
229
332
|
values.map(toACVMField)
|
|
230
333
|
];
|
|
231
334
|
}
|
|
232
|
-
|
|
335
|
+
// eslint-disable-next-line camelcase
|
|
336
|
+
async aztec_utl_callUtilityFunction([contractAddress], [functionSelector], args) {
|
|
337
|
+
const result = await this.handlerAsUtility().callUtilityFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), args.map(Fr.fromString));
|
|
338
|
+
return [
|
|
339
|
+
result.map(toACVMField)
|
|
340
|
+
];
|
|
341
|
+
}
|
|
342
|
+
// eslint-disable-next-line camelcase
|
|
343
|
+
aztec_prv_notifyCreatedContractClassLog([contractAddress], message, [length], [counter]) {
|
|
233
344
|
const logFields = new ContractClassLogFields(message.map(Fr.fromString));
|
|
234
345
|
const log = new ContractClassLog(new AztecAddress(Fr.fromString(contractAddress)), logFields, +length);
|
|
235
|
-
this.handlerAsPrivate().
|
|
346
|
+
this.handlerAsPrivate().notifyCreatedContractClassLog(log, +counter);
|
|
236
347
|
return Promise.resolve([]);
|
|
237
348
|
}
|
|
238
|
-
|
|
349
|
+
// eslint-disable-next-line camelcase
|
|
350
|
+
async aztec_utl_log(level, message, _ignoredFieldsSize, fields) {
|
|
239
351
|
const levelFr = Fr.fromString(level[0]);
|
|
240
352
|
const messageStr = message.map((acvmField)=>String.fromCharCode(Fr.fromString(acvmField).toNumber())).join('');
|
|
241
353
|
const fieldsFr = fields.map(Fr.fromString);
|
|
242
|
-
this.handlerAsMisc().
|
|
243
|
-
return
|
|
354
|
+
await this.handlerAsMisc().log(levelFr.toNumber(), messageStr, fieldsFr);
|
|
355
|
+
return [];
|
|
244
356
|
}
|
|
245
357
|
// This function's name is directly hardcoded in `circuit_recorder.ts`. Don't forget to update it there if you
|
|
246
358
|
// change the name here.
|
|
247
|
-
|
|
248
|
-
|
|
359
|
+
// eslint-disable-next-line camelcase
|
|
360
|
+
async aztec_prv_callPrivateFunction([contractAddress], [functionSelector], [argsHash], [sideEffectCounter], [isStaticCall]) {
|
|
361
|
+
const { endSideEffectCounter, returnsHash } = await this.handlerAsPrivate().callPrivateFunction(AztecAddress.fromField(Fr.fromString(contractAddress)), FunctionSelector.fromField(Fr.fromString(functionSelector)), Fr.fromString(argsHash), Fr.fromString(sideEffectCounter).toNumber(), Fr.fromString(isStaticCall).toBool());
|
|
249
362
|
return [
|
|
250
363
|
[
|
|
251
364
|
endSideEffectCounter,
|
|
@@ -253,48 +366,111 @@ export class UnavailableOracleError extends Error {
|
|
|
253
366
|
].map(toACVMField)
|
|
254
367
|
];
|
|
255
368
|
}
|
|
256
|
-
|
|
257
|
-
|
|
369
|
+
// eslint-disable-next-line camelcase
|
|
370
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]) {
|
|
371
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
258
372
|
return [];
|
|
259
373
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
async privateNotifySetMinRevertibleSideEffectCounter([minRevertibleSideEffectCounter]) {
|
|
265
|
-
await this.handlerAsPrivate().privateNotifySetMinRevertibleSideEffectCounter(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
374
|
+
// eslint-disable-next-line camelcase
|
|
375
|
+
async aztec_prv_notifyRevertiblePhaseStart([minRevertibleSideEffectCounter]) {
|
|
376
|
+
await this.handlerAsPrivate().notifyRevertiblePhaseStart(Fr.fromString(minRevertibleSideEffectCounter).toNumber());
|
|
266
377
|
return Promise.resolve([]);
|
|
267
378
|
}
|
|
268
|
-
|
|
269
|
-
|
|
379
|
+
// eslint-disable-next-line camelcase
|
|
380
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]) {
|
|
381
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(Fr.fromString(sideEffectCounter).toNumber());
|
|
270
382
|
return Promise.resolve([
|
|
271
383
|
toACVMField(isRevertible)
|
|
272
384
|
]);
|
|
273
385
|
}
|
|
274
|
-
|
|
275
|
-
|
|
386
|
+
// eslint-disable-next-line camelcase
|
|
387
|
+
async aztec_prv_getNextAppTagAsSender([sender], [recipient]) {
|
|
388
|
+
const tag = await this.handlerAsPrivate().getNextAppTagAsSender(AztecAddress.fromString(sender), AztecAddress.fromString(recipient));
|
|
276
389
|
return [
|
|
277
390
|
toACVMField(tag.value)
|
|
278
391
|
];
|
|
279
392
|
}
|
|
280
|
-
|
|
281
|
-
|
|
393
|
+
// eslint-disable-next-line camelcase
|
|
394
|
+
async aztec_utl_getPendingTaggedLogs([pendingTaggedLogArrayBaseSlot], [scope]) {
|
|
395
|
+
await this.handlerAsUtility().getPendingTaggedLogs(Fr.fromString(pendingTaggedLogArrayBaseSlot), AztecAddress.fromString(scope));
|
|
282
396
|
return [];
|
|
283
397
|
}
|
|
284
|
-
|
|
285
|
-
|
|
398
|
+
// eslint-disable-next-line camelcase
|
|
399
|
+
async aztec_utl_getPendingTaggedLogs_v2([scope]) {
|
|
400
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
|
|
401
|
+
return [
|
|
402
|
+
toACVMField(slot)
|
|
403
|
+
];
|
|
404
|
+
}
|
|
405
|
+
// eslint-disable-next-line camelcase
|
|
406
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents([contractAddress], [noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
|
|
407
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(AztecAddress.fromString(contractAddress), Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
|
|
286
408
|
return [];
|
|
287
409
|
}
|
|
288
|
-
|
|
289
|
-
|
|
410
|
+
// eslint-disable-next-line camelcase
|
|
411
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2([noteValidationRequestsArrayBaseSlot], [eventValidationRequestsArrayBaseSlot], [maxNotePackedLen], [maxEventSerializedLen], [scope]) {
|
|
412
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(Fr.fromString(noteValidationRequestsArrayBaseSlot), Fr.fromString(eventValidationRequestsArrayBaseSlot), Fr.fromString(maxNotePackedLen).toNumber(), Fr.fromString(maxEventSerializedLen).toNumber(), AztecAddress.fromString(scope));
|
|
290
413
|
return [];
|
|
291
414
|
}
|
|
292
|
-
|
|
293
|
-
|
|
415
|
+
// eslint-disable-next-line camelcase
|
|
416
|
+
async aztec_utl_getLogsByTag([contractAddress], [logRetrievalRequestsArrayBaseSlot], [logRetrievalResponsesArrayBaseSlot], [scope]) {
|
|
417
|
+
await this.handlerAsUtility().getLogsByTag(AztecAddress.fromString(contractAddress), Fr.fromString(logRetrievalRequestsArrayBaseSlot), Fr.fromString(logRetrievalResponsesArrayBaseSlot), AztecAddress.fromString(scope));
|
|
294
418
|
return [];
|
|
295
419
|
}
|
|
296
|
-
|
|
297
|
-
|
|
420
|
+
// eslint-disable-next-line camelcase
|
|
421
|
+
async aztec_utl_getMessageContextsByTxHash([contractAddress], [messageContextRequestsArrayBaseSlot], [messageContextResponsesArrayBaseSlot], [scope]) {
|
|
422
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(AztecAddress.fromString(contractAddress), Fr.fromString(messageContextRequestsArrayBaseSlot), Fr.fromString(messageContextResponsesArrayBaseSlot), AztecAddress.fromString(scope));
|
|
423
|
+
return [];
|
|
424
|
+
}
|
|
425
|
+
// eslint-disable-next-line camelcase
|
|
426
|
+
async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]) {
|
|
427
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
|
|
428
|
+
return [
|
|
429
|
+
toACVMField(responseSlot)
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
// eslint-disable-next-line camelcase
|
|
433
|
+
async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]) {
|
|
434
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(Fr.fromString(requestArrayBaseSlot));
|
|
435
|
+
return [
|
|
436
|
+
toACVMField(responseSlot)
|
|
437
|
+
];
|
|
438
|
+
}
|
|
439
|
+
// eslint-disable-next-line camelcase
|
|
440
|
+
async aztec_utl_getTxEffect([txHash]) {
|
|
441
|
+
const txEffect = await this.handlerAsUtility().getTxEffect(TxHash.fromField(Fr.fromString(txHash)));
|
|
442
|
+
// The Noir oracle returns `Option<TxEffect>`. ACVM expands this into 12 destination slots: the Option discriminant
|
|
443
|
+
// followed by the 11 leaf slots of `TxEffect` (each scalar is one slot, each top-level array is one slot, and
|
|
444
|
+
// the nested `PublicLogs { length, payload }` splits into two slots).
|
|
445
|
+
const effect = txEffect ?? TxEffect.empty();
|
|
446
|
+
const flatPublicLogs = FlatPublicLogs.fromLogs(effect.publicLogs);
|
|
447
|
+
return [
|
|
448
|
+
toACVMField(txEffect === null ? 0 : 1),
|
|
449
|
+
toACVMField(effect.revertCode.toField()),
|
|
450
|
+
toACVMField(effect.txHash.hash),
|
|
451
|
+
toACVMField(effect.transactionFee),
|
|
452
|
+
padArrayEnd(effect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX).map(toACVMField),
|
|
453
|
+
padArrayEnd(effect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(toACVMField),
|
|
454
|
+
padArrayEnd(effect.l2ToL1Msgs, Fr.ZERO, MAX_L2_TO_L1_MSGS_PER_TX).map(toACVMField),
|
|
455
|
+
padArrayEnd(effect.publicDataWrites, PublicDataWrite.empty(), MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX).flatMap((w)=>w.toFields()).map(toACVMField),
|
|
456
|
+
padArrayEnd(effect.privateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX).flatMap((l)=>l.toFields()).map(toACVMField),
|
|
457
|
+
toACVMField(flatPublicLogs.length),
|
|
458
|
+
flatPublicLogs.payload.map(toACVMField),
|
|
459
|
+
padArrayEnd(effect.contractClassLogs, ContractClassLog.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX).flatMap((l)=>[
|
|
460
|
+
...l.fields.toFields(),
|
|
461
|
+
new Fr(l.emittedLength),
|
|
462
|
+
l.contractAddress.toField()
|
|
463
|
+
]).map(toACVMField)
|
|
464
|
+
];
|
|
465
|
+
}
|
|
466
|
+
// eslint-disable-next-line camelcase
|
|
467
|
+
aztec_utl_setCapsule([contractAddress], [slot], capsule, [scope]) {
|
|
468
|
+
this.handlerAsUtility().setCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), capsule.map(Fr.fromString), AztecAddress.fromField(Fr.fromString(scope)));
|
|
469
|
+
return Promise.resolve([]);
|
|
470
|
+
}
|
|
471
|
+
// eslint-disable-next-line camelcase
|
|
472
|
+
async aztec_utl_getCapsule([contractAddress], [slot], [tSize], [scope]) {
|
|
473
|
+
const values = await this.handlerAsUtility().getCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
|
|
298
474
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
299
475
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
300
476
|
if (values === null) {
|
|
@@ -311,35 +487,107 @@ export class UnavailableOracleError extends Error {
|
|
|
311
487
|
];
|
|
312
488
|
}
|
|
313
489
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
490
|
+
// eslint-disable-next-line camelcase
|
|
491
|
+
aztec_utl_deleteCapsule([contractAddress], [slot], [scope]) {
|
|
492
|
+
this.handlerAsUtility().deleteCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(slot), AztecAddress.fromField(Fr.fromString(scope)));
|
|
493
|
+
return Promise.resolve([]);
|
|
317
494
|
}
|
|
318
|
-
|
|
319
|
-
|
|
495
|
+
// eslint-disable-next-line camelcase
|
|
496
|
+
async aztec_utl_copyCapsule([contractAddress], [srcSlot], [dstSlot], [numEntries], [scope]) {
|
|
497
|
+
await this.handlerAsUtility().copyCapsule(AztecAddress.fromField(Fr.fromString(contractAddress)), Fr.fromString(srcSlot), Fr.fromString(dstSlot), Fr.fromString(numEntries).toNumber(), AztecAddress.fromField(Fr.fromString(scope)));
|
|
320
498
|
return [];
|
|
321
499
|
}
|
|
322
|
-
|
|
500
|
+
// eslint-disable-next-line camelcase
|
|
501
|
+
aztec_utl_pushEphemeral([slot], elements) {
|
|
502
|
+
const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
|
|
503
|
+
return Promise.resolve([
|
|
504
|
+
toACVMField(newLen)
|
|
505
|
+
]);
|
|
506
|
+
}
|
|
507
|
+
// eslint-disable-next-line camelcase
|
|
508
|
+
aztec_utl_popEphemeral([slot]) {
|
|
509
|
+
const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
|
|
510
|
+
return Promise.resolve([
|
|
511
|
+
element.map(toACVMField)
|
|
512
|
+
]);
|
|
513
|
+
}
|
|
514
|
+
// eslint-disable-next-line camelcase
|
|
515
|
+
aztec_utl_getEphemeral([slot], [index]) {
|
|
516
|
+
const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
517
|
+
return Promise.resolve([
|
|
518
|
+
element.map(toACVMField)
|
|
519
|
+
]);
|
|
520
|
+
}
|
|
521
|
+
// eslint-disable-next-line camelcase
|
|
522
|
+
aztec_utl_setEphemeral([slot], [index], elements) {
|
|
523
|
+
this.handlerAsUtility().setEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber(), elements.map(Fr.fromString));
|
|
524
|
+
return Promise.resolve([]);
|
|
525
|
+
}
|
|
526
|
+
// eslint-disable-next-line camelcase
|
|
527
|
+
aztec_utl_getEphemeralLen([slot]) {
|
|
528
|
+
const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
|
|
529
|
+
return Promise.resolve([
|
|
530
|
+
toACVMField(len)
|
|
531
|
+
]);
|
|
532
|
+
}
|
|
533
|
+
// eslint-disable-next-line camelcase
|
|
534
|
+
aztec_utl_removeEphemeral([slot], [index]) {
|
|
535
|
+
this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
536
|
+
return Promise.resolve([]);
|
|
537
|
+
}
|
|
538
|
+
// eslint-disable-next-line camelcase
|
|
539
|
+
aztec_utl_clearEphemeral([slot]) {
|
|
540
|
+
this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
|
|
541
|
+
return Promise.resolve([]);
|
|
542
|
+
}
|
|
543
|
+
// eslint-disable-next-line camelcase
|
|
544
|
+
async aztec_utl_decryptAes128(ciphertextBVecStorage, [ciphertextLength], iv, symKey) {
|
|
323
545
|
const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
|
|
324
546
|
const ivBuffer = fromUintArray(iv, 8);
|
|
325
547
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
326
|
-
|
|
327
|
-
|
|
548
|
+
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
549
|
+
try {
|
|
550
|
+
const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
|
|
551
|
+
const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
552
|
+
return [
|
|
553
|
+
toACVMField(1),
|
|
554
|
+
storage,
|
|
555
|
+
length
|
|
556
|
+
];
|
|
557
|
+
} catch {
|
|
558
|
+
const zeroStorage = Array(ciphertextBVecStorage.length).fill(toACVMField(0));
|
|
559
|
+
return [
|
|
560
|
+
toACVMField(0),
|
|
561
|
+
zeroStorage,
|
|
562
|
+
toACVMField(0)
|
|
563
|
+
];
|
|
564
|
+
}
|
|
328
565
|
}
|
|
329
|
-
|
|
330
|
-
|
|
566
|
+
// eslint-disable-next-line camelcase
|
|
567
|
+
async aztec_utl_getSharedSecret([address], [ephPKField0], [ephPKField1], [ephPKField2], [contractAddress]) {
|
|
568
|
+
const secret = await this.handlerAsUtility().getSharedSecret(AztecAddress.fromField(Fr.fromString(address)), Point.fromFields([
|
|
331
569
|
ephPKField0,
|
|
332
570
|
ephPKField1,
|
|
333
571
|
ephPKField2
|
|
334
|
-
].map(Fr.fromString)));
|
|
335
|
-
return
|
|
572
|
+
].map(Fr.fromString)), AztecAddress.fromField(Fr.fromString(contractAddress)));
|
|
573
|
+
return [
|
|
574
|
+
toACVMField(secret)
|
|
575
|
+
];
|
|
576
|
+
}
|
|
577
|
+
// eslint-disable-next-line camelcase
|
|
578
|
+
aztec_utl_setContractSyncCacheInvalid([contractAddress], scopes, [scopeCount]) {
|
|
579
|
+
const scopeAddresses = scopes.slice(0, +scopeCount).map((s)=>AztecAddress.fromField(Fr.fromString(s)));
|
|
580
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(AztecAddress.fromField(Fr.fromString(contractAddress)), scopeAddresses);
|
|
581
|
+
return Promise.resolve([]);
|
|
336
582
|
}
|
|
337
|
-
|
|
338
|
-
|
|
583
|
+
// eslint-disable-next-line camelcase
|
|
584
|
+
async aztec_utl_emitOffchainEffect(data) {
|
|
585
|
+
await this.handlerAsUtility().emitOffchainEffect(data.map(Fr.fromString));
|
|
339
586
|
return [];
|
|
340
587
|
}
|
|
341
|
-
|
|
342
|
-
|
|
588
|
+
// eslint-disable-next-line camelcase
|
|
589
|
+
async aztec_prv_getSenderForTags() {
|
|
590
|
+
const sender = await this.handlerAsPrivate().getSenderForTags();
|
|
343
591
|
// Return [1, address] for Some(address), [0, 0] for None
|
|
344
592
|
return sender ? [
|
|
345
593
|
toACVMField(1n),
|
|
@@ -349,8 +597,9 @@ export class UnavailableOracleError extends Error {
|
|
|
349
597
|
toACVMField(0n)
|
|
350
598
|
];
|
|
351
599
|
}
|
|
352
|
-
|
|
353
|
-
|
|
600
|
+
// eslint-disable-next-line camelcase
|
|
601
|
+
async aztec_prv_setSenderForTags([senderForTags]) {
|
|
602
|
+
await this.handlerAsPrivate().setSenderForTags(AztecAddress.fromField(Fr.fromString(senderForTags)));
|
|
354
603
|
return [];
|
|
355
604
|
}
|
|
356
605
|
}
|