@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
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
2
2
|
import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
3
|
|
|
4
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Data provider of tagging data used when syncing the logs as a recipient. The sender counterpart of this class
|
|
6
8
|
* is called SenderTaggingStore. We have the providers separate for the sender and recipient because
|
|
@@ -8,46 +10,130 @@ import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
|
|
|
8
10
|
*
|
|
9
11
|
* @dev Chain reorgs do not need to be handled here because both the finalized and aged indexes refer to finalized
|
|
10
12
|
* blocks, which by definition cannot be affected by reorgs.
|
|
11
|
-
*
|
|
12
|
-
* TODO(benesjan): Relocate to yarn-project/pxe/src/storage/tagging_store
|
|
13
13
|
*/
|
|
14
|
-
export class RecipientTaggingStore {
|
|
14
|
+
export class RecipientTaggingStore implements StagedStore {
|
|
15
|
+
storeName: string = 'recipient_tagging';
|
|
16
|
+
|
|
15
17
|
#store: AztecAsyncKVStore;
|
|
16
18
|
|
|
17
19
|
#highestAgedIndex: AztecAsyncMap<string, number>;
|
|
18
20
|
#highestFinalizedIndex: AztecAsyncMap<string, number>;
|
|
19
21
|
|
|
22
|
+
// jobId => secret => number
|
|
23
|
+
#highestAgedIndexForJob: Map<string, Map<string, number>>;
|
|
24
|
+
|
|
25
|
+
// jobId => secret => number
|
|
26
|
+
#highestFinalizedIndexForJob: Map<string, Map<string, number>>;
|
|
27
|
+
|
|
20
28
|
constructor(store: AztecAsyncKVStore) {
|
|
21
29
|
this.#store = store;
|
|
22
30
|
|
|
23
31
|
this.#highestAgedIndex = this.#store.openMap('highest_aged_index');
|
|
24
32
|
this.#highestFinalizedIndex = this.#store.openMap('highest_finalized_index');
|
|
33
|
+
|
|
34
|
+
this.#highestAgedIndexForJob = new Map();
|
|
35
|
+
this.#highestFinalizedIndexForJob = new Map();
|
|
25
36
|
}
|
|
26
37
|
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
#getHighestAgedIndexForJob(jobId: string): Map<string, number> {
|
|
39
|
+
let highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
|
|
40
|
+
if (!highestAgedIndexForJob) {
|
|
41
|
+
highestAgedIndexForJob = new Map();
|
|
42
|
+
this.#highestAgedIndexForJob.set(jobId, highestAgedIndexForJob);
|
|
43
|
+
}
|
|
44
|
+
return highestAgedIndexForJob;
|
|
29
45
|
}
|
|
30
46
|
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
async #readHighestAgedIndex(jobId: string, secret: string): Promise<number | undefined> {
|
|
48
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
49
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
50
|
+
const dbValue = await this.#highestAgedIndex.getAsync(secret);
|
|
51
|
+
const staged = this.#getHighestAgedIndexForJob(jobId).get(secret);
|
|
52
|
+
return staged ?? dbValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#writeHighestAgedIndex(jobId: string, secret: string, index: number) {
|
|
56
|
+
this.#getHighestAgedIndexForJob(jobId).set(secret, index);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#getHighestFinalizedIndexForJob(jobId: string): Map<string, number> {
|
|
60
|
+
let jobStagedHighestFinalizedIndex = this.#highestFinalizedIndexForJob.get(jobId);
|
|
61
|
+
if (!jobStagedHighestFinalizedIndex) {
|
|
62
|
+
jobStagedHighestFinalizedIndex = new Map();
|
|
63
|
+
this.#highestFinalizedIndexForJob.set(jobId, jobStagedHighestFinalizedIndex);
|
|
36
64
|
}
|
|
37
|
-
|
|
65
|
+
return jobStagedHighestFinalizedIndex;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async #readHighestFinalizedIndex(jobId: string, secret: string): Promise<number | undefined> {
|
|
69
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
70
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
71
|
+
const dbValue = await this.#highestFinalizedIndex.getAsync(secret);
|
|
72
|
+
const staged = this.#getHighestFinalizedIndexForJob(jobId).get(secret);
|
|
73
|
+
return staged ?? dbValue;
|
|
38
74
|
}
|
|
39
75
|
|
|
40
|
-
|
|
41
|
-
|
|
76
|
+
#writeHighestFinalizedIndex(jobId: string, secret: string, index: number) {
|
|
77
|
+
this.#getHighestFinalizedIndexForJob(jobId).set(secret, index);
|
|
42
78
|
}
|
|
43
79
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Writes all job-specific in-memory data to persistent storage.
|
|
82
|
+
*
|
|
83
|
+
* @remark This method must run in a DB transaction context. It's designed to be called from JobCoordinator#commitJob.
|
|
84
|
+
*/
|
|
85
|
+
async commit(jobId: string): Promise<void> {
|
|
86
|
+
const highestAgedIndexForJob = this.#highestAgedIndexForJob.get(jobId);
|
|
87
|
+
if (highestAgedIndexForJob) {
|
|
88
|
+
for (const [secret, index] of highestAgedIndexForJob.entries()) {
|
|
89
|
+
await this.#highestAgedIndex.set(secret, index);
|
|
90
|
+
}
|
|
50
91
|
}
|
|
51
|
-
|
|
92
|
+
|
|
93
|
+
const highestFinalizedIndexForJob = this.#highestFinalizedIndexForJob.get(jobId);
|
|
94
|
+
if (highestFinalizedIndexForJob) {
|
|
95
|
+
for (const [secret, index] of highestFinalizedIndexForJob.entries()) {
|
|
96
|
+
await this.#highestFinalizedIndex.set(secret, index);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return this.discardStaged(jobId);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
discardStaged(jobId: string): Promise<void> {
|
|
104
|
+
this.#highestAgedIndexForJob.delete(jobId);
|
|
105
|
+
this.#highestFinalizedIndexForJob.delete(jobId);
|
|
106
|
+
return Promise.resolve();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getHighestAgedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
110
|
+
return this.#store.transactionAsync(() => this.#readHighestAgedIndex(jobId, secret.toString()));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
updateHighestAgedIndex(secret: DirectionalAppTaggingSecret, index: number, jobId: string): Promise<void> {
|
|
114
|
+
return this.#store.transactionAsync(async () => {
|
|
115
|
+
const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
|
|
116
|
+
if (currentIndex !== undefined && index <= currentIndex) {
|
|
117
|
+
// Log sync should never set a lower highest aged index.
|
|
118
|
+
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
119
|
+
}
|
|
120
|
+
this.#writeHighestAgedIndex(jobId, secret.toString(), index);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
125
|
+
return this.#store.transactionAsync(() => this.#readHighestFinalizedIndex(jobId, secret.toString()));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number, jobId: string): Promise<void> {
|
|
129
|
+
return this.#store.transactionAsync(async () => {
|
|
130
|
+
const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
|
|
131
|
+
if (currentIndex !== undefined && index < currentIndex) {
|
|
132
|
+
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
133
|
+
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
134
|
+
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
135
|
+
}
|
|
136
|
+
this.#writeHighestFinalizedIndex(jobId, secret.toString(), index);
|
|
137
|
+
});
|
|
52
138
|
}
|
|
53
139
|
}
|
|
@@ -16,27 +16,33 @@ export class SenderAddressBookStore {
|
|
|
16
16
|
this.#addressBook = this.#store.openMap('address_book');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
addSender(address: AztecAddress): Promise<boolean> {
|
|
20
|
+
return this.#store.transactionAsync(async () => {
|
|
21
|
+
if (await this.#addressBook.hasAsync(address.toString())) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
await this.#addressBook.set(address.toString(), true);
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
return true;
|
|
28
|
+
});
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
+
getSenders(): Promise<AztecAddress[]> {
|
|
32
|
+
return this.#store.transactionAsync(async () => {
|
|
33
|
+
return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
|
|
34
|
+
});
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
removeSender(address: AztecAddress): Promise<boolean> {
|
|
38
|
+
return this.#store.transactionAsync(async () => {
|
|
39
|
+
if (!(await this.#addressBook.hasAsync(address.toString()))) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
await this.#addressBook.delete(address.toString());
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
41
47
|
}
|
|
42
48
|
}
|