@aztec/pxe 0.0.1-commit.2448fdb → 0.0.1-commit.2606882
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 +40 -96
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +26 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +93 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +62 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +21 -11
- package/dest/config/index.d.ts +8 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +4 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +20 -12
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -9
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -7
- package/dest/contract_function_simulator/index.d.ts +13 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +10 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +48 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +45 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- 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 +3 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +12 -2
- 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 +34 -3
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -2
- 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 +3 -2
- package/dest/contract_function_simulator/noir-structs/option.d.ts +61 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +62 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +24 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +16 -114
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts +55 -57
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +343 -344
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +127 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +786 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +139 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +560 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +27 -29
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +55 -47
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +59 -39
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +244 -149
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +35 -67
- package/dest/contract_sync/contract_sync_service.d.ts +4 -6
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +43 -24
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +12 -19
- package/dest/debug/pxe_debug_utils.d.ts +1 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +0 -6
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -3
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -3
- package/dest/entrypoints/pxe_creation_options.d.ts +7 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/utils.d.ts +3 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -3
- package/dest/events/event_service.d.ts +13 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +30 -9
- package/dest/hooks/authorize_utility_call.d.ts +41 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +42 -0
- package/dest/hooks/execution_hooks.d.ts.map +1 -0
- package/dest/hooks/execution_hooks.js +9 -0
- package/dest/hooks/index.d.ts +4 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +1 -0
- package/dest/logs/log_service.d.ts +6 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +112 -48
- package/dest/messages/message_context_service.d.ts +1 -1
- package/dest/messages/message_context_service.d.ts.map +1 -1
- package/dest/messages/message_context_service.js +28 -9
- package/dest/notes/note_service.d.ts +25 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +80 -65
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +4 -4
- 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/private_kernel_reset_private_inputs_builder.js +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +2 -3
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +148 -52
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +12 -7
- package/dest/pxe.d.ts +54 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +126 -84
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +591 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +5 -24
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/open_pxe_stores.d.ts +33 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +27 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +3 -3
- package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +36 -37
- package/dest/tagging/index.d.ts +5 -4
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +4 -3
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +163 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -5
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +26 -14
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -6
- 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 +21 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
- 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 +2 -2
- package/package.json +20 -17
- package/src/bin/check_oracle_version.ts +46 -119
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +121 -0
- package/src/block_synchronizer/block_stream_source.ts +81 -0
- package/src/block_synchronizer/block_synchronizer.ts +22 -12
- package/src/config/index.ts +15 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +34 -11
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -9
- package/src/contract_function_simulator/index.ts +50 -1
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +55 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +3 -2
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +35 -2
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -2
- package/src/contract_function_simulator/noir-structs/option.ts +69 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +27 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +12 -204
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle.ts +406 -556
- package/src/contract_function_simulator/oracle/oracle_registry.ts +585 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +553 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +74 -67
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +350 -304
- package/src/contract_function_simulator/proxied_contract_data_source.ts +40 -70
- package/src/contract_sync/contract_sync_service.ts +56 -43
- package/src/contract_sync/helpers.ts +11 -23
- package/src/debug/pxe_debug_utils.ts +0 -8
- package/src/entrypoints/client/bundle/utils.ts +8 -2
- package/src/entrypoints/client/lazy/utils.ts +8 -2
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/utils.ts +13 -3
- package/src/events/event_service.ts +54 -19
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/logs/log_service.ts +137 -92
- package/src/messages/message_context_service.ts +42 -24
- package/src/notes/note_service.ts +115 -91
- package/src/oracle_version.ts +4 -4
- package/src/private_kernel/batch_planner.ts +169 -0
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +1 -1
- package/src/private_kernel/hints/test_utils.ts +2 -9
- package/src/private_kernel/private_kernel_execution_prover.ts +236 -73
- package/src/private_kernel/private_kernel_oracle.ts +21 -11
- package/src/pxe.ts +208 -85
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +46 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +712 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/contract_store/contract_store.ts +6 -29
- package/src/storage/metadata.ts +1 -1
- package/src/storage/open_pxe_stores.ts +49 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -9
- package/src/storage/tagging_store/sender_tagging_store.ts +6 -6
- package/src/tagging/get_all_logs_by_tags.ts +78 -50
- package/src/tagging/index.ts +4 -3
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +240 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +41 -19
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +23 -8
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -5
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -47
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -85
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -33
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -104
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -130
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -44
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/server/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/server/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAOjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,4BAA4B,CAAC;AAE5F,KAAK,wBAAwB,GAAG,IAAI,CAClC,SAAS,EACT,WAAW,GAAG,kBAAkB,GAAG,eAAe,GAAG,MAAM,mBAAmB,CAC/E,CAAC;AAEF,wBAAsB,SAAS,CAC7B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,wBAAwB,EAChC,OAAO,GAAE,kBAAoC,gBAwD9C"}
|
|
@@ -4,6 +4,7 @@ import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
|
4
4
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
5
5
|
import { MemoryCircuitRecorder, SimulatorRecorderWrapper, WASMSimulator } from '@aztec/simulator/client';
|
|
6
6
|
import { FileCircuitRecorder } from '@aztec/simulator/testing';
|
|
7
|
+
import { getStandardMultiCallEntrypoint } from '@aztec/standard-contracts/multi-call-entrypoint';
|
|
7
8
|
import { PXE } from '../../pxe.js';
|
|
8
9
|
import { PXE_DATA_SCHEMA_VERSION } from '../../storage/index.js';
|
|
9
10
|
import { isPrivateKernelProver } from '../pxe_creation_options.js';
|
|
@@ -20,10 +21,10 @@ export async function createPXE(aztecNode, config, options = {
|
|
|
20
21
|
});
|
|
21
22
|
const simulator = new SimulatorRecorderWrapper(new WASMSimulator(simulatorLogger), recorder);
|
|
22
23
|
const loggers = options.loggers ?? {};
|
|
23
|
-
const { l1ChainId, l1ContractAddresses
|
|
24
|
+
const { l1ChainId, l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
|
|
24
25
|
const configWithContracts = {
|
|
25
26
|
...config,
|
|
26
|
-
|
|
27
|
+
...l1ContractAddresses,
|
|
27
28
|
l1ChainId,
|
|
28
29
|
rollupVersion,
|
|
29
30
|
l2BlockBatchSize: 50
|
|
@@ -47,6 +48,11 @@ export async function createPXE(aztecNode, config, options = {
|
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
51
|
+
const preloadedContractsProvider = options.preloadedContractsProvider ?? {
|
|
52
|
+
getPreloadedContracts: async ()=>[
|
|
53
|
+
await getStandardMultiCallEntrypoint()
|
|
54
|
+
]
|
|
55
|
+
};
|
|
50
56
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', {
|
|
51
57
|
actor
|
|
52
58
|
});
|
|
@@ -56,8 +62,10 @@ export async function createPXE(aztecNode, config, options = {
|
|
|
56
62
|
proofCreator: prover,
|
|
57
63
|
simulator,
|
|
58
64
|
protocolContractsProvider,
|
|
65
|
+
preloadedContractsProvider,
|
|
59
66
|
config: configWithContracts,
|
|
60
|
-
loggerOrSuffix: pxeLogger
|
|
67
|
+
loggerOrSuffix: pxeLogger,
|
|
68
|
+
hooks: options.hooks
|
|
61
69
|
});
|
|
62
70
|
return pxe;
|
|
63
71
|
}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
3
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
2
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { BlockHeader,
|
|
3
|
+
import type { BlockHeader, IndexedTxEffect } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { EventValidationRequest } from '../contract_function_simulator/noir-structs/event_validation_request.js';
|
|
6
5
|
import { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
7
6
|
export declare class EventService {
|
|
7
|
+
#private;
|
|
8
8
|
private readonly anchorBlockHeader;
|
|
9
9
|
private readonly aztecNode;
|
|
10
10
|
private readonly privateEventStore;
|
|
11
11
|
private readonly jobId;
|
|
12
12
|
private readonly log;
|
|
13
13
|
constructor(anchorBlockHeader: BlockHeader, aztecNode: AztecNode, privateEventStore: PrivateEventStore, jobId: string, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Validates and stores a batch of private events against pre-fetched tx effects.
|
|
16
|
+
*
|
|
17
|
+
* @param requests - The events to validate and store.
|
|
18
|
+
* @param scope - The scope under which the events are being stored.
|
|
19
|
+
* @param txEffects - Pre-fetched tx effects keyed by `TxHash.toString()`. Must contain entries for every request's
|
|
20
|
+
* txHash; missing entries are treated as a node bug and cause an error.
|
|
21
|
+
*/
|
|
22
|
+
validateAndStoreEvents(requests: EventValidationRequest[], scope: AztecAddress, txEffects: Map<string, IndexedTxEffect>): Promise<void>;
|
|
15
23
|
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXZlbnRfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2V2ZW50cy9ldmVudF9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBRWhFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxlQUFlLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUVyRSxPQUFPLEtBQUssRUFBRSxzQkFBc0IsRUFBRSxNQUFNLHlFQUF5RSxDQUFDO0FBQ3RILE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHVEQUF1RCxDQUFDO0FBRTFGLHFCQUFhLFlBQVk7O0lBRXJCLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCO0lBQ2xDLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLGlCQUFpQjtJQUNsQyxPQUFPLENBQUMsUUFBUSxDQUFDLEtBQUs7SUFDdEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHO0lBTHRCLFlBQ21CLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsaUJBQWlCLEVBQUUsaUJBQWlCLEVBQ3BDLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyx5Q0FBb0MsRUFDdEQ7SUFFSjs7Ozs7OztPQU9HO0lBQ1Usc0JBQXNCLENBQ2pDLFFBQVEsRUFBRSxzQkFBc0IsRUFBRSxFQUNsQyxLQUFLLEVBQUUsWUFBWSxFQUNuQixTQUFTLEVBQUUsR0FBRyxDQUFDLE1BQU0sRUFBRSxlQUFlLENBQUMsR0FDdEMsT0FBTyxDQUFDLElBQUksQ0FBQyxDQVFmO0NBZ0ZGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_service.d.ts","sourceRoot":"","sources":["../../src/events/event_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event_service.d.ts","sourceRoot":"","sources":["../../src/events/event_service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yEAAyE,CAAC;AACtH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,qBAAa,YAAY;;IAErB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IALtB,YACmB,iBAAiB,EAAE,WAAW,EAC9B,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,GAAG,yCAAoC,EACtD;IAEJ;;;;;;;OAOG;IACU,sBAAsB,CACjC,QAAQ,EAAE,sBAAsB,EAAE,EAClC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CAQf;CAgFF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
2
|
+
import { computePrivateEventCommitment, siloNullifier } from '@aztec/stdlib/hash';
|
|
3
3
|
export class EventService {
|
|
4
4
|
anchorBlockHeader;
|
|
5
5
|
aztecNode;
|
|
@@ -13,20 +13,41 @@ export class EventService {
|
|
|
13
13
|
this.jobId = jobId;
|
|
14
14
|
this.log = log;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Validates and stores a batch of private events against pre-fetched tx effects.
|
|
18
|
+
*
|
|
19
|
+
* @param requests - The events to validate and store.
|
|
20
|
+
* @param scope - The scope under which the events are being stored.
|
|
21
|
+
* @param txEffects - Pre-fetched tx effects keyed by `TxHash.toString()`. Must contain entries for every request's
|
|
22
|
+
* txHash; missing entries are treated as a node bug and cause an error.
|
|
23
|
+
*/ async validateAndStoreEvents(requests, scope, txEffects) {
|
|
24
|
+
if (requests.length === 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
28
|
+
await Promise.all(requests.map((req)=>this.#validateAndStoreEvent(req, scope, txEffects, anchorBlockNumber)));
|
|
29
|
+
}
|
|
30
|
+
async #validateAndStoreEvent(request, scope, txEffects, anchorBlockNumber) {
|
|
31
|
+
const { contractAddress, eventTypeId: selector, randomness, serializedEvent: content, eventCommitment, txHash } = request;
|
|
32
|
+
// Defense-in-depth: the built-in private-event path derives this commitment from content before enqueueing, but
|
|
33
|
+
// unconstrained PXE-side code (e.g. a custom message handler) can reach this oracle with arbitrary
|
|
34
|
+
// (content, commitment) pairs. Without this check it could bind arbitrary content to a legitimate tx nullifier,
|
|
35
|
+
// causing PXE to surface fabricated event data.
|
|
36
|
+
const recomputedCommitment = await computePrivateEventCommitment(randomness, selector.toField(), content);
|
|
37
|
+
if (!recomputedCommitment.equals(eventCommitment)) {
|
|
38
|
+
this.log.warn(`Skipping event whose content does not hash to the provided commitment. contract=${contractAddress}, selector=${selector}, eventCommitment=${eventCommitment}, txHash=${txHash}, recomputedCommitment=${recomputedCommitment}`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
17
41
|
// While using 'latest' block number would be fine for private events since they cannot be accessed from Aztec.nr
|
|
18
42
|
// (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
|
|
19
43
|
// maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
|
|
20
44
|
// since `fetchTaggedLogs` only processes logs up to the synced block.
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
this.aztecNode.getTxEffect(txHash)
|
|
24
|
-
]);
|
|
25
|
-
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
45
|
+
const siloedEventCommitment = await siloNullifier(contractAddress, eventCommitment);
|
|
46
|
+
const txEffect = txEffects.get(txHash.toString());
|
|
26
47
|
if (!txEffect) {
|
|
27
48
|
// We error out instead of just logging a warning and skipping the event because this would indicate a bug. This
|
|
28
|
-
// is because the node has already served info about this tx either when obtaining the log (
|
|
29
|
-
// tx info) or when getting metadata for the offchain message (before the message got passed to `process_log`).
|
|
49
|
+
// is because the node has already served info about this tx either when obtaining the log (LogResult carries
|
|
50
|
+
// the tx info) or when getting metadata for the offchain message (before the message got passed to `process_log`).
|
|
30
51
|
throw new Error(`Could not find tx effect for tx hash ${txHash} when processing an event.`);
|
|
31
52
|
}
|
|
32
53
|
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
/** Information about a cross-contract utility call that requires authorization. */
|
|
5
|
+
export type UtilityCallAuthorizationRequest = {
|
|
6
|
+
/** The contract requesting the cross-contract call. */
|
|
7
|
+
caller: AztecAddress;
|
|
8
|
+
/** The contract class ID of the calling contract. */
|
|
9
|
+
callerClassId: Fr;
|
|
10
|
+
/** The target contract being called. */
|
|
11
|
+
target: AztecAddress;
|
|
12
|
+
/** The contract class ID of the target contract. */
|
|
13
|
+
targetClassId: Fr;
|
|
14
|
+
/** The function selector being invoked on the target. */
|
|
15
|
+
functionSelector: FunctionSelector;
|
|
16
|
+
/** The name of the function being called, from the contract artifact. */
|
|
17
|
+
functionName: string;
|
|
18
|
+
/** The serialized arguments passed to the function. */
|
|
19
|
+
args: Fr[];
|
|
20
|
+
/** The execution context from which the call originates. */
|
|
21
|
+
callerContext: 'private' | 'private view' | 'utility';
|
|
22
|
+
};
|
|
23
|
+
/** Authorization was granted. */
|
|
24
|
+
type Authorized = {
|
|
25
|
+
authorized: true;
|
|
26
|
+
};
|
|
27
|
+
/** Authorization was denied. */
|
|
28
|
+
type Denied = {
|
|
29
|
+
authorized: false;
|
|
30
|
+
/** Reason for denial, included in the error message. */
|
|
31
|
+
reason?: string;
|
|
32
|
+
};
|
|
33
|
+
/** Result of an authorization hook evaluation. */
|
|
34
|
+
export type UtilityCallAuthorizationResponse = Authorized | Denied;
|
|
35
|
+
/**
|
|
36
|
+
* Hook called when a utility function attempts a cross-contract call.
|
|
37
|
+
* Returns a response indicating whether the call is authorized and an optional denial reason.
|
|
38
|
+
*/
|
|
39
|
+
export type AuthorizeUtilityCall = (request: UtilityCallAuthorizationRequest) => Promise<UtilityCallAuthorizationResponse>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXplX3V0aWxpdHlfY2FsbC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2hvb2tzL2F1dGhvcml6ZV91dGlsaXR5X2NhbGwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRSxtRkFBbUY7QUFDbkYsTUFBTSxNQUFNLCtCQUErQixHQUFHO0lBQzVDLHVEQUF1RDtJQUN2RCxNQUFNLEVBQUUsWUFBWSxDQUFDO0lBQ3JCLHFEQUFxRDtJQUNyRCxhQUFhLEVBQUUsRUFBRSxDQUFDO0lBQ2xCLHdDQUF3QztJQUN4QyxNQUFNLEVBQUUsWUFBWSxDQUFDO0lBQ3JCLG9EQUFvRDtJQUNwRCxhQUFhLEVBQUUsRUFBRSxDQUFDO0lBQ2xCLHlEQUF5RDtJQUN6RCxnQkFBZ0IsRUFBRSxnQkFBZ0IsQ0FBQztJQUNuQyx5RUFBeUU7SUFDekUsWUFBWSxFQUFFLE1BQU0sQ0FBQztJQUNyQix1REFBdUQ7SUFDdkQsSUFBSSxFQUFFLEVBQUUsRUFBRSxDQUFDO0lBQ1gsNERBQTREO0lBQzVELGFBQWEsRUFBRSxTQUFTLEdBQUcsY0FBYyxHQUFHLFNBQVMsQ0FBQztDQUN2RCxDQUFDO0FBRUYsaUNBQWlDO0FBQ2pDLEtBQUssVUFBVSxHQUFHO0lBQUUsVUFBVSxFQUFFLElBQUksQ0FBQTtDQUFFLENBQUM7QUFFdkMsZ0NBQWdDO0FBQ2hDLEtBQUssTUFBTSxHQUFHO0lBQ1osVUFBVSxFQUFFLEtBQUssQ0FBQztJQUNsQix3REFBd0Q7SUFDeEQsTUFBTSxDQUFDLEVBQUUsTUFBTSxDQUFDO0NBQ2pCLENBQUM7QUFFRixrREFBa0Q7QUFDbEQsTUFBTSxNQUFNLGdDQUFnQyxHQUFHLFVBQVUsR0FBRyxNQUFNLENBQUM7QUFFbkU7OztHQUdHO0FBQ0gsTUFBTSxNQUFNLG9CQUFvQixHQUFHLENBQ2pDLE9BQU8sRUFBRSwrQkFBK0IsS0FDckMsT0FBTyxDQUFDLGdDQUFnQyxDQUFDLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize_utility_call.d.ts","sourceRoot":"","sources":["../../src/hooks/authorize_utility_call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,mFAAmF;AACnF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,uDAAuD;IACvD,MAAM,EAAE,YAAY,CAAC;IACrB,qDAAqD;IACrD,aAAa,EAAE,EAAE,CAAC;IAClB,wCAAwC;IACxC,MAAM,EAAE,YAAY,CAAC;IACrB,oDAAoD;IACpD,aAAa,EAAE,EAAE,CAAC;IAClB,yDAAyD;IACzD,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,IAAI,EAAE,EAAE,EAAE,CAAC;IACX,4DAA4D;IAC5D,aAAa,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS,CAAC;CACvD,CAAC;AAEF,iCAAiC;AACjC,KAAK,UAAU,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,CAAC;AAEvC,gCAAgC;AAChC,KAAK,MAAM,GAAG;IACZ,UAAU,EAAE,KAAK,CAAC;IAClB,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,kDAAkD;AAClD,MAAM,MAAM,gCAAgC,GAAG,UAAU,GAAG,MAAM,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,+BAA+B,KACrC,OAAO,CAAC,gCAAgC,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AuthorizeUtilityCall } from './authorize_utility_call.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hooks that PXE invokes during client-side simulation to gate operations that the protocol
|
|
4
|
+
* does not restrict on its own. They give the wallet a chance to apply custom policies (e.g.
|
|
5
|
+
* prompting the user, consulting a dynamic allowlist, or inspecting call arguments) before the
|
|
6
|
+
* execution proceeds.
|
|
7
|
+
*
|
|
8
|
+
* For example, {@link authorizeUtilityCall} is called whenever a utility function makes a
|
|
9
|
+
* cross-contract call. A call made by a malicious contract could leak private information, so the
|
|
10
|
+
* hook lets the wallet decide, per-call, whether to allow it. A static allowlist would not work
|
|
11
|
+
* here because neither the app nor the wallet can predict ahead of time which contracts will be
|
|
12
|
+
* invoked during execution.
|
|
13
|
+
*
|
|
14
|
+
* Note: hooks are unrelated to authentication witnesses (authwits). Authwits are an on-chain
|
|
15
|
+
* mechanism where a contract verifies that a caller was authorized by a specific account; hooks
|
|
16
|
+
* are a client-side PXE concern that gates execution before it proceeds.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const pxe = await PXE.create({
|
|
21
|
+
* // ...
|
|
22
|
+
* hooks: {
|
|
23
|
+
* authorizeUtilityCall: async (req) => {
|
|
24
|
+
* // Allow calls to a known helper contract, deny everything else.
|
|
25
|
+
* return req.target.equals(trustedHelper)
|
|
26
|
+
* ? { authorized: true }
|
|
27
|
+
* : { authorized: false, reason: 'Unknown target' };
|
|
28
|
+
* },
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface ExecutionHooks {
|
|
34
|
+
/** Called when a contract attempts a cross-contract utility call. */
|
|
35
|
+
authorizeUtilityCall: AuthorizeUtilityCall;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Builds an {@link ExecutionHooks} from individually-constructed hook callbacks. Returns `undefined`
|
|
39
|
+
* when every field is absent, so callers can unconditionally pass the result as `hooks`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function composeHooks(partial: Partial<ExecutionHooks>): ExecutionHooks | undefined;
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0aW9uX2hvb2tzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9va3MvZXhlY3V0aW9uX2hvb2tzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFeEU7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQThCRztBQUNILE1BQU0sV0FBVyxjQUFjO0lBQzdCLHFFQUFxRTtJQUNyRSxvQkFBb0IsRUFBRSxvQkFBb0IsQ0FBQztDQUM1QztBQUVEOzs7R0FHRztBQUNILHdCQUFnQixZQUFZLENBQUMsT0FBTyxFQUFFLE9BQU8sQ0FBQyxjQUFjLENBQUMsR0FBRyxjQUFjLEdBQUcsU0FBUyxDQUt6RiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution_hooks.d.ts","sourceRoot":"","sources":["../../src/hooks/execution_hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,GAAG,SAAS,CAKzF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds an {@link ExecutionHooks} from individually-constructed hook callbacks. Returns `undefined`
|
|
3
|
+
* when every field is absent, so callers can unconditionally pass the result as `hooks`.
|
|
4
|
+
*/ export function composeHooks(partial) {
|
|
5
|
+
if (Object.values(partial).every((v)=>v === undefined)) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return partial;
|
|
9
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { AuthorizeUtilityCall, UtilityCallAuthorizationRequest, UtilityCallAuthorizationResponse, } from './authorize_utility_call.js';
|
|
2
|
+
export type { ExecutionHooks } from './execution_hooks.js';
|
|
3
|
+
export { composeHooks } from './execution_hooks.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ob29rcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZLEVBQ1Ysb0JBQW9CLEVBQ3BCLCtCQUErQixFQUMvQixnQ0FBZ0MsR0FDakMsTUFBTSw2QkFBNkIsQ0FBQztBQUNyQyxZQUFZLEVBQUUsY0FBYyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDM0QsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHNCQUFzQixDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { composeHooks } from './execution_hooks.js';
|
|
@@ -3,9 +3,9 @@ import type { KeyStore } from '@aztec/key-store';
|
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { L2TipsProvider } from '@aztec/stdlib/block';
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import { PendingTaggedLog } from '@aztec/stdlib/logs';
|
|
6
|
+
import { AppTaggingSecret, PendingTaggedLog } from '@aztec/stdlib/logs';
|
|
7
7
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
|
-
import type
|
|
8
|
+
import { type LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
9
9
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
10
10
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
11
11
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
@@ -22,7 +22,8 @@ export declare class LogService {
|
|
|
22
22
|
private readonly jobId;
|
|
23
23
|
private log;
|
|
24
24
|
constructor(aztecNode: AztecNode, anchorBlockHeader: BlockHeader, l2TipsStore: L2TipsProvider, keyStore: KeyStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, addressStore: AddressStore, jobId: string, bindings?: LoggerBindings);
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/** Fetches all logs matching each request's tag, returning an array of log arrays (one per request). */
|
|
26
|
+
fetchLogsByTag(contractAddress: AztecAddress, logRetrievalRequests: LogRetrievalRequest[]): Promise<LogRetrievalResponse[][]>;
|
|
27
|
+
fetchTaggedLogs(contractAddress: AztecAddress, recipient: AztecAddress, providedSecrets: AppTaggingSecret[]): Promise<PendingTaggedLog[]>;
|
|
27
28
|
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nX3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2dzL2xvZ19zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBZSxLQUFLLGNBQWMsRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUN2RixPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNqRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQWEsY0FBYyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUFFLGdCQUFnQixFQUFrQixnQkFBZ0IsRUFBYSxNQUFNLG9CQUFvQixDQUFDO0FBQ25HLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXBELE9BQU8sRUFDTCxLQUFLLG1CQUFtQixFQUV6QixNQUFNLHNFQUFzRSxDQUFDO0FBQzlFLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVFQUF1RSxDQUFDO0FBQzdHLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSwyQ0FBMkMsQ0FBQztBQUN6RSxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBQ2pHLE9BQU8sS0FBSyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sdURBQXVELENBQUM7QUFXcEcscUJBQWEsVUFBVTs7SUFJbkIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsaUJBQWlCO0lBQ2xDLE9BQU8sQ0FBQyxRQUFRLENBQUMsV0FBVztJQUM1QixPQUFPLENBQUMsUUFBUSxDQUFDLFFBQVE7SUFDekIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxxQkFBcUI7SUFDdEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxzQkFBc0I7SUFDdkMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxZQUFZO0lBQzdCLE9BQU8sQ0FBQyxRQUFRLENBQUMsS0FBSztJQVZ4QixPQUFPLENBQUMsR0FBRyxDQUFTO0lBRXBCLFlBQ21CLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsV0FBVyxFQUFFLGNBQWMsRUFDM0IsUUFBUSxFQUFFLFFBQVEsRUFDbEIscUJBQXFCLEVBQUUscUJBQXFCLEVBQzVDLHNCQUFzQixFQUFFLHNCQUFzQixFQUM5QyxZQUFZLEVBQUUsWUFBWSxFQUMxQixLQUFLLEVBQUUsTUFBTSxFQUM5QixRQUFRLENBQUMsRUFBRSxjQUFjLEVBRzFCO0lBRUQsd0dBQXdHO0lBQzNGLGNBQWMsQ0FDekIsZUFBZSxFQUFFLFlBQVksRUFDN0Isb0JBQW9CLEVBQUUsbUJBQW1CLEVBQUUsR0FDMUMsT0FBTyxDQUFDLG9CQUFvQixFQUFFLEVBQUUsQ0FBQyxDQXNCbkM7SUFrR1ksZUFBZSxDQUMxQixlQUFlLEVBQUUsWUFBWSxFQUM3QixTQUFTLEVBQUUsWUFBWSxFQUN2QixlQUFlLEVBQUUsZ0JBQWdCLEVBQUUsR0FDbEMsT0FBTyxDQUFDLGdCQUFnQixFQUFFLENBQUMsQ0F5QjdCO0NBdUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAa,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAkB,gBAAgB,EAAa,MAAM,oBAAoB,CAAC;AACnG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAWpG,qBAAa,UAAU;;IAInB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAVxB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACmB,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,WAAW,EAC9B,WAAW,EAAE,cAAc,EAC3B,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EAC9B,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAED,wGAAwG;IAC3F,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,oBAAoB,EAAE,mBAAmB,EAAE,GAC1C,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAsBnC;IAkGY,eAAe,CAC1B,eAAe,EAAE,YAAY,EAC7B,SAAS,EAAE,YAAY,EACvB,eAAe,EAAE,gBAAgB,EAAE,GAClC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAyB7B;CAuCF"}
|
package/dest/logs/log_service.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import {
|
|
3
|
+
import { AppTaggingSecret, PendingTaggedLog, SiloedTag } from '@aztec/stdlib/logs';
|
|
4
|
+
import { LogSource } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
4
5
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
5
|
-
import { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract,
|
|
6
|
+
import { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract, syncTaggedPrivateLogs } from '../tagging/index.js';
|
|
7
|
+
const rangeKey = (fromBlock, toBlock)=>`${fromBlock ?? ''}-${toBlock ?? ''}`;
|
|
6
8
|
export class LogService {
|
|
7
9
|
aztecNode;
|
|
8
10
|
anchorBlockHeader;
|
|
@@ -24,63 +26,125 @@ export class LogService {
|
|
|
24
26
|
this.jobId = jobId;
|
|
25
27
|
this.log = createLogger('pxe:log_service', bindings);
|
|
26
28
|
}
|
|
27
|
-
async fetchLogsByTag(contractAddress, logRetrievalRequests) {
|
|
29
|
+
/** Fetches all logs matching each request's tag, returning an array of log arrays (one per request). */ async fetchLogsByTag(contractAddress, logRetrievalRequests) {
|
|
28
30
|
for (const request of logRetrievalRequests){
|
|
29
31
|
if (!contractAddress.equals(request.contractAddress)) {
|
|
30
32
|
throw new Error(`Got a log retrieval request from ${request.contractAddress}, expected ${contractAddress}`);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (logRetrievalRequests.length === 0) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
39
|
+
const [publicLogsPerRequest, privateLogsPerRequest] = await Promise.all([
|
|
40
|
+
this.#fetchPublicLogs(contractAddress, logRetrievalRequests, anchorBlockHash),
|
|
41
|
+
this.#fetchPrivateLogs(logRetrievalRequests, anchorBlockHash)
|
|
42
|
+
]);
|
|
43
|
+
return logRetrievalRequests.map((_request, i)=>[
|
|
44
|
+
...publicLogsPerRequest[i].map(LogService.#toLogRetrievalResponse),
|
|
45
|
+
...privateLogsPerRequest[i].map(LogService.#toLogRetrievalResponse)
|
|
37
46
|
]);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
}
|
|
48
|
+
async #fetchPublicLogs(contractAddress, requests, anchorBlockHash) {
|
|
49
|
+
const indices = requests.flatMap((r, i)=>r.source !== LogSource.PRIVATE ? [
|
|
50
|
+
i
|
|
51
|
+
] : []);
|
|
52
|
+
if (indices.length === 0) {
|
|
53
|
+
return requests.map(()=>[]);
|
|
54
|
+
}
|
|
55
|
+
const resultsPerRequest = requests.map(()=>[]);
|
|
56
|
+
const groups = LogService.#groupByRange(indices.map((i)=>({
|
|
57
|
+
index: i,
|
|
58
|
+
request: requests[i]
|
|
59
|
+
})));
|
|
60
|
+
await Promise.all(Array.from(groups.values()).map(async (group)=>{
|
|
61
|
+
const tags = group.entries.map((e)=>e.request.tag);
|
|
62
|
+
const results = await getAllPublicLogsByTagsFromContract(this.aztecNode, contractAddress, tags, anchorBlockHash, {
|
|
63
|
+
fromBlock: group.fromBlock,
|
|
64
|
+
toBlock: group.toBlock,
|
|
65
|
+
includeEffects: true
|
|
66
|
+
});
|
|
67
|
+
group.entries.forEach((entry, i)=>{
|
|
68
|
+
resultsPerRequest[entry.index] = results[i];
|
|
69
|
+
});
|
|
42
70
|
}));
|
|
71
|
+
return resultsPerRequest;
|
|
43
72
|
}
|
|
44
|
-
async #
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (logsForTag.length === 0) {
|
|
51
|
-
return null;
|
|
52
|
-
} else if (logsForTag.length > 1) {
|
|
53
|
-
this.log.warn(`Expected at most 1 public log for tag ${tag} and contract ${contractAddress.toString()}, got ${logsForTag.length}. This may indicate a contract bug. Returning the first log.`);
|
|
73
|
+
async #fetchPrivateLogs(requests, anchorBlockHash) {
|
|
74
|
+
const indices = requests.flatMap((r, i)=>r.source !== LogSource.PUBLIC ? [
|
|
75
|
+
i
|
|
76
|
+
] : []);
|
|
77
|
+
if (indices.length === 0) {
|
|
78
|
+
return requests.map(()=>[]);
|
|
54
79
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
80
|
+
const resultsPerRequest = requests.map(()=>[]);
|
|
81
|
+
const groups = LogService.#groupByRange(indices.map((i)=>({
|
|
82
|
+
index: i,
|
|
83
|
+
request: requests[i]
|
|
84
|
+
})));
|
|
85
|
+
await Promise.all(Array.from(groups.values()).map(async (group)=>{
|
|
86
|
+
const siloedTags = await Promise.all(group.entries.map((e)=>SiloedTag.computeFromTagAndApp(e.request.tag, e.request.contractAddress)));
|
|
87
|
+
const results = await getAllPrivateLogsByTags(this.aztecNode, siloedTags, anchorBlockHash, {
|
|
88
|
+
fromBlock: group.fromBlock,
|
|
89
|
+
toBlock: group.toBlock,
|
|
90
|
+
includeEffects: true
|
|
91
|
+
});
|
|
92
|
+
group.entries.forEach((entry, i)=>{
|
|
93
|
+
resultsPerRequest[entry.index] = results[i];
|
|
94
|
+
});
|
|
95
|
+
}));
|
|
96
|
+
return resultsPerRequest;
|
|
57
97
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Groups requests by their (fromBlock, toBlock) range so each distinct range becomes a single node call with
|
|
100
|
+
* the range pushed down into the query (no in-memory filter).
|
|
101
|
+
*/ static #groupByRange(entries) {
|
|
102
|
+
const groups = new Map();
|
|
103
|
+
for (const entry of entries){
|
|
104
|
+
const key = rangeKey(entry.request.fromBlock, entry.request.toBlock);
|
|
105
|
+
const existing = groups.get(key);
|
|
106
|
+
if (existing) {
|
|
107
|
+
existing.entries.push(entry);
|
|
108
|
+
} else {
|
|
109
|
+
groups.set(key, {
|
|
110
|
+
fromBlock: entry.request.fromBlock,
|
|
111
|
+
toBlock: entry.request.toBlock,
|
|
112
|
+
entries: [
|
|
113
|
+
entry
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return groups;
|
|
119
|
+
}
|
|
120
|
+
static #toLogRetrievalResponse(log) {
|
|
121
|
+
// includeEffects: true was used, so noteHashes and nullifiers are populated. Every tx has at least one nullifier
|
|
122
|
+
// (the first nullifier derived from the tx hash); empty here would indicate a buggy node.
|
|
123
|
+
const noteHashes = log.noteHashes;
|
|
124
|
+
const nullifiers = log.nullifiers;
|
|
125
|
+
if (nullifiers.length === 0) {
|
|
126
|
+
throw new Error(`Log for tx ${log.txHash} returned no nullifiers from the node`);
|
|
68
127
|
}
|
|
69
|
-
|
|
70
|
-
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
128
|
+
return new LogRetrievalResponse(log.logData.slice(1), log.txHash, noteHashes, nullifiers[0]);
|
|
71
129
|
}
|
|
72
|
-
async fetchTaggedLogs(contractAddress, recipient) {
|
|
130
|
+
async fetchTaggedLogs(contractAddress, recipient, providedSecrets) {
|
|
73
131
|
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
74
|
-
// We only load logs from block up to and including the anchor block number
|
|
75
|
-
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
76
|
-
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
77
132
|
const l2Tips = await this.l2TipsStore.getL2Tips();
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
const secrets =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
133
|
+
// The secrets PXE derives or stores internally, plus any the app supplies explicitly for secrets PXE cannot
|
|
134
|
+
// enumerate itself (e.g. handshake-derived ones).
|
|
135
|
+
const secrets = [
|
|
136
|
+
...await this.#getSecretsForSenders(contractAddress, recipient),
|
|
137
|
+
...providedSecrets
|
|
138
|
+
];
|
|
139
|
+
const logs = await syncTaggedPrivateLogs(secrets, this.aztecNode, this.recipientTaggingStore, this.anchorBlockHeader, l2Tips.finalized.block.number, this.jobId);
|
|
140
|
+
return logs.map((log)=>{
|
|
141
|
+
const noteHashes = log.noteHashes;
|
|
142
|
+
const nullifiers = log.nullifiers;
|
|
143
|
+
if (nullifiers.length === 0) {
|
|
144
|
+
throw new Error(`Log for tx ${log.txHash} returned no nullifiers from the node`);
|
|
145
|
+
}
|
|
146
|
+
return new PendingTaggedLog(log.logData, log.txHash, noteHashes, nullifiers[0]);
|
|
147
|
+
});
|
|
84
148
|
}
|
|
85
149
|
async #getSecretsForSenders(contractAddress, recipient) {
|
|
86
150
|
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
@@ -88,8 +152,8 @@ export class LogService {
|
|
|
88
152
|
return [];
|
|
89
153
|
}
|
|
90
154
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
91
|
-
// We implicitly add all PXE accounts as senders, this helps us
|
|
92
|
-
// (recipient = us, sender = us)
|
|
155
|
+
// We implicitly add all PXE accounts as senders, this helps us find tagged logs with messages that are sent to a
|
|
156
|
+
// local account (recipient = us, sender = us)
|
|
93
157
|
const allSenders = [
|
|
94
158
|
...await this.senderAddressBookStore.getSenders(),
|
|
95
159
|
...await this.keyStore.getAccounts()
|
|
@@ -97,7 +161,7 @@ export class LogService {
|
|
|
97
161
|
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
98
162
|
const deduplicatedSenders = Array.from(new Set(allSenders.map((sender)=>sender.toString()))).map((sender)=>AztecAddress.fromString(sender));
|
|
99
163
|
return Promise.all(deduplicatedSenders.map(async (sender)=>{
|
|
100
|
-
const secret = await
|
|
164
|
+
const secret = await AppTaggingSecret.computeUnconstrained(recipientCompleteAddress, recipientIvsk, sender, contractAddress, recipient);
|
|
101
165
|
if (!secret) {
|
|
102
166
|
// Note that all senders originate from either the SenderAddressBookStore or the KeyStore.
|
|
103
167
|
throw new Error(`Failed to compute a tagging secret for sender ${sender} - this implies this is an invalid address, which should not happen as they have been previously registered in PXE.`);
|
|
@@ -14,4 +14,4 @@ export declare class MessageContextService {
|
|
|
14
14
|
*/
|
|
15
15
|
getMessageContextsByTxHash(txHashes: Fr[], anchorBlockNumber: number): Promise<(MessageContext | null)[]>;
|
|
16
16
|
}
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzc2FnZV9jb250ZXh0X3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tZXNzYWdlcy9tZXNzYWdlX2NvbnRleHRfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBR3BELCtFQUErRTtBQUMvRSxxQkFBYSxxQkFBcUI7SUFDcEIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQXRDLFlBQTZCLFNBQVMsRUFBRSxTQUFTLEVBQUk7SUFFckQ7Ozs7OztPQU1HO0lBQ0csMEJBQTBCLENBQUMsUUFBUSxFQUFFLEVBQUUsRUFBRSxFQUFFLGlCQUFpQixFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsQ0FBQyxjQUFjLEdBQUcsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQTJDOUc7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_context_service.d.ts","sourceRoot":"","sources":["../../src/messages/message_context_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message_context_service.d.ts","sourceRoot":"","sources":["../../src/messages/message_context_service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,+EAA+E;AAC/E,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAtC,YAA6B,SAAS,EAAE,SAAS,EAAI;IAErD;;;;;;OAMG;IACG,0BAA0B,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,CA2C9G;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { uniqueBy } from '@aztec/foundation/collection';
|
|
1
2
|
import { MessageContext } from '@aztec/stdlib/logs';
|
|
2
3
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
3
4
|
/** Resolves transaction hashes into the context needed to process messages. */ export class MessageContextService {
|
|
@@ -11,16 +12,34 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
11
12
|
* For each tx hash, looks up the corresponding tx effect and extracts the note hashes and first nullifier needed to
|
|
12
13
|
* process messages that originated from that transaction. Returns `null` for tx hashes that are zero, not yet
|
|
13
14
|
* available, or in blocks beyond the anchor block.
|
|
14
|
-
*/ getMessageContextsByTxHash(txHashes, anchorBlockNumber) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
*/ async getMessageContextsByTxHash(txHashes, anchorBlockNumber) {
|
|
16
|
+
const nonZeroTxHashes = txHashes.filter((h)=>!h.isZero()).map((h)=>TxHash.fromField(h));
|
|
17
|
+
const uniqueTxHashes = uniqueBy(nonZeroTxHashes, (h)=>h.toString());
|
|
18
|
+
const fetched = await Promise.all(uniqueTxHashes.map((h)=>this.aztecNode.getTxReceipt(h, {
|
|
19
|
+
includeTxEffect: true
|
|
20
|
+
})));
|
|
21
|
+
const txEffects = new Map(uniqueTxHashes.map((h, i)=>{
|
|
22
|
+
const receipt = fetched[i];
|
|
23
|
+
if (!receipt.isMined() || !receipt.txEffect) {
|
|
24
|
+
return [
|
|
25
|
+
h.toString(),
|
|
26
|
+
undefined
|
|
27
|
+
];
|
|
21
28
|
}
|
|
29
|
+
return [
|
|
30
|
+
h.toString(),
|
|
31
|
+
{
|
|
32
|
+
data: receipt.txEffect,
|
|
33
|
+
l2BlockNumber: receipt.blockNumber,
|
|
34
|
+
l2BlockHash: receipt.blockHash,
|
|
35
|
+
txIndexInBlock: receipt.txIndexInBlock,
|
|
36
|
+
slotNumber: receipt.slotNumber
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}).filter((entry)=>entry[1] !== undefined));
|
|
40
|
+
return txHashes.map((txHashField)=>{
|
|
22
41
|
const txHash = TxHash.fromField(txHashField);
|
|
23
|
-
const txEffect =
|
|
42
|
+
const txEffect = txEffects.get(txHash.toString());
|
|
24
43
|
if (!txEffect || txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
25
44
|
return null;
|
|
26
45
|
}
|
|
@@ -31,6 +50,6 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
31
50
|
throw new Error(`Tx effect for ${txHash} has no nullifiers`);
|
|
32
51
|
}
|
|
33
52
|
return new MessageContext(data.txHash, data.noteHashes, data.nullifiers[0]);
|
|
34
|
-
})
|
|
53
|
+
});
|
|
35
54
|
}
|
|
36
55
|
}
|