@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.0658669b3
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.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +17 -11
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +80 -34
- 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 +65 -40
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +209 -89
- 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 +7 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- 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 +2 -2
- 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 +17 -13
- 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 +12 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +67 -44
- 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 +46 -46
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +88 -56
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +82 -48
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +141 -120
- 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_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 +26 -12
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +30 -19
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- 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 +31 -8
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +32 -9
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -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 +39 -16
- 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 -8
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +21 -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 +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 +18 -32
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +76 -197
- package/dest/notes/note_service.d.ts +13 -12
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +42 -46
- 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} +141 -74
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +24 -17
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -24
- 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 +85 -66
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +203 -185
- 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/{anchor_block_data_provider/anchor_block_data_provider.js → anchor_block_store/anchor_block_store.js} +9 -2
- 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/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 +1 -1
- 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_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_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 -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 +60 -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 +12 -12
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- 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 +27 -18
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +99 -46
- 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 +363 -153
- 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 +6 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +22 -12
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +79 -47
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +121 -135
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +217 -132
- package/src/contract_function_simulator/proxied_contract_data_source.ts +7 -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 +65 -20
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +23 -16
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +24 -17
- package/src/entrypoints/pxe_creation_options.ts +4 -2
- package/src/entrypoints/server/index.ts +4 -0
- package/src/entrypoints/server/utils.ts +33 -41
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +22 -28
- package/src/events/private_event_filter_validator.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +118 -274
- package/src/notes/note_service.ts +45 -49
- 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} +196 -138
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +27 -19
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +331 -257
- 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/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +9 -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_store/contract_store.ts +429 -0
- package/src/storage/contract_store/index.ts +1 -0
- 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 +139 -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 -3
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +17 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +27 -13
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- 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/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 -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 +0 -66
- 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 -224
- 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/storage/tagging_data_provider/sender_tagging_data_provider.js +0 -196
- 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/contract_data_provider.ts +0 -319
- 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/storage/tagging_data_provider/sender_tagging_data_provider.ts +0 -244
- 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
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
2
|
-
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
3
|
-
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
4
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
|
-
|
|
6
|
-
import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../../tagging/sync/sync_sender_tagging_indexes.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Data provider of tagging data used when syncing the sender tagging indexes. The recipient counterpart of this class
|
|
10
|
-
* is called RecipientTaggingDataProvider. We have the providers separate for the sender and recipient because
|
|
11
|
-
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
12
|
-
*/
|
|
13
|
-
export class SenderTaggingDataProvider {
|
|
14
|
-
#store: AztecAsyncKVStore;
|
|
15
|
-
|
|
16
|
-
// Stores the pending indexes for each directional app tagging secret. Pending here means that the tx that contained
|
|
17
|
-
// the private logs with tags corresponding to these indexes has not been finalized yet.
|
|
18
|
-
//
|
|
19
|
-
// We don't store just the highest index because if their transaction is dropped we'd then need the information about
|
|
20
|
-
// the lower pending indexes. For each secret-tx pair however we only store the largest index used in that tx, since
|
|
21
|
-
// the smaller ones are irrelevant due to tx atomicity.
|
|
22
|
-
//
|
|
23
|
-
// TODO(#17615): This assumes no logs are used in the non-revertible phase.
|
|
24
|
-
#pendingIndexes: AztecAsyncMap<string, { index: number; txHash: string }[]>;
|
|
25
|
-
|
|
26
|
-
// Stores the last (highest) finalized index for each directional app tagging secret. We care only about the last
|
|
27
|
-
// index because unlike the pending indexes, it will never happen that a finalized index would be removed and hence
|
|
28
|
-
// we don't need to store the history.
|
|
29
|
-
#lastFinalizedIndexes: AztecAsyncMap<string, number>;
|
|
30
|
-
|
|
31
|
-
constructor(store: AztecAsyncKVStore) {
|
|
32
|
-
this.#store = store;
|
|
33
|
-
|
|
34
|
-
this.#pendingIndexes = this.#store.openMap('pending_indexes');
|
|
35
|
-
this.#lastFinalizedIndexes = this.#store.openMap('last_finalized_indexes');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Stores pending indexes.
|
|
40
|
-
* @remarks Ignores the index if the same preTag + txHash combination already exists in the db with the same index.
|
|
41
|
-
* This is expected to happen because whenever we start sync we start from the last finalized index and we can have
|
|
42
|
-
* pending indexes already stored from previous syncs.
|
|
43
|
-
* @param preTags - The pre-tags containing the directional app tagging secrets and the indexes that are to be
|
|
44
|
-
* stored in the db.
|
|
45
|
-
* @param txHash - The tx in which the pretags were used in private logs.
|
|
46
|
-
* @throws If any two pre-tags contain the same directional app tagging secret. This is enforced because we care
|
|
47
|
-
* only about the highest index for a given secret that was used in the tx. Hence this check is a good way to catch
|
|
48
|
-
* bugs.
|
|
49
|
-
* @throws If the newly stored pending index is further than window length from the highest finalized index for the
|
|
50
|
-
* same secret. This is enforced in order to give a guarantee to a recipient that he doesn't need to look further than
|
|
51
|
-
* window length ahead of the highest finalized index.
|
|
52
|
-
* @throws If a secret + txHash pair already exists in the db with a different index value. It should never happen
|
|
53
|
-
* that we would attempt to store a different index for a given secret-txHash pair because we always store just the
|
|
54
|
-
* highest index for a given secret-txHash pair. Hence this is a good way to catch bugs.
|
|
55
|
-
* @throws If the newly stored pending index is lower than or equal to the last finalized index for the same secret.
|
|
56
|
-
* This is enforced because this should never happen if the syncing is done correctly as we look for logs from higher
|
|
57
|
-
* indexes than finalized ones.
|
|
58
|
-
*/
|
|
59
|
-
async storePendingIndexes(preTags: PreTag[], txHash: TxHash) {
|
|
60
|
-
// The secrets in pre-tags should be unique because we always store just the highest index per given secret-txHash
|
|
61
|
-
// pair. Below we check that this is the case.
|
|
62
|
-
const secretsSet = new Set(preTags.map(preTag => preTag.secret.toString()));
|
|
63
|
-
if (secretsSet.size !== preTags.length) {
|
|
64
|
-
throw new Error(`Duplicate secrets found when storing pending indexes`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
for (const { secret, index } of preTags) {
|
|
68
|
-
// First we check that for any secret the highest used index in tx is not further than window length from
|
|
69
|
-
// the highest finalized index.
|
|
70
|
-
const finalizedIndex = (await this.getLastFinalizedIndex(secret)) ?? 0;
|
|
71
|
-
if (index > finalizedIndex + UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
`Highest used index ${index} is further than window length from the highest finalized index ${finalizedIndex}.
|
|
74
|
-
Tagging window length ${UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN} is configured too low. Contact the Aztec team
|
|
75
|
-
to increase it!`,
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Throw if the new pending index is lower than or equal to the last finalized index
|
|
80
|
-
const secretStr = secret.toString();
|
|
81
|
-
const lastFinalizedIndex = await this.#lastFinalizedIndexes.getAsync(secretStr);
|
|
82
|
-
if (lastFinalizedIndex !== undefined && index <= lastFinalizedIndex) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`Cannot store pending index ${index} for secret ${secretStr}: ` +
|
|
85
|
-
`it is lower than or equal to the last finalized index ${lastFinalizedIndex}`,
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Check if this secret + txHash combination already exists
|
|
90
|
-
const txHashStr = txHash.toString();
|
|
91
|
-
const existingForSecret = (await this.#pendingIndexes.getAsync(secretStr)) ?? [];
|
|
92
|
-
const existingForSecretAndTx = existingForSecret.find(entry => entry.txHash === txHashStr);
|
|
93
|
-
|
|
94
|
-
if (existingForSecretAndTx) {
|
|
95
|
-
// If it exists with a different index, throw an error
|
|
96
|
-
if (existingForSecretAndTx.index !== index) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`Cannot store index ${index} for secret ${secretStr} and txHash ${txHashStr}: ` +
|
|
99
|
-
`a different index ${existingForSecretAndTx.index} already exists for this secret-txHash pair`,
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
// If it exists with the same index, ignore the update (no-op)
|
|
103
|
-
} else {
|
|
104
|
-
// If it doesn't exist, add it
|
|
105
|
-
await this.#pendingIndexes.set(secretStr, [...existingForSecret, { index, txHash: txHashStr }]);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Returns the transaction hashes of all pending transactions that contain indexes within a specified range
|
|
112
|
-
* for a given directional app tagging secret.
|
|
113
|
-
* @param secret - The directional app tagging secret to query pending indexes for.
|
|
114
|
-
* @param startIndex - The lower bound of the index range (inclusive).
|
|
115
|
-
* @param endIndex - The upper bound of the index range (exclusive).
|
|
116
|
-
* @returns An array of unique transaction hashes for pending transactions that contain indexes in the range
|
|
117
|
-
* [startIndex, endIndex). Returns an empty array if no pending indexes exist in the range.
|
|
118
|
-
*/
|
|
119
|
-
async getTxHashesOfPendingIndexes(
|
|
120
|
-
secret: DirectionalAppTaggingSecret,
|
|
121
|
-
startIndex: number,
|
|
122
|
-
endIndex: number,
|
|
123
|
-
): Promise<TxHash[]> {
|
|
124
|
-
const existing = (await this.#pendingIndexes.getAsync(secret.toString())) ?? [];
|
|
125
|
-
const txHashes = existing
|
|
126
|
-
.filter(entry => entry.index >= startIndex && entry.index < endIndex)
|
|
127
|
-
.map(entry => entry.txHash);
|
|
128
|
-
return Array.from(new Set(txHashes)).map(TxHash.fromString);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns the last (highest) finalized index for a given secret.
|
|
133
|
-
* @param secret - The secret to get the last finalized index for.
|
|
134
|
-
* @returns The last (highest) finalized index for the given secret.
|
|
135
|
-
*/
|
|
136
|
-
getLastFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
137
|
-
return this.#lastFinalizedIndexes.getAsync(secret.toString());
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Returns the last used index for a given directional app tagging secret, considering both finalized and pending
|
|
142
|
-
* indexes.
|
|
143
|
-
* @param secret - The directional app tagging secret to query the last used index for.
|
|
144
|
-
* @returns The last used index.
|
|
145
|
-
*/
|
|
146
|
-
async getLastUsedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
147
|
-
const secretStr = secret.toString();
|
|
148
|
-
const pendingTxScopedIndexes = (await this.#pendingIndexes.getAsync(secretStr)) ?? [];
|
|
149
|
-
const pendingIndexes = pendingTxScopedIndexes.map(entry => entry.index);
|
|
150
|
-
|
|
151
|
-
if (pendingTxScopedIndexes.length === 0) {
|
|
152
|
-
return this.#lastFinalizedIndexes.getAsync(secretStr);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// As the last used index we return the highest one from the pending indexes. Note that this value will be always
|
|
156
|
-
// higher than the last finalized index because we prune lower pending indexes when a tx is finalized.
|
|
157
|
-
return Math.max(...pendingIndexes);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Drops all pending indexes corresponding to the given transaction hashes.
|
|
162
|
-
*/
|
|
163
|
-
async dropPendingIndexes(txHashes: TxHash[]) {
|
|
164
|
-
if (txHashes.length === 0) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const txHashStrs = new Set<string>(txHashes.map(txHash => txHash.toString()));
|
|
169
|
-
const allSecrets = await toArray(this.#pendingIndexes.keysAsync());
|
|
170
|
-
|
|
171
|
-
for (const secret of allSecrets) {
|
|
172
|
-
const pendingData = await this.#pendingIndexes.getAsync(secret);
|
|
173
|
-
if (pendingData) {
|
|
174
|
-
const filtered = pendingData.filter(item => !txHashStrs.has(item.txHash));
|
|
175
|
-
if (filtered.length === 0) {
|
|
176
|
-
await this.#pendingIndexes.delete(secret);
|
|
177
|
-
} else if (filtered.length !== pendingData.length) {
|
|
178
|
-
// Some items were filtered out, so update the pending data
|
|
179
|
-
await this.#pendingIndexes.set(secret, filtered);
|
|
180
|
-
}
|
|
181
|
-
// else: No items were filtered out (txHashes not found for this secret) --> no-op
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Updates pending indexes corresponding to the given transaction hashes to be finalized and prunes any lower pending
|
|
188
|
-
* indexes.
|
|
189
|
-
*/
|
|
190
|
-
async finalizePendingIndexes(txHashes: TxHash[]) {
|
|
191
|
-
if (txHashes.length === 0) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
for (const txHash of txHashes) {
|
|
196
|
-
const txHashStr = txHash.toString();
|
|
197
|
-
|
|
198
|
-
const allSecrets = await toArray(this.#pendingIndexes.keysAsync());
|
|
199
|
-
|
|
200
|
-
for (const secret of allSecrets) {
|
|
201
|
-
const pendingData = await this.#pendingIndexes.getAsync(secret);
|
|
202
|
-
if (!pendingData) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const matchingIndexes = pendingData.filter(item => item.txHash === txHashStr).map(item => item.index);
|
|
207
|
-
if (matchingIndexes.length === 0) {
|
|
208
|
-
continue;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (matchingIndexes.length > 1) {
|
|
212
|
-
// We should always just store the highest pending index for a given tx hash and secret because the lower
|
|
213
|
-
// values are irrelevant.
|
|
214
|
-
throw new Error(`Multiple pending indexes found for tx hash ${txHashStr} and secret ${secret}`);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
let lastFinalized = await this.#lastFinalizedIndexes.getAsync(secret);
|
|
218
|
-
const newFinalized = matchingIndexes[0];
|
|
219
|
-
|
|
220
|
-
if (newFinalized < (lastFinalized ?? 0)) {
|
|
221
|
-
// This should never happen because when last finalized index was finalized we should have pruned the lower
|
|
222
|
-
// pending indexes.
|
|
223
|
-
throw new Error(
|
|
224
|
-
`New finalized index ${newFinalized} is smaller than the current last finalized index ${lastFinalized}`,
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
await this.#lastFinalizedIndexes.set(secret, newFinalized);
|
|
229
|
-
lastFinalized = newFinalized;
|
|
230
|
-
|
|
231
|
-
// When we add pending indexes, we ensure they are higher than the last finalized index. However, because we
|
|
232
|
-
// cannot control the order in which transactions are finalized, there may be pending indexes that are now
|
|
233
|
-
// obsolete because they are lower than the most recently finalized index. For this reason, we prune these
|
|
234
|
-
// outdated pending indexes.
|
|
235
|
-
const remainingItemsOfHigherIndex = pendingData.filter(item => item.index > (lastFinalized ?? 0));
|
|
236
|
-
if (remainingItemsOfHigherIndex.length === 0) {
|
|
237
|
-
await this.#pendingIndexes.delete(secret);
|
|
238
|
-
} else {
|
|
239
|
-
await this.#pendingIndexes.set(secret, remainingItemsOfHigherIndex);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
2
|
-
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
6
|
-
* is called SenderTaggingDataProvider. We have the providers separate for the sender and recipient because
|
|
7
|
-
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
8
|
-
*
|
|
9
|
-
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
10
|
-
* blocks, which by definition cannot be affected by reorgs.
|
|
11
|
-
*
|
|
12
|
-
* TODO(benesjan): Rename as to RecipientTaggingDataProvider and relocate once the old tagging sync is purged.
|
|
13
|
-
*/
|
|
14
|
-
export class NewRecipientTaggingDataProvider {
|
|
15
|
-
#store: AztecAsyncKVStore;
|
|
16
|
-
|
|
17
|
-
#highestAgedIndex: AztecAsyncMap<string, number>;
|
|
18
|
-
#highestFinalizedIndex: AztecAsyncMap<string, number>;
|
|
19
|
-
|
|
20
|
-
constructor(store: AztecAsyncKVStore) {
|
|
21
|
-
this.#store = store;
|
|
22
|
-
|
|
23
|
-
this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
|
|
24
|
-
this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getHighestAgedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
28
|
-
return this.#highestAgedIndex.getAsync(secret.toString());
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void> {
|
|
32
|
-
const currentIndex = await this.#highestAgedIndex.getAsync(secret.toString());
|
|
33
|
-
if (currentIndex !== undefined && index <= currentIndex) {
|
|
34
|
-
// Log sync should never set a lower highest aged index.
|
|
35
|
-
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
36
|
-
}
|
|
37
|
-
await this.#highestAgedIndex.set(secret.toString(), index);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
41
|
-
return this.#highestFinalizedIndex.getAsync(secret.toString());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number): Promise<void> {
|
|
45
|
-
const currentIndex = await this.#highestFinalizedIndex.getAsync(secret.toString());
|
|
46
|
-
if (currentIndex !== undefined && index < currentIndex) {
|
|
47
|
-
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
48
|
-
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
49
|
-
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
50
|
-
}
|
|
51
|
-
await this.#highestFinalizedIndex.set(secret.toString(), index);
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/tagging/utils.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
2
|
-
|
|
3
|
-
// TODO(#17775): If this does not get dropped when implementing the linked issue make this return tags instead. This
|
|
4
|
-
// will move some complexity from syncTaggedLogs to here.
|
|
5
|
-
export function getPreTagsForTheWindow(
|
|
6
|
-
secretsAndWindows: { secret: DirectionalAppTaggingSecret; leftMostIndex: number; rightMostIndex: number }[],
|
|
7
|
-
): PreTag[] {
|
|
8
|
-
const secrets = [];
|
|
9
|
-
for (const secretAndWindow of secretsAndWindows) {
|
|
10
|
-
for (let i = secretAndWindow.leftMostIndex; i <= secretAndWindow.rightMostIndex; i++) {
|
|
11
|
-
secrets.push({ secret: secretAndWindow.secret, index: i });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return secrets;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Creates a map from directional app tagging secret to initial index.
|
|
19
|
-
* @param preTags - The pre-tags to get the initial indexes map from.
|
|
20
|
-
* @returns The map from directional app tagging secret to initial index.
|
|
21
|
-
*/
|
|
22
|
-
export function getInitialIndexesMap(preTags: { secret: DirectionalAppTaggingSecret; index: number | undefined }[]): {
|
|
23
|
-
[k: string]: number;
|
|
24
|
-
} {
|
|
25
|
-
const initialIndexes: { [k: string]: number } = {};
|
|
26
|
-
|
|
27
|
-
for (const preTag of preTags) {
|
|
28
|
-
initialIndexes[preTag.secret.toString()] = preTag.index ?? 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return initialIndexes;
|
|
32
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
6
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
|
-
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
8
|
-
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
9
|
-
|
|
10
|
-
import type { AnchorBlockDataProvider } from '../storage/anchor_block_data_provider/anchor_block_data_provider.js';
|
|
11
|
-
|
|
12
|
-
export class TreeMembershipService {
|
|
13
|
-
constructor(
|
|
14
|
-
private readonly aztecNode: AztecNode,
|
|
15
|
-
private readonly anchorBlockDataProvider: AnchorBlockDataProvider,
|
|
16
|
-
) {}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Gets the index of a nullifier in the nullifier tree.
|
|
20
|
-
* @returns - The index of the nullifier. Undefined if it does not exist in the tree.
|
|
21
|
-
*/
|
|
22
|
-
public getNullifierIndex(nullifier: Fr) {
|
|
23
|
-
return this.#findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
28
|
-
* @param blockNumber - The block number at which to get the membership witness.
|
|
29
|
-
* @param treeId - Id of the tree to get the sibling path from.
|
|
30
|
-
* @param leafValue - The leaf value
|
|
31
|
-
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
32
|
-
*/
|
|
33
|
-
public async getMembershipWitness(blockNumber: BlockParameter, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
|
|
34
|
-
const witness = await this.#tryGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
35
|
-
if (!witness) {
|
|
36
|
-
throw new Error(`Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block ${blockNumber}`);
|
|
37
|
-
}
|
|
38
|
-
return witness;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
43
|
-
* @param blockNumber - The block number at which to get the index.
|
|
44
|
-
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
45
|
-
* @returns The low nullifier membership witness (if found).
|
|
46
|
-
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
47
|
-
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
48
|
-
* we are trying to prove non-inclusion for.
|
|
49
|
-
*/
|
|
50
|
-
public async getLowNullifierMembershipWitness(
|
|
51
|
-
blockNumber: BlockParameter,
|
|
52
|
-
nullifier: Fr,
|
|
53
|
-
): Promise<NullifierMembershipWitness | undefined> {
|
|
54
|
-
const anchorBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
|
|
55
|
-
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
56
|
-
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
57
|
-
}
|
|
58
|
-
return this.aztecNode.getLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Returns a witness for a given slot of the public data tree at a given block.
|
|
63
|
-
* @param blockNumber - The block number at which to get the witness.
|
|
64
|
-
* @param leafSlot - The slot of the public data in the public data tree.
|
|
65
|
-
*/
|
|
66
|
-
public async getPublicDataWitness(blockNumber: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
67
|
-
const anchorBlockNumber = (await this.anchorBlockDataProvider.getBlockHeader()).getBlockNumber();
|
|
68
|
-
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
69
|
-
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
70
|
-
}
|
|
71
|
-
return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Looks for the L1 to L2 membership witness of a message at the Aztec node, given its hash.
|
|
76
|
-
* @param contractAddress - Address of a contract by which the message was emitted.
|
|
77
|
-
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages.
|
|
78
|
-
* The message nullifier is computed locally, so the secret is not sent to the node.
|
|
79
|
-
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
80
|
-
*/
|
|
81
|
-
public getL1ToL2MembershipWitness(
|
|
82
|
-
contractAddress: AztecAddress,
|
|
83
|
-
messageHash: Fr,
|
|
84
|
-
secret: Fr,
|
|
85
|
-
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
|
|
86
|
-
return getNonNullifiedL1ToL2MessageWitness(this.aztecNode, contractAddress, messageHash, secret);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async #tryGetMembershipWitness(
|
|
90
|
-
blockNumber: BlockParameter,
|
|
91
|
-
treeId: MerkleTreeId,
|
|
92
|
-
value: Fr,
|
|
93
|
-
): Promise<Fr[] | undefined> {
|
|
94
|
-
switch (treeId) {
|
|
95
|
-
case MerkleTreeId.NULLIFIER_TREE:
|
|
96
|
-
return (await this.aztecNode.getNullifierMembershipWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
97
|
-
case MerkleTreeId.NOTE_HASH_TREE:
|
|
98
|
-
return (await this.aztecNode.getNoteHashMembershipWitness(blockNumber, value))?.toFields();
|
|
99
|
-
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
100
|
-
return (await this.aztecNode.getPublicDataWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
101
|
-
case MerkleTreeId.ARCHIVE:
|
|
102
|
-
return (await this.aztecNode.getArchiveMembershipWitness(blockNumber, value))?.toFields();
|
|
103
|
-
default:
|
|
104
|
-
throw new Error('Not implemented');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async #findLeafIndex(blockNumber: BlockParameter, treeId: MerkleTreeId, leafValue: Fr): Promise<bigint | undefined> {
|
|
109
|
-
const [leafIndex] = await this.aztecNode.findLeavesIndexes(blockNumber, treeId, [leafValue]);
|
|
110
|
-
return leafIndex?.data;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
File without changes
|
|
File without changes
|