@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.e2b2873ed
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/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +62 -16
- 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/contract_function_simulator/contract_function_simulator.d.ts +50 -28
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +71 -40
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -12
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +7 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +51 -29
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +43 -36
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +87 -23
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +61 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +108 -86
- package/dest/contract_sync/contract_sync_service.d.ts +42 -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 +28 -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 +22 -9
- 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/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -7
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +28 -9
- package/dest/events/event_service.d.ts +5 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +6 -7
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +6 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -28
- package/dest/notes/note_service.d.ts +6 -6
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -14
- 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/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 +2 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -3
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/pxe.d.ts +68 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +78 -48
- 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.js +6 -8
- package/dest/storage/contract_store/contract_store.d.ts +1 -2
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +27 -30
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +47 -50
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +278 -252
- 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 +17 -4
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +198 -147
- 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 +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +31 -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 +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
- 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 +46 -0
- package/dest/tagging/index.d.ts +2 -1
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -0
- 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 +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 +2 -2
- 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 +3 -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 +7 -4
- package/package.json +25 -16
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +76 -33
- package/src/config/index.ts +14 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +117 -87
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -11
- package/src/contract_function_simulator/oracle/oracle.ts +56 -26
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +122 -101
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +170 -95
- package/src/contract_sync/contract_sync_service.ts +145 -0
- package/src/contract_sync/helpers.ts +93 -0
- package/src/debug/pxe_debug_utils.ts +61 -17
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +5 -7
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +35 -28
- package/src/notes/note_service.ts +21 -20
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/private_kernel_execution_prover.ts +6 -3
- package/src/private_kernel/private_kernel_oracle.ts +2 -2
- package/src/pxe.ts +178 -85
- 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 +8 -8
- package/src/storage/contract_store/contract_store.ts +26 -35
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +317 -318
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +250 -190
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +31 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
- package/src/tagging/get_all_logs_by_tags.ts +68 -0
- package/src/tagging/index.ts +1 -0
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +11 -1
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +3 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +12 -3
- package/dest/tree_membership/tree_membership_service.d.ts +0 -50
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -75
- package/src/tree_membership/tree_membership_service.ts +0 -97
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ProtocolContractAddress, isProtocolContract } from '@aztec/protocol-contracts';
|
|
2
|
+
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
5
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
|
+
|
|
9
|
+
import { NoteService } from '../notes/note_service.js';
|
|
10
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
11
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
15
|
+
* from the instance is used.
|
|
16
|
+
* @param contractAddress - The address of the contract to read the class id for.
|
|
17
|
+
* @param instance - The instance of the contract.
|
|
18
|
+
* @param aztecNode - The Aztec node to query for storage.
|
|
19
|
+
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
20
|
+
* @returns The current class id.
|
|
21
|
+
*/
|
|
22
|
+
export async function readCurrentClassId(
|
|
23
|
+
contractAddress: AztecAddress,
|
|
24
|
+
instance: ContractInstance,
|
|
25
|
+
aztecNode: AztecNode,
|
|
26
|
+
header: BlockHeader,
|
|
27
|
+
) {
|
|
28
|
+
const blockHash = await header.hash();
|
|
29
|
+
const timestamp = header.globalVariables.timestamp;
|
|
30
|
+
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
31
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
32
|
+
aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
33
|
+
);
|
|
34
|
+
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
35
|
+
if (currentClassId.isZero()) {
|
|
36
|
+
currentClassId = instance.originalContractClassId;
|
|
37
|
+
}
|
|
38
|
+
return currentClassId;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function syncState(
|
|
42
|
+
contractAddress: AztecAddress,
|
|
43
|
+
contractStore: ContractStore,
|
|
44
|
+
functionToInvokeAfterSync: FunctionSelector | null,
|
|
45
|
+
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
46
|
+
noteStore: NoteStore,
|
|
47
|
+
aztecNode: AztecNode,
|
|
48
|
+
anchorBlockHeader: BlockHeader,
|
|
49
|
+
jobId: string,
|
|
50
|
+
) {
|
|
51
|
+
// Protocol contracts don't have private state to sync
|
|
52
|
+
if (!isProtocolContract(contractAddress)) {
|
|
53
|
+
const syncStateFunctionCall = await contractStore.getFunctionCall('sync_state', [], contractAddress);
|
|
54
|
+
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncStateFunctionCall.selector)) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'Forbidden `sync_state` invocation. `sync_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const noteService = new NoteService(noteStore, aztecNode, anchorBlockHeader, jobId);
|
|
61
|
+
|
|
62
|
+
// Both sync_state and syncNoteNullifiers interact with the note store, but running them in parallel is safe
|
|
63
|
+
// because note store is designed to handle concurrent operations.
|
|
64
|
+
await Promise.all([utilityExecutor(syncStateFunctionCall), noteService.syncNoteNullifiers(contractAddress)]);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
70
|
+
* provider (i.e. PXE's own storage).
|
|
71
|
+
* @param contractAddress - The address of the contract to verify.
|
|
72
|
+
* @param aztecNode - The Aztec node to query for storage.
|
|
73
|
+
* @param contractStore - The contract store to fetch the local instance from.
|
|
74
|
+
* @param header - The header of the block at which to verify the current class id.
|
|
75
|
+
*/
|
|
76
|
+
export async function verifyCurrentClassId(
|
|
77
|
+
contractAddress: AztecAddress,
|
|
78
|
+
aztecNode: AztecNode,
|
|
79
|
+
contractStore: ContractStore,
|
|
80
|
+
header: BlockHeader,
|
|
81
|
+
) {
|
|
82
|
+
const instance = await contractStore.getContractInstance(contractAddress);
|
|
83
|
+
if (!instance) {
|
|
84
|
+
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
88
|
+
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
1
4
|
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
5
|
+
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
2
6
|
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
7
|
+
import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
|
|
8
|
+
import type { ContractFunctionSimulator } from '../contract_function_simulator/contract_function_simulator.js';
|
|
9
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
10
|
+
import type { AnchorBlockStore } from '../storage/index.js';
|
|
5
11
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
6
12
|
|
|
7
13
|
/**
|
|
@@ -9,18 +15,38 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
9
15
|
* No backwards compatibility or API stability should be expected. Use at your own risk.
|
|
10
16
|
*/
|
|
11
17
|
export class PXEDebugUtils {
|
|
12
|
-
#
|
|
18
|
+
#putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
|
|
19
|
+
#getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
|
|
20
|
+
#simulateUtility!: (
|
|
21
|
+
contractFunctionSimulator: ContractFunctionSimulator,
|
|
22
|
+
call: FunctionCall,
|
|
23
|
+
authWitnesses: AuthWitness[] | undefined,
|
|
24
|
+
scopes: AztecAddress[] | undefined,
|
|
25
|
+
jobId: string,
|
|
26
|
+
) => Promise<any>;
|
|
13
27
|
|
|
14
28
|
constructor(
|
|
15
|
-
private
|
|
29
|
+
private contractSyncService: ContractSyncService,
|
|
16
30
|
private noteStore: NoteStore,
|
|
31
|
+
private blockStateSynchronizer: BlockSynchronizer,
|
|
32
|
+
private anchorBlockStore: AnchorBlockStore,
|
|
17
33
|
) {}
|
|
18
34
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
35
|
+
/** Not injected through constructor since they're are co-dependant */
|
|
36
|
+
public setPXEHelpers(
|
|
37
|
+
putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
|
|
38
|
+
getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
|
|
39
|
+
simulateUtility: (
|
|
40
|
+
contractFunctionSimulator: ContractFunctionSimulator,
|
|
41
|
+
call: FunctionCall,
|
|
42
|
+
authWitnesses: AuthWitness[] | undefined,
|
|
43
|
+
scopes: AztecAddress[] | undefined,
|
|
44
|
+
jobId: string,
|
|
45
|
+
) => Promise<any>,
|
|
46
|
+
) {
|
|
47
|
+
this.#putJobInQueue = putJobInQueue;
|
|
48
|
+
this.#getSimulatorForTx = getSimulatorForTx;
|
|
49
|
+
this.#simulateUtility = simulateUtility;
|
|
24
50
|
}
|
|
25
51
|
|
|
26
52
|
/**
|
|
@@ -34,15 +60,33 @@ export class PXEDebugUtils {
|
|
|
34
60
|
* @param filter - The filter to apply to the notes.
|
|
35
61
|
* @returns The requested notes.
|
|
36
62
|
*/
|
|
37
|
-
public
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
63
|
+
public getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
64
|
+
return this.#putJobInQueue(async (jobId: string) => {
|
|
65
|
+
await this.blockStateSynchronizer.sync();
|
|
66
|
+
|
|
67
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
68
|
+
|
|
69
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
41
70
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
71
|
+
await this.contractSyncService.ensureContractSynced(
|
|
72
|
+
filter.contractAddress,
|
|
73
|
+
null,
|
|
74
|
+
async (privateSyncCall, execScopes) =>
|
|
75
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
76
|
+
anchorBlockHeader,
|
|
77
|
+
jobId,
|
|
78
|
+
filter.scopes,
|
|
79
|
+
);
|
|
45
80
|
|
|
46
|
-
|
|
81
|
+
return this.noteStore.getNotes(filter, jobId);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Triggers a sync of the PXE with the node.
|
|
87
|
+
* Blocks until the sync is complete.
|
|
88
|
+
*/
|
|
89
|
+
public sync(): Promise<void> {
|
|
90
|
+
return this.#putJobInQueue(() => this.blockStateSynchronizer.sync());
|
|
47
91
|
}
|
|
48
92
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BBPrivateKernelProver } from '@aztec/bb-prover/client';
|
|
2
2
|
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
3
|
-
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
6
5
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
@@ -9,6 +8,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
9
8
|
|
|
10
9
|
import type { PXEConfig } from '../../../config/index.js';
|
|
11
10
|
import { PXE } from '../../../pxe.js';
|
|
11
|
+
import { PXE_DATA_SCHEMA_VERSION } from '../../../storage/metadata.js';
|
|
12
12
|
import type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -26,13 +26,7 @@ export async function createPXE(
|
|
|
26
26
|
config: PXEConfig,
|
|
27
27
|
options: PXECreationOptions = { loggers: {} },
|
|
28
28
|
) {
|
|
29
|
-
const
|
|
30
|
-
typeof options.useLogSuffix === 'boolean'
|
|
31
|
-
? options.useLogSuffix
|
|
32
|
-
? randomBytes(3).toString('hex')
|
|
33
|
-
: undefined
|
|
34
|
-
: options.useLogSuffix;
|
|
35
|
-
|
|
29
|
+
const actor = options.loggerActorLabel;
|
|
36
30
|
const loggers = options.loggers ?? {};
|
|
37
31
|
|
|
38
32
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
@@ -41,14 +35,13 @@ export async function createPXE(
|
|
|
41
35
|
l1Contracts,
|
|
42
36
|
} as PXEConfig;
|
|
43
37
|
|
|
44
|
-
const storeLogger = loggers.store
|
|
38
|
+
const storeLogger = loggers.store ?? createLogger('pxe:data:idb', { actor });
|
|
45
39
|
|
|
46
|
-
const store =
|
|
40
|
+
const store =
|
|
41
|
+
options.store ?? (await createStore('pxe_data', configWithContracts, PXE_DATA_SCHEMA_VERSION, storeLogger));
|
|
47
42
|
|
|
48
43
|
const simulator = options.simulator ?? new WASMSimulator();
|
|
49
|
-
const proverLogger = loggers.prover
|
|
50
|
-
? loggers.prover
|
|
51
|
-
: createLogger('pxe:bb:wasm:bundle' + (logSuffix ? `:${logSuffix}` : ''));
|
|
44
|
+
const proverLogger = loggers.prover ?? createLogger('pxe:bb:wasm:bundle', { actor });
|
|
52
45
|
|
|
53
46
|
let prover;
|
|
54
47
|
if (options.proverOrOptions instanceof BBPrivateKernelProver) {
|
|
@@ -58,7 +51,15 @@ export async function createPXE(
|
|
|
58
51
|
}
|
|
59
52
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
60
53
|
|
|
61
|
-
const pxeLogger = loggers.pxe
|
|
62
|
-
const pxe = await PXE.create(
|
|
54
|
+
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
55
|
+
const pxe = await PXE.create({
|
|
56
|
+
node: aztecNode,
|
|
57
|
+
store,
|
|
58
|
+
proofCreator: prover,
|
|
59
|
+
simulator,
|
|
60
|
+
protocolContractsProvider,
|
|
61
|
+
config,
|
|
62
|
+
loggerOrSuffix: pxeLogger,
|
|
63
|
+
});
|
|
63
64
|
return pxe;
|
|
64
65
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BBPrivateKernelProver } from '@aztec/bb-prover/client';
|
|
2
2
|
import { BBLazyPrivateKernelProver } from '@aztec/bb-prover/client/lazy';
|
|
3
|
-
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { createStore } from '@aztec/kv-store/indexeddb';
|
|
6
5
|
import { LazyProtocolContractsProvider } from '@aztec/protocol-contracts/providers/lazy';
|
|
@@ -9,6 +8,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
9
8
|
|
|
10
9
|
import type { PXEConfig } from '../../../config/index.js';
|
|
11
10
|
import { PXE } from '../../../pxe.js';
|
|
11
|
+
import { PXE_DATA_SCHEMA_VERSION } from '../../../storage/metadata.js';
|
|
12
12
|
import type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -17,7 +17,7 @@ import type { PXECreationOptions } from '../../pxe_creation_options.js';
|
|
|
17
17
|
*
|
|
18
18
|
* @param aztecNode - The AztecNode instance to be used by the server.
|
|
19
19
|
* @param config - The PXE Config to use
|
|
20
|
-
* @param
|
|
20
|
+
* @param options - (Optional) Optional information for creating an PXE.
|
|
21
21
|
* @returns A Promise that resolves to the started PXE instance.
|
|
22
22
|
*/
|
|
23
23
|
export async function createPXE(
|
|
@@ -25,12 +25,7 @@ export async function createPXE(
|
|
|
25
25
|
config: PXEConfig,
|
|
26
26
|
options: PXECreationOptions = { loggers: {} },
|
|
27
27
|
) {
|
|
28
|
-
const
|
|
29
|
-
typeof options.useLogSuffix === 'boolean'
|
|
30
|
-
? options.useLogSuffix
|
|
31
|
-
? randomBytes(3).toString('hex')
|
|
32
|
-
: undefined
|
|
33
|
-
: options.useLogSuffix;
|
|
28
|
+
const actor = options.loggerActorLabel;
|
|
34
29
|
|
|
35
30
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
36
31
|
const configWithContracts = {
|
|
@@ -40,14 +35,13 @@ export async function createPXE(
|
|
|
40
35
|
|
|
41
36
|
const loggers = options.loggers ?? {};
|
|
42
37
|
|
|
43
|
-
const storeLogger = loggers.store
|
|
38
|
+
const storeLogger = loggers.store ?? createLogger('pxe:data:idb', { actor });
|
|
44
39
|
|
|
45
|
-
const store =
|
|
40
|
+
const store =
|
|
41
|
+
options.store ?? (await createStore('pxe_data', configWithContracts, PXE_DATA_SCHEMA_VERSION, storeLogger));
|
|
46
42
|
|
|
47
43
|
const simulator = options.simulator ?? new WASMSimulator();
|
|
48
|
-
const proverLogger = loggers.prover
|
|
49
|
-
? loggers.prover
|
|
50
|
-
: createLogger('pxe:bb:wasm:bundle' + (logSuffix ? `:${logSuffix}` : ''));
|
|
44
|
+
const proverLogger = loggers.prover ?? createLogger('pxe:bb:wasm:bundle', { actor });
|
|
51
45
|
|
|
52
46
|
let prover;
|
|
53
47
|
if (options.proverOrOptions instanceof BBPrivateKernelProver) {
|
|
@@ -57,7 +51,15 @@ export async function createPXE(
|
|
|
57
51
|
}
|
|
58
52
|
const protocolContractsProvider = new LazyProtocolContractsProvider();
|
|
59
53
|
|
|
60
|
-
const pxeLogger = loggers.pxe
|
|
61
|
-
const pxe = await PXE.create(
|
|
54
|
+
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
55
|
+
const pxe = await PXE.create({
|
|
56
|
+
node: aztecNode,
|
|
57
|
+
store,
|
|
58
|
+
proofCreator: prover,
|
|
59
|
+
simulator,
|
|
60
|
+
protocolContractsProvider,
|
|
61
|
+
config,
|
|
62
|
+
loggerOrSuffix: pxeLogger,
|
|
63
|
+
});
|
|
62
64
|
return pxe;
|
|
63
65
|
}
|
|
@@ -6,7 +6,8 @@ import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
|
6
6
|
|
|
7
7
|
export type PXECreationOptions = {
|
|
8
8
|
loggers?: { store?: Logger; pxe?: Logger; prover?: Logger };
|
|
9
|
-
|
|
9
|
+
/** Actor label to include in log output (e.g., 'pxe-0', 'pxe-test'). */
|
|
10
|
+
loggerActorLabel?: string;
|
|
10
11
|
proverOrOptions?: PrivateKernelProver | BBPrivateKernelProverOptions;
|
|
11
12
|
store?: AztecAsyncKVStore;
|
|
12
13
|
simulator?: CircuitSimulator;
|
|
@@ -7,3 +7,4 @@ export { NoteService } from '../../notes/note_service.js';
|
|
|
7
7
|
export { ORACLE_VERSION } from '../../oracle_version.js';
|
|
8
8
|
export { type PXECreationOptions } from '../pxe_creation_options.js';
|
|
9
9
|
export { JobCoordinator } from '../../job_coordinator/job_coordinator.js';
|
|
10
|
+
export { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BBPrivateKernelProver } from '@aztec/bb-prover/client';
|
|
2
2
|
import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
|
|
3
|
-
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { createStore } from '@aztec/kv-store/lmdb-v2';
|
|
6
5
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
@@ -20,17 +19,13 @@ export async function createPXE(
|
|
|
20
19
|
config: PXEConfigWithoutDefaults,
|
|
21
20
|
options: PXECreationOptions = { loggers: {} },
|
|
22
21
|
) {
|
|
22
|
+
const actor = options.loggerActorLabel;
|
|
23
|
+
const recorderLogger = createLogger('simulator:acvm:recording', { actor });
|
|
23
24
|
const recorder = process.env.CIRCUIT_RECORD_DIR
|
|
24
|
-
? new FileCircuitRecorder(process.env.CIRCUIT_RECORD_DIR)
|
|
25
|
-
: new MemoryCircuitRecorder();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const logSuffix =
|
|
29
|
-
typeof options.useLogSuffix === 'boolean'
|
|
30
|
-
? options.useLogSuffix
|
|
31
|
-
? randomBytes(3).toString('hex')
|
|
32
|
-
: undefined
|
|
33
|
-
: options.useLogSuffix;
|
|
25
|
+
? new FileCircuitRecorder(process.env.CIRCUIT_RECORD_DIR, recorderLogger)
|
|
26
|
+
: new MemoryCircuitRecorder(recorderLogger);
|
|
27
|
+
const simulatorLogger = createLogger('wasm-simulator', { actor });
|
|
28
|
+
const simulator = new SimulatorRecorderWrapper(new WASMSimulator(simulatorLogger), recorder);
|
|
34
29
|
const loggers = options.loggers ?? {};
|
|
35
30
|
|
|
36
31
|
const { l1ChainId, l1ContractAddresses: l1Contracts, rollupVersion } = await aztecNode.getNodeInfo();
|
|
@@ -43,14 +38,15 @@ export async function createPXE(
|
|
|
43
38
|
};
|
|
44
39
|
|
|
45
40
|
if (!options.store) {
|
|
46
|
-
const storeLogger = loggers.store
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
const storeLogger = loggers.store ?? createLogger('pxe:data:lmdb', { actor });
|
|
42
|
+
options.store = await createStore(
|
|
43
|
+
'pxe_data',
|
|
44
|
+
PXE_DATA_SCHEMA_VERSION,
|
|
45
|
+
configWithContracts,
|
|
46
|
+
storeLogger.getBindings(),
|
|
47
|
+
);
|
|
50
48
|
}
|
|
51
|
-
const proverLogger = loggers.prover
|
|
52
|
-
? loggers.prover
|
|
53
|
-
: createLogger('pxe:bb:native' + (logSuffix ? `:${logSuffix}` : ''));
|
|
49
|
+
const proverLogger = loggers.prover ?? createLogger('pxe:bb:native', { actor });
|
|
54
50
|
|
|
55
51
|
let prover;
|
|
56
52
|
if (options.proverOrOptions instanceof BBPrivateKernelProver) {
|
|
@@ -61,15 +57,15 @@ export async function createPXE(
|
|
|
61
57
|
|
|
62
58
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
63
59
|
|
|
64
|
-
const pxeLogger = loggers.pxe
|
|
65
|
-
const pxe = await PXE.create(
|
|
66
|
-
aztecNode,
|
|
67
|
-
options.store,
|
|
68
|
-
prover,
|
|
60
|
+
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
61
|
+
const pxe = await PXE.create({
|
|
62
|
+
node: aztecNode,
|
|
63
|
+
store: options.store,
|
|
64
|
+
proofCreator: prover,
|
|
69
65
|
simulator,
|
|
70
66
|
protocolContractsProvider,
|
|
71
|
-
configWithContracts,
|
|
72
|
-
pxeLogger,
|
|
73
|
-
);
|
|
67
|
+
config: configWithContracts,
|
|
68
|
+
loggerOrSuffix: pxeLogger,
|
|
69
|
+
});
|
|
74
70
|
return pxe;
|
|
75
71
|
}
|
|
@@ -3,20 +3,19 @@ import type { EventSelector } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
5
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
9
8
|
import { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
10
9
|
|
|
11
10
|
export class EventService {
|
|
12
11
|
constructor(
|
|
13
|
-
private readonly
|
|
12
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
14
13
|
private readonly aztecNode: AztecNode,
|
|
15
14
|
private readonly privateEventStore: PrivateEventStore,
|
|
16
15
|
private readonly jobId: string,
|
|
17
16
|
) {}
|
|
18
17
|
|
|
19
|
-
public async
|
|
18
|
+
public async validateAndStoreEvent(
|
|
20
19
|
contractAddress: AztecAddress,
|
|
21
20
|
selector: EventSelector,
|
|
22
21
|
randomness: Fr,
|
|
@@ -29,13 +28,12 @@ export class EventService {
|
|
|
29
28
|
// (and thus we're less concerned about being ahead of the synced block), we use the synced block number to
|
|
30
29
|
// maintain consistent behavior in the PXE. Additionally, events should never be ahead of the synced block here
|
|
31
30
|
// since `fetchTaggedLogs` only processes logs up to the synced block.
|
|
32
|
-
const [
|
|
33
|
-
this.anchorBlockStore.getBlockHeader(),
|
|
31
|
+
const [siloedEventCommitment, txEffect] = await Promise.all([
|
|
34
32
|
siloNullifier(contractAddress, eventCommitment),
|
|
35
33
|
this.aztecNode.getTxEffect(txHash),
|
|
36
34
|
]);
|
|
37
35
|
|
|
38
|
-
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
36
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
39
37
|
|
|
40
38
|
if (!txEffect) {
|
|
41
39
|
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -40,7 +40,7 @@ export interface StagedStore {
|
|
|
40
40
|
* using a job queue with concurrency=1.
|
|
41
41
|
*/
|
|
42
42
|
export class JobCoordinator {
|
|
43
|
-
private readonly log
|
|
43
|
+
private readonly log: Logger;
|
|
44
44
|
|
|
45
45
|
/** The underlying KV store */
|
|
46
46
|
kvStore: AztecAsyncKVStore;
|
|
@@ -48,8 +48,9 @@ export class JobCoordinator {
|
|
|
48
48
|
#currentJobId: string | undefined;
|
|
49
49
|
#stores: Map<string, StagedStore> = new Map();
|
|
50
50
|
|
|
51
|
-
constructor(kvStore: AztecAsyncKVStore) {
|
|
51
|
+
constructor(kvStore: AztecAsyncKVStore, bindings?: LoggerBindings) {
|
|
52
52
|
this.kvStore = kvStore;
|
|
53
|
+
this.log = createLogger('pxe:job_coordinator', bindings);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
/**
|
package/src/logs/log_service.ts
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
6
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
7
6
|
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
7
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
9
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
10
10
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
11
11
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
13
12
|
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
14
13
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
15
14
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
16
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getAllPrivateLogsByTags,
|
|
17
|
+
getAllPublicLogsByTagsFromContract,
|
|
18
|
+
loadPrivateLogsForSenderRecipientPair,
|
|
19
|
+
} from '../tagging/index.js';
|
|
17
20
|
|
|
18
21
|
export class LogService {
|
|
19
|
-
private log
|
|
22
|
+
private log: Logger;
|
|
20
23
|
|
|
21
24
|
constructor(
|
|
22
25
|
private readonly aztecNode: AztecNode,
|
|
23
|
-
private readonly
|
|
26
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
24
27
|
private readonly keyStore: KeyStore,
|
|
25
28
|
private readonly capsuleStore: CapsuleStore,
|
|
26
29
|
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
27
30
|
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
28
31
|
private readonly addressStore: AddressStore,
|
|
29
32
|
private readonly jobId: string,
|
|
30
|
-
|
|
33
|
+
bindings?: LoggerBindings,
|
|
34
|
+
) {
|
|
35
|
+
this.log = createLogger('pxe:log_service', bindings);
|
|
36
|
+
}
|
|
31
37
|
|
|
32
38
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
33
39
|
return await Promise.all(
|
|
@@ -49,10 +55,16 @@ export class LogService {
|
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
58
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
59
|
+
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
60
|
+
this.aztecNode,
|
|
61
|
+
contractAddress,
|
|
62
|
+
[tag],
|
|
63
|
+
anchorBlockHash,
|
|
64
|
+
);
|
|
65
|
+
const logsForTag = allLogsPerTag[0];
|
|
54
66
|
|
|
55
|
-
if (logsForTag.length
|
|
67
|
+
if (logsForTag.length === 0) {
|
|
56
68
|
return null;
|
|
57
69
|
} else if (logsForTag.length > 1) {
|
|
58
70
|
// TODO(#11627): handle this case
|
|
@@ -72,10 +84,11 @@ export class LogService {
|
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
87
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
88
|
+
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
89
|
+
const logsForTag = allLogsPerTag[0];
|
|
77
90
|
|
|
78
|
-
if (logsForTag.length
|
|
91
|
+
if (logsForTag.length === 0) {
|
|
79
92
|
return null;
|
|
80
93
|
} else if (logsForTag.length > 1) {
|
|
81
94
|
// TODO(#11627): handle this case
|
|
@@ -94,15 +107,16 @@ export class LogService {
|
|
|
94
107
|
);
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
public async
|
|
110
|
+
public async fetchTaggedLogs(
|
|
98
111
|
contractAddress: AztecAddress,
|
|
99
112
|
pendingTaggedLogArrayBaseSlot: Fr,
|
|
100
113
|
scopes?: AztecAddress[],
|
|
101
114
|
) {
|
|
102
|
-
this.log.verbose(
|
|
115
|
+
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
103
116
|
|
|
104
117
|
// We only load logs from block up to and including the anchor block number
|
|
105
|
-
const anchorBlockNumber =
|
|
118
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
119
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
106
120
|
|
|
107
121
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
108
122
|
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
@@ -123,6 +137,7 @@ export class LogService {
|
|
|
123
137
|
this.aztecNode,
|
|
124
138
|
this.recipientTaggingStore,
|
|
125
139
|
anchorBlockNumber,
|
|
140
|
+
anchorBlockHash,
|
|
126
141
|
this.jobId,
|
|
127
142
|
),
|
|
128
143
|
),
|
|
@@ -143,7 +158,10 @@ export class LogService {
|
|
|
143
158
|
contractAddress: AztecAddress,
|
|
144
159
|
recipient: AztecAddress,
|
|
145
160
|
): Promise<DirectionalAppTaggingSecret[]> {
|
|
146
|
-
const recipientCompleteAddress = await this
|
|
161
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
162
|
+
if (!recipientCompleteAddress) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
147
165
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
148
166
|
|
|
149
167
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
@@ -190,15 +208,4 @@ export class LogService {
|
|
|
190
208
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
191
209
|
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
192
210
|
}
|
|
193
|
-
|
|
194
|
-
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
195
|
-
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
196
|
-
if (!completeAddress) {
|
|
197
|
-
throw new Error(
|
|
198
|
-
`No public key registered for address ${account}.
|
|
199
|
-
Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`,
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
return completeAddress;
|
|
203
|
-
}
|
|
204
211
|
}
|