@aztec/pxe 0.0.1-commit.b655e406 → 0.0.1-commit.c0b82b2
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/bin/check_oracle_version.d.ts +1 -1
- package/dest/bin/check_oracle_version.js +105 -15
- package/dest/block_synchronizer/block_synchronizer.d.ts +45 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +153 -0
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +6 -12
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +24 -13
- package/dest/config/package_info.d.ts +1 -1
- 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 +78 -26
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +226 -82
- package/dest/contract_function_simulator/execution_note_cache.d.ts +25 -14
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +59 -34
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +6 -6
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +4 -4
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- 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 +5 -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 +7 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
- 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 +7 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
- 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 +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +7 -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 +13 -4
- 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/index.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +30 -20
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +14 -8
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +16 -11
- package/dest/contract_function_simulator/oracle/oracle.d.ts +15 -12
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +93 -53
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -27
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +2 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +56 -52
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +120 -66
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +114 -39
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +214 -86
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- 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 +23 -5
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +45 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +48 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -1
- 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 +33 -10
- package/dest/entrypoints/client/lazy/index.d.ts +4 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -1
- 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 +34 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +7 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +6 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +5 -1
- 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 +40 -28
- 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 +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +44 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +9 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +38 -0
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +29 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +118 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +49 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +148 -0
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- 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/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 +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -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} +144 -77
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/index.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +33 -25
- package/dest/private_kernel/private_kernel_oracle.d.ts +26 -25
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +94 -2
- package/dest/pxe.d.ts +121 -103
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +268 -279
- 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} +13 -12
- 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 +17 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +10 -10
- 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 +253 -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_store/contract_store.d.ts +93 -0
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/contract_store/contract_store.js +309 -0
- 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/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
- 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/metadata.d.ts +2 -2
- package/dest/storage/metadata.js +1 -1
- 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 +83 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +343 -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 +273 -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 +111 -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 +36 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -2
- 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 +60 -0
- package/dest/tagging/index.d.ts +16 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +15 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +33 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +17 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +71 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +59 -0
- package/package.json +29 -19
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +131 -20
- package/src/block_synchronizer/block_synchronizer.ts +178 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +24 -25
- 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 +396 -116
- package/src/contract_function_simulator/execution_note_cache.ts +58 -28
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +6 -6
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +7 -3
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +15 -3
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +43 -18
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +30 -14
- package/src/contract_function_simulator/oracle/oracle.ts +111 -49
- package/src/contract_function_simulator/oracle/private_execution.ts +2 -68
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +166 -98
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +350 -91
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +93 -0
- package/src/entrypoints/client/bundle/index.ts +3 -1
- package/src/entrypoints/client/bundle/utils.ts +25 -18
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +26 -19
- package/src/entrypoints/pxe_creation_options.ts +6 -2
- package/src/entrypoints/server/index.ts +5 -1
- package/src/entrypoints/server/utils.ts +34 -56
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +71 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +46 -0
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +213 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +196 -0
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -3
- 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 +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +199 -145
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +38 -34
- package/src/private_kernel/private_kernel_oracle.ts +118 -37
- package/src/pxe.ts +410 -382
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -11
- 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_store/contract_store.ts +429 -0
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
- package/src/storage/index.ts +7 -7
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +418 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +384 -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 +143 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
- package/src/tagging/constants.ts +10 -2
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +18 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +140 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +44 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +94 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +75 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -274
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- 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/contract_function_simulator/pxe_oracle_interface.d.ts +0 -122
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -701
- 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/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/private_kernel/private_kernel_oracle_impl.d.ts +0 -45
- 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/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/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- 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 -118
- 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 +0 -74
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -205
- 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_dao.d.ts +0 -100
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -102
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -83
- 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 -308
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -43
- 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 -104
- package/dest/storage/sync_data_provider/index.d.ts +0 -2
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -10
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -35
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/synchronizer/synchronizer.js +0 -101
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -24
- package/src/contract_function_simulator/execution_data_provider.ts +0 -343
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1019
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/contract_data_provider.ts +0 -294
- 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_dao.ts +0 -154
- package/src/storage/note_data_provider/note_data_provider.ts +0 -393
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -148
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
- package/src/synchronizer/index.ts +0 -1
- package/src/synchronizer/synchronizer.ts +0 -120
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { Note } from '@aztec/stdlib/note';
|
|
6
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
|
-
|
|
8
|
-
import type { NoteData } from '../../contract_function_simulator/oracle/interfaces.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
|
|
12
|
-
* information required to use it during execution and manage its state.
|
|
13
|
-
*/
|
|
14
|
-
export class NoteDao implements NoteData {
|
|
15
|
-
constructor(
|
|
16
|
-
// Note information
|
|
17
|
-
|
|
18
|
-
/** The packed content of the note, as will be returned in the getNotes oracle. */
|
|
19
|
-
public note: Note,
|
|
20
|
-
/** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
|
|
21
|
-
public contractAddress: AztecAddress,
|
|
22
|
-
/**
|
|
23
|
-
* The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
|
|
24
|
-
* since contracts typically make queries based on it.
|
|
25
|
-
*/
|
|
26
|
-
public storageSlot: Fr,
|
|
27
|
-
/** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
|
|
28
|
-
public noteNonce: Fr,
|
|
29
|
-
|
|
30
|
-
// Computed values
|
|
31
|
-
/**
|
|
32
|
-
* The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
|
|
33
|
-
* be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
|
|
34
|
-
*/
|
|
35
|
-
public noteHash: Fr,
|
|
36
|
-
/**
|
|
37
|
-
* The nullifier of the note, siloed by contract address.
|
|
38
|
-
* Note: Might be set as 0 if the note was added to PXE as nullified.
|
|
39
|
-
*/
|
|
40
|
-
public siloedNullifier: Fr,
|
|
41
|
-
|
|
42
|
-
// Metadata
|
|
43
|
-
/** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
|
|
44
|
-
* when searching for txEffects.
|
|
45
|
-
*/
|
|
46
|
-
public txHash: TxHash,
|
|
47
|
-
/** The L2 block number in which the tx with this note was included. Used for note management while processing
|
|
48
|
-
* reorgs.*/
|
|
49
|
-
public l2BlockNumber: number,
|
|
50
|
-
/** The L2 block hash in which the tx with this note was included. Used for note management while processing
|
|
51
|
-
* reorgs.*/
|
|
52
|
-
public l2BlockHash: string,
|
|
53
|
-
/** The index of the leaf in the global note hash tree the note is stored at */
|
|
54
|
-
public index: bigint,
|
|
55
|
-
/**
|
|
56
|
-
* The address whose public key was used to encrypt the note log during delivery.
|
|
57
|
-
* (This is the x-coordinate of the public key.)
|
|
58
|
-
*/
|
|
59
|
-
public recipient: AztecAddress,
|
|
60
|
-
) {}
|
|
61
|
-
|
|
62
|
-
toBuffer(): Buffer {
|
|
63
|
-
return serializeToBuffer([
|
|
64
|
-
this.note,
|
|
65
|
-
this.contractAddress,
|
|
66
|
-
this.storageSlot,
|
|
67
|
-
this.noteNonce,
|
|
68
|
-
this.noteHash,
|
|
69
|
-
this.siloedNullifier,
|
|
70
|
-
this.txHash,
|
|
71
|
-
this.l2BlockNumber,
|
|
72
|
-
Fr.fromHexString(this.l2BlockHash),
|
|
73
|
-
this.index,
|
|
74
|
-
this.recipient,
|
|
75
|
-
]);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
79
|
-
const reader = BufferReader.asReader(buffer);
|
|
80
|
-
|
|
81
|
-
const note = Note.fromBuffer(reader);
|
|
82
|
-
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
83
|
-
const storageSlot = Fr.fromBuffer(reader);
|
|
84
|
-
const noteNonce = Fr.fromBuffer(reader);
|
|
85
|
-
const noteHash = Fr.fromBuffer(reader);
|
|
86
|
-
const siloedNullifier = Fr.fromBuffer(reader);
|
|
87
|
-
const txHash = reader.readObject(TxHash);
|
|
88
|
-
const l2BlockNumber = reader.readNumber();
|
|
89
|
-
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
90
|
-
const index = toBigIntBE(reader.readBytes(32));
|
|
91
|
-
const recipient = AztecAddress.fromBuffer(reader);
|
|
92
|
-
|
|
93
|
-
return new NoteDao(
|
|
94
|
-
note,
|
|
95
|
-
contractAddress,
|
|
96
|
-
storageSlot,
|
|
97
|
-
noteNonce,
|
|
98
|
-
noteHash,
|
|
99
|
-
siloedNullifier,
|
|
100
|
-
txHash,
|
|
101
|
-
l2BlockNumber,
|
|
102
|
-
l2BlockHash,
|
|
103
|
-
index,
|
|
104
|
-
recipient,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
toString() {
|
|
109
|
-
return '0x' + this.toBuffer().toString('hex');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
static fromString(str: string) {
|
|
113
|
-
const hex = str.replace(/^0x/, '');
|
|
114
|
-
return NoteDao.fromBuffer(Buffer.from(hex, 'hex'));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Returns the size in bytes of the Note Dao.
|
|
119
|
-
* @returns - Its size in bytes.
|
|
120
|
-
*/
|
|
121
|
-
public getSize() {
|
|
122
|
-
const indexSize = Math.ceil(Math.log2(Number(this.index)));
|
|
123
|
-
const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
|
|
124
|
-
return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
static async random({
|
|
128
|
-
note = Note.random(),
|
|
129
|
-
contractAddress = undefined,
|
|
130
|
-
storageSlot = Fr.random(),
|
|
131
|
-
noteNonce = Fr.random(),
|
|
132
|
-
noteHash = Fr.random(),
|
|
133
|
-
siloedNullifier = Fr.random(),
|
|
134
|
-
txHash = TxHash.random(),
|
|
135
|
-
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
136
|
-
l2BlockHash = Fr.random().toString(),
|
|
137
|
-
index = Fr.random().toBigInt(),
|
|
138
|
-
recipient = undefined,
|
|
139
|
-
}: Partial<NoteDao> = {}) {
|
|
140
|
-
return new NoteDao(
|
|
141
|
-
note,
|
|
142
|
-
contractAddress ?? (await AztecAddress.random()),
|
|
143
|
-
storageSlot,
|
|
144
|
-
noteNonce,
|
|
145
|
-
noteHash,
|
|
146
|
-
siloedNullifier,
|
|
147
|
-
txHash,
|
|
148
|
-
l2BlockNumber,
|
|
149
|
-
l2BlockHash,
|
|
150
|
-
index,
|
|
151
|
-
recipient ?? (await AztecAddress.random()),
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
4
|
-
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type { InBlock } from '@aztec/stdlib/block';
|
|
7
|
-
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
8
|
-
|
|
9
|
-
import { NoteDao } from './note_dao.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* NoteDataProvider manages the storage and retrieval of notes.
|
|
13
|
-
*
|
|
14
|
-
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
15
|
-
* and performs rollback handling in the case of a reorg.
|
|
16
|
-
**/
|
|
17
|
-
export class NoteDataProvider {
|
|
18
|
-
#store: AztecAsyncKVStore;
|
|
19
|
-
#notes: AztecAsyncMap<string, Buffer>;
|
|
20
|
-
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
21
|
-
#nullifierToNoteId: AztecAsyncMap<string, string>;
|
|
22
|
-
#nullifiersByBlockNumber: AztecAsyncMultiMap<number, string>;
|
|
23
|
-
|
|
24
|
-
#nullifiedNotesToScope: AztecAsyncMultiMap<string, string>;
|
|
25
|
-
#nullifiedNotesByContract: AztecAsyncMultiMap<string, string>;
|
|
26
|
-
#nullifiedNotesByStorageSlot: AztecAsyncMultiMap<string, string>;
|
|
27
|
-
#nullifiedNotesByNullifier: AztecAsyncMap<string, string>;
|
|
28
|
-
|
|
29
|
-
#scopes: AztecAsyncMap<string, true>;
|
|
30
|
-
#notesToScope: AztecAsyncMultiMap<string, string>;
|
|
31
|
-
#notesByContractAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
32
|
-
#notesByStorageSlotAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
33
|
-
|
|
34
|
-
private constructor(store: AztecAsyncKVStore) {
|
|
35
|
-
this.#store = store;
|
|
36
|
-
this.#notes = store.openMap('notes');
|
|
37
|
-
this.#nullifiedNotes = store.openMap('nullified_notes');
|
|
38
|
-
this.#nullifierToNoteId = store.openMap('nullifier_to_note');
|
|
39
|
-
this.#nullifiersByBlockNumber = store.openMultiMap('nullifier_to_block_number');
|
|
40
|
-
|
|
41
|
-
this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
|
|
42
|
-
this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
|
|
43
|
-
this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
|
|
44
|
-
this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
|
|
45
|
-
|
|
46
|
-
this.#scopes = store.openMap('scopes');
|
|
47
|
-
this.#notesToScope = store.openMultiMap('notes_to_scope');
|
|
48
|
-
this.#notesByContractAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
49
|
-
this.#notesByStorageSlotAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Creates and initializes a new NoteDataProvider instance.
|
|
54
|
-
*
|
|
55
|
-
* This factory method creates a NoteDataProvider and restores any existing
|
|
56
|
-
* scope-specific indexes from the database.
|
|
57
|
-
*
|
|
58
|
-
* @param store - The key-value store to use for persistence
|
|
59
|
-
* @returns Promise resolving to a fully initialized NoteDataProvider instance
|
|
60
|
-
*/
|
|
61
|
-
public static async create(store: AztecAsyncKVStore): Promise<NoteDataProvider> {
|
|
62
|
-
const pxeDB = new NoteDataProvider(store);
|
|
63
|
-
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
64
|
-
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
65
|
-
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
66
|
-
}
|
|
67
|
-
return pxeDB;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Adds a new scope to the note data provider.
|
|
72
|
-
*
|
|
73
|
-
* Scopes provide privacy isolation by creating separate indexes for each user.
|
|
74
|
-
* Each scope gets its own set of indexes for efficient note retrieval by various criteria.
|
|
75
|
-
*
|
|
76
|
-
* @param scope - The AztecAddress representing the scope/user to add
|
|
77
|
-
* @returns Promise resolving to true if scope was added, false if it already existed
|
|
78
|
-
*/
|
|
79
|
-
public async addScope(scope: AztecAddress): Promise<boolean> {
|
|
80
|
-
const scopeString = scope.toString();
|
|
81
|
-
|
|
82
|
-
if (await this.#scopes.hasAsync(scopeString)) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
await this.#scopes.set(scopeString, true);
|
|
87
|
-
this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
88
|
-
this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
89
|
-
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Adds multiple notes to the data provider under the specified scope.
|
|
95
|
-
*
|
|
96
|
-
* Notes are stored using their index from the notes hash tree as the key, which provides
|
|
97
|
-
* uniqueness and maintains creation order. Each note is indexed by multiple criteria
|
|
98
|
-
* for efficient retrieval.
|
|
99
|
-
*
|
|
100
|
-
* @param notes - Notes to store
|
|
101
|
-
* @param scope - The scope (user/account) under which to store the notes
|
|
102
|
-
*/
|
|
103
|
-
addNotes(notes: NoteDao[], scope: AztecAddress): Promise<void> {
|
|
104
|
-
return this.#store.transactionAsync(async () => {
|
|
105
|
-
if (!(await this.#scopes.hasAsync(scope.toString()))) {
|
|
106
|
-
await this.addScope(scope);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
for (const dao of notes) {
|
|
110
|
-
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
111
|
-
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
112
|
-
await this.#notesToScope.set(noteIndex, scope.toString());
|
|
113
|
-
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
114
|
-
|
|
115
|
-
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
116
|
-
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Synchronizes notes and nullifiers to a specific block number.
|
|
123
|
-
*
|
|
124
|
-
* This method ensures that the state of notes and nullifiers is consistent with the
|
|
125
|
-
* specified block number. It restores any notes that were nullified after the given block
|
|
126
|
-
* and deletes any active notes created after that block.
|
|
127
|
-
*
|
|
128
|
-
* @param blockNumber - The new chain tip after a reorg
|
|
129
|
-
* @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
|
|
130
|
-
*/
|
|
131
|
-
public async rollbackNotesAndNullifiers(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
132
|
-
await this.#rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber);
|
|
133
|
-
await this.#deleteActiveNotesAfterBlock(blockNumber);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Deletes (removes) all active notes created after the specified block number.
|
|
138
|
-
*
|
|
139
|
-
* Permanently delete notes from the active notes store, e.g. during a reorg.
|
|
140
|
-
* Note: This only affects #notes (active notes), not #nullifiedNotes.
|
|
141
|
-
*
|
|
142
|
-
* @param blockNumber - Notes created after this block number will be deleted
|
|
143
|
-
*/
|
|
144
|
-
#deleteActiveNotesAfterBlock(blockNumber: number): Promise<void> {
|
|
145
|
-
return this.#store.transactionAsync(async () => {
|
|
146
|
-
const notes = await toArray(this.#notes.valuesAsync());
|
|
147
|
-
for (const note of notes) {
|
|
148
|
-
const noteDao = NoteDao.fromBuffer(note);
|
|
149
|
-
if (noteDao.l2BlockNumber > blockNumber) {
|
|
150
|
-
const noteIndex = toBufferBE(noteDao.index, 32).toString('hex');
|
|
151
|
-
await this.#notes.delete(noteIndex);
|
|
152
|
-
await this.#notesToScope.delete(noteIndex);
|
|
153
|
-
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
154
|
-
const scopes = await toArray(this.#scopes.keysAsync());
|
|
155
|
-
for (const scope of scopes) {
|
|
156
|
-
await this.#notesByContractAndScope.get(scope)!.deleteValue(noteDao.contractAddress.toString(), noteIndex);
|
|
157
|
-
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(noteDao.storageSlot.toString(), noteIndex);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Rewinds nullifications after a given block number.
|
|
166
|
-
*
|
|
167
|
-
* This operation "unnullifies" notes, rolling back nullifications that occurred
|
|
168
|
-
* in orphaned blocks, e.g. during a reorg. The notes are restored to the
|
|
169
|
-
* active notes store and removed from the nullified store.
|
|
170
|
-
*
|
|
171
|
-
* @param blockNumber - Revert nullifications that occurred after this block
|
|
172
|
-
* @param synchedBlockNumber - Upper bound for the block range to process
|
|
173
|
-
*/
|
|
174
|
-
async #rewindNullifiersAfterBlock(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
175
|
-
await this.#store.transactionAsync(async () => {
|
|
176
|
-
const nullifiersToUndo: string[] = [];
|
|
177
|
-
const currentBlockNumber = blockNumber + 1;
|
|
178
|
-
for (let i = currentBlockNumber; i <= synchedBlockNumber; i++) {
|
|
179
|
-
nullifiersToUndo.push(...(await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i))));
|
|
180
|
-
}
|
|
181
|
-
const notesIndexesToReinsert = await Promise.all(
|
|
182
|
-
nullifiersToUndo.map(nullifier => this.#nullifiedNotesByNullifier.getAsync(nullifier)),
|
|
183
|
-
);
|
|
184
|
-
const notNullNoteIndexes = notesIndexesToReinsert.filter(noteIndex => noteIndex != undefined);
|
|
185
|
-
const nullifiedNoteBuffers = await Promise.all(
|
|
186
|
-
notNullNoteIndexes.map(noteIndex => this.#nullifiedNotes.getAsync(noteIndex!)),
|
|
187
|
-
);
|
|
188
|
-
const noteDaos = nullifiedNoteBuffers
|
|
189
|
-
.filter(buffer => buffer != undefined)
|
|
190
|
-
.map(buffer => NoteDao.fromBuffer(buffer!));
|
|
191
|
-
|
|
192
|
-
for (const dao of noteDaos) {
|
|
193
|
-
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
194
|
-
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
195
|
-
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
196
|
-
|
|
197
|
-
let scopes = (await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex))) ?? [];
|
|
198
|
-
|
|
199
|
-
if (scopes.length === 0) {
|
|
200
|
-
scopes = [dao.recipient.toString()];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
for (const scope of scopes) {
|
|
204
|
-
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
205
|
-
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
206
|
-
await this.#notesToScope.set(noteIndex, scope);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
await this.#nullifiedNotes.delete(noteIndex);
|
|
210
|
-
await this.#nullifiedNotesToScope.delete(noteIndex);
|
|
211
|
-
await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
|
|
212
|
-
await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
|
|
213
|
-
await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
|
|
214
|
-
await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Retrieves notes based on the provided filter criteria.
|
|
221
|
-
*
|
|
222
|
-
* This method queries both active and optionally nullified notes based on the filter
|
|
223
|
-
* parameters.
|
|
224
|
-
*
|
|
225
|
-
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
226
|
-
* storageSlot, status, scopes and siloedNullifier.
|
|
227
|
-
* @returns Promise resolving to array of NoteDao objects matching the filter
|
|
228
|
-
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
229
|
-
*/
|
|
230
|
-
async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
231
|
-
filter.status = filter.status ?? NoteStatus.ACTIVE;
|
|
232
|
-
|
|
233
|
-
// throw early if scopes is an empty array
|
|
234
|
-
if (filter.scopes !== undefined && filter.scopes.length === 0) {
|
|
235
|
-
throw new Error(
|
|
236
|
-
'Trying to get notes with an empty scopes array. Scopes have to be set to undefined if intending on not filtering by scopes.',
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const candidateNoteSources = [];
|
|
241
|
-
|
|
242
|
-
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map(addressString =>
|
|
243
|
-
AztecAddress.fromString(addressString),
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
const activeNoteIdsPerScope: string[][] = [];
|
|
247
|
-
|
|
248
|
-
for (const scope of new Set(filter.scopes)) {
|
|
249
|
-
const formattedScopeString = scope.toString();
|
|
250
|
-
if (!(await this.#scopes.hasAsync(formattedScopeString))) {
|
|
251
|
-
throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
activeNoteIdsPerScope.push(
|
|
255
|
-
filter.storageSlot
|
|
256
|
-
? await toArray(
|
|
257
|
-
this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValuesAsync(filter.storageSlot.toString()),
|
|
258
|
-
)
|
|
259
|
-
: await toArray(
|
|
260
|
-
this.#notesByContractAndScope
|
|
261
|
-
.get(formattedScopeString)!
|
|
262
|
-
.getValuesAsync(filter.contractAddress.toString()),
|
|
263
|
-
),
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
candidateNoteSources.push({
|
|
268
|
-
ids: new Set(activeNoteIdsPerScope.flat()),
|
|
269
|
-
notes: this.#notes,
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
// If status is ACTIVE_OR_NULLIFIED we add nullified notes as candidates on top of the default active ones.
|
|
273
|
-
if (filter.status === NoteStatus.ACTIVE_OR_NULLIFIED) {
|
|
274
|
-
const nullifiedIds = filter.storageSlot
|
|
275
|
-
? await toArray(this.#nullifiedNotesByStorageSlot.getValuesAsync(filter.storageSlot.toString()))
|
|
276
|
-
: await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString()));
|
|
277
|
-
|
|
278
|
-
const setOfScopes = new Set(filter.scopes.map(s => s.toString() as string));
|
|
279
|
-
const filteredNullifiedIds = new Set<string>();
|
|
280
|
-
|
|
281
|
-
for (const noteId of nullifiedIds) {
|
|
282
|
-
const scopeList = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteId));
|
|
283
|
-
if (scopeList.some(scope => setOfScopes.has(scope))) {
|
|
284
|
-
filteredNullifiedIds.add(noteId);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (filteredNullifiedIds.size > 0) {
|
|
289
|
-
candidateNoteSources.push({
|
|
290
|
-
ids: filteredNullifiedIds,
|
|
291
|
-
notes: this.#nullifiedNotes,
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const result: NoteDao[] = [];
|
|
297
|
-
for (const { ids, notes } of candidateNoteSources) {
|
|
298
|
-
for (const id of ids) {
|
|
299
|
-
const serializedNote = await notes.getAsync(id);
|
|
300
|
-
if (!serializedNote) {
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const note = NoteDao.fromBuffer(serializedNote);
|
|
305
|
-
if (!note.contractAddress.equals(filter.contractAddress)) {
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) {
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
result.push(note);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return result;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Transitions notes from "active" to "nullified" state.
|
|
326
|
-
*
|
|
327
|
-
* This operation processes a batch of nullifiers to mark the corresponding notes
|
|
328
|
-
* as spent/nullified. The operation is atomic - if any nullifier is not found,
|
|
329
|
-
* the entire operation fails and no notes are modified.
|
|
330
|
-
*
|
|
331
|
-
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
332
|
-
* @returns Promise resolving to array of nullified NoteDao objects
|
|
333
|
-
* @throws Error if any nullifier is not found in the active notes
|
|
334
|
-
*/
|
|
335
|
-
applyNullifiers(nullifiers: InBlock<Fr>[]): Promise<NoteDao[]> {
|
|
336
|
-
if (nullifiers.length === 0) {
|
|
337
|
-
return Promise.resolve([]);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return this.#store.transactionAsync(async () => {
|
|
341
|
-
const nullifiedNotes: NoteDao[] = [];
|
|
342
|
-
|
|
343
|
-
for (const blockScopedNullifier of nullifiers) {
|
|
344
|
-
const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
|
|
345
|
-
const nullifierKey = nullifier.toString();
|
|
346
|
-
|
|
347
|
-
const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
|
|
348
|
-
if (!noteIndex) {
|
|
349
|
-
// Check if already nullified?
|
|
350
|
-
const alreadyNullified = await this.#nullifiedNotesByNullifier.getAsync(nullifierKey);
|
|
351
|
-
if (alreadyNullified) {
|
|
352
|
-
throw new Error(`Nullifier already applied in applyNullifiers`);
|
|
353
|
-
}
|
|
354
|
-
throw new Error('Nullifier not found in applyNullifiers');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
|
|
358
|
-
|
|
359
|
-
if (!noteBuffer) {
|
|
360
|
-
throw new Error('Note not found in applyNullifiers');
|
|
361
|
-
}
|
|
362
|
-
const noteScopes = (await toArray(this.#notesToScope.getValuesAsync(noteIndex))) ?? [];
|
|
363
|
-
const note = NoteDao.fromBuffer(noteBuffer);
|
|
364
|
-
|
|
365
|
-
nullifiedNotes.push(note);
|
|
366
|
-
|
|
367
|
-
await this.#notes.delete(noteIndex);
|
|
368
|
-
await this.#notesToScope.delete(noteIndex);
|
|
369
|
-
|
|
370
|
-
const scopes = await toArray(this.#scopes.keysAsync());
|
|
371
|
-
|
|
372
|
-
for (const scope of scopes) {
|
|
373
|
-
await this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex);
|
|
374
|
-
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (noteScopes !== undefined) {
|
|
378
|
-
for (const scope of noteScopes) {
|
|
379
|
-
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
383
|
-
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
384
|
-
await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
|
|
385
|
-
await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
|
|
386
|
-
await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
|
|
387
|
-
|
|
388
|
-
await this.#nullifierToNoteId.delete(nullifier.toString());
|
|
389
|
-
}
|
|
390
|
-
return nullifiedNotes;
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
|
-
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
6
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
8
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
9
|
-
|
|
10
|
-
interface PrivateEventEntry {
|
|
11
|
-
msgContent: Buffer;
|
|
12
|
-
blockNumber: number;
|
|
13
|
-
blockHash: Buffer;
|
|
14
|
-
eventCommitmentIndex: number;
|
|
15
|
-
txHash: Buffer;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type PrivateEvent = {
|
|
19
|
-
msgContent: Fr[];
|
|
20
|
-
blockNumber: number;
|
|
21
|
-
blockHash: L2BlockHash;
|
|
22
|
-
txHash: TxHash;
|
|
23
|
-
recipient: AztecAddress;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Stores decrypted private event logs.
|
|
28
|
-
*/
|
|
29
|
-
export class PrivateEventDataProvider {
|
|
30
|
-
#store: AztecAsyncKVStore;
|
|
31
|
-
/** Array storing the actual private event log entries containing the log content and block number */
|
|
32
|
-
#eventLogs: AztecAsyncArray<PrivateEventEntry>;
|
|
33
|
-
/** Map from contract_address_recipient_eventSelector to array of indices into #eventLogs for efficient lookup */
|
|
34
|
-
#eventLogIndex: AztecAsyncMap<string, number[]>;
|
|
35
|
-
/** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
|
|
36
|
-
#seenLogs: AztecAsyncMap<number, boolean>;
|
|
37
|
-
|
|
38
|
-
logger = createLogger('private_event_data_provider');
|
|
39
|
-
|
|
40
|
-
constructor(store: AztecAsyncKVStore) {
|
|
41
|
-
this.#store = store;
|
|
42
|
-
this.#eventLogs = this.#store.openArray('private_event_logs');
|
|
43
|
-
this.#eventLogIndex = this.#store.openMap('private_event_log_index');
|
|
44
|
-
this.#seenLogs = this.#store.openMap('seen_logs');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Store a private event log.
|
|
49
|
-
* @param contractAddress - The address of the contract that emitted the event.
|
|
50
|
-
* @param recipient - The recipient of the event.
|
|
51
|
-
* @param eventSelector - The event selector of the event.
|
|
52
|
-
* @param msgContent - The content of the event.
|
|
53
|
-
* @param txHash - The transaction hash of the event log.
|
|
54
|
-
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
55
|
-
* @param blockNumber - The block number in which the event was emitted.
|
|
56
|
-
*/
|
|
57
|
-
storePrivateEventLog(
|
|
58
|
-
contractAddress: AztecAddress,
|
|
59
|
-
recipient: AztecAddress,
|
|
60
|
-
eventSelector: EventSelector,
|
|
61
|
-
msgContent: Fr[],
|
|
62
|
-
txHash: TxHash,
|
|
63
|
-
eventCommitmentIndex: number,
|
|
64
|
-
blockNumber: number,
|
|
65
|
-
blockHash: L2BlockHash,
|
|
66
|
-
): Promise<void> {
|
|
67
|
-
return this.#store.transactionAsync(async () => {
|
|
68
|
-
const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
|
|
69
|
-
|
|
70
|
-
// Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
|
|
71
|
-
const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
|
|
72
|
-
if (hasBeenSeen) {
|
|
73
|
-
this.logger.verbose('Ignoring duplicate event log', { txHash: txHash.toString(), eventCommitmentIndex });
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.logger.verbose('storing private event log', { contractAddress, recipient, msgContent, blockNumber });
|
|
78
|
-
|
|
79
|
-
const index = await this.#eventLogs.lengthAsync();
|
|
80
|
-
await this.#eventLogs.push({
|
|
81
|
-
msgContent: serializeToBuffer(msgContent),
|
|
82
|
-
blockNumber,
|
|
83
|
-
blockHash: blockHash.toBuffer(),
|
|
84
|
-
eventCommitmentIndex,
|
|
85
|
-
txHash: txHash.toBuffer(),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const existingIndices = (await this.#eventLogIndex.getAsync(key)) || [];
|
|
89
|
-
await this.#eventLogIndex.set(key, [...existingIndices, index]);
|
|
90
|
-
|
|
91
|
-
// Mark this log as seen using eventCommitmentIndex
|
|
92
|
-
await this.#seenLogs.set(eventCommitmentIndex, true);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Returns the private events given search parameters.
|
|
98
|
-
* @param contractAddress - The address of the contract to get events from.
|
|
99
|
-
* @param from - The block number to search from.
|
|
100
|
-
* @param numBlocks - The amount of blocks to search.
|
|
101
|
-
* @param recipients - The addresses that decrypted the logs.
|
|
102
|
-
* @param eventSelector - The event selector to filter by.
|
|
103
|
-
* @returns - The event log contents.
|
|
104
|
-
*/
|
|
105
|
-
public async getPrivateEvents(
|
|
106
|
-
contractAddress: AztecAddress,
|
|
107
|
-
from: number,
|
|
108
|
-
numBlocks: number,
|
|
109
|
-
recipients: AztecAddress[],
|
|
110
|
-
eventSelector: EventSelector,
|
|
111
|
-
): Promise<PrivateEvent[]> {
|
|
112
|
-
const events: Array<{ eventCommitmentIndex: number; event: PrivateEvent }> = [];
|
|
113
|
-
|
|
114
|
-
for (const recipient of recipients) {
|
|
115
|
-
const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
|
|
116
|
-
const indices = (await this.#eventLogIndex.getAsync(key)) || [];
|
|
117
|
-
|
|
118
|
-
for (const index of indices) {
|
|
119
|
-
const entry = await this.#eventLogs.atAsync(index);
|
|
120
|
-
if (!entry || entry.blockNumber < from || entry.blockNumber >= from + numBlocks) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Convert buffer back to Fr array
|
|
125
|
-
const reader = BufferReader.asReader(entry.msgContent);
|
|
126
|
-
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
127
|
-
const msgContent = reader.readArray(numFields, Fr);
|
|
128
|
-
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
129
|
-
const blockHash = L2BlockHash.fromBuffer(entry.blockHash);
|
|
130
|
-
|
|
131
|
-
events.push({
|
|
132
|
-
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
133
|
-
event: {
|
|
134
|
-
msgContent,
|
|
135
|
-
blockNumber: entry.blockNumber,
|
|
136
|
-
recipient,
|
|
137
|
-
txHash,
|
|
138
|
-
blockHash,
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Sort by eventCommitmentIndex only
|
|
145
|
-
events.sort((a, b) => a.eventCommitmentIndex - b.eventCommitmentIndex);
|
|
146
|
-
return events.map(ev => ev.event);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SyncDataProvider } from './sync_data_provider.js';
|