@aztec/pxe 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e
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 +5 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts +16 -6
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +91 -22
- package/dest/config/index.d.ts +4 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +12 -2
- 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 +66 -36
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +230 -89
- 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 +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- 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 -11
- package/dest/contract_function_simulator/index.d.ts +3 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -7
- 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 +9 -11
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- 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_validation_request.d.ts +5 -8
- 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 +7 -12
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +67 -47
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +327 -119
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +59 -76
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +125 -90
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +140 -73
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +347 -162
- 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 +3 -0
- 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 +44 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +116 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +60 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- 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 +23 -9
- 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 +3 -3
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +24 -10
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
- 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 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -1
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +30 -11
- package/dest/events/event_service.d.ts +7 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +33 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +20 -6
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +11 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +52 -64
- 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 +36 -0
- package/dest/notes/note_service.d.ts +9 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +45 -40
- 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 -9
- 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 +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +140 -73
- 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 +203 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -16
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -25
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +91 -2
- package/dest/pxe.d.ts +80 -59
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +163 -145
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +9 -2
- 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 +25 -10
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +143 -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 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +160 -85
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- 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 +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +229 -111
- 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/recipient_tagging_store.d.ts +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +43 -32
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +300 -122
- 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 +60 -0
- package/dest/tagging/index.d.ts +4 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +12 -26
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +18 -12
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +23 -16
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +8 -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 +44 -27
- package/package.json +27 -18
- package/src/bin/check_oracle_version.ts +5 -4
- package/src/block_synchronizer/block_synchronizer.ts +113 -35
- package/src/config/index.ts +9 -1
- 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 +392 -154
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +2 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +10 -10
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +5 -11
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +97 -59
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +422 -166
- package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +169 -185
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +578 -193
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +176 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +18 -18
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +19 -18
- package/src/entrypoints/pxe_creation_options.ts +9 -1
- package/src/entrypoints/server/index.ts +4 -1
- package/src/entrypoints/server/utils.ts +24 -29
- package/src/events/event_service.ts +31 -26
- package/src/events/private_event_filter_validator.ts +23 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +94 -104
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +54 -48
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -9
- 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 +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +195 -136
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +25 -20
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +297 -223
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +9 -1
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +183 -29
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +193 -101
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +323 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +296 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +366 -134
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +3 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +27 -29
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +31 -15
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +42 -29
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/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/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.11bf3dd6e",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"typedocOptions": {
|
|
6
|
+
"entryPoints": [
|
|
7
|
+
"./src/entrypoints/server/index.ts",
|
|
8
|
+
"./src/entrypoints/client/lazy/index.ts",
|
|
9
|
+
"./src/config/index.ts"
|
|
10
|
+
],
|
|
11
|
+
"name": "PXE",
|
|
12
|
+
"tsconfig": "./tsconfig.json"
|
|
13
|
+
},
|
|
5
14
|
"exports": {
|
|
6
15
|
"./server": "./dest/entrypoints/server/index.js",
|
|
7
16
|
"./client/lazy": "./dest/entrypoints/client/lazy/index.js",
|
|
@@ -11,7 +20,7 @@
|
|
|
11
20
|
},
|
|
12
21
|
"bin": "./dest/bin/index.js",
|
|
13
22
|
"scripts": {
|
|
14
|
-
"build": "yarn clean && yarn generate &&
|
|
23
|
+
"build": "yarn clean && yarn generate && ../scripts/tsc.sh",
|
|
15
24
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
16
25
|
"clean": "rm -rf ./dest .tsbuildinfo ./src/config/package_info.ts",
|
|
17
26
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
@@ -61,19 +70,19 @@
|
|
|
61
70
|
]
|
|
62
71
|
},
|
|
63
72
|
"dependencies": {
|
|
64
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
65
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
66
|
-
"@aztec/builder": "0.0.1-commit.
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
69
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
70
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
71
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
73
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
74
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
75
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
76
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
73
|
+
"@aztec/bb-prover": "0.0.1-commit.11bf3dd6e",
|
|
74
|
+
"@aztec/bb.js": "0.0.1-commit.11bf3dd6e",
|
|
75
|
+
"@aztec/builder": "0.0.1-commit.11bf3dd6e",
|
|
76
|
+
"@aztec/constants": "0.0.1-commit.11bf3dd6e",
|
|
77
|
+
"@aztec/ethereum": "0.0.1-commit.11bf3dd6e",
|
|
78
|
+
"@aztec/foundation": "0.0.1-commit.11bf3dd6e",
|
|
79
|
+
"@aztec/key-store": "0.0.1-commit.11bf3dd6e",
|
|
80
|
+
"@aztec/kv-store": "0.0.1-commit.11bf3dd6e",
|
|
81
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.11bf3dd6e",
|
|
82
|
+
"@aztec/noir-types": "0.0.1-commit.11bf3dd6e",
|
|
83
|
+
"@aztec/protocol-contracts": "0.0.1-commit.11bf3dd6e",
|
|
84
|
+
"@aztec/simulator": "0.0.1-commit.11bf3dd6e",
|
|
85
|
+
"@aztec/stdlib": "0.0.1-commit.11bf3dd6e",
|
|
77
86
|
"koa": "^2.16.1",
|
|
78
87
|
"koa-router": "^13.1.1",
|
|
79
88
|
"lodash.omit": "^4.5.0",
|
|
@@ -82,14 +91,14 @@
|
|
|
82
91
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
83
92
|
},
|
|
84
93
|
"devDependencies": {
|
|
85
|
-
"@aztec/
|
|
86
|
-
"@aztec/
|
|
94
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.11bf3dd6e",
|
|
95
|
+
"@aztec/world-state": "0.0.1-commit.11bf3dd6e",
|
|
87
96
|
"@jest/globals": "^30.0.0",
|
|
88
97
|
"@types/jest": "^30.0.0",
|
|
89
98
|
"@types/lodash.omit": "^4.5.7",
|
|
90
99
|
"@types/lodash.times": "^4.3.9",
|
|
91
100
|
"@types/node": "^22.15.17",
|
|
92
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
101
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
93
102
|
"jest": "^30.0.0",
|
|
94
103
|
"jest-mock-extended": "^4.0.0",
|
|
95
104
|
"lodash.times": "^4.3.2",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable import-x/no-named-as-default-member */
|
|
1
2
|
import { keccak256String } from '@aztec/foundation/crypto/keccak';
|
|
2
3
|
|
|
3
4
|
import { readFileSync } from 'fs';
|
|
@@ -12,8 +13,9 @@ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
|
|
|
12
13
|
*
|
|
13
14
|
* The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
|
|
14
15
|
* a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
|
|
15
|
-
* changed and the
|
|
16
|
-
*
|
|
16
|
+
* changed and the oracle version needs to be bumped:
|
|
17
|
+
* - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
|
|
18
|
+
* - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
|
|
17
19
|
*
|
|
18
20
|
* TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
|
|
19
21
|
* oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
|
|
@@ -25,9 +27,8 @@ function assertOracleInterfaceMatches(): void {
|
|
|
25
27
|
// We use keccak256 here just because we already have it in the dependencies.
|
|
26
28
|
const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
|
|
27
29
|
if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
|
|
28
|
-
// This check exists only to notify you when you need to update the ORACLE_VERSION constant.
|
|
29
30
|
throw new Error(
|
|
30
|
-
`The Oracle interface has changed
|
|
31
|
+
`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).`,
|
|
31
32
|
);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
5
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
4
|
-
import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
6
|
+
import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
5
7
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
8
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
6
9
|
|
|
7
|
-
import type {
|
|
10
|
+
import type { BlockSynchronizerConfig } from '../config/index.js';
|
|
11
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
8
12
|
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
9
13
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
10
14
|
import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
@@ -17,66 +21,131 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
|
|
|
17
21
|
export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
18
22
|
private log: Logger;
|
|
19
23
|
private isSyncing: Promise<void> | undefined;
|
|
24
|
+
private readonly eventQueue = new SerialQueue();
|
|
20
25
|
protected readonly blockStream: L2BlockStream;
|
|
21
26
|
|
|
22
27
|
constructor(
|
|
23
28
|
private node: AztecNode,
|
|
29
|
+
private store: AztecAsyncKVStore,
|
|
24
30
|
private anchorBlockStore: AnchorBlockStore,
|
|
25
31
|
private noteStore: NoteStore,
|
|
26
32
|
private privateEventStore: PrivateEventStore,
|
|
27
33
|
private l2TipsStore: L2TipsKVStore,
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
private contractSyncService: ContractSyncService,
|
|
35
|
+
private config: Partial<BlockSynchronizerConfig> = {},
|
|
36
|
+
bindings?: LoggerBindings,
|
|
30
37
|
) {
|
|
31
|
-
this.log =
|
|
32
|
-
!loggerOrSuffix || typeof loggerOrSuffix === 'string'
|
|
33
|
-
? createLogger(loggerOrSuffix ? `pxe:block_synchronizer:${loggerOrSuffix}` : `pxe:block_synchronizer`)
|
|
34
|
-
: loggerOrSuffix;
|
|
38
|
+
this.log = createLogger('pxe:block_synchronizer', bindings);
|
|
35
39
|
this.blockStream = this.createBlockStream(config);
|
|
40
|
+
this.eventQueue.start();
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
protected createBlockStream(config: Partial<
|
|
39
|
-
return new L2BlockStream(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
|
|
44
|
+
return new L2BlockStream(
|
|
45
|
+
this.node,
|
|
46
|
+
this.l2TipsStore,
|
|
47
|
+
this,
|
|
48
|
+
createLogger('pxe:block_stream', this.log.getBindings()),
|
|
49
|
+
{
|
|
50
|
+
batchSize: config.l2BlockBatchSize,
|
|
51
|
+
// Skipping finalized blocks makes us sync much faster - we only need to download blocks other than the latest one
|
|
52
|
+
// in order to detect reorgs, and there can be no reorgs on finalized block, making this safe.
|
|
53
|
+
skipFinalized: true,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
45
56
|
}
|
|
46
57
|
|
|
47
|
-
/** Handle events emitted by the block stream. */
|
|
48
|
-
public
|
|
58
|
+
/** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
|
|
59
|
+
public handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
60
|
+
return this.eventQueue.put(() => this.doHandleBlockStreamEvent(event));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private async doHandleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
49
64
|
await this.l2TipsStore.handleBlockStreamEvent(event);
|
|
50
65
|
|
|
51
66
|
switch (event.type) {
|
|
52
67
|
case 'blocks-added': {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
if (this.config.syncChainTip === undefined || this.config.syncChainTip === 'proposed') {
|
|
69
|
+
const lastBlock = event.blocks.at(-1)!;
|
|
70
|
+
await this.updateAnchorBlockHeader(lastBlock.header);
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'chain-checkpointed': {
|
|
75
|
+
if (this.config.syncChainTip === 'checkpointed') {
|
|
76
|
+
// Get the last block header from the checkpoint
|
|
77
|
+
const lastBlock = event.checkpoint.checkpoint.blocks.at(-1)!;
|
|
78
|
+
await this.updateAnchorBlockHeader(lastBlock.header);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'chain-proven': {
|
|
83
|
+
if (this.config.syncChainTip === 'proven') {
|
|
84
|
+
const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
|
|
85
|
+
if (blockHeader) {
|
|
86
|
+
await this.updateAnchorBlockHeader(blockHeader);
|
|
87
|
+
} else {
|
|
88
|
+
this.log.warn(`Block header not found for proven block ${event.block.number}, skipping anchor update`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 'chain-finalized': {
|
|
94
|
+
if (this.config.syncChainTip === 'finalized') {
|
|
95
|
+
const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
|
|
96
|
+
if (blockHeader) {
|
|
97
|
+
await this.updateAnchorBlockHeader(blockHeader);
|
|
98
|
+
} else {
|
|
99
|
+
this.log.warn(`Block header not found for finalized block ${event.block.number}, skipping anchor update`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
60
102
|
break;
|
|
61
103
|
}
|
|
62
104
|
case 'chain-pruned': {
|
|
105
|
+
const currentAnchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
106
|
+
const currentAnchorBlockNumber = currentAnchorBlockHeader.getBlockNumber();
|
|
107
|
+
if (currentAnchorBlockNumber <= event.block.number) {
|
|
108
|
+
this.log.verbose(
|
|
109
|
+
`Ignoring prune event to block ${event.block.number} greater than current anchor block ${currentAnchorBlockNumber}`,
|
|
110
|
+
{ pruneEvent: event, currentAnchorBlockHeader: currentAnchorBlockHeader.toInspect() },
|
|
111
|
+
);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
63
115
|
this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
116
|
+
|
|
117
|
+
// Note that the following is not necessarily the anchor block that will be used in the transaction - if
|
|
118
|
+
// the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
|
|
119
|
+
// forward.
|
|
120
|
+
const newAnchorBlockHeader = await this.node.getBlockHeader(BlockHash.fromString(event.block.hash));
|
|
121
|
+
|
|
122
|
+
if (!newAnchorBlockHeader) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`Block header for block number ${event.block.number} and hash ${event.block.hash} not found during chain prune. This likely indicates a bug in the node, as we receive block stream events and fetch block headers from the same node.`,
|
|
125
|
+
);
|
|
74
126
|
}
|
|
127
|
+
|
|
128
|
+
// Operations are wrapped in a single transaction to ensure atomicity.
|
|
129
|
+
await this.store.transactionAsync(async () => {
|
|
130
|
+
await this.noteStore.rollback(event.block.number, currentAnchorBlockNumber);
|
|
131
|
+
await this.privateEventStore.rollback(event.block.number, currentAnchorBlockNumber);
|
|
132
|
+
await this.updateAnchorBlockHeader(newAnchorBlockHeader);
|
|
133
|
+
});
|
|
75
134
|
break;
|
|
76
135
|
}
|
|
77
136
|
}
|
|
78
137
|
}
|
|
79
138
|
|
|
139
|
+
/** Updates the anchor block header to the target block */
|
|
140
|
+
private async updateAnchorBlockHeader(blockHeader: BlockHeader) {
|
|
141
|
+
// Whenever the anchor block header is updated, we need to synchronize the private state of contracts again.
|
|
142
|
+
// Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
|
|
143
|
+
// execution.
|
|
144
|
+
this.contractSyncService.wipe();
|
|
145
|
+
this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
|
|
146
|
+
await this.anchorBlockStore.setHeader(blockHeader);
|
|
147
|
+
}
|
|
148
|
+
|
|
80
149
|
/**
|
|
81
150
|
* Syncs PXE and the node by downloading the metadata of the latest blocks, allowing simulations to use
|
|
82
151
|
* recent data (e.g. notes), and handling any reorgs that might have occurred.
|
|
@@ -94,6 +163,8 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
94
163
|
}
|
|
95
164
|
|
|
96
165
|
this.log.debug(`Syncing PXE with the node`);
|
|
166
|
+
// Capture the promise locally so we always await the exact promise we created, even if this.isSyncing is modified
|
|
167
|
+
// between assignment and await (e.g. due to future refactors introducing a yield point).
|
|
97
168
|
const isSyncing = this.doSync();
|
|
98
169
|
this.isSyncing = isSyncing;
|
|
99
170
|
try {
|
|
@@ -103,6 +174,13 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
103
174
|
}
|
|
104
175
|
}
|
|
105
176
|
|
|
177
|
+
/** Stops the block synchronizer, waiting for any in-progress sync and queued events to complete. */
|
|
178
|
+
public async stop() {
|
|
179
|
+
await this.isSyncing;
|
|
180
|
+
await this.blockStream.stop();
|
|
181
|
+
await this.eventQueue.end();
|
|
182
|
+
}
|
|
183
|
+
|
|
106
184
|
private async doSync() {
|
|
107
185
|
let currentHeader;
|
|
108
186
|
|
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
|
|
|
@@ -24,6 +25,8 @@ export interface KernelProverConfig {
|
|
|
24
25
|
export interface BlockSynchronizerConfig {
|
|
25
26
|
/** Maximum amount of blocks to pull from the stream in one request when synchronizing */
|
|
26
27
|
l2BlockBatchSize: number;
|
|
28
|
+
/** Which chain tip to sync to (proposed, checkpointed, proven, finalized) */
|
|
29
|
+
syncChainTip?: 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & BlockSynchronizerConfig;
|
|
@@ -53,6 +56,11 @@ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
|
|
|
53
56
|
description: 'Enable real proofs',
|
|
54
57
|
...booleanConfigHelper(true),
|
|
55
58
|
},
|
|
59
|
+
syncChainTip: {
|
|
60
|
+
env: 'PXE_SYNC_CHAIN_TIP',
|
|
61
|
+
description: 'Which chain tip to sync to (proposed, checkpointed, proven, finalized)',
|
|
62
|
+
...enumConfigHelper(['proposed', 'checkpointed', 'proven', 'finalized'], 'proposed'),
|
|
63
|
+
},
|
|
56
64
|
};
|
|
57
65
|
|
|
58
66
|
/**
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import type { NodeStats, RoundTripStats } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Proxy generator for an AztecNode that tracks the time taken for each RPC call and the number of round trips (actual
|
|
7
|
+
* blocking waits for node responses).
|
|
8
|
+
*
|
|
9
|
+
* A round trip is counted when we transition from 0 to 1 in-flight calls, and ends when all concurrent calls complete.
|
|
10
|
+
* This means parallel calls in Promise.all count as a single round trip.
|
|
11
|
+
*
|
|
12
|
+
* Note that batching of RPC calls in `safe_json_rpc_client.ts` could affect the round trip counts but in places we
|
|
13
|
+
* currently use this information we do not even use HTTP as we have direct access to the Aztec Node instance in TS
|
|
14
|
+
* (i.e. not running against external node) so this is not a problem for now.
|
|
15
|
+
*
|
|
16
|
+
* If you want to use this against external node and the info gets skewed by batching you can set the `maxBatchSize`
|
|
17
|
+
* value in `safe_json_rpc_client.ts` to 1 (the main motivation for batching was to get around parallel http requests
|
|
18
|
+
* limits in web browsers which is not a problem when debugging in node.js).
|
|
19
|
+
*/
|
|
20
|
+
export type BenchmarkedNode = AztecNode & { getStats(): NodeStats };
|
|
21
|
+
|
|
22
|
+
export class BenchmarkedNodeFactory {
|
|
23
|
+
static create(node: AztecNode): BenchmarkedNode {
|
|
24
|
+
// Per-method call stats
|
|
25
|
+
const perMethod: Partial<Record<keyof AztecNode, { times: number[] }>> = {};
|
|
26
|
+
|
|
27
|
+
// Round trip tracking
|
|
28
|
+
let inFlightCount = 0;
|
|
29
|
+
let currentRoundTripTimer: Timer | null = null;
|
|
30
|
+
let currentRoundTripMethods: string[] = [];
|
|
31
|
+
const roundTrips: RoundTripStats = {
|
|
32
|
+
roundTrips: 0,
|
|
33
|
+
totalBlockingTime: 0,
|
|
34
|
+
roundTripDurations: [],
|
|
35
|
+
roundTripMethods: [],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return new Proxy(node, {
|
|
39
|
+
get(target, prop: keyof BenchmarkedNode) {
|
|
40
|
+
if (prop === 'getStats') {
|
|
41
|
+
return (): NodeStats => {
|
|
42
|
+
return { perMethod, roundTrips };
|
|
43
|
+
};
|
|
44
|
+
} else {
|
|
45
|
+
return function (...args: any[]) {
|
|
46
|
+
// Track per-method stats
|
|
47
|
+
if (!perMethod[prop]) {
|
|
48
|
+
perMethod[prop] = { times: [] };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Start of a new round trip batch?
|
|
52
|
+
if (inFlightCount === 0) {
|
|
53
|
+
roundTrips.roundTrips++;
|
|
54
|
+
currentRoundTripTimer = new Timer();
|
|
55
|
+
currentRoundTripMethods = [];
|
|
56
|
+
}
|
|
57
|
+
inFlightCount++;
|
|
58
|
+
currentRoundTripMethods.push(prop);
|
|
59
|
+
|
|
60
|
+
const callTimer = new Timer();
|
|
61
|
+
const result = (target[prop] as any).apply(target, args);
|
|
62
|
+
|
|
63
|
+
// Handle completion - called when the call finishes (after Promise resolves)
|
|
64
|
+
const handleCompletion = () => {
|
|
65
|
+
const callTime = callTimer.ms();
|
|
66
|
+
perMethod[prop]!.times.push(callTime);
|
|
67
|
+
|
|
68
|
+
inFlightCount--;
|
|
69
|
+
|
|
70
|
+
// End of round trip batch - all concurrent calls completed
|
|
71
|
+
if (inFlightCount === 0 && currentRoundTripTimer) {
|
|
72
|
+
const roundTripTime = currentRoundTripTimer.ms();
|
|
73
|
+
roundTrips.totalBlockingTime += roundTripTime;
|
|
74
|
+
roundTrips.roundTripDurations.push(roundTripTime);
|
|
75
|
+
roundTrips.roundTripMethods.push(currentRoundTripMethods);
|
|
76
|
+
currentRoundTripTimer = null;
|
|
77
|
+
currentRoundTripMethods = [];
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// If the result is a Promise, chain the completion handler
|
|
82
|
+
if (result && typeof result.then === 'function') {
|
|
83
|
+
return result.then(
|
|
84
|
+
(value: any) => {
|
|
85
|
+
handleCompletion();
|
|
86
|
+
return value;
|
|
87
|
+
},
|
|
88
|
+
(error: any) => {
|
|
89
|
+
handleCompletion();
|
|
90
|
+
throw error;
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
} else {
|
|
94
|
+
// Synchronous method - handle completion immediately
|
|
95
|
+
handleCompletion();
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
}) as BenchmarkedNode;
|
|
102
|
+
}
|
|
103
|
+
}
|