@aztec/pxe 0.0.1-commit.d3ec352c → 0.0.1-commit.d6f2b3f94
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 +105 -15
- package/dest/block_synchronizer/block_synchronizer.d.ts +45 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +153 -0
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +6 -4
- 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 +42 -14
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +74 -33
- package/dest/contract_function_simulator/execution_note_cache.d.ts +21 -12
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +48 -31
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +6 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +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 +22 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +4 -2
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +11 -7
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +14 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts +11 -9
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +82 -48
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -28
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +2 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +34 -25
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +41 -45
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +88 -32
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +201 -74
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
- package/dest/contract_sync/contract_sync_service.d.ts +41 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +82 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +44 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +48 -0
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +23 -8
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +24 -9
- package/dest/entrypoints/pxe_creation_options.d.ts +7 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +30 -15
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +44 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +9 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +38 -0
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +28 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +123 -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 +147 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/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 +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +10 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +26 -29
- 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 +56 -81
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +209 -217
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -12
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +10 -10
- package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +253 -0
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +7 -5
- 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} +56 -16
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +83 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +344 -0
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +91 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +273 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +36 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +77 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +348 -0
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -2
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +46 -0
- package/dest/tagging/index.d.ts +16 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +15 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +15 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +15 -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 +32 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +21 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +29 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +21 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +60 -0
- package/package.json +27 -18
- package/src/bin/check_oracle_version.ts +131 -20
- package/src/block_synchronizer/block_synchronizer.ts +178 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +17 -3
- 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 +117 -34
- package/src/contract_function_simulator/execution_note_cache.ts +51 -29
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -2
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +6 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +27 -17
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +27 -13
- package/src/contract_function_simulator/oracle/oracle.ts +97 -51
- package/src/contract_function_simulator/oracle/private_execution.ts +2 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +121 -59
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +294 -91
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
- package/src/contract_sync/contract_sync_service.ts +129 -0
- package/src/contract_sync/helpers.ts +93 -0
- package/src/debug/pxe_debug_utils.ts +91 -0
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +15 -16
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +16 -17
- package/src/entrypoints/pxe_creation_options.ts +6 -2
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +26 -34
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +71 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +46 -0
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +220 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +195 -0
- 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} +34 -23
- package/src/private_kernel/private_kernel_execution_prover.ts +13 -12
- package/src/private_kernel/private_kernel_oracle.ts +118 -37
- package/src/pxe.ts +299 -280
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +10 -12
- 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} +67 -14
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
- package/src/storage/index.ts +7 -7
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +415 -0
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +384 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +48 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +429 -0
- package/src/tagging/constants.ts +10 -2
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +18 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +143 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +49 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +99 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +36 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +84 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -267
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -123
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -696
- 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 -45
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -118
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.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 -83
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_data_provider.js +0 -314
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
- 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 -105
- 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 -11
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -36
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/synchronizer/synchronizer.js +0 -102
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -24
- package/src/contract_function_simulator/execution_data_provider.ts +0 -342
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1023
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/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 -403
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -143
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
- package/src/synchronizer/index.ts +0 -1
- package/src/synchronizer/synchronizer.ts +0 -121
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
|
@@ -3,7 +3,7 @@ import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/k
|
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
|
|
6
|
-
export class
|
|
6
|
+
export class AddressStore {
|
|
7
7
|
#store: AztecAsyncKVStore;
|
|
8
8
|
#completeAddresses: AztecAsyncArray<Buffer>;
|
|
9
9
|
#completeAddressIndex: AztecAsyncMap<string, number>;
|
|
@@ -43,23 +43,23 @@ export class AddressDataProvider {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
async #getCompleteAddress(address: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
47
|
-
const index = await this.#completeAddressIndex.getAsync(address.toString());
|
|
48
|
-
if (index === undefined) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const value = await this.#completeAddresses.atAsync(index);
|
|
53
|
-
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
46
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
|
|
57
|
-
return this.#
|
|
47
|
+
return this.#store.transactionAsync(async () => {
|
|
48
|
+
const index = await this.#completeAddressIndex.getAsync(account.toString());
|
|
49
|
+
if (index === undefined) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const value = await this.#completeAddresses.atAsync(index);
|
|
54
|
+
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
55
|
+
});
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
getCompleteAddresses(): Promise<CompleteAddress[]> {
|
|
59
|
+
return this.#store.transactionAsync(async () => {
|
|
60
|
+
return await Promise.all(
|
|
61
|
+
(await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AddressStore } from './address_store.js';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
1
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
3
2
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
4
3
|
|
|
5
|
-
export class
|
|
4
|
+
export class AnchorBlockStore {
|
|
6
5
|
#store: AztecAsyncKVStore;
|
|
7
6
|
#synchronizedHeader: AztecAsyncSingleton<Buffer>;
|
|
8
7
|
|
|
@@ -11,23 +10,22 @@ export class SyncDataProvider {
|
|
|
11
10
|
this.#synchronizedHeader = this.#store.openSingleton('header');
|
|
12
11
|
}
|
|
13
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Sets the currently synchronized block
|
|
15
|
+
*
|
|
16
|
+
* Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
|
|
17
|
+
* stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
|
|
18
|
+
* deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
14
21
|
async setHeader(header: BlockHeader): Promise<void> {
|
|
15
22
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
async getBlockNumber(): Promise<BlockNumber> {
|
|
19
|
-
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
20
|
-
if (!headerBuffer) {
|
|
21
|
-
throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return BlockHeader.fromBuffer(headerBuffer).globalVariables.blockNumber;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
25
|
async getBlockHeader(): Promise<BlockHeader> {
|
|
28
26
|
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
29
27
|
if (!headerBuffer) {
|
|
30
|
-
throw new Error(`
|
|
28
|
+
throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
return BlockHeader.fromBuffer(headerBuffer);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AnchorBlockStore } from './anchor_block_store.js';
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
|
|
6
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
7
|
+
|
|
8
|
+
export class CapsuleStore implements StagedStore {
|
|
9
|
+
readonly storeName = 'capsule';
|
|
10
|
+
|
|
11
|
+
#store: AztecAsyncKVStore;
|
|
12
|
+
|
|
13
|
+
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
14
|
+
#capsules: AztecAsyncMap<string, Buffer>;
|
|
15
|
+
|
|
16
|
+
// jobId => `${contractAddress}:${key}` => capsule data
|
|
17
|
+
// when `#stagedCapsules.get('some-job-id').get('${some-contract-address:some-key') === null`,
|
|
18
|
+
// it signals that the capsule was deleted during the job, so it needs to be deleted on commit
|
|
19
|
+
#stagedCapsules: Map<string, Map<string, Buffer | null>>;
|
|
20
|
+
|
|
21
|
+
logger: Logger;
|
|
22
|
+
|
|
23
|
+
constructor(store: AztecAsyncKVStore) {
|
|
24
|
+
this.#store = store;
|
|
25
|
+
|
|
26
|
+
this.#capsules = this.#store.openMap('capsules');
|
|
27
|
+
|
|
28
|
+
this.#stagedCapsules = new Map();
|
|
29
|
+
|
|
30
|
+
this.logger = createLogger('pxe:capsule-data-provider');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Given a job denoted by `jobId`, it returns the
|
|
35
|
+
* capsules that said job has interacted with.
|
|
36
|
+
*
|
|
37
|
+
* Capsules that haven't been committed to persistence KV storage
|
|
38
|
+
* are kept in-memory in `#stagedCapsules`, this method provides a convenient
|
|
39
|
+
* way to access that in-memory collection of data.
|
|
40
|
+
*
|
|
41
|
+
* @param jobId
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
#getJobStagedCapsules(jobId: string): Map<string, Buffer | null> {
|
|
45
|
+
let jobStagedCapsules = this.#stagedCapsules.get(jobId);
|
|
46
|
+
if (!jobStagedCapsules) {
|
|
47
|
+
jobStagedCapsules = new Map();
|
|
48
|
+
this.#stagedCapsules.set(jobId, jobStagedCapsules);
|
|
49
|
+
}
|
|
50
|
+
return jobStagedCapsules;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Reads a capsule's slot from the staged version of the data associated to the given jobId.
|
|
55
|
+
*
|
|
56
|
+
* If it is not there, it reads it from the KV store.
|
|
57
|
+
*/
|
|
58
|
+
async #getFromStage(jobId: string, dbSlotKey: string): Promise<Buffer | null | undefined> {
|
|
59
|
+
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
60
|
+
const staged: Buffer | null | undefined = jobStagedCapsules.get(dbSlotKey);
|
|
61
|
+
|
|
62
|
+
// Always issue DB read to keep IndexedDB transaction alive, even if the value is in the job staged data. This
|
|
63
|
+
// keeps IndexedDB transactions alive (they auto-commit when a new micro-task starts and there are no pending read
|
|
64
|
+
// requests). The staged value still takes precedence if it exists (including null for deletions).
|
|
65
|
+
const dbValue = await this.#loadCapsuleFromDb(dbSlotKey);
|
|
66
|
+
|
|
67
|
+
return staged !== undefined ? staged : dbValue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Writes a capsule to the stage of a job.
|
|
72
|
+
*/
|
|
73
|
+
#setOnStage(jobId: string, dbSlotKey: string, capsuleData: Buffer) {
|
|
74
|
+
this.#getJobStagedCapsules(jobId).set(dbSlotKey, capsuleData);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Deletes a capsule on the stage of a job. Note the capsule will still
|
|
79
|
+
* exist in storage until the job is committed.
|
|
80
|
+
*/
|
|
81
|
+
#deleteOnStage(jobId: string, dbSlotKey: string) {
|
|
82
|
+
this.#getJobStagedCapsules(jobId).set(dbSlotKey, null);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async #loadCapsuleFromDb(dbSlotKey: string): Promise<Buffer | null> {
|
|
86
|
+
const dataBuffer = await this.#capsules.getAsync(dbSlotKey);
|
|
87
|
+
if (!dataBuffer) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return dataBuffer;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Commits staged data to main storage.
|
|
96
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
97
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't
|
|
98
|
+
* need our own transactionAsync here (and using one would deadlock on IndexedDB).
|
|
99
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
100
|
+
*/
|
|
101
|
+
async commit(jobId: string): Promise<void> {
|
|
102
|
+
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
103
|
+
|
|
104
|
+
for (const [key, value] of jobStagedCapsules) {
|
|
105
|
+
// In the write stage, we represent deleted capsules with null
|
|
106
|
+
// (as opposed to undefined, which denotes there was never a capsule there to begin with).
|
|
107
|
+
// So we delete from actual KV store here.
|
|
108
|
+
if (value === null) {
|
|
109
|
+
await this.#capsules.delete(key);
|
|
110
|
+
} else {
|
|
111
|
+
await this.#capsules.set(key, value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.#stagedCapsules.delete(jobId);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Discards staged data without committing.
|
|
120
|
+
*/
|
|
121
|
+
discardStaged(jobId: string): Promise<void> {
|
|
122
|
+
this.#stagedCapsules.delete(jobId);
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
128
|
+
* * If data was already stored at this slot, it is overwritten.
|
|
129
|
+
* @param contractAddress - The contract address to scope the data under.
|
|
130
|
+
* @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
|
|
131
|
+
* @param capsule - An array of field elements representing the capsule.
|
|
132
|
+
* @param jobId - The context in which this store will be visible until PXE decides to persist it to underlying KV store
|
|
133
|
+
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
134
|
+
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
135
|
+
* network state it's backed by local PXE db.
|
|
136
|
+
*/
|
|
137
|
+
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string) {
|
|
138
|
+
const dbSlotKey = dbSlotToKey(contractAddress, slot);
|
|
139
|
+
|
|
140
|
+
// A store overrides any pre-existing data on the slot
|
|
141
|
+
this.#setOnStage(jobId, dbSlotKey, Buffer.concat(capsule.map(value => value.toBuffer())));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
146
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
147
|
+
* @param slot - The slot in the database to read.
|
|
148
|
+
* @returns The stored data or `null` if no data is stored under the slot.
|
|
149
|
+
*/
|
|
150
|
+
async loadCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): Promise<Fr[] | null> {
|
|
151
|
+
const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
152
|
+
if (!dataBuffer) {
|
|
153
|
+
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const capsule: Fr[] = [];
|
|
157
|
+
for (let i = 0; i < dataBuffer.length; i += Fr.SIZE_IN_BYTES) {
|
|
158
|
+
capsule.push(Fr.fromBuffer(dataBuffer.subarray(i, i + Fr.SIZE_IN_BYTES)));
|
|
159
|
+
}
|
|
160
|
+
return capsule;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
165
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
166
|
+
* @param slot - The slot in the database to delete.
|
|
167
|
+
*/
|
|
168
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string) {
|
|
169
|
+
// When we commit this, we will interpret null as a deletion, so we'll propagate the delete to the KV store
|
|
170
|
+
this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
175
|
+
* structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
|
|
176
|
+
* Supports overlapping source and destination regions (which will result in the overlapped source values being
|
|
177
|
+
* overwritten). All copied slots must exist in the database (i.e. have been stored and not deleted)
|
|
178
|
+
*
|
|
179
|
+
* @param contractAddress - The contract address under which the data is scoped.
|
|
180
|
+
* @param srcSlot - The first slot to copy from.
|
|
181
|
+
* @param dstSlot - The first slot to copy to.
|
|
182
|
+
* @param numEntries - The number of entries to copy.
|
|
183
|
+
*/
|
|
184
|
+
copyCapsule(
|
|
185
|
+
contractAddress: AztecAddress,
|
|
186
|
+
srcSlot: Fr,
|
|
187
|
+
dstSlot: Fr,
|
|
188
|
+
numEntries: number,
|
|
189
|
+
jobId: string,
|
|
190
|
+
): Promise<void> {
|
|
191
|
+
// This transactional context gives us "copy atomicity":
|
|
192
|
+
// there shouldn't be concurrent writes to what's being copied here.
|
|
193
|
+
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
194
|
+
// and not using a transaction here would heavily impact performance.
|
|
195
|
+
return this.#store.transactionAsync(async () => {
|
|
196
|
+
// In order to support overlapping source and destination regions, we need to check the relative positions of source
|
|
197
|
+
// and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
|
|
198
|
+
// indexes we'll have already read those. On the contrary, if source is ahead of destination we need to use backward
|
|
199
|
+
// indexes to avoid reading elements that've been overwritten.
|
|
200
|
+
const indexes = Array.from(Array(numEntries).keys());
|
|
201
|
+
if (srcSlot.lt(dstSlot)) {
|
|
202
|
+
indexes.reverse();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
for (const i of indexes) {
|
|
206
|
+
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
207
|
+
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
208
|
+
|
|
209
|
+
const toCopy = await this.#getFromStage(jobId, currentSrcSlot);
|
|
210
|
+
if (!toCopy) {
|
|
211
|
+
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.#setOnStage(jobId, currentDstSlot, toCopy);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
221
|
+
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
222
|
+
* All operations are performed in a single transaction.
|
|
223
|
+
* @param contractAddress - The contract address that owns the capsule array
|
|
224
|
+
* @param baseSlot - The slot where the array length is stored
|
|
225
|
+
* @param content - Array of capsule data to append
|
|
226
|
+
*/
|
|
227
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void> {
|
|
228
|
+
// We wrap this in a transaction to serialize concurrent calls from Promise.all.
|
|
229
|
+
// Without this, concurrent appends to the same array could race: both read length=0,
|
|
230
|
+
// both write at the same slots, one overwrites the other.
|
|
231
|
+
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
232
|
+
// and not using a transaction here would heavily impact performance.
|
|
233
|
+
return this.#store.transactionAsync(async () => {
|
|
234
|
+
// Load current length, defaulting to 0 if not found
|
|
235
|
+
const lengthData = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
236
|
+
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
237
|
+
|
|
238
|
+
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
239
|
+
for (let i = 0; i < content.length; i++) {
|
|
240
|
+
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
241
|
+
this.storeCapsule(contractAddress, nextSlot, content[i], jobId);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Update length to include all new capsules
|
|
245
|
+
const newLength = currentLength + content.length;
|
|
246
|
+
this.storeCapsule(contractAddress, baseSlot, [new Fr(newLength)], jobId);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string): Promise<Fr[][]> {
|
|
251
|
+
// I'm leaving this transactional context here though because I'm assuming this
|
|
252
|
+
// gives us "read array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
253
|
+
// here.
|
|
254
|
+
// This is one point we should revisit in the future if we want to relax the concurrency
|
|
255
|
+
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
256
|
+
return this.#store.transactionAsync(async () => {
|
|
257
|
+
// Load length, defaulting to 0 if not found
|
|
258
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
259
|
+
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
260
|
+
|
|
261
|
+
const values: Fr[][] = [];
|
|
262
|
+
|
|
263
|
+
// Read each capsule at consecutive slots after baseSlot
|
|
264
|
+
for (let i = 0; i < length; i++) {
|
|
265
|
+
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
266
|
+
if (currentValue == undefined) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
values.push(currentValue);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return values;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string) {
|
|
280
|
+
// This transactional context in theory isn't so critical now because we aren't
|
|
281
|
+
// writing to DB so if there's exceptions midway and it blows up, no visible impact
|
|
282
|
+
// to persistent storage will happen.
|
|
283
|
+
// I'm leaving this transactional context here though because I'm assuming this
|
|
284
|
+
// gives us "write array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
285
|
+
// here.
|
|
286
|
+
// This is one point we should revisit in the future if we want to relax the concurrency
|
|
287
|
+
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
288
|
+
return this.#store.transactionAsync(async () => {
|
|
289
|
+
// Load current length, defaulting to 0 if not found
|
|
290
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
291
|
+
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
292
|
+
|
|
293
|
+
// Set the new length
|
|
294
|
+
this.storeCapsule(contractAddress, baseSlot, [new Fr(content.length)], jobId);
|
|
295
|
+
|
|
296
|
+
// Store the new content, possibly overwriting existing values
|
|
297
|
+
for (let i = 0; i < content.length; i++) {
|
|
298
|
+
this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Clear any stragglers
|
|
302
|
+
for (let i = content.length; i < originalLength; i++) {
|
|
303
|
+
this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function dbSlotToKey(contractAddress: AztecAddress, slot: Fr): string {
|
|
310
|
+
return `${contractAddress.toString()}:${slot.toString()}`;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function arraySlot(baseSlot: Fr, index: number) {
|
|
314
|
+
return baseSlot.add(new Fr(1)).add(new Fr(index));
|
|
315
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CapsuleStore } from './capsule_store.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
@@ -8,11 +8,13 @@ import {
|
|
|
8
8
|
type FunctionAbi,
|
|
9
9
|
type FunctionArtifact,
|
|
10
10
|
type FunctionArtifactWithContractName,
|
|
11
|
+
FunctionCall,
|
|
11
12
|
type FunctionDebugMetadata,
|
|
12
13
|
FunctionSelector,
|
|
13
14
|
FunctionType,
|
|
14
15
|
contractArtifactFromBuffer,
|
|
15
16
|
contractArtifactToBuffer,
|
|
17
|
+
encodeArguments,
|
|
16
18
|
getFunctionDebugMetadata,
|
|
17
19
|
} from '@aztec/stdlib/abi';
|
|
18
20
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -26,13 +28,13 @@ import {
|
|
|
26
28
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
31
|
+
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
30
32
|
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
31
33
|
* from a given contract address and function selector. The class maintains a cache of ContractTree instances
|
|
32
34
|
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
33
35
|
* the required information and facilitate cryptographic proof generation.
|
|
34
36
|
*/
|
|
35
|
-
export class
|
|
37
|
+
export class ContractStore {
|
|
36
38
|
/** Map from contract class id to private function tree. */
|
|
37
39
|
// TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
38
40
|
#privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
|
|
@@ -40,10 +42,12 @@ export class ContractDataProvider {
|
|
|
40
42
|
/** Map from contract address to contract class id */
|
|
41
43
|
#contractClassIdMap: Map<string, Fr> = new Map();
|
|
42
44
|
|
|
45
|
+
#store: AztecAsyncKVStore;
|
|
43
46
|
#contractArtifacts: AztecAsyncMap<string, Buffer>;
|
|
44
47
|
#contractInstances: AztecAsyncMap<string, Buffer>;
|
|
45
48
|
|
|
46
49
|
constructor(store: AztecAsyncKVStore) {
|
|
50
|
+
this.#store = store;
|
|
47
51
|
this.#contractArtifacts = store.openMap('contract_artifacts');
|
|
48
52
|
this.#contractInstances = store.openMap('contracts_instances');
|
|
49
53
|
}
|
|
@@ -51,6 +55,7 @@ export class ContractDataProvider {
|
|
|
51
55
|
// Setters
|
|
52
56
|
|
|
53
57
|
public async addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void> {
|
|
58
|
+
// Validation outside transactionAsync - these are not DB operations
|
|
54
59
|
const privateFunctions = contract.functions.filter(
|
|
55
60
|
functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE,
|
|
56
61
|
);
|
|
@@ -67,7 +72,9 @@ export class ContractDataProvider {
|
|
|
67
72
|
throw new Error('Repeated function selectors of private functions');
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
await this.#
|
|
75
|
+
await this.#store.transactionAsync(() =>
|
|
76
|
+
this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract)),
|
|
77
|
+
);
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
|
|
@@ -121,21 +128,27 @@ export class ContractDataProvider {
|
|
|
121
128
|
|
|
122
129
|
// Public getters
|
|
123
130
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
getContractsAddresses(): Promise<AztecAddress[]> {
|
|
132
|
+
return this.#store.transactionAsync(async () => {
|
|
133
|
+
const keys = await toArray(this.#contractInstances.keysAsync());
|
|
134
|
+
return keys.map(AztecAddress.fromString);
|
|
135
|
+
});
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
/** Returns a contract instance for a given address. Throws if not found. */
|
|
130
|
-
public
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
public getContractInstance(contractAddress: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
140
|
+
return this.#store.transactionAsync(async () => {
|
|
141
|
+
const contract = await this.#contractInstances.getAsync(contractAddress.toString());
|
|
142
|
+
return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
|
|
143
|
+
});
|
|
133
144
|
}
|
|
134
145
|
|
|
135
|
-
public
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
public getContractArtifact(contractClassId: Fr): Promise<ContractArtifact | undefined> {
|
|
147
|
+
return this.#store.transactionAsync(async () => {
|
|
148
|
+
const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
|
|
149
|
+
// TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
|
|
150
|
+
return contract && contractArtifactFromBuffer(Buffer.from(contract));
|
|
151
|
+
});
|
|
139
152
|
}
|
|
140
153
|
|
|
141
154
|
/** Returns a contract class for a given class id. Throws if not found. */
|
|
@@ -176,6 +189,21 @@ export class ContractDataProvider {
|
|
|
176
189
|
return fnArtifact && { ...fnArtifact, contractName: artifact.name };
|
|
177
190
|
}
|
|
178
191
|
|
|
192
|
+
public async getFunctionArtifactWithDebugMetadata(
|
|
193
|
+
contractAddress: AztecAddress,
|
|
194
|
+
selector: FunctionSelector,
|
|
195
|
+
): Promise<FunctionArtifactWithContractName> {
|
|
196
|
+
const artifact = await this.getFunctionArtifact(contractAddress, selector);
|
|
197
|
+
if (!artifact) {
|
|
198
|
+
throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
|
|
199
|
+
}
|
|
200
|
+
const debug = await this.getFunctionDebugMetadata(contractAddress, selector);
|
|
201
|
+
return {
|
|
202
|
+
...artifact,
|
|
203
|
+
debug,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
179
207
|
public async getPublicFunctionArtifact(
|
|
180
208
|
contractAddress: AztecAddress,
|
|
181
209
|
): Promise<FunctionArtifactWithContractName | undefined> {
|
|
@@ -274,4 +302,29 @@ export class ContractDataProvider {
|
|
|
274
302
|
}
|
|
275
303
|
}
|
|
276
304
|
}
|
|
305
|
+
|
|
306
|
+
public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
307
|
+
const contract = await this.getContract(to);
|
|
308
|
+
if (!contract) {
|
|
309
|
+
throw new Error(
|
|
310
|
+
`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const functionDao = contract.functions.find(f => f.name === functionName);
|
|
315
|
+
if (!functionDao) {
|
|
316
|
+
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return FunctionCall.from({
|
|
320
|
+
name: functionDao.name,
|
|
321
|
+
to,
|
|
322
|
+
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
323
|
+
type: functionDao.functionType,
|
|
324
|
+
hideMsgSender: false,
|
|
325
|
+
isStatic: functionDao.isStatic,
|
|
326
|
+
args: encodeArguments(functionDao, args),
|
|
327
|
+
returnTypes: functionDao.returnTypes,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
277
330
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContractStore } from './contract_store.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
package/src/storage/index.ts
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';
|
package/src/storage/metadata.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 3;
|