@aztec/pxe 0.0.1-commit.2ed92850 → 0.0.1-commit.358457c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +11 -5
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +174 -70
- 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 +2 -2
- 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 +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +10 -10
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +38 -26
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +36 -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 +66 -21
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +53 -29
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +84 -63
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +13 -12
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -18
- package/dest/entrypoints/client/bundle/index.d.ts +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -7
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +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 +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -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 +28 -9
- package/dest/events/event_service.d.ts +4 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +5 -6
- 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 +7 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +15 -25
- 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 +9 -9
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +2 -2
- 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 +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
- 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 +69 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +96 -62
- 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 +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +157 -72
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +13 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +147 -107
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +84 -61
- package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
- package/dest/storage/private_event_store/stored_private_event.js +2 -2
- 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 +4 -4
- 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/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 +4 -4
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -3
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +3 -3
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/package.json +25 -16
- package/src/access_scopes.ts +9 -0
- package/src/block_synchronizer/block_synchronizer.ts +23 -19
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +323 -128
- 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 +12 -12
- package/src/contract_function_simulator/oracle/oracle.ts +41 -24
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +88 -101
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +139 -70
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/{index.ts → helpers.ts} +21 -21
- package/src/debug/pxe_debug_utils.ts +63 -19
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +20 -32
- package/src/notes/note_service.ts +9 -10
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +2 -2
- 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 +25 -15
- package/src/private_kernel/private_kernel_oracle.ts +9 -9
- package/src/pxe.ts +189 -114
- 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 +186 -76
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +169 -132
- package/src/storage/private_event_store/private_event_store.ts +102 -81
- package/src/storage/private_event_store/stored_private_event.ts +3 -3
- 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 +31 -7
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +6 -6
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +2 -2
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +2 -2
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +3 -3
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
+
import type { NoteDao } from '@aztec/stdlib/note';
|
|
4
|
+
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
3
5
|
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
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 { NotesFilter } from '../notes_filter.js';
|
|
11
|
+
import type { AnchorBlockStore } from '../storage/index.js';
|
|
6
12
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
7
13
|
|
|
8
14
|
/**
|
|
@@ -10,18 +16,38 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
10
16
|
* No backwards compatibility or API stability should be expected. Use at your own risk.
|
|
11
17
|
*/
|
|
12
18
|
export class PXEDebugUtils {
|
|
13
|
-
#
|
|
19
|
+
#putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
|
|
20
|
+
#getSimulatorForTx!: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator;
|
|
21
|
+
#executeUtility!: (
|
|
22
|
+
contractFunctionSimulator: ContractFunctionSimulator,
|
|
23
|
+
call: FunctionCall,
|
|
24
|
+
authWitnesses: AuthWitness[] | undefined,
|
|
25
|
+
scopes: AccessScopes,
|
|
26
|
+
jobId: string,
|
|
27
|
+
) => Promise<any>;
|
|
14
28
|
|
|
15
29
|
constructor(
|
|
16
|
-
private
|
|
30
|
+
private contractSyncService: ContractSyncService,
|
|
17
31
|
private noteStore: NoteStore,
|
|
32
|
+
private blockStateSynchronizer: BlockSynchronizer,
|
|
33
|
+
private anchorBlockStore: AnchorBlockStore,
|
|
18
34
|
) {}
|
|
19
35
|
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
/** Not injected through constructor since they're are co-dependant */
|
|
37
|
+
public setPXEHelpers(
|
|
38
|
+
putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>,
|
|
39
|
+
getSimulatorForTx: (overrides?: { contracts?: ContractOverrides }) => ContractFunctionSimulator,
|
|
40
|
+
executeUtility: (
|
|
41
|
+
contractFunctionSimulator: ContractFunctionSimulator,
|
|
42
|
+
call: FunctionCall,
|
|
43
|
+
authWitnesses: AuthWitness[] | undefined,
|
|
44
|
+
scopes: AccessScopes,
|
|
45
|
+
jobId: string,
|
|
46
|
+
) => Promise<any>,
|
|
47
|
+
) {
|
|
48
|
+
this.#putJobInQueue = putJobInQueue;
|
|
49
|
+
this.#getSimulatorForTx = getSimulatorForTx;
|
|
50
|
+
this.#executeUtility = executeUtility;
|
|
25
51
|
}
|
|
26
52
|
|
|
27
53
|
/**
|
|
@@ -35,15 +61,33 @@ export class PXEDebugUtils {
|
|
|
35
61
|
* @param filter - The filter to apply to the notes.
|
|
36
62
|
* @returns The requested notes.
|
|
37
63
|
*/
|
|
38
|
-
public
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
public getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
65
|
+
return this.#putJobInQueue(async (jobId: string) => {
|
|
66
|
+
await this.blockStateSynchronizer.sync();
|
|
67
|
+
|
|
68
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
69
|
+
|
|
70
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
42
71
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
72
|
+
await this.contractSyncService.ensureContractSynced(
|
|
73
|
+
filter.contractAddress,
|
|
74
|
+
null,
|
|
75
|
+
async (privateSyncCall, execScopes) =>
|
|
76
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
77
|
+
anchorBlockHeader,
|
|
78
|
+
jobId,
|
|
79
|
+
filter.scopes,
|
|
80
|
+
);
|
|
46
81
|
|
|
47
|
-
|
|
82
|
+
return this.noteStore.getNotes(filter, jobId);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Triggers a sync of the PXE with the node.
|
|
88
|
+
* Blocks until the sync is complete.
|
|
89
|
+
*/
|
|
90
|
+
public sync(): Promise<void> {
|
|
91
|
+
return this.#putJobInQueue(() => this.blockStateSynchronizer.sync());
|
|
48
92
|
}
|
|
49
93
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
export * from '../../../access_scopes.js';
|
|
2
|
+
export * from '../../../notes_filter.js';
|
|
1
3
|
export * from '../../../pxe.js';
|
|
2
4
|
export * from '../../../config/index.js';
|
|
3
5
|
export * from '../../../error_enriching.js';
|
|
6
|
+
export * from '../../../contract_logging.js';
|
|
4
7
|
export * from '../../../storage/index.js';
|
|
5
8
|
export * from './utils.js';
|
|
6
9
|
export type { PXECreationOptions } from '../../pxe_creation_options.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/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,9 @@
|
|
|
1
|
+
export * from '../../../access_scopes.js';
|
|
2
|
+
export * from '../../../notes_filter.js';
|
|
1
3
|
export * from '../../../pxe.js';
|
|
2
4
|
export * from '../../../config/index.js';
|
|
3
5
|
export * from '../../../storage/index.js';
|
|
4
6
|
export * from '../../../error_enriching.js';
|
|
7
|
+
export * from '../../../contract_logging.js';
|
|
5
8
|
export * from './utils.js';
|
|
6
9
|
export { type PXECreationOptions } from '../../pxe_creation_options.js';
|
|
@@ -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;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from '../../access_scopes.js';
|
|
2
|
+
export * from '../../notes_filter.js';
|
|
1
3
|
export * from '../../pxe.js';
|
|
2
4
|
export * from '../../config/index.js';
|
|
3
5
|
export * from '../../error_enriching.js';
|
|
@@ -7,4 +9,4 @@ export { NoteService } from '../../notes/note_service.js';
|
|
|
7
9
|
export { ORACLE_VERSION } from '../../oracle_version.js';
|
|
8
10
|
export { type PXECreationOptions } from '../pxe_creation_options.js';
|
|
9
11
|
export { JobCoordinator } from '../../job_coordinator/job_coordinator.js';
|
|
10
|
-
export {
|
|
12
|
+
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,14 +3,13 @@ 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,
|
|
@@ -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,15 +1,15 @@
|
|
|
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
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
9
10
|
import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
|
|
10
11
|
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
11
12
|
import { AddressStore } from '../storage/address_store/address_store.js';
|
|
12
|
-
import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
13
13
|
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
14
14
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
15
15
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
@@ -20,18 +20,21 @@ import {
|
|
|
20
20
|
} from '../tagging/index.js';
|
|
21
21
|
|
|
22
22
|
export class LogService {
|
|
23
|
-
private log
|
|
23
|
+
private log: Logger;
|
|
24
24
|
|
|
25
25
|
constructor(
|
|
26
26
|
private readonly aztecNode: AztecNode,
|
|
27
|
-
private readonly
|
|
27
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
28
28
|
private readonly keyStore: KeyStore,
|
|
29
29
|
private readonly capsuleStore: CapsuleStore,
|
|
30
30
|
private readonly recipientTaggingStore: RecipientTaggingStore,
|
|
31
31
|
private readonly senderAddressBookStore: SenderAddressBookStore,
|
|
32
32
|
private readonly addressStore: AddressStore,
|
|
33
33
|
private readonly jobId: string,
|
|
34
|
-
|
|
34
|
+
bindings?: LoggerBindings,
|
|
35
|
+
) {
|
|
36
|
+
this.log = createLogger('pxe:log_service', bindings);
|
|
37
|
+
}
|
|
35
38
|
|
|
36
39
|
public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
|
|
37
40
|
return await Promise.all(
|
|
@@ -53,8 +56,7 @@ export class LogService {
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
56
|
-
const
|
|
57
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
59
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
58
60
|
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
59
61
|
this.aztecNode,
|
|
60
62
|
contractAddress,
|
|
@@ -83,8 +85,7 @@ export class LogService {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
86
|
-
const
|
|
87
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
88
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
88
89
|
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
89
90
|
const logsForTag = allLogsPerTag[0];
|
|
90
91
|
|
|
@@ -107,20 +108,15 @@ export class LogService {
|
|
|
107
108
|
);
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
public async
|
|
111
|
-
contractAddress
|
|
112
|
-
pendingTaggedLogArrayBaseSlot: Fr,
|
|
113
|
-
scopes?: AztecAddress[],
|
|
114
|
-
) {
|
|
115
|
-
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
111
|
+
public async fetchTaggedLogs(contractAddress: AztecAddress, pendingTaggedLogArrayBaseSlot: Fr, scopes: AccessScopes) {
|
|
112
|
+
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
116
113
|
|
|
117
114
|
// We only load logs from block up to and including the anchor block number
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
115
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
116
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
121
117
|
|
|
122
118
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
123
|
-
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
119
|
+
const recipients = scopes !== 'ALL_SCOPES' && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
124
120
|
|
|
125
121
|
// For each recipient, fetch secrets, load logs, and store them.
|
|
126
122
|
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
@@ -159,7 +155,10 @@ export class LogService {
|
|
|
159
155
|
contractAddress: AztecAddress,
|
|
160
156
|
recipient: AztecAddress,
|
|
161
157
|
): Promise<DirectionalAppTaggingSecret[]> {
|
|
162
|
-
const recipientCompleteAddress = await this
|
|
158
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
159
|
+
if (!recipientCompleteAddress) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
163
162
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
164
163
|
|
|
165
164
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
@@ -206,15 +205,4 @@ export class LogService {
|
|
|
206
205
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
207
206
|
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
208
207
|
}
|
|
209
|
-
|
|
210
|
-
async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
|
|
211
|
-
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
212
|
-
if (!completeAddress) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
`No public key registered for address ${account}.
|
|
215
|
-
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`,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
return completeAddress;
|
|
219
|
-
}
|
|
220
208
|
}
|
|
@@ -5,16 +5,16 @@ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdli
|
|
|
5
5
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
6
6
|
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
7
7
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
8
|
-
import type { TxHash } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { AccessScopes } from '../access_scopes.js';
|
|
11
11
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
12
|
|
|
13
13
|
export class NoteService {
|
|
14
14
|
constructor(
|
|
15
15
|
private readonly noteStore: NoteStore,
|
|
16
16
|
private readonly aztecNode: AztecNode,
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly anchorBlockHeader: BlockHeader,
|
|
18
18
|
private readonly jobId: string,
|
|
19
19
|
) {}
|
|
20
20
|
|
|
@@ -32,7 +32,7 @@ export class NoteService {
|
|
|
32
32
|
owner: AztecAddress | undefined,
|
|
33
33
|
storageSlot: Fr,
|
|
34
34
|
status: NoteStatus,
|
|
35
|
-
scopes
|
|
35
|
+
scopes: AccessScopes,
|
|
36
36
|
) {
|
|
37
37
|
const noteDaos = await this.noteStore.getNotes(
|
|
38
38
|
{
|
|
@@ -71,10 +71,10 @@ export class NoteService {
|
|
|
71
71
|
*
|
|
72
72
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
73
73
|
*/
|
|
74
|
-
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
75
|
-
const anchorBlockHash = await
|
|
74
|
+
public async syncNoteNullifiers(contractAddress: AztecAddress, scopes: AccessScopes): Promise<void> {
|
|
75
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
76
76
|
|
|
77
|
-
const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
|
|
77
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress, scopes }, this.jobId);
|
|
78
78
|
|
|
79
79
|
if (contractNotes.length === 0) {
|
|
80
80
|
return;
|
|
@@ -142,9 +142,8 @@ export class NoteService {
|
|
|
142
142
|
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
143
143
|
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
144
144
|
// logs up to the synced block making this only an additional safety check.
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
145
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
146
|
+
const anchorBlockHash = await this.anchorBlockHeader.hash();
|
|
148
147
|
|
|
149
148
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
150
149
|
// of other contracts, which would constitute a security breach.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
4
|
+
|
|
5
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A filter used to fetch notes.
|
|
9
|
+
* @remarks This filter is applied as an intersection of all its params.
|
|
10
|
+
*/
|
|
11
|
+
export type NotesFilter = {
|
|
12
|
+
/**
|
|
13
|
+
* The contract address the note belongs to.
|
|
14
|
+
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
15
|
+
*/
|
|
16
|
+
contractAddress: AztecAddress;
|
|
17
|
+
/** The owner of the note. */
|
|
18
|
+
owner?: AztecAddress;
|
|
19
|
+
/** The specific storage location of the note on the contract. */
|
|
20
|
+
storageSlot?: Fr;
|
|
21
|
+
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
22
|
+
status?: NoteStatus;
|
|
23
|
+
/** The siloed nullifier for the note. */
|
|
24
|
+
siloedNullifier?: Fr;
|
|
25
|
+
scopes: AccessScopes;
|
|
26
|
+
};
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
///
|
|
5
5
|
/// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
|
|
6
6
|
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
-
export const ORACLE_VERSION =
|
|
7
|
+
export const ORACLE_VERSION = 12;
|
|
8
8
|
|
|
9
9
|
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
10
10
|
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
11
11
|
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
12
|
-
export const ORACLE_INTERFACE_HASH = '
|
|
12
|
+
export const ORACLE_INTERFACE_HASH = '666a8a7fc697f72b29dbf0ae7464db269cf5afa019acac8861f814543147dbb4';
|