@aztec/pxe 0.0.0-test.1 → 0.0.1-commit.0208eb9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +2 -0
- package/dest/bin/check_oracle_version.d.ts.map +1 -0
- package/dest/bin/check_oracle_version.js +129 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +43 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +147 -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 +13 -24
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +35 -33
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +82 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -0
- package/dest/contract_function_simulator/contract_function_simulator.js +339 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +104 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_note_cache.js +208 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +28 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/hashed_values_cache.js +36 -0
- package/dest/contract_function_simulator/index.d.ts +14 -0
- package/dest/contract_function_simulator/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/index.js +12 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +21 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +40 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +26 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +17 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +65 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +24 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +51 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +22 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +14 -0
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/index.js +2 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +107 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +19 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +24 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +28 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +54 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +60 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle.js +368 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +23 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +87 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +239 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +426 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +208 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +367 -0
- package/dest/contract_function_simulator/pick_notes.d.ts +85 -0
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -0
- package/dest/contract_function_simulator/pick_notes.js +51 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +6 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -0
- package/dest/contract_function_simulator/proxied_contract_data_source.js +80 -0
- package/dest/contract_sync/index.d.ts +24 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +61 -0
- package/dest/debug/pxe_debug_utils.d.ts +41 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +47 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -3
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts +10 -10
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +33 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -3
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts +10 -10
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +33 -12
- package/dest/entrypoints/pxe_creation_options.d.ts +18 -0
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -0
- package/dest/entrypoints/server/index.d.ts +8 -4
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +6 -3
- package/dest/entrypoints/server/utils.d.ts +8 -16
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +46 -36
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +30 -22
- 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 -0
- package/dest/oracle_version.d.ts.map +1 -0
- package/dest/oracle_version.js +11 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +41 -0
- package/dest/private_kernel/hints/index.d.ts +3 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/private_kernel/hints/index.js +2 -0
- 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/private_kernel_reset_private_inputs_builder.js +277 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +45 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_execution_prover.js +285 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts +59 -0
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +92 -0
- package/dest/pxe.d.ts +204 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/pxe.js +742 -0
- 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 -15
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +17 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.js +26 -0
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +253 -0
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +66 -0
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/contract_store/contract_store.js +233 -0
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts +27 -0
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/contract_store/private_functions_tree.js +47 -0
- package/dest/storage/index.d.ts +9 -10
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +8 -9
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_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 +341 -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 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- 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 +17 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +15 -0
- 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 +37 -34
- package/src/bin/check_oracle_version.ts +161 -0
- package/src/block_synchronizer/block_synchronizer.ts +172 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +41 -55
- 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 +633 -0
- package/src/contract_function_simulator/execution_note_cache.ts +252 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +47 -0
- package/src/contract_function_simulator/index.ts +13 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +51 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +69 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +64 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +23 -0
- package/src/contract_function_simulator/oracle/index.ts +16 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +185 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +23 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +68 -0
- package/src/contract_function_simulator/oracle/oracle.ts +637 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +141 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +701 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +544 -0
- package/src/contract_function_simulator/pick_notes.ts +141 -0
- package/src/contract_function_simulator/proxied_contract_data_source.ts +83 -0
- package/src/contract_sync/index.ts +119 -0
- package/src/debug/pxe_debug_utils.ts +63 -0
- package/src/entrypoints/client/bundle/index.ts +3 -2
- package/src/entrypoints/client/bundle/utils.ts +35 -36
- package/src/entrypoints/client/lazy/index.ts +3 -2
- package/src/entrypoints/client/lazy/utils.ts +36 -32
- package/src/entrypoints/pxe_creation_options.ts +14 -0
- package/src/entrypoints/server/index.ts +7 -3
- package/src/entrypoints/server/utils.ts +52 -52
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +40 -39
- 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 +12 -0
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +58 -0
- package/src/private_kernel/hints/index.ts +2 -0
- package/src/{kernel_prover/hints/build_private_kernel_reset_private_inputs.ts → private_kernel/hints/private_kernel_reset_private_inputs_builder.ts} +179 -156
- package/src/private_kernel/index.ts +2 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +433 -0
- package/src/private_kernel/private_kernel_oracle.ts +152 -0
- package/src/pxe.ts +1076 -0
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +15 -21
- 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 -17
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/capsule_store/capsule_store.ts +315 -0
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +330 -0
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/contract_store/private_functions_tree.ts +67 -0
- package/src/storage/index.ts +8 -10
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +411 -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 -0
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +19 -0
- 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/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -28
- package/dest/entrypoints/client/pxe_creation_options.d.ts +0 -11
- package/dest/entrypoints/client/pxe_creation_options.d.ts.map +0 -1
- package/dest/kernel_oracle/index.d.ts +0 -45
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_oracle/index.js +0 -76
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +0 -270
- package/dest/kernel_prover/hints/index.d.ts +0 -2
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/index.js +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts +0 -38
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/kernel_prover.js +0 -217
- package/dest/kernel_prover/proving_data_oracle.d.ts +0 -73
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/pxe_http/index.d.ts +0 -2
- package/dest/pxe_http/index.d.ts.map +0 -1
- package/dest/pxe_http/index.js +0 -1
- package/dest/pxe_http/pxe_http_server.d.ts +0 -16
- package/dest/pxe_http/pxe_http_server.d.ts.map +0 -1
- package/dest/pxe_http/pxe_http_server.js +0 -27
- package/dest/pxe_oracle_interface/index.d.ts +0 -159
- package/dest/pxe_oracle_interface/index.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/index.js +0 -692
- package/dest/pxe_oracle_interface/tagging_utils.d.ts +0 -17
- package/dest/pxe_oracle_interface/tagging_utils.d.ts.map +0 -1
- package/dest/pxe_oracle_interface/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -111
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/pxe_service/pxe_service.js +0 -664
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -13
- 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/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -16
- 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 -57
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -109
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -183
- package/dest/storage/contract_data_provider/index.d.ts +0 -3
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -2
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +0 -66
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +0 -99
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -106
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -106
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -20
- 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 -249
- package/dest/storage/sync_data_provider/index.d.ts +0 -2
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -12
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +0 -29
- 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 -18
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -65
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -37
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/synchronizer/synchronizer.js +0 -103
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -38
- package/src/entrypoints/client/pxe_creation_options.ts +0 -7
- package/src/kernel_oracle/index.ts +0 -117
- package/src/kernel_prover/hints/index.ts +0 -1
- package/src/kernel_prover/index.ts +0 -2
- package/src/kernel_prover/kernel_prover.ts +0 -351
- package/src/kernel_prover/proving_data_oracle.ts +0 -83
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/pxe_http/index.ts +0 -1
- package/src/pxe_http/pxe_http_server.ts +0 -29
- package/src/pxe_oracle_interface/index.ts +0 -925
- package/src/pxe_oracle_interface/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/pxe_service/pxe_service.ts +0 -949
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -80
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/contract_data_provider.ts +0 -261
- package/src/storage/contract_data_provider/index.ts +0 -2
- package/src/storage/contract_data_provider/private_functions_tree.ts +0 -131
- package/src/storage/data_provider.ts +0 -3
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_dao.ts +0 -162
- package/src/storage/note_data_provider/note_data_provider.ts +0 -345
- 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 -92
- package/src/synchronizer/index.ts +0 -1
- package/src/synchronizer/synchronizer.ts +0 -121
- package/src/test/pxe_test_suite.ts +0 -111
- /package/dest/entrypoints/{client/pxe_creation_options.js → pxe_creation_options.js} +0 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { toArray } from '@aztec/foundation/iterable';
|
|
4
|
+
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
6
|
+
import {
|
|
7
|
+
type ContractArtifact,
|
|
8
|
+
type FunctionAbi,
|
|
9
|
+
type FunctionArtifact,
|
|
10
|
+
type FunctionArtifactWithContractName,
|
|
11
|
+
FunctionCall,
|
|
12
|
+
type FunctionDebugMetadata,
|
|
13
|
+
FunctionSelector,
|
|
14
|
+
FunctionType,
|
|
15
|
+
contractArtifactFromBuffer,
|
|
16
|
+
contractArtifactToBuffer,
|
|
17
|
+
encodeArguments,
|
|
18
|
+
getFunctionDebugMetadata,
|
|
19
|
+
} from '@aztec/stdlib/abi';
|
|
20
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import {
|
|
22
|
+
type ContractClass,
|
|
23
|
+
type ContractInstanceWithAddress,
|
|
24
|
+
SerializableContractInstance,
|
|
25
|
+
getContractClassFromArtifact,
|
|
26
|
+
} from '@aztec/stdlib/contract';
|
|
27
|
+
|
|
28
|
+
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ContractStore serves as a data manager and retriever for Aztec.nr contracts.
|
|
32
|
+
* It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
|
|
33
|
+
* from a given contract address and function selector. The class maintains a cache of ContractTree instances
|
|
34
|
+
* to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
|
|
35
|
+
* the required information and facilitate cryptographic proof generation.
|
|
36
|
+
*/
|
|
37
|
+
export class ContractStore {
|
|
38
|
+
/** Map from contract class id to private function tree. */
|
|
39
|
+
// TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
40
|
+
#privateFunctionTrees: Map<string, PrivateFunctionsTree> = new Map();
|
|
41
|
+
|
|
42
|
+
/** Map from contract address to contract class id */
|
|
43
|
+
#contractClassIdMap: Map<string, Fr> = new Map();
|
|
44
|
+
|
|
45
|
+
#store: AztecAsyncKVStore;
|
|
46
|
+
#contractArtifacts: AztecAsyncMap<string, Buffer>;
|
|
47
|
+
#contractInstances: AztecAsyncMap<string, Buffer>;
|
|
48
|
+
|
|
49
|
+
constructor(store: AztecAsyncKVStore) {
|
|
50
|
+
this.#store = store;
|
|
51
|
+
this.#contractArtifacts = store.openMap('contract_artifacts');
|
|
52
|
+
this.#contractInstances = store.openMap('contracts_instances');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Setters
|
|
56
|
+
|
|
57
|
+
public async addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void> {
|
|
58
|
+
// Validation outside transactionAsync - these are not DB operations
|
|
59
|
+
const privateFunctions = contract.functions.filter(
|
|
60
|
+
functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const privateSelectors = await Promise.all(
|
|
64
|
+
privateFunctions.map(async privateFunctionArtifact =>
|
|
65
|
+
(
|
|
66
|
+
await FunctionSelector.fromNameAndParameters(privateFunctionArtifact.name, privateFunctionArtifact.parameters)
|
|
67
|
+
).toString(),
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (privateSelectors.length !== new Set(privateSelectors).size) {
|
|
72
|
+
throw new Error('Repeated function selectors of private functions');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
await this.#store.transactionAsync(() =>
|
|
76
|
+
this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract)),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async addContractInstance(contract: ContractInstanceWithAddress): Promise<void> {
|
|
81
|
+
this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
|
|
82
|
+
|
|
83
|
+
await this.#contractInstances.set(
|
|
84
|
+
contract.address.toString(),
|
|
85
|
+
new SerializableContractInstance(contract).toBuffer(),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Private getters
|
|
90
|
+
|
|
91
|
+
async #getContractClassId(contractAddress: AztecAddress): Promise<Fr | undefined> {
|
|
92
|
+
if (!this.#contractClassIdMap.has(contractAddress.toString())) {
|
|
93
|
+
const instance = await this.getContractInstance(contractAddress);
|
|
94
|
+
if (!instance) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.#contractClassIdMap.set(contractAddress.toString(), instance.currentContractClassId);
|
|
98
|
+
}
|
|
99
|
+
return this.#contractClassIdMap.get(contractAddress.toString());
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Retrieve or create a ContractTree instance based on the provided class id.
|
|
104
|
+
* If an existing tree with the same class id is found in the cache, it will be returned.
|
|
105
|
+
* Otherwise, a new ContractTree instance will be created using the contract data from the database
|
|
106
|
+
* and added to the cache before returning.
|
|
107
|
+
*
|
|
108
|
+
* @param classId - The class id of the contract for which the ContractTree is required.
|
|
109
|
+
* @returns A ContractTree instance associated with the specified contract address.
|
|
110
|
+
* @throws An Error if the contract is not found in the ContractDatabase.
|
|
111
|
+
*/
|
|
112
|
+
async #getPrivateFunctionTreeForClassId(classId: Fr): Promise<PrivateFunctionsTree | undefined> {
|
|
113
|
+
if (!this.#privateFunctionTrees.has(classId.toString())) {
|
|
114
|
+
const artifact = await this.getContractArtifact(classId);
|
|
115
|
+
if (!artifact) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const tree = await PrivateFunctionsTree.create(artifact);
|
|
119
|
+
this.#privateFunctionTrees.set(classId.toString(), tree);
|
|
120
|
+
}
|
|
121
|
+
return this.#privateFunctionTrees.get(classId.toString())!;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async #getContractArtifactByAddress(contractAddress: AztecAddress): Promise<ContractArtifact | undefined> {
|
|
125
|
+
const contractClassId = await this.#getContractClassId(contractAddress);
|
|
126
|
+
return contractClassId && this.getContractArtifact(contractClassId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Public getters
|
|
130
|
+
|
|
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
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Returns a contract instance for a given address. Throws if not found. */
|
|
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
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
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
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Returns a contract class for a given class id. Throws if not found. */
|
|
155
|
+
public async getContractClass(contractClassId: Fr): Promise<ContractClass | undefined> {
|
|
156
|
+
const artifact = await this.getContractArtifact(contractClassId);
|
|
157
|
+
return artifact && getContractClassFromArtifact(artifact);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public async getContract(
|
|
161
|
+
address: AztecAddress,
|
|
162
|
+
): Promise<(ContractInstanceWithAddress & ContractArtifact) | undefined> {
|
|
163
|
+
const instance = await this.getContractInstance(address);
|
|
164
|
+
if (!instance) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const artifact = await this.getContractArtifact(instance.currentContractClassId);
|
|
168
|
+
if (!artifact) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
return { ...instance, ...artifact };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves the artifact of a specified function within a given contract.
|
|
176
|
+
* The function is identified by its selector, which is a unique code generated from the function's signature.
|
|
177
|
+
* Throws an error if the contract address or function selector are invalid or not found.
|
|
178
|
+
*
|
|
179
|
+
* @param contractAddress - The AztecAddress representing the contract containing the function.
|
|
180
|
+
* @param selector - The function selector.
|
|
181
|
+
* @returns The corresponding function's artifact as an object.
|
|
182
|
+
*/
|
|
183
|
+
public async getFunctionArtifact(
|
|
184
|
+
contractAddress: AztecAddress,
|
|
185
|
+
selector: FunctionSelector,
|
|
186
|
+
): Promise<FunctionArtifactWithContractName | undefined> {
|
|
187
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
188
|
+
const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
|
|
189
|
+
return fnArtifact && { ...fnArtifact, contractName: artifact.name };
|
|
190
|
+
}
|
|
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
|
+
|
|
207
|
+
public async getPublicFunctionArtifact(
|
|
208
|
+
contractAddress: AztecAddress,
|
|
209
|
+
): Promise<FunctionArtifactWithContractName | undefined> {
|
|
210
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
211
|
+
const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
|
|
212
|
+
return fnArtifact && { ...fnArtifact, contractName: artifact.name };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public async getFunctionAbi(
|
|
216
|
+
contractAddress: AztecAddress,
|
|
217
|
+
selector: FunctionSelector,
|
|
218
|
+
): Promise<FunctionAbi | undefined> {
|
|
219
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
220
|
+
return artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Retrieves the debug metadata of a specified function within a given contract.
|
|
225
|
+
* The function is identified by its selector, which is a unique code generated from the function's signature.
|
|
226
|
+
* Returns undefined if the debug metadata for the given function is not found.
|
|
227
|
+
* Throws if the contract has not been added to the database.
|
|
228
|
+
*
|
|
229
|
+
* @param contractAddress - The AztecAddress representing the contract containing the function.
|
|
230
|
+
* @param selector - The function selector.
|
|
231
|
+
* @returns The corresponding function's artifact as an object.
|
|
232
|
+
*/
|
|
233
|
+
public async getFunctionDebugMetadata(
|
|
234
|
+
contractAddress: AztecAddress,
|
|
235
|
+
selector: FunctionSelector,
|
|
236
|
+
): Promise<FunctionDebugMetadata | undefined> {
|
|
237
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
238
|
+
const fnArtifact = artifact && (await this.#findFunctionArtifactBySelector(artifact, selector));
|
|
239
|
+
return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public async getPublicFunctionDebugMetadata(
|
|
243
|
+
contractAddress: AztecAddress,
|
|
244
|
+
): Promise<FunctionDebugMetadata | undefined> {
|
|
245
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
246
|
+
const fnArtifact = artifact && artifact.functions.find(fn => fn.functionType === FunctionType.PUBLIC);
|
|
247
|
+
return fnArtifact && getFunctionDebugMetadata(artifact, fnArtifact);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Retrieve the function membership witness for the given contract class and function selector.
|
|
252
|
+
* The function membership witness represents a proof that the function belongs to the specified contract.
|
|
253
|
+
* Throws an error if the contract address or function selector is unknown.
|
|
254
|
+
*
|
|
255
|
+
* @param contractClassId - The id of the class.
|
|
256
|
+
* @param selector - The function selector.
|
|
257
|
+
* @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
|
|
258
|
+
*/
|
|
259
|
+
public async getFunctionMembershipWitness(
|
|
260
|
+
contractClassId: Fr,
|
|
261
|
+
selector: FunctionSelector,
|
|
262
|
+
): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined> {
|
|
263
|
+
const tree = await this.#getPrivateFunctionTreeForClassId(contractClassId);
|
|
264
|
+
return tree?.getFunctionMembershipWitness(selector);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
public async getDebugContractName(contractAddress: AztecAddress) {
|
|
268
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
269
|
+
return artifact?.name;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) {
|
|
273
|
+
const artifact = await this.#getContractArtifactByAddress(contractAddress);
|
|
274
|
+
const fnArtifact = artifact && (await this.#findFunctionAbiBySelector(artifact, selector));
|
|
275
|
+
return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async #findFunctionArtifactBySelector(
|
|
279
|
+
artifact: ContractArtifact,
|
|
280
|
+
selector: FunctionSelector,
|
|
281
|
+
): Promise<FunctionArtifact | undefined> {
|
|
282
|
+
const functions = artifact.functions;
|
|
283
|
+
for (let i = 0; i < functions.length; i++) {
|
|
284
|
+
const fn = functions[i];
|
|
285
|
+
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
286
|
+
if (fnSelector.equals(selector)) {
|
|
287
|
+
return fn;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async #findFunctionAbiBySelector(
|
|
293
|
+
artifact: ContractArtifact,
|
|
294
|
+
selector: FunctionSelector,
|
|
295
|
+
): Promise<FunctionAbi | undefined> {
|
|
296
|
+
const functions = [...artifact.functions, ...(artifact.nonDispatchPublicFunctions ?? [])];
|
|
297
|
+
for (let i = 0; i < functions.length; i++) {
|
|
298
|
+
const fn = functions[i];
|
|
299
|
+
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
300
|
+
if (fnSelector.equals(selector)) {
|
|
301
|
+
return fn;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
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 {
|
|
320
|
+
name: functionDao.name,
|
|
321
|
+
args: encodeArguments(functionDao, args),
|
|
322
|
+
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
323
|
+
type: functionDao.functionType,
|
|
324
|
+
to,
|
|
325
|
+
hideMsgSender: false,
|
|
326
|
+
isStatic: functionDao.isStatic,
|
|
327
|
+
returnTypes: functionDao.returnTypes,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContractStore } from './contract_store.js';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { assertLength } from '@aztec/foundation/serialize';
|
|
4
|
+
import { MembershipWitness, type MerkleTree } from '@aztec/foundation/trees';
|
|
5
|
+
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
6
|
+
import {
|
|
7
|
+
type PrivateFunction,
|
|
8
|
+
computePrivateFunctionLeaf,
|
|
9
|
+
computePrivateFunctionsTree,
|
|
10
|
+
getContractClassPrivateFunctionFromArtifact,
|
|
11
|
+
} from '@aztec/stdlib/contract';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents a Merkle tree of functions for a particular Contract Class.
|
|
15
|
+
* It manages the construction of the function tree, computes its root, and generates membership witnesses
|
|
16
|
+
* for constrained functions. This class also enables lookup of specific function artifact using selectors.
|
|
17
|
+
* It is used in combination with the AztecNode to compute various data for executing private transactions.
|
|
18
|
+
*/
|
|
19
|
+
export class PrivateFunctionsTree {
|
|
20
|
+
private tree?: MerkleTree;
|
|
21
|
+
|
|
22
|
+
private constructor(private readonly privateFunctions: PrivateFunction[]) {}
|
|
23
|
+
|
|
24
|
+
static async create(artifact: ContractArtifact) {
|
|
25
|
+
const privateFunctions = await Promise.all(
|
|
26
|
+
artifact.functions
|
|
27
|
+
.filter(fn => fn.functionType === FunctionType.PRIVATE)
|
|
28
|
+
.map(getContractClassPrivateFunctionFromArtifact),
|
|
29
|
+
);
|
|
30
|
+
return new PrivateFunctionsTree(privateFunctions);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve the membership witness of a function within a contract's function tree.
|
|
35
|
+
* A membership witness represents the position and authentication path of a target function
|
|
36
|
+
* in the Merkle tree of constrained functions. It is required to prove the existence of the
|
|
37
|
+
* function within the contract during execution. Throws if fn does not exist or is not private.
|
|
38
|
+
*
|
|
39
|
+
* @param selector - The function selector.
|
|
40
|
+
* @returns A MembershipWitness instance representing the position and authentication path of the function in the function tree.
|
|
41
|
+
*/
|
|
42
|
+
public async getFunctionMembershipWitness(
|
|
43
|
+
selector: FunctionSelector,
|
|
44
|
+
): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
|
|
45
|
+
const fn = this.privateFunctions.find(f => f.selector.equals(selector));
|
|
46
|
+
if (!fn) {
|
|
47
|
+
throw new Error(`Private function with selector ${selector.toString()} not found in contract class.`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const leaf = await computePrivateFunctionLeaf(fn);
|
|
51
|
+
const tree = await this.getTree();
|
|
52
|
+
const index = tree.getIndex(leaf);
|
|
53
|
+
const path = tree.getSiblingPath(index);
|
|
54
|
+
return new MembershipWitness<typeof FUNCTION_TREE_HEIGHT>(
|
|
55
|
+
FUNCTION_TREE_HEIGHT,
|
|
56
|
+
BigInt(index),
|
|
57
|
+
assertLength(path.map(Fr.fromBuffer), FUNCTION_TREE_HEIGHT),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private async getTree() {
|
|
62
|
+
if (!this.tree) {
|
|
63
|
+
this.tree = await computePrivateFunctionsTree(this.privateFunctions);
|
|
64
|
+
}
|
|
65
|
+
return this.tree;
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/storage/index.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
|
|
10
|
-
export const PXE_DATA_SCHEMA_VERSION = 2;
|
|
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
|
+
export * from './metadata.js';
|
|
8
|
+
export * from './private_event_store/private_event_store.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 3;
|