@aztec/pxe 0.0.1-commit.96bb3f7 → 0.0.1-commit.993d52e
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +11 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -21
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +57 -35
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +198 -84
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- 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 -3
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- 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 +2 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +17 -13
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +67 -44
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +97 -32
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +66 -33
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +130 -111
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- 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 +21 -7
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +28 -9
- package/dest/events/event_service.d.ts +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +31 -33
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +34 -38
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- 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 +28 -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} +15 -9
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +9 -9
- package/dest/private_kernel/private_kernel_oracle.d.ts +23 -24
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +94 -2
- package/dest/pxe.d.ts +75 -58
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +124 -132
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +130 -23
- package/dest/storage/contract_store/contract_store.d.ts +42 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +157 -84
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +226 -111
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +20 -10
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +253 -101
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +11 -11
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -11
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- 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 +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +7 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +23 -19
- package/package.json +27 -18
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +91 -33
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +356 -148
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +22 -12
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +79 -47
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -67
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +137 -111
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +197 -116
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +4 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +17 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +51 -40
- package/src/notes/note_service.ts +41 -45
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -3
- 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} +38 -26
- package/src/private_kernel/private_kernel_execution_prover.ts +13 -10
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +235 -209
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +186 -96
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +326 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +292 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +296 -111
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +2 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +22 -14
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +12 -14
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +26 -23
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_service.d.ts","sourceRoot":"","sources":["../../src/events/event_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"event_service.d.ts","sourceRoot":"","sources":["../../src/events/event_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,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;IAJxB,YACmB,iBAAiB,EAAE,WAAW,EAC9B,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EAC5B;IAES,qBAAqB,CAChC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,EAAE,EAAE,EACb,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CA4Cf;CACF"}
|
|
@@ -1,47 +1,44 @@
|
|
|
1
1
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
2
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
3
2
|
export class EventService {
|
|
4
|
-
|
|
3
|
+
anchorBlockHeader;
|
|
5
4
|
aztecNode;
|
|
6
5
|
privateEventStore;
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
jobId;
|
|
7
|
+
constructor(anchorBlockHeader, aztecNode, privateEventStore, jobId){
|
|
8
|
+
this.anchorBlockHeader = anchorBlockHeader;
|
|
9
9
|
this.aztecNode = aztecNode;
|
|
10
10
|
this.privateEventStore = privateEventStore;
|
|
11
|
+
this.jobId = jobId;
|
|
11
12
|
}
|
|
12
|
-
async
|
|
13
|
+
async validateAndStoreEvent(contractAddress, selector, randomness, content, eventCommitment, txHash, scope) {
|
|
13
14
|
// While using 'latest' block number would be fine for private events since they cannot be accessed from Aztec.nr
|
|
14
15
|
// (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
|
|
15
16
|
// maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
|
|
16
17
|
// since `fetchTaggedLogs` only processes logs up to the synced block.
|
|
17
|
-
const [
|
|
18
|
-
this.anchorBlockStore.getBlockHeader(),
|
|
18
|
+
const [siloedEventCommitment, txEffect] = await Promise.all([
|
|
19
19
|
siloNullifier(contractAddress, eventCommitment),
|
|
20
20
|
this.aztecNode.getTxEffect(txHash)
|
|
21
21
|
]);
|
|
22
|
-
const
|
|
22
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
23
23
|
if (!txEffect) {
|
|
24
24
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
25
25
|
}
|
|
26
|
-
if (txEffect.l2BlockNumber >
|
|
27
|
-
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${
|
|
26
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
27
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Find the index of the event commitment in the nullifiers array to determine event ordering within the tx
|
|
30
|
+
const eventIndexInTx = txEffect.data.nullifiers.findIndex((n)=>n.equals(siloedEventCommitment));
|
|
31
|
+
if (eventIndexInTx === -1) {
|
|
31
32
|
throw new Error(`Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present in tx ${txHash}`);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
siloedEventCommitment
|
|
35
|
-
]);
|
|
36
|
-
if (nullifierIndex === undefined) {
|
|
37
|
-
throw new Error(`Event commitment ${eventCommitment} (siloed as ${siloedEventCommitment}) is not present on the nullifier tree at block ${syncedBlockNumber} (from tx ${txHash})`);
|
|
38
|
-
}
|
|
39
|
-
return this.privateEventStore.storePrivateEventLog(selector, randomness, content, Number(nullifierIndex.data), {
|
|
34
|
+
return this.privateEventStore.storePrivateEventLog(selector, randomness, content, siloedEventCommitment, {
|
|
40
35
|
contractAddress,
|
|
41
36
|
scope,
|
|
42
37
|
txHash,
|
|
43
|
-
l2BlockNumber:
|
|
44
|
-
l2BlockHash:
|
|
45
|
-
|
|
38
|
+
l2BlockNumber: txEffect.l2BlockNumber,
|
|
39
|
+
l2BlockHash: txEffect.l2BlockHash,
|
|
40
|
+
txIndexInBlock: txEffect.txIndexInBlock,
|
|
41
|
+
eventIndexInTx
|
|
42
|
+
}, this.jobId);
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
-
import {
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { PrivateEventStoreFilter } from '../storage/private_event_store/private_event_store.js';
|
|
4
4
|
export declare class PrivateEventFilterValidator {
|
|
5
|
-
private
|
|
6
|
-
constructor(
|
|
7
|
-
validate(filter: PrivateEventFilter):
|
|
5
|
+
private lastBlock;
|
|
6
|
+
constructor(lastBlock: BlockNumber);
|
|
7
|
+
validate(filter: PrivateEventFilter): PrivateEventStoreFilter;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9ldmVudF9maWx0ZXJfdmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXZlbnRzL3ByaXZhdGVfZXZlbnRfZmlsdGVyX3ZhbGlkYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBRWpFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSx1QkFBdUIsRUFBRSxNQUFNLHVEQUF1RCxDQUFDO0FBRXJHLHFCQUFhLDJCQUEyQjtJQUMxQixPQUFPLENBQUMsU0FBUztJQUE3QixZQUFvQixTQUFTLEVBQUUsV0FBVyxFQUFJO0lBRTlDLFFBQVEsQ0FBQyxNQUFNLEVBQUUsa0JBQWtCLEdBQUcsdUJBQXVCLENBbUM1RDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_event_filter_validator.d.ts","sourceRoot":"","sources":["../../src/events/private_event_filter_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"private_event_filter_validator.d.ts","sourceRoot":"","sources":["../../src/events/private_event_filter_validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAErG,qBAAa,2BAA2B;IAC1B,OAAO,CAAC,SAAS;IAA7B,YAAoB,SAAS,EAAE,WAAW,EAAI;IAE9C,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,uBAAuB,CAmC5D;CACF"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
export class PrivateEventFilterValidator {
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
4
|
+
lastBlock;
|
|
5
|
+
constructor(lastBlock){
|
|
6
|
+
this.lastBlock = lastBlock;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
validate(filter) {
|
|
9
9
|
let { fromBlock, toBlock } = filter;
|
|
10
10
|
// Block range filters in Aztec Node are defined as closed-open intervals [fromBlock, toBlock), so
|
|
11
11
|
// we respect that convention here for consistency.
|
|
12
12
|
// We then default to [INITIAL_L2_BLOCK_NUM, latestKnownBlock + 1), ie: by default return events from
|
|
13
13
|
// the first block to the latest known block.
|
|
14
14
|
if (!fromBlock || !toBlock) {
|
|
15
|
-
const lastKnownBlock = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
16
15
|
fromBlock = fromBlock ?? BlockNumber(INITIAL_L2_BLOCK_NUM);
|
|
17
|
-
toBlock = toBlock ?? BlockNumber(
|
|
16
|
+
toBlock = toBlock ?? BlockNumber(this.lastBlock + 1);
|
|
18
17
|
}
|
|
19
18
|
if (filter.scopes.length === 0) {
|
|
20
19
|
throw new Error('At least one scope is required to get private events');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
3
|
/**
|
|
3
4
|
* Interface that stores must implement to support staged writes.
|
|
@@ -38,7 +39,7 @@ export declare class JobCoordinator {
|
|
|
38
39
|
private readonly log;
|
|
39
40
|
/** The underlying KV store */
|
|
40
41
|
kvStore: AztecAsyncKVStore;
|
|
41
|
-
constructor(kvStore: AztecAsyncKVStore);
|
|
42
|
+
constructor(kvStore: AztecAsyncKVStore, bindings?: LoggerBindings);
|
|
42
43
|
/**
|
|
43
44
|
* Registers a staged store.
|
|
44
45
|
* Must be called during initialization for all stores that need staging support.
|
|
@@ -71,4 +72,4 @@ export declare class JobCoordinator {
|
|
|
71
72
|
*/
|
|
72
73
|
hasJobInProgress(): boolean;
|
|
73
74
|
}
|
|
74
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
75
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiam9iX2Nvb3JkaW5hdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvam9iX2Nvb3JkaW5hdG9yL2pvYl9jb29yZGluYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQWUsS0FBSyxjQUFjLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDdkYsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUV6RDs7R0FFRztBQUNILE1BQU0sV0FBVyxXQUFXO0lBQzFCLCtGQUErRjtJQUMvRixRQUFRLENBQUMsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUUzQjs7Ozs7T0FLRztJQUNILE1BQU0sQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUVyQzs7Ozs7T0FLRztJQUNILGFBQWEsQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztDQUM3QztBQUVEOzs7Ozs7Ozs7Ozs7R0FZRztBQUNILHFCQUFhLGNBQWM7O0lBQ3pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsR0FBRyxDQUFTO0lBRTdCLDhCQUE4QjtJQUM5QixPQUFPLEVBQUUsaUJBQWlCLENBQUM7SUFLM0IsWUFBWSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsUUFBUSxDQUFDLEVBQUUsY0FBYyxFQUdoRTtJQUVEOzs7T0FHRztJQUNILGFBQWEsQ0FBQyxLQUFLLEVBQUUsV0FBVyxHQUFHLElBQUksQ0FNdEM7SUFFRDs7T0FFRztJQUNILGNBQWMsQ0FBQyxNQUFNLEVBQUUsV0FBVyxFQUFFLEdBQUcsSUFBSSxDQUkxQztJQUVEOzs7O09BSUc7SUFDSCxRQUFRLElBQUksTUFBTSxDQWFqQjtJQUVEOzs7O09BSUc7SUFDRyxTQUFTLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBbUI1QztJQUVEOzs7O09BSUc7SUFDRyxRQUFRLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBYzNDO0lBRUQ7O09BRUc7SUFDSCxnQkFBZ0IsSUFBSSxPQUFPLENBRTFCO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job_coordinator.d.ts","sourceRoot":"","sources":["../../src/job_coordinator/job_coordinator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"job_coordinator.d.ts","sourceRoot":"","sources":["../../src/job_coordinator/job_coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B,8BAA8B;IAC9B,OAAO,EAAE,iBAAiB,CAAC;IAK3B,YAAY,OAAO,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,cAAc,EAGhE;IAED;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAMtC;IAED;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAI1C;IAED;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAajB;IAED;;;;OAIG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmB5C;IAED;;;;OAIG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3C;IAED;;OAEG;IACH,gBAAgB,IAAI,OAAO,CAE1B;CACF"}
|
|
@@ -13,12 +13,13 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
13
13
|
* orchestrate concurrent jobs. Right now it doesn't make a difference because we're
|
|
14
14
|
* using a job queue with concurrency=1.
|
|
15
15
|
*/ export class JobCoordinator {
|
|
16
|
-
log
|
|
16
|
+
log;
|
|
17
17
|
/** The underlying KV store */ kvStore;
|
|
18
18
|
#currentJobId;
|
|
19
19
|
#stores = new Map();
|
|
20
|
-
constructor(kvStore){
|
|
20
|
+
constructor(kvStore, bindings){
|
|
21
21
|
this.kvStore = kvStore;
|
|
22
|
+
this.log = createLogger('pxe:job_coordinator', bindings);
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Registers a staged store.
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type LoggerBindings } from '@aztec/foundation/log';
|
|
2
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
3
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
7
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
5
8
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
6
9
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
7
10
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
8
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
9
11
|
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
10
12
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
11
13
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
12
14
|
export declare class LogService {
|
|
13
15
|
#private;
|
|
14
16
|
private readonly aztecNode;
|
|
15
|
-
private readonly
|
|
17
|
+
private readonly anchorBlockHeader;
|
|
16
18
|
private readonly keyStore;
|
|
17
19
|
private readonly capsuleStore;
|
|
18
20
|
private readonly recipientTaggingStore;
|
|
19
21
|
private readonly senderAddressBookStore;
|
|
20
22
|
private readonly addressStore;
|
|
23
|
+
private readonly jobId;
|
|
21
24
|
private log;
|
|
22
|
-
constructor(aztecNode: AztecNode,
|
|
25
|
+
constructor(aztecNode: AztecNode, anchorBlockHeader: BlockHeader, keyStore: KeyStore, capsuleStore: CapsuleStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, addressStore: AddressStore, jobId: string, bindings?: LoggerBindings);
|
|
23
26
|
bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]>;
|
|
24
|
-
|
|
27
|
+
fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes: AccessScopes): Promise<void>;
|
|
25
28
|
}
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nX3NlcnZpY2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sb2dzL2xvZ19zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sRUFBZSxLQUFLLGNBQWMsRUFBZ0IsTUFBTSx1QkFBdUIsQ0FBQztBQUN2RixPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNqRCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFRakUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDeEQsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxzRUFBc0UsQ0FBQztBQUNoSCxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1RUFBdUUsQ0FBQztBQUM3RyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkNBQTJDLENBQUM7QUFDekUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDJDQUEyQyxDQUFDO0FBQ3pFLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0scURBQXFELENBQUM7QUFDakcsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSx1REFBdUQsQ0FBQztBQU9wRyxxQkFBYSxVQUFVOztJQUluQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFDMUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxpQkFBaUI7SUFDbEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxRQUFRO0lBQ3pCLE9BQU8sQ0FBQyxRQUFRLENBQUMsWUFBWTtJQUM3QixPQUFPLENBQUMsUUFBUSxDQUFDLHFCQUFxQjtJQUN0QyxPQUFPLENBQUMsUUFBUSxDQUFDLHNCQUFzQjtJQUN2QyxPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBVnhCLE9BQU8sQ0FBQyxHQUFHLENBQVM7SUFFcEIsWUFDbUIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsaUJBQWlCLEVBQUUsV0FBVyxFQUM5QixRQUFRLEVBQUUsUUFBUSxFQUNsQixZQUFZLEVBQUUsWUFBWSxFQUMxQixxQkFBcUIsRUFBRSxxQkFBcUIsRUFDNUMsc0JBQXNCLEVBQUUsc0JBQXNCLEVBQzlDLFlBQVksRUFBRSxZQUFZLEVBQzFCLEtBQUssRUFBRSxNQUFNLEVBQzlCLFFBQVEsQ0FBQyxFQUFFLGNBQWMsRUFHMUI7SUFFWSxnQkFBZ0IsQ0FBQyxvQkFBb0IsRUFBRSxtQkFBbUIsRUFBRSxHQUFHLE9BQU8sQ0FBQyxDQUFDLG9CQUFvQixHQUFHLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FpQm5IO0lBdURZLGVBQWUsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLDZCQUE2QixFQUFFLEVBQUUsRUFBRSxNQUFNLEVBQUUsWUFBWSxpQkF3Q2xIO0NBd0RGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"log_service.d.ts","sourceRoot":"","sources":["../../src/logs/log_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,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,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAQjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sEAAsE,CAAC;AAChH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,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;AAOpG,qBAAa,UAAU;;IAInB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,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,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,qBAAqB,EAAE,qBAAqB,EAC5C,sBAAsB,EAAE,sBAAsB,EAC9C,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,MAAM,EAC9B,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEY,gBAAgB,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC,CAAC,oBAAoB,GAAG,IAAI,CAAC,EAAE,CAAC,CAiBnH;IAuDY,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,6BAA6B,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,iBAwClH;CAwDF"}
|
package/dest/logs/log_service.js
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import {
|
|
3
|
+
import { ExtendedDirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag } from '@aztec/stdlib/logs';
|
|
4
4
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
5
|
-
import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
|
|
5
|
+
import { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract, loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
|
|
6
6
|
export class LogService {
|
|
7
7
|
aztecNode;
|
|
8
|
-
|
|
8
|
+
anchorBlockHeader;
|
|
9
9
|
keyStore;
|
|
10
10
|
capsuleStore;
|
|
11
11
|
recipientTaggingStore;
|
|
12
12
|
senderAddressBookStore;
|
|
13
13
|
addressStore;
|
|
14
|
+
jobId;
|
|
14
15
|
log;
|
|
15
|
-
constructor(aztecNode,
|
|
16
|
+
constructor(aztecNode, anchorBlockHeader, keyStore, capsuleStore, recipientTaggingStore, senderAddressBookStore, addressStore, jobId, bindings){
|
|
16
17
|
this.aztecNode = aztecNode;
|
|
17
|
-
this.
|
|
18
|
+
this.anchorBlockHeader = anchorBlockHeader;
|
|
18
19
|
this.keyStore = keyStore;
|
|
19
20
|
this.capsuleStore = capsuleStore;
|
|
20
21
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
21
22
|
this.senderAddressBookStore = senderAddressBookStore;
|
|
22
23
|
this.addressStore = addressStore;
|
|
23
|
-
this.
|
|
24
|
+
this.jobId = jobId;
|
|
25
|
+
this.log = createLogger('pxe:log_service', bindings);
|
|
24
26
|
}
|
|
25
27
|
async bulkRetrieveLogs(logRetrievalRequests) {
|
|
26
28
|
return await Promise.all(logRetrievalRequests.map(async (request)=>{
|
|
27
29
|
const [publicLog, privateLog] = await Promise.all([
|
|
28
30
|
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
29
|
-
this.#getPrivateLogByTag(await SiloedTag.
|
|
31
|
+
this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress))
|
|
30
32
|
]);
|
|
31
33
|
if (publicLog !== null && privateLog !== null) {
|
|
32
34
|
throw new Error(`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`);
|
|
@@ -35,11 +37,12 @@ export class LogService {
|
|
|
35
37
|
}));
|
|
36
38
|
}
|
|
37
39
|
async #getPublicLogByTag(tag, contractAddress) {
|
|
38
|
-
const
|
|
40
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
41
|
+
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(this.aztecNode, contractAddress, [
|
|
39
42
|
tag
|
|
40
|
-
]);
|
|
41
|
-
const logsForTag =
|
|
42
|
-
if (logsForTag.length
|
|
43
|
+
], anchorBlockHash);
|
|
44
|
+
const logsForTag = allLogsPerTag[0];
|
|
45
|
+
if (logsForTag.length === 0) {
|
|
43
46
|
return null;
|
|
44
47
|
} else if (logsForTag.length > 1) {
|
|
45
48
|
// TODO(#11627): handle this case
|
|
@@ -49,11 +52,12 @@ export class LogService {
|
|
|
49
52
|
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
50
53
|
}
|
|
51
54
|
async #getPrivateLogByTag(siloedTag) {
|
|
52
|
-
const
|
|
55
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
56
|
+
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [
|
|
53
57
|
siloedTag
|
|
54
|
-
]);
|
|
55
|
-
const logsForTag =
|
|
56
|
-
if (logsForTag.length
|
|
58
|
+
], anchorBlockHash);
|
|
59
|
+
const logsForTag = allLogsPerTag[0];
|
|
60
|
+
if (logsForTag.length === 0) {
|
|
57
61
|
return null;
|
|
58
62
|
} else if (logsForTag.length > 1) {
|
|
59
63
|
// TODO(#11627): handle this case
|
|
@@ -62,21 +66,20 @@ export class LogService {
|
|
|
62
66
|
const scopedLog = logsForTag[0];
|
|
63
67
|
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
64
68
|
}
|
|
65
|
-
async
|
|
66
|
-
this.log.verbose(
|
|
67
|
-
contract: contractAddress
|
|
68
|
-
});
|
|
69
|
+
async fetchTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, scopes) {
|
|
70
|
+
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
69
71
|
// We only load logs from block up to and including the anchor block number
|
|
70
|
-
const anchorBlockNumber =
|
|
72
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
73
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
71
74
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
72
|
-
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
75
|
+
const recipients = scopes !== 'ALL_SCOPES' && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
73
76
|
// For each recipient, fetch secrets, load logs, and store them.
|
|
74
77
|
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
75
78
|
await Promise.all(recipients.map(async (recipient)=>{
|
|
76
79
|
// Get all secrets for this recipient (one per sender)
|
|
77
80
|
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
78
81
|
// Load logs for all sender-recipient pairs in parallel
|
|
79
|
-
const logArrays = await Promise.all(secrets.map((secret)=>loadPrivateLogsForSenderRecipientPair(secret,
|
|
82
|
+
const logArrays = await Promise.all(secrets.map((secret)=>loadPrivateLogsForSenderRecipientPair(secret, this.aztecNode, this.recipientTaggingStore, anchorBlockNumber, anchorBlockHash, this.jobId)));
|
|
80
83
|
// Flatten all logs from all secrets
|
|
81
84
|
const allLogs = logArrays.flat();
|
|
82
85
|
// Store the logs for this recipient
|
|
@@ -86,7 +89,10 @@ export class LogService {
|
|
|
86
89
|
}));
|
|
87
90
|
}
|
|
88
91
|
async #getSecretsForSenders(contractAddress, recipient) {
|
|
89
|
-
const recipientCompleteAddress = await this
|
|
92
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
93
|
+
if (!recipientCompleteAddress) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
90
96
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
91
97
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
92
98
|
// (recipient = us, sender = us)
|
|
@@ -97,7 +103,7 @@ export class LogService {
|
|
|
97
103
|
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
98
104
|
const deduplicatedSenders = Array.from(new Set(allSenders.map((sender)=>sender.toString()))).map((sender)=>AztecAddress.fromString(sender));
|
|
99
105
|
return Promise.all(deduplicatedSenders.map((sender)=>{
|
|
100
|
-
return
|
|
106
|
+
return ExtendedDirectionalAppTaggingSecret.compute(recipientCompleteAddress, recipientIvsk, sender, contractAddress, recipient);
|
|
101
107
|
}));
|
|
102
108
|
}
|
|
103
109
|
#storePendingTaggedLogs(contractAddress, capsuleArrayBaseSlot, recipient, privateLogs) {
|
|
@@ -107,14 +113,6 @@ export class LogService {
|
|
|
107
113
|
return pendingTaggedLog.toFields();
|
|
108
114
|
});
|
|
109
115
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
110
|
-
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
111
|
-
}
|
|
112
|
-
async #getCompleteAddress(account) {
|
|
113
|
-
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
114
|
-
if (!completeAddress) {
|
|
115
|
-
throw new Error(`No public key registered for address ${account}.
|
|
116
|
-
Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`);
|
|
117
|
-
}
|
|
118
|
-
return completeAddress;
|
|
116
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
119
117
|
}
|
|
120
118
|
}
|
|
@@ -2,14 +2,15 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { type AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
import { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
5
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
-
import type {
|
|
5
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
7
7
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
8
8
|
export declare class NoteService {
|
|
9
9
|
private readonly noteStore;
|
|
10
10
|
private readonly aztecNode;
|
|
11
|
-
private readonly
|
|
12
|
-
|
|
11
|
+
private readonly anchorBlockHeader;
|
|
12
|
+
private readonly jobId;
|
|
13
|
+
constructor(noteStore: NoteStore, aztecNode: AztecNode, anchorBlockHeader: BlockHeader, jobId: string);
|
|
13
14
|
/**
|
|
14
15
|
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
15
16
|
* The query result is paginated using 'limit' and 'offset' values.
|
|
@@ -19,7 +20,7 @@ export declare class NoteService {
|
|
|
19
20
|
* @param status - The status of notes to fetch.
|
|
20
21
|
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
21
22
|
*/
|
|
22
|
-
getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes
|
|
23
|
+
getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes: AccessScopes): Promise<{
|
|
23
24
|
contractAddress: AztecAddress;
|
|
24
25
|
owner: AztecAddress;
|
|
25
26
|
storageSlot: Fr;
|
|
@@ -27,8 +28,8 @@ export declare class NoteService {
|
|
|
27
28
|
noteNonce: Fr;
|
|
28
29
|
note: Note;
|
|
29
30
|
noteHash: Fr;
|
|
31
|
+
isPending: boolean;
|
|
30
32
|
siloedNullifier: Fr;
|
|
31
|
-
index: bigint;
|
|
32
33
|
}[]>;
|
|
33
34
|
/**
|
|
34
35
|
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
@@ -42,7 +43,7 @@ export declare class NoteService {
|
|
|
42
43
|
*
|
|
43
44
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
44
45
|
*/
|
|
45
|
-
syncNoteNullifiers(contractAddress: AztecAddress): Promise<void>;
|
|
46
|
-
|
|
46
|
+
syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void>;
|
|
47
|
+
validateAndStoreNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress): Promise<void>;
|
|
47
48
|
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbm90ZXMvbm90ZV9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUdoRSxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RSxPQUFPLEVBQUUsSUFBSSxFQUFXLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRS9ELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUU1RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUVyRSxxQkFBYSxXQUFXO0lBRXBCLE9BQU8sQ0FBQyxRQUFRLENBQUMsU0FBUztJQUMxQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFDMUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxpQkFBaUI7SUFDbEMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxLQUFLO0lBSnhCLFlBQ21CLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLGlCQUFpQixFQUFFLFdBQVcsRUFDOUIsS0FBSyxFQUFFLE1BQU0sRUFDNUI7SUFFSjs7Ozs7Ozs7T0FRRztJQUNVLFFBQVEsQ0FDbkIsZUFBZSxFQUFFLFlBQVksRUFDN0IsS0FBSyxFQUFFLFlBQVksR0FBRyxTQUFTLEVBQy9CLFdBQVcsRUFBRSxFQUFFLEVBQ2YsTUFBTSxFQUFFLFVBQVUsRUFDbEIsTUFBTSxFQUFFLFlBQVk7Ozs7Ozs7Ozs7U0F5QnJCO0lBRUQ7Ozs7Ozs7Ozs7O09BV0c7SUFDVSxrQkFBa0IsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLE1BQU0sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQXNDbEc7SUFFWSxvQkFBb0IsQ0FDL0IsZUFBZSxFQUFFLFlBQVksRUFDN0IsS0FBSyxFQUFFLFlBQVksRUFDbkIsV0FBVyxFQUFFLEVBQUUsRUFDZixVQUFVLEVBQUUsRUFBRSxFQUNkLFNBQVMsRUFBRSxFQUFFLEVBQ2IsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUNiLFFBQVEsRUFBRSxFQUFFLEVBQ1osU0FBUyxFQUFFLEVBQUUsRUFDYixNQUFNLEVBQUUsTUFBTSxFQUNkLFNBQVMsRUFBRSxZQUFZLEdBQ3RCLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FzRWY7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"note_service.d.ts","sourceRoot":"","sources":["../../src/notes/note_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"note_service.d.ts","sourceRoot":"","sources":["../../src/notes/note_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAErE,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,YACmB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,WAAW,EAC9B,KAAK,EAAE,MAAM,EAC5B;IAEJ;;;;;;;;OAQG;IACU,QAAQ,CACnB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,YAAY;;;;;;;;;;SAyBrB;IAED;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsClG;IAEY,oBAAoB,CAC/B,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,SAAS,EAAE,EAAE,EACb,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC,CAsEf;CACF"}
|
|
@@ -5,11 +5,13 @@ import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
|
5
5
|
export class NoteService {
|
|
6
6
|
noteStore;
|
|
7
7
|
aztecNode;
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
anchorBlockHeader;
|
|
9
|
+
jobId;
|
|
10
|
+
constructor(noteStore, aztecNode, anchorBlockHeader, jobId){
|
|
10
11
|
this.noteStore = noteStore;
|
|
11
12
|
this.aztecNode = aztecNode;
|
|
12
|
-
this.
|
|
13
|
+
this.anchorBlockHeader = anchorBlockHeader;
|
|
14
|
+
this.jobId = jobId;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
@@ -26,8 +28,8 @@ export class NoteService {
|
|
|
26
28
|
storageSlot,
|
|
27
29
|
status,
|
|
28
30
|
scopes
|
|
29
|
-
});
|
|
30
|
-
return noteDaos.map(({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier
|
|
31
|
+
}, this.jobId);
|
|
32
|
+
return noteDaos.map(({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier })=>({
|
|
31
33
|
contractAddress,
|
|
32
34
|
owner,
|
|
33
35
|
storageSlot,
|
|
@@ -35,9 +37,8 @@ export class NoteService {
|
|
|
35
37
|
noteNonce,
|
|
36
38
|
note,
|
|
37
39
|
noteHash,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
index
|
|
40
|
+
isPending: false,
|
|
41
|
+
siloedNullifier
|
|
41
42
|
}));
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
@@ -51,11 +52,12 @@ export class NoteService {
|
|
|
51
52
|
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
52
53
|
*
|
|
53
54
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
54
|
-
*/ async syncNoteNullifiers(contractAddress) {
|
|
55
|
-
const
|
|
55
|
+
*/ async syncNoteNullifiers(contractAddress, scopes) {
|
|
56
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
56
57
|
const contractNotes = await this.noteStore.getNotes({
|
|
57
|
-
contractAddress
|
|
58
|
-
|
|
58
|
+
contractAddress,
|
|
59
|
+
scopes
|
|
60
|
+
}, this.jobId);
|
|
59
61
|
if (contractNotes.length === 0) {
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
@@ -72,7 +74,7 @@ export class NoteService {
|
|
|
72
74
|
}, [
|
|
73
75
|
[]
|
|
74
76
|
]);
|
|
75
|
-
const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(
|
|
77
|
+
const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch)))).flat();
|
|
76
78
|
const foundNullifiers = nullifiersToCheck.map((nullifier, i)=>{
|
|
77
79
|
if (nullifierIndexes[i] !== undefined) {
|
|
78
80
|
return {
|
|
@@ -83,9 +85,9 @@ export class NoteService {
|
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
}).filter((nullifier)=>nullifier !== undefined);
|
|
86
|
-
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
88
|
+
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
87
89
|
}
|
|
88
|
-
async
|
|
90
|
+
async validateAndStoreNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash, recipient) {
|
|
89
91
|
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
90
92
|
// There's two things we need to check before we do this however:
|
|
91
93
|
// - we must make sure the note does actually exist in the note hash tree
|
|
@@ -104,49 +106,43 @@ export class NoteService {
|
|
|
104
106
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
105
107
|
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
106
108
|
// logs up to the synced block making this only an additional safety check.
|
|
107
|
-
const
|
|
109
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
110
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
108
111
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
109
112
|
// of other contracts, which would constitute a security breach.
|
|
110
113
|
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
111
114
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
112
|
-
const txEffect = await
|
|
115
|
+
const [txEffect, [nullifierIndex]] = await Promise.all([
|
|
116
|
+
this.aztecNode.getTxEffect(txHash),
|
|
117
|
+
this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [
|
|
118
|
+
siloedNullifier
|
|
119
|
+
])
|
|
120
|
+
]);
|
|
113
121
|
if (!txEffect) {
|
|
114
122
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
115
123
|
}
|
|
116
|
-
if (txEffect.l2BlockNumber >
|
|
117
|
-
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${
|
|
124
|
+
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
125
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
|
|
118
126
|
}
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
// Find the index of the note hash in the noteHashes array to determine note ordering within the tx
|
|
128
|
+
const noteIndexInTx = txEffect.data.noteHashes.findIndex((nh)=>nh.equals(uniqueNoteHash));
|
|
129
|
+
if (noteIndexInTx === -1) {
|
|
121
130
|
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
122
131
|
}
|
|
123
|
-
|
|
124
|
-
// note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
|
|
125
|
-
// queries in a single round-trip.
|
|
126
|
-
const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
|
|
127
|
-
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [
|
|
128
|
-
uniqueNoteHash
|
|
129
|
-
]),
|
|
130
|
-
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
|
|
131
|
-
siloedNullifier
|
|
132
|
-
])
|
|
133
|
-
]);
|
|
134
|
-
if (uniqueNoteHashTreeIndexInBlock === undefined) {
|
|
135
|
-
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`);
|
|
136
|
-
}
|
|
137
|
-
const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, uniqueNoteHashTreeIndexInBlock.l2BlockNumber, uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(), uniqueNoteHashTreeIndexInBlock.data);
|
|
132
|
+
const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, txEffect.l2BlockNumber, txEffect.l2BlockHash.toString(), txEffect.txIndexInBlock, noteIndexInTx);
|
|
138
133
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
139
134
|
await this.noteStore.addNotes([
|
|
140
135
|
noteDao
|
|
141
|
-
], recipient);
|
|
136
|
+
], recipient, this.jobId);
|
|
142
137
|
if (nullifierIndex !== undefined) {
|
|
138
|
+
// We found nullifier index which implies that the note has already been nullified.
|
|
143
139
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
144
140
|
await this.noteStore.applyNullifiers([
|
|
145
141
|
{
|
|
146
142
|
data: siloedNullifier,
|
|
147
143
|
...blockHashAndNum
|
|
148
144
|
}
|
|
149
|
-
]);
|
|
145
|
+
], this.jobId);
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
4
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
5
|
+
/**
|
|
6
|
+
* A filter used to fetch notes.
|
|
7
|
+
* @remarks This filter is applied as an intersection of all its params.
|
|
8
|
+
*/
|
|
9
|
+
export type NotesFilter = {
|
|
10
|
+
/**
|
|
11
|
+
* The contract address the note belongs to.
|
|
12
|
+
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
13
|
+
*/
|
|
14
|
+
contractAddress: AztecAddress;
|
|
15
|
+
/** The owner of the note. */
|
|
16
|
+
owner?: AztecAddress;
|
|
17
|
+
/** The specific storage location of the note on the contract. */
|
|
18
|
+
storageSlot?: Fr;
|
|
19
|
+
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
20
|
+
status?: NoteStatus;
|
|
21
|
+
/** The siloed nullifier for the note. */
|
|
22
|
+
siloedNullifier?: Fr;
|
|
23
|
+
scopes: AccessScopes;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZXNfZmlsdGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvbm90ZXNfZmlsdGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXJELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXZEOzs7R0FHRztBQUNILE1BQU0sTUFBTSxXQUFXLEdBQUc7SUFDeEI7OztPQUdHO0lBQ0gsZUFBZSxFQUFFLFlBQVksQ0FBQztJQUM5Qiw2QkFBNkI7SUFDN0IsS0FBSyxDQUFDLEVBQUUsWUFBWSxDQUFDO0lBQ3JCLGlFQUFpRTtJQUNqRSxXQUFXLENBQUMsRUFBRSxFQUFFLENBQUM7SUFDakIsb0RBQW9EO0lBQ3BELE1BQU0sQ0FBQyxFQUFFLFVBQVUsQ0FBQztJQUNwQix5Q0FBeUM7SUFDekMsZUFBZSxDQUFDLEVBQUUsRUFBRSxDQUFDO0lBQ3JCLE1BQU0sRUFBRSxZQUFZLENBQUM7Q0FDdEIsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notes_filter.d.ts","sourceRoot":"","sources":["../src/notes_filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,eAAe,EAAE,YAAY,CAAC;IAC9B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,iEAAiE;IACjE,WAAW,CAAC,EAAE,EAAE,CAAC;IACjB,oDAAoD;IACpD,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,yCAAyC;IACzC,eAAe,CAAC,EAAE,EAAE,CAAC;IACrB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC"}
|