@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.03f7ef2
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/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +129 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +39 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +36 -32
- 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 +11 -24
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -33
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +83 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +325 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +95 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +191 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +14 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +12 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +20 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +37 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +103 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +17 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +58 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +345 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +47 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +123 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +240 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +439 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +195 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +372 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +51 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
- package/dest/contract_function_simulator/proxied_node.d.ts +9 -0
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_node.js +27 -0
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +18 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +9 -9
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +17 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +16 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +6 -4
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -3
- package/dest/entrypoints/server/utils.d.ts +8 -16
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +31 -36
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +26 -18
- 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 +47 -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 +39 -0
- package/dest/logs/log_service.d.ts +43 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +239 -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 +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +152 -0
- package/dest/oracle_version.d.ts +3 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +10 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +28 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +271 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/{kernel_prover → private_kernel}/hints/index.js +1 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +44 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +286 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +63 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +46 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +19 -9
- package/dest/public_storage/public_storage_service.d.ts +24 -0
- package/dest/public_storage/public_storage_service.d.ts.map +1 -0
- package/dest/public_storage/public_storage_service.js +26 -0
- package/dest/pxe.d.ts +231 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +756 -0
- package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/address_data_provider/index.d.ts +1 -1
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +9 -0
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_data_provider/anchor_block_data_provider.js} +2 -12
- package/dest/storage/anchor_block_data_provider/index.d.ts +2 -0
- package/dest/storage/anchor_block_data_provider/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_data_provider/index.js +1 -0
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +48 -7
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +117 -28
- package/dest/storage/capsule_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +16 -59
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +121 -80
- package/dest/storage/contract_data_provider/index.d.ts +1 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +3 -42
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +10 -62
- package/dest/storage/index.d.ts +4 -5
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +3 -4
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_data_provider/index.d.ts +2 -2
- package/dest/storage/note_data_provider/index.d.ts.map +1 -1
- package/dest/storage/note_data_provider/index.js +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +75 -11
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +155 -82
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +51 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -0
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +115 -0
- package/dest/storage/tagging_data_provider/index.d.ts +3 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/index.js +2 -1
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +31 -0
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +1 -0
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +65 -0
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts +67 -0
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +1 -0
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +196 -0
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +3 -0
- package/dest/tagging/index.d.ts +5 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +3 -0
- 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/new_recipient_tagging_data_provider.d.ts +21 -0
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +42 -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 +29 -0
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +21 -0
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sync/sync_sender_tagging_indexes.js +89 -0
- package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sync/utils/get_status_change_of_pending.js +32 -0
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +55 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +25 -0
- package/dest/tree_membership/tree_membership_service.d.ts +52 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +84 -0
- package/package.json +37 -34
- package/src/bin/check_oracle_version.ts +160 -0
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +39 -35
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +27 -55
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +618 -0
- package/src/contract_function_simulator/execution_note_cache.ts +233 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +13 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +47 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +175 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
- package/src/contract_function_simulator/oracle/oracle.ts +605 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +209 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +704 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +532 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
- package/src/contract_function_simulator/proxied_node.ts +33 -0
- package/src/debug/pxe_debug_utils.ts +48 -0
- package/src/entrypoints/client/bundle/index.ts +3 -2
- package/src/entrypoints/client/bundle/utils.ts +36 -36
- package/src/entrypoints/client/lazy/index.ts +3 -2
- package/src/entrypoints/client/lazy/utils.ts +36 -31
- package/src/entrypoints/pxe_creation_options.ts +12 -0
- package/src/entrypoints/server/index.ts +5 -3
- package/src/entrypoints/server/utils.ts +59 -51
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +36 -27
- package/src/events/event_service.ts +77 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +48 -0
- package/src/logs/log_service.ts +364 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +200 -0
- package/src/oracle_version.ts +11 -0
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +159 -147
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/{kernel_prover → private_kernel}/hints/index.ts +1 -0
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +432 -0
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +19 -30
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +33 -17
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +1063 -0
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_data_provider/anchor_block_data_provider.ts} +2 -17
- package/src/storage/anchor_block_data_provider/index.ts +1 -0
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +130 -31
- package/src/storage/contract_data_provider/contract_data_provider.ts +152 -94
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/private_functions_tree.ts +12 -76
- package/src/storage/index.ts +3 -5
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_data_provider/index.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +188 -121
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +162 -0
- package/src/storage/tagging_data_provider/index.ts +2 -1
- package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +86 -0
- package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +244 -0
- package/src/tagging/constants.ts +3 -0
- package/src/tagging/index.ts +4 -0
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
- package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +53 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
- package/src/tagging/sync/sync_sender_tagging_indexes.ts +112 -0
- package/src/tagging/sync/utils/get_status_change_of_pending.ts +44 -0
- package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
- package/src/tagging/utils.ts +32 -0
- package/src/tree_membership/tree_membership_service.ts +112 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -28
- package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
- package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
- package/dest/kernel_oracle/index.d.ts +0 -45
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
- package/dest/kernel_prover/hints/index.d.ts +0 -2
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/kernel_prover.js +0 -217
- package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/pxe_http/index.d.ts +0 -2
- package/dest/pxe_http/index.d.ts.map +0 -1
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +0 -16
- package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
- package/dest/pxe_http/pxe_http_server.js +0 -27
- package/dest/pxe_oracle_interface/index.d.ts +0 -159
- package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/index.js +0 -692
- package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
- package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -111
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/pxe_service/pxe_service.js +0 -664
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -106
- 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 -12
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -18
- 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 -65
- 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 -37
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -38
- package/src/entrypoints/client/pxe_creation_options.ts +0 -7
- package/src/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/pxe_http/index.ts +0 -1
- package/src/pxe_http/pxe_http_server.ts +0 -29
- package/src/pxe_oracle_interface/index.ts +0 -925
- package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/pxe_service/pxe_service.ts +0 -949
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- package/src/storage/data_provider.ts +0 -3
- package/src/storage/note_data_provider/note_dao.ts +0 -162
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -92
- package/src/synchronizer/index.ts +0 -1
- package/src/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
4
4
|
import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
|
|
5
|
-
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
|
+
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
6
6
|
import {
|
|
7
|
-
type
|
|
7
|
+
type PrivateFunction,
|
|
8
8
|
computePrivateFunctionLeaf,
|
|
9
9
|
computePrivateFunctionsTree,
|
|
10
|
-
|
|
10
|
+
getContractClassPrivateFunctionFromArtifact,
|
|
11
11
|
} from '@aztec/stdlib/contract';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -19,78 +19,15 @@ import {
|
|
|
19
19
|
export class PrivateFunctionsTree {
|
|
20
20
|
private tree?: MerkleTree;
|
|
21
21
|
|
|
22
|
-
private constructor(private readonly
|
|
22
|
+
private constructor(private readonly privateFunctions: PrivateFunction[]) {}
|
|
23
23
|
|
|
24
24
|
static async create(artifact: ContractArtifact) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Retrieve the artifact of a given function.
|
|
31
|
-
* The function is identified by its selector, which represents a unique identifier for the function's signature.
|
|
32
|
-
* Throws an error if the function with the provided selector is not found in the contract.
|
|
33
|
-
*
|
|
34
|
-
* @param selector - The function selector.
|
|
35
|
-
* @returns The artifact object containing relevant information about the targeted function.
|
|
36
|
-
*/
|
|
37
|
-
public async getFunctionArtifact(selector: FunctionSelector) {
|
|
38
|
-
const functionsAndSelectors = await Promise.all(
|
|
39
|
-
this.artifact.functions.map(async f => ({
|
|
40
|
-
f,
|
|
41
|
-
selector: await FunctionSelector.fromNameAndParameters(f.name, f.parameters),
|
|
42
|
-
})),
|
|
25
|
+
const privateFunctions = await Promise.all(
|
|
26
|
+
artifact.functions
|
|
27
|
+
.filter(fn => fn.functionType === FunctionType.PRIVATE)
|
|
28
|
+
.map(getContractClassPrivateFunctionFromArtifact),
|
|
43
29
|
);
|
|
44
|
-
|
|
45
|
-
if (!artifact) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`Unknown function. Selector ${selector.toString()} not found in the artifact ${
|
|
48
|
-
this.artifact.name
|
|
49
|
-
} with class ${this.getContractClassId().toString()}.`,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
return artifact;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Retrieve the bytecode of a function in the contract by its function selector.
|
|
57
|
-
* The function selector is a unique identifier for each function in a contract.
|
|
58
|
-
* Throws an error if the function with the given selector is not found in the contract.
|
|
59
|
-
*
|
|
60
|
-
* @param selector - The selector of a function to get bytecode for.
|
|
61
|
-
* @returns The bytecode of the function as a string.
|
|
62
|
-
*/
|
|
63
|
-
public async getBytecode(selector: FunctionSelector) {
|
|
64
|
-
const artifact = await this.getFunctionArtifact(selector);
|
|
65
|
-
return artifact.bytecode;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Calculate and return the root of the function tree for the current contract.
|
|
70
|
-
* This root is a cryptographic commitment to the set of constrained functions within the contract,
|
|
71
|
-
* which is used in the Aztec node's proof system. The root will be cached after the first call.
|
|
72
|
-
*
|
|
73
|
-
* @returns A promise that resolves to the Fr (finite field element) representation of the function tree root.
|
|
74
|
-
*/
|
|
75
|
-
public getFunctionTreeRoot() {
|
|
76
|
-
return this.getTree();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Returns the contract class object. */
|
|
80
|
-
public getContractClass() {
|
|
81
|
-
return this.contractClass;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Returns the contract artifact. */
|
|
85
|
-
public getArtifact() {
|
|
86
|
-
return this.artifact;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Returns the contract class identifier for the given artifact.
|
|
91
|
-
*/
|
|
92
|
-
public getContractClassId() {
|
|
93
|
-
return this.getContractClass().id;
|
|
30
|
+
return new PrivateFunctionsTree(privateFunctions);
|
|
94
31
|
}
|
|
95
32
|
|
|
96
33
|
/**
|
|
@@ -105,7 +42,7 @@ export class PrivateFunctionsTree {
|
|
|
105
42
|
public async getFunctionMembershipWitness(
|
|
106
43
|
selector: FunctionSelector,
|
|
107
44
|
): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
|
|
108
|
-
const fn = this.
|
|
45
|
+
const fn = this.privateFunctions.find(f => f.selector.equals(selector));
|
|
109
46
|
if (!fn) {
|
|
110
47
|
throw new Error(`Private function with selector ${selector.toString()} not found in contract class.`);
|
|
111
48
|
}
|
|
@@ -123,8 +60,7 @@ export class PrivateFunctionsTree {
|
|
|
123
60
|
|
|
124
61
|
private async getTree() {
|
|
125
62
|
if (!this.tree) {
|
|
126
|
-
|
|
127
|
-
this.tree = await computePrivateFunctionsTree(fns);
|
|
63
|
+
this.tree = await computePrivateFunctionsTree(this.privateFunctions);
|
|
128
64
|
}
|
|
129
65
|
return this.tree;
|
|
130
66
|
}
|
package/src/storage/index.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export * from './address_data_provider/index.js';
|
|
2
|
-
export * from './auth_witness_data_provider/index.js';
|
|
3
2
|
export * from './capsule_data_provider/index.js';
|
|
4
3
|
export * from './contract_data_provider/index.js';
|
|
5
4
|
export * from './note_data_provider/index.js';
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './anchor_block_data_provider/index.js';
|
|
7
6
|
export * from './tagging_data_provider/index.js';
|
|
8
|
-
export * from './
|
|
9
|
-
|
|
10
|
-
export const PXE_DATA_SCHEMA_VERSION = 2;
|
|
7
|
+
export * from './metadata.js';
|
|
8
|
+
export * from './private_event_data_provider/private_event_data_provider.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 2;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { NoteDao } from '
|
|
1
|
+
export { NoteDao } from '@aztec/stdlib/note';
|
|
2
2
|
export { NoteDataProvider } from './note_data_provider.js';
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Fr
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type {
|
|
7
|
-
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
6
|
+
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
8
7
|
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* NoteDataProvider manages the storage and retrieval of notes.
|
|
12
|
+
*
|
|
13
|
+
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
14
|
+
* and performs rollback handling in the case of a reorg.
|
|
15
|
+
**/
|
|
16
|
+
export class NoteDataProvider {
|
|
14
17
|
#store: AztecAsyncKVStore;
|
|
15
|
-
|
|
16
18
|
#notes: AztecAsyncMap<string, Buffer>;
|
|
17
19
|
#nullifiedNotes: AztecAsyncMap<string, Buffer>;
|
|
18
20
|
#nullifierToNoteId: AztecAsyncMap<string, string>;
|
|
@@ -21,16 +23,12 @@ export class NoteDataProvider implements DataProvider {
|
|
|
21
23
|
#nullifiedNotesToScope: AztecAsyncMultiMap<string, string>;
|
|
22
24
|
#nullifiedNotesByContract: AztecAsyncMultiMap<string, string>;
|
|
23
25
|
#nullifiedNotesByStorageSlot: AztecAsyncMultiMap<string, string>;
|
|
24
|
-
#nullifiedNotesByTxHash: AztecAsyncMultiMap<string, string>;
|
|
25
|
-
#nullifiedNotesByAddressPoint: AztecAsyncMultiMap<string, string>;
|
|
26
26
|
#nullifiedNotesByNullifier: AztecAsyncMap<string, string>;
|
|
27
27
|
|
|
28
28
|
#scopes: AztecAsyncMap<string, true>;
|
|
29
29
|
#notesToScope: AztecAsyncMultiMap<string, string>;
|
|
30
30
|
#notesByContractAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
31
31
|
#notesByStorageSlotAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
32
|
-
#notesByTxHashAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
33
|
-
#notesByAddressPointAndScope: Map<string, AztecAsyncMultiMap<string, string>>;
|
|
34
32
|
|
|
35
33
|
private constructor(store: AztecAsyncKVStore) {
|
|
36
34
|
this.#store = store;
|
|
@@ -42,29 +40,41 @@ export class NoteDataProvider implements DataProvider {
|
|
|
42
40
|
this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
|
|
43
41
|
this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
|
|
44
42
|
this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
|
|
45
|
-
this.#nullifiedNotesByTxHash = store.openMultiMap('nullified_notes_by_tx_hash');
|
|
46
|
-
this.#nullifiedNotesByAddressPoint = store.openMultiMap('nullified_notes_by_address_point');
|
|
47
43
|
this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
|
|
48
44
|
|
|
49
45
|
this.#scopes = store.openMap('scopes');
|
|
50
46
|
this.#notesToScope = store.openMultiMap('notes_to_scope');
|
|
51
47
|
this.#notesByContractAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
52
48
|
this.#notesByStorageSlotAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
53
|
-
this.#notesByTxHashAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
54
|
-
this.#notesByAddressPointAndScope = new Map<string, AztecAsyncMultiMap<string, string>>();
|
|
55
49
|
}
|
|
56
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Creates and initializes a new NoteDataProvider instance.
|
|
53
|
+
*
|
|
54
|
+
* This factory method creates a NoteDataProvider and restores any existing
|
|
55
|
+
* scope-specific indexes from the database.
|
|
56
|
+
*
|
|
57
|
+
* @param store - The key-value store to use for persistence
|
|
58
|
+
* @returns Promise resolving to a fully initialized NoteDataProvider instance
|
|
59
|
+
*/
|
|
57
60
|
public static async create(store: AztecAsyncKVStore): Promise<NoteDataProvider> {
|
|
58
61
|
const pxeDB = new NoteDataProvider(store);
|
|
59
62
|
for await (const scope of pxeDB.#scopes.keysAsync()) {
|
|
60
63
|
pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
|
|
61
64
|
pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
|
|
62
|
-
pxeDB.#notesByTxHashAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_tx_hash`));
|
|
63
|
-
pxeDB.#notesByAddressPointAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_address_point`));
|
|
64
65
|
}
|
|
65
66
|
return pxeDB;
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Adds a new scope to the note data provider.
|
|
71
|
+
*
|
|
72
|
+
* Scopes provide privacy isolation by creating separate indexes for each user.
|
|
73
|
+
* Each scope gets its own set of indexes for efficient note retrieval by various criteria.
|
|
74
|
+
*
|
|
75
|
+
* @param scope - The AztecAddress representing the scope/user to add
|
|
76
|
+
* @returns Promise resolving to true if scope was added, false if it already existed
|
|
77
|
+
*/
|
|
68
78
|
public async addScope(scope: AztecAddress): Promise<boolean> {
|
|
69
79
|
const scopeString = scope.toString();
|
|
70
80
|
|
|
@@ -75,26 +85,27 @@ export class NoteDataProvider implements DataProvider {
|
|
|
75
85
|
await this.#scopes.set(scopeString, true);
|
|
76
86
|
this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
|
|
77
87
|
this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
|
|
78
|
-
this.#notesByTxHashAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_tx_hash`));
|
|
79
|
-
this.#notesByAddressPointAndScope.set(
|
|
80
|
-
scopeString,
|
|
81
|
-
this.#store.openMultiMap(`${scopeString}:notes_by_address_point`),
|
|
82
|
-
);
|
|
83
88
|
|
|
84
89
|
return true;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Adds multiple notes to the data provider under the specified scope.
|
|
94
|
+
*
|
|
95
|
+
* Notes are stored using their index from the notes hash tree as the key, which provides
|
|
96
|
+
* uniqueness and maintains creation order. Each note is indexed by multiple criteria
|
|
97
|
+
* for efficient retrieval.
|
|
98
|
+
*
|
|
99
|
+
* @param notes - Notes to store
|
|
100
|
+
* @param scope - The scope (user/account) under which to store the notes
|
|
101
|
+
*/
|
|
102
|
+
addNotes(notes: NoteDao[], scope: AztecAddress): Promise<void> {
|
|
92
103
|
return this.#store.transactionAsync(async () => {
|
|
104
|
+
if (!(await this.#scopes.hasAsync(scope.toString()))) {
|
|
105
|
+
await this.addScope(scope);
|
|
106
|
+
}
|
|
107
|
+
|
|
93
108
|
for (const dao of notes) {
|
|
94
|
-
// store notes by their index in the notes hash tree
|
|
95
|
-
// this provides the uniqueness we need to store individual notes
|
|
96
|
-
// and should also return notes in the order that they were created.
|
|
97
|
-
// Had we stored them by their nullifier, they would be returned in random order
|
|
98
109
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
99
110
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
100
111
|
await this.#notesToScope.set(noteIndex, scope.toString());
|
|
@@ -102,13 +113,34 @@ export class NoteDataProvider implements DataProvider {
|
|
|
102
113
|
|
|
103
114
|
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
104
115
|
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
105
|
-
await this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex);
|
|
106
|
-
await this.#notesByAddressPointAndScope.get(scope.toString())!.set(dao.addressPoint.toString(), noteIndex);
|
|
107
116
|
}
|
|
108
117
|
});
|
|
109
118
|
}
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Synchronizes notes and nullifiers to a specific block number.
|
|
122
|
+
*
|
|
123
|
+
* This method ensures that the state of notes and nullifiers is consistent with the
|
|
124
|
+
* specified block number. It restores any notes that were nullified after the given block
|
|
125
|
+
* and deletes any active notes created after that block.
|
|
126
|
+
*
|
|
127
|
+
* @param blockNumber - The new chain tip after a reorg
|
|
128
|
+
* @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
|
|
129
|
+
*/
|
|
130
|
+
public async rollbackNotesAndNullifiers(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
131
|
+
await this.#rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber);
|
|
132
|
+
await this.#deleteActiveNotesAfterBlock(blockNumber);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Deletes (removes) all active notes created after the specified block number.
|
|
137
|
+
*
|
|
138
|
+
* Permanently delete notes from the active notes store, e.g. during a reorg.
|
|
139
|
+
* Note: This only affects #notes (active notes), not #nullifiedNotes.
|
|
140
|
+
*
|
|
141
|
+
* @param blockNumber - Notes created after this block number will be deleted
|
|
142
|
+
*/
|
|
143
|
+
#deleteActiveNotesAfterBlock(blockNumber: number): Promise<void> {
|
|
112
144
|
return this.#store.transactionAsync(async () => {
|
|
113
145
|
const notes = await toArray(this.#notes.valuesAsync());
|
|
114
146
|
for (const note of notes) {
|
|
@@ -120,8 +152,6 @@ export class NoteDataProvider implements DataProvider {
|
|
|
120
152
|
await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
|
|
121
153
|
const scopes = await toArray(this.#scopes.keysAsync());
|
|
122
154
|
for (const scope of scopes) {
|
|
123
|
-
await this.#notesByAddressPointAndScope.get(scope)!.deleteValue(noteDao.addressPoint.toString(), noteIndex);
|
|
124
|
-
await this.#notesByTxHashAndScope.get(scope)!.deleteValue(noteDao.txHash.toString(), noteIndex);
|
|
125
155
|
await this.#notesByContractAndScope.get(scope)!.deleteValue(noteDao.contractAddress.toString(), noteIndex);
|
|
126
156
|
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(noteDao.storageSlot.toString(), noteIndex);
|
|
127
157
|
}
|
|
@@ -130,41 +160,50 @@ export class NoteDataProvider implements DataProvider {
|
|
|
130
160
|
});
|
|
131
161
|
}
|
|
132
162
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const nullifiedNoteBuffers = await Promise.all(
|
|
145
|
-
notNullNoteIndexes.map(noteIndex => this.#nullifiedNotes.getAsync(noteIndex!)),
|
|
146
|
-
);
|
|
147
|
-
const noteDaos = nullifiedNoteBuffers
|
|
148
|
-
.filter(buffer => buffer != undefined)
|
|
149
|
-
.map(buffer => NoteDao.fromBuffer(buffer!));
|
|
150
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Rewinds nullifications after a given block number.
|
|
165
|
+
*
|
|
166
|
+
* This operation "unnullifies" notes, rolling back nullifications that occurred
|
|
167
|
+
* in orphaned blocks, e.g. during a reorg. The notes are restored to the
|
|
168
|
+
* active notes store and removed from the nullified store.
|
|
169
|
+
*
|
|
170
|
+
* @param blockNumber - Revert nullifications that occurred after this block
|
|
171
|
+
* @param synchedBlockNumber - Upper bound for the block range to process
|
|
172
|
+
*/
|
|
173
|
+
async #rewindNullifiersAfterBlock(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
151
174
|
await this.#store.transactionAsync(async () => {
|
|
175
|
+
const nullifiersToUndo: string[] = [];
|
|
176
|
+
const currentBlockNumber = blockNumber + 1;
|
|
177
|
+
for (let i = currentBlockNumber; i <= synchedBlockNumber; i++) {
|
|
178
|
+
nullifiersToUndo.push(...(await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i))));
|
|
179
|
+
}
|
|
180
|
+
const notesIndexesToReinsert = await Promise.all(
|
|
181
|
+
nullifiersToUndo.map(nullifier => this.#nullifiedNotesByNullifier.getAsync(nullifier)),
|
|
182
|
+
);
|
|
183
|
+
const notNullNoteIndexes = notesIndexesToReinsert.filter(noteIndex => noteIndex != undefined);
|
|
184
|
+
const nullifiedNoteBuffers = await Promise.all(
|
|
185
|
+
notNullNoteIndexes.map(noteIndex => this.#nullifiedNotes.getAsync(noteIndex!)),
|
|
186
|
+
);
|
|
187
|
+
const noteDaos = nullifiedNoteBuffers
|
|
188
|
+
.filter(buffer => buffer != undefined)
|
|
189
|
+
.map(buffer => NoteDao.fromBuffer(buffer!));
|
|
190
|
+
|
|
152
191
|
for (const dao of noteDaos) {
|
|
153
192
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
154
193
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
|
155
194
|
await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
|
|
156
195
|
|
|
157
|
-
|
|
196
|
+
const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
|
|
158
197
|
|
|
159
198
|
if (scopes.length === 0) {
|
|
160
|
-
|
|
199
|
+
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
200
|
+
// insertion via `addNotes` or when removing their nullifiers.
|
|
201
|
+
throw new Error(`No scopes found for nullified note with index ${noteIndex}`);
|
|
161
202
|
}
|
|
162
203
|
|
|
163
204
|
for (const scope of scopes) {
|
|
164
205
|
await this.#notesByContractAndScope.get(scope.toString())!.set(dao.contractAddress.toString(), noteIndex);
|
|
165
206
|
await this.#notesByStorageSlotAndScope.get(scope.toString())!.set(dao.storageSlot.toString(), noteIndex);
|
|
166
|
-
await this.#notesByTxHashAndScope.get(scope.toString())!.set(dao.txHash.toString(), noteIndex);
|
|
167
|
-
await this.#notesByAddressPointAndScope.get(scope.toString())!.set(dao.addressPoint.toString(), noteIndex);
|
|
168
207
|
await this.#notesToScope.set(noteIndex, scope);
|
|
169
208
|
}
|
|
170
209
|
|
|
@@ -173,18 +212,33 @@ export class NoteDataProvider implements DataProvider {
|
|
|
173
212
|
await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
|
|
174
213
|
await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
|
|
175
214
|
await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
|
|
176
|
-
await this.#nullifiedNotesByTxHash.deleteValue(dao.txHash.toString(), noteIndex);
|
|
177
|
-
await this.#nullifiedNotesByAddressPoint.deleteValue(dao.addressPoint.toString(), noteIndex);
|
|
178
215
|
await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
|
|
179
216
|
}
|
|
180
217
|
});
|
|
181
218
|
}
|
|
182
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Retrieves notes based on the provided filter criteria.
|
|
222
|
+
*
|
|
223
|
+
* This method queries both active and optionally nullified notes based on the filter
|
|
224
|
+
* parameters.
|
|
225
|
+
*
|
|
226
|
+
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
227
|
+
* owner, storageSlot, status, scopes, and siloedNullifier.
|
|
228
|
+
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
229
|
+
* returned once if this is the case)
|
|
230
|
+
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
231
|
+
*/
|
|
183
232
|
async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
184
|
-
const publicKey: PublicKey | undefined = filter.owner ? await filter.owner.toAddressPoint() : undefined;
|
|
185
|
-
|
|
186
233
|
filter.status = filter.status ?? NoteStatus.ACTIVE;
|
|
187
234
|
|
|
235
|
+
// throw early if scopes is an empty array
|
|
236
|
+
if (filter.scopes !== undefined && filter.scopes.length === 0) {
|
|
237
|
+
throw new Error(
|
|
238
|
+
'Trying to get notes with an empty scopes array. Scopes have to be set to undefined if intending on not filtering by scopes.',
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
188
242
|
const candidateNoteSources = [];
|
|
189
243
|
|
|
190
244
|
filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map(addressString =>
|
|
@@ -196,29 +250,19 @@ export class NoteDataProvider implements DataProvider {
|
|
|
196
250
|
for (const scope of new Set(filter.scopes)) {
|
|
197
251
|
const formattedScopeString = scope.toString();
|
|
198
252
|
if (!(await this.#scopes.hasAsync(formattedScopeString))) {
|
|
199
|
-
throw new Error('Trying to get incoming notes of
|
|
253
|
+
throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
|
|
200
254
|
}
|
|
201
255
|
|
|
202
256
|
activeNoteIdsPerScope.push(
|
|
203
|
-
|
|
204
|
-
? await toArray(
|
|
205
|
-
this.#notesByAddressPointAndScope.get(formattedScopeString)!.getValuesAsync(publicKey.toString()),
|
|
206
|
-
)
|
|
207
|
-
: filter.txHash
|
|
257
|
+
filter.storageSlot
|
|
208
258
|
? await toArray(
|
|
209
|
-
this.#
|
|
259
|
+
this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValuesAsync(filter.storageSlot.toString()),
|
|
210
260
|
)
|
|
211
|
-
:
|
|
212
|
-
? await toArray(
|
|
261
|
+
: await toArray(
|
|
213
262
|
this.#notesByContractAndScope
|
|
214
263
|
.get(formattedScopeString)!
|
|
215
264
|
.getValuesAsync(filter.contractAddress.toString()),
|
|
216
|
-
)
|
|
217
|
-
: filter.storageSlot
|
|
218
|
-
? await toArray(
|
|
219
|
-
this.#notesByStorageSlotAndScope.get(formattedScopeString)!.getValuesAsync(filter.storageSlot.toString()),
|
|
220
|
-
)
|
|
221
|
-
: await toArray(this.#notesByAddressPointAndScope.get(formattedScopeString)!.valuesAsync()),
|
|
265
|
+
),
|
|
222
266
|
);
|
|
223
267
|
}
|
|
224
268
|
|
|
@@ -227,19 +271,28 @@ export class NoteDataProvider implements DataProvider {
|
|
|
227
271
|
notes: this.#notes,
|
|
228
272
|
});
|
|
229
273
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
274
|
+
// If status is ACTIVE_OR_NULLIFIED we add nullified notes as candidates on top of the default active ones.
|
|
275
|
+
if (filter.status === NoteStatus.ACTIVE_OR_NULLIFIED) {
|
|
276
|
+
const nullifiedIds = filter.storageSlot
|
|
277
|
+
? await toArray(this.#nullifiedNotesByStorageSlot.getValuesAsync(filter.storageSlot.toString()))
|
|
278
|
+
: await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString()));
|
|
279
|
+
|
|
280
|
+
const setOfScopes = new Set(filter.scopes.map(s => s.toString() as string));
|
|
281
|
+
const filteredNullifiedIds = new Set<string>();
|
|
282
|
+
|
|
283
|
+
for (const noteId of nullifiedIds) {
|
|
284
|
+
const scopeList = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteId));
|
|
285
|
+
if (scopeList.some(scope => setOfScopes.has(scope))) {
|
|
286
|
+
filteredNullifiedIds.add(noteId);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (filteredNullifiedIds.size > 0) {
|
|
291
|
+
candidateNoteSources.push({
|
|
292
|
+
ids: filteredNullifiedIds,
|
|
293
|
+
notes: this.#nullifiedNotes,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
243
296
|
}
|
|
244
297
|
|
|
245
298
|
const result: NoteDao[] = [];
|
|
@@ -251,11 +304,11 @@ export class NoteDataProvider implements DataProvider {
|
|
|
251
304
|
}
|
|
252
305
|
|
|
253
306
|
const note = NoteDao.fromBuffer(serializedNote);
|
|
254
|
-
if (
|
|
307
|
+
if (!note.contractAddress.equals(filter.contractAddress)) {
|
|
255
308
|
continue;
|
|
256
309
|
}
|
|
257
310
|
|
|
258
|
-
if (filter.
|
|
311
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
259
312
|
continue;
|
|
260
313
|
}
|
|
261
314
|
|
|
@@ -263,10 +316,6 @@ export class NoteDataProvider implements DataProvider {
|
|
|
263
316
|
continue;
|
|
264
317
|
}
|
|
265
318
|
|
|
266
|
-
if (publicKey && !note.addressPoint.equals(publicKey)) {
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
319
|
if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
271
320
|
continue;
|
|
272
321
|
}
|
|
@@ -275,10 +324,29 @@ export class NoteDataProvider implements DataProvider {
|
|
|
275
324
|
}
|
|
276
325
|
}
|
|
277
326
|
|
|
278
|
-
|
|
327
|
+
// A note might be present in multiple scopes - we ensure it is only returned once
|
|
328
|
+
const deduplicated: NoteDao[] = [];
|
|
329
|
+
for (const note of result) {
|
|
330
|
+
if (!deduplicated.some(existing => existing.equals(note))) {
|
|
331
|
+
deduplicated.push(note);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return deduplicated;
|
|
279
336
|
}
|
|
280
337
|
|
|
281
|
-
|
|
338
|
+
/**
|
|
339
|
+
* Transitions notes from "active" to "nullified" state.
|
|
340
|
+
*
|
|
341
|
+
* This operation processes a batch of nullifiers to mark the corresponding notes
|
|
342
|
+
* as spent/nullified. The operation is atomic - if any nullifier is not found,
|
|
343
|
+
* the entire operation fails and no notes are modified.
|
|
344
|
+
*
|
|
345
|
+
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
346
|
+
* @returns Promise resolving to array of nullified NoteDao objects
|
|
347
|
+
* @throws Error if any nullifier is not found in the active notes
|
|
348
|
+
*/
|
|
349
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[]): Promise<NoteDao[]> {
|
|
282
350
|
if (nullifiers.length === 0) {
|
|
283
351
|
return Promise.resolve([]);
|
|
284
352
|
}
|
|
@@ -288,24 +356,33 @@ export class NoteDataProvider implements DataProvider {
|
|
|
288
356
|
|
|
289
357
|
for (const blockScopedNullifier of nullifiers) {
|
|
290
358
|
const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
|
|
291
|
-
const
|
|
359
|
+
const nullifierKey = nullifier.toString();
|
|
360
|
+
|
|
361
|
+
const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
|
|
292
362
|
if (!noteIndex) {
|
|
293
|
-
|
|
363
|
+
// Check if already nullified?
|
|
364
|
+
const alreadyNullified = await this.#nullifiedNotesByNullifier.getAsync(nullifierKey);
|
|
365
|
+
if (alreadyNullified) {
|
|
366
|
+
throw new Error(`Nullifier already applied in applyNullifiers`);
|
|
367
|
+
}
|
|
368
|
+
throw new Error('Nullifier not found in applyNullifiers');
|
|
294
369
|
}
|
|
295
370
|
|
|
296
371
|
const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
|
|
297
372
|
|
|
298
373
|
if (!noteBuffer) {
|
|
299
|
-
|
|
300
|
-
continue;
|
|
374
|
+
throw new Error('Note not found in applyNullifiers');
|
|
301
375
|
}
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
//
|
|
306
|
-
|
|
376
|
+
|
|
377
|
+
const noteScopes = await toArray(this.#notesToScope.getValuesAsync(noteIndex));
|
|
378
|
+
if (noteScopes.length === 0) {
|
|
379
|
+
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
380
|
+
// insertion via `addNotes` or when removing their nullifiers.
|
|
381
|
+
throw new Error('Note scopes are missing in applyNullifiers');
|
|
307
382
|
}
|
|
308
383
|
|
|
384
|
+
const note = NoteDao.fromBuffer(noteBuffer);
|
|
385
|
+
|
|
309
386
|
nullifiedNotes.push(note);
|
|
310
387
|
|
|
311
388
|
await this.#notes.delete(noteIndex);
|
|
@@ -314,23 +391,17 @@ export class NoteDataProvider implements DataProvider {
|
|
|
314
391
|
const scopes = await toArray(this.#scopes.keysAsync());
|
|
315
392
|
|
|
316
393
|
for (const scope of scopes) {
|
|
317
|
-
await this.#notesByAddressPointAndScope.get(scope)!.deleteValue(accountAddressPoint.toString(), noteIndex);
|
|
318
|
-
await this.#notesByTxHashAndScope.get(scope)!.deleteValue(note.txHash.toString(), noteIndex);
|
|
319
394
|
await this.#notesByContractAndScope.get(scope)!.deleteValue(note.contractAddress.toString(), noteIndex);
|
|
320
395
|
await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
|
|
321
396
|
}
|
|
322
397
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
326
|
-
}
|
|
398
|
+
for (const scope of noteScopes) {
|
|
399
|
+
await this.#nullifiedNotesToScope.set(noteIndex, scope);
|
|
327
400
|
}
|
|
328
401
|
await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
|
|
329
402
|
await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
|
|
330
403
|
await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
|
|
331
404
|
await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
|
|
332
|
-
await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
|
|
333
|
-
await this.#nullifiedNotesByAddressPoint.set(note.addressPoint.toString(), noteIndex);
|
|
334
405
|
await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
|
|
335
406
|
|
|
336
407
|
await this.#nullifierToNoteId.delete(nullifier.toString());
|
|
@@ -338,8 +409,4 @@ export class NoteDataProvider implements DataProvider {
|
|
|
338
409
|
return nullifiedNotes;
|
|
339
410
|
});
|
|
340
411
|
}
|
|
341
|
-
|
|
342
|
-
async getSize() {
|
|
343
|
-
return (await this.getNotes({})).reduce((sum, note) => sum + note.getSize(), 0);
|
|
344
|
-
}
|
|
345
412
|
}
|