@aztec/pxe 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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 +13 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +74 -20
- 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 -34
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +197 -82
- 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/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 +4 -3
- 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 +7 -4
- 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 +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -50
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +83 -54
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +67 -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 +131 -110
- 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 +31 -8
- 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 +32 -9
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
- 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 +39 -16
- 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 +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +28 -30
- 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} +16 -10
- 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 +12 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -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 +76 -58
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +149 -138
- 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 +47 -7
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +231 -73
- 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 +15 -8
- 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 +19 -9
- 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/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- 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 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +12 -12
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- 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 +5 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
- 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 -8
- 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 +5 -2
- 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 +10 -5
- 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 +93 -32
- 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 +350 -143
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -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 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +119 -137
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +198 -115
- 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 +23 -16
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +24 -17
- package/src/entrypoints/pxe_creation_options.ts +4 -2
- package/src/entrypoints/server/index.ts +4 -0
- package/src/entrypoints/server/utils.ts +33 -41
- package/src/events/event_service.ts +19 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +40 -34
- 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} +39 -28
- package/src/private_kernel/private_kernel_execution_prover.ts +15 -14
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +280 -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 +301 -79
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +106 -20
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +294 -109
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +2 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +25 -11
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +10 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
- 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 -86
- 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 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -5,38 +5,107 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
7
7
|
* blocks, which by definition cannot be affected by reorgs.
|
|
8
|
-
*
|
|
9
|
-
* TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
|
|
10
8
|
*/ export class RecipientTaggingStore {
|
|
9
|
+
storeName = 'recipient_tagging';
|
|
11
10
|
#store;
|
|
12
11
|
#highestAgedIndex;
|
|
13
12
|
#highestFinalizedIndex;
|
|
13
|
+
// jobId => secret => number
|
|
14
|
+
#highestAgedIndexForJob;
|
|
15
|
+
// jobId => secret => number
|
|
16
|
+
#highestFinalizedIndexForJob;
|
|
14
17
|
constructor(store){
|
|
15
18
|
this.#store = store;
|
|
16
19
|
this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
|
|
17
20
|
this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
|
|
21
|
+
this.#highestAgedIndexForJob = new Map();
|
|
22
|
+
this.#highestFinalizedIndexForJob = new Map();
|
|
23
|
+
}
|
|
24
|
+
#getHighestAgedIndexForJob(jobId) {
|
|
25
|
+
let highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
|
|
26
|
+
if (!highestAgedIndexForJob) {
|
|
27
|
+
highestAgedIndexForJob = new Map();
|
|
28
|
+
this.#highestAgedIndexForJob.set(jobId, highestAgedIndexForJob);
|
|
29
|
+
}
|
|
30
|
+
return highestAgedIndexForJob;
|
|
18
31
|
}
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
async #readHighestAgedIndex(jobId, secret) {
|
|
33
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
34
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
35
|
+
const dbValue = await this.#highestAgedIndex.getAsync(secret);
|
|
36
|
+
const staged = this.#getHighestAgedIndexForJob(jobId).get(secret);
|
|
37
|
+
return staged ?? dbValue;
|
|
21
38
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
#writeHighestAgedIndex(jobId, secret, index) {
|
|
40
|
+
this.#getHighestAgedIndexForJob(jobId).set(secret, index);
|
|
41
|
+
}
|
|
42
|
+
#getHighestFinalizedIndexForJob(jobId) {
|
|
43
|
+
let jobStagedHighestFinalizedIndex = this.#highestFinalizedIndexForJob.get(jobId);
|
|
44
|
+
if (!jobStagedHighestFinalizedIndex) {
|
|
45
|
+
jobStagedHighestFinalizedIndex = new Map();
|
|
46
|
+
this.#highestFinalizedIndexForJob.set(jobId, jobStagedHighestFinalizedIndex);
|
|
27
47
|
}
|
|
28
|
-
|
|
48
|
+
return jobStagedHighestFinalizedIndex;
|
|
49
|
+
}
|
|
50
|
+
async #readHighestFinalizedIndex(jobId, secret) {
|
|
51
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
52
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
53
|
+
const dbValue = await this.#highestFinalizedIndex.getAsync(secret);
|
|
54
|
+
const staged = this.#getHighestFinalizedIndexForJob(jobId).get(secret);
|
|
55
|
+
return staged ?? dbValue;
|
|
29
56
|
}
|
|
30
|
-
|
|
31
|
-
|
|
57
|
+
#writeHighestFinalizedIndex(jobId, secret, index) {
|
|
58
|
+
this.#getHighestFinalizedIndexForJob(jobId).set(secret, index);
|
|
32
59
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Writes all job-specific in-memory data to persistent storage.
|
|
62
|
+
*
|
|
63
|
+
* @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
|
|
64
|
+
*/ async commit(jobId) {
|
|
65
|
+
const highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
|
|
66
|
+
if (highestAgedIndexForJob) {
|
|
67
|
+
for (const [secret, index] of highestAgedIndexForJob.entries()){
|
|
68
|
+
await this.#highestAgedIndex.set(secret, index);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const highestFinalizedIndexForJob = this.#highestFinalizedIndexForJob.get(jobId);
|
|
72
|
+
if (highestFinalizedIndexForJob) {
|
|
73
|
+
for (const [secret, index] of highestFinalizedIndexForJob.entries()){
|
|
74
|
+
await this.#highestFinalizedIndex.set(secret, index);
|
|
75
|
+
}
|
|
39
76
|
}
|
|
40
|
-
|
|
77
|
+
return this.discardStaged(jobId);
|
|
78
|
+
}
|
|
79
|
+
discardStaged(jobId) {
|
|
80
|
+
this.#highestAgedIndexForJob.delete(jobId);
|
|
81
|
+
this.#highestFinalizedIndexForJob.delete(jobId);
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
}
|
|
84
|
+
getHighestAgedIndex(secret, jobId) {
|
|
85
|
+
return this.#store.transactionAsync(()=>this.#readHighestAgedIndex(jobId, secret.toString()));
|
|
86
|
+
}
|
|
87
|
+
updateHighestAgedIndex(secret, index, jobId) {
|
|
88
|
+
return this.#store.transactionAsync(async ()=>{
|
|
89
|
+
const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
|
|
90
|
+
if (currentIndex !== undefined && index <= currentIndex) {
|
|
91
|
+
// Log sync should never set a lower highest aged index.
|
|
92
|
+
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
93
|
+
}
|
|
94
|
+
this.#writeHighestAgedIndex(jobId, secret.toString(), index);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
getHighestFinalizedIndex(secret, jobId) {
|
|
98
|
+
return this.#store.transactionAsync(()=>this.#readHighestFinalizedIndex(jobId, secret.toString()));
|
|
99
|
+
}
|
|
100
|
+
updateHighestFinalizedIndex(secret, index, jobId) {
|
|
101
|
+
return this.#store.transactionAsync(async ()=>{
|
|
102
|
+
const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
|
|
103
|
+
if (currentIndex !== undefined && index < currentIndex) {
|
|
104
|
+
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
105
|
+
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
106
|
+
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
107
|
+
}
|
|
108
|
+
this.#writeHighestFinalizedIndex(jobId, secret.toString(), index);
|
|
109
|
+
});
|
|
41
110
|
}
|
|
42
111
|
}
|
|
@@ -11,4 +11,4 @@ export declare class SenderAddressBookStore {
|
|
|
11
11
|
getSenders(): Promise<AztecAddress[]>;
|
|
12
12
|
removeSender(address: AztecAddress): Promise<boolean>;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX2FkZHJlc3NfYm9va19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvdGFnZ2luZ19zdG9yZS9zZW5kZXJfYWRkcmVzc19ib29rX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUzRDs7O0dBR0c7QUFDSCxxQkFBYSxzQkFBc0I7O0lBSWpDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUluQztJQUVELFNBQVMsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FVakQ7SUFFRCxVQUFVLElBQUksT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBSXBDO0lBRUQsWUFBWSxDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVVwRDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;
|
|
1
|
+
{"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;IAED,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjD;IAED,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAIpC;IAED,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAUpD;CACF"}
|
|
@@ -10,21 +10,27 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
10
10
|
this.#store = store;
|
|
11
11
|
this.#addressBook = this.#store.openMap('address_book');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
addSender(address) {
|
|
14
|
+
return this.#store.transactionAsync(async ()=>{
|
|
15
|
+
if (await this.#addressBook.hasAsync(address.toString())) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
await this.#addressBook.set(address.toString(), true);
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
+
getSenders() {
|
|
23
|
+
return this.#store.transactionAsync(async ()=>{
|
|
24
|
+
return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
|
|
25
|
+
});
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
removeSender(address) {
|
|
28
|
+
return this.#store.transactionAsync(async ()=>{
|
|
29
|
+
if (!await this.#addressBook.hasAsync(address.toString())) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
await this.#addressBook.delete(address.toString());
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
2
|
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
3
3
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
4
5
|
/**
|
|
5
6
|
* Data provider of tagging data used when syncing the sender tagging indexes. The recipient counterpart of this class
|
|
6
|
-
* is called RecipientTaggingStore. We have the
|
|
7
|
+
* is called RecipientTaggingStore. We have the data stores separate for sender and recipient because
|
|
7
8
|
* the algorithms are completely disjoint and there is not data reuse between the two.
|
|
8
9
|
*/
|
|
9
|
-
export declare class SenderTaggingStore {
|
|
10
|
+
export declare class SenderTaggingStore implements StagedStore {
|
|
10
11
|
#private;
|
|
12
|
+
readonly storeName = "sender_tagging";
|
|
11
13
|
constructor(store: AztecAsyncKVStore);
|
|
14
|
+
/**
|
|
15
|
+
* Writes all job-specific in-memory data to persistent storage.
|
|
16
|
+
*
|
|
17
|
+
* @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
|
|
18
|
+
*/
|
|
19
|
+
commit(jobId: string): Promise<void>;
|
|
20
|
+
discardStaged(jobId: string): Promise<void>;
|
|
12
21
|
/**
|
|
13
22
|
* Stores pending indexes.
|
|
14
23
|
* @remarks Ignores the index if the same preTag + txHash combination already exists in the db with the same index.
|
|
@@ -17,6 +26,7 @@ export declare class SenderTaggingStore {
|
|
|
17
26
|
* @param preTags - The pre-tags containing the directional app tagging secrets and the indexes that are to be
|
|
18
27
|
* stored in the db.
|
|
19
28
|
* @param txHash - The tx in which the pretags were used in private logs.
|
|
29
|
+
* @param jobId - job context for staged writes to this store. See `JobCoordinator` for more details.
|
|
20
30
|
* @throws If any two pre-tags contain the same directional app tagging secret. This is enforced because we care
|
|
21
31
|
* only about the highest index for a given secret that was used in the tx. Hence this check is a good way to catch
|
|
22
32
|
* bugs.
|
|
@@ -30,7 +40,7 @@ export declare class SenderTaggingStore {
|
|
|
30
40
|
* This is enforced because this should never happen if the syncing is done correctly as we look for logs from higher
|
|
31
41
|
* indexes than finalized ones.
|
|
32
42
|
*/
|
|
33
|
-
storePendingIndexes(preTags: PreTag[], txHash: TxHash): Promise<void>;
|
|
43
|
+
storePendingIndexes(preTags: PreTag[], txHash: TxHash, jobId: string): Promise<void>;
|
|
34
44
|
/**
|
|
35
45
|
* Returns the transaction hashes of all pending transactions that contain indexes within a specified range
|
|
36
46
|
* for a given directional app tagging secret.
|
|
@@ -40,28 +50,28 @@ export declare class SenderTaggingStore {
|
|
|
40
50
|
* @returns An array of unique transaction hashes for pending transactions that contain indexes in the range
|
|
41
51
|
* [startIndex, endIndex). Returns an empty array if no pending indexes exist in the range.
|
|
42
52
|
*/
|
|
43
|
-
getTxHashesOfPendingIndexes(secret: DirectionalAppTaggingSecret, startIndex: number, endIndex: number): Promise<TxHash[]>;
|
|
53
|
+
getTxHashesOfPendingIndexes(secret: DirectionalAppTaggingSecret, startIndex: number, endIndex: number, jobId: string): Promise<TxHash[]>;
|
|
44
54
|
/**
|
|
45
55
|
* Returns the last (highest) finalized index for a given secret.
|
|
46
56
|
* @param secret - The secret to get the last finalized index for.
|
|
47
57
|
* @returns The last (highest) finalized index for the given secret.
|
|
48
58
|
*/
|
|
49
|
-
getLastFinalizedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
|
|
59
|
+
getLastFinalizedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
50
60
|
/**
|
|
51
61
|
* Returns the last used index for a given directional app tagging secret, considering both finalized and pending
|
|
52
62
|
* indexes.
|
|
53
63
|
* @param secret - The directional app tagging secret to query the last used index for.
|
|
54
64
|
* @returns The last used index.
|
|
55
65
|
*/
|
|
56
|
-
getLastUsedIndex(secret: DirectionalAppTaggingSecret): Promise<number | undefined>;
|
|
66
|
+
getLastUsedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
57
67
|
/**
|
|
58
68
|
* Drops all pending indexes corresponding to the given transaction hashes.
|
|
59
69
|
*/
|
|
60
|
-
dropPendingIndexes(txHashes: TxHash[]): Promise<void>;
|
|
70
|
+
dropPendingIndexes(txHashes: TxHash[], jobId: string): Promise<void>;
|
|
61
71
|
/**
|
|
62
72
|
* Updates pending indexes corresponding to the given transaction hashes to be finalized and prunes any lower pending
|
|
63
73
|
* indexes.
|
|
64
74
|
*/
|
|
65
|
-
finalizePendingIndexes(txHashes: TxHash[]): Promise<void>;
|
|
75
|
+
finalizePendingIndexes(txHashes: TxHash[], jobId: string): Promise<void>;
|
|
66
76
|
}
|
|
67
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvc2VuZGVyX3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDOUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTFDLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLDBDQUEwQyxDQUFDO0FBRzVFOzs7O0dBSUc7QUFDSCxxQkFBYSxrQkFBbUIsWUFBVyxXQUFXOztJQUNwRCxRQUFRLENBQUMsU0FBUyxvQkFBb0I7SUE2QnRDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQVFuQztJQTRDRDs7OztPQUlHO0lBQ0csTUFBTSxDQUFDLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQW9CekM7SUFFRCxhQUFhLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBSTFDO0lBRUQ7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztPQXFCRztJQUNILG1CQUFtQixDQUFDLE9BQU8sRUFBRSxNQUFNLEVBQUUsRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTBFbkY7SUFFRDs7Ozs7Ozs7T0FRRztJQUNILDJCQUEyQixDQUN6QixNQUFNLEVBQUUsMkJBQTJCLEVBQ25DLFVBQVUsRUFBRSxNQUFNLEVBQ2xCLFFBQVEsRUFBRSxNQUFNLEVBQ2hCLEtBQUssRUFBRSxNQUFNLEdBQ1osT0FBTyxDQUFDLE1BQU0sRUFBRSxDQUFDLENBUW5CO0lBRUQ7Ozs7T0FJRztJQUNILHFCQUFxQixDQUFDLE1BQU0sRUFBRSwyQkFBMkIsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRXJHO0lBRUQ7Ozs7O09BS0c7SUFDSCxnQkFBZ0IsQ0FBQyxNQUFNLEVBQUUsMkJBQTJCLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQWtCaEc7SUFFRDs7T0FFRztJQUNILGtCQUFrQixDQUFDLFFBQVEsRUFBRSxNQUFNLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0EyQ25FO0lBRUQ7OztPQUdHO0lBQ0gsc0JBQXNCLENBQUMsUUFBUSxFQUFFLE1BQU0sRUFBRSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTJGdkU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_tagging_store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sender_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAG5E;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,WAAW;;IACpD,QAAQ,CAAC,SAAS,oBAAoB;IA6BtC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA4CD;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0EnF;IAED;;;;;;;;OAQG;IACH,2BAA2B,CACzB,MAAM,EAAE,2BAA2B,EACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;IAED;;;;OAIG;IACH,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAErG;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkBhG;IAED;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CnE;IAED;;;OAGG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2FvE;CACF"}
|