@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.0b941701
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +14 -10
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -32
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +28 -27
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +56 -40
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +10 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +43 -32
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -26
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +28 -41
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +44 -34
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +92 -92
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +5 -5
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +6 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +8 -7
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +8 -7
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +22 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -6
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/logs/log_service.d.ts +15 -31
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +77 -188
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +40 -44
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +4 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +17 -44
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +131 -147
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{anchor_block_data_provider/anchor_block_data_provider.js → anchor_block_store/anchor_block_store.js} +1 -1
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +255 -0
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +3 -3
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +2 -2
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +73 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +303 -0
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +250 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +99 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.d.ts → tagging_store/sender_tagging_store.d.ts} +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.js → tagging_store/sender_tagging_store.js} +111 -29
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -3
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +15 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +14 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +8 -8
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.d.ts +4 -4
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.js +8 -23
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.js +5 -8
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.d.ts +7 -4
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.js +12 -7
- package/package.json +18 -18
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +83 -34
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +79 -64
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +5 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -10
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +56 -41
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +77 -78
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +121 -105
- package/src/contract_function_simulator/proxied_contract_data_source.ts +7 -7
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +7 -6
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +2 -0
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +23 -27
- package/src/events/private_event_filter_validator.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +116 -260
- package/src/notes/note_service.ts +43 -46
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +189 -190
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +1 -1
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/capsule_store/capsule_store.ts +315 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +2 -2
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +381 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +363 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +129 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/{tagging_data_provider/sender_tagging_data_provider.ts → tagging_store/sender_tagging_store.ts} +129 -28
- package/src/tagging/constants.ts +10 -3
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +17 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +23 -9
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.ts +12 -25
- package/src/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.ts +19 -7
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +0 -9
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.d.ts +0 -2
- package/dest/storage/anchor_block_data_provider/index.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -57
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -146
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -84
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_data_provider.js +0 -322
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -115
- package/dest/storage/tagging_data_provider/index.d.ts +0 -3
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -2
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +0 -31
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +0 -65
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +0 -21
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +0 -42
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -25
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/anchor_block_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -179
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_data_provider.ts +0 -412
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -162
- package/src/storage/tagging_data_provider/index.ts +0 -2
- package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +0 -86
- package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +0 -53
- package/src/tagging/utils.ts +0 -32
- package/src/tree_membership/tree_membership_service.ts +0 -112
- /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
- /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
6
|
+
export declare class CapsuleStore implements StagedStore {
|
|
7
|
+
#private;
|
|
8
|
+
readonly storeName = "capsule";
|
|
9
|
+
logger: Logger;
|
|
10
|
+
constructor(store: AztecAsyncKVStore);
|
|
11
|
+
/**
|
|
12
|
+
* Commits staged data to main storage.
|
|
13
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
14
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't
|
|
15
|
+
* need our own transactionAsync here (and using one would deadlock on IndexedDB).
|
|
16
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
17
|
+
*/
|
|
18
|
+
commit(jobId: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Discards staged data without committing.
|
|
21
|
+
*/
|
|
22
|
+
discardStaged(jobId: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
25
|
+
* * If data was already stored at this slot, it is overwritten.
|
|
26
|
+
* @param contractAddress - The contract address to scope the data under.
|
|
27
|
+
* @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
|
|
28
|
+
* @param capsule - An array of field elements representing the capsule.
|
|
29
|
+
* @param jobId - The context in which this store will be visible until PXE decides to persist it to underlying KV store
|
|
30
|
+
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
31
|
+
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
32
|
+
* network state it's backed by local PXE db.
|
|
33
|
+
*/
|
|
34
|
+
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
37
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
38
|
+
* @param slot - The slot in the database to read.
|
|
39
|
+
* @returns The stored data or `null` if no data is stored under the slot.
|
|
40
|
+
*/
|
|
41
|
+
loadCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): Promise<Fr[] | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
44
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
45
|
+
* @param slot - The slot in the database to delete.
|
|
46
|
+
*/
|
|
47
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
50
|
+
* structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
|
|
51
|
+
* Supports overlapping source and destination regions (which will result in the overlapped source values being
|
|
52
|
+
* overwritten). All copied slots must exist in the database (i.e. have been stored and not deleted)
|
|
53
|
+
*
|
|
54
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
55
|
+
* @param srcSlot - The first slot to copy from.
|
|
56
|
+
* @param dstSlot - The first slot to copy to.
|
|
57
|
+
* @param numEntries - The number of entries to copy.
|
|
58
|
+
*/
|
|
59
|
+
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
62
|
+
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
63
|
+
* All operations are performed in a single transaction.
|
|
64
|
+
* @param contractAddress - The contract address that owns the capsule array
|
|
65
|
+
* @param baseSlot - The slot where the array length is stored
|
|
66
|
+
* @param content - Array of capsule data to append
|
|
67
|
+
*/
|
|
68
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void>;
|
|
69
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string): Promise<Fr[][]>;
|
|
70
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvY2Fwc3VsZV9zdG9yZS9jYXBzdWxlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sMENBQTBDLENBQUM7QUFFNUUscUJBQWEsWUFBYSxZQUFXLFdBQVc7O0lBQzlDLFFBQVEsQ0FBQyxTQUFTLGFBQWE7SUFZL0IsTUFBTSxFQUFFLE1BQU0sQ0FBQztJQUVmLFlBQVksS0FBSyxFQUFF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EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,QAKjF;IAED;;;;;OAKG;IACG,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAW9F;IAED;;;;OAIG;IACH,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,QAGnE;IAED;;;;;;;;;;OAUG;IACH,WAAW,CACT,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CA2Bf;IAED;;;;;;;OAOG;IACH,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB/G;IAED,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CA2B5F;IAED,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,iBA2B1F;CACF"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
export class CapsuleStore {
|
|
4
|
+
storeName = 'capsule';
|
|
5
|
+
#store;
|
|
6
|
+
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
7
|
+
#capsules;
|
|
8
|
+
// jobId => `${contractAddress}:${key}` => capsule data
|
|
9
|
+
// when `#stagedCapsules.get('some-job-id').get('${some-contract-address:some-key') === null`,
|
|
10
|
+
// it signals that the capsule was deleted during the job, so it needs to be deleted on commit
|
|
11
|
+
#stagedCapsules;
|
|
12
|
+
logger;
|
|
13
|
+
constructor(store){
|
|
14
|
+
this.#store = store;
|
|
15
|
+
this.#capsules = this.#store.openMap('capsules');
|
|
16
|
+
this.#stagedCapsules = new Map();
|
|
17
|
+
this.logger = createLogger('pxe:capsule-data-provider');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Given a job denoted by `jobId`, it returns the
|
|
21
|
+
* capsules that said job has interacted with.
|
|
22
|
+
*
|
|
23
|
+
* Capsules that haven't been committed to persistence KV storage
|
|
24
|
+
* are kept in-memory in `#stagedCapsules`, this method provides a convenient
|
|
25
|
+
* way to access that in-memory collection of data.
|
|
26
|
+
*
|
|
27
|
+
* @param jobId
|
|
28
|
+
* @returns
|
|
29
|
+
*/ #getJobStagedCapsules(jobId) {
|
|
30
|
+
let jobStagedCapsules = this.#stagedCapsules.get(jobId);
|
|
31
|
+
if (!jobStagedCapsules) {
|
|
32
|
+
jobStagedCapsules = new Map();
|
|
33
|
+
this.#stagedCapsules.set(jobId, jobStagedCapsules);
|
|
34
|
+
}
|
|
35
|
+
return jobStagedCapsules;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads a capsule's slot from the staged version of the data associated to the given jobId.
|
|
39
|
+
*
|
|
40
|
+
* If it is not there, it reads it from the KV store.
|
|
41
|
+
*/ async #getFromStage(jobId, dbSlotKey) {
|
|
42
|
+
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
43
|
+
let staged = jobStagedCapsules.get(dbSlotKey);
|
|
44
|
+
// Note that if staged === null, we marked it for deletion, so we don't want to
|
|
45
|
+
// re-read it from DB
|
|
46
|
+
if (staged === undefined) {
|
|
47
|
+
// If we don't have a staged version of this dbSlotKey, first we check if there's one in DB
|
|
48
|
+
staged = await this.#loadCapsuleFromDb(dbSlotKey);
|
|
49
|
+
}
|
|
50
|
+
return staged;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Writes a capsule to the stage of a job.
|
|
54
|
+
*/ #setOnStage(jobId, dbSlotKey, capsuleData) {
|
|
55
|
+
this.#getJobStagedCapsules(jobId).set(dbSlotKey, capsuleData);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Deletes a capsule on the stage of a job. Note the capsule will still
|
|
59
|
+
* exist in storage until the job is committed.
|
|
60
|
+
*/ #deleteOnStage(jobId, dbSlotKey) {
|
|
61
|
+
this.#getJobStagedCapsules(jobId).set(dbSlotKey, null);
|
|
62
|
+
}
|
|
63
|
+
async #loadCapsuleFromDb(dbSlotKey) {
|
|
64
|
+
const dataBuffer = await this.#capsules.getAsync(dbSlotKey);
|
|
65
|
+
if (!dataBuffer) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return dataBuffer;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Commits staged data to main storage.
|
|
72
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
73
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't
|
|
74
|
+
* need our own transactionAsync here (and using one would deadlock on IndexedDB).
|
|
75
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
76
|
+
*/ async commit(jobId) {
|
|
77
|
+
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
78
|
+
for (const [key, value] of jobStagedCapsules){
|
|
79
|
+
// In the write stage, we represent deleted capsules with null
|
|
80
|
+
// (as opposed to undefined, which denotes there was never a capsule there to begin with).
|
|
81
|
+
// So we delete from actual KV store here.
|
|
82
|
+
if (value === null) {
|
|
83
|
+
await this.#capsules.delete(key);
|
|
84
|
+
} else {
|
|
85
|
+
await this.#capsules.set(key, value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
this.#stagedCapsules.delete(jobId);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Discards staged data without committing.
|
|
92
|
+
*/ discardStaged(jobId) {
|
|
93
|
+
this.#stagedCapsules.delete(jobId);
|
|
94
|
+
return Promise.resolve();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
98
|
+
* * If data was already stored at this slot, it is overwritten.
|
|
99
|
+
* @param contractAddress - The contract address to scope the data under.
|
|
100
|
+
* @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
|
|
101
|
+
* @param capsule - An array of field elements representing the capsule.
|
|
102
|
+
* @param jobId - The context in which this store will be visible until PXE decides to persist it to underlying KV store
|
|
103
|
+
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
104
|
+
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
105
|
+
* network state it's backed by local PXE db.
|
|
106
|
+
*/ storeCapsule(contractAddress, slot, capsule, jobId) {
|
|
107
|
+
const dbSlotKey = dbSlotToKey(contractAddress, slot);
|
|
108
|
+
// A store overrides any pre-existing data on the slot
|
|
109
|
+
this.#setOnStage(jobId, dbSlotKey, Buffer.concat(capsule.map((value)=>value.toBuffer())));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
113
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
114
|
+
* @param slot - The slot in the database to read.
|
|
115
|
+
* @returns The stored data or `null` if no data is stored under the slot.
|
|
116
|
+
*/ async loadCapsule(contractAddress, slot, jobId) {
|
|
117
|
+
const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
118
|
+
if (!dataBuffer) {
|
|
119
|
+
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const capsule = [];
|
|
123
|
+
for(let i = 0; i < dataBuffer.length; i += Fr.SIZE_IN_BYTES){
|
|
124
|
+
capsule.push(Fr.fromBuffer(dataBuffer.subarray(i, i + Fr.SIZE_IN_BYTES)));
|
|
125
|
+
}
|
|
126
|
+
return capsule;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
130
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
131
|
+
* @param slot - The slot in the database to delete.
|
|
132
|
+
*/ deleteCapsule(contractAddress, slot, jobId) {
|
|
133
|
+
// When we commit this, we will interpret null as a deletion, so we'll propagate the delete to the KV store
|
|
134
|
+
this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
138
|
+
* structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
|
|
139
|
+
* Supports overlapping source and destination regions (which will result in the overlapped source values being
|
|
140
|
+
* overwritten). All copied slots must exist in the database (i.e. have been stored and not deleted)
|
|
141
|
+
*
|
|
142
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
143
|
+
* @param srcSlot - The first slot to copy from.
|
|
144
|
+
* @param dstSlot - The first slot to copy to.
|
|
145
|
+
* @param numEntries - The number of entries to copy.
|
|
146
|
+
*/ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId) {
|
|
147
|
+
// This transactional context gives us "copy atomicity":
|
|
148
|
+
// there shouldn't be concurrent writes to what's being copied here.
|
|
149
|
+
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
150
|
+
// and not using a transaction here would heavily impact performance.
|
|
151
|
+
return this.#store.transactionAsync(async ()=>{
|
|
152
|
+
// In order to support overlapping source and destination regions, we need to check the relative positions of source
|
|
153
|
+
// and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
|
|
154
|
+
// indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
|
|
155
|
+
// indexes to avoid reading elements that've been overwritten.
|
|
156
|
+
const indexes = Array.from(Array(numEntries).keys());
|
|
157
|
+
if (srcSlot.lt(dstSlot)) {
|
|
158
|
+
indexes.reverse();
|
|
159
|
+
}
|
|
160
|
+
for (const i of indexes){
|
|
161
|
+
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
162
|
+
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
163
|
+
const toCopy = await this.#getFromStage(jobId, currentSrcSlot);
|
|
164
|
+
if (!toCopy) {
|
|
165
|
+
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
166
|
+
}
|
|
167
|
+
this.#setOnStage(jobId, currentDstSlot, toCopy);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
173
|
+
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
174
|
+
* All operations are performed in a single transaction.
|
|
175
|
+
* @param contractAddress - The contract address that owns the capsule array
|
|
176
|
+
* @param baseSlot - The slot where the array length is stored
|
|
177
|
+
* @param content - Array of capsule data to append
|
|
178
|
+
*/ appendToCapsuleArray(contractAddress, baseSlot, content, jobId) {
|
|
179
|
+
// We wrap this in a transaction to serialize concurrent calls from Promise.all.
|
|
180
|
+
// Without this, concurrent appends to the same array could race: both read length=0,
|
|
181
|
+
// both write at the same slots, one overwrites the other.
|
|
182
|
+
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
183
|
+
// and not using a transaction here would heavily impact performance.
|
|
184
|
+
return this.#store.transactionAsync(async ()=>{
|
|
185
|
+
// Load current length, defaulting to 0 if not found
|
|
186
|
+
const lengthData = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
187
|
+
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
188
|
+
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
189
|
+
for(let i = 0; i < content.length; i++){
|
|
190
|
+
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
191
|
+
this.storeCapsule(contractAddress, nextSlot, content[i], jobId);
|
|
192
|
+
}
|
|
193
|
+
// Update length to include all new capsules
|
|
194
|
+
const newLength = currentLength + content.length;
|
|
195
|
+
this.storeCapsule(contractAddress, baseSlot, [
|
|
196
|
+
new Fr(newLength)
|
|
197
|
+
], jobId);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
readCapsuleArray(contractAddress, baseSlot, jobId) {
|
|
201
|
+
// I'm leaving this transactional context here though because I'm assuming this
|
|
202
|
+
// gives us "read array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
203
|
+
// here.
|
|
204
|
+
// This is one point we should revisit in the future if we want to relax the concurrency
|
|
205
|
+
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
206
|
+
return this.#store.transactionAsync(async ()=>{
|
|
207
|
+
// Load length, defaulting to 0 if not found
|
|
208
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
209
|
+
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
210
|
+
const values = [];
|
|
211
|
+
// Read each capsule at consecutive slots after baseSlot
|
|
212
|
+
for(let i = 0; i < length; i++){
|
|
213
|
+
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
214
|
+
if (currentValue == undefined) {
|
|
215
|
+
throw new Error(`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`);
|
|
216
|
+
}
|
|
217
|
+
values.push(currentValue);
|
|
218
|
+
}
|
|
219
|
+
return values;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
setCapsuleArray(contractAddress, baseSlot, content, jobId) {
|
|
223
|
+
// This transactional context in theory isn't so critical now because we aren't
|
|
224
|
+
// writing to DB so if there's exceptions midway and it blows up, no visible impact
|
|
225
|
+
// to persistent storage will happen.
|
|
226
|
+
// I'm leaving this transactional context here though because I'm assuming this
|
|
227
|
+
// gives us "write array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
228
|
+
// here.
|
|
229
|
+
// This is one point we should revisit in the future if we want to relax the concurrency
|
|
230
|
+
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
231
|
+
return this.#store.transactionAsync(async ()=>{
|
|
232
|
+
// Load current length, defaulting to 0 if not found
|
|
233
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
234
|
+
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
235
|
+
// Set the new length
|
|
236
|
+
this.storeCapsule(contractAddress, baseSlot, [
|
|
237
|
+
new Fr(content.length)
|
|
238
|
+
], jobId);
|
|
239
|
+
// Store the new content, possibly overwriting existing values
|
|
240
|
+
for(let i = 0; i < content.length; i++){
|
|
241
|
+
this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId);
|
|
242
|
+
}
|
|
243
|
+
// Clear any stragglers
|
|
244
|
+
for(let i = content.length; i < originalLength; i++){
|
|
245
|
+
this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function dbSlotToKey(contractAddress, slot) {
|
|
251
|
+
return `${contractAddress.toString()}:${slot.toString()}`;
|
|
252
|
+
}
|
|
253
|
+
function arraySlot(baseSlot, index) {
|
|
254
|
+
return baseSlot.add(new Fr(1)).add(new Fr(index));
|
|
255
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { CapsuleStore } from './capsule_store.js';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NhcHN1bGVfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLG9CQUFvQixDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CapsuleStore } from './capsule_store.js';
|
|
@@ -6,13 +6,13 @@ import { type ContractArtifact, type FunctionAbi, type FunctionArtifactWithContr
|
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { type ContractClass, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
10
10
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
11
11
|
* from a given contract address and function selector. The class maintains a cache of ContractTree instances
|
|
12
12
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
13
13
|
* the required information and facilitate cryptographic proof generation.
|
|
14
14
|
*/
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class ContractStore {
|
|
16
16
|
#private;
|
|
17
17
|
constructor(store: AztecAsyncKVStore);
|
|
18
18
|
addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void>;
|
|
@@ -63,4 +63,4 @@ export declare class ContractDataProvider {
|
|
|
63
63
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
64
64
|
getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall>;
|
|
65
65
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
66
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJ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,CAU3C;IAEY,yBAAyB,CACpC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC,CAIvD;IAEY,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGlC;IAED;;;;;;;;;OASG;IACU,wBAAwB,CACnC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAEY,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAED;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAGrE;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,+BAG9D;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,mBAI1F;IA8BY,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAuBvG;CACF"}
|
|
@@ -4,12 +4,12 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
4
4
|
import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
5
5
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
8
8
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
9
9
|
* from a given contract address and function selector. The class maintains a cache of ContractTree instances
|
|
10
10
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
11
11
|
* the required information and facilitate cryptographic proof generation.
|
|
12
|
-
*/ export class
|
|
12
|
+
*/ export class ContractStore {
|
|
13
13
|
/** Map from contract class id to private function tree. */ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
14
14
|
#privateFunctionTrees = new Map();
|
|
15
15
|
/** Map from contract address to contract class id */ #contractClassIdMap = new Map();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { ContractStore } from './contract_store.js';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NvbnRyYWN0X3N0b3JlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContractStore } from './contract_store.js';
|
|
@@ -24,4 +24,4 @@ export declare class PrivateFunctionsTree {
|
|
|
24
24
|
getFunctionMembershipWitness(selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
|
|
25
25
|
private getTree;
|
|
26
26
|
}
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9mdW5jdGlvbnNfdHJlZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc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,CAAC,CAAa;IAE1B,OAAO,eAAqE;IAE5E,OAAa,MAAM,CAAC,QAAQ,EAAE,gBAAgB,iCAO7C;IAED;;;;;;;;OAQG;IACU,4BAA4B,CACvC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAezD;YAEa,OAAO;CAMtB"}
|
package/dest/storage/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './address_store/index.js';
|
|
2
|
+
export * from './capsule_store/index.js';
|
|
3
|
+
export * from './contract_store/index.js';
|
|
4
|
+
export * from './note_store/index.js';
|
|
5
|
+
export * from './anchor_block_store/index.js';
|
|
6
|
+
export * from './tagging_store/index.js';
|
|
7
7
|
export * from './metadata.js';
|
|
8
|
-
export * from './
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
export * from './private_event_store/private_event_store.js';
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsMEJBQTBCLENBQUM7QUFDekMsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLDJCQUEyQixDQUFDO0FBQzFDLGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYywrQkFBK0IsQ0FBQztBQUM5QyxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLGNBQWMsZUFBZSxDQUFDO0FBQzlCLGNBQWMsOENBQThDLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,8CAA8C,CAAC"}
|
package/dest/storage/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './address_store/index.js';
|
|
2
|
+
export * from './capsule_store/index.js';
|
|
3
|
+
export * from './contract_store/index.js';
|
|
4
|
+
export * from './note_store/index.js';
|
|
5
|
+
export * from './anchor_block_store/index.js';
|
|
6
|
+
export * from './tagging_store/index.js';
|
|
7
7
|
export * from './metadata.js';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './private_event_store/private_event_store.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NoteDao } from '@aztec/stdlib/note';
|
|
2
|
+
export { NoteStore } from './note_store.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL25vdGVfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBQzdDLE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/note_store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/schemas';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
5
|
+
import { NoteDao, type NotesFilter } from '@aztec/stdlib/note';
|
|
6
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
7
|
+
/**
|
|
8
|
+
* NoteStore manages the storage and retrieval of notes.
|
|
9
|
+
*
|
|
10
|
+
* Notes can be active or nullified. This class processes new notes, nullifications, and performs rollback handling in
|
|
11
|
+
* the case of a reorg.
|
|
12
|
+
**/
|
|
13
|
+
export declare class NoteStore implements StagedStore {
|
|
14
|
+
#private;
|
|
15
|
+
readonly storeName: string;
|
|
16
|
+
constructor(store: AztecAsyncKVStore);
|
|
17
|
+
/**
|
|
18
|
+
* Adds multiple notes to the notes store under the specified scope.
|
|
19
|
+
*
|
|
20
|
+
* Notes are stored using their siloedNullifier as the key, which provides uniqueness. Each note is indexed by
|
|
21
|
+
* multiple criteria for efficient retrieval.
|
|
22
|
+
*
|
|
23
|
+
* @param notes - Notes to store
|
|
24
|
+
* @param scope - The scope (user/account) under which to store the notes
|
|
25
|
+
* @param jobId - The job context for staged writes
|
|
26
|
+
*/
|
|
27
|
+
addNotes(notes: NoteDao[], scope: AztecAddress, jobId: string): Promise<void[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves notes based on the provided filter criteria.
|
|
30
|
+
*
|
|
31
|
+
* This method queries both active and optionally nullified notes based on the filter parameters.
|
|
32
|
+
*
|
|
33
|
+
* @param filter - Filter criteria including contractAddress (required), and optional owner,
|
|
34
|
+
* storageSlot, status, scopes, and siloedNullifier.
|
|
35
|
+
* @params jobId - the job context to read from.
|
|
36
|
+
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
37
|
+
* returned once if this is the case)
|
|
38
|
+
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
39
|
+
*/
|
|
40
|
+
getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Transitions notes from "active" to "nullified" state.
|
|
43
|
+
*
|
|
44
|
+
* This operation processes a batch of nullifiers to mark the corresponding notes as spent/nullified.
|
|
45
|
+
* The operation is atomic - if any nullifier is not found, the entire operation fails and no notes are modified.
|
|
46
|
+
*
|
|
47
|
+
* applyNullifiers is idempotent: the same nullifier can be applied multiple times without error.
|
|
48
|
+
* This relaxes constraints on usage of NoteService#validateAndStoreNote, which can then be run concurrently in a Promise.all
|
|
49
|
+
* context without risking unnecessarily defensive checks failing.
|
|
50
|
+
*
|
|
51
|
+
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
52
|
+
* @param jobId - The job context for staged writes
|
|
53
|
+
* @returns Array of NoteDao objects that were nullified
|
|
54
|
+
* @throws Error if any nullifier is not found in this notes store
|
|
55
|
+
*/
|
|
56
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[], jobId: string): Promise<NoteDao[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Synchronizes notes and nullifiers to a specific block number.
|
|
59
|
+
*
|
|
60
|
+
* This method ensures that the state of notes and nullifiers is consistent with the specified block number.
|
|
61
|
+
* It restores any notes that were nullified after the given block and deletes any active notes created after that
|
|
62
|
+
* block.
|
|
63
|
+
*
|
|
64
|
+
* IMPORTANT: This method must be called within a transaction to ensure atomicity.
|
|
65
|
+
*
|
|
66
|
+
* @param blockNumber - The new chain tip after a reorg
|
|
67
|
+
* @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
|
|
68
|
+
*/
|
|
69
|
+
rollback(blockNumber: number, synchedBlockNumber: number): Promise<void>;
|
|
70
|
+
commit(jobId: string): Promise<void>;
|
|
71
|
+
discardStaged(jobId: string): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2Uvbm90ZV9zdG9yZS9ub3RlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFxQyxNQUFNLGlCQUFpQixDQUFDO0FBQzVGLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxPQUFPLEVBQWMsS0FBSyxXQUFXLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUUzRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwwQ0FBMEMsQ0FBQztBQUc1RTs7Ozs7SUFLSTtBQUNKLHFCQUFhLFNBQVUsWUFBVyxXQUFXOztJQUMzQyxRQUFRLENBQUMsU0FBUyxFQUFFLE1BQU0sQ0FBVTtJQStCcEMsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBUW5DO0lBRUQ7Ozs7Ozs7OztPQVNHO0lBQ0ksUUFBUSxDQUFDLEtBQUssRUFBRSxPQUFPLEVBQUUsRUFBRSxLQUFLLEVBQUUsWUF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