@aztec/pxe 0.0.1-commit.4ad48494d → 0.0.1-commit.4d3c002
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 +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +11 -5
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +38 -15
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -5
- 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 -9
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -6
- 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 +5 -10
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +38 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +64 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +187 -97
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -48
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +50 -81
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +66 -46
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +190 -99
- package/dest/contract_logging.d.ts +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +7 -5
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +45 -38
- package/dest/contract_sync/helpers.d.ts +2 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +9 -4
- package/dest/debug/pxe_debug_utils.d.ts +4 -3
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +6 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +34 -32
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/notes/note_service.d.ts +4 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -7
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +3 -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 +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- 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 +19 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +18 -14
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +73 -47
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -2
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/config/index.ts +1 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +60 -29
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -8
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -9
- package/src/contract_function_simulator/oracle/interfaces.ts +63 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +98 -0
- package/src/contract_function_simulator/oracle/oracle.ts +223 -139
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +58 -102
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +320 -122
- package/src/contract_logging.ts +52 -0
- package/src/contract_sync/contract_sync_service.ts +79 -54
- package/src/contract_sync/helpers.ts +8 -3
- package/src/debug/pxe_debug_utils.ts +8 -7
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +68 -51
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +19 -8
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +3 -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 +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +103 -61
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +4 -3
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
- 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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { type LogLevel, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { DebugLog } from '@aztec/stdlib/logs';
|
|
5
|
+
|
|
6
|
+
/** Resolves a contract address to a human-readable name, if available. */
|
|
7
|
+
export type ContractNameResolver = (address: AztecAddress) => Promise<string | undefined>;
|
|
8
|
+
export type CONTRACT_LOG_KIND = 'aztecnr' | 'user';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates a logger whose output is prefixed with `contract:<name>(<addrAbbrev>)`.
|
|
12
|
+
*/
|
|
13
|
+
export async function createContractLogger(
|
|
14
|
+
contractAddress: AztecAddress,
|
|
15
|
+
getContractName: ContractNameResolver,
|
|
16
|
+
kind: CONTRACT_LOG_KIND,
|
|
17
|
+
options?: { instanceId?: string },
|
|
18
|
+
): Promise<Logger> {
|
|
19
|
+
const addrAbbrev = contractAddress.toString().slice(0, 10);
|
|
20
|
+
const name = await getContractName(contractAddress);
|
|
21
|
+
|
|
22
|
+
const prefix = kind == 'aztecnr' ? 'aztecnr' : 'contract';
|
|
23
|
+
const module = name ? `${prefix}:${name}(${addrAbbrev})` : `${prefix}:Unknown(${addrAbbrev})`;
|
|
24
|
+
return createLogger(module, options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Formats and emits a single contract log message through the given logger.
|
|
29
|
+
*/
|
|
30
|
+
export function logContractMessage(logger: Logger, level: LogLevel, message: string, fields: Fr[]): void {
|
|
31
|
+
logger[level](applyStringFormatting(message, fields));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Displays debug logs collected during public function simulation,
|
|
36
|
+
* using the `contract:` prefixed logger format.
|
|
37
|
+
*/
|
|
38
|
+
export async function displayDebugLogs(debugLogs: DebugLog[], getContractName: ContractNameResolver): Promise<void> {
|
|
39
|
+
for (const log of debugLogs) {
|
|
40
|
+
const { kind, message } = stripAztecnrLogPrefix(log.message);
|
|
41
|
+
const logger = await createContractLogger(log.contractAddress, getContractName, kind);
|
|
42
|
+
logContractMessage(logger, log.level, message, log.fields);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function stripAztecnrLogPrefix(message: string): { kind: CONTRACT_LOG_KIND; message: string } {
|
|
47
|
+
if (message.startsWith('[aztec-nr] ')) {
|
|
48
|
+
return { kind: 'aztecnr', message: message.slice('[aztec-nr] '.length) };
|
|
49
|
+
} else {
|
|
50
|
+
return { kind: 'user', message };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -19,12 +19,12 @@ export class ContractSyncService implements StagedStore {
|
|
|
19
19
|
readonly storeName = 'contract_sync';
|
|
20
20
|
|
|
21
21
|
// Tracks contracts synced since last wipe. The cache is keyed per individual scope address
|
|
22
|
-
// (`contractAddress:scopeAddress`), or `contractAddress:*` for
|
|
22
|
+
// (`contractAddress:scopeAddress`), or `contractAddress:*` for all scopes (all accounts).
|
|
23
23
|
// The value is a promise that resolves when the contract is synced.
|
|
24
24
|
private syncedContracts: Map<string, Promise<void>> = new Map();
|
|
25
25
|
|
|
26
|
-
// Per-job
|
|
27
|
-
private
|
|
26
|
+
// Per-job excluded contract addresses - these contracts should not be synced.
|
|
27
|
+
private excludedFromSync: Map<string, Set<string>> = new Map();
|
|
28
28
|
|
|
29
29
|
constructor(
|
|
30
30
|
private aztecNode: AztecNode,
|
|
@@ -34,8 +34,8 @@ export class ContractSyncService implements StagedStore {
|
|
|
34
34
|
) {}
|
|
35
35
|
|
|
36
36
|
/** Sets contracts that should be skipped during sync for a specific job. */
|
|
37
|
-
|
|
38
|
-
this.
|
|
37
|
+
setExcludedFromSync(jobId: string, addresses: Set<string>): void {
|
|
38
|
+
this.excludedFromSync.set(jobId, addresses);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -45,71 +45,70 @@ export class ContractSyncService implements StagedStore {
|
|
|
45
45
|
* @param functionToInvokeAfterSync - The function selector that will be called after sync (used to validate it's
|
|
46
46
|
* not sync_state itself).
|
|
47
47
|
* @param utilityExecutor - Executor function for running the sync_state utility function.
|
|
48
|
-
* @param scopes -
|
|
48
|
+
* @param scopes - Access scopes to pass through to the utility executor (affects whose account's private state is discovered).
|
|
49
49
|
*/
|
|
50
50
|
async ensureContractSynced(
|
|
51
51
|
contractAddress: AztecAddress,
|
|
52
52
|
functionToInvokeAfterSync: FunctionSelector | null,
|
|
53
|
-
utilityExecutor: (call: FunctionCall, scopes:
|
|
53
|
+
utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<any>,
|
|
54
54
|
anchorBlockHeader: BlockHeader,
|
|
55
55
|
jobId: string,
|
|
56
|
-
scopes:
|
|
56
|
+
scopes: AztecAddress[],
|
|
57
57
|
): Promise<void> {
|
|
58
|
-
|
|
59
|
-
const overrides = this.overriddenContracts.get(jobId);
|
|
60
|
-
if (overrides?.has(contractAddress.toString())) {
|
|
58
|
+
if (this.#shouldSkipSync(jobId, contractAddress)) {
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const allScopesExisting = this.syncedContracts.get(allScopesKey);
|
|
67
|
-
if (allScopesExisting || (scopes && scopes.length == 0)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const unsyncedScopes = scopes?.filter(scope => !this.syncedContracts.has(toKey(contractAddress, scope)));
|
|
72
|
-
const unsyncedScopesKeys = toKeys(contractAddress, unsyncedScopes);
|
|
73
|
-
|
|
74
|
-
if (unsyncedScopesKeys.length > 0) {
|
|
75
|
-
// Start sync and store the promise for all unsynced scopes
|
|
76
|
-
const promise = this.#doSync(
|
|
62
|
+
this.#startSyncIfNeeded(contractAddress, scopes, scopesToSync =>
|
|
63
|
+
this.#syncContract(
|
|
77
64
|
contractAddress,
|
|
78
65
|
functionToInvokeAfterSync,
|
|
79
|
-
|
|
66
|
+
utilityExecutor,
|
|
80
67
|
anchorBlockHeader,
|
|
81
68
|
jobId,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
throw err;
|
|
86
|
-
});
|
|
87
|
-
unsyncedScopesKeys.forEach(key => this.syncedContracts.set(key, promise));
|
|
88
|
-
}
|
|
69
|
+
scopesToSync,
|
|
70
|
+
),
|
|
71
|
+
);
|
|
89
72
|
|
|
90
|
-
|
|
91
|
-
await Promise.all(promises);
|
|
73
|
+
await this.#awaitSync(contractAddress, scopes);
|
|
92
74
|
}
|
|
93
75
|
|
|
94
|
-
|
|
76
|
+
/** Clears sync cache entries for the given scopes of a contract. */
|
|
77
|
+
invalidateContractForScopes(contractAddress: AztecAddress, scopes: AztecAddress[]): void {
|
|
78
|
+
if (scopes.length === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
scopes.forEach(scope => this.syncedContracts.delete(toKey(contractAddress, scope)));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async #syncContract(
|
|
95
85
|
contractAddress: AztecAddress,
|
|
96
86
|
functionToInvokeAfterSync: FunctionSelector | null,
|
|
97
|
-
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
87
|
+
utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<any>,
|
|
98
88
|
anchorBlockHeader: BlockHeader,
|
|
99
89
|
jobId: string,
|
|
90
|
+
scopes: AztecAddress[],
|
|
100
91
|
): Promise<void> {
|
|
101
92
|
this.log.debug(`Syncing contract ${contractAddress}`);
|
|
93
|
+
|
|
102
94
|
await Promise.all([
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
// Call sync_state sequentially for each scope address — each invocation synchronizes one account's private
|
|
96
|
+
// state using scoped capsule arrays.
|
|
97
|
+
(async () => {
|
|
98
|
+
for (const scope of scopes) {
|
|
99
|
+
await syncState(
|
|
100
|
+
contractAddress,
|
|
101
|
+
this.contractStore,
|
|
102
|
+
functionToInvokeAfterSync,
|
|
103
|
+
utilityExecutor,
|
|
104
|
+
this.noteStore,
|
|
105
|
+
this.aztecNode,
|
|
106
|
+
anchorBlockHeader,
|
|
107
|
+
jobId,
|
|
108
|
+
scope,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
})(),
|
|
113
112
|
verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader),
|
|
114
113
|
]);
|
|
115
114
|
this.log.debug(`Contract ${contractAddress} synced`);
|
|
@@ -122,8 +121,8 @@ export class ContractSyncService implements StagedStore {
|
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
commit(jobId: string): Promise<void> {
|
|
125
|
-
// Clear
|
|
126
|
-
this.
|
|
124
|
+
// Clear excluded contracts for this job
|
|
125
|
+
this.excludedFromSync.delete(jobId);
|
|
127
126
|
return Promise.resolve();
|
|
128
127
|
}
|
|
129
128
|
|
|
@@ -131,15 +130,41 @@ export class ContractSyncService implements StagedStore {
|
|
|
131
130
|
// We clear the synced contracts cache here because, when the job is discarded, any associated database writes from
|
|
132
131
|
// the sync are also undone.
|
|
133
132
|
this.syncedContracts.clear();
|
|
134
|
-
this.
|
|
133
|
+
this.excludedFromSync.delete(jobId);
|
|
135
134
|
return Promise.resolve();
|
|
136
135
|
}
|
|
137
|
-
|
|
136
|
+
/** Returns true if sync should be skipped for this contract */
|
|
137
|
+
#shouldSkipSync(jobId: string, contractAddress: AztecAddress): boolean {
|
|
138
|
+
return !!this.excludedFromSync.get(jobId)?.has(contractAddress.toString());
|
|
139
|
+
}
|
|
138
140
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
/** If there are unsynced scopes, starts sync and stores the promise in cache with error cleanup. */
|
|
142
|
+
#startSyncIfNeeded(
|
|
143
|
+
contractAddress: AztecAddress,
|
|
144
|
+
scopes: AztecAddress[],
|
|
145
|
+
syncFn: (scopesToSync: AztecAddress[]) => Promise<void>,
|
|
146
|
+
): void {
|
|
147
|
+
const scopesToSync = scopes.filter(scope => !this.syncedContracts.has(toKey(contractAddress, scope)));
|
|
148
|
+
const keys = scopesToSync.map(scope => toKey(contractAddress, scope));
|
|
149
|
+
if (keys.length === 0) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const promise = syncFn(scopesToSync).catch(err => {
|
|
153
|
+
keys.forEach(key => this.syncedContracts.delete(key));
|
|
154
|
+
throw err;
|
|
155
|
+
});
|
|
156
|
+
keys.forEach(key => this.syncedContracts.set(key, promise));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Collects all relevant scope promises (including in-flight ones from concurrent calls) and awaits them. */
|
|
160
|
+
async #awaitSync(contractAddress: AztecAddress, scopes: AztecAddress[]): Promise<void> {
|
|
161
|
+
const promises = scopes
|
|
162
|
+
.map(scope => this.syncedContracts.get(toKey(contractAddress, scope)))
|
|
163
|
+
.filter(p => p !== undefined);
|
|
164
|
+
await Promise.all(promises);
|
|
165
|
+
}
|
|
141
166
|
}
|
|
142
167
|
|
|
143
|
-
function toKey(contract: AztecAddress, scope: AztecAddress
|
|
144
|
-
return
|
|
168
|
+
function toKey(contract: AztecAddress, scope: AztecAddress) {
|
|
169
|
+
return `${contract.toString()}:${scope.toString()}`;
|
|
145
170
|
}
|
|
@@ -42,15 +42,16 @@ export async function syncState(
|
|
|
42
42
|
contractAddress: AztecAddress,
|
|
43
43
|
contractStore: ContractStore,
|
|
44
44
|
functionToInvokeAfterSync: FunctionSelector | null,
|
|
45
|
-
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
45
|
+
utilityExecutor: (privateSyncCall: FunctionCall, scopes: AztecAddress[]) => Promise<any>,
|
|
46
46
|
noteStore: NoteStore,
|
|
47
47
|
aztecNode: AztecNode,
|
|
48
48
|
anchorBlockHeader: BlockHeader,
|
|
49
49
|
jobId: string,
|
|
50
|
+
scope: AztecAddress,
|
|
50
51
|
) {
|
|
51
52
|
// Protocol contracts don't have private state to sync
|
|
52
53
|
if (!isProtocolContract(contractAddress)) {
|
|
53
|
-
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [], contractAddress);
|
|
54
|
+
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [scope], contractAddress);
|
|
54
55
|
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
55
56
|
throw new Error(
|
|
56
57
|
'Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
@@ -58,10 +59,14 @@ export async function syncState(
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
const noteService = new NoteService(noteStore, aztecNode, anchorBlockHeader, jobId);
|
|
62
|
+
const scopes: AztecAddress[] = [scope];
|
|
61
63
|
|
|
62
64
|
// Both sync_state and syncNoteNullifiers interact with the note store, but running them in parallel is safe
|
|
63
65
|
// because note store is designed to handle concurrent operations.
|
|
64
|
-
await Promise.all([
|
|
66
|
+
await Promise.all([
|
|
67
|
+
utilityExecutor(syncStateFunctionCall, scopes),
|
|
68
|
+
noteService.syncNoteNullifiers(contractAddress, scopes),
|
|
69
|
+
]);
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { NoteDao
|
|
4
|
+
import type { NoteDao } from '@aztec/stdlib/note';
|
|
5
5
|
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
|
|
8
8
|
import type { ContractFunctionSimulator } from '../contract_function_simulator/contract_function_simulator.js';
|
|
9
9
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
10
|
+
import type { NotesFilter } from '../notes_filter.js';
|
|
10
11
|
import type { AnchorBlockStore } from '../storage/index.js';
|
|
11
12
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
13
|
|
|
@@ -17,11 +18,11 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
17
18
|
export class PXEDebugUtils {
|
|
18
19
|
#putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
|
|
19
20
|
#getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
|
|
20
|
-
#
|
|
21
|
+
#executeUtility!: (
|
|
21
22
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
22
23
|
call: FunctionCall,
|
|
23
24
|
authWitnesses: AuthWitness[] | undefined,
|
|
24
|
-
scopes: AztecAddress[]
|
|
25
|
+
scopes: AztecAddress[],
|
|
25
26
|
jobId: string,
|
|
26
27
|
) => Promise<any>;
|
|
27
28
|
|
|
@@ -36,17 +37,17 @@ export class PXEDebugUtils {
|
|
|
36
37
|
public setPXEHelpers(
|
|
37
38
|
putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
|
|
38
39
|
getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
|
|
39
|
-
|
|
40
|
+
executeUtility: (
|
|
40
41
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
41
42
|
call: FunctionCall,
|
|
42
43
|
authWitnesses: AuthWitness[] | undefined,
|
|
43
|
-
scopes: AztecAddress[]
|
|
44
|
+
scopes: AztecAddress[],
|
|
44
45
|
jobId: string,
|
|
45
46
|
) => Promise<any>,
|
|
46
47
|
) {
|
|
47
48
|
this.#putJobInQueue = putJobInQueue;
|
|
48
49
|
this.#getSimulatorForTx = getSimulatorForTx;
|
|
49
|
-
this.#
|
|
50
|
+
this.#executeUtility = executeUtility;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -72,7 +73,7 @@ export class PXEDebugUtils {
|
|
|
72
73
|
filter.contractAddress,
|
|
73
74
|
null,
|
|
74
75
|
async (privateSyncCall, execScopes) =>
|
|
75
|
-
await this.#
|
|
76
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
76
77
|
anchorBlockHeader,
|
|
77
78
|
jobId,
|
|
78
79
|
filter.scopes,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from '../../../notes_filter.js';
|
|
1
2
|
export * from '../../../pxe.js';
|
|
2
3
|
export * from '../../../config/index.js';
|
|
3
4
|
export * from '../../../error_enriching.js';
|
|
5
|
+
export * from '../../../contract_logging.js';
|
|
4
6
|
export * from '../../../storage/index.js';
|
|
5
7
|
export * from './utils.js';
|
|
6
8
|
export type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export * from '../../../notes_filter.js';
|
|
1
2
|
export * from '../../../pxe.js';
|
|
2
3
|
export * from '../../../config/index.js';
|
|
3
4
|
export * from '../../../storage/index.js';
|
|
4
5
|
export * from '../../../error_enriching.js';
|
|
6
|
+
export * from '../../../contract_logging.js';
|
|
5
7
|
export * from './utils.js';
|
|
6
8
|
export { type PXECreationOptions } from '../../pxe_creation_options.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
3
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
@@ -13,6 +14,7 @@ export class EventService {
|
|
|
13
14
|
private readonly aztecNode: AztecNode,
|
|
14
15
|
private readonly privateEventStore: PrivateEventStore,
|
|
15
16
|
private readonly jobId: string,
|
|
17
|
+
private readonly log = createLogger('pxe:event_service'),
|
|
16
18
|
) {}
|
|
17
19
|
|
|
18
20
|
public async validateAndStoreEvent(
|
|
@@ -36,19 +38,30 @@ export class EventService {
|
|
|
36
38
|
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
37
39
|
|
|
38
40
|
if (!txEffect) {
|
|
39
|
-
|
|
41
|
+
// We error out instead of just logging a warning and skipping the event because this would indicate a bug. This
|
|
42
|
+
// is because the node has already served info about this tx either when obtaining the log (TxScopedL2Log contain
|
|
43
|
+
// tx info) or when getting metadata for the offchain message (before the message got passed to `process_log`).
|
|
44
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} when processing an event.`);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
if (txEffect.l2BlockNumber > anchorBlockNumber) {
|
|
43
|
-
|
|
48
|
+
// We should never process a message from a tx past the anchor block. If we got here, a preprocessing step made
|
|
49
|
+
// a mistake.
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Obtained a newer tx effect for ${txHash} for an event validation request than the anchor block ${anchorBlockNumber}. This is a bug as smart contracts should not issue event validation requests for events from blocks newer than the anchor block.`,
|
|
52
|
+
);
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
// Find the index of the event commitment in the nullifiers array to determine event ordering within the tx
|
|
47
56
|
const eventIndexInTx = txEffect.data.nullifiers.findIndex(n => n.equals(siloedEventCommitment));
|
|
48
57
|
if (eventIndexInTx === -1) {
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
// Unlike in NoteService, this might not be a bug since the commitment hasn't been verified yet in the message
|
|
59
|
+
// processing pipeline. A malformed or malicious message could trigger this condition. Because of this we don't
|
|
60
|
+
// error out and we just show a warning.
|
|
61
|
+
this.log.warn(
|
|
62
|
+
`Skipping event whose commitment is not present in its tx. siloedEventCommitment=${siloedEventCommitment}, contract=${contractAddress}, selector=${selector}, eventCommitment=${eventCommitment}, txHash=${txHash}`,
|
|
51
63
|
);
|
|
64
|
+
return;
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
return this.privateEventStore.storePrivateEventLog(
|
package/src/logs/log_service.ts
CHANGED
|
@@ -3,13 +3,19 @@ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundatio
|
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ExtendedDirectionalAppTaggingSecret,
|
|
8
|
+
PendingTaggedLog,
|
|
9
|
+
SiloedTag,
|
|
10
|
+
Tag,
|
|
11
|
+
TxScopedL2Log,
|
|
12
|
+
} from '@aztec/stdlib/logs';
|
|
7
13
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
14
|
|
|
9
15
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
10
16
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
11
17
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
-
import {
|
|
18
|
+
import type { CapsuleService } from '../storage/capsule_store/capsule_service.js';
|
|
13
19
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
14
20
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
15
21
|
import {
|
|
@@ -25,7 +31,7 @@ export class LogService {
|
|
|
25
31
|
private readonly aztecNode: AztecNode,
|
|
26
32
|
private readonly anchorBlockHeader: BlockHeader,
|
|
27
33
|
private readonly keyStore: KeyStore,
|
|
28
|
-
private readonly
|
|
34
|
+
private readonly capsuleService: CapsuleService,
|
|
29
35
|
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
30
36
|
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
31
37
|
private readonly addressStore: AddressStore,
|
|
@@ -35,17 +41,26 @@ export class LogService {
|
|
|
35
41
|
this.log = createLogger('pxe:log_service', bindings);
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
public async
|
|
44
|
+
public async fetchLogsByTag(
|
|
45
|
+
contractAddress: AztecAddress,
|
|
46
|
+
logRetrievalRequests: LogRetrievalRequest[],
|
|
47
|
+
): Promise<(LogRetrievalResponse | null)[]> {
|
|
48
|
+
for (const request of logRetrievalRequests) {
|
|
49
|
+
if (!contractAddress.equals(request.contractAddress)) {
|
|
50
|
+
throw new Error(`Got a log retrieval request from ${request.contractAddress}, expected ${contractAddress}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
return await Promise.all(
|
|
40
55
|
logRetrievalRequests.map(async request => {
|
|
41
56
|
const [publicLog, privateLog] = await Promise.all([
|
|
42
57
|
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
43
|
-
this.#getPrivateLogByTag(await SiloedTag.
|
|
58
|
+
this.#getPrivateLogByTag(await SiloedTag.computeFromTagAndApp(request.tag, request.contractAddress)),
|
|
44
59
|
]);
|
|
45
60
|
|
|
46
61
|
if (publicLog !== null && privateLog !== null) {
|
|
47
|
-
|
|
48
|
-
`Found both a public and private log
|
|
62
|
+
this.log.warn(
|
|
63
|
+
`Found both a public and private log for tag ${request.tag} from contract ${request.contractAddress}. This may indicate a contract bug. Returning the public log.`,
|
|
49
64
|
);
|
|
50
65
|
}
|
|
51
66
|
|
|
@@ -67,9 +82,8 @@ export class LogService {
|
|
|
67
82
|
if (logsForTag.length === 0) {
|
|
68
83
|
return null;
|
|
69
84
|
} else if (logsForTag.length > 1) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`,
|
|
85
|
+
this.log.warn(
|
|
86
|
+
`Expected at most 1 public log for tag ${tag} and contract ${contractAddress.toString()}, got ${logsForTag.length}. This may indicate a contract bug. Returning the first log.`,
|
|
73
87
|
);
|
|
74
88
|
}
|
|
75
89
|
|
|
@@ -91,9 +105,8 @@ export class LogService {
|
|
|
91
105
|
if (logsForTag.length === 0) {
|
|
92
106
|
return null;
|
|
93
107
|
} else if (logsForTag.length > 1) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`,
|
|
108
|
+
this.log.warn(
|
|
109
|
+
`Expected at most 1 private log for tag ${siloedTag}, got ${logsForTag.length}. This may indicate a contract bug. Returning the first log.`,
|
|
97
110
|
);
|
|
98
111
|
}
|
|
99
112
|
|
|
@@ -110,7 +123,7 @@ export class LogService {
|
|
|
110
123
|
public async fetchTaggedLogs(
|
|
111
124
|
contractAddress: AztecAddress,
|
|
112
125
|
pendingTaggedLogArrayBaseSlot: Fr,
|
|
113
|
-
|
|
126
|
+
recipient: AztecAddress,
|
|
114
127
|
) {
|
|
115
128
|
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
116
129
|
|
|
@@ -118,46 +131,35 @@ export class LogService {
|
|
|
118
131
|
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
119
132
|
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
120
133
|
|
|
121
|
-
//
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.aztecNode,
|
|
138
|
-
this.recipientTaggingStore,
|
|
139
|
-
anchorBlockNumber,
|
|
140
|
-
anchorBlockHash,
|
|
141
|
-
this.jobId,
|
|
142
|
-
),
|
|
143
|
-
),
|
|
144
|
-
);
|
|
134
|
+
// Get all secrets for this recipient (one per sender)
|
|
135
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
136
|
+
|
|
137
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
138
|
+
const logArrays = await Promise.all(
|
|
139
|
+
secrets.map(secret =>
|
|
140
|
+
loadPrivateLogsForSenderRecipientPair(
|
|
141
|
+
secret,
|
|
142
|
+
this.aztecNode,
|
|
143
|
+
this.recipientTaggingStore,
|
|
144
|
+
anchorBlockNumber,
|
|
145
|
+
anchorBlockHash,
|
|
146
|
+
this.jobId,
|
|
147
|
+
),
|
|
148
|
+
),
|
|
149
|
+
);
|
|
145
150
|
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
// Flatten all logs from all secrets
|
|
152
|
+
const allLogs = logArrays.flat();
|
|
148
153
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
154
|
+
if (allLogs.length > 0) {
|
|
155
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
156
|
+
}
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
async #getSecretsForSenders(
|
|
158
160
|
contractAddress: AztecAddress,
|
|
159
161
|
recipient: AztecAddress,
|
|
160
|
-
): Promise<
|
|
162
|
+
): Promise<ExtendedDirectionalAppTaggingSecret[]> {
|
|
161
163
|
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
162
164
|
if (!recipientCompleteAddress) {
|
|
163
165
|
return [];
|
|
@@ -174,14 +176,24 @@ export class LogService {
|
|
|
174
176
|
);
|
|
175
177
|
|
|
176
178
|
return Promise.all(
|
|
177
|
-
deduplicatedSenders.map(sender => {
|
|
178
|
-
|
|
179
|
+
deduplicatedSenders.map(async sender => {
|
|
180
|
+
const secret = await ExtendedDirectionalAppTaggingSecret.compute(
|
|
179
181
|
recipientCompleteAddress,
|
|
180
182
|
recipientIvsk,
|
|
181
183
|
sender,
|
|
182
184
|
contractAddress,
|
|
183
185
|
recipient,
|
|
184
186
|
);
|
|
187
|
+
|
|
188
|
+
if (!secret) {
|
|
189
|
+
// Note that all senders originate from either the SenderAddressBookStore or the KeyStore.
|
|
190
|
+
// TODO(F-512): make sure we actually prevent registering invalid senders.
|
|
191
|
+
throw new Error(
|
|
192
|
+
`Failed to compute a tagging secret for sender ${sender} - this implies this is an invalid address, which should not happen as they have been previously registered in PXE.`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return secret;
|
|
185
197
|
}),
|
|
186
198
|
);
|
|
187
199
|
}
|
|
@@ -199,13 +211,18 @@ export class LogService {
|
|
|
199
211
|
scopedLog.txHash,
|
|
200
212
|
scopedLog.noteHashes,
|
|
201
213
|
scopedLog.firstNullifier,
|
|
202
|
-
recipient,
|
|
203
214
|
);
|
|
204
215
|
|
|
205
216
|
return pendingTaggedLog.toFields();
|
|
206
217
|
});
|
|
207
218
|
|
|
208
219
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
209
|
-
return this.
|
|
220
|
+
return this.capsuleService.appendToCapsuleArray(
|
|
221
|
+
contractAddress,
|
|
222
|
+
capsuleArrayBaseSlot,
|
|
223
|
+
pendingTaggedLogs,
|
|
224
|
+
this.jobId,
|
|
225
|
+
recipient,
|
|
226
|
+
);
|
|
210
227
|
}
|
|
211
228
|
}
|