@aztec/pxe 0.0.1-commit.e3c1de76 → 0.0.1-commit.e57c76e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bin/check_oracle_version.js +43 -99
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +26 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +93 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +62 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +9 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +37 -11
- package/dest/config/index.d.ts +8 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +66 -29
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +216 -75
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -11
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -15
- package/dest/contract_function_simulator/index.d.ts +14 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +11 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +48 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +45 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +8 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +13 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +35 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -5
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +6 -10
- package/dest/contract_function_simulator/noir-structs/option.d.ts +61 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +62 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +24 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +16 -98
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -46
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +471 -275
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +127 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +786 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +139 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +560 -0
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +68 -95
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +141 -110
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +156 -76
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +450 -166
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +20 -3
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +35 -64
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +42 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +135 -0
- package/dest/contract_sync/helpers.d.ts +27 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +16 -17
- package/dest/debug/pxe_debug_utils.d.ts +14 -15
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +16 -21
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -5
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +21 -5
- package/dest/entrypoints/pxe_creation_options.d.ts +9 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +5 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -2
- package/dest/entrypoints/server/utils.d.ts +4 -3
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +21 -5
- package/dest/events/event_service.d.ts +15 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +44 -11
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/hooks/authorize_utility_call.d.ts +41 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +42 -0
- package/dest/hooks/execution_hooks.d.ts.map +1 -0
- package/dest/hooks/execution_hooks.js +9 -0
- package/dest/hooks/index.d.ts +4 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +1 -0
- package/dest/logs/log_service.d.ts +9 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +131 -84
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +55 -0
- package/dest/notes/note_service.d.ts +27 -5
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +83 -58
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/private_kernel/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +130 -69
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +202 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +166 -65
- package/dest/private_kernel/private_kernel_oracle.d.ts +15 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +31 -25
- package/dest/pxe.d.ts +120 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +231 -134
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +591 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +36 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +146 -87
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +6 -4
- package/dest/storage/open_pxe_stores.d.ts +33 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +27 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +3 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +45 -32
- package/dest/tagging/index.d.ts +6 -5
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +4 -3
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +163 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -9
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +32 -14
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +41 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +37 -25
- package/package.json +29 -17
- package/src/bin/check_oracle_version.ts +49 -122
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +121 -0
- package/src/block_synchronizer/block_stream_source.ts +81 -0
- package/src/block_synchronizer/block_synchronizer.ts +39 -11
- package/src/config/index.ts +15 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +391 -136
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -18
- package/src/contract_function_simulator/index.ts +51 -1
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +55 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +36 -3
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -9
- package/src/contract_function_simulator/noir-structs/option.ts +69 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +27 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +12 -176
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle.ts +564 -473
- package/src/contract_function_simulator/oracle/oracle_registry.ts +585 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +553 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +173 -205
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +664 -245
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +41 -64
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +189 -0
- package/src/contract_sync/{index.ts → helpers.ts} +17 -29
- package/src/debug/pxe_debug_utils.ts +47 -25
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +19 -6
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +19 -6
- package/src/entrypoints/pxe_creation_options.ts +14 -0
- package/src/entrypoints/server/index.ts +4 -2
- package/src/entrypoints/server/utils.ts +22 -13
- package/src/events/event_service.ts +69 -21
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/logs/log_service.ts +162 -145
- package/src/messages/message_context_service.ts +62 -0
- package/src/notes/note_service.ts +120 -85
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/batch_planner.ts +169 -0
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +165 -118
- package/src/private_kernel/hints/test_utils.ts +318 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +254 -89
- package/src/private_kernel/private_kernel_oracle.ts +42 -32
- package/src/pxe.ts +416 -181
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +46 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +712 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +182 -104
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +9 -5
- package/src/storage/open_pxe_stores.ts +49 -0
- package/src/storage/private_event_store/private_event_store.ts +4 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +87 -35
- package/src/tagging/index.ts +5 -4
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +240 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +4 -4
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +52 -17
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -14
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -27
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -15
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -99
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -15
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -32
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -143
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -49
|
@@ -1,42 +1,21 @@
|
|
|
1
|
-
/* eslint-disable import-x/no-named-as-default-member */
|
|
2
1
|
import { keccak256String } from '@aztec/foundation/crypto/keccak';
|
|
3
2
|
|
|
4
|
-
import { readFileSync } from 'fs';
|
|
5
3
|
import { dirname, join } from 'path';
|
|
6
|
-
import ts from 'typescript';
|
|
7
4
|
import { fileURLToPath } from 'url';
|
|
8
5
|
|
|
9
|
-
import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
|
|
6
|
+
import { ORACLE_INTERFACE_HASH, ORACLE_VERSION_MAJOR } from '../oracle_version.js';
|
|
7
|
+
import { getOracleInterfaceSignature, readNumericGlobal } from './oracle_version_helpers.js';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Verifies that the Oracle interface matches the expected interface hash.
|
|
13
11
|
*
|
|
14
12
|
* The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
|
|
15
13
|
* a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
|
|
16
|
-
* changed and the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
|
|
20
|
-
* oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
|
|
21
|
-
* oracle interface like we do in PXE (i.e., there is no single Oracle class that contains only the oracles).
|
|
14
|
+
* changed and the oracle version needs to be bumped:
|
|
15
|
+
* - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
|
|
16
|
+
* - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
|
|
22
17
|
*/
|
|
23
18
|
function assertOracleInterfaceMatches(): void {
|
|
24
|
-
const oracleInterfaceSignature = getOracleInterfaceSignature();
|
|
25
|
-
|
|
26
|
-
// We use keccak256 here just because we already have it in the dependencies.
|
|
27
|
-
const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
|
|
28
|
-
if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
|
|
29
|
-
// This check exists only to notify you when you need to update the ORACLE_VERSION constant.
|
|
30
|
-
throw new Error(
|
|
31
|
-
`The Oracle interface has changed, which implies a breaking change in the aztec.nr/PXE oracle interface. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} and bump ORACLE_VERSION in pxe/src/oracle_version.ts.`,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Constructs a signature of the Oracle interface while ignoring methods that are not foreign call handlers.
|
|
38
|
-
*/
|
|
39
|
-
function getOracleInterfaceSignature(): string {
|
|
40
19
|
const excludedProps = [
|
|
41
20
|
'handler',
|
|
42
21
|
'constructor',
|
|
@@ -44,7 +23,7 @@ function getOracleInterfaceSignature(): string {
|
|
|
44
23
|
'handlerAsMisc',
|
|
45
24
|
'handlerAsUtility',
|
|
46
25
|
'handlerAsPrivate',
|
|
47
|
-
]
|
|
26
|
+
];
|
|
48
27
|
|
|
49
28
|
// Get the path to Oracle.ts source file
|
|
50
29
|
// The script runs from dest/bin/ after compilation, so we need to go up to the package root
|
|
@@ -54,108 +33,56 @@ function getOracleInterfaceSignature(): string {
|
|
|
54
33
|
const packageRoot = dirname(dirname(currentDir)); // Go up from bin/ to pxe/
|
|
55
34
|
const oracleSourcePath = join(packageRoot, 'src/contract_function_simulator/oracle/oracle.ts');
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
const sourceCode = readFileSync(oracleSourcePath, 'utf-8');
|
|
59
|
-
const sourceFile = ts.createSourceFile('oracle.ts', sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
60
|
-
|
|
61
|
-
// Extract method signatures from the Oracle class
|
|
62
|
-
const methodSignatures: string[] = [];
|
|
63
|
-
|
|
64
|
-
function visit(node: ts.Node) {
|
|
65
|
-
// Look for class declaration named "Oracle"
|
|
66
|
-
if (ts.isClassDeclaration(node) && node.name?.text === 'Oracle') {
|
|
67
|
-
// Visit all members of the class
|
|
68
|
-
node.members.forEach(member => {
|
|
69
|
-
if (ts.isMethodDeclaration(member) && member.name && ts.isIdentifier(member.name)) {
|
|
70
|
-
const methodName = member.name.text;
|
|
71
|
-
|
|
72
|
-
// Skip excluded methods
|
|
73
|
-
if (excludedProps.includes(methodName as (typeof excludedProps)[number])) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Extract parameter signatures
|
|
78
|
-
const paramSignatures: string[] = [];
|
|
79
|
-
member.parameters.forEach(param => {
|
|
80
|
-
const paramName = extractParameterName(param, sourceFile);
|
|
81
|
-
const paramType = extractTypeString(param.type, sourceFile);
|
|
82
|
-
paramSignatures.push(`${paramName}: ${paramType}`);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Extract return type
|
|
86
|
-
const returnType = extractTypeString(member.type, sourceFile);
|
|
87
|
-
|
|
88
|
-
// Build full signature: methodName(param1: Type1, param2: Type2): ReturnType
|
|
89
|
-
const signature = `${methodName}(${paramSignatures.join(', ')}): ${returnType}`;
|
|
90
|
-
methodSignatures.push(signature);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
ts.forEachChild(node, visit);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
visit(sourceFile);
|
|
36
|
+
const oracleInterfaceSignature = getOracleInterfaceSignature(oracleSourcePath, ['Oracle'], excludedProps);
|
|
99
37
|
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Extracts the parameter name from a parameter node, handling destructured parameters.
|
|
109
|
-
*/
|
|
110
|
-
function extractParameterName(param: ts.ParameterDeclaration, sourceFile: ts.SourceFile): string {
|
|
111
|
-
const name = param.name;
|
|
112
|
-
|
|
113
|
-
if (ts.isIdentifier(name)) {
|
|
114
|
-
return name.text;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (ts.isArrayBindingPattern(name)) {
|
|
118
|
-
// Handle destructured parameters like [blockNumber]: ACVMField[]
|
|
119
|
-
// Extract the first element name
|
|
120
|
-
if (name.elements.length > 0) {
|
|
121
|
-
const element = name.elements[0];
|
|
122
|
-
if (ts.isBindingElement(element)) {
|
|
123
|
-
const elementName = element.name;
|
|
124
|
-
if (ts.isIdentifier(elementName)) {
|
|
125
|
-
return elementName.text;
|
|
126
|
-
}
|
|
127
|
-
// Nested destructuring - use text representation
|
|
128
|
-
if (ts.isArrayBindingPattern(elementName) || ts.isObjectBindingPattern(elementName)) {
|
|
129
|
-
return elementName.getText(sourceFile);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Fallback: return the text representation
|
|
134
|
-
return name.getText(sourceFile);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (ts.isObjectBindingPattern(name)) {
|
|
138
|
-
// Handle object destructuring
|
|
139
|
-
return name.getText(sourceFile);
|
|
38
|
+
// We use keccak256 here just because we already have it in the dependencies.
|
|
39
|
+
const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
|
|
40
|
+
if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`The Oracle interface has changed. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} in pxe/src/oracle_version.ts and bump the oracle version (ORACLE_VERSION_MAJOR for breaking changes, ORACLE_VERSION_MINOR for oracle additions).`,
|
|
43
|
+
);
|
|
140
44
|
}
|
|
141
|
-
|
|
142
|
-
// Fallback for any other case - this should never happen but TypeScript needs it
|
|
143
|
-
return (name as ts.Node).getText(sourceFile);
|
|
144
45
|
}
|
|
145
46
|
|
|
146
47
|
/**
|
|
147
|
-
*
|
|
48
|
+
* Verifies that `ORACLE_VERSION_MAJOR` is identical across all of its hand-maintained copies.
|
|
49
|
+
*
|
|
50
|
+
* The major version is duplicated across the PXE TypeScript constant and two Noir constants (Aztec.nr and the protocol
|
|
51
|
+
* contracts' `aztec_sublib`) because those layers can't import each other. This static check fails fast at build time,
|
|
52
|
+
* naming each file and its value.
|
|
53
|
+
*
|
|
54
|
+
* Only the major version is checked: the minor version legitimately diverges under the "environment minor >= contract
|
|
55
|
+
* minor" tolerance, so asserting minor equality would false-positive.
|
|
148
56
|
*/
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
|
|
57
|
+
function assertContractOracleVersionMajorInSync(): void {
|
|
58
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
// Go up from dest/bin/ or src/bin/ to the package root (pxe/), then up two more to the git root.
|
|
60
|
+
const packageRoot = dirname(dirname(currentDir));
|
|
61
|
+
const gitRoot = join(packageRoot, '..', '..');
|
|
62
|
+
|
|
63
|
+
const copies = [
|
|
64
|
+
{ label: 'pxe/src/oracle_version.ts', value: ORACLE_VERSION_MAJOR },
|
|
65
|
+
{
|
|
66
|
+
label: 'aztec-nr/aztec/src/oracle/version.nr',
|
|
67
|
+
value: readNumericGlobal(
|
|
68
|
+
join(gitRoot, 'noir-projects/aztec-nr/aztec/src/oracle/version.nr'),
|
|
69
|
+
'ORACLE_VERSION_MAJOR',
|
|
70
|
+
),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
label: 'aztec_sublib/src/oracle/version.nr',
|
|
74
|
+
value: readNumericGlobal(
|
|
75
|
+
join(gitRoot, 'noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/oracle/version.nr'),
|
|
76
|
+
'ORACLE_VERSION_MAJOR',
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
if (new Set(copies.map(copy => copy.value)).size > 1) {
|
|
82
|
+
const details = copies.map(copy => `${copy.label}=${copy.value}`).join(', ');
|
|
83
|
+
throw new Error(`ORACLE_VERSION_MAJOR is out of sync: ${details}. Bump all copies together.`);
|
|
152
84
|
}
|
|
153
|
-
|
|
154
|
-
// Get the type text and normalize whitespace
|
|
155
|
-
let typeText = typeNode.getText(sourceFile);
|
|
156
|
-
// Normalize whitespace: remove extra spaces, newlines, and tabs
|
|
157
|
-
typeText = typeText.replace(/\s+/g, ' ').trim();
|
|
158
|
-
return typeText;
|
|
159
85
|
}
|
|
160
86
|
|
|
161
87
|
assertOracleInterfaceMatches();
|
|
88
|
+
assertContractOracleVersionMajorInSync();
|
package/src/bin/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getOracleInterfaceSignature, readNumericGlobal } from './oracle_version_helpers.js';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* eslint-disable import-x/no-named-as-default-member */
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extracts method signatures from TypeScript classes or interfaces and returns a deterministic string representation.
|
|
7
|
+
*
|
|
8
|
+
* This is used to detect when an oracle interface changes so that the oracle version can be bumped. It works with both
|
|
9
|
+
* class declarations (e.g. PXE's `Oracle` class) and interface declarations (e.g. TXE's `IAvmExecutionOracle`).
|
|
10
|
+
*
|
|
11
|
+
* @param sourcePath - Absolute path to the TypeScript source file to parse.
|
|
12
|
+
* @param targets - Names of classes or interfaces to extract methods from.
|
|
13
|
+
* @param excludedMembers - Method names to skip (e.g. non-oracle helpers like `constructor`).
|
|
14
|
+
*/
|
|
15
|
+
export function getOracleInterfaceSignature(sourcePath: string, targets: string[], excludedMembers: string[]): string {
|
|
16
|
+
const sourceCode = readFileSync(sourcePath, 'utf-8');
|
|
17
|
+
const sourceFile = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
18
|
+
|
|
19
|
+
const methodSignatures: string[] = [];
|
|
20
|
+
|
|
21
|
+
function visit(node: ts.Node) {
|
|
22
|
+
const isTarget =
|
|
23
|
+
(ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) && targets.includes(node.name?.text ?? '');
|
|
24
|
+
|
|
25
|
+
if (isTarget) {
|
|
26
|
+
node.members.forEach(member => {
|
|
27
|
+
if (
|
|
28
|
+
(ts.isMethodDeclaration(member) || ts.isMethodSignature(member)) &&
|
|
29
|
+
member.name &&
|
|
30
|
+
ts.isIdentifier(member.name)
|
|
31
|
+
) {
|
|
32
|
+
const methodName = member.name.text;
|
|
33
|
+
|
|
34
|
+
if (excludedMembers.includes(methodName)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const paramSignatures: string[] = [];
|
|
39
|
+
member.parameters.forEach(param => {
|
|
40
|
+
const paramName = extractParameterName(param, sourceFile);
|
|
41
|
+
const paramType = extractTypeString(param.type, sourceFile);
|
|
42
|
+
paramSignatures.push(`${paramName}: ${paramType}`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const returnType = extractTypeString(member.type, sourceFile);
|
|
46
|
+
|
|
47
|
+
const signature = `${methodName}(${paramSignatures.join(', ')}): ${returnType}`;
|
|
48
|
+
methodSignatures.push(signature);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ts.forEachChild(node, visit);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
visit(sourceFile);
|
|
57
|
+
|
|
58
|
+
methodSignatures.sort();
|
|
59
|
+
|
|
60
|
+
return methodSignatures.join('');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Reads an integer-valued global constant from a Noir or TypeScript source file.
|
|
65
|
+
*
|
|
66
|
+
* Matches both the Noir form (`pub global NAME: Field = N;`) and the TypeScript form (`export const NAME = N;`). This
|
|
67
|
+
* lets us compare a version constant that is hand-duplicated across the TS and Noir layers (which can't import each
|
|
68
|
+
* other) without depending on either compiler. Only the assignment form `NAME = N` matches, so later usages of the
|
|
69
|
+
* constant are ignored regardless of their order in the file.
|
|
70
|
+
*
|
|
71
|
+
* @param sourcePath - Absolute path to the source file to read.
|
|
72
|
+
* @param name - Name of the global constant whose integer value should be extracted.
|
|
73
|
+
* @returns The integer value assigned to the constant.
|
|
74
|
+
* @throws If the constant's declaration is not found in the file.
|
|
75
|
+
*/
|
|
76
|
+
export function readNumericGlobal(sourcePath: string, name: string): number {
|
|
77
|
+
const sourceCode = readFileSync(sourcePath, 'utf-8');
|
|
78
|
+
const match = sourceCode.match(new RegExp(`\\b${name}\\s*(?::\\s*\\w+\\s*)?=\\s*(\\d+)`));
|
|
79
|
+
if (!match) {
|
|
80
|
+
throw new Error(`Could not find numeric global '${name}' in ${sourcePath}.`);
|
|
81
|
+
}
|
|
82
|
+
return Number(match[1]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function extractParameterName(param: ts.ParameterDeclaration, sourceFile: ts.SourceFile): string {
|
|
86
|
+
const name = param.name;
|
|
87
|
+
|
|
88
|
+
if (ts.isIdentifier(name)) {
|
|
89
|
+
return name.text;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (ts.isArrayBindingPattern(name)) {
|
|
93
|
+
if (name.elements.length > 0) {
|
|
94
|
+
const element = name.elements[0];
|
|
95
|
+
if (ts.isBindingElement(element)) {
|
|
96
|
+
const elementName = element.name;
|
|
97
|
+
if (ts.isIdentifier(elementName)) {
|
|
98
|
+
return elementName.text;
|
|
99
|
+
}
|
|
100
|
+
if (ts.isArrayBindingPattern(elementName) || ts.isObjectBindingPattern(elementName)) {
|
|
101
|
+
return elementName.getText(sourceFile);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return name.getText(sourceFile);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (ts.isObjectBindingPattern(name)) {
|
|
109
|
+
return name.getText(sourceFile);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (name as ts.Node).getText(sourceFile);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function extractTypeString(typeNode: ts.TypeNode | undefined, sourceFile: ts.SourceFile): string {
|
|
116
|
+
if (!typeNode) {
|
|
117
|
+
return 'void';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return typeNode.getText(sourceFile).replace(/\s+/g, ' ').trim();
|
|
121
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import {
|
|
3
|
+
type BlockData,
|
|
4
|
+
type BlockQuery,
|
|
5
|
+
type BlocksQuery,
|
|
6
|
+
type CheckpointsQuery,
|
|
7
|
+
L2Block,
|
|
8
|
+
type L2BlockSource,
|
|
9
|
+
} from '@aztec/stdlib/block';
|
|
10
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
11
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Lifts an {@link AztecNode} RPC client into the shape {@link L2BlockStream} expects.
|
|
15
|
+
* `getBlocks` requests transaction bodies so that real `L2Block` instances can be constructed;
|
|
16
|
+
* `getCheckpoints` requests blocks + L1 info + attestations so that `PublishedCheckpoint`
|
|
17
|
+
* instances are fully populated.
|
|
18
|
+
*/
|
|
19
|
+
export function blockStreamSourceFromAztecNode(
|
|
20
|
+
node: AztecNode,
|
|
21
|
+
): Pick<L2BlockSource, 'getBlocks' | 'getBlockData' | 'getL2Tips' | 'getCheckpoints'> {
|
|
22
|
+
return {
|
|
23
|
+
getL2Tips: async () => {
|
|
24
|
+
const tips = await node.getChainTips();
|
|
25
|
+
return { ...tips, proposedCheckpoint: tips.checkpointed };
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async getBlockData(query: BlockQuery): Promise<BlockData | undefined> {
|
|
29
|
+
const response = await node.getBlock(query);
|
|
30
|
+
if (!response) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
header: response.header,
|
|
35
|
+
archive: response.archive,
|
|
36
|
+
blockHash: response.hash,
|
|
37
|
+
checkpointNumber: response.checkpointNumber,
|
|
38
|
+
indexWithinCheckpoint: response.indexWithinCheckpoint,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
async getBlocks(query: BlocksQuery): Promise<L2Block[]> {
|
|
43
|
+
// Epoch lookups are not exposed on the public AztecNode RPC; only `from + limit` is.
|
|
44
|
+
if (!('from' in query)) {
|
|
45
|
+
throw new Error('getBlocks with epoch query not supported via AztecNode RPC');
|
|
46
|
+
}
|
|
47
|
+
if (query.onlyCheckpointed) {
|
|
48
|
+
throw new Error('getBlocks with onlyCheckpointed not supported via AztecNode RPC');
|
|
49
|
+
}
|
|
50
|
+
const responses = await node.getBlocks(query.from, query.limit, { includeTransactions: true });
|
|
51
|
+
return responses.map(r => new L2Block(r.archive, r.header, r.body!, r.checkpointNumber, r.indexWithinCheckpoint));
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
async getCheckpoints(query: CheckpointsQuery): Promise<PublishedCheckpoint[]> {
|
|
55
|
+
if (!('from' in query)) {
|
|
56
|
+
throw new Error('getCheckpoints with epoch query not supported via AztecNode RPC');
|
|
57
|
+
}
|
|
58
|
+
const { from, limit } = query;
|
|
59
|
+
const responses = await node.getCheckpoints(from, limit, {
|
|
60
|
+
includeBlocks: true,
|
|
61
|
+
includeTransactions: true,
|
|
62
|
+
includeL1PublishInfo: true,
|
|
63
|
+
includeAttestations: true,
|
|
64
|
+
});
|
|
65
|
+
return responses.map(r => {
|
|
66
|
+
const checkpoint = new Checkpoint(
|
|
67
|
+
r.archive,
|
|
68
|
+
r.header,
|
|
69
|
+
r.blocks!.map(b => new L2Block(b.archive, b.header, b.body!, b.checkpointNumber, b.indexWithinCheckpoint)),
|
|
70
|
+
r.number,
|
|
71
|
+
r.feeAssetPriceModifier,
|
|
72
|
+
);
|
|
73
|
+
const l1 =
|
|
74
|
+
r.l1?.published === true
|
|
75
|
+
? new L1PublishedData(r.l1.blockNumber, r.l1.timestamp, r.l1.blockHash)
|
|
76
|
+
: new L1PublishedData(0n, 0n, Fr.ZERO.toString());
|
|
77
|
+
return new PublishedCheckpoint(checkpoint, l1, r.attestations ?? []);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
5
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
5
6
|
import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
@@ -7,9 +8,11 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
7
8
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
9
|
|
|
9
10
|
import type { BlockSynchronizerConfig } from '../config/index.js';
|
|
11
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
10
12
|
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
11
13
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
14
|
import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
15
|
+
import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* The BlockSynchronizer class orchestrates synchronization between PXE and Aztec node, maintaining an up-to-date
|
|
@@ -19,6 +22,7 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
|
|
|
19
22
|
export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
20
23
|
private log: Logger;
|
|
21
24
|
private isSyncing: Promise<void> | undefined;
|
|
25
|
+
private readonly eventQueue = new SerialQueue();
|
|
22
26
|
protected readonly blockStream: L2BlockStream;
|
|
23
27
|
|
|
24
28
|
constructor(
|
|
@@ -28,16 +32,18 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
28
32
|
private noteStore: NoteStore,
|
|
29
33
|
private privateEventStore: PrivateEventStore,
|
|
30
34
|
private l2TipsStore: L2TipsKVStore,
|
|
35
|
+
private contractSyncService: ContractSyncService,
|
|
31
36
|
private config: Partial<BlockSynchronizerConfig> = {},
|
|
32
37
|
bindings?: LoggerBindings,
|
|
33
38
|
) {
|
|
34
39
|
this.log = createLogger('pxe:block_synchronizer', bindings);
|
|
35
40
|
this.blockStream = this.createBlockStream(config);
|
|
41
|
+
this.eventQueue.start();
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
|
|
39
45
|
return new L2BlockStream(
|
|
40
|
-
this.node,
|
|
46
|
+
blockStreamSourceFromAztecNode(this.node),
|
|
41
47
|
this.l2TipsStore,
|
|
42
48
|
this,
|
|
43
49
|
createLogger('pxe:block_stream', this.log.getBindings()),
|
|
@@ -50,8 +56,12 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
50
56
|
);
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
/** Handle events emitted by the block stream. */
|
|
54
|
-
public
|
|
59
|
+
/** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
|
|
60
|
+
public handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
61
|
+
return this.eventQueue.put(() => this.doHandleBlockStreamEvent(event));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private async doHandleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
55
65
|
await this.l2TipsStore.handleBlockStreamEvent(event);
|
|
56
66
|
|
|
57
67
|
switch (event.type) {
|
|
@@ -72,18 +82,22 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
72
82
|
}
|
|
73
83
|
case 'chain-proven': {
|
|
74
84
|
if (this.config.syncChainTip === 'proven') {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
await this.updateAnchorBlockHeader(
|
|
85
|
+
const block = await this.node.getBlock(BlockNumber(event.block.number));
|
|
86
|
+
if (block) {
|
|
87
|
+
await this.updateAnchorBlockHeader(block.header);
|
|
88
|
+
} else {
|
|
89
|
+
this.log.warn(`Block header not found for proven block ${event.block.number}, skipping anchor update`);
|
|
78
90
|
}
|
|
79
91
|
}
|
|
80
92
|
break;
|
|
81
93
|
}
|
|
82
94
|
case 'chain-finalized': {
|
|
83
95
|
if (this.config.syncChainTip === 'finalized') {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
await this.updateAnchorBlockHeader(
|
|
96
|
+
const block = await this.node.getBlock(BlockNumber(event.block.number));
|
|
97
|
+
if (block) {
|
|
98
|
+
await this.updateAnchorBlockHeader(block.header);
|
|
99
|
+
} else {
|
|
100
|
+
this.log.warn(`Block header not found for finalized block ${event.block.number}, skipping anchor update`);
|
|
87
101
|
}
|
|
88
102
|
}
|
|
89
103
|
break;
|
|
@@ -104,7 +118,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
104
118
|
// Note that the following is not necessarily the anchor block that will be used in the transaction - if
|
|
105
119
|
// the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
|
|
106
120
|
// forward.
|
|
107
|
-
const
|
|
121
|
+
const newAnchorBlock = await this.node.getBlock(BlockHash.fromString(event.block.hash));
|
|
122
|
+
const newAnchorBlockHeader = newAnchorBlock?.header;
|
|
108
123
|
|
|
109
124
|
if (!newAnchorBlockHeader) {
|
|
110
125
|
throw new Error(
|
|
@@ -125,6 +140,10 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
125
140
|
|
|
126
141
|
/** Updates the anchor block header to the target block */
|
|
127
142
|
private async updateAnchorBlockHeader(blockHeader: BlockHeader) {
|
|
143
|
+
// Whenever the anchor block header is updated, we need to synchronize the private state of contracts again.
|
|
144
|
+
// Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
|
|
145
|
+
// execution.
|
|
146
|
+
this.contractSyncService.wipe();
|
|
128
147
|
this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
|
|
129
148
|
await this.anchorBlockStore.setHeader(blockHeader);
|
|
130
149
|
}
|
|
@@ -146,6 +165,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
146
165
|
}
|
|
147
166
|
|
|
148
167
|
this.log.debug(`Syncing PXE with the node`);
|
|
168
|
+
// Capture the promise locally so we always await the exact promise we created, even if this.isSyncing is modified
|
|
169
|
+
// between assignment and await (e.g. due to future refactors introducing a yield point).
|
|
149
170
|
const isSyncing = this.doSync();
|
|
150
171
|
this.isSyncing = isSyncing;
|
|
151
172
|
try {
|
|
@@ -155,6 +176,13 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
155
176
|
}
|
|
156
177
|
}
|
|
157
178
|
|
|
179
|
+
/** Stops the block synchronizer, waiting for any in-progress sync and queued events to complete. */
|
|
180
|
+
public async stop() {
|
|
181
|
+
await this.isSyncing;
|
|
182
|
+
await this.blockStream.stop();
|
|
183
|
+
await this.eventQueue.end();
|
|
184
|
+
}
|
|
185
|
+
|
|
158
186
|
private async doSync() {
|
|
159
187
|
let currentHeader;
|
|
160
188
|
|
|
@@ -165,7 +193,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
165
193
|
}
|
|
166
194
|
if (!currentHeader) {
|
|
167
195
|
// REFACTOR: We should know the header of the genesis block without having to request it from the node.
|
|
168
|
-
await this.anchorBlockStore.setHeader((await this.node.
|
|
196
|
+
await this.anchorBlockStore.setHeader((await this.node.getBlockData(BlockNumber.ZERO))!.header);
|
|
169
197
|
}
|
|
170
198
|
await this.blockStream.sync();
|
|
171
199
|
}
|
package/src/config/index.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
booleanConfigHelper,
|
|
4
|
+
enumConfigHelper,
|
|
4
5
|
getConfigFromMappings,
|
|
5
6
|
numberConfigHelper,
|
|
6
7
|
parseBooleanEnv,
|
|
7
8
|
} from '@aztec/foundation/config';
|
|
8
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
9
9
|
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
10
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
10
11
|
|
|
11
12
|
export { getPackageInfo } from './package_info.js';
|
|
12
13
|
|
|
@@ -26,6 +27,12 @@ export interface BlockSynchronizerConfig {
|
|
|
26
27
|
l2BlockBatchSize: number;
|
|
27
28
|
/** Which chain tip to sync to (proposed, checkpointed, proven, finalized) */
|
|
28
29
|
syncChainTip?: 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
30
|
+
/**
|
|
31
|
+
* Whether PXE should automatically sync with the node before each operation (simulate, prove, profile,
|
|
32
|
+
* execute utility, get private events, update contract). When disabled, callers (e.g. wallets) are
|
|
33
|
+
* responsible for calling `pxe.sync()` explicitly
|
|
34
|
+
*/
|
|
35
|
+
autoSync: boolean;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & BlockSynchronizerConfig;
|
|
@@ -58,14 +65,13 @@ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
|
|
|
58
65
|
syncChainTip: {
|
|
59
66
|
env: 'PXE_SYNC_CHAIN_TIP',
|
|
60
67
|
description: 'Which chain tip to sync to (proposed, checkpointed, proven, finalized)',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
},
|
|
68
|
+
...enumConfigHelper(['proposed', 'checkpointed', 'proven', 'finalized'], 'proposed'),
|
|
69
|
+
},
|
|
70
|
+
autoSync: {
|
|
71
|
+
env: 'PXE_AUTO_SYNC',
|
|
72
|
+
description:
|
|
73
|
+
'Whether PXE syncs with the node automatically before each operation. Disable to let the caller (e.g. a wallet) drive syncs explicitly via pxe.sync().',
|
|
74
|
+
...booleanConfigHelper(true),
|
|
69
75
|
},
|
|
70
76
|
};
|
|
71
77
|
|