@aztec/pxe 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0
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 +48 -29
- 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 +34 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +46 -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 +37 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +53 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/block_synchronizer/block_synchronizer.js +209 -0
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +14 -5
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -2
- package/dest/config/package_info.js +1 -1
- package/dest/contract/contract_class_service.d.ts +31 -0
- package/dest/contract/contract_class_service.d.ts.map +1 -0
- package/dest/contract/contract_class_service.js +68 -0
- package/dest/contract/contract_sync_service.d.ts +48 -0
- package/dest/contract/contract_sync_service.d.ts.map +1 -0
- package/dest/contract/contract_sync_service.js +116 -0
- package/dest/contract/helpers.d.ts +7 -0
- package/dest/contract/helpers.d.ts.map +1 -0
- package/dest/contract/helpers.js +20 -0
- package/dest/contract/skip_sync_contracts.d.ts +11 -0
- package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
- package/dest/contract/skip_sync_contracts.js +18 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts +36 -0
- package/dest/contract_function_simulator/anchored_contract_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/anchored_contract_data.js +54 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +39 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.js +60 -0
- 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 +91 -27
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +302 -91
- 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 +19 -16
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +34 -37
- 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/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.d.ts +27 -6
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +12 -4
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +29 -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 +30 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts +9 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/contract_class_log_data.js +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts +7 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/embedded_curve_point.js +1 -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 +6 -6
- 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 +13 -11
- package/dest/contract_function_simulator/noir-structs/fact.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/fact.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact.js +6 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +31 -0
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +21 -11
- 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 +12 -23
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +11 -9
- 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 -63
- 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 +5 -7
- 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 +9 -13
- package/dest/contract_function_simulator/noir-structs/option.d.ts +59 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +67 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/origin_block.js +5 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/pending_tagged_log.js +4 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +8 -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 +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts +28 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tagging_strategy.js +50 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +19 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +9 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +15 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +5 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +7 -18
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -31
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts +21 -0
- package/dest/contract_function_simulator/oracle/acir_callback.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/acir_callback.js +115 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -13
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -94
- 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/legacy_oracle_registry.d.ts +39 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_registry.js +107 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +5 -14
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -24
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +12 -8
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +15 -11
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +139 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +1016 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +274 -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 +1243 -0
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -28
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +8 -43
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +90 -97
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +275 -138
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +236 -65
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +661 -132
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +21 -4
- package/dest/contract_function_simulator/transient_array_service.d.ts +31 -0
- package/dest/contract_function_simulator/transient_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/transient_array_service.js +62 -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/debug/pxe_debug_utils.d.ts +40 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +42 -0
- package/dest/entrypoints/client/bundle/index.d.ts +4 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -1
- 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 +54 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -1
- 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 +55 -13
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +42 -0
- package/dest/entrypoints/pxe_creation_options.d.ts +22 -4
- 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 +10 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +8 -2
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- 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 +62 -19
- package/dest/error_enriching.d.ts +6 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +13 -11
- package/dest/events/event_service.d.ts +24 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +77 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +10 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +53 -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 +62 -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 +5 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +2 -0
- package/dest/hooks/resolve_custom_request.d.ts +23 -0
- package/dest/hooks/resolve_custom_request.d.ts.map +1 -0
- package/dest/hooks/resolve_custom_request.js +3 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts +50 -0
- package/dest/hooks/resolve_tagging_secret_strategy.d.ts.map +1 -0
- package/dest/hooks/resolve_tagging_secret_strategy.js +3 -0
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +31 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +232 -0
- package/dest/messages/tx_resolver_service.d.ts +17 -0
- package/dest/messages/tx_resolver_service.d.ts.map +1 -0
- package/dest/messages/tx_resolver_service.js +60 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +70 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +172 -0
- 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/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 +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} +147 -76
- 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 +7 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +214 -93
- package/dest/private_kernel/private_kernel_oracle.d.ts +32 -29
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +108 -2
- package/dest/pxe.d.ts +260 -134
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +496 -342
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +13 -12
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/allowed_scopes.d.ts +6 -0
- package/dest/storage/allowed_scopes.d.ts.map +1 -0
- package/dest/storage/allowed_scopes.js +7 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +20 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.js +28 -0
- package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/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 +671 -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 +47 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +72 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_store.js +261 -0
- package/dest/storage/capsule_store/index.d.ts +3 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +2 -0
- package/dest/storage/contract_store/contract_store.d.ts +96 -0
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/contract_store/contract_store.js +281 -0
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +1 -1
- package/dest/storage/fact_store/fact_service.d.ts +22 -0
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_service.js +45 -0
- package/dest/storage/fact_store/fact_store.d.ts +95 -0
- package/dest/storage/fact_store/fact_store.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store.js +408 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts +34 -0
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_store_keys.js +50 -0
- package/dest/storage/fact_store/index.d.ts +6 -0
- package/dest/storage/fact_store/index.d.ts.map +1 -0
- package/dest/storage/fact_store/index.js +4 -0
- package/dest/storage/fact_store/origin_state.d.ts +59 -0
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -0
- package/dest/storage/fact_store/origin_state.js +60 -0
- package/dest/storage/fact_store/stored_fact.d.ts +32 -0
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -0
- package/dest/storage/fact_store/stored_fact.js +64 -0
- package/dest/storage/index.d.ts +9 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +8 -7
- package/dest/storage/metadata.d.ts +2 -2
- package/dest/storage/metadata.d.ts.map +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/note_store/note_store.d.ts +92 -0
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/note_store/note_store.js +372 -0
- package/dest/storage/note_store/stored_note.d.ts +11 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +27 -0
- package/dest/storage/open_pxe_stores.d.ts +35 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +29 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +88 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/private_event_store/private_event_store.js +273 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +28 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +111 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +94 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +411 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts +51 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/tagging_secret_sources_store.js +105 -0
- package/dest/tagging/constants.d.ts +3 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +28 -2
- package/dest/tagging/get_all_logs_by_tags.d.ts +48 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +59 -0
- package/dest/tagging/index.d.ts +18 -7
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +16 -5
- 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 +74 -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 +238 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/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 +16 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +92 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +17 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +60 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +19 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +76 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/package.json +31 -19
- package/src/bin/check_oracle_version.ts +56 -34
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +54 -0
- package/src/block_synchronizer/block_stream_source.ts +42 -0
- package/src/block_synchronizer/block_synchronizer.ts +241 -0
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +25 -4
- package/src/config/package_info.ts +1 -1
- package/src/contract/contract_class_service.ts +83 -0
- package/src/contract/contract_sync_service.ts +176 -0
- package/src/contract/helpers.ts +35 -0
- package/src/contract/skip_sync_contracts.ts +23 -0
- package/src/contract_function_simulator/anchored_contract_data.ts +74 -0
- package/src/contract_function_simulator/aztec_node_read_cache.ts +89 -0
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +513 -124
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_note_cache.ts +39 -38
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -18
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/index.ts +90 -5
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +43 -0
- package/src/contract_function_simulator/noir-structs/contract_class_log_data.ts +9 -0
- package/src/contract_function_simulator/noir-structs/embedded_curve_point.ts +4 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +16 -11
- package/src/contract_function_simulator/noir-structs/fact.ts +13 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +64 -0
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +28 -20
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +14 -64
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +8 -13
- package/src/contract_function_simulator/noir-structs/option.ts +75 -0
- package/src/contract_function_simulator/noir-structs/origin_block.ts +8 -0
- package/src/contract_function_simulator/noir-structs/pending_tagged_log.ts +12 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +5 -0
- package/src/contract_function_simulator/noir-structs/resolved_tagging_strategy.ts +66 -0
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +19 -0
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +16 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -37
- package/src/contract_function_simulator/oracle/acir_callback.ts +154 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -15
- package/src/contract_function_simulator/oracle/interfaces.ts +11 -166
- package/src/contract_function_simulator/oracle/legacy_oracle_registry.ts +147 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +6 -21
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +28 -14
- package/src/contract_function_simulator/oracle/oracle_registry.ts +710 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +1052 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +8 -76
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +355 -189
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +1027 -166
- package/src/contract_function_simulator/pick_notes.ts +23 -4
- package/src/contract_function_simulator/transient_array_service.ts +91 -0
- package/src/contract_logging.ts +52 -0
- package/src/debug/pxe_debug_utils.ts +85 -0
- package/src/entrypoints/client/bundle/index.ts +3 -1
- package/src/entrypoints/client/bundle/utils.ts +52 -21
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +54 -23
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/pxe_creation_options.ts +27 -3
- package/src/entrypoints/server/index.ts +10 -2
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +68 -45
- package/src/error_enriching.ts +20 -12
- package/src/events/event_service.ts +119 -0
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +66 -0
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +68 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/resolve_custom_request.ts +24 -0
- package/src/hooks/resolve_tagging_secret_strategy.ts +60 -0
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +300 -0
- package/src/messages/tx_resolver_service.ts +69 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +230 -0
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -9
- package/src/private_kernel/batch_planner.ts +168 -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 +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +209 -141
- package/src/private_kernel/hints/test_utils.ts +318 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +352 -130
- package/src/private_kernel/private_kernel_oracle.ts +149 -39
- package/src/pxe.ts +846 -457
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +16 -16
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/allowed_scopes.ts +14 -0
- package/src/storage/anchor_block_store/anchor_block_store.ts +35 -0
- package/src/storage/anchor_block_store/index.ts +1 -0
- 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__/FactStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +40 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +56 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +26 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/TaggingSecretSourcesStore.json +30 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +117 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +803 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/capsule_store/capsule_service.ts +85 -0
- package/src/storage/capsule_store/capsule_store.ts +333 -0
- package/src/storage/capsule_store/index.ts +2 -0
- package/src/storage/contract_store/contract_store.ts +401 -0
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +1 -1
- package/src/storage/fact_store/fact_service.ts +69 -0
- package/src/storage/fact_store/fact_store.ts +487 -0
- package/src/storage/fact_store/fact_store_keys.ts +75 -0
- package/src/storage/fact_store/index.ts +15 -0
- package/src/storage/fact_store/origin_state.ts +84 -0
- package/src/storage/fact_store/stored_fact.ts +80 -0
- package/src/storage/index.ts +8 -7
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/note_store/note_store.ts +454 -0
- package/src/storage/note_store/stored_note.ts +26 -0
- package/src/storage/open_pxe_stores.ts +52 -0
- package/src/storage/private_event_store/private_event_store.ts +382 -0
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +139 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +523 -0
- package/src/storage/tagging_store/tagging_secret_sources_store.ts +138 -0
- package/src/tagging/constants.ts +30 -2
- package/src/tagging/get_all_logs_by_tags.ts +120 -0
- package/src/tagging/index.ts +20 -6
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +358 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +134 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +66 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +88 -0
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -267
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- package/dest/contract_function_simulator/oracle/oracle.d.ts +0 -58
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/oracle.js +0 -334
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +0 -6
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +0 -62
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -123
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -696
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/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 -45
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -118
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +0 -64
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -193
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts +0 -83
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_data_provider.js +0 -314
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -37
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -105
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +0 -11
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +0 -26
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -36
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/synchronizer/synchronizer.js +0 -102
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -24
- package/src/contract_function_simulator/execution_data_provider.ts +0 -342
- package/src/contract_function_simulator/oracle/oracle.ts +0 -591
- package/src/contract_function_simulator/proxied_contract_data_source.ts +0 -66
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1023
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -132
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +0 -147
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/contract_data_provider.ts +0 -277
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/note_data_provider/note_data_provider.ts +0 -403
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +0 -143
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/sync_data_provider/sync_data_provider.ts +0 -35
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
- package/src/synchronizer/index.ts +0 -1
- package/src/synchronizer/synchronizer.ts +0 -121
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { Semaphore } from '@aztec/foundation/queue';
|
|
5
|
+
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
6
|
+
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
7
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
+
import type { InTx, TxHash } from '@aztec/stdlib/tx';
|
|
9
|
+
|
|
10
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
11
|
+
import type { PackedPrivateEvent } from '../../pxe.js';
|
|
12
|
+
import { StoredPrivateEvent } from './stored_private_event.js';
|
|
13
|
+
|
|
14
|
+
export type PrivateEventStoreFilter = {
|
|
15
|
+
contractAddress: AztecAddress;
|
|
16
|
+
fromBlock: number;
|
|
17
|
+
toBlock: number;
|
|
18
|
+
scopes: AztecAddress[];
|
|
19
|
+
txHash?: TxHash;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type PrivateEventMetadata = InTx & {
|
|
23
|
+
contractAddress: AztecAddress;
|
|
24
|
+
scope: AztecAddress;
|
|
25
|
+
/** The index of the tx within the block */
|
|
26
|
+
txIndexInBlock: number;
|
|
27
|
+
/** The index of the event within the tx (based on nullifier position) */
|
|
28
|
+
eventIndexInTx: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/// Alias types for kv map readability
|
|
32
|
+
type EventId = string; // the siloedEventCommitment, stringified
|
|
33
|
+
type JobId = string;
|
|
34
|
+
type ContractAndSelectorKey = string;
|
|
35
|
+
type BlockNum = number;
|
|
36
|
+
type StoredEventBuffer = Buffer;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stores decrypted private event logs.
|
|
40
|
+
*
|
|
41
|
+
* Append-only: events are never deleted during normal operation. Reorgs are handled by delete-on-prune, which removes
|
|
42
|
+
* every event originating on a reorg'd block.
|
|
43
|
+
*/
|
|
44
|
+
export class PrivateEventStore implements StagedStore {
|
|
45
|
+
readonly storeName: string = 'private_event';
|
|
46
|
+
|
|
47
|
+
#store: AztecAsyncKVStore;
|
|
48
|
+
/** Actual private event log entries, keyed by siloedEventCommitment */
|
|
49
|
+
#events: AztecAsyncMap<EventId, StoredEventBuffer>;
|
|
50
|
+
/** Multi-map from contractAddress_eventSelector to siloedEventCommitment for efficient lookup */
|
|
51
|
+
#eventsByContractAndEventSelector: AztecAsyncMultiMap<ContractAndSelectorKey, EventId>;
|
|
52
|
+
/** Multi-map from block number to siloedEventCommitment, for delete-on-prune. */
|
|
53
|
+
#eventsByBlockNumber: AztecAsyncMultiMap<BlockNum, EventId>;
|
|
54
|
+
|
|
55
|
+
/** jobId => eventId (event siloed nullifier) => StoredPrivateEvent */
|
|
56
|
+
#eventsForJob: Map<JobId, Map<EventId, StoredPrivateEvent>>;
|
|
57
|
+
|
|
58
|
+
/** Per-job locks to prevent concurrent writes from affecting each other. */
|
|
59
|
+
#jobLocks: Map<JobId, Semaphore>;
|
|
60
|
+
|
|
61
|
+
logger = createLogger('private_event_store');
|
|
62
|
+
|
|
63
|
+
constructor(store: AztecAsyncKVStore) {
|
|
64
|
+
this.#store = store;
|
|
65
|
+
this.#events = this.#store.openMap('private_event_logs');
|
|
66
|
+
this.#eventsByContractAndEventSelector = this.#store.openMultiMap('events_by_contract_selector');
|
|
67
|
+
this.#eventsByBlockNumber = this.#store.openMultiMap('events_by_block_number');
|
|
68
|
+
|
|
69
|
+
this.#eventsForJob = new Map();
|
|
70
|
+
this.#jobLocks = new Map();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Store a private event log.
|
|
75
|
+
* @param eventSelector - The event selector of the event.
|
|
76
|
+
* @param randomness - The randomness used for the event commitment.
|
|
77
|
+
* @param msgContent - The content of the event.
|
|
78
|
+
* @param siloedEventCommitment - The siloed event commitment (used as unique identifier).
|
|
79
|
+
* @param metadata
|
|
80
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
81
|
+
* scope - The address to which the event is scoped.
|
|
82
|
+
* txHash - The transaction hash of the event log.
|
|
83
|
+
* blockNumber - The block number in which the event was emitted.
|
|
84
|
+
*/
|
|
85
|
+
storePrivateEventLog(
|
|
86
|
+
eventSelector: EventSelector,
|
|
87
|
+
randomness: Fr,
|
|
88
|
+
msgContent: Fr[],
|
|
89
|
+
siloedEventCommitment: Fr,
|
|
90
|
+
metadata: PrivateEventMetadata,
|
|
91
|
+
jobId: string,
|
|
92
|
+
) {
|
|
93
|
+
return this.#withJobLock(jobId, () =>
|
|
94
|
+
this.#store.transactionAsync(async () => {
|
|
95
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash, txIndexInBlock, eventIndexInTx } = metadata;
|
|
96
|
+
const eventId = siloedEventCommitment.toString();
|
|
97
|
+
|
|
98
|
+
this.logger.verbose('storing private event log (job stage)', {
|
|
99
|
+
eventId,
|
|
100
|
+
contractAddress,
|
|
101
|
+
scope,
|
|
102
|
+
msgContent,
|
|
103
|
+
l2BlockNumber,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const existing = await this.#readEvent(eventId, jobId);
|
|
107
|
+
|
|
108
|
+
if (existing) {
|
|
109
|
+
// If we already stored this event, we still want to make sure to track it for the given scope
|
|
110
|
+
existing.addScope(scope.toString());
|
|
111
|
+
this.#writeEvent(eventId, existing, jobId);
|
|
112
|
+
} else {
|
|
113
|
+
this.#writeEvent(
|
|
114
|
+
eventId,
|
|
115
|
+
new StoredPrivateEvent(
|
|
116
|
+
randomness,
|
|
117
|
+
msgContent,
|
|
118
|
+
l2BlockNumber,
|
|
119
|
+
l2BlockHash,
|
|
120
|
+
txHash,
|
|
121
|
+
txIndexInBlock,
|
|
122
|
+
eventIndexInTx,
|
|
123
|
+
contractAddress,
|
|
124
|
+
eventSelector,
|
|
125
|
+
new Set([scope.toString()]),
|
|
126
|
+
),
|
|
127
|
+
jobId,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns the private events given search parameters.
|
|
136
|
+
* @param eventSelector - The event selector to filter by.
|
|
137
|
+
* @param filter - Filtering criteria:
|
|
138
|
+
* contractAddress: The address of the contract to get events from.
|
|
139
|
+
* fromBlock: The block number to search from (inclusive).
|
|
140
|
+
* toBlock: The block number to search upto (exclusive).
|
|
141
|
+
* scope: - The addresses that decrypted the logs.
|
|
142
|
+
* @returns - The event log contents, augmented with metadata about the transaction and block in which the event was
|
|
143
|
+
* included.
|
|
144
|
+
*/
|
|
145
|
+
public getPrivateEvents(
|
|
146
|
+
eventSelector: EventSelector,
|
|
147
|
+
filter: PrivateEventStoreFilter,
|
|
148
|
+
): Promise<PackedPrivateEvent[]> {
|
|
149
|
+
return this.#store.transactionAsync(async () => {
|
|
150
|
+
const key = this.#keyFor(filter.contractAddress, eventSelector);
|
|
151
|
+
const targetScopes = new Set(filter.scopes.map(s => s.toString()));
|
|
152
|
+
|
|
153
|
+
// Map from eventId to the promise that reads the event buffer.
|
|
154
|
+
// We start reads during iteration to keep DB requests pending and avoid IndexedDB auto-commit.
|
|
155
|
+
const eventReadPromises: Map<string, Promise<Buffer | undefined>> = new Map();
|
|
156
|
+
|
|
157
|
+
for await (const eventId of this.#eventsByContractAndEventSelector.getValuesAsync(key)) {
|
|
158
|
+
eventReadPromises.set(eventId, this.#events.getAsync(eventId));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const eventIds = [...eventReadPromises.keys()];
|
|
162
|
+
const eventBuffers = await Promise.all(eventReadPromises.values());
|
|
163
|
+
|
|
164
|
+
const events: Array<{
|
|
165
|
+
l2BlockNumber: number;
|
|
166
|
+
txIndexInBlock: number;
|
|
167
|
+
eventIndexInTx: number;
|
|
168
|
+
event: PackedPrivateEvent;
|
|
169
|
+
}> = [];
|
|
170
|
+
|
|
171
|
+
for (let i = 0; i < eventIds.length; i++) {
|
|
172
|
+
const eventId = eventIds[i];
|
|
173
|
+
const eventBuffer = eventBuffers[i];
|
|
174
|
+
|
|
175
|
+
// Defensive, if it happens, there's a problem with how we're handling #eventsByContractAndEventSelector
|
|
176
|
+
if (!eventBuffer) {
|
|
177
|
+
this.logger.verbose(
|
|
178
|
+
`EventId ${eventId} does not exist in main index but it is referenced from contract event selector index`,
|
|
179
|
+
);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const storedPrivateEvent = StoredPrivateEvent.fromBuffer(eventBuffer);
|
|
184
|
+
|
|
185
|
+
// Filter by block range
|
|
186
|
+
if (storedPrivateEvent.l2BlockNumber < filter.fromBlock || storedPrivateEvent.l2BlockNumber >= filter.toBlock) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Filter by scopes
|
|
191
|
+
if (storedPrivateEvent.scopes.intersection(targetScopes).size === 0) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Filter by txHash
|
|
196
|
+
if (filter.txHash && !storedPrivateEvent.txHash.equals(filter.txHash)) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
events.push({
|
|
201
|
+
l2BlockNumber: storedPrivateEvent.l2BlockNumber,
|
|
202
|
+
txIndexInBlock: storedPrivateEvent.txIndexInBlock,
|
|
203
|
+
eventIndexInTx: storedPrivateEvent.eventIndexInTx,
|
|
204
|
+
event: {
|
|
205
|
+
packedEvent: storedPrivateEvent.msgContent,
|
|
206
|
+
l2BlockNumber: BlockNumber(storedPrivateEvent.l2BlockNumber),
|
|
207
|
+
txHash: storedPrivateEvent.txHash,
|
|
208
|
+
l2BlockHash: storedPrivateEvent.l2BlockHash,
|
|
209
|
+
eventSelector,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Sort by block number, then by tx index within block, then by event index within tx
|
|
215
|
+
events.sort((a, b) => {
|
|
216
|
+
if (a.l2BlockNumber !== b.l2BlockNumber) {
|
|
217
|
+
return a.l2BlockNumber - b.l2BlockNumber;
|
|
218
|
+
}
|
|
219
|
+
if (a.txIndexInBlock !== b.txIndexInBlock) {
|
|
220
|
+
return a.txIndexInBlock - b.txIndexInBlock;
|
|
221
|
+
}
|
|
222
|
+
return a.eventIndexInTx - b.eventIndexInTx;
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return events.map(ev => ev.event);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Returns the ids (siloed event commitments) of all events emitted at the given block number. Used by delete-on-prune. */
|
|
230
|
+
public async eventIdsAtBlock(blockNumber: number): Promise<string[]> {
|
|
231
|
+
const eventIds: string[] = [];
|
|
232
|
+
for await (const eventId of this.#eventsByBlockNumber.getValuesAsync(blockNumber)) {
|
|
233
|
+
eventIds.push(eventId);
|
|
234
|
+
}
|
|
235
|
+
return eventIds;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Rolls the store back to `toBlock`: deletes every event anchored to a block strictly above it, as if nothing past
|
|
240
|
+
* that block height ever happened. Used by the reorg (`chain-pruned`) path to truncate the orphaned tail. Scanning
|
|
241
|
+
* from `toBlock + 1` upward covers everything above the rollback target without needing to know the chain tip.
|
|
242
|
+
*
|
|
243
|
+
* Must be called inside a transaction owned by the caller (it issues no `transactionAsync` of its own, the reorg
|
|
244
|
+
* path wraps it together with the anchor update, and IndexedDB has no nested transactions). Throws if any job has
|
|
245
|
+
* uncommitted staged writes, since rolling back mid-job could later re-introduce events anchored to deleted blocks.
|
|
246
|
+
*/
|
|
247
|
+
public async rollback(toBlock: number): Promise<void> {
|
|
248
|
+
if (this.#eventsForJob.size > 0) {
|
|
249
|
+
throw new Error('PXE private event store rollback is not allowed while jobs are running');
|
|
250
|
+
}
|
|
251
|
+
// Snapshot before mutating so we never delete from the multimap we are iterating.
|
|
252
|
+
const orphaned: { block: number; eventId: string }[] = [];
|
|
253
|
+
for await (const [block, eventId] of this.#eventsByBlockNumber.entriesAsync({ start: toBlock + 1 })) {
|
|
254
|
+
orphaned.push({ block, eventId });
|
|
255
|
+
}
|
|
256
|
+
let removedCount = 0;
|
|
257
|
+
for (const { block, eventId } of orphaned) {
|
|
258
|
+
const buf = await this.#events.getAsync(eventId);
|
|
259
|
+
if (!buf) {
|
|
260
|
+
throw new Error(`Event not found for eventId ${eventId}`);
|
|
261
|
+
}
|
|
262
|
+
const stored = StoredPrivateEvent.fromBuffer(buf);
|
|
263
|
+
await this.#events.delete(eventId);
|
|
264
|
+
await this.#eventsByContractAndEventSelector.deleteValue(
|
|
265
|
+
this.#keyFor(stored.contractAddress, stored.eventSelector),
|
|
266
|
+
eventId,
|
|
267
|
+
);
|
|
268
|
+
await this.#eventsByBlockNumber.deleteValue(block, eventId);
|
|
269
|
+
removedCount++;
|
|
270
|
+
}
|
|
271
|
+
this.logger.verbose('rolled back private events', { removedCount, toBlock });
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Commits in memory job data to persistent storage.
|
|
276
|
+
*
|
|
277
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
278
|
+
*
|
|
279
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't need our own transactionAsync here
|
|
280
|
+
* (and using one would throw on IndexedDB as it does not support nested txs).
|
|
281
|
+
*
|
|
282
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
283
|
+
*/
|
|
284
|
+
async commit(jobId: string): Promise<void> {
|
|
285
|
+
// Note: Don't use #withJobLock here - commit runs within JobCoordinator's transactionAsync,
|
|
286
|
+
// and awaiting the lock would create a microtask boundary with no pending DB request,
|
|
287
|
+
// causing IndexedDB to auto-commit the transaction.
|
|
288
|
+
for (const [eventId, entry] of this.#getEventsForJob(jobId).entries()) {
|
|
289
|
+
const lookupKey = this.#keyFor(entry.contractAddress, entry.eventSelector);
|
|
290
|
+
this.logger.verbose('storing private event log', { eventId, lookupKey });
|
|
291
|
+
|
|
292
|
+
await Promise.all([
|
|
293
|
+
this.#events.set(eventId, entry.toBuffer()),
|
|
294
|
+
this.#eventsByContractAndEventSelector.set(lookupKey, eventId),
|
|
295
|
+
this.#eventsByBlockNumber.set(entry.l2BlockNumber, eventId),
|
|
296
|
+
]);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
this.#clearJobData(jobId);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Discards in memory job data without persisting it.
|
|
304
|
+
*/
|
|
305
|
+
discardStaged(jobId: string): Promise<void> {
|
|
306
|
+
this.#clearJobData(jobId);
|
|
307
|
+
return Promise.resolve();
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Reads an event from in-memory job data first, falling back to persistent storage if not found.
|
|
312
|
+
*
|
|
313
|
+
* Returns undefined if the event does not exist in the store overall.
|
|
314
|
+
*/
|
|
315
|
+
async #readEvent(eventId: string, jobId: string): Promise<StoredPrivateEvent | undefined> {
|
|
316
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
317
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
318
|
+
const buffer = await this.#events.getAsync(eventId);
|
|
319
|
+
const eventForJob = this.#getEventsForJob(jobId).get(eventId);
|
|
320
|
+
return eventForJob ?? (buffer ? StoredPrivateEvent.fromBuffer(buffer) : undefined);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Writes an event to in-memory job data.
|
|
325
|
+
*
|
|
326
|
+
* Writes are only allowed in a job context. Events modified during a job will only be persisted when `commit` is
|
|
327
|
+
* called.
|
|
328
|
+
*/
|
|
329
|
+
#writeEvent(eventId: string, entry: StoredPrivateEvent, jobId: string) {
|
|
330
|
+
this.#getEventsForJob(jobId).set(eventId, entry);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get in-memory data only visible to @param jobId
|
|
335
|
+
*/
|
|
336
|
+
#getEventsForJob(jobId: string): Map<string, StoredPrivateEvent> {
|
|
337
|
+
let eventsForJob = this.#eventsForJob.get(jobId);
|
|
338
|
+
if (eventsForJob === undefined) {
|
|
339
|
+
eventsForJob = new Map();
|
|
340
|
+
this.#eventsForJob.set(jobId, eventsForJob);
|
|
341
|
+
}
|
|
342
|
+
return eventsForJob;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Clear data structures supporting a specific job.
|
|
347
|
+
*/
|
|
348
|
+
#clearJobData(jobId: string) {
|
|
349
|
+
this.#eventsForJob.delete(jobId);
|
|
350
|
+
this.#jobLocks.delete(jobId);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Ensures a function can only run once it acquires a unique per-job lock, and handles proper lock release after it
|
|
355
|
+
* runs.
|
|
356
|
+
*
|
|
357
|
+
* This primitive allows concurrent writes on this store without risking data corruption due to unsound write
|
|
358
|
+
* interleaving.
|
|
359
|
+
*/
|
|
360
|
+
async #withJobLock<T>(jobId: string, fn: () => Promise<T>): Promise<T> {
|
|
361
|
+
let lock = this.#jobLocks.get(jobId);
|
|
362
|
+
if (!lock) {
|
|
363
|
+
lock = new Semaphore(1);
|
|
364
|
+
this.#jobLocks.set(jobId, lock);
|
|
365
|
+
}
|
|
366
|
+
await lock.acquire();
|
|
367
|
+
try {
|
|
368
|
+
return await fn();
|
|
369
|
+
} finally {
|
|
370
|
+
lock.release();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Returns a string key based on @param contractAddress and @param eventSelector.
|
|
376
|
+
*
|
|
377
|
+
* The returned key is meant to be used when interacting with index #eventsByContractAndEventSelector.
|
|
378
|
+
*/
|
|
379
|
+
#keyFor(contractAddress: AztecAddress, eventSelector: EventSelector): string {
|
|
380
|
+
return `${contractAddress.toString()}_${eventSelector.toString()}`;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import { EventSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
6
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
|
+
|
|
8
|
+
/** Serializable private event entry with scope tracking. */
|
|
9
|
+
export class StoredPrivateEvent {
|
|
10
|
+
constructor(
|
|
11
|
+
readonly randomness: Fr,
|
|
12
|
+
readonly msgContent: Fr[],
|
|
13
|
+
readonly l2BlockNumber: number,
|
|
14
|
+
readonly l2BlockHash: BlockHash,
|
|
15
|
+
readonly txHash: TxHash,
|
|
16
|
+
readonly txIndexInBlock: number,
|
|
17
|
+
readonly eventIndexInTx: number,
|
|
18
|
+
readonly contractAddress: AztecAddress,
|
|
19
|
+
readonly eventSelector: EventSelector,
|
|
20
|
+
readonly scopes: Set<string>,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
addScope(scope: string) {
|
|
24
|
+
this.scopes.add(scope);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
toBuffer(): Buffer {
|
|
28
|
+
const scopesArray = [...this.scopes];
|
|
29
|
+
return serializeToBuffer(
|
|
30
|
+
this.randomness,
|
|
31
|
+
this.msgContent.length,
|
|
32
|
+
...this.msgContent,
|
|
33
|
+
this.l2BlockNumber,
|
|
34
|
+
this.l2BlockHash,
|
|
35
|
+
this.txHash,
|
|
36
|
+
this.txIndexInBlock,
|
|
37
|
+
this.eventIndexInTx,
|
|
38
|
+
this.contractAddress,
|
|
39
|
+
this.eventSelector.toBuffer(),
|
|
40
|
+
scopesArray.length,
|
|
41
|
+
...scopesArray,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromBuffer(buffer: Buffer): StoredPrivateEvent {
|
|
46
|
+
const reader = BufferReader.asReader(buffer);
|
|
47
|
+
|
|
48
|
+
const randomness = Fr.fromBuffer(reader);
|
|
49
|
+
const msgContentLength = reader.readNumber();
|
|
50
|
+
const msgContent = reader.readArray(msgContentLength, Fr);
|
|
51
|
+
const l2BlockNumber = reader.readNumber();
|
|
52
|
+
const l2BlockHash = BlockHash.fromBuffer(reader);
|
|
53
|
+
const txHash = TxHash.fromBuffer(reader);
|
|
54
|
+
const txIndexInBlock = reader.readNumber();
|
|
55
|
+
const eventIndexInTx = reader.readNumber();
|
|
56
|
+
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
57
|
+
const eventSelector = EventSelector.fromBuffer(reader);
|
|
58
|
+
const scopes = reader.readVector({ fromBuffer: (r: BufferReader) => r.readString() });
|
|
59
|
+
|
|
60
|
+
return new StoredPrivateEvent(
|
|
61
|
+
randomness,
|
|
62
|
+
msgContent,
|
|
63
|
+
l2BlockNumber,
|
|
64
|
+
l2BlockHash,
|
|
65
|
+
txHash,
|
|
66
|
+
txIndexInBlock,
|
|
67
|
+
eventIndexInTx,
|
|
68
|
+
contractAddress,
|
|
69
|
+
eventSelector,
|
|
70
|
+
new Set(scopes),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import { DatabaseVersion } from '@aztec/stdlib/database-version/version';
|
|
4
|
+
|
|
5
|
+
/** The triple that determine which physical store a logical store name maps to. */
|
|
6
|
+
export type StoreIdentity = {
|
|
7
|
+
/** Chain ID of the L1 the rollup is deployed to. */
|
|
8
|
+
l1ChainId: number;
|
|
9
|
+
/** Address of the rollup contract the store's data pertains to. */
|
|
10
|
+
rollupAddress: EthAddress;
|
|
11
|
+
/** Schema version of the data held in the store. */
|
|
12
|
+
schemaVersion: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Composes the store-name discriminator for a store identity. Two identities map to the same physical store iff
|
|
17
|
+
* their slugs are equal, so the format must stay stable: `<l1ChainId>-<rollupAddress>-v<schemaVersion>` — changing
|
|
18
|
+
* it orphans every existing store.
|
|
19
|
+
*/
|
|
20
|
+
export function storeIdentitySlug({ l1ChainId, rollupAddress, schemaVersion }: StoreIdentity): string {
|
|
21
|
+
return `${l1ChainId}-${rollupAddress.toString()}-v${schemaVersion}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Composes the physical store name for a logical store name and identity. */
|
|
25
|
+
export function effectiveStoreName(name: string, identity: StoreIdentity): string {
|
|
26
|
+
return `${name}_${storeIdentitySlug(identity)}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Invariant check for stores whose physical name carries their identity: the recorded version can
|
|
31
|
+
* only disagree with the expected one if there is a store-naming bug.
|
|
32
|
+
*/
|
|
33
|
+
export async function assertStoreIdentity(
|
|
34
|
+
store: AztecAsyncKVStore,
|
|
35
|
+
storeName: string,
|
|
36
|
+
identity: StoreIdentity,
|
|
37
|
+
): Promise<void> {
|
|
38
|
+
const expected = new DatabaseVersion(identity.schemaVersion, identity.rollupAddress);
|
|
39
|
+
const singleton = store.openSingleton<string>('dbVersion');
|
|
40
|
+
const stored = await singleton.getAsync();
|
|
41
|
+
if (stored === undefined) {
|
|
42
|
+
await singleton.set(expected.toBuffer().toString('utf-8'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let storedVersion: DatabaseVersion;
|
|
46
|
+
try {
|
|
47
|
+
storedVersion = DatabaseVersion.fromBuffer(Buffer.from(stored, 'utf-8'));
|
|
48
|
+
} catch {
|
|
49
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), stored);
|
|
50
|
+
}
|
|
51
|
+
if (!storedVersion.equals(expected)) {
|
|
52
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), storedVersion.toString());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when a store's recorded identity does not match the identity it was opened under. Since the identity is
|
|
58
|
+
* part of the physical store name, this can only indicate a store-naming bug; the store is left untouched.
|
|
59
|
+
*/
|
|
60
|
+
export class StoreIdentityMismatchError extends Error {
|
|
61
|
+
constructor(
|
|
62
|
+
public readonly storeName: string,
|
|
63
|
+
public readonly expected: string,
|
|
64
|
+
public readonly actual: string,
|
|
65
|
+
) {
|
|
66
|
+
super(
|
|
67
|
+
`Store '${storeName}' records identity ${actual} but was opened as ${expected}. ` +
|
|
68
|
+
`Refusing to open; data was NOT modified.`,
|
|
69
|
+
);
|
|
70
|
+
this.name = 'StoreIdentityMismatchError';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
2
|
+
import type { AppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
|
+
|
|
4
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
8
|
+
* is called SenderTaggingStore. We have the providers separate for the sender and recipient because
|
|
9
|
+
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
10
|
+
*
|
|
11
|
+
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
12
|
+
* blocks, which by definition cannot be affected by reorgs.
|
|
13
|
+
*/
|
|
14
|
+
export class RecipientTaggingStore implements StagedStore {
|
|
15
|
+
storeName: string = 'recipient_tagging';
|
|
16
|
+
|
|
17
|
+
#store: AztecAsyncKVStore;
|
|
18
|
+
|
|
19
|
+
#highestAgedIndex: AztecAsyncMap<string, number>;
|
|
20
|
+
#highestFinalizedIndex: AztecAsyncMap<string, number>;
|
|
21
|
+
|
|
22
|
+
// jobId => secret => number
|
|
23
|
+
#highestAgedIndexForJob: Map<string, Map<string, number>>;
|
|
24
|
+
|
|
25
|
+
// jobId => secret => number
|
|
26
|
+
#highestFinalizedIndexForJob: Map<string, Map<string, number>>;
|
|
27
|
+
|
|
28
|
+
constructor(store: AztecAsyncKVStore) {
|
|
29
|
+
this.#store = store;
|
|
30
|
+
|
|
31
|
+
this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
|
|
32
|
+
this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
|
|
33
|
+
|
|
34
|
+
this.#highestAgedIndexForJob = new Map();
|
|
35
|
+
this.#highestFinalizedIndexForJob = new Map();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#getHighestAgedIndexForJob(jobId: string): Map<string, number> {
|
|
39
|
+
let highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
|
|
40
|
+
if (!highestAgedIndexForJob) {
|
|
41
|
+
highestAgedIndexForJob = new Map();
|
|
42
|
+
this.#highestAgedIndexForJob.set(jobId, highestAgedIndexForJob);
|
|
43
|
+
}
|
|
44
|
+
return highestAgedIndexForJob;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async #readHighestAgedIndex(jobId: string, secret: string): Promise<number | undefined> {
|
|
48
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
49
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
50
|
+
const dbValue = await this.#highestAgedIndex.getAsync(secret);
|
|
51
|
+
const staged = this.#getHighestAgedIndexForJob(jobId).get(secret);
|
|
52
|
+
return staged ?? dbValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#writeHighestAgedIndex(jobId: string, secret: string, index: number) {
|
|
56
|
+
this.#getHighestAgedIndexForJob(jobId).set(secret, index);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#getHighestFinalizedIndexForJob(jobId: string): Map<string, number> {
|
|
60
|
+
let jobStagedHighestFinalizedIndex = this.#highestFinalizedIndexForJob.get(jobId);
|
|
61
|
+
if (!jobStagedHighestFinalizedIndex) {
|
|
62
|
+
jobStagedHighestFinalizedIndex = new Map();
|
|
63
|
+
this.#highestFinalizedIndexForJob.set(jobId, jobStagedHighestFinalizedIndex);
|
|
64
|
+
}
|
|
65
|
+
return jobStagedHighestFinalizedIndex;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async #readHighestFinalizedIndex(jobId: string, secret: string): Promise<number | undefined> {
|
|
69
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
70
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
71
|
+
const dbValue = await this.#highestFinalizedIndex.getAsync(secret);
|
|
72
|
+
const staged = this.#getHighestFinalizedIndexForJob(jobId).get(secret);
|
|
73
|
+
return staged ?? dbValue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#writeHighestFinalizedIndex(jobId: string, secret: string, index: number) {
|
|
77
|
+
this.#getHighestFinalizedIndexForJob(jobId).set(secret, index);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Writes all job-specific in-memory data to persistent storage.
|
|
82
|
+
*
|
|
83
|
+
* @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
|
|
84
|
+
*/
|
|
85
|
+
async commit(jobId: string): Promise<void> {
|
|
86
|
+
const highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
|
|
87
|
+
if (highestAgedIndexForJob) {
|
|
88
|
+
for (const [secret, index] of highestAgedIndexForJob.entries()) {
|
|
89
|
+
await this.#highestAgedIndex.set(secret, index);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const highestFinalizedIndexForJob = this.#highestFinalizedIndexForJob.get(jobId);
|
|
94
|
+
if (highestFinalizedIndexForJob) {
|
|
95
|
+
for (const [secret, index] of highestFinalizedIndexForJob.entries()) {
|
|
96
|
+
await this.#highestFinalizedIndex.set(secret, index);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return this.discardStaged(jobId);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
discardStaged(jobId: string): Promise<void> {
|
|
104
|
+
this.#highestAgedIndexForJob.delete(jobId);
|
|
105
|
+
this.#highestFinalizedIndexForJob.delete(jobId);
|
|
106
|
+
return Promise.resolve();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getHighestAgedIndex(secret: AppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
110
|
+
return this.#store.transactionAsync(() => this.#readHighestAgedIndex(jobId, secret.toString()));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
updateHighestAgedIndex(secret: AppTaggingSecret, index: number, jobId: string): Promise<void> {
|
|
114
|
+
return this.#store.transactionAsync(async () => {
|
|
115
|
+
const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
|
|
116
|
+
if (currentIndex !== undefined && index <= currentIndex) {
|
|
117
|
+
// Log sync should never set a lower highest aged index.
|
|
118
|
+
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
119
|
+
}
|
|
120
|
+
this.#writeHighestAgedIndex(jobId, secret.toString(), index);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getHighestFinalizedIndex(secret: AppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
125
|
+
return this.#store.transactionAsync(() => this.#readHighestFinalizedIndex(jobId, secret.toString()));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
updateHighestFinalizedIndex(secret: AppTaggingSecret, index: number, jobId: string): Promise<void> {
|
|
129
|
+
return this.#store.transactionAsync(async () => {
|
|
130
|
+
const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
|
|
131
|
+
if (currentIndex !== undefined && index < currentIndex) {
|
|
132
|
+
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
133
|
+
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
134
|
+
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
135
|
+
}
|
|
136
|
+
this.#writeHighestFinalizedIndex(jobId, secret.toString(), index);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|