@aztec/pxe 0.0.1-commit.e3c1de76 → 0.0.1-commit.e57c76e
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 +43 -99
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +26 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +93 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +62 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +9 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +37 -11
- package/dest/config/index.d.ts +8 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -29
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +216 -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_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -11
- 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 -15
- package/dest/contract_function_simulator/index.d.ts +14 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +11 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +48 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +45 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
- 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 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +13 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +35 -4
- 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_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -5
- 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 -10
- package/dest/contract_function_simulator/noir-structs/option.d.ts +61 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +62 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +24 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +16 -98
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -46
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +471 -275
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +127 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +786 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +139 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +560 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +68 -95
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +141 -110
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +156 -76
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +450 -166
- 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 +35 -64
- 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 +42 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +135 -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 +14 -15
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +16 -21
- 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 +21 -5
- 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 +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +21 -5
- package/dest/entrypoints/pxe_creation_options.d.ts +9 -1
- 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 +4 -3
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +21 -5
- package/dest/events/event_service.d.ts +15 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +44 -11
- 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 +41 -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/logs/log_service.d.ts +9 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +131 -84
- 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 +55 -0
- package/dest/notes/note_service.d.ts +27 -5
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +83 -58
- 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/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- 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 +130 -69
- 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 +202 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +166 -65
- package/dest/private_kernel/private_kernel_oracle.d.ts +15 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +31 -25
- package/dest/pxe.d.ts +120 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +231 -134
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- 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 +591 -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 +36 -28
- 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 +146 -87
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +6 -4
- package/dest/storage/open_pxe_stores.d.ts +33 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +27 -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 +3 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- 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/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 +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +45 -32
- 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 +163 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- 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 +4 -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 +32 -14
- 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 +5 -7
- 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 +37 -25
- package/package.json +29 -17
- package/src/bin/check_oracle_version.ts +49 -122
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +121 -0
- package/src/block_synchronizer/block_stream_source.ts +81 -0
- package/src/block_synchronizer/block_synchronizer.ts +39 -11
- package/src/config/index.ts +15 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +391 -136
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -18
- package/src/contract_function_simulator/index.ts +51 -1
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +55 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +36 -3
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -9
- package/src/contract_function_simulator/noir-structs/option.ts +69 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +27 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +12 -176
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle.ts +564 -473
- package/src/contract_function_simulator/oracle/oracle_registry.ts +585 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +553 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +173 -205
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +664 -245
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +41 -64
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +189 -0
- package/src/contract_sync/{index.ts → helpers.ts} +17 -29
- package/src/debug/pxe_debug_utils.ts +47 -25
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +19 -6
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +19 -6
- package/src/entrypoints/pxe_creation_options.ts +14 -0
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +22 -13
- package/src/events/event_service.ts +69 -21
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/logs/log_service.ts +162 -145
- package/src/messages/message_context_service.ts +62 -0
- package/src/notes/note_service.ts +120 -85
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/batch_planner.ts +169 -0
- 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 +165 -118
- package/src/private_kernel/hints/test_utils.ts +318 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +254 -89
- package/src/private_kernel/private_kernel_oracle.ts +42 -32
- package/src/pxe.ts +416 -181
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -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 +46 -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 +712 -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 +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +182 -104
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +9 -5
- package/src/storage/open_pxe_stores.ts +49 -0
- package/src/storage/private_event_store/private_event_store.ts +4 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +87 -35
- 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 +240 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +4 -4
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +52 -17
- 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 +27 -27
- 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
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BLOCK_HEADER_LENGTH,
|
|
3
|
+
KEY_VALIDATION_REQUEST_LENGTH,
|
|
4
|
+
L1_TO_L2_MSG_TREE_HEIGHT,
|
|
5
|
+
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
6
|
+
MAX_L2_TO_L1_MSGS_PER_TX,
|
|
7
|
+
MAX_NOTE_HASHES_PER_TX,
|
|
8
|
+
MAX_NULLIFIERS_PER_TX,
|
|
9
|
+
MAX_PRIVATE_LOGS_PER_TX,
|
|
10
|
+
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
11
|
+
} from '@aztec/constants';
|
|
12
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
13
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
14
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
15
|
+
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
16
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
17
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
18
|
+
import { type ACVMField, fromUintArray } from '@aztec/simulator/client';
|
|
19
|
+
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
20
|
+
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
21
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
23
|
+
import type { ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
|
|
24
|
+
import { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
25
|
+
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
26
|
+
import {
|
|
27
|
+
type AppTaggingSecretKind,
|
|
28
|
+
ContractClassLog,
|
|
29
|
+
ContractClassLogFields,
|
|
30
|
+
FlatPublicLogs,
|
|
31
|
+
MessageContext,
|
|
32
|
+
PendingTaggedLog,
|
|
33
|
+
PrivateLog,
|
|
34
|
+
Tag,
|
|
35
|
+
appTaggingSecretKindFromDeliveryMode,
|
|
36
|
+
} from '@aztec/stdlib/logs';
|
|
37
|
+
import { NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
38
|
+
import { BlockHeader, TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
39
|
+
|
|
40
|
+
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
41
|
+
import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
|
|
42
|
+
import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
|
|
43
|
+
import { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
|
|
44
|
+
import { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
|
|
45
|
+
import type { NoteData } from '../noir-structs/note_data.js';
|
|
46
|
+
import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
|
|
47
|
+
import { Option } from '../noir-structs/option.js';
|
|
48
|
+
import { ProvidedSecret } from '../noir-structs/provided_secret.js';
|
|
49
|
+
import { UtilityContext } from '../noir-structs/utility_context.js';
|
|
50
|
+
import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
51
|
+
import { packAsHintedNote } from './note_packing_utils.js';
|
|
52
|
+
|
|
53
|
+
// ─── Core Types ──────────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
/** One ACVM input slot: an array of hex-encoded field strings. */
|
|
56
|
+
export type InputSlot = ACVMField[];
|
|
57
|
+
|
|
58
|
+
/** One ACVM output slot: a scalar hex string or an array of hex strings. */
|
|
59
|
+
export type OutputSlot = ACVMField | ACVMField[];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Describes how to serialize and/or deserialize a single typed value to/from ACVM wire format.
|
|
63
|
+
* Either side is optional — output-only types omit `deserialization`, input-only types omit `serialization`.
|
|
64
|
+
*/
|
|
65
|
+
export interface TypeMapping<T = any> {
|
|
66
|
+
serialization?: {
|
|
67
|
+
/** Convert a typed value to ACVM output slot(s). */
|
|
68
|
+
fn: (value: T) => (Fr | Fr[])[];
|
|
69
|
+
};
|
|
70
|
+
deserialization?: {
|
|
71
|
+
/** Read a typed value from one FieldReader per consumed slot. */
|
|
72
|
+
fn: (readers: FieldReader[]) => T;
|
|
73
|
+
/**
|
|
74
|
+
* Number of InputSlots this type reads from. `deserialization.fn` receives one FieldReader per slot in `readers`.
|
|
75
|
+
*
|
|
76
|
+
* Examples:
|
|
77
|
+
* - `FIELD`, `U32`, `AZTEC_ADDRESS` — single slot → `slots: 1`
|
|
78
|
+
* - `OPTION(T)` — discriminant + inner slots → `slots: T.slots + 1`
|
|
79
|
+
* - `CONTRACT_CLASS_LOG_INPUT` — [addr], [fields], [len] → `slots: 3`
|
|
80
|
+
*/
|
|
81
|
+
slots: number;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Asserts that every reader was fully consumed by a deserialization, throwing on leftover fields.
|
|
89
|
+
*/
|
|
90
|
+
export function assertReadersConsumed(readers: FieldReader[]): void {
|
|
91
|
+
readers.forEach((reader, slot) => {
|
|
92
|
+
if (!reader.isFinished()) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
`Malformed oracle input: ${reader.remainingFields()} unexpected trailing field(s) in slot ${slot}`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ─── Scalar Type Mappings ────────────────────────────────────────────────────
|
|
101
|
+
|
|
102
|
+
export const FIELD: TypeMapping<Fr> = {
|
|
103
|
+
serialization: { fn: v => [v] },
|
|
104
|
+
deserialization: { fn: ([reader]) => reader.readField(), slots: 1 },
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const BOOL: TypeMapping<boolean> = {
|
|
108
|
+
serialization: { fn: v => [new Fr(v ? 1n : 0n)] },
|
|
109
|
+
deserialization: { fn: ([reader]) => !reader.readField().isZero(), slots: 1 },
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const U32: TypeMapping<number> = {
|
|
113
|
+
serialization: { fn: v => [new Fr(v)] },
|
|
114
|
+
deserialization: {
|
|
115
|
+
fn: ([reader]) => {
|
|
116
|
+
const value = reader.readField().toBigInt();
|
|
117
|
+
if (value > 0xffffffffn) {
|
|
118
|
+
throw new Error(`U32 overflow: value ${value} exceeds u32 max (${0xffffffffn})`);
|
|
119
|
+
}
|
|
120
|
+
return Number(value);
|
|
121
|
+
},
|
|
122
|
+
slots: 1,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const BLOCK_NUMBER: TypeMapping<BlockNumber> = {
|
|
127
|
+
serialization: { fn: v => [new Fr(v)] },
|
|
128
|
+
deserialization: { fn: ([reader]) => BlockNumber(reader.readField().toNumber()), slots: 1 },
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/** A u8 byte: serializes to a single Fr; deserializes from a single Fr to a number in [0, 255]. */
|
|
132
|
+
export const BYTE: TypeMapping<number> = {
|
|
133
|
+
serialization: { fn: byte => [new Fr(byte)] },
|
|
134
|
+
deserialization: {
|
|
135
|
+
fn: ([reader]) => {
|
|
136
|
+
const value = reader.readField().toBigInt();
|
|
137
|
+
if (value > 0xffn) {
|
|
138
|
+
throw new Error(`BYTE overflow: value ${value} exceeds u8 max (255)`);
|
|
139
|
+
}
|
|
140
|
+
return Number(value);
|
|
141
|
+
},
|
|
142
|
+
slots: 1,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Noir passes `MessageDelivery` onchain variants here.
|
|
147
|
+
export const DELIVERY_MODE: TypeMapping<AppTaggingSecretKind> = {
|
|
148
|
+
deserialization: {
|
|
149
|
+
fn: readers => appTaggingSecretKindFromDeliveryMode(BYTE.deserialization!.fn(readers)),
|
|
150
|
+
slots: BYTE.deserialization!.slots,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const BIGINT: TypeMapping<bigint> = {
|
|
155
|
+
serialization: { fn: v => [new Fr(v)] },
|
|
156
|
+
deserialization: { fn: ([reader]) => reader.readField().toBigInt(), slots: 1 },
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/** Reads every field in the slot as a UTF-8 character code. */
|
|
160
|
+
export const STR: TypeMapping<string> = {
|
|
161
|
+
serialization: { fn: str => [Array.from(Buffer.from(str, 'utf-8')).map(b => new Fr(b))] },
|
|
162
|
+
deserialization: {
|
|
163
|
+
fn: ([reader]) => {
|
|
164
|
+
const chars: string[] = [];
|
|
165
|
+
while (!reader.isFinished()) {
|
|
166
|
+
chars.push(String.fromCharCode(reader.readField().toNumber()));
|
|
167
|
+
}
|
|
168
|
+
return chars.join('');
|
|
169
|
+
},
|
|
170
|
+
slots: 1,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const AZTEC_ADDRESS: TypeMapping<AztecAddress> = {
|
|
175
|
+
serialization: { fn: v => [v.toField()] },
|
|
176
|
+
deserialization: { fn: ([reader]) => AztecAddress.fromField(reader.readField()), slots: 1 },
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export const BLOCK_HASH: TypeMapping<BlockHash> = {
|
|
180
|
+
serialization: { fn: v => [new Fr(v.toBuffer())] },
|
|
181
|
+
deserialization: { fn: ([reader]) => new BlockHash(reader.readField()), slots: 1 },
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const FUNCTION_SELECTOR: TypeMapping<FunctionSelector> = {
|
|
185
|
+
serialization: { fn: v => [v.toField()] },
|
|
186
|
+
deserialization: { fn: ([reader]) => FunctionSelector.fromField(reader.readField()), slots: 1 },
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const NOTE_SELECTOR: TypeMapping<NoteSelector> = {
|
|
190
|
+
serialization: { fn: v => [v.toField()] },
|
|
191
|
+
deserialization: { fn: ([reader]) => NoteSelector.fromField(reader.readField()), slots: 1 },
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const TX_HASH: TypeMapping<TxHash> = {
|
|
195
|
+
serialization: { fn: v => [v.hash] },
|
|
196
|
+
deserialization: { fn: ([reader]) => TxHash.fromField(reader.readField()), slots: 1 },
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const TAG: TypeMapping<Tag> = {
|
|
200
|
+
serialization: { fn: v => [v.value] },
|
|
201
|
+
deserialization: { fn: ([reader]) => new Tag(reader.readField()), slots: 1 },
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const POINT: TypeMapping<Point> = {
|
|
205
|
+
serialization: { fn: p => [p.toFields()] },
|
|
206
|
+
deserialization: {
|
|
207
|
+
fn: ([reader]) => Point.fromFields([reader.readField(), reader.readField()]),
|
|
208
|
+
slots: 1,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// ─── Struct Type Mappings ────────────────────────────────────────────────────
|
|
213
|
+
|
|
214
|
+
export const BLOCK_HEADER: TypeMapping<BlockHeader> = {
|
|
215
|
+
serialization: { fn: v => v.toFields() },
|
|
216
|
+
deserialization: { fn: ([reader]) => BlockHeader.fromFields(reader.readFieldArray(BLOCK_HEADER_LENGTH)), slots: 1 },
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const KEY_VALIDATION_REQUEST: TypeMapping<KeyValidationRequest> = {
|
|
220
|
+
serialization: { fn: v => v.toFields() },
|
|
221
|
+
deserialization: {
|
|
222
|
+
fn: ([reader]) => KeyValidationRequest.fromFields(reader.readFieldArray(KEY_VALIDATION_REQUEST_LENGTH)),
|
|
223
|
+
slots: 1,
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const CONTRACT_INSTANCE: TypeMapping<ContractInstance> = {
|
|
228
|
+
serialization: {
|
|
229
|
+
fn: v => [
|
|
230
|
+
v.salt,
|
|
231
|
+
v.deployer.toField(),
|
|
232
|
+
v.currentContractClassId,
|
|
233
|
+
v.initializationHash,
|
|
234
|
+
v.immutablesHash,
|
|
235
|
+
...v.publicKeys.toFields(),
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export const NULLIFIER_MEMBERSHIP_WITNESS: TypeMapping<NullifierMembershipWitness> = {
|
|
241
|
+
serialization: {
|
|
242
|
+
fn: (w: NullifierMembershipWitness) =>
|
|
243
|
+
w
|
|
244
|
+
.toNoirRepresentation()
|
|
245
|
+
.map(slot => (Array.isArray(slot) ? slot.map(s => Fr.fromString(s)) : Fr.fromString(slot as string))),
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export const PUBLIC_DATA_WITNESS: TypeMapping<PublicDataWitness> = {
|
|
250
|
+
serialization: {
|
|
251
|
+
fn: (w: PublicDataWitness) =>
|
|
252
|
+
w
|
|
253
|
+
.toNoirRepresentation()
|
|
254
|
+
.map(slot => (Array.isArray(slot) ? slot.map(s => Fr.fromString(s)) : Fr.fromString(slot as string))),
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export const MESSAGE_LOAD_ORACLE_INPUTS: TypeMapping<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>> = {
|
|
259
|
+
serialization: {
|
|
260
|
+
fn: (m: MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>) =>
|
|
261
|
+
m
|
|
262
|
+
.toNoirRepresentation()
|
|
263
|
+
.map(slot => (Array.isArray(slot) ? slot.map(s => Fr.fromString(s)) : Fr.fromString(slot as string))),
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export const UTILITY_CONTEXT: TypeMapping<UtilityContext> = {
|
|
268
|
+
serialization: {
|
|
269
|
+
fn: (ctx: UtilityContext) => [...ctx.blockHeader.toFields(), ctx.contractAddress.toField()],
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const CALL_PRIVATE_RESULT: TypeMapping<{ endSideEffectCounter: Fr; returnsHash: Fr }> = {
|
|
274
|
+
serialization: { fn: v => [[v.endSideEffectCounter, v.returnsHash]] },
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
export const PUBLIC_KEYS_AND_PARTIAL_ADDRESS: TypeMapping<{
|
|
278
|
+
publicKeys: PublicKeys;
|
|
279
|
+
partialAddress: PartialAddress;
|
|
280
|
+
}> = {
|
|
281
|
+
serialization: {
|
|
282
|
+
fn: v => [[...v.publicKeys.toFields(), v.partialAddress]],
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export const CONTRACT_CLASS_LOG_INPUT: TypeMapping<ContractClassLog> = {
|
|
287
|
+
deserialization: {
|
|
288
|
+
fn: ([addrReader, fieldsReader, lengthReader]) => {
|
|
289
|
+
const addr = AztecAddress.fromField(addrReader.readField());
|
|
290
|
+
const fields = new ContractClassLogFields([...fieldsReader.readFieldArray(fieldsReader.remainingFields())]);
|
|
291
|
+
const length = lengthReader.readField().toNumber();
|
|
292
|
+
return new ContractClassLog(addr, fields, length);
|
|
293
|
+
},
|
|
294
|
+
// ContractClassLog input occupies 3 ACVM slots: [contractAddress], [message fields...], [length].
|
|
295
|
+
slots: 3,
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
export const TX_EFFECT: TypeMapping<TxEffect> = {
|
|
300
|
+
serialization: {
|
|
301
|
+
fn: (effect: TxEffect) => {
|
|
302
|
+
const flatPublicLogs = FlatPublicLogs.fromLogs(effect.publicLogs);
|
|
303
|
+
return [
|
|
304
|
+
effect.revertCode.toField(),
|
|
305
|
+
effect.txHash.hash,
|
|
306
|
+
effect.transactionFee,
|
|
307
|
+
padArrayEnd(effect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
|
|
308
|
+
padArrayEnd(effect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
|
|
309
|
+
padArrayEnd(effect.l2ToL1Msgs, Fr.ZERO, MAX_L2_TO_L1_MSGS_PER_TX),
|
|
310
|
+
padArrayEnd(
|
|
311
|
+
effect.publicDataWrites,
|
|
312
|
+
PublicDataWrite.empty(),
|
|
313
|
+
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
314
|
+
).flatMap(w => w.toFields()),
|
|
315
|
+
padArrayEnd(effect.privateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX).flatMap(l => l.toFields()),
|
|
316
|
+
new Fr(flatPublicLogs.length),
|
|
317
|
+
flatPublicLogs.payload,
|
|
318
|
+
padArrayEnd(effect.contractClassLogs, ContractClassLog.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX).flatMap(l => [
|
|
319
|
+
...l.fields.toFields(),
|
|
320
|
+
new Fr(l.emittedLength),
|
|
321
|
+
l.contractAddress.toField(),
|
|
322
|
+
]),
|
|
323
|
+
] as (Fr | Fr[])[];
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export const NOTE: TypeMapping<NoteData> = {
|
|
329
|
+
serialization: {
|
|
330
|
+
fn: noteData =>
|
|
331
|
+
packAsHintedNote({
|
|
332
|
+
contractAddress: noteData.contractAddress,
|
|
333
|
+
owner: noteData.owner,
|
|
334
|
+
randomness: noteData.randomness,
|
|
335
|
+
storageSlot: noteData.storageSlot,
|
|
336
|
+
noteNonce: noteData.noteNonce,
|
|
337
|
+
isPending: noteData.isPending,
|
|
338
|
+
note: noteData.note,
|
|
339
|
+
}),
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export const PENDING_TAGGED_LOG: TypeMapping<PendingTaggedLog> = {
|
|
344
|
+
serialization: { fn: log => [log.toFields()] },
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const NOTE_VALIDATION_REQUEST: TypeMapping<NoteValidationRequest> = {
|
|
348
|
+
deserialization: {
|
|
349
|
+
fn: ([reader]) => NoteValidationRequest.fromFields(reader),
|
|
350
|
+
slots: 1,
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
export const EVENT_VALIDATION_REQUEST: TypeMapping<EventValidationRequest> = {
|
|
355
|
+
deserialization: {
|
|
356
|
+
fn: ([reader]) => EventValidationRequest.fromFields(reader),
|
|
357
|
+
slots: 1,
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export const LOG_RETRIEVAL_REQUEST: TypeMapping<LogRetrievalRequest> = {
|
|
362
|
+
serialization: { fn: req => [req.toFields()] },
|
|
363
|
+
deserialization: {
|
|
364
|
+
fn: ([reader]) => LogRetrievalRequest.fromFields(reader),
|
|
365
|
+
slots: 1,
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
export const LOG_RETRIEVAL_RESPONSE: TypeMapping<LogRetrievalResponse> = {
|
|
370
|
+
serialization: { fn: resp => [resp.toFields()] },
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
export const MESSAGE_CONTEXT: TypeMapping<MessageContext> = {
|
|
374
|
+
serialization: { fn: mc => [mc.toFields()] },
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
export const PROVIDED_SECRET: TypeMapping<ProvidedSecret> = {
|
|
378
|
+
deserialization: {
|
|
379
|
+
fn: ([reader]) => ProvidedSecret.fromFields(reader),
|
|
380
|
+
slots: 1,
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
// ─── Combinator Type Mappings ────────────────────────────────────────────────
|
|
385
|
+
|
|
386
|
+
/** `_height` is unused at runtime but lets TypeScript infer the exact `N` for `MembershipWitness<N>`. */
|
|
387
|
+
export function MEMBERSHIP_WITNESS<N extends number>(_height: N): TypeMapping<MembershipWitness<N>> {
|
|
388
|
+
return {
|
|
389
|
+
serialization: {
|
|
390
|
+
fn: (witness: MembershipWitness<N>) => [new Fr(witness.leafIndex), [...witness.siblingPath]],
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export function ARRAY<T>(element: TypeMapping<T>): TypeMapping<T[]> {
|
|
396
|
+
return {
|
|
397
|
+
serialization: element.serialization
|
|
398
|
+
? { fn: values => [values.flatMap(v => element.serialization!.fn(v).flat())] }
|
|
399
|
+
: undefined,
|
|
400
|
+
deserialization: element.deserialization
|
|
401
|
+
? {
|
|
402
|
+
fn: ([reader]) => {
|
|
403
|
+
const result: T[] = [];
|
|
404
|
+
while (!reader.isFinished()) {
|
|
405
|
+
result.push(element.deserialization!.fn([reader]));
|
|
406
|
+
}
|
|
407
|
+
return result;
|
|
408
|
+
},
|
|
409
|
+
slots: 1,
|
|
410
|
+
}
|
|
411
|
+
: undefined,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Maps Noir's `BoundedVec<T, MaxLen>` ↔ TS `BoundedVec<T>` over 2 slots:
|
|
417
|
+
* slot 0 — flat storage, padded/parsed as `maxLength * elementSize` fields
|
|
418
|
+
* slot 1 — length scalar (count of actual items)
|
|
419
|
+
*
|
|
420
|
+
* Both directions are derived from `element`: bidirectional iff `element` has both serialization and deserialization.
|
|
421
|
+
*
|
|
422
|
+
* @example Serializing `BoundedVec.from({ data: [0x41, 0x42], maxLength: 4 })` with `BOUNDED_VEC(BYTE)`:
|
|
423
|
+
* ```
|
|
424
|
+
* slot 0: [Fr(0x41), Fr(0x42), Fr(0), Fr(0)] // data padded to maxLength
|
|
425
|
+
* slot 1: Fr(2) // actual length
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
export function BOUNDED_VEC<T>(element: TypeMapping<T>): TypeMapping<BoundedVec<T>> {
|
|
429
|
+
return {
|
|
430
|
+
serialization: element.serialization
|
|
431
|
+
? {
|
|
432
|
+
fn: bv => {
|
|
433
|
+
if (bv.data.length > bv.maxLength) {
|
|
434
|
+
throw new Error(`Got ${bv.data.length} items, but maxLength is ${bv.maxLength}`);
|
|
435
|
+
}
|
|
436
|
+
const flat = bv.data.flatMap(item => element.serialization!.fn(item).flat());
|
|
437
|
+
return [padArrayEnd(flat, Fr.ZERO, bv.maxLength * bv.elementSize), new Fr(bv.data.length)];
|
|
438
|
+
},
|
|
439
|
+
}
|
|
440
|
+
: undefined,
|
|
441
|
+
deserialization: element.deserialization
|
|
442
|
+
? {
|
|
443
|
+
fn: ([storageReader, lengthReader]) => {
|
|
444
|
+
const maxLength = storageReader.remainingFields();
|
|
445
|
+
const length = lengthReader.readField().toNumber();
|
|
446
|
+
const elements: T[] = [];
|
|
447
|
+
for (let i = 0; i < length; i++) {
|
|
448
|
+
elements.push(element.deserialization!.fn([storageReader]));
|
|
449
|
+
}
|
|
450
|
+
// Drain the trailing zero-padding (maxLength - length unused element slots) so the storage reader is
|
|
451
|
+
// fully consumed.
|
|
452
|
+
storageReader.skip(storageReader.remainingFields());
|
|
453
|
+
return BoundedVec.from<T>({ data: elements, maxLength });
|
|
454
|
+
},
|
|
455
|
+
slots: 2,
|
|
456
|
+
}
|
|
457
|
+
: undefined,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Wraps an inner TypeMapping in Noir-style `Option<T>`. Adds a discriminant slot and uses the handler-provided
|
|
463
|
+
* `Option.none(shape)` template to produce a correctly-sized zero-filled output for the None case.
|
|
464
|
+
*
|
|
465
|
+
* @example Serializing `Option.some(AztecAddress.fromField(Fr(42)))` with `OPTION(AZTEC_ADDRESS)`:
|
|
466
|
+
* ```
|
|
467
|
+
* slot 0: Fr(1) // discriminant: Some
|
|
468
|
+
* slot 1: Fr(42) // inner value
|
|
469
|
+
* ```
|
|
470
|
+
*
|
|
471
|
+
* @example Serializing `Option.empty(AztecAddress.ZERO)` with `OPTION(AZTEC_ADDRESS)`:
|
|
472
|
+
* ```
|
|
473
|
+
* slot 0: Fr(0) // discriminant: None
|
|
474
|
+
* slot 1: Fr(0) // zero-filled using shape
|
|
475
|
+
* ```
|
|
476
|
+
*/
|
|
477
|
+
export function OPTION<T>(inner: TypeMapping<T>): TypeMapping<Option<T>> {
|
|
478
|
+
return {
|
|
479
|
+
serialization: inner.serialization
|
|
480
|
+
? {
|
|
481
|
+
fn: opt => {
|
|
482
|
+
if (opt.isSome()) {
|
|
483
|
+
return [Fr.ONE, ...inner.serialization!.fn(opt.value)];
|
|
484
|
+
}
|
|
485
|
+
if (opt.template === undefined) {
|
|
486
|
+
throw new Error(
|
|
487
|
+
'Cannot serialize Option.empty() without an emptyTemplate — provide one via Option.empty(emptyTemplate)',
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
const zeroSlots = inner
|
|
491
|
+
.serialization!.fn(opt.template)
|
|
492
|
+
.map(s => (Array.isArray(s) ? Array(s.length).fill(Fr.ZERO) : Fr.ZERO));
|
|
493
|
+
return [Fr.ZERO, ...zeroSlots];
|
|
494
|
+
},
|
|
495
|
+
}
|
|
496
|
+
: undefined,
|
|
497
|
+
deserialization: inner.deserialization
|
|
498
|
+
? {
|
|
499
|
+
fn: ([discriminant, ...innerReaders]) => {
|
|
500
|
+
if (discriminant.readField().isZero()) {
|
|
501
|
+
// None still carries zero-filled inner slots on the wire; drain them so the inner readers are fully
|
|
502
|
+
// consumed.
|
|
503
|
+
innerReaders.forEach(reader => reader.skip(reader.remainingFields()));
|
|
504
|
+
return Option.none<T>(undefined as unknown as T);
|
|
505
|
+
}
|
|
506
|
+
return Option.some(inner.deserialization!.fn(innerReaders));
|
|
507
|
+
},
|
|
508
|
+
slots: inner.deserialization.slots + 1,
|
|
509
|
+
}
|
|
510
|
+
: undefined,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** A packed uint buffer (e.g. `[u8; N]` in Noir): 1 slot of packed uint values ↔ `Buffer`. */
|
|
515
|
+
export function BUFFER(bitSize: number): TypeMapping<Buffer> {
|
|
516
|
+
return {
|
|
517
|
+
serialization: {
|
|
518
|
+
fn: buf => [Array.from(buf).map(b => new Fr(b))],
|
|
519
|
+
},
|
|
520
|
+
deserialization: {
|
|
521
|
+
fn: ([reader]) => {
|
|
522
|
+
const fields = reader.readFieldArray(reader.remainingFields()).map(f => f.toString());
|
|
523
|
+
return fromUintArray(fields, bitSize);
|
|
524
|
+
},
|
|
525
|
+
slots: 1,
|
|
526
|
+
},
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export function EPHEMERAL_ARRAY<T>(element: TypeMapping<T>): TypeMapping<EphemeralArray<T>> {
|
|
531
|
+
// An EphemeralArray param is a single slot; the per-param assert covers that slot but never sees the
|
|
532
|
+
// per-row readers materialized in readAll(). Assert full consumption per row here.
|
|
533
|
+
const rowElement: TypeMapping<T> | undefined = element.deserialization
|
|
534
|
+
? {
|
|
535
|
+
deserialization: {
|
|
536
|
+
fn: readers => {
|
|
537
|
+
const value = element.deserialization!.fn(readers);
|
|
538
|
+
assertReadersConsumed(readers);
|
|
539
|
+
return value;
|
|
540
|
+
},
|
|
541
|
+
slots: element.deserialization.slots,
|
|
542
|
+
},
|
|
543
|
+
}
|
|
544
|
+
: undefined;
|
|
545
|
+
return {
|
|
546
|
+
serialization: element.serialization
|
|
547
|
+
? { fn: ea => [ea.materializeSlot(v => element.serialization!.fn(v).flat() as Fr[])] }
|
|
548
|
+
: undefined,
|
|
549
|
+
deserialization: rowElement
|
|
550
|
+
? { fn: ([reader]) => EphemeralArray.fromSlot(reader.readField(), rowElement), slots: 1 }
|
|
551
|
+
: undefined,
|
|
552
|
+
};
|
|
553
|
+
}
|
|
@@ -76,12 +76,12 @@ export async function executePrivateFunction(
|
|
|
76
76
|
|
|
77
77
|
const contractClassLogs = privateExecutionOracle.getContractClassLogs();
|
|
78
78
|
|
|
79
|
-
const rawReturnValues = await privateExecutionOracle.
|
|
79
|
+
const rawReturnValues = await privateExecutionOracle.getHashPreimage(publicInputs.returnsHash);
|
|
80
80
|
|
|
81
81
|
const newNotes = privateExecutionOracle.getNewNotes();
|
|
82
82
|
const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
|
|
83
83
|
const offchainEffects = privateExecutionOracle.getOffchainEffects();
|
|
84
|
-
const
|
|
84
|
+
const taggingIndexRanges = privateExecutionOracle.getUsedTaggingIndexRanges();
|
|
85
85
|
const nestedExecutionResults = privateExecutionOracle.getNestedExecutionResults();
|
|
86
86
|
|
|
87
87
|
let timerSubtractionList = nestedExecutionResults;
|
|
@@ -103,8 +103,8 @@ export async function executePrivateFunction(
|
|
|
103
103
|
newNotes,
|
|
104
104
|
noteHashNullifierCounterMap,
|
|
105
105
|
rawReturnValues,
|
|
106
|
-
offchainEffects,
|
|
107
|
-
|
|
106
|
+
offchainEffects.map(e => ({ data: e.data })),
|
|
107
|
+
taggingIndexRanges,
|
|
108
108
|
nestedExecutionResults,
|
|
109
109
|
contractClassLogs,
|
|
110
110
|
{
|