@aztec/pxe 0.0.0-test.0 → 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,48 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { type AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
5
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
7
|
+
export declare class NoteService {
|
|
8
|
+
private readonly noteStore;
|
|
9
|
+
private readonly aztecNode;
|
|
10
|
+
private readonly anchorBlockHeader;
|
|
11
|
+
private readonly jobId;
|
|
12
|
+
constructor(noteStore: NoteStore, aztecNode: AztecNode, anchorBlockHeader: BlockHeader, jobId: string);
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
15
|
+
* The query result is paginated using 'limit' and 'offset' values.
|
|
16
|
+
* Returns an object containing an array of note data.
|
|
17
|
+
*
|
|
18
|
+
* @param owner - The owner of the notes. If undefined, returns notes for all known owners.
|
|
19
|
+
* @param status - The status of notes to fetch.
|
|
20
|
+
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
21
|
+
*/
|
|
22
|
+
getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes?: AztecAddress[]): Promise<{
|
|
23
|
+
contractAddress: AztecAddress;
|
|
24
|
+
owner: AztecAddress;
|
|
25
|
+
storageSlot: Fr;
|
|
26
|
+
randomness: Fr;
|
|
27
|
+
noteNonce: Fr;
|
|
28
|
+
note: Note;
|
|
29
|
+
noteHash: Fr;
|
|
30
|
+
isPending: boolean;
|
|
31
|
+
siloedNullifier: Fr;
|
|
32
|
+
}[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
35
|
+
*
|
|
36
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
37
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
38
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
39
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
40
|
+
* block up to which the PXE has synced.
|
|
41
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
42
|
+
*
|
|
43
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
44
|
+
*/
|
|
45
|
+
syncNoteNullifiers(contractAddress: AztecAddress): Promise<void>;
|
|
46
|
+
validateAndStoreNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbm90ZXMvbm90ZV9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUdoRSxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RSxPQUFPLEVBQUUsSUFBSSxFQUFXLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRS9ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUU1RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUVyRSxxQkFBYSxXQUFXO0lBRXBCLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFDMUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxpQkFBaUI7SUFDbEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBSnhCLFlBQ21CLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsS0FBSyxFQUFFLE1BQU0sRUFDNUI7SUFFSjs7Ozs7Ozs7T0FRRztJQUNVLFFBQVEsQ0FDbkIsZUFBZSxFQUFFLFlBQVksRUFDN0IsS0FBSyxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQy9CLFdBQVcsRUFBRSxFQUFFLEVBQ2YsTUFBTSxFQUFFLFVBQVUsRUFDbEIsTUFBTSxDQUFDLEVBQUUsWUFBWSxFQUFFOzs7Ozs7Ozs7O1NBeUJ4QjtJQUVEOzs7Ozs7Ozs7OztPQVdHO0lBQ1Usa0JBQWtCLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBc0M1RTtJQUVZLG9CQUFvQixDQUMvQixlQUFlLEVBQUUsWUFBWSxFQUM3QixLQUFLLEVBQUUsWUFBWSxFQUNuQixXQUFXLEVBQUUsRUFBRSxFQUNmLFVBQVUsRUFBRSxFQUFFLEVBQ2QsU0FBUyxFQUFFLEVBQUUsRUFDYixPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQ2IsUUFBUSxFQUFFLEVBQUUsRUFDWixTQUFTLEVBQUUsRUFBRSxFQUNiLE1BQU0sRUFBRSxNQUFNLEVBQ2QsU0FBUyxFQUFFLFlBQVksR0FDdEIsT0FBTyxDQUFDLElBQUksQ0FBQyxDQXNFZjtDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note_service.d.ts","sourceRoot":"","sources":["../../src/notes/note_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAErE,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,YACmB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,WAAW,EAC9B,KAAK,EAAE,MAAM,EAC5B;IAEJ;;;;;;;;OAQG;IACU,QAAQ,CACnB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,CAAC,EAAE,YAAY,EAAE;;;;;;;;;;SAyBxB;IAED;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC5E;IAEY,oBAAoB,CAC/B,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,SAAS,EAAE,EAAE,EACb,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC,CAsEf;CACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
2
|
+
import { MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import { Note, NoteDao } from '@aztec/stdlib/note';
|
|
4
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
|
+
export class NoteService {
|
|
6
|
+
noteStore;
|
|
7
|
+
aztecNode;
|
|
8
|
+
anchorBlockHeader;
|
|
9
|
+
jobId;
|
|
10
|
+
constructor(noteStore, aztecNode, anchorBlockHeader, jobId){
|
|
11
|
+
this.noteStore = noteStore;
|
|
12
|
+
this.aztecNode = aztecNode;
|
|
13
|
+
this.anchorBlockHeader = anchorBlockHeader;
|
|
14
|
+
this.jobId = jobId;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
18
|
+
* The query result is paginated using 'limit' and 'offset' values.
|
|
19
|
+
* Returns an object containing an array of note data.
|
|
20
|
+
*
|
|
21
|
+
* @param owner - The owner of the notes. If undefined, returns notes for all known owners.
|
|
22
|
+
* @param status - The status of notes to fetch.
|
|
23
|
+
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
24
|
+
*/ async getNotes(contractAddress, owner, storageSlot, status, scopes) {
|
|
25
|
+
const noteDaos = await this.noteStore.getNotes({
|
|
26
|
+
contractAddress,
|
|
27
|
+
owner,
|
|
28
|
+
storageSlot,
|
|
29
|
+
status,
|
|
30
|
+
scopes
|
|
31
|
+
}, this.jobId);
|
|
32
|
+
return noteDaos.map(({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier })=>({
|
|
33
|
+
contractAddress,
|
|
34
|
+
owner,
|
|
35
|
+
storageSlot,
|
|
36
|
+
randomness,
|
|
37
|
+
noteNonce,
|
|
38
|
+
note,
|
|
39
|
+
noteHash,
|
|
40
|
+
isPending: false,
|
|
41
|
+
siloedNullifier
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
46
|
+
*
|
|
47
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
48
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
49
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
50
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
51
|
+
* block up to which the PXE has synced.
|
|
52
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
53
|
+
*
|
|
54
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
55
|
+
*/ async syncNoteNullifiers(contractAddress) {
|
|
56
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
57
|
+
const contractNotes = await this.noteStore.getNotes({
|
|
58
|
+
contractAddress
|
|
59
|
+
}, this.jobId);
|
|
60
|
+
if (contractNotes.length === 0) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const nullifiersToCheck = contractNotes.map((note)=>note.siloedNullifier);
|
|
64
|
+
const nullifierBatches = nullifiersToCheck.reduce((acc, nullifier)=>{
|
|
65
|
+
if (acc[acc.length - 1].length < MAX_RPC_LEN) {
|
|
66
|
+
acc[acc.length - 1].push(nullifier);
|
|
67
|
+
} else {
|
|
68
|
+
acc.push([
|
|
69
|
+
nullifier
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
return acc;
|
|
73
|
+
}, [
|
|
74
|
+
[]
|
|
75
|
+
]);
|
|
76
|
+
const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch)))).flat();
|
|
77
|
+
const foundNullifiers = nullifiersToCheck.map((nullifier, i)=>{
|
|
78
|
+
if (nullifierIndexes[i] !== undefined) {
|
|
79
|
+
return {
|
|
80
|
+
...nullifierIndexes[i],
|
|
81
|
+
...{
|
|
82
|
+
data: nullifier
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}).filter((nullifier)=>nullifier !== undefined);
|
|
87
|
+
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
88
|
+
}
|
|
89
|
+
async validateAndStoreNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash, recipient) {
|
|
90
|
+
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
91
|
+
// There's two things we need to check before we do this however:
|
|
92
|
+
// - we must make sure the note does actually exist in the note hash tree
|
|
93
|
+
// - we need to check if the note has already been nullified
|
|
94
|
+
//
|
|
95
|
+
// Failing to do either of the above would result in circuits getting either non-existent notes and failing to
|
|
96
|
+
// produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
|
|
97
|
+
// are catastrophic failure modes.
|
|
98
|
+
//
|
|
99
|
+
// Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
|
|
100
|
+
// emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
|
|
101
|
+
// so we must store both the note hash and nullifier block information.
|
|
102
|
+
// We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
|
|
103
|
+
// in time of the locally synced state.
|
|
104
|
+
// Note that while this technically results in historical queries, we perform it at the latest locally synced block
|
|
105
|
+
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
106
|
+
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
107
|
+
// logs up to the synced block making this only an additional safety check.
|
|
108
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
109
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
110
|
+
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
111
|
+
// of other contracts, which would constitute a security breach.
|
|
112
|
+
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
113
|
+
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
114
|
+
const [txEffect, [nullifierIndex]] = await Promise.all([
|
|
115
|
+
this.aztecNode.getTxEffect(txHash),
|
|
116
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [
|
|
117
|
+
siloedNullifier
|
|
118
|
+
])
|
|
119
|
+
]);
|
|
120
|
+
if (!txEffect) {
|
|
121
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
122
|
+
}
|
|
123
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
124
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
125
|
+
}
|
|
126
|
+
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
127
|
+
const noteIndexInTx = txEffect.data.noteHashes.findIndex((nh)=>nh.equals(uniqueNoteHash));
|
|
128
|
+
if (noteIndexInTx === -1) {
|
|
129
|
+
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
130
|
+
}
|
|
131
|
+
const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, txEffect.l2BlockNumber, txEffect.l2BlockHash.toString(), txEffect.txIndexInBlock, noteIndexInTx);
|
|
132
|
+
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
133
|
+
await this.noteStore.addNotes([
|
|
134
|
+
noteDao
|
|
135
|
+
], recipient, this.jobId);
|
|
136
|
+
if (nullifierIndex !== undefined) {
|
|
137
|
+
// We found nullifier index which implies that the note has already been nullified.
|
|
138
|
+
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
139
|
+
await this.noteStore.applyNullifiers([
|
|
140
|
+
{
|
|
141
|
+
data: siloedNullifier,
|
|
142
|
+
...blockHashAndNum
|
|
143
|
+
}
|
|
144
|
+
], this.jobId);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const ORACLE_VERSION = 11;
|
|
2
|
+
export declare const ORACLE_INTERFACE_HASH = "20c4d02d8cd5e448c11001a5f72ea2e0927630aeda75e537550872a9627bf40b";
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb24uZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9vcmFjbGVfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxlQUFPLE1BQU0sY0FBYyxLQUFLLENBQUM7QUFLakMsZUFBTyxNQUFNLHFCQUFxQixxRUFBcUUsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oracle_version.d.ts","sourceRoot":"","sources":["../src/oracle_version.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,KAAK,CAAC;AAKjC,eAAO,MAAM,qBAAqB,qEAAqE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// The ORACLE_VERSION constant is used to check that the oracle interface is in sync between PXE and Aztec.nr. We need
|
|
2
|
+
/// to version the oracle interface to ensure that developers get a reasonable error message if they use incompatible
|
|
3
|
+
/// versions of Aztec.nr and PXE. The Noir counterpart is in `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
4
|
+
///
|
|
5
|
+
/// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
|
|
6
|
+
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
+
export const ORACLE_VERSION = 11;
|
|
8
|
+
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
9
|
+
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
10
|
+
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
11
|
+
export const ORACLE_INTERFACE_HASH = '20c4d02d8cd5e448c11001a5f72ea2e0927630aeda75e537550872a9627bf40b';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
2
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
3
|
+
export declare function computeTxIncludeByTimestamp(previousKernel: PrivateKernelCircuitPublicInputs, maxDuration?: number): UInt64;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcHV0ZV90eF9pbmNsdWRlX2J5X3RpbWVzdGFtcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL2hpbnRzL2NvbXB1dGVfdHhfaW5jbHVkZV9ieV90aW1lc3RhbXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsZ0NBQWdDLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQXFCbEQsd0JBQWdCLDJCQUEyQixDQUN6QyxjQUFjLEVBQUUsZ0NBQWdDLEVBQ2hELFdBQVcsU0FBb0MsR0FDOUMsTUFBTSxDQStCUiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_tx_include_by_timestamp.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/compute_tx_include_by_timestamp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAqBlD,wBAAgB,2BAA2B,CACzC,cAAc,EAAE,gCAAgC,EAChD,WAAW,SAAoC,GAC9C,MAAM,CA+BR"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
|
|
2
|
+
const ROUNDED_DURATIONS = [
|
|
3
|
+
3600,
|
|
4
|
+
1800,
|
|
5
|
+
1
|
|
6
|
+
];
|
|
7
|
+
function roundTimestamp(blockTimestamp, includeByTimestamp) {
|
|
8
|
+
return ROUNDED_DURATIONS.reduce((timestamp, duration)=>{
|
|
9
|
+
if (timestamp <= blockTimestamp) {
|
|
10
|
+
// The timestamp must be greater than the block timestamp.
|
|
11
|
+
// If it is too small, round it down again using a smaller duration.
|
|
12
|
+
const totalDuration = includeByTimestamp - blockTimestamp;
|
|
13
|
+
const roundedDuration = totalDuration - totalDuration % BigInt(duration);
|
|
14
|
+
return blockTimestamp + roundedDuration;
|
|
15
|
+
}
|
|
16
|
+
return timestamp;
|
|
17
|
+
}, 0n);
|
|
18
|
+
}
|
|
19
|
+
export function computeTxIncludeByTimestamp(previousKernel, maxDuration = MAX_INCLUDE_BY_TIMESTAMP_DURATION) {
|
|
20
|
+
if (maxDuration > MAX_INCLUDE_BY_TIMESTAMP_DURATION) {
|
|
21
|
+
throw new Error(`Custom max duration cannot be greater than the max allowed. Max allowed: ${MAX_INCLUDE_BY_TIMESTAMP_DURATION}. Custom value: ${maxDuration}.`);
|
|
22
|
+
}
|
|
23
|
+
const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
24
|
+
const maxTimestamp = anchorBlockTimestamp + BigInt(maxDuration);
|
|
25
|
+
const includeByTimestamp = previousKernel.includeByTimestamp;
|
|
26
|
+
// If the includeByTimestamp set during the tx execution is greater than or equal to the max allowed duration,
|
|
27
|
+
// use the maximum allowed timestamp.
|
|
28
|
+
// Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
|
|
29
|
+
if (includeByTimestamp >= maxTimestamp) {
|
|
30
|
+
return maxTimestamp;
|
|
31
|
+
}
|
|
32
|
+
// Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
|
|
33
|
+
// This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
|
|
34
|
+
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, includeByTimestamp);
|
|
35
|
+
// The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
|
|
36
|
+
// Future blocks will have a greater timestamp, so the tx would never be included.
|
|
37
|
+
if (roundedTimestamp <= anchorBlockTimestamp) {
|
|
38
|
+
throw new Error(`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${includeByTimestamp}.`);
|
|
39
|
+
}
|
|
40
|
+
return roundedTimestamp;
|
|
41
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
|
+
export * from './compute_tx_include_by_timestamp.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9oaW50cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGtEQUFrRCxDQUFDO0FBQ2pFLGNBQWMsc0NBQXNDLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/index.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC;AACjE,cAAc,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type PrivateKernelCircuitPublicInputs, PrivateKernelResetCircuitPrivateInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
|
|
2
|
+
import { type PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
|
|
4
|
+
export declare class PrivateKernelResetPrivateInputsBuilder {
|
|
5
|
+
private previousKernelOutput;
|
|
6
|
+
private executionStack;
|
|
7
|
+
private noteHashNullifierCounterMap;
|
|
8
|
+
private splitCounter;
|
|
9
|
+
private previousKernel;
|
|
10
|
+
private nextIteration?;
|
|
11
|
+
private noteHashResetActions;
|
|
12
|
+
private nullifierResetActions;
|
|
13
|
+
private numTransientData?;
|
|
14
|
+
private transientDataSquashingHints;
|
|
15
|
+
private requestedDimensions;
|
|
16
|
+
constructor(previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>, executionStack: PrivateCallExecutionResult[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number);
|
|
17
|
+
needsReset(): boolean;
|
|
18
|
+
build(oracle: PrivateKernelOracle): Promise<PrivateKernelResetCircuitPrivateInputs>;
|
|
19
|
+
private reduceReadRequestActions;
|
|
20
|
+
private needsResetNoteHashReadRequests;
|
|
21
|
+
private needsResetNullifierReadRequests;
|
|
22
|
+
private needsResetNullifierKeys;
|
|
23
|
+
private needsResetTransientData;
|
|
24
|
+
private needsSiloNoteHashes;
|
|
25
|
+
private needsSiloNullifiers;
|
|
26
|
+
private needsSiloPrivateLogs;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfcmVzZXRfcHJpdmF0ZV9pbnB1dHNfYnVpbGRlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL2hpbnRzL3ByaXZhdGVfa2VybmVsX3Jlc2V0X3ByaXZhdGVfaW5wdXRzX2J1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBZUEsT0FBTyxFQUtMLEtBQUssZ0NBQWdDLEVBRXJDLHNDQUFzQyxFQUd0QyxLQUFLLDJCQUEyQixFQWVqQyxNQUFNLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sRUFBRSxLQUFLLDBCQUEwQixFQUFpQixNQUFNLGtCQUFrQixDQUFDO0FBR2xGLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUE0Q3ZFLHFCQUFhLHNDQUFzQztJQVkvQyxPQUFPLENBQUMsb0JBQW9CO0lBQzVCLE9BQU8sQ0FBQyxjQUFjO0lBQ3RCLE9BQU8sQ0FBQywyQkFBMkI7SUFDbkMsT0FBTyxDQUFDLFlBQVk7SUFkdEIsT0FBTyxDQUFDLGNBQWMsQ0FBbUM7SUFFekQsT0FBTyxDQUFDLGFBQWEsQ0FBQyxDQUE2QjtJQUVuRCxPQUFPLENBQUMsb0JBQW9CLENBQXFFO0lBQ2pHLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBcUU7SUFDbEcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBQVM7SUFDbEMsT0FBTyxDQUFDLDJCQUEyQixDQUFrRTtJQUNyRyxPQUFPLENBQUMsbUJBQW1CLENBQStCO0lBRTFELFlBQ1Usb0JBQW9CLEVBQUUsMkJBQTJCLENBQUMsZ0NBQWdDLENBQUMsRUFDbkYsY0FBYyxFQUFFLDBCQUEwQixFQUFFLEVBQzVDLDJCQUEyQixFQUFFLEdBQUcsQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLEVBQ2hELFlBQVksRUFBRSxNQUFNLEVBVzdCO0lBRUQsVUFBVSxJQUFJLE9BQU8sQ0FzQnBCO0lBRUssS0FBSyxDQUFDLE1BQU0sRUFBRSxtQkFBbUIsbURBK0V0QztJQUVELE9BQU8sQ0FBQyx3QkFBd0I7SUEyQmhDLE9BQU8sQ0FBQyw4QkFBOEI7SUF1RHRDLE9BQU8sQ0FBQywrQkFBK0I7SUF1RHZDLE9BQU8sQ0FBQyx1QkFBdUI7SUFhL0IsT0FBTyxDQUFDLHVCQUF1QjtJQXNFL0IsT0FBTyxDQUFDLG1CQUFtQjtJQWMzQixPQUFPLENBQUMsbUJBQW1CO0lBa0IzQixPQUFPLENBQUMsb0JBQW9CO0NBcUI3QiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private_kernel_reset_private_inputs_builder.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,gCAAgC,EAErC,sCAAsC,EAGtC,KAAK,2BAA2B,EAejC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,0BAA0B,EAAiB,MAAM,kBAAkB,CAAC;AAGlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA4CvE,qBAAa,sCAAsC;IAY/C,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,YAAY;IAdtB,OAAO,CAAC,cAAc,CAAmC;IAEzD,OAAO,CAAC,aAAa,CAAC,CAA6B;IAEnD,OAAO,CAAC,oBAAoB,CAAqE;IACjG,OAAO,CAAC,qBAAqB,CAAqE;IAClG,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,2BAA2B,CAAkE;IACrG,OAAO,CAAC,mBAAmB,CAA+B;IAE1D,YACU,oBAAoB,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,EACnF,cAAc,EAAE,0BAA0B,EAAE,EAC5C,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,YAAY,EAAE,MAAM,EAW7B;IAED,UAAU,IAAI,OAAO,CAsBpB;IAEK,KAAK,CAAC,MAAM,EAAE,mBAAmB,mDA+EtC;IAED,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,8BAA8B;IAuDtC,OAAO,CAAC,+BAA+B;IAuDvC,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,uBAAuB;IAsE/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,oBAAoB;CAqB7B"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { MAX_KEY_VALIDATION_REQUESTS_PER_TX, MAX_NOTE_HASHES_PER_TX, MAX_NOTE_HASH_READ_REQUESTS_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_NULLIFIER_READ_REQUESTS_PER_TX, MAX_PRIVATE_LOGS_PER_TX, NULLIFIER_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
3
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
+
import { assertLength } from '@aztec/foundation/serialize';
|
|
5
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
6
|
+
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
7
|
+
import { KeyValidationHint, PaddedSideEffects, PrivateKernelData, PrivateKernelResetCircuitPrivateInputs, PrivateKernelResetDimensions, PrivateKernelResetHints, ReadRequestActionEnum, ReadRequestResetActions, ScopedNoteHash, ScopedNullifier, TransientDataSquashingHint, buildNoteHashReadRequestHintsFromResetActions, buildNullifierReadRequestHintsFromResetActions, buildTransientDataHints, findPrivateKernelResetDimensions, getNoteHashReadRequestResetActions, getNullifierReadRequestResetActions, privateKernelResetDimensionNames } from '@aztec/stdlib/kernel';
|
|
8
|
+
import { collectNested } from '@aztec/stdlib/tx';
|
|
9
|
+
import { VkData } from '@aztec/stdlib/vks';
|
|
10
|
+
function collectNestedReadRequests(executionStack, extractReadRequests) {
|
|
11
|
+
return collectNested(executionStack, (executionResult)=>{
|
|
12
|
+
return extractReadRequests(executionResult).getActiveItems();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function getNullifierMembershipWitnessResolver(oracle) {
|
|
16
|
+
return async (nullifier)=>{
|
|
17
|
+
const res = await oracle.getNullifierMembershipWitness(nullifier);
|
|
18
|
+
if (!res) {
|
|
19
|
+
throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`);
|
|
20
|
+
}
|
|
21
|
+
const { index, siblingPath, leafPreimage } = res;
|
|
22
|
+
return {
|
|
23
|
+
membershipWitness: new MembershipWitness(NULLIFIER_TREE_HEIGHT, index, siblingPath.toTuple()),
|
|
24
|
+
leafPreimage
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function getMasterSecretKeysAndAppKeyGenerators(keyValidationRequests, numRequestsToVerify, oracle) {
|
|
29
|
+
const numRequestsToProcess = Math.min(keyValidationRequests.claimedLength, numRequestsToVerify);
|
|
30
|
+
const keysHints = await Promise.all(keyValidationRequests.array.slice(0, numRequestsToProcess).map(async ({ request })=>{
|
|
31
|
+
const secretKeys = await oracle.getMasterSecretKey(request.request.pkM);
|
|
32
|
+
return new KeyValidationHint(secretKeys);
|
|
33
|
+
}));
|
|
34
|
+
return padArrayEnd(keysHints, KeyValidationHint.empty(), MAX_KEY_VALIDATION_REQUESTS_PER_TX);
|
|
35
|
+
}
|
|
36
|
+
export class PrivateKernelResetPrivateInputsBuilder {
|
|
37
|
+
previousKernelOutput;
|
|
38
|
+
executionStack;
|
|
39
|
+
noteHashNullifierCounterMap;
|
|
40
|
+
splitCounter;
|
|
41
|
+
previousKernel;
|
|
42
|
+
// If there's no next iteration, it's the final reset.
|
|
43
|
+
nextIteration;
|
|
44
|
+
noteHashResetActions;
|
|
45
|
+
nullifierResetActions;
|
|
46
|
+
numTransientData;
|
|
47
|
+
transientDataSquashingHints;
|
|
48
|
+
requestedDimensions;
|
|
49
|
+
constructor(previousKernelOutput, executionStack, noteHashNullifierCounterMap, splitCounter){
|
|
50
|
+
this.previousKernelOutput = previousKernelOutput;
|
|
51
|
+
this.executionStack = executionStack;
|
|
52
|
+
this.noteHashNullifierCounterMap = noteHashNullifierCounterMap;
|
|
53
|
+
this.splitCounter = splitCounter;
|
|
54
|
+
this.previousKernel = previousKernelOutput.publicInputs;
|
|
55
|
+
this.requestedDimensions = PrivateKernelResetDimensions.empty();
|
|
56
|
+
this.noteHashResetActions = ReadRequestResetActions.empty(MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
57
|
+
this.nullifierResetActions = ReadRequestResetActions.empty(MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
58
|
+
this.transientDataSquashingHints = makeTuple(MAX_NULLIFIERS_PER_TX, ()=>new TransientDataSquashingHint(MAX_NULLIFIERS_PER_TX, MAX_NOTE_HASHES_PER_TX));
|
|
59
|
+
this.nextIteration = executionStack[this.executionStack.length - 1]?.publicInputs;
|
|
60
|
+
}
|
|
61
|
+
needsReset() {
|
|
62
|
+
const fns = [
|
|
63
|
+
()=>this.needsResetNoteHashReadRequests(),
|
|
64
|
+
()=>this.needsResetNullifierReadRequests(),
|
|
65
|
+
()=>this.needsResetNullifierKeys(),
|
|
66
|
+
()=>this.needsResetTransientData()
|
|
67
|
+
];
|
|
68
|
+
if (this.nextIteration) {
|
|
69
|
+
// If there's a next iteration, reset is needed only when data of a dimension is about to overflow.
|
|
70
|
+
// fns are executed until a dimension that needs reset is found.
|
|
71
|
+
return fns.some((fn)=>fn());
|
|
72
|
+
} else {
|
|
73
|
+
// Siloing is only needed after processing all iterations.
|
|
74
|
+
fns.push(...[
|
|
75
|
+
()=>this.needsSiloNoteHashes(),
|
|
76
|
+
()=>this.needsSiloNullifiers(),
|
|
77
|
+
()=>this.needsSiloPrivateLogs()
|
|
78
|
+
]);
|
|
79
|
+
// If there's no next iteration, reset is needed when any of the dimension has non empty data.
|
|
80
|
+
// All the fns should to be executed so that data in all dimensions will be reset.
|
|
81
|
+
const result = fns.map((fn)=>fn());
|
|
82
|
+
return result.some((r)=>r);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async build(oracle) {
|
|
86
|
+
if (privateKernelResetDimensionNames.every((name)=>!this.requestedDimensions[name])) {
|
|
87
|
+
throw new Error('Reset is not required.');
|
|
88
|
+
}
|
|
89
|
+
const isInner = !!this.nextIteration;
|
|
90
|
+
// "final" reset must be done at most once.
|
|
91
|
+
// Because the code that silo note hashes can't be run repeatedly.
|
|
92
|
+
// The dimensions found must be big enough to reset all values, i.e. empty remainder.
|
|
93
|
+
const allowRemainder = isInner;
|
|
94
|
+
const dimensions = findPrivateKernelResetDimensions(this.requestedDimensions, privateKernelResetDimensionsConfig, isInner, allowRemainder);
|
|
95
|
+
this.reduceReadRequestActions(this.noteHashResetActions, dimensions.NOTE_HASH_PENDING_READ, dimensions.NOTE_HASH_SETTLED_READ);
|
|
96
|
+
this.reduceReadRequestActions(this.nullifierResetActions, dimensions.NULLIFIER_PENDING_READ, dimensions.NULLIFIER_SETTLED_READ);
|
|
97
|
+
// Execute all the expensive node querying operations in parallel.
|
|
98
|
+
const [previousVkMembershipWitness, noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints] = await Promise.all([
|
|
99
|
+
oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields),
|
|
100
|
+
buildNoteHashReadRequestHintsFromResetActions(oracle, this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, this.noteHashResetActions),
|
|
101
|
+
buildNullifierReadRequestHintsFromResetActions({
|
|
102
|
+
getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle)
|
|
103
|
+
}, this.previousKernel.validationRequests.nullifierReadRequests, this.nullifierResetActions),
|
|
104
|
+
getMasterSecretKeysAndAppKeyGenerators(this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators, dimensions.KEY_VALIDATION, oracle)
|
|
105
|
+
]);
|
|
106
|
+
const vkData = new VkData(this.previousKernelOutput.verificationKey, Number(previousVkMembershipWitness.leafIndex), previousVkMembershipWitness.siblingPath);
|
|
107
|
+
const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
|
|
108
|
+
// TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
|
|
109
|
+
const paddedSideEffects = PaddedSideEffects.empty();
|
|
110
|
+
return new PrivateKernelResetCircuitPrivateInputs(previousKernelData, paddedSideEffects, new PrivateKernelResetHints(noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints, this.transientDataSquashingHints), dimensions);
|
|
111
|
+
}
|
|
112
|
+
reduceReadRequestActions(resetActions, maxPending, maxSettled) {
|
|
113
|
+
let numPending = 0;
|
|
114
|
+
let numSettled = 0;
|
|
115
|
+
for(let i = 0; i < resetActions.actions.length; i++){
|
|
116
|
+
const action = resetActions.actions[i];
|
|
117
|
+
if (action === ReadRequestActionEnum.READ_AS_PENDING) {
|
|
118
|
+
if (numPending < maxPending) {
|
|
119
|
+
numPending++;
|
|
120
|
+
} else {
|
|
121
|
+
resetActions.actions[i] = ReadRequestActionEnum.SKIP;
|
|
122
|
+
}
|
|
123
|
+
} else if (action === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
124
|
+
if (numSettled < maxSettled) {
|
|
125
|
+
numSettled++;
|
|
126
|
+
} else {
|
|
127
|
+
resetActions.actions[i] = ReadRequestActionEnum.SKIP;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
resetActions.pendingReadHints = resetActions.pendingReadHints.slice(0, maxPending);
|
|
132
|
+
}
|
|
133
|
+
needsResetNoteHashReadRequests(forceResetAll = false) {
|
|
134
|
+
const numCurr = this.previousKernel.validationRequests.noteHashReadRequests.claimedLength;
|
|
135
|
+
const numNext = this.nextIteration ? this.nextIteration.noteHashReadRequests.claimedLength : 0;
|
|
136
|
+
const maxAmountToKeep = !this.nextIteration || forceResetAll ? 0 : MAX_NOTE_HASH_READ_REQUESTS_PER_TX;
|
|
137
|
+
if (numCurr + numNext <= maxAmountToKeep) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
const futureNoteHashes = collectNested(this.executionStack, (executionResult)=>{
|
|
141
|
+
return executionResult.publicInputs.noteHashes.getActiveItems().map((noteHash)=>new ScopedNoteHash(noteHash, executionResult.publicInputs.callContext.contractAddress));
|
|
142
|
+
});
|
|
143
|
+
const resetActions = getNoteHashReadRequestResetActions(this.previousKernel.validationRequests.noteHashReadRequests, this.previousKernel.end.noteHashes, futureNoteHashes);
|
|
144
|
+
const numPendingReads = resetActions.pendingReadHints.length;
|
|
145
|
+
const numSettledReads = resetActions.actions.reduce((accum, action)=>accum + (action === ReadRequestActionEnum.READ_AS_SETTLED ? 1 : 0), 0);
|
|
146
|
+
if (!this.nextIteration) {
|
|
147
|
+
this.noteHashResetActions = resetActions;
|
|
148
|
+
this.requestedDimensions.NOTE_HASH_PENDING_READ = numPendingReads;
|
|
149
|
+
this.requestedDimensions.NOTE_HASH_SETTLED_READ = numSettledReads;
|
|
150
|
+
} else {
|
|
151
|
+
// Pick only one dimension to reset if next iteration is not empty.
|
|
152
|
+
if (numPendingReads > numSettledReads) {
|
|
153
|
+
this.requestedDimensions.NOTE_HASH_PENDING_READ = numPendingReads;
|
|
154
|
+
this.noteHashResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_PENDING ? action : ReadRequestActionEnum.SKIP), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
155
|
+
this.noteHashResetActions.pendingReadHints = resetActions.pendingReadHints;
|
|
156
|
+
} else {
|
|
157
|
+
this.requestedDimensions.NOTE_HASH_SETTLED_READ = numSettledReads;
|
|
158
|
+
this.noteHashResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_SETTLED ? action : ReadRequestActionEnum.SKIP), MAX_NOTE_HASH_READ_REQUESTS_PER_TX);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
needsResetNullifierReadRequests(forceResetAll = false) {
|
|
164
|
+
const numCurr = this.previousKernel.validationRequests.nullifierReadRequests.claimedLength;
|
|
165
|
+
const numNext = this.nextIteration ? this.nextIteration.nullifierReadRequests.claimedLength : 0;
|
|
166
|
+
const maxAmountToKeep = !this.nextIteration || forceResetAll ? 0 : MAX_NULLIFIER_READ_REQUESTS_PER_TX;
|
|
167
|
+
if (numCurr + numNext <= maxAmountToKeep) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
const futureNullifiers = collectNested(this.executionStack, (executionResult)=>{
|
|
171
|
+
return executionResult.publicInputs.nullifiers.getActiveItems().map((nullifier)=>new ScopedNullifier(nullifier, executionResult.publicInputs.callContext.contractAddress));
|
|
172
|
+
});
|
|
173
|
+
const resetActions = getNullifierReadRequestResetActions(this.previousKernel.validationRequests.nullifierReadRequests, this.previousKernel.end.nullifiers, futureNullifiers);
|
|
174
|
+
const numPendingReads = resetActions.pendingReadHints.length;
|
|
175
|
+
const numSettledReads = resetActions.actions.reduce((accum, action)=>accum + (action === ReadRequestActionEnum.READ_AS_SETTLED ? 1 : 0), 0);
|
|
176
|
+
if (!this.nextIteration) {
|
|
177
|
+
this.nullifierResetActions = resetActions;
|
|
178
|
+
this.requestedDimensions.NULLIFIER_PENDING_READ = numPendingReads;
|
|
179
|
+
this.requestedDimensions.NULLIFIER_SETTLED_READ = numSettledReads;
|
|
180
|
+
} else {
|
|
181
|
+
// Pick only one dimension to reset if next iteration is not empty.
|
|
182
|
+
if (numPendingReads > numSettledReads) {
|
|
183
|
+
this.requestedDimensions.NULLIFIER_PENDING_READ = numPendingReads;
|
|
184
|
+
this.nullifierResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_PENDING ? action : ReadRequestActionEnum.SKIP), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
185
|
+
this.nullifierResetActions.pendingReadHints = resetActions.pendingReadHints;
|
|
186
|
+
} else {
|
|
187
|
+
this.requestedDimensions.NULLIFIER_SETTLED_READ = numSettledReads;
|
|
188
|
+
this.nullifierResetActions.actions = assertLength(resetActions.actions.map((action)=>action === ReadRequestActionEnum.READ_AS_SETTLED ? action : ReadRequestActionEnum.SKIP), MAX_NULLIFIER_READ_REQUESTS_PER_TX);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
needsResetNullifierKeys() {
|
|
194
|
+
const numCurr = this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators.claimedLength;
|
|
195
|
+
const numNext = this.nextIteration ? this.nextIteration.keyValidationRequestsAndGenerators.claimedLength : 0;
|
|
196
|
+
const maxAmountToKeep = !this.nextIteration ? 0 : MAX_KEY_VALIDATION_REQUESTS_PER_TX;
|
|
197
|
+
if (numCurr + numNext <= maxAmountToKeep) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
this.requestedDimensions.KEY_VALIDATION = numCurr;
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
needsResetTransientData() {
|
|
204
|
+
// Initialize this to 0 so that needsSilo can be run.
|
|
205
|
+
this.numTransientData = 0;
|
|
206
|
+
const nextAccumNoteHashes = this.previousKernel.end.noteHashes.claimedLength + (this.nextIteration?.noteHashes.claimedLength ?? 0);
|
|
207
|
+
const noteHashWillOverflow = nextAccumNoteHashes > MAX_NOTE_HASHES_PER_TX;
|
|
208
|
+
const nextAccumNullifiers = this.previousKernel.end.nullifiers.claimedLength + (this.nextIteration?.nullifiers.claimedLength ?? 0);
|
|
209
|
+
const nullifierWillOverflow = nextAccumNullifiers > MAX_NULLIFIERS_PER_TX;
|
|
210
|
+
const nextAccumLogs = this.previousKernel.end.privateLogs.claimedLength + (this.nextIteration?.privateLogs.claimedLength ?? 0);
|
|
211
|
+
const logsWillOverflow = nextAccumLogs > MAX_PRIVATE_LOGS_PER_TX;
|
|
212
|
+
if (this.nextIteration && !noteHashWillOverflow && !nullifierWillOverflow && !logsWillOverflow) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
const futureNoteHashReads = collectNestedReadRequests(this.executionStack, (executionResult)=>executionResult.publicInputs.noteHashReadRequests);
|
|
216
|
+
const futureNullifierReads = collectNestedReadRequests(this.executionStack, (executionResult)=>executionResult.publicInputs.nullifierReadRequests);
|
|
217
|
+
// TODO(#15902): Collect future logs and only allow squashing a note hash when all its logs have been emitted
|
|
218
|
+
// (i.e. none of the future logs are linked to the to-be-squashed note hashes).
|
|
219
|
+
if (this.nextIteration) {
|
|
220
|
+
// If it's not the final reset, only one dimension will be reset at a time.
|
|
221
|
+
// The note hashes and nullifiers for the remaining read requests can't be squashed.
|
|
222
|
+
futureNoteHashReads.push(...this.previousKernel.validationRequests.noteHashReadRequests.getActiveItems());
|
|
223
|
+
futureNullifierReads.push(...this.previousKernel.validationRequests.nullifierReadRequests.getActiveItems());
|
|
224
|
+
}
|
|
225
|
+
const { numTransientData, hints: transientDataSquashingHints } = buildTransientDataHints(this.previousKernel.end.noteHashes, this.previousKernel.end.nullifiers, futureNoteHashReads, futureNullifierReads, this.noteHashNullifierCounterMap, this.splitCounter);
|
|
226
|
+
if (this.nextIteration && !numTransientData) {
|
|
227
|
+
const forceResetAll = true;
|
|
228
|
+
const canClearReadRequests = noteHashWillOverflow && this.needsResetNoteHashReadRequests(forceResetAll) || nullifierWillOverflow && this.needsResetNullifierReadRequests(forceResetAll) || logsWillOverflow && this.needsResetNoteHashReadRequests(forceResetAll);
|
|
229
|
+
if (!canClearReadRequests) {
|
|
230
|
+
const overflownData = noteHashWillOverflow ? 'note hashes' : nullifierWillOverflow ? 'nullifiers' : 'private logs';
|
|
231
|
+
throw new Error(`Number of ${overflownData} exceeds the limit.`);
|
|
232
|
+
}
|
|
233
|
+
// Clearing the read requests might not be enough to squash the overflown data.
|
|
234
|
+
// In this case, the next iteration will fail at the above check.
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
this.numTransientData = numTransientData;
|
|
238
|
+
this.transientDataSquashingHints = transientDataSquashingHints;
|
|
239
|
+
this.requestedDimensions.TRANSIENT_DATA_SQUASHING = numTransientData;
|
|
240
|
+
return numTransientData > 0;
|
|
241
|
+
}
|
|
242
|
+
needsSiloNoteHashes() {
|
|
243
|
+
if (this.numTransientData === undefined) {
|
|
244
|
+
throw new Error('`needsResetTransientData` must be run before `needsSiloNoteHashes`.');
|
|
245
|
+
}
|
|
246
|
+
const numNoteHashes = this.previousKernel.end.noteHashes.getActiveItems().filter((n)=>!n.contractAddress.isZero()).length;
|
|
247
|
+
const numToSilo = Math.max(0, numNoteHashes - this.numTransientData);
|
|
248
|
+
this.requestedDimensions.NOTE_HASH_SILOING = numToSilo;
|
|
249
|
+
return numToSilo > 0;
|
|
250
|
+
}
|
|
251
|
+
needsSiloNullifiers() {
|
|
252
|
+
if (this.numTransientData === undefined) {
|
|
253
|
+
throw new Error('`needsResetTransientData` must be run before `needsSiloNullifiers`.');
|
|
254
|
+
}
|
|
255
|
+
const numNullifiers = this.previousKernel.end.nullifiers.getActiveItems().filter((n)=>!n.contractAddress.isZero()).length;
|
|
256
|
+
const numToSilo = Math.max(0, numNullifiers - this.numTransientData);
|
|
257
|
+
// Include the first nullifier if there's something to silo.
|
|
258
|
+
// The reset circuit checks that capped_size must be greater than or equal to all non-empty nullifiers.
|
|
259
|
+
// Which includes the first nullifier, even though its contract address is always zero and doesn't need siloing.
|
|
260
|
+
const cappedSize = numToSilo ? numToSilo + 1 : 0;
|
|
261
|
+
this.requestedDimensions.NULLIFIER_SILOING = cappedSize;
|
|
262
|
+
return numToSilo > 0;
|
|
263
|
+
}
|
|
264
|
+
needsSiloPrivateLogs() {
|
|
265
|
+
if (this.numTransientData === undefined) {
|
|
266
|
+
throw new Error('`needsResetTransientData` must be run before `needsSiloPrivateLogs`.');
|
|
267
|
+
}
|
|
268
|
+
const privateLogs = this.previousKernel.end.privateLogs;
|
|
269
|
+
const numLogs = privateLogs.getActiveItems().filter((l)=>!l.contractAddress.isZero()).length;
|
|
270
|
+
const noteHashes = this.previousKernel.end.noteHashes;
|
|
271
|
+
const squashedNoteHashCounters = this.transientDataSquashingHints.filter((h)=>h.noteHashIndex < noteHashes.claimedLength).map((h)=>noteHashes.array[h.noteHashIndex].counter);
|
|
272
|
+
const numSquashedLogs = privateLogs.getActiveItems().filter((l)=>squashedNoteHashCounters.includes(l.inner.noteHashCounter)).length;
|
|
273
|
+
const numToSilo = numLogs - numSquashedLogs;
|
|
274
|
+
this.requestedDimensions.PRIVATE_LOG_SILOING = numToSilo;
|
|
275
|
+
return numToSilo > 0;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from './private_kernel_execution_prover.js';
|
|
2
|
+
export * from './private_kernel_oracle.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHNDQUFzQyxDQUFDO0FBQ3JELGNBQWMsNEJBQTRCLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/private_kernel/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC"}
|