@aztec/pxe 0.0.1-commit.3469e52 → 0.0.1-commit.59e663cd
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 +6 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +53 -13
- 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 +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +1 -4
- 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 +13 -10
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +27 -17
- 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 +9 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +16 -5
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +34 -36
- package/dest/contract_sync/index.d.ts +23 -0
- package/dest/contract_sync/index.d.ts.map +1 -0
- package/dest/contract_sync/index.js +54 -0
- package/dest/debug/pxe_debug_utils.d.ts +16 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +20 -10
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/events/event_service.d.ts +2 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +1 -1
- package/dest/logs/log_service.d.ts +1 -1
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +17 -11
- package/dest/notes/note_service.d.ts +4 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +11 -10
- 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_oracle.d.ts +3 -3
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +13 -11
- 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 +0 -12
- package/dest/storage/note_store/note_store.d.ts +43 -55
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +238 -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 +163 -135
- 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/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 +16 -16
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +55 -21
- package/src/config/index.ts +14 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +1 -9
- 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 +18 -9
- package/src/contract_function_simulator/oracle/oracle.ts +34 -21
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -6
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +53 -45
- package/src/contract_sync/index.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +26 -11
- package/src/entrypoints/server/index.ts +1 -0
- package/src/events/event_service.ts +1 -1
- package/src/logs/log_service.ts +24 -8
- package/src/notes/note_service.ts +18 -15
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/private_kernel_oracle.ts +2 -2
- package/src/pxe.ts +35 -12
- package/src/storage/contract_store/contract_store.ts +0 -20
- package/src/storage/note_store/note_store.ts +279 -313
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +214 -175
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- 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
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
1
2
|
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
3
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
2
4
|
|
|
5
|
+
import type { BlockSynchronizer } from '../block_synchronizer/block_synchronizer.js';
|
|
3
6
|
import type { PXE } from '../pxe.js';
|
|
4
7
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
8
|
+
import type { AnchorBlockStore } from '../storage/index.js';
|
|
5
9
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
6
10
|
|
|
7
11
|
/**
|
|
@@ -9,18 +13,20 @@ import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
|
9
13
|
* No backwards compatibility or API stability should be expected. Use at your own risk.
|
|
10
14
|
*/
|
|
11
15
|
export class PXEDebugUtils {
|
|
12
|
-
#pxe
|
|
16
|
+
#pxe!: PXE;
|
|
17
|
+
#putJobInQueue!: <T>(job: (jobId: string) => Promise<T>) => Promise<T>;
|
|
13
18
|
|
|
14
19
|
constructor(
|
|
15
20
|
private contractStore: ContractStore,
|
|
16
21
|
private noteStore: NoteStore,
|
|
22
|
+
private blockStateSynchronizer: BlockSynchronizer,
|
|
23
|
+
private anchorBlockStore: AnchorBlockStore,
|
|
17
24
|
) {}
|
|
18
25
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
*/
|
|
22
|
-
public setPXE(pxe: PXE) {
|
|
26
|
+
/** Not injected through constructor since they're are co-dependant */
|
|
27
|
+
public setPXE(pxe: PXE, putJobInQueue: <T>(job: (jobId: string) => Promise<T>) => Promise<T>) {
|
|
23
28
|
this.#pxe = pxe;
|
|
29
|
+
this.#putJobInQueue = putJobInQueue;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
/**
|
|
@@ -35,14 +41,23 @@ export class PXEDebugUtils {
|
|
|
35
41
|
* @returns The requested notes.
|
|
36
42
|
*/
|
|
37
43
|
public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
38
|
-
if (!this.#pxe) {
|
|
39
|
-
throw new Error('Cannot getNotes because no PXE is set');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
44
|
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
43
|
-
const call = await this.contractStore.getFunctionCall('
|
|
45
|
+
const call = await this.contractStore.getFunctionCall('sync_state', [], filter.contractAddress);
|
|
44
46
|
await this.#pxe.simulateUtility(call);
|
|
45
47
|
|
|
46
|
-
return this.noteStore.getNotes(filter);
|
|
48
|
+
return this.noteStore.getNotes(filter, randomBytes(8).toString('hex'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Returns the block header up to which the PXE has synced. */
|
|
52
|
+
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
53
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Triggers a sync of the PXE with the node.
|
|
58
|
+
* Blocks until the sync is complete.
|
|
59
|
+
*/
|
|
60
|
+
public sync(): Promise<void> {
|
|
61
|
+
return this.#putJobInQueue(() => this.blockStateSynchronizer.sync());
|
|
47
62
|
}
|
|
48
63
|
}
|
|
@@ -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 { syncState } from '../../contract_sync/index.js';
|
package/src/logs/log_service.ts
CHANGED
|
@@ -13,7 +13,11 @@ import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_sto
|
|
|
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';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
getAllPrivateLogsByTags,
|
|
18
|
+
getAllPublicLogsByTagsFromContract,
|
|
19
|
+
loadPrivateLogsForSenderRecipientPair,
|
|
20
|
+
} from '../tagging/index.js';
|
|
17
21
|
|
|
18
22
|
export class LogService {
|
|
19
23
|
private log = createLogger('log_service');
|
|
@@ -49,10 +53,17 @@ export class LogService {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
56
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
57
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
58
|
+
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
59
|
+
this.aztecNode,
|
|
60
|
+
contractAddress,
|
|
61
|
+
[tag],
|
|
62
|
+
anchorBlockHash,
|
|
63
|
+
);
|
|
64
|
+
const logsForTag = allLogsPerTag[0];
|
|
54
65
|
|
|
55
|
-
if (logsForTag.length
|
|
66
|
+
if (logsForTag.length === 0) {
|
|
56
67
|
return null;
|
|
57
68
|
} else if (logsForTag.length > 1) {
|
|
58
69
|
// TODO(#11627): handle this case
|
|
@@ -72,10 +83,12 @@ export class LogService {
|
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
86
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
87
|
+
const anchorBlockHash = await 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
|
|
@@ -102,7 +115,9 @@ export class LogService {
|
|
|
102
115
|
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
103
116
|
|
|
104
117
|
// We only load logs from block up to and including the anchor block number
|
|
105
|
-
const
|
|
118
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
119
|
+
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
120
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
106
121
|
|
|
107
122
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
108
123
|
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
@@ -123,6 +138,7 @@ export class LogService {
|
|
|
123
138
|
this.aztecNode,
|
|
124
139
|
this.recipientTaggingStore,
|
|
125
140
|
anchorBlockNumber,
|
|
141
|
+
anchorBlockHash,
|
|
126
142
|
this.jobId,
|
|
127
143
|
),
|
|
128
144
|
),
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
4
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
5
4
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
6
5
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
7
6
|
import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
|
|
@@ -16,6 +15,7 @@ export class NoteService {
|
|
|
16
15
|
private readonly noteStore: NoteStore,
|
|
17
16
|
private readonly aztecNode: AztecNode,
|
|
18
17
|
private readonly anchorBlockStore: AnchorBlockStore,
|
|
18
|
+
private readonly jobId: string,
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -34,13 +34,16 @@ export class NoteService {
|
|
|
34
34
|
status: NoteStatus,
|
|
35
35
|
scopes?: AztecAddress[],
|
|
36
36
|
) {
|
|
37
|
-
const noteDaos = await this.noteStore.getNotes(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
const noteDaos = await this.noteStore.getNotes(
|
|
38
|
+
{
|
|
39
|
+
contractAddress,
|
|
40
|
+
owner,
|
|
41
|
+
storageSlot,
|
|
42
|
+
status,
|
|
43
|
+
scopes,
|
|
44
|
+
},
|
|
45
|
+
this.jobId,
|
|
46
|
+
);
|
|
44
47
|
return noteDaos.map(
|
|
45
48
|
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
46
49
|
contractAddress,
|
|
@@ -69,9 +72,9 @@ export class NoteService {
|
|
|
69
72
|
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
70
73
|
*/
|
|
71
74
|
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
72
|
-
const anchorBlockHash =
|
|
75
|
+
const anchorBlockHash = await (await this.anchorBlockStore.getBlockHeader()).hash();
|
|
73
76
|
|
|
74
|
-
const contractNotes = await this.noteStore.getNotes({ contractAddress });
|
|
77
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
|
|
75
78
|
|
|
76
79
|
if (contractNotes.length === 0) {
|
|
77
80
|
return;
|
|
@@ -105,10 +108,10 @@ export class NoteService {
|
|
|
105
108
|
})
|
|
106
109
|
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
107
110
|
|
|
108
|
-
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
111
|
+
await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
public async
|
|
114
|
+
public async validateAndStoreNote(
|
|
112
115
|
contractAddress: AztecAddress,
|
|
113
116
|
owner: AztecAddress,
|
|
114
117
|
storageSlot: Fr,
|
|
@@ -141,7 +144,7 @@ export class NoteService {
|
|
|
141
144
|
// logs up to the synced block making this only an additional safety check.
|
|
142
145
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
143
146
|
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
144
|
-
const anchorBlockHash =
|
|
147
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
145
148
|
|
|
146
149
|
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
147
150
|
// of other contracts, which would constitute a security breach.
|
|
@@ -183,12 +186,12 @@ export class NoteService {
|
|
|
183
186
|
);
|
|
184
187
|
|
|
185
188
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
186
|
-
await this.noteStore.addNotes([noteDao], recipient);
|
|
189
|
+
await this.noteStore.addNotes([noteDao], recipient, this.jobId);
|
|
187
190
|
|
|
188
191
|
if (nullifierIndex !== undefined) {
|
|
189
192
|
// We found nullifier index which implies that the note has already been nullified.
|
|
190
193
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
191
|
-
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
|
|
194
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
}
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,8 +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 = 9;
|
|
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
|
-
/// which in turn implies that you need to update the ORACLE_VERSION constant
|
|
11
|
-
|
|
10
|
+
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
11
|
+
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
12
|
+
export const ORACLE_INTERFACE_HASH = '9866cc52510acaef75a3d47a0ed501fd9ff92b9d53b2c8a88c8a3ffd04ced81f';
|
|
@@ -7,7 +7,7 @@ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-type
|
|
|
7
7
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
8
8
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
9
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
import {
|
|
10
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
11
11
|
import {
|
|
12
12
|
type ContractInstanceWithAddress,
|
|
13
13
|
computeContractClassIdPreimage,
|
|
@@ -30,7 +30,7 @@ export class PrivateKernelOracle {
|
|
|
30
30
|
private contractStore: ContractStore,
|
|
31
31
|
private keyStore: KeyStore,
|
|
32
32
|
private node: AztecNode,
|
|
33
|
-
private blockHash:
|
|
33
|
+
private blockHash: BlockHash,
|
|
34
34
|
) {}
|
|
35
35
|
|
|
36
36
|
/** Retrieves the preimage of a contract address from the registered contract instances db. */
|
package/src/pxe.ts
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
} from '@aztec/stdlib/abi';
|
|
19
19
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
22
21
|
import {
|
|
23
22
|
CompleteAddress,
|
|
24
23
|
type ContractInstanceWithAddress,
|
|
@@ -59,8 +58,8 @@ import {
|
|
|
59
58
|
ContractFunctionSimulator,
|
|
60
59
|
generateSimulatedProvingResult,
|
|
61
60
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
|
-
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
63
61
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
62
|
+
import { ensureContractSynced, readCurrentClassId } from './contract_sync/index.js';
|
|
64
63
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
65
64
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
66
65
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
@@ -138,7 +137,7 @@ export class PXE {
|
|
|
138
137
|
const addressStore = new AddressStore(store);
|
|
139
138
|
const privateEventStore = new PrivateEventStore(store);
|
|
140
139
|
const contractStore = new ContractStore(store);
|
|
141
|
-
const noteStore =
|
|
140
|
+
const noteStore = new NoteStore(store);
|
|
142
141
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
143
142
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
144
143
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -158,9 +157,15 @@ export class PXE {
|
|
|
158
157
|
);
|
|
159
158
|
|
|
160
159
|
const jobCoordinator = new JobCoordinator(store);
|
|
161
|
-
jobCoordinator.registerStores([
|
|
160
|
+
jobCoordinator.registerStores([
|
|
161
|
+
capsuleStore,
|
|
162
|
+
senderTaggingStore,
|
|
163
|
+
recipientTaggingStore,
|
|
164
|
+
privateEventStore,
|
|
165
|
+
noteStore,
|
|
166
|
+
]);
|
|
162
167
|
|
|
163
|
-
const debugUtils = new PXEDebugUtils(contractStore, noteStore);
|
|
168
|
+
const debugUtils = new PXEDebugUtils(contractStore, noteStore, synchronizer, anchorBlockStore);
|
|
164
169
|
|
|
165
170
|
const jobQueue = new SerialQueue();
|
|
166
171
|
|
|
@@ -187,7 +192,7 @@ export class PXE {
|
|
|
187
192
|
debugUtils,
|
|
188
193
|
);
|
|
189
194
|
|
|
190
|
-
debugUtils.setPXE(pxe);
|
|
195
|
+
debugUtils.setPXE(pxe, pxe.#putInJobQueue.bind(pxe));
|
|
191
196
|
|
|
192
197
|
pxe.jobQueue.start();
|
|
193
198
|
|
|
@@ -289,6 +294,15 @@ export class PXE {
|
|
|
289
294
|
try {
|
|
290
295
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
291
296
|
|
|
297
|
+
await ensureContractSynced(
|
|
298
|
+
contractAddress,
|
|
299
|
+
functionSelector,
|
|
300
|
+
privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
301
|
+
this.node,
|
|
302
|
+
this.contractStore,
|
|
303
|
+
anchorBlockHeader,
|
|
304
|
+
);
|
|
305
|
+
|
|
292
306
|
const result = await contractFunctionSimulator.run(
|
|
293
307
|
txRequest,
|
|
294
308
|
contractAddress,
|
|
@@ -384,7 +398,7 @@ export class PXE {
|
|
|
384
398
|
config: PrivateKernelExecutionProverConfig,
|
|
385
399
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
386
400
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
387
|
-
const anchorBlockHash =
|
|
401
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
388
402
|
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
389
403
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
390
404
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
@@ -428,7 +442,6 @@ export class PXE {
|
|
|
428
442
|
}
|
|
429
443
|
|
|
430
444
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
431
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
432
445
|
return accountCompleteAddress;
|
|
433
446
|
}
|
|
434
447
|
|
|
@@ -948,8 +961,14 @@ export class PXE {
|
|
|
948
961
|
const functionTimer = new Timer();
|
|
949
962
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
950
963
|
|
|
951
|
-
await this.
|
|
952
|
-
|
|
964
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
965
|
+
await ensureContractSynced(
|
|
966
|
+
call.to,
|
|
967
|
+
call.selector,
|
|
968
|
+
privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
969
|
+
this.node,
|
|
970
|
+
this.contractStore,
|
|
971
|
+
anchorBlockHeader,
|
|
953
972
|
);
|
|
954
973
|
|
|
955
974
|
const executionResult = await this.#simulateUtility(
|
|
@@ -1008,15 +1027,19 @@ export class PXE {
|
|
|
1008
1027
|
await this.#putInJobQueue(async jobId => {
|
|
1009
1028
|
await this.blockStateSynchronizer.sync();
|
|
1010
1029
|
|
|
1011
|
-
|
|
1030
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
1031
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
1012
1032
|
|
|
1013
1033
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1014
1034
|
|
|
1015
|
-
await
|
|
1035
|
+
await ensureContractSynced(
|
|
1016
1036
|
filter.contractAddress,
|
|
1017
1037
|
null,
|
|
1018
1038
|
async privateSyncCall =>
|
|
1019
1039
|
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
1040
|
+
this.node,
|
|
1041
|
+
this.contractStore,
|
|
1042
|
+
anchorBlockHeader,
|
|
1020
1043
|
);
|
|
1021
1044
|
});
|
|
1022
1045
|
|
|
@@ -3,7 +3,6 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
6
|
-
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
7
6
|
import {
|
|
8
7
|
type ContractArtifact,
|
|
9
8
|
type FunctionAbi,
|
|
@@ -317,23 +316,4 @@ export class ContractStore {
|
|
|
317
316
|
returnTypes: functionDao.returnTypes,
|
|
318
317
|
};
|
|
319
318
|
}
|
|
320
|
-
|
|
321
|
-
// Synchronize target contract data
|
|
322
|
-
public async syncPrivateState(
|
|
323
|
-
contractAddress: AztecAddress,
|
|
324
|
-
functionToInvokeAfterSync: FunctionSelector | null,
|
|
325
|
-
utilityExecutor: (privateSyncCall: FunctionCall) => Promise<any>,
|
|
326
|
-
) {
|
|
327
|
-
// Protocol contracts don't have private state to sync
|
|
328
|
-
if (!isProtocolContract(contractAddress)) {
|
|
329
|
-
const syncPrivateStateFunctionCall = await this.getFunctionCall('sync_private_state', [], contractAddress);
|
|
330
|
-
if (functionToInvokeAfterSync && functionToInvokeAfterSync.equals(syncPrivateStateFunctionCall.selector)) {
|
|
331
|
-
throw new Error(
|
|
332
|
-
'Forbidden `sync_private_state` invocation. `sync_private_state` can only be invoked by PXE, manual execution can lead to inconsistencies.',
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return utilityExecutor(syncPrivateStateFunctionCall);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
319
|
}
|