@aztec/pxe 0.0.1-commit.03f7ef2 → 0.0.1-commit.1142ef1
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/block_synchronizer/block_synchronizer.d.ts +8 -8
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +15 -20
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +25 -22
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +34 -28
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +4 -4
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +4 -5
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +17 -26
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +14 -39
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -19
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +47 -45
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +5 -5
- package/dest/debug/pxe_debug_utils.d.ts +6 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +7 -7
- 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 +10 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- 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/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +7 -7
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +8 -8
- package/dest/events/private_event_filter_validator.d.ts +6 -6
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +4 -4
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/logs/log_service.d.ts +14 -31
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +61 -180
- package/dest/notes/note_service.d.ts +7 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -14
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +2 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +3 -4
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +5 -5
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +9 -10
- package/dest/public_storage/public_storage_service.d.ts +4 -4
- package/dest/public_storage/public_storage_service.d.ts.map +1 -1
- package/dest/public_storage/public_storage_service.js +4 -4
- package/dest/pxe.d.ts +11 -9
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +113 -87
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -0
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{anchor_block_data_provider/anchor_block_data_provider.js → anchor_block_store/anchor_block_store.js} +1 -1
- package/dest/storage/anchor_block_store/index.d.ts +2 -0
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.d.ts → capsule_store/capsule_store.d.ts} +2 -2
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +1 -1
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +4 -3
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +14 -2
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +7 -7
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +6 -6
- package/dest/storage/private_event_store/private_event_store.d.ts +56 -0
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/{private_event_data_provider/private_event_data_provider.js → private_event_store/private_event_store.js} +59 -16
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/{tagging/recipient_sync/new_recipient_tagging_data_provider.js → storage/tagging_store/recipient_tagging_store.js} +3 -3
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.d.ts → tagging_store/sender_tagging_store.d.ts} +3 -3
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/{tagging_data_provider/sender_tagging_data_provider.js → tagging_store/sender_tagging_store.js} +3 -3
- package/dest/tagging/constants.d.ts +2 -2
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +10 -3
- package/dest/tagging/index.d.ts +14 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +13 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -3
- 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 +7 -7
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.d.ts +3 -4
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.js +8 -23
- package/dest/tagging/{sync → 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 -0
- package/dest/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.js +2 -2
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.js +3 -3
- package/dest/tree_membership/tree_membership_service.d.ts +4 -4
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -1
- package/dest/tree_membership/tree_membership_service.js +5 -5
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +14 -19
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +57 -48
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +4 -0
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -6
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +52 -80
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +53 -49
- package/src/contract_function_simulator/proxied_contract_data_source.ts +7 -7
- package/src/debug/pxe_debug_utils.ts +6 -6
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +8 -6
- package/src/events/private_event_filter_validator.ts +5 -5
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +92 -254
- package/src/notes/note_service.ts +13 -13
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +1 -2
- package/src/private_kernel/private_kernel_execution_prover.ts +2 -4
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +8 -14
- package/src/public_storage/public_storage_service.ts +3 -3
- package/src/pxe.ts +154 -106
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{anchor_block_data_provider/anchor_block_data_provider.ts → anchor_block_store/anchor_block_store.ts} +1 -1
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +1 -1
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +22 -2
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +7 -7
- package/src/storage/{private_event_data_provider/private_event_data_provider.ts → private_event_store/private_event_store.ts} +72 -18
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/{tagging/recipient_sync/new_recipient_tagging_data_provider.ts → storage/tagging_store/recipient_tagging_store.ts} +3 -3
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/{tagging_data_provider/sender_tagging_data_provider.ts → tagging_store/sender_tagging_store.ts} +3 -3
- package/src/tagging/constants.ts +10 -3
- package/src/tagging/index.ts +16 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +11 -8
- package/src/tagging/{sync → sender_sync}/sync_sender_tagging_indexes.ts +9 -25
- package/src/tagging/{sync → sender_sync}/utils/get_status_change_of_pending.ts +6 -2
- package/src/tagging/{sync → sender_sync}/utils/load_and_store_new_tagging_indexes.ts +4 -4
- package/src/tree_membership/tree_membership_service.ts +4 -4
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts +0 -9
- package/dest/storage/anchor_block_data_provider/anchor_block_data_provider.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.d.ts +0 -2
- package/dest/storage/anchor_block_data_provider/index.d.ts.map +0 -1
- package/dest/storage/anchor_block_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +0 -51
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -3
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -2
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts +0 -31
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/recipient_tagging_data_provider.js +0 -65
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +0 -21
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +0 -1
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +0 -1
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -25
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/anchor_block_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/tagging_data_provider/index.ts +0 -2
- package/src/storage/tagging_data_provider/recipient_tagging_data_provider.ts +0 -86
- package/src/tagging/utils.ts +0 -32
- /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
- /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface that stores must implement to support staged writes.
|
|
7
|
+
*/
|
|
8
|
+
export interface StagedStore {
|
|
9
|
+
/** Unique name identifying this store (used for tracking staged stores from JobCoordinator) */
|
|
10
|
+
readonly storeName: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Commits staged data to main storage.
|
|
14
|
+
* Should be called within a transaction for atomicity.
|
|
15
|
+
*
|
|
16
|
+
* @param jobId - The job identifier
|
|
17
|
+
*/
|
|
18
|
+
commit(jobId: string): Promise<void>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Discards staged data without committing.
|
|
22
|
+
* Called on abort.
|
|
23
|
+
*
|
|
24
|
+
* @param jobId - The job identifier
|
|
25
|
+
*/
|
|
26
|
+
discardStaged(jobId: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* JobCoordinator manages job lifecycle and provides crash resilience for PXE operations.
|
|
31
|
+
*
|
|
32
|
+
* It uses a staged writes pattern:
|
|
33
|
+
* 1. When a job begins, a unique job ID is created
|
|
34
|
+
* 2. During the job, all writes go to staging (keyed by job ID)
|
|
35
|
+
* 3. On commit, staging is promoted to main storage
|
|
36
|
+
* 4. On abort, staged data is discarded
|
|
37
|
+
*
|
|
38
|
+
* Note: PXE should only rely on a single JobCoordinator instance, so it can eventually
|
|
39
|
+
* orchestrate concurrent jobs. Right now it doesn't make a difference because we're
|
|
40
|
+
* using a job queue with concurrency=1.
|
|
41
|
+
*/
|
|
42
|
+
export class JobCoordinator {
|
|
43
|
+
private readonly log = createLogger('pxe:job_coordinator');
|
|
44
|
+
|
|
45
|
+
/** The underlying KV store */
|
|
46
|
+
kvStore: AztecAsyncKVStore;
|
|
47
|
+
|
|
48
|
+
#currentJobId: string | undefined;
|
|
49
|
+
#stores: Map<string, StagedStore> = new Map();
|
|
50
|
+
|
|
51
|
+
constructor(kvStore: AztecAsyncKVStore) {
|
|
52
|
+
this.kvStore = kvStore;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Registers a staged store.
|
|
57
|
+
* Must be called during initialization for all stores that need staging support.
|
|
58
|
+
*/
|
|
59
|
+
registerStore(store: StagedStore): void {
|
|
60
|
+
if (this.#stores.has(store.storeName)) {
|
|
61
|
+
throw new Error(`Store "${store.storeName}" is already registered`);
|
|
62
|
+
}
|
|
63
|
+
this.#stores.set(store.storeName, store);
|
|
64
|
+
this.log.debug(`Registered staged store: ${store.storeName}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Registers multiple staged stores.
|
|
69
|
+
*/
|
|
70
|
+
registerStores(stores: StagedStore[]): void {
|
|
71
|
+
for (const store of stores) {
|
|
72
|
+
this.registerStore(store);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Begins a new job and returns a job ID for staged writes.
|
|
78
|
+
*
|
|
79
|
+
* @returns Job ID to pass to store operations
|
|
80
|
+
*/
|
|
81
|
+
beginJob(): string {
|
|
82
|
+
if (this.#currentJobId) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Cannot begin job: job ${this.#currentJobId} is already in progress. ` +
|
|
85
|
+
`This should not happen - ensure jobs are properly committed or aborted.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const jobId = randomBytes(8).toString('hex');
|
|
90
|
+
this.#currentJobId = jobId;
|
|
91
|
+
|
|
92
|
+
this.log.debug(`Started job ${jobId}`);
|
|
93
|
+
return jobId;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Commits a job by promoting all staged data to main storage.
|
|
98
|
+
*
|
|
99
|
+
* @param jobId - The job ID returned from beginJob
|
|
100
|
+
*/
|
|
101
|
+
async commitJob(jobId: string): Promise<void> {
|
|
102
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`Cannot commit job ${jobId}: no matching job in progress. ` + `Current job: ${this.#currentJobId ?? 'none'}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.log.debug(`Committing job ${jobId}`);
|
|
109
|
+
|
|
110
|
+
// Commit all stores atomically in a single transaction.
|
|
111
|
+
// Each store's commit is a no-op if it has no staged data (but that's up to each store to handle).
|
|
112
|
+
await this.kvStore.transactionAsync(async () => {
|
|
113
|
+
for (const store of this.#stores.values()) {
|
|
114
|
+
await store.commit(jobId);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.#currentJobId = undefined;
|
|
119
|
+
this.log.debug(`Job ${jobId} committed successfully`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Aborts a job by discarding all staged data.
|
|
124
|
+
*
|
|
125
|
+
* @param jobId - The job ID returned from beginJob
|
|
126
|
+
*/
|
|
127
|
+
async abortJob(jobId: string): Promise<void> {
|
|
128
|
+
if (!this.#currentJobId || this.#currentJobId !== jobId) {
|
|
129
|
+
// Job may have already been aborted or never started properly
|
|
130
|
+
this.log.warn(`Abort called for job ${jobId} but current job is ${this.#currentJobId ?? 'none'}`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.log.debug(`Aborting job ${jobId}`);
|
|
134
|
+
|
|
135
|
+
for (const store of this.#stores.values()) {
|
|
136
|
+
await store.discardStaged(jobId);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.#currentJobId = undefined;
|
|
140
|
+
this.log.debug(`Job ${jobId} aborted`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Checks if there's a job currently in progress.
|
|
145
|
+
*/
|
|
146
|
+
hasJobInProgress(): boolean {
|
|
147
|
+
return this.#currentJobId !== undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
package/src/logs/log_service.ts
CHANGED
|
@@ -1,75 +1,53 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
3
|
-
import
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
6
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import {
|
|
7
|
-
DirectionalAppTaggingSecret,
|
|
8
|
-
PendingTaggedLog,
|
|
9
|
-
PrivateLogWithTxData,
|
|
10
|
-
PublicLogWithTxData,
|
|
11
|
-
SiloedTag,
|
|
12
|
-
Tag,
|
|
13
|
-
TxScopedL2Log,
|
|
14
|
-
} from '@aztec/stdlib/logs';
|
|
7
|
+
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
15
8
|
|
|
16
9
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
17
10
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
11
|
+
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
+
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
13
|
+
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
14
|
+
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
15
|
+
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
16
|
+
import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
|
|
24
17
|
|
|
25
18
|
export class LogService {
|
|
19
|
+
private log = createLogger('log_service');
|
|
20
|
+
|
|
26
21
|
constructor(
|
|
27
22
|
private readonly aztecNode: AztecNode,
|
|
28
|
-
private readonly
|
|
23
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
29
24
|
private readonly keyStore: KeyStore,
|
|
30
|
-
private readonly
|
|
31
|
-
private readonly
|
|
32
|
-
private readonly
|
|
25
|
+
private readonly capsuleStore: CapsuleStore,
|
|
26
|
+
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
27
|
+
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
28
|
+
private readonly addressStore: AddressStore,
|
|
33
29
|
) {}
|
|
34
30
|
|
|
35
31
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
36
32
|
return await Promise.all(
|
|
37
33
|
logRetrievalRequests.map(async request => {
|
|
38
|
-
// TODO(F-231): remove these internal functions and have node endpoints that do this instead
|
|
39
34
|
const [publicLog, privateLog] = await Promise.all([
|
|
40
|
-
this
|
|
41
|
-
this
|
|
35
|
+
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
36
|
+
this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress)),
|
|
42
37
|
]);
|
|
43
38
|
|
|
44
|
-
if (publicLog !== null) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return new LogRetrievalResponse(
|
|
52
|
-
publicLog.logPayload,
|
|
53
|
-
publicLog.txHash,
|
|
54
|
-
publicLog.uniqueNoteHashesInTx,
|
|
55
|
-
publicLog.firstNullifierInTx,
|
|
56
|
-
);
|
|
57
|
-
} else if (privateLog !== null) {
|
|
58
|
-
return new LogRetrievalResponse(
|
|
59
|
-
privateLog.logPayload,
|
|
60
|
-
privateLog.txHash,
|
|
61
|
-
privateLog.uniqueNoteHashesInTx,
|
|
62
|
-
privateLog.firstNullifierInTx,
|
|
39
|
+
if (publicLog !== null && privateLog !== null) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`,
|
|
63
42
|
);
|
|
64
|
-
} else {
|
|
65
|
-
return null;
|
|
66
43
|
}
|
|
44
|
+
|
|
45
|
+
return publicLog ?? privateLog;
|
|
67
46
|
}),
|
|
68
47
|
);
|
|
69
48
|
}
|
|
70
49
|
|
|
71
|
-
|
|
72
|
-
public async getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<PublicLogWithTxData | null> {
|
|
50
|
+
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
73
51
|
const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [tag]);
|
|
74
52
|
const logsForTag = logs[0];
|
|
75
53
|
|
|
@@ -84,24 +62,15 @@ export class LogService {
|
|
|
84
62
|
|
|
85
63
|
const scopedLog = logsForTag[0];
|
|
86
64
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// TODO(#9789): bundle this information in the `getLogsByTag` call.
|
|
90
|
-
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
91
|
-
if (txEffect == undefined) {
|
|
92
|
-
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return new PublicLogWithTxData(
|
|
96
|
-
scopedLog.log.getEmittedFieldsWithoutTag(),
|
|
65
|
+
return new LogRetrievalResponse(
|
|
66
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
97
67
|
scopedLog.txHash,
|
|
98
|
-
|
|
99
|
-
|
|
68
|
+
scopedLog.noteHashes,
|
|
69
|
+
scopedLog.firstNullifier,
|
|
100
70
|
);
|
|
101
71
|
}
|
|
102
72
|
|
|
103
|
-
|
|
104
|
-
public async getPrivateLogByTag(siloedTag: SiloedTag): Promise<PrivateLogWithTxData | null> {
|
|
73
|
+
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
105
74
|
const logs = await this.aztecNode.getPrivateLogsByTags([siloedTag]);
|
|
106
75
|
const logsForTag = logs[0];
|
|
107
76
|
|
|
@@ -116,243 +85,112 @@ export class LogService {
|
|
|
116
85
|
|
|
117
86
|
const scopedLog = logsForTag[0];
|
|
118
87
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// TODO(#9789): bundle this information in the `getLogsByTag` call.
|
|
122
|
-
const txEffect = await this.aztecNode.getTxEffect(scopedLog.txHash);
|
|
123
|
-
if (txEffect == undefined) {
|
|
124
|
-
throw new Error(`Unexpected: failed to retrieve tx effects for tx ${scopedLog.txHash} which is known to exist`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return new PrivateLogWithTxData(
|
|
128
|
-
scopedLog.log.getEmittedFieldsWithoutTag(),
|
|
88
|
+
return new LogRetrievalResponse(
|
|
89
|
+
scopedLog.logData.slice(1), // Skip the tag
|
|
129
90
|
scopedLog.txHash,
|
|
130
|
-
|
|
131
|
-
|
|
91
|
+
scopedLog.noteHashes,
|
|
92
|
+
scopedLog.firstNullifier,
|
|
132
93
|
);
|
|
133
94
|
}
|
|
134
95
|
|
|
135
|
-
// TODO(#17775): Replace this implementation of this function with one implementing an approach similar
|
|
136
|
-
// to syncSenderTaggingIndexes. Not done yet due to re-prioritization to devex and this doesn't directly affect
|
|
137
|
-
// devex.
|
|
138
96
|
public async syncTaggedLogs(
|
|
139
97
|
contractAddress: AztecAddress,
|
|
140
98
|
pendingTaggedLogArrayBaseSlot: Fr,
|
|
141
99
|
scopes?: AztecAddress[],
|
|
142
100
|
) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
let secretsAndWindows = indexedSecrets.map(indexedSecret => {
|
|
164
|
-
if (indexedSecret.index === undefined) {
|
|
165
|
-
return {
|
|
166
|
-
secret: indexedSecret.secret,
|
|
167
|
-
leftMostIndex: 0,
|
|
168
|
-
rightMostIndex: WINDOW_HALF_SIZE,
|
|
169
|
-
};
|
|
170
|
-
} else {
|
|
171
|
-
return {
|
|
172
|
-
secret: indexedSecret.secret,
|
|
173
|
-
leftMostIndex: Math.max(0, indexedSecret.index - WINDOW_HALF_SIZE),
|
|
174
|
-
rightMostIndex: indexedSecret.index + WINDOW_HALF_SIZE,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// As we iterate we store the largest index we have seen for a given secret to later on store it in the db.
|
|
180
|
-
const newLargestIndexMapToStore: { [k: string]: number } = {};
|
|
181
|
-
|
|
182
|
-
// The initial/unmodified indexes of the secrets stored in a key-value map where key is the directional app
|
|
183
|
-
// tagging secret.
|
|
184
|
-
const initialIndexesMap = getInitialIndexesMap(indexedSecrets);
|
|
185
|
-
|
|
186
|
-
while (secretsAndWindows.length > 0) {
|
|
187
|
-
const preTagsForTheWholeWindow = getPreTagsForTheWindow(secretsAndWindows);
|
|
188
|
-
const tagsForTheWholeWindow = await Promise.all(
|
|
189
|
-
preTagsForTheWholeWindow.map(async preTag => {
|
|
190
|
-
return SiloedTag.compute(await Tag.compute(preTag), contractAddress);
|
|
191
|
-
}),
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
// We store the new largest indexes we find in the iteration in the following map to later on construct
|
|
195
|
-
// a new set of secrets and windows to fetch logs for.
|
|
196
|
-
const newLargestIndexMapForIteration: { [k: string]: number } = {};
|
|
197
|
-
|
|
198
|
-
// Fetch the private logs for the tags and iterate over them
|
|
199
|
-
const logsByTags = await this.aztecNode.getPrivateLogsByTags(tagsForTheWholeWindow);
|
|
200
|
-
|
|
201
|
-
for (let logIndex = 0; logIndex < logsByTags.length; logIndex++) {
|
|
202
|
-
const logsByTag = logsByTags[logIndex];
|
|
203
|
-
if (logsByTag.length > 0) {
|
|
204
|
-
// We filter out the logs that are newer than the anchor block number of the tx currently being constructed
|
|
205
|
-
const filteredLogsByBlockNumber = logsByTag.filter(l => l.blockNumber <= maxBlockNumber);
|
|
206
|
-
|
|
207
|
-
// We store the logs in capsules (to later be obtained in Noir)
|
|
208
|
-
await this.#storePendingTaggedLogs(
|
|
101
|
+
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
102
|
+
|
|
103
|
+
// We only load logs from block up to and including the anchor block number
|
|
104
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
105
|
+
|
|
106
|
+
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
107
|
+
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
108
|
+
|
|
109
|
+
// For each recipient, fetch secrets, load logs, and store them.
|
|
110
|
+
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
111
|
+
await Promise.all(
|
|
112
|
+
recipients.map(async recipient => {
|
|
113
|
+
// Get all secrets for this recipient (one per sender)
|
|
114
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
115
|
+
|
|
116
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
117
|
+
const logArrays = await Promise.all(
|
|
118
|
+
secrets.map(secret =>
|
|
119
|
+
loadPrivateLogsForSenderRecipientPair(
|
|
120
|
+
secret,
|
|
209
121
|
contractAddress,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// a new largest index have been found.
|
|
217
|
-
const preTagCorrespondingToLog = preTagsForTheWholeWindow[logIndex];
|
|
218
|
-
const initialIndex = initialIndexesMap[preTagCorrespondingToLog.secret.toString()];
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
preTagCorrespondingToLog.index >= initialIndex &&
|
|
222
|
-
(newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] === undefined ||
|
|
223
|
-
preTagCorrespondingToLog.index >=
|
|
224
|
-
newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()])
|
|
225
|
-
) {
|
|
226
|
-
// We have found a new largest index so we store it for later processing (storing it in the db + fetching
|
|
227
|
-
// the difference of the window sets of current and the next iteration)
|
|
228
|
-
newLargestIndexMapForIteration[preTagCorrespondingToLog.secret.toString()] =
|
|
229
|
-
preTagCorrespondingToLog.index + 1;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
122
|
+
this.aztecNode,
|
|
123
|
+
this.recipientTaggingStore,
|
|
124
|
+
anchorBlockNumber,
|
|
125
|
+
),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
233
128
|
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
// so we fetch the logs only for the difference of the window sets.
|
|
237
|
-
const newSecretsAndWindows = [];
|
|
238
|
-
for (const [directionalAppTaggingSecret, newIndex] of Object.entries(newLargestIndexMapForIteration)) {
|
|
239
|
-
const maybeIndexedSecret = indexedSecrets.find(
|
|
240
|
-
indexedSecret => indexedSecret.secret.toString() === directionalAppTaggingSecret,
|
|
241
|
-
);
|
|
242
|
-
if (maybeIndexedSecret) {
|
|
243
|
-
newSecretsAndWindows.push({
|
|
244
|
-
secret: maybeIndexedSecret.secret,
|
|
245
|
-
// We set the left most index to the new index to avoid fetching the same logs again
|
|
246
|
-
leftMostIndex: newIndex,
|
|
247
|
-
rightMostIndex: newIndex + WINDOW_HALF_SIZE,
|
|
248
|
-
});
|
|
129
|
+
// Flatten all logs from all secrets
|
|
130
|
+
const allLogs = logArrays.flat();
|
|
249
131
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
throw new Error(
|
|
254
|
-
`Secret not found for directionalAppTaggingSecret ${directionalAppTaggingSecret}. This is a bug as it should never happen!`,
|
|
255
|
-
);
|
|
256
|
-
}
|
|
132
|
+
// Store the logs for this recipient
|
|
133
|
+
if (allLogs.length > 0) {
|
|
134
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
257
135
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
secretsAndWindows = newSecretsAndWindows;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// At this point we have processed all the logs for the recipient so we store the last used indexes in the db.
|
|
264
|
-
// newLargestIndexMapToStore contains "next" indexes to look for (one past the last found), so subtract 1 to get
|
|
265
|
-
// last used.
|
|
266
|
-
await this.recipientTaggingDataProvider.setLastUsedIndexes(
|
|
267
|
-
Object.entries(newLargestIndexMapToStore).map(([directionalAppTaggingSecret, index]) => ({
|
|
268
|
-
secret: DirectionalAppTaggingSecret.fromString(directionalAppTaggingSecret),
|
|
269
|
-
index: index - 1,
|
|
270
|
-
})),
|
|
271
|
-
);
|
|
272
|
-
}
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
273
138
|
}
|
|
274
139
|
|
|
275
|
-
|
|
276
|
-
* Returns the last used tagging indexes along with the directional app tagging secrets for a given recipient and all
|
|
277
|
-
* the senders in the address book.
|
|
278
|
-
* This method should be exposed as an oracle call to allow aztec.nr to perform the orchestration
|
|
279
|
-
* of the syncTaggedLogs and processTaggedLogs methods. However, it is not possible to do so at the moment,
|
|
280
|
-
* so we're keeping it private for now.
|
|
281
|
-
* @param contractAddress - The contract address to silo the secret for
|
|
282
|
-
* @param recipient - The address receiving the notes
|
|
283
|
-
* @returns A list of directional app tagging secrets along with the last used tagging indexes. If the corresponding
|
|
284
|
-
* secret was never used, the index is undefined.
|
|
285
|
-
* TODO(#17775): The naming here is broken as the function name does not reflect the return type. Make sure this gets
|
|
286
|
-
* fixed when implementing the linked issue.
|
|
287
|
-
*/
|
|
288
|
-
protected async getLastUsedTaggingIndexesForSenders(
|
|
140
|
+
async #getSecretsForSenders(
|
|
289
141
|
contractAddress: AztecAddress,
|
|
290
142
|
recipient: AztecAddress,
|
|
291
|
-
): Promise<
|
|
143
|
+
): Promise<DirectionalAppTaggingSecret[]> {
|
|
292
144
|
const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
|
|
293
145
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
294
146
|
|
|
295
147
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
296
148
|
// (recipient = us, sender = us)
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
149
|
+
const allSenders = [...(await this.senderAddressBookStore.getSenders()), ...(await this.keyStore.getAccounts())];
|
|
150
|
+
|
|
151
|
+
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
152
|
+
const deduplicatedSenders = Array.from(new Set(allSenders.map(sender => sender.toString()))).map(sender =>
|
|
153
|
+
AztecAddress.fromString(sender),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return Promise.all(
|
|
157
|
+
deduplicatedSenders.map(sender => {
|
|
303
158
|
return DirectionalAppTaggingSecret.compute(
|
|
304
159
|
recipientCompleteAddress,
|
|
305
160
|
recipientIvsk,
|
|
306
|
-
|
|
161
|
+
sender,
|
|
307
162
|
contractAddress,
|
|
308
163
|
recipient,
|
|
309
164
|
);
|
|
310
165
|
}),
|
|
311
166
|
);
|
|
312
|
-
const indexes = await this.recipientTaggingDataProvider.getLastUsedIndexes(secrets);
|
|
313
|
-
if (indexes.length !== secrets.length) {
|
|
314
|
-
throw new Error('Indexes and directional app tagging secrets have different lengths');
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return secrets.map((secret, i) => ({
|
|
318
|
-
secret,
|
|
319
|
-
index: indexes[i],
|
|
320
|
-
}));
|
|
321
167
|
}
|
|
322
168
|
|
|
323
|
-
|
|
169
|
+
#storePendingTaggedLogs(
|
|
324
170
|
contractAddress: AztecAddress,
|
|
325
171
|
capsuleArrayBaseSlot: Fr,
|
|
326
172
|
recipient: AztecAddress,
|
|
327
173
|
privateLogs: TxScopedL2Log[],
|
|
328
174
|
) {
|
|
329
|
-
// Build all pending tagged logs
|
|
330
|
-
const pendingTaggedLogs =
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const pendingTaggedLog = new PendingTaggedLog(
|
|
339
|
-
scopedLog.log.fields,
|
|
340
|
-
scopedLog.txHash,
|
|
341
|
-
txEffect.data.noteHashes,
|
|
342
|
-
txEffect.data.nullifiers[0],
|
|
343
|
-
recipient,
|
|
344
|
-
);
|
|
175
|
+
// Build all pending tagged logs from the scoped logs
|
|
176
|
+
const pendingTaggedLogs = privateLogs.map(scopedLog => {
|
|
177
|
+
const pendingTaggedLog = new PendingTaggedLog(
|
|
178
|
+
scopedLog.logData,
|
|
179
|
+
scopedLog.txHash,
|
|
180
|
+
scopedLog.noteHashes,
|
|
181
|
+
scopedLog.firstNullifier,
|
|
182
|
+
recipient,
|
|
183
|
+
);
|
|
345
184
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
);
|
|
185
|
+
return pendingTaggedLog.toFields();
|
|
186
|
+
});
|
|
349
187
|
|
|
350
188
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
351
|
-
return this.
|
|
189
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
352
190
|
}
|
|
353
191
|
|
|
354
192
|
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
355
|
-
const completeAddress = await this.
|
|
193
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
356
194
|
if (!completeAddress) {
|
|
357
195
|
throw new Error(
|
|
358
196
|
`No public key registered for address ${account}.
|