@aztec/pxe 0.0.1-commit.023c3e5 → 0.0.1-commit.08c5969dc
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 +4 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +7 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +52 -27
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +169 -63
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -3
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +3 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +23 -11
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +73 -20
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +34 -15
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +64 -44
- 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/{index.js → helpers.js} +13 -12
- package/dest/debug/pxe_debug_utils.d.ts +12 -9
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +16 -15
- 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 +9 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +9 -1
- package/dest/entrypoints/server/index.d.ts +2 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -1
- package/dest/entrypoints/server/utils.js +9 -1
- package/dest/logs/log_service.d.ts +2 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +6 -13
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/pxe.d.ts +68 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +68 -42
- package/dest/storage/contract_store/contract_store.js +5 -5
- package/dest/storage/note_store/note_store.d.ts +1 -2
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +4 -2
- package/package.json +25 -16
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +315 -119
- package/src/contract_function_simulator/oracle/interfaces.ts +2 -2
- package/src/contract_function_simulator/oracle/oracle.ts +14 -7
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +95 -96
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +105 -44
- package/src/contract_sync/contract_sync_service.ts +145 -0
- package/src/contract_sync/{index.ts → helpers.ts} +15 -20
- package/src/debug/pxe_debug_utils.ts +46 -17
- package/src/entrypoints/client/bundle/utils.ts +9 -1
- package/src/entrypoints/client/lazy/utils.ts +9 -1
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/logs/log_service.ts +6 -15
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +146 -83
- package/src/storage/contract_store/contract_store.ts +4 -4
- package/src/storage/note_store/note_store.ts +5 -2
- package/dest/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
import type { StagedStore } from '../job_coordinator/job_coordinator.js';
|
|
8
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
9
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
10
|
+
import { syncState, verifyCurrentClassId } from './helpers.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Service for syncing the private state of contracts and verifying that the PXE holds the current class artifact.
|
|
14
|
+
* It uses a cache to avoid redundant sync operations - the cache is wiped when the anchor block changes.
|
|
15
|
+
*
|
|
16
|
+
* TODO: The StagedStore naming is broken here. Figure out a better name.
|
|
17
|
+
*/
|
|
18
|
+
export class ContractSyncService implements StagedStore {
|
|
19
|
+
readonly storeName = 'contract_sync';
|
|
20
|
+
|
|
21
|
+
// Tracks contracts synced since last wipe. The cache is keyed per individual scope address
|
|
22
|
+
// (`contractAddress:scopeAddress`), or `contractAddress:*` for undefined scopes (all accounts).
|
|
23
|
+
// The value is a promise that resolves when the contract is synced.
|
|
24
|
+
private syncedContracts: Map<string, Promise<void>> = new Map();
|
|
25
|
+
|
|
26
|
+
// Per-job overridden contract addresses - these contracts should not be synced.
|
|
27
|
+
private overriddenContracts: Map<string, Set<string>> = new Map();
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
private aztecNode: AztecNode,
|
|
31
|
+
private contractStore: ContractStore,
|
|
32
|
+
private noteStore: NoteStore,
|
|
33
|
+
private log: Logger,
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
/** Sets contracts that should be skipped during sync for a specific job. */
|
|
37
|
+
setOverriddenContracts(jobId: string, addresses: Set<string>): void {
|
|
38
|
+
this.overriddenContracts.set(jobId, addresses);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Ensures a contract's private state is synchronized and that the PXE holds the current class artifact.
|
|
43
|
+
* Uses a cache to avoid redundant sync operations - the cache is wiped when the anchor block changes.
|
|
44
|
+
* @param contractAddress - The address of the contract to sync.
|
|
45
|
+
* @param functionToInvokeAfterSync - The function selector that will be called after sync (used to validate it's
|
|
46
|
+
* not sync_state itself).
|
|
47
|
+
* @param utilityExecutor - Executor function for running the sync_state utility function.
|
|
48
|
+
* @param scopes - Scopes to pass through to the utility executor (affects which notes are discovered).
|
|
49
|
+
*/
|
|
50
|
+
async ensureContractSynced(
|
|
51
|
+
contractAddress: AztecAddress,
|
|
52
|
+
functionToInvokeAfterSync: FunctionSelector | null,
|
|
53
|
+
utilityExecutor: (call: FunctionCall, scopes: undefined | AztecAddress[]) => Promise<any>,
|
|
54
|
+
anchorBlockHeader: BlockHeader,
|
|
55
|
+
jobId: string,
|
|
56
|
+
scopes: undefined | AztecAddress[],
|
|
57
|
+
): Promise<void> {
|
|
58
|
+
// Skip sync if this contract has an override for this job (overrides are keyed by contract address only)
|
|
59
|
+
const overrides = this.overriddenContracts.get(jobId);
|
|
60
|
+
if (overrides?.has(contractAddress.toString())) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Skip sync if we already synced for "all scopes", or if we have an empty list of scopes
|
|
65
|
+
const allScopesKey = toKey(contractAddress, undefined);
|
|
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(
|
|
77
|
+
contractAddress,
|
|
78
|
+
functionToInvokeAfterSync,
|
|
79
|
+
call => utilityExecutor(call, unsyncedScopes),
|
|
80
|
+
anchorBlockHeader,
|
|
81
|
+
jobId,
|
|
82
|
+
).catch(err => {
|
|
83
|
+
// There was an error syncing the contract, so we remove it from the cache so that it can be retried.
|
|
84
|
+
unsyncedScopesKeys.forEach(key => this.syncedContracts.delete(key));
|
|
85
|
+
throw err;
|
|
86
|
+
});
|
|
87
|
+
unsyncedScopesKeys.forEach(key => this.syncedContracts.set(key, promise));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const promises = toKeys(contractAddress, scopes).map(key => this.syncedContracts.get(key)!);
|
|
91
|
+
await Promise.all(promises);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async #doSync(
|
|
95
|
+
contractAddress: AztecAddress,
|
|
96
|
+
functionToInvokeAfterSync: FunctionSelector | null,
|
|
97
|
+
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
98
|
+
anchorBlockHeader: BlockHeader,
|
|
99
|
+
jobId: string,
|
|
100
|
+
): Promise<void> {
|
|
101
|
+
this.log.debug(`Syncing contract ${contractAddress}`);
|
|
102
|
+
await Promise.all([
|
|
103
|
+
syncState(
|
|
104
|
+
contractAddress,
|
|
105
|
+
this.contractStore,
|
|
106
|
+
functionToInvokeAfterSync,
|
|
107
|
+
utilityExecutor,
|
|
108
|
+
this.noteStore,
|
|
109
|
+
this.aztecNode,
|
|
110
|
+
anchorBlockHeader,
|
|
111
|
+
jobId,
|
|
112
|
+
),
|
|
113
|
+
verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader),
|
|
114
|
+
]);
|
|
115
|
+
this.log.debug(`Contract ${contractAddress} synced`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Clears sync cache. Called by BlockSynchronizer when anchor block changes. */
|
|
119
|
+
wipe(): void {
|
|
120
|
+
this.log.debug(`Wiping contract sync cache (${this.syncedContracts.size} entries)`);
|
|
121
|
+
this.syncedContracts.clear();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
commit(jobId: string): Promise<void> {
|
|
125
|
+
// Clear overridden contracts for this job
|
|
126
|
+
this.overriddenContracts.delete(jobId);
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
discardStaged(jobId: string): Promise<void> {
|
|
131
|
+
// We clear the synced contracts cache here because, when the job is discarded, any associated database writes from
|
|
132
|
+
// the sync are also undone.
|
|
133
|
+
this.syncedContracts.clear();
|
|
134
|
+
this.overriddenContracts.delete(jobId);
|
|
135
|
+
return Promise.resolve();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function toKeys(contract: AztecAddress, scopes: undefined | AztecAddress[]) {
|
|
140
|
+
return scopes === undefined ? [toKey(contract, undefined)] : scopes.map(scope => toKey(contract, scope));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function toKey(contract: AztecAddress, scope: AztecAddress | undefined) {
|
|
144
|
+
return scope === undefined ? `${contract.toString()}:*` : `${contract.toString()}:${scope.toString()}`;
|
|
145
|
+
}
|
|
@@ -6,7 +6,9 @@ import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '
|
|
|
6
6
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
7
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
|
+
import { NoteService } from '../notes/note_service.js';
|
|
9
10
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
11
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
|
|
@@ -41,6 +43,10 @@ export async function syncState(
|
|
|
41
43
|
contractStore: ContractStore,
|
|
42
44
|
functionToInvokeAfterSync: FunctionSelector | null,
|
|
43
45
|
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
46
|
+
noteStore: NoteStore,
|
|
47
|
+
aztecNode: AztecNode,
|
|
48
|
+
anchorBlockHeader: BlockHeader,
|
|
49
|
+
jobId: string,
|
|
44
50
|
) {
|
|
45
51
|
// Protocol contracts don't have private state to sync
|
|
46
52
|
if (!isProtocolContract(contractAddress)) {
|
|
@@ -51,16 +57,23 @@ export async function syncState(
|
|
|
51
57
|
);
|
|
52
58
|
}
|
|
53
59
|
|
|
54
|
-
|
|
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)]);
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
/**
|
|
59
69
|
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
60
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.
|
|
61
74
|
* @param header - The header of the block at which to verify the current class id.
|
|
62
75
|
*/
|
|
63
|
-
async function verifyCurrentClassId(
|
|
76
|
+
export async function verifyCurrentClassId(
|
|
64
77
|
contractAddress: AztecAddress,
|
|
65
78
|
aztecNode: AztecNode,
|
|
66
79
|
contractStore: ContractStore,
|
|
@@ -78,21 +91,3 @@ async function verifyCurrentClassId(
|
|
|
78
91
|
);
|
|
79
92
|
}
|
|
80
93
|
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Ensures the contract's private state is synchronized and that the PXE holds the current class artifact for
|
|
84
|
-
* the contract.
|
|
85
|
-
*/
|
|
86
|
-
export async function ensureContractSynced(
|
|
87
|
-
contractAddress: AztecAddress,
|
|
88
|
-
functionToInvokeAfterSync: FunctionSelector | null,
|
|
89
|
-
utilityExecutor: (call: FunctionCall) => Promise<any>,
|
|
90
|
-
aztecNode: AztecNode,
|
|
91
|
-
contractStore: ContractStore,
|
|
92
|
-
header: BlockHeader,
|
|
93
|
-
): Promise<void> {
|
|
94
|
-
await Promise.all([
|
|
95
|
-
syncState(contractAddress, contractStore, functionToInvokeAfterSync, utilityExecutor),
|
|
96
|
-
verifyCurrentClassId(contractAddress, aztecNode, contractStore, header),
|
|
97
|
-
]);
|
|
98
|
-
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
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';
|
|
2
4
|
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
3
|
-
import type {
|
|
5
|
+
import type { ContractOverrides } from '@aztec/stdlib/tx';
|
|
4
6
|
|
|
5
7
|
import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
+
import type { ContractFunctionSimulator } from '../contract_function_simulator/contract_function_simulator.js';
|
|
9
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
8
10
|
import type { AnchorBlockStore } from '../storage/index.js';
|
|
9
11
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
10
12
|
|
|
@@ -13,20 +15,38 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
13
15
|
* No backwards compatibility or API stability should be expected. Use at your own risk.
|
|
14
16
|
*/
|
|
15
17
|
export class PXEDebugUtils {
|
|
16
|
-
#pxe!: PXE;
|
|
17
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>;
|
|
18
27
|
|
|
19
28
|
constructor(
|
|
20
|
-
private
|
|
29
|
+
private contractSyncService: ContractSyncService,
|
|
21
30
|
private noteStore: NoteStore,
|
|
22
31
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
23
32
|
private anchorBlockStore: AnchorBlockStore,
|
|
24
33
|
) {}
|
|
25
34
|
|
|
26
35
|
/** Not injected through constructor since they're are co-dependant */
|
|
27
|
-
public
|
|
28
|
-
|
|
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
|
+
) {
|
|
29
47
|
this.#putJobInQueue = putJobInQueue;
|
|
48
|
+
this.#getSimulatorForTx = getSimulatorForTx;
|
|
49
|
+
this.#simulateUtility = simulateUtility;
|
|
30
50
|
}
|
|
31
51
|
|
|
32
52
|
/**
|
|
@@ -40,17 +60,26 @@ export class PXEDebugUtils {
|
|
|
40
60
|
* @param filter - The filter to apply to the notes.
|
|
41
61
|
* @returns The requested notes.
|
|
42
62
|
*/
|
|
43
|
-
public
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await this.#pxe.simulateUtility(call);
|
|
63
|
+
public getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
64
|
+
return this.#putJobInQueue(async (jobId: string) => {
|
|
65
|
+
await this.blockStateSynchronizer.sync();
|
|
47
66
|
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
68
|
+
|
|
69
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
70
|
+
|
|
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
|
+
);
|
|
50
80
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return this.anchorBlockStore.getBlockHeader();
|
|
81
|
+
return this.noteStore.getNotes(filter, jobId);
|
|
82
|
+
});
|
|
54
83
|
}
|
|
55
84
|
|
|
56
85
|
/**
|
|
@@ -52,6 +52,14 @@ export async function createPXE(
|
|
|
52
52
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
53
53
|
|
|
54
54
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
55
|
-
const pxe = await PXE.create(
|
|
55
|
+
const pxe = await PXE.create({
|
|
56
|
+
node: aztecNode,
|
|
57
|
+
store,
|
|
58
|
+
proofCreator: prover,
|
|
59
|
+
simulator,
|
|
60
|
+
protocolContractsProvider,
|
|
61
|
+
config,
|
|
62
|
+
loggerOrSuffix: pxeLogger,
|
|
63
|
+
});
|
|
56
64
|
return pxe;
|
|
57
65
|
}
|
|
@@ -52,6 +52,14 @@ export async function createPXE(
|
|
|
52
52
|
const protocolContractsProvider = new LazyProtocolContractsProvider();
|
|
53
53
|
|
|
54
54
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
55
|
-
const pxe = await PXE.create(
|
|
55
|
+
const pxe = await PXE.create({
|
|
56
|
+
node: aztecNode,
|
|
57
|
+
store,
|
|
58
|
+
proofCreator: prover,
|
|
59
|
+
simulator,
|
|
60
|
+
protocolContractsProvider,
|
|
61
|
+
config,
|
|
62
|
+
loggerOrSuffix: pxeLogger,
|
|
63
|
+
});
|
|
56
64
|
return pxe;
|
|
57
65
|
}
|
|
@@ -7,4 +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 {
|
|
10
|
+
export { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
|
|
@@ -58,14 +58,14 @@ export async function createPXE(
|
|
|
58
58
|
const protocolContractsProvider = new BundledProtocolContractsProvider();
|
|
59
59
|
|
|
60
60
|
const pxeLogger = loggers.pxe ?? createLogger('pxe:service', { actor });
|
|
61
|
-
const pxe = await PXE.create(
|
|
62
|
-
aztecNode,
|
|
63
|
-
options.store,
|
|
64
|
-
prover,
|
|
61
|
+
const pxe = await PXE.create({
|
|
62
|
+
node: aztecNode,
|
|
63
|
+
store: options.store,
|
|
64
|
+
proofCreator: prover,
|
|
65
65
|
simulator,
|
|
66
66
|
protocolContractsProvider,
|
|
67
|
-
configWithContracts,
|
|
68
|
-
pxeLogger,
|
|
69
|
-
);
|
|
67
|
+
config: configWithContracts,
|
|
68
|
+
loggerOrSuffix: pxeLogger,
|
|
69
|
+
});
|
|
70
70
|
return pxe;
|
|
71
71
|
}
|
package/src/logs/log_service.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
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';
|
|
8
7
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
@@ -108,12 +107,12 @@ export class LogService {
|
|
|
108
107
|
);
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
public async
|
|
110
|
+
public async fetchTaggedLogs(
|
|
112
111
|
contractAddress: AztecAddress,
|
|
113
112
|
pendingTaggedLogArrayBaseSlot: Fr,
|
|
114
113
|
scopes?: AztecAddress[],
|
|
115
114
|
) {
|
|
116
|
-
this.log.verbose(
|
|
115
|
+
this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
|
|
117
116
|
|
|
118
117
|
// We only load logs from block up to and including the anchor block number
|
|
119
118
|
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
@@ -159,7 +158,10 @@ export class LogService {
|
|
|
159
158
|
contractAddress: AztecAddress,
|
|
160
159
|
recipient: AztecAddress,
|
|
161
160
|
): Promise<DirectionalAppTaggingSecret[]> {
|
|
162
|
-
const recipientCompleteAddress = await this
|
|
161
|
+
const recipientCompleteAddress = await this.addressStore.getCompleteAddress(recipient);
|
|
162
|
+
if (!recipientCompleteAddress) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
163
165
|
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
164
166
|
|
|
165
167
|
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
@@ -206,15 +208,4 @@ export class LogService {
|
|
|
206
208
|
// TODO: This looks like it could belong more at the oracle interface level
|
|
207
209
|
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
|
|
208
210
|
}
|
|
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
211
|
}
|
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';
|