@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.0b941701
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 +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +14 -10
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -32
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +28 -27
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +56 -40
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- 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 +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +43 -32
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -26
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +28 -41
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +44 -34
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +92 -92
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +5 -5
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +6 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +8 -7
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +8 -7
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +22 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -6
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/logs/log_service.d.ts +15 -31
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +77 -188
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +40 -44
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +4 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +17 -44
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +131 -147
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{anchor_block_data_provider/anchor_block_data_provider.js → anchor_block_store/anchor_block_store.js} +1 -1
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +255 -0
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +3 -3
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +2 -2
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +73 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +303 -0
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +250 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +99 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.d.ts → tagging_store/sender_tagging_store.d.ts} +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.js → tagging_store/sender_tagging_store.js} +111 -29
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -3
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +15 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +14 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -8
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.d.ts +4 -4
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.js +8 -23
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.js +5 -8
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.d.ts +7 -4
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.js +12 -7
- package/package.json +18 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +83 -34
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +79 -64
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -10
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +56 -41
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +77 -78
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +121 -105
- package/src/contract_function_simulator/proxied_contract_data_source.ts +7 -7
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +7 -6
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +23 -27
- package/src/events/private_event_filter_validator.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +116 -260
- package/src/notes/note_service.ts +43 -46
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +189 -190
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +1 -1
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/capsule_store/capsule_store.ts +315 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +2 -2
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +381 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +363 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +129 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/{tagging_data_provider/sender_tagging_data_provider.ts → tagging_store/sender_tagging_store.ts} +129 -28
- package/src/tagging/constants.ts +10 -3
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +17 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +23 -9
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.ts +12 -25
- package/src/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.ts +19 -7
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +0 -9
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.d.ts +0 -2
- package/dest/storage/anchor_block_data_provider/index.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -57
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -146
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -84
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_data_provider.js +0 -322
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -115
- package/dest/storage/tagging_data_provider/index.d.ts +0 -3
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -2
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +0 -31
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +0 -65
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +0 -21
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +0 -42
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -25
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/anchor_block_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -179
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_data_provider.ts +0 -412
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -162
- package/src/storage/tagging_data_provider/index.ts +0 -2
- package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +0 -86
- package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +0 -53
- package/src/tagging/utils.ts +0 -32
- package/src/tree_membership/tree_membership_service.ts +0 -112
- /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
- /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
package/src/logs/log_service.ts
CHANGED
|
@@ -1,79 +1,69 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
3
|
-
import
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
6
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import {
|
|
7
|
-
DirectionalAppTaggingSecret,
|
|
8
|
-
PendingTaggedLog,
|
|
9
|
-
PrivateLogWithTxData,
|
|
10
|
-
PublicLogWithTxData,
|
|
11
|
-
SiloedTag,
|
|
12
|
-
Tag,
|
|
13
|
-
TxScopedL2Log,
|
|
14
|
-
} from '@aztec/stdlib/logs';
|
|
7
|
+
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
15
8
|
|
|
16
9
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
17
10
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
11
|
+
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
+
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
13
|
+
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
14
|
+
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
15
|
+
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
16
|
+
import {
|
|
17
|
+
getAllPrivateLogsByTags,
|
|
18
|
+
getAllPublicLogsByTagsFromContract,
|
|
19
|
+
loadPrivateLogsForSenderRecipientPair,
|
|
20
|
+
} from '../tagging/index.js';
|
|
24
21
|
|
|
25
22
|
export class LogService {
|
|
23
|
+
private log = createLogger('log_service');
|
|
24
|
+
|
|
26
25
|
constructor(
|
|
27
26
|
private readonly aztecNode: AztecNode,
|
|
28
|
-
private readonly
|
|
27
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
29
28
|
private readonly keyStore: KeyStore,
|
|
30
|
-
private readonly
|
|
31
|
-
private readonly
|
|
32
|
-
private readonly
|
|
29
|
+
private readonly capsuleStore: CapsuleStore,
|
|
30
|
+
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
31
|
+
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
32
|
+
private readonly addressStore: AddressStore,
|
|
33
|
+
private readonly jobId: string,
|
|
33
34
|
) {}
|
|
34
35
|
|
|
35
36
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
36
37
|
return await Promise.all(
|
|
37
38
|
logRetrievalRequests.map(async request => {
|
|
38
|
-
// TODO(F-231): remove these internal functions and have node endpoints that do this instead
|
|
39
39
|
const [publicLog, privateLog] = await Promise.all([
|
|
40
|
-
this
|
|
41
|
-
this
|
|
40
|
+
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
41
|
+
this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
|
|
42
42
|
]);
|
|
43
43
|
|
|
44
|
-
if (publicLog !== null) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return new LogRetrievalResponse(
|
|
52
|
-
publicLog.logPayload,
|
|
53
|
-
publicLog.txHash,
|
|
54
|
-
publicLog.uniqueNoteHashesInTx,
|
|
55
|
-
publicLog.firstNullifierInTx,
|
|
56
|
-
);
|
|
57
|
-
} else if (privateLog !== null) {
|
|
58
|
-
return new LogRetrievalResponse(
|
|
59
|
-
privateLog.logPayload,
|
|
60
|
-
privateLog.txHash,
|
|
61
|
-
privateLog.uniqueNoteHashesInTx,
|
|
62
|
-
privateLog.firstNullifierInTx,
|
|
44
|
+
if (publicLog !== null && privateLog !== null) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`,
|
|
63
47
|
);
|
|
64
|
-
} else {
|
|
65
|
-
return null;
|
|
66
48
|
}
|
|
49
|
+
|
|
50
|
+
return publicLog ?? privateLog;
|
|
67
51
|
}),
|
|
68
52
|
);
|
|
69
53
|
}
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
const
|
|
55
|
+
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
56
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
57
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
58
|
+
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
59
|
+
this.aztecNode,
|
|
60
|
+
contractAddress,
|
|
61
|
+
[tag],
|
|
62
|
+
anchorBlockHash,
|
|
63
|
+
);
|
|
64
|
+
const logsForTag = allLogsPerTag[0];
|
|
75
65
|
|
|
76
|
-
if (logsForTag.length
|
|
66
|
+
if (logsForTag.length === 0) {
|
|
77
67
|
return null;
|
|
78
68
|
} else if (logsForTag.length > 1) {
|
|
79
69
|
// TODO(#11627): handle this case
|
|
@@ -84,28 +74,21 @@ export class LogService {
|
|
|
84
74
|
|
|
85
75
|
const scopedLog = logsForTag[0];
|
|
86
76
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// TODO(#9789): bundle this information in the `getLogsByTag` call.
|
|
90
|
-
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
91
|
-
if (txEffect == undefined) {
|
|
92
|
-
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return new PublicLogWithTxData(
|
|
96
|
-
scopedLog.log.getEmittedFieldsWithoutTag(),
|
|
77
|
+
return new LogRetrievalResponse(
|
|
78
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
97
79
|
scopedLog.txHash,
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
scopedLog.noteHashes,
|
|
81
|
+
scopedLog.firstNullifier,
|
|
100
82
|
);
|
|
101
83
|
}
|
|
102
84
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
const
|
|
85
|
+
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
86
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
87
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
88
|
+
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
89
|
+
const logsForTag = allLogsPerTag[0];
|
|
107
90
|
|
|
108
|
-
if (logsForTag.length
|
|
91
|
+
if (logsForTag.length === 0) {
|
|
109
92
|
return null;
|
|
110
93
|
} else if (logsForTag.length > 1) {
|
|
111
94
|
// TODO(#11627): handle this case
|
|
@@ -116,243 +99,116 @@ export class LogService {
|
|
|
116
99
|
|
|
117
100
|
const scopedLog = logsForTag[0];
|
|
118
101
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// TODO(#9789): bundle this information in the `getLogsByTag` call.
|
|
122
|
-
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
123
|
-
if (txEffect == undefined) {
|
|
124
|
-
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return new PrivateLogWithTxData(
|
|
128
|
-
scopedLog.log.getEmittedFieldsWithoutTag(),
|
|
102
|
+
return new LogRetrievalResponse(
|
|
103
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
129
104
|
scopedLog.txHash,
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
scopedLog.noteHashes,
|
|
106
|
+
scopedLog.firstNullifier,
|
|
132
107
|
);
|
|
133
108
|
}
|
|
134
109
|
|
|
135
|
-
// TODO(#17775): Replace this implementation of this function with one implementing an approach similar
|
|
136
|
-
// to syncSenderTaggingIndexes. Not done yet due to re-prioritization to devex and this doesn't directly affect
|
|
137
|
-
// devex.
|
|
138
110
|
public async syncTaggedLogs(
|
|
139
111
|
contractAddress: AztecAddress,
|
|
140
112
|
pendingTaggedLogArrayBaseSlot: Fr,
|
|
141
113
|
scopes?: AztecAddress[],
|
|
142
114
|
) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
secret: indexedSecret.secret,
|
|
167
|
-
leftMostIndex: 0,
|
|
168
|
-
rightMostIndex: WINDOW_HALF_SIZE,
|
|
169
|
-
};
|
|
170
|
-
} else {
|
|
171
|
-
return {
|
|
172
|
-
secret: indexedSecret.secret,
|
|
173
|
-
leftMostIndex: Math.max(0, indexedSecret.index - WINDOW_HALF_SIZE),
|
|
174
|
-
rightMostIndex: indexedSecret.index + WINDOW_HALF_SIZE,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// As we iterate we store the largest index we have seen for a given secret to later on store it in the db.
|
|
180
|
-
const newLargestIndexMapToStore: { [k: string]: number } = {};
|
|
181
|
-
|
|
182
|
-
// The initial/unmodified indexes of the secrets stored in a key-value map where key is the directional app
|
|
183
|
-
// tagging secret.
|
|
184
|
-
const initialIndexesMap = getInitialIndexesMap(indexedSecrets);
|
|
185
|
-
|
|
186
|
-
while (secretsAndWindows.length > 0) {
|
|
187
|
-
const preTagsForTheWholeWindow = getPreTagsForTheWindow(secretsAndWindows);
|
|
188
|
-
const tagsForTheWholeWindow = await Promise.all(
|
|
189
|
-
preTagsForTheWholeWindow.map(async preTag => {
|
|
190
|
-
return SiloedTag.compute(await Tag.compute(preTag), contractAddress);
|
|
191
|
-
}),
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
// We store the new largest indexes we find in the iteration in the following map to later on construct
|
|
195
|
-
// a new set of secrets and windows to fetch logs for.
|
|
196
|
-
const newLargestIndexMapForIteration: { [k: string]: number } = {};
|
|
197
|
-
|
|
198
|
-
// Fetch the private logs for the tags and iterate over them
|
|
199
|
-
const logsByTags = await this.aztecNode.getPrivateLogsByTags(tagsForTheWholeWindow);
|
|
200
|
-
|
|
201
|
-
for (let logIndex = 0; logIndex < logsByTags.length; logIndex++) {
|
|
202
|
-
const logsByTag = logsByTags[logIndex];
|
|
203
|
-
if (logsByTag.length > 0) {
|
|
204
|
-
// We filter out the logs that are newer than the anchor block number of the tx currently being constructed
|
|
205
|
-
const filteredLogsByBlockNumber = logsByTag.filter(l => l.blockNumber <= maxBlockNumber);
|
|
206
|
-
|
|
207
|
-
// We store the logs in capsules (to later be obtained in Noir)
|
|
208
|
-
await this.#storePendingTaggedLogs(
|
|
115
|
+
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
116
|
+
|
|
117
|
+
// We only load logs from block up to and including the anchor block number
|
|
118
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
119
|
+
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
120
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
121
|
+
|
|
122
|
+
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
123
|
+
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
124
|
+
|
|
125
|
+
// For each recipient, fetch secrets, load logs, and store them.
|
|
126
|
+
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
127
|
+
await Promise.all(
|
|
128
|
+
recipients.map(async recipient => {
|
|
129
|
+
// Get all secrets for this recipient (one per sender)
|
|
130
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
131
|
+
|
|
132
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
133
|
+
const logArrays = await Promise.all(
|
|
134
|
+
secrets.map(secret =>
|
|
135
|
+
loadPrivateLogsForSenderRecipientPair(
|
|
136
|
+
secret,
|
|
209
137
|
contractAddress,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const initialIndex = initialIndexesMap[preTagCorrespondingToLog.secret.toString()];
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
preTagCorrespondingToLog.index >= initialIndex &&
|
|
222
|
-
(newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] === undefined ||
|
|
223
|
-
preTagCorrespondingToLog.index >=
|
|
224
|
-
newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()])
|
|
225
|
-
) {
|
|
226
|
-
// We have found a new largest index so we store it for later processing (storing it in the db + fetching
|
|
227
|
-
// the difference of the window sets of current and the next iteration)
|
|
228
|
-
newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] =
|
|
229
|
-
preTagCorrespondingToLog.index + 1;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
138
|
+
this.aztecNode,
|
|
139
|
+
this.recipientTaggingStore,
|
|
140
|
+
anchorBlockNumber,
|
|
141
|
+
anchorBlockHash,
|
|
142
|
+
this.jobId,
|
|
143
|
+
),
|
|
144
|
+
),
|
|
145
|
+
);
|
|
233
146
|
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
// so we fetch the logs only for the difference of the window sets.
|
|
237
|
-
const newSecretsAndWindows = [];
|
|
238
|
-
for (const [directionalAppTaggingSecret, newIndex] of Object.entries(newLargestIndexMapForIteration)) {
|
|
239
|
-
const maybeIndexedSecret = indexedSecrets.find(
|
|
240
|
-
indexedSecret => indexedSecret.secret.toString() === directionalAppTaggingSecret,
|
|
241
|
-
);
|
|
242
|
-
if (maybeIndexedSecret) {
|
|
243
|
-
newSecretsAndWindows.push({
|
|
244
|
-
secret: maybeIndexedSecret.secret,
|
|
245
|
-
// We set the left most index to the new index to avoid fetching the same logs again
|
|
246
|
-
leftMostIndex: newIndex,
|
|
247
|
-
rightMostIndex: newIndex + WINDOW_HALF_SIZE,
|
|
248
|
-
});
|
|
147
|
+
// Flatten all logs from all secrets
|
|
148
|
+
const allLogs = logArrays.flat();
|
|
249
149
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
throw new Error(
|
|
254
|
-
`Secret not found for directionalAppTaggingSecret ${directionalAppTaggingSecret}. This is a bug as it should never happen!`,
|
|
255
|
-
);
|
|
256
|
-
}
|
|
150
|
+
// Store the logs for this recipient
|
|
151
|
+
if (allLogs.length > 0) {
|
|
152
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
257
153
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
secretsAndWindows = newSecretsAndWindows;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// At this point we have processed all the logs for the recipient so we store the last used indexes in the db.
|
|
264
|
-
// newLargestIndexMapToStore contains "next" indexes to look for (one past the last found), so subtract 1 to get
|
|
265
|
-
// last used.
|
|
266
|
-
await this.recipientTaggingDataProvider.setLastUsedIndexes(
|
|
267
|
-
Object.entries(newLargestIndexMapToStore).map(([directionalAppTaggingSecret, index]) => ({
|
|
268
|
-
secret: DirectionalAppTaggingSecret.fromString(directionalAppTaggingSecret),
|
|
269
|
-
index: index - 1,
|
|
270
|
-
})),
|
|
271
|
-
);
|
|
272
|
-
}
|
|
154
|
+
}),
|
|
155
|
+
);
|
|
273
156
|
}
|
|
274
157
|
|
|
275
|
-
|
|
276
|
-
* Returns the last used tagging indexes along with the directional app tagging secrets for a given recipient and all
|
|
277
|
-
* the senders in the address book.
|
|
278
|
-
* This method should be exposed as an oracle call to allow aztec.nr to perform the orchestration
|
|
279
|
-
* of the syncTaggedLogs and processTaggedLogs methods. However, it is not possible to do so at the moment,
|
|
280
|
-
* so we're keeping it private for now.
|
|
281
|
-
* @param contractAddress - The contract address to silo the secret for
|
|
282
|
-
* @param recipient - The address receiving the notes
|
|
283
|
-
* @returns A list of directional app tagging secrets along with the last used tagging indexes. If the corresponding
|
|
284
|
-
* secret was never used, the index is undefined.
|
|
285
|
-
* TODO(#17775): The naming here is broken as the function name does not reflect the return type. Make sure this gets
|
|
286
|
-
* fixed when implementing the linked issue.
|
|
287
|
-
*/
|
|
288
|
-
protected async getLastUsedTaggingIndexesForSenders(
|
|
158
|
+
async #getSecretsForSenders(
|
|
289
159
|
contractAddress: AztecAddress,
|
|
290
160
|
recipient: AztecAddress,
|
|
291
|
-
): Promise<
|
|
161
|
+
): Promise<DirectionalAppTaggingSecret[]> {
|
|
292
162
|
const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
|
|
293
163
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
294
164
|
|
|
295
165
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
296
166
|
// (recipient = us, sender = us)
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
167
|
+
const allSenders = [...(await this.senderAddressBookStore.getSenders()), ...(await this.keyStore.getAccounts())];
|
|
168
|
+
|
|
169
|
+
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
170
|
+
const deduplicatedSenders = Array.from(new Set(allSenders.map(sender => sender.toString()))).map(sender =>
|
|
171
|
+
AztecAddress.fromString(sender),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
return Promise.all(
|
|
175
|
+
deduplicatedSenders.map(sender => {
|
|
303
176
|
return DirectionalAppTaggingSecret.compute(
|
|
304
177
|
recipientCompleteAddress,
|
|
305
178
|
recipientIvsk,
|
|
306
|
-
|
|
179
|
+
sender,
|
|
307
180
|
contractAddress,
|
|
308
181
|
recipient,
|
|
309
182
|
);
|
|
310
183
|
}),
|
|
311
184
|
);
|
|
312
|
-
const indexes = await this.recipientTaggingDataProvider.getLastUsedIndexes(secrets);
|
|
313
|
-
if (indexes.length !== secrets.length) {
|
|
314
|
-
throw new Error('Indexes and directional app tagging secrets have different lengths');
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return secrets.map((secret, i) => ({
|
|
318
|
-
secret,
|
|
319
|
-
index: indexes[i],
|
|
320
|
-
}));
|
|
321
185
|
}
|
|
322
186
|
|
|
323
|
-
|
|
187
|
+
#storePendingTaggedLogs(
|
|
324
188
|
contractAddress: AztecAddress,
|
|
325
189
|
capsuleArrayBaseSlot: Fr,
|
|
326
190
|
recipient: AztecAddress,
|
|
327
191
|
privateLogs: TxScopedL2Log[],
|
|
328
192
|
) {
|
|
329
|
-
// Build all pending tagged logs
|
|
330
|
-
const pendingTaggedLogs =
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const pendingTaggedLog = new PendingTaggedLog(
|
|
339
|
-
scopedLog.log.fields,
|
|
340
|
-
scopedLog.txHash,
|
|
341
|
-
txEffect.data.noteHashes,
|
|
342
|
-
txEffect.data.nullifiers[0],
|
|
343
|
-
recipient,
|
|
344
|
-
);
|
|
193
|
+
// Build all pending tagged logs from the scoped logs
|
|
194
|
+
const pendingTaggedLogs = privateLogs.map(scopedLog => {
|
|
195
|
+
const pendingTaggedLog = new PendingTaggedLog(
|
|
196
|
+
scopedLog.logData,
|
|
197
|
+
scopedLog.txHash,
|
|
198
|
+
scopedLog.noteHashes,
|
|
199
|
+
scopedLog.firstNullifier,
|
|
200
|
+
recipient,
|
|
201
|
+
);
|
|
345
202
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
);
|
|
203
|
+
return pendingTaggedLog.toFields();
|
|
204
|
+
});
|
|
349
205
|
|
|
350
206
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
351
|
-
return this.
|
|
207
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
352
208
|
}
|
|
353
209
|
|
|
354
210
|
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
355
|
-
const completeAddress = await this.
|
|
211
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
356
212
|
if (!completeAddress) {
|
|
357
213
|
throw new Error(
|
|
358
214
|
`No public key registered for address ${account}.
|
|
@@ -7,14 +7,15 @@ import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
8
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
10
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
11
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
12
|
|
|
13
13
|
export class NoteService {
|
|
14
14
|
constructor(
|
|
15
|
-
private readonly
|
|
15
|
+
private readonly noteStore: NoteStore,
|
|
16
16
|
private readonly aztecNode: AztecNode,
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
18
|
+
private readonly jobId: string,
|
|
18
19
|
) {}
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -33,15 +34,18 @@ export class NoteService {
|
|
|
33
34
|
status: NoteStatus,
|
|
34
35
|
scopes?: AztecAddress[],
|
|
35
36
|
) {
|
|
36
|
-
const noteDaos = await this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const noteDaos = await this.noteStore.getNotes(
|
|
38
|
+
{
|
|
39
|
+
contractAddress,
|
|
40
|
+
owner,
|
|
41
|
+
storageSlot,
|
|
42
|
+
status,
|
|
43
|
+
scopes,
|
|
44
|
+
},
|
|
45
|
+
this.jobId,
|
|
46
|
+
);
|
|
43
47
|
return noteDaos.map(
|
|
44
|
-
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier
|
|
48
|
+
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
45
49
|
contractAddress,
|
|
46
50
|
owner,
|
|
47
51
|
storageSlot,
|
|
@@ -49,9 +53,8 @@ export class NoteService {
|
|
|
49
53
|
noteNonce,
|
|
50
54
|
note,
|
|
51
55
|
noteHash,
|
|
56
|
+
isPending: false, // Note service deals only with settled notes
|
|
52
57
|
siloedNullifier,
|
|
53
|
-
// PXE can use this index to get full MembershipWitness
|
|
54
|
-
index,
|
|
55
58
|
}),
|
|
56
59
|
);
|
|
57
60
|
}
|
|
@@ -59,7 +62,7 @@ export class NoteService {
|
|
|
59
62
|
/**
|
|
60
63
|
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
61
64
|
*
|
|
62
|
-
* Fetches notes from the
|
|
65
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
63
66
|
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
64
67
|
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
65
68
|
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
@@ -69,9 +72,9 @@ export class NoteService {
|
|
|
69
72
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
70
73
|
*/
|
|
71
74
|
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
72
|
-
const
|
|
75
|
+
const anchorBlockHash = await (await this.anchorBlockStore.getBlockHeader()).hash();
|
|
73
76
|
|
|
74
|
-
const contractNotes = await this.
|
|
77
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
|
|
75
78
|
|
|
76
79
|
if (contractNotes.length === 0) {
|
|
77
80
|
return;
|
|
@@ -92,7 +95,7 @@ export class NoteService {
|
|
|
92
95
|
const nullifierIndexes = (
|
|
93
96
|
await Promise.all(
|
|
94
97
|
nullifierBatches.map(batch =>
|
|
95
|
-
this.aztecNode.findLeavesIndexes(
|
|
98
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
|
|
96
99
|
),
|
|
97
100
|
)
|
|
98
101
|
).flat();
|
|
@@ -105,10 +108,10 @@ export class NoteService {
|
|
|
105
108
|
})
|
|
106
109
|
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
107
110
|
|
|
108
|
-
await this.
|
|
111
|
+
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
public async
|
|
114
|
+
public async validateAndStoreNote(
|
|
112
115
|
contractAddress: AztecAddress,
|
|
113
116
|
owner: AztecAddress,
|
|
114
117
|
storageSlot: Fr,
|
|
@@ -120,7 +123,7 @@ export class NoteService {
|
|
|
120
123
|
txHash: TxHash,
|
|
121
124
|
recipient: AztecAddress,
|
|
122
125
|
): Promise<void> {
|
|
123
|
-
// We are going to store the new note in the
|
|
126
|
+
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
124
127
|
// There's two things we need to check before we do this however:
|
|
125
128
|
// - we must make sure the note does actually exist in the note hash tree
|
|
126
129
|
// - we need to check if the note has already been nullified
|
|
@@ -139,41 +142,33 @@ export class NoteService {
|
|
|
139
142
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
140
143
|
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
141
144
|
// logs up to the synced block making this only an additional safety check.
|
|
142
|
-
const
|
|
145
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
146
|
+
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
147
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
143
148
|
|
|
144
149
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
145
150
|
// of other contracts, which would constitute a security breach.
|
|
146
151
|
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
147
152
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
148
153
|
|
|
149
|
-
const txEffect = await
|
|
154
|
+
const [txEffect, [nullifierIndex]] = await Promise.all([
|
|
155
|
+
this.aztecNode.getTxEffect(txHash),
|
|
156
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
157
|
+
]);
|
|
150
158
|
if (!txEffect) {
|
|
151
159
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
152
160
|
}
|
|
153
161
|
|
|
154
|
-
if (txEffect.l2BlockNumber >
|
|
155
|
-
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${
|
|
162
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
163
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
156
164
|
}
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
166
|
+
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
167
|
+
const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
|
|
168
|
+
if (noteIndexInTx === -1) {
|
|
160
169
|
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
161
170
|
}
|
|
162
171
|
|
|
163
|
-
// We store notes by their index in the global note hash tree, which has the convenient side effect of validating
|
|
164
|
-
// note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
|
|
165
|
-
// queries in a single round-trip.
|
|
166
|
-
const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
|
|
167
|
-
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]),
|
|
168
|
-
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
|
|
169
|
-
]);
|
|
170
|
-
|
|
171
|
-
if (uniqueNoteHashTreeIndexInBlock === undefined) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`,
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
172
|
const noteDao = new NoteDao(
|
|
178
173
|
new Note(content),
|
|
179
174
|
contractAddress,
|
|
@@ -184,17 +179,19 @@ export class NoteService {
|
|
|
184
179
|
noteHash,
|
|
185
180
|
siloedNullifier,
|
|
186
181
|
txHash,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
182
|
+
txEffect.l2BlockNumber,
|
|
183
|
+
txEffect.l2BlockHash.toString(),
|
|
184
|
+
txEffect.txIndexInBlock,
|
|
185
|
+
noteIndexInTx,
|
|
190
186
|
);
|
|
191
187
|
|
|
192
188
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
193
|
-
await this.
|
|
189
|
+
await this.noteStore.addNotes([noteDao], recipient, this.jobId);
|
|
194
190
|
|
|
195
191
|
if (nullifierIndex !== undefined) {
|
|
192
|
+
// We found nullifier index which implies that the note has already been nullified.
|
|
196
193
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
197
|
-
await this.
|
|
194
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
|
|
198
195
|
}
|
|
199
196
|
}
|
|
200
197
|
}
|