@aztec/pxe 0.0.1-commit.d1f2d6c → 0.0.1-commit.d431d1c
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 -6
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +11 -51
- package/dest/config/index.d.ts +1 -3
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +0 -17
- 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 +4 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +4 -7
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -4
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +9 -19
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +6 -5
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -10
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -9
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +5 -17
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +6 -14
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +33 -31
- package/dest/debug/pxe_debug_utils.d.ts +1 -1
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +1 -2
- 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 +11 -18
- package/dest/notes/note_service.d.ts +2 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +6 -8
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +3 -4
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +7 -10
- package/dest/storage/note_store/note_store.d.ts +55 -43
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +252 -238
- package/dest/storage/private_event_store/private_event_store.d.ts +4 -17
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +135 -163
- package/dest/tagging/index.d.ts +1 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -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 +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +2 -3
- 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 +2 -5
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +2 -3
- 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 +8 -5
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -3
- 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 +4 -7
- package/dest/tree_membership/tree_membership_service.d.ts +50 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +75 -0
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +14 -53
- package/src/config/index.ts +0 -14
- package/src/contract_function_simulator/contract_function_simulator.ts +9 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +3 -12
- package/src/contract_function_simulator/oracle/oracle.ts +13 -26
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -20
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +6 -33
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +38 -46
- package/src/debug/pxe_debug_utils.ts +1 -2
- package/src/logs/log_service.ts +8 -25
- package/src/notes/note_service.ts +11 -15
- package/src/oracle_version.ts +3 -4
- package/src/pxe.ts +8 -32
- package/src/storage/note_store/note_store.ts +313 -279
- package/src/storage/private_event_store/private_event_store.ts +175 -214
- package/src/tagging/index.ts +0 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +1 -11
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +1 -7
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +1 -3
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +17 -5
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +3 -12
- package/src/tree_membership/tree_membership_service.ts +97 -0
- package/dest/storage/note_store/stored_note.d.ts +0 -16
- package/dest/storage/note_store/stored_note.d.ts.map +0 -1
- package/dest/storage/note_store/stored_note.js +0 -43
- package/dest/storage/private_event_store/stored_private_event.d.ts +0 -23
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +0 -1
- package/dest/storage/private_event_store/stored_private_event.js +0 -56
- package/dest/tagging/get_all_logs_by_tags.d.ts +0 -24
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +0 -1
- package/dest/tagging/get_all_logs_by_tags.js +0 -46
- package/src/storage/note_store/stored_note.ts +0 -48
- package/src/storage/private_event_store/stored_private_event.ts +0 -73
- package/src/tagging/get_all_logs_by_tags.ts +0 -68
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
2
1
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
2
|
import { Aes128 } from '@aztec/foundation/crypto/aes128';
|
|
4
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
4
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
6
5
|
import { LogLevels, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
7
|
-
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
8
6
|
import type { KeyStore } from '@aztec/key-store';
|
|
9
7
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
10
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -15,7 +13,6 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
|
15
13
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
16
14
|
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
17
15
|
import { deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
|
|
18
|
-
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
19
16
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
20
17
|
import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
21
18
|
import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
|
|
@@ -32,6 +29,7 @@ import type { NoteStore } from '../../storage/note_store/note_store.js';
|
|
|
32
29
|
import type { PrivateEventStore } from '../../storage/private_event_store/private_event_store.js';
|
|
33
30
|
import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
|
|
34
31
|
import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_address_book_store.js';
|
|
32
|
+
import { TreeMembershipService } from '../../tree_membership/tree_membership_service.js';
|
|
35
33
|
import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
|
|
36
34
|
import { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
|
|
37
35
|
import { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
|
|
@@ -96,29 +94,15 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
96
94
|
}
|
|
97
95
|
|
|
98
96
|
/**
|
|
99
|
-
* Fetches the index and sibling path of a leaf at a given block from
|
|
97
|
+
* Fetches the index and sibling path of a leaf at a given block from a given tree.
|
|
100
98
|
* @param blockHash - The block hash at which to get the membership witness.
|
|
99
|
+
* @param treeId - Id of the tree to get the sibling path from.
|
|
101
100
|
* @param leafValue - The leaf value
|
|
102
|
-
* @returns The
|
|
101
|
+
* @returns The index and sibling path concatenated [index, sibling_path]
|
|
103
102
|
*/
|
|
104
|
-
public
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
108
|
-
return this.aztecNode.getNoteHashMembershipWitness(blockHash, leafValue);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Fetches the index and sibling path of a leaf at a given block from the archive tree.
|
|
113
|
-
* @param blockHash - The block hash at which to get the membership witness.
|
|
114
|
-
* @param leafValue - The leaf value
|
|
115
|
-
* @returns The membership witness containing the leaf index and sibling path
|
|
116
|
-
*/
|
|
117
|
-
public utilityGetArchiveMembershipWitness(
|
|
118
|
-
blockHash: L2BlockHash,
|
|
119
|
-
leafValue: Fr,
|
|
120
|
-
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
121
|
-
return this.aztecNode.getArchiveMembershipWitness(blockHash, leafValue);
|
|
103
|
+
public utilityGetMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
|
|
104
|
+
const treeMembershipService = new TreeMembershipService(this.aztecNode);
|
|
105
|
+
return treeMembershipService.getMembershipWitness(blockHash, treeId, leafValue);
|
|
122
106
|
}
|
|
123
107
|
|
|
124
108
|
/**
|
|
@@ -127,11 +111,11 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
127
111
|
* @param nullifier - Nullifier we try to find witness for.
|
|
128
112
|
* @returns The nullifier membership witness (if found).
|
|
129
113
|
*/
|
|
130
|
-
public utilityGetNullifierMembershipWitness(
|
|
114
|
+
public async utilityGetNullifierMembershipWitness(
|
|
131
115
|
blockHash: L2BlockHash,
|
|
132
116
|
nullifier: Fr,
|
|
133
117
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
134
|
-
return this.aztecNode.getNullifierMembershipWitness(blockHash, nullifier);
|
|
118
|
+
return await this.aztecNode.getNullifierMembershipWitness(blockHash, nullifier);
|
|
135
119
|
}
|
|
136
120
|
|
|
137
121
|
/**
|
|
@@ -143,11 +127,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
143
127
|
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
144
128
|
* we are trying to prove non-inclusion for.
|
|
145
129
|
*/
|
|
146
|
-
public utilityGetLowNullifierMembershipWitness(
|
|
130
|
+
public async utilityGetLowNullifierMembershipWitness(
|
|
147
131
|
blockHash: L2BlockHash,
|
|
148
132
|
nullifier: Fr,
|
|
149
133
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
150
|
-
|
|
134
|
+
const treeMembershipService = new TreeMembershipService(this.aztecNode);
|
|
135
|
+
return await treeMembershipService.getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
151
136
|
}
|
|
152
137
|
|
|
153
138
|
/**
|
|
@@ -156,8 +141,12 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
156
141
|
* @param leafSlot - The slot of the public data tree to get the witness for.
|
|
157
142
|
* @returns - The witness
|
|
158
143
|
*/
|
|
159
|
-
public utilityGetPublicDataWitness(
|
|
160
|
-
|
|
144
|
+
public async utilityGetPublicDataWitness(
|
|
145
|
+
blockHash: L2BlockHash,
|
|
146
|
+
leafSlot: Fr,
|
|
147
|
+
): Promise<PublicDataWitness | undefined> {
|
|
148
|
+
const treeMembershipService = new TreeMembershipService(this.aztecNode);
|
|
149
|
+
return await treeMembershipService.getPublicDataWitness(blockHash, leafSlot);
|
|
161
150
|
}
|
|
162
151
|
|
|
163
152
|
/**
|
|
@@ -262,7 +251,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
262
251
|
offset: number,
|
|
263
252
|
status: NoteStatus,
|
|
264
253
|
): Promise<NoteData[]> {
|
|
265
|
-
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore
|
|
254
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
|
|
266
255
|
|
|
267
256
|
const dbNotes = await noteService.getNotes(this.contractAddress, owner, storageSlot, status, this.scopes);
|
|
268
257
|
return pickNotes<NoteData>(dbNotes, {
|
|
@@ -287,8 +276,9 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
287
276
|
*/
|
|
288
277
|
public async utilityCheckNullifierExists(innerNullifier: Fr) {
|
|
289
278
|
const nullifier = await siloNullifier(this.contractAddress, innerNullifier!);
|
|
290
|
-
const
|
|
291
|
-
|
|
279
|
+
const treeMembershipService = new TreeMembershipService(this.aztecNode);
|
|
280
|
+
const index = await treeMembershipService.getNullifierIndex(nullifier);
|
|
281
|
+
return index !== undefined;
|
|
292
282
|
}
|
|
293
283
|
|
|
294
284
|
/**
|
|
@@ -300,13 +290,14 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
300
290
|
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
301
291
|
*/
|
|
302
292
|
public async utilityGetL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
|
|
303
|
-
const
|
|
304
|
-
|
|
293
|
+
const treeMembershipService = new TreeMembershipService(this.aztecNode);
|
|
294
|
+
const [messageIndex, siblingPath] = await treeMembershipService.getL1ToL2MembershipWitness(
|
|
305
295
|
contractAddress,
|
|
306
296
|
messageHash,
|
|
307
297
|
secret,
|
|
308
298
|
);
|
|
309
299
|
|
|
300
|
+
// Assuming messageIndex is what you intended to use for the index in MessageLoadOracleInputs
|
|
310
301
|
return new MessageLoadOracleInputs(messageIndex, siblingPath);
|
|
311
302
|
}
|
|
312
303
|
|
|
@@ -323,18 +314,19 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
323
314
|
startStorageSlot: Fr,
|
|
324
315
|
numberOfElements: number,
|
|
325
316
|
) {
|
|
326
|
-
const
|
|
327
|
-
.fill(0)
|
|
328
|
-
.map((_, i) => new Fr(startStorageSlot.value + BigInt(i)));
|
|
317
|
+
const values = [];
|
|
329
318
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
)
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
`Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
|
|
336
|
-
);
|
|
319
|
+
// TODO: why do we serialize these requests? This should probably a single call
|
|
320
|
+
// Privacy considerations?
|
|
321
|
+
for (let i = 0n; i < numberOfElements; i++) {
|
|
322
|
+
const storageSlot = new Fr(startStorageSlot.value + i);
|
|
323
|
+
const value = await this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot);
|
|
337
324
|
|
|
325
|
+
this.log.debug(
|
|
326
|
+
`Oracle storage read: slot=${storageSlot.toString()} address-${contractAddress.toString()} value=${value}`,
|
|
327
|
+
);
|
|
328
|
+
values.push(value);
|
|
329
|
+
}
|
|
338
330
|
return values;
|
|
339
331
|
}
|
|
340
332
|
|
|
@@ -358,7 +350,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
358
350
|
this.jobId,
|
|
359
351
|
);
|
|
360
352
|
|
|
361
|
-
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore
|
|
353
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
|
|
362
354
|
|
|
363
355
|
// It is acceptable to run the following operations in parallel for several reasons:
|
|
364
356
|
// 1. syncTaggedLogs does not write to the note store — it only stores the pending tagged logs in a capsule array,
|
|
@@ -400,7 +392,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
400
392
|
await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId)
|
|
401
393
|
).map(EventValidationRequest.fromFields);
|
|
402
394
|
|
|
403
|
-
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore
|
|
395
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
|
|
404
396
|
const noteStorePromises = noteValidationRequests.map(request =>
|
|
405
397
|
noteService.storeNote(
|
|
406
398
|
request.contractAddress,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
1
|
import type { NoteDao, NotesFilter } from '@aztec/stdlib/note';
|
|
3
2
|
|
|
4
3
|
import type { PXE } from '../pxe.js';
|
|
@@ -44,6 +43,6 @@ export class PXEDebugUtils {
|
|
|
44
43
|
const call = await this.contractStore.getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
45
44
|
await this.#pxe.simulateUtility(call);
|
|
46
45
|
|
|
47
|
-
return this.noteStore.getNotes(filter
|
|
46
|
+
return this.noteStore.getNotes(filter);
|
|
48
47
|
}
|
|
49
48
|
}
|
package/src/logs/log_service.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { 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 { L2BlockHash } from '@aztec/stdlib/block';
|
|
6
5
|
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
7
6
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
8
7
|
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
@@ -14,11 +13,7 @@ import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_sto
|
|
|
14
13
|
import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
15
14
|
import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
|
|
16
15
|
import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
|
|
17
|
-
import {
|
|
18
|
-
getAllPrivateLogsByTags,
|
|
19
|
-
getAllPublicLogsByTagsFromContract,
|
|
20
|
-
loadPrivateLogsForSenderRecipientPair,
|
|
21
|
-
} from '../tagging/index.js';
|
|
16
|
+
import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
|
|
22
17
|
|
|
23
18
|
export class LogService {
|
|
24
19
|
private log = createLogger('log_service');
|
|
@@ -54,17 +49,10 @@ export class LogService {
|
|
|
54
49
|
}
|
|
55
50
|
|
|
56
51
|
async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
|
|
60
|
-
this.aztecNode,
|
|
61
|
-
contractAddress,
|
|
62
|
-
[tag],
|
|
63
|
-
anchorBlockHash,
|
|
64
|
-
);
|
|
65
|
-
const logsForTag = allLogsPerTag[0];
|
|
52
|
+
const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [tag]);
|
|
53
|
+
const logsForTag = logs[0];
|
|
66
54
|
|
|
67
|
-
if (logsForTag.length
|
|
55
|
+
if (logsForTag.length == 0) {
|
|
68
56
|
return null;
|
|
69
57
|
} else if (logsForTag.length > 1) {
|
|
70
58
|
// TODO(#11627): handle this case
|
|
@@ -84,12 +72,10 @@ export class LogService {
|
|
|
84
72
|
}
|
|
85
73
|
|
|
86
74
|
async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
|
|
90
|
-
const logsForTag = allLogsPerTag[0];
|
|
75
|
+
const logs = await this.aztecNode.getPrivateLogsByTags([siloedTag]);
|
|
76
|
+
const logsForTag = logs[0];
|
|
91
77
|
|
|
92
|
-
if (logsForTag.length
|
|
78
|
+
if (logsForTag.length == 0) {
|
|
93
79
|
return null;
|
|
94
80
|
} else if (logsForTag.length > 1) {
|
|
95
81
|
// TODO(#11627): handle this case
|
|
@@ -116,9 +102,7 @@ export class LogService {
|
|
|
116
102
|
this.log.verbose('Searching for tagged logs', { contract: contractAddress });
|
|
117
103
|
|
|
118
104
|
// We only load logs from block up to and including the anchor block number
|
|
119
|
-
const
|
|
120
|
-
const anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
121
|
-
const anchorBlockHash = L2BlockHash.fromField(await anchorBlockHeader.hash());
|
|
105
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
122
106
|
|
|
123
107
|
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
124
108
|
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
@@ -139,7 +123,6 @@ export class LogService {
|
|
|
139
123
|
this.aztecNode,
|
|
140
124
|
this.recipientTaggingStore,
|
|
141
125
|
anchorBlockNumber,
|
|
142
|
-
anchorBlockHash,
|
|
143
126
|
this.jobId,
|
|
144
127
|
),
|
|
145
128
|
),
|
|
@@ -16,7 +16,6 @@ export class NoteService {
|
|
|
16
16
|
private readonly noteStore: NoteStore,
|
|
17
17
|
private readonly aztecNode: AztecNode,
|
|
18
18
|
private readonly anchorBlockStore: AnchorBlockStore,
|
|
19
|
-
private readonly jobId: string,
|
|
20
19
|
) {}
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -35,16 +34,13 @@ export class NoteService {
|
|
|
35
34
|
status: NoteStatus,
|
|
36
35
|
scopes?: AztecAddress[],
|
|
37
36
|
) {
|
|
38
|
-
const noteDaos = await this.noteStore.getNotes(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
this.jobId,
|
|
47
|
-
);
|
|
37
|
+
const noteDaos = await this.noteStore.getNotes({
|
|
38
|
+
contractAddress,
|
|
39
|
+
owner,
|
|
40
|
+
storageSlot,
|
|
41
|
+
status,
|
|
42
|
+
scopes,
|
|
43
|
+
});
|
|
48
44
|
return noteDaos.map(
|
|
49
45
|
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
|
|
50
46
|
contractAddress,
|
|
@@ -75,7 +71,7 @@ export class NoteService {
|
|
|
75
71
|
public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
|
|
76
72
|
const anchorBlockHash = L2BlockHash.fromField(await (await this.anchorBlockStore.getBlockHeader()).hash());
|
|
77
73
|
|
|
78
|
-
const contractNotes = await this.noteStore.getNotes({ contractAddress }
|
|
74
|
+
const contractNotes = await this.noteStore.getNotes({ contractAddress });
|
|
79
75
|
|
|
80
76
|
if (contractNotes.length === 0) {
|
|
81
77
|
return;
|
|
@@ -109,7 +105,7 @@ export class NoteService {
|
|
|
109
105
|
})
|
|
110
106
|
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
111
107
|
|
|
112
|
-
await this.noteStore.applyNullifiers(foundNullifiers
|
|
108
|
+
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
113
109
|
}
|
|
114
110
|
|
|
115
111
|
public async storeNote(
|
|
@@ -187,12 +183,12 @@ export class NoteService {
|
|
|
187
183
|
);
|
|
188
184
|
|
|
189
185
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
190
|
-
await this.noteStore.addNotes([noteDao], recipient
|
|
186
|
+
await this.noteStore.addNotes([noteDao], recipient);
|
|
191
187
|
|
|
192
188
|
if (nullifierIndex !== undefined) {
|
|
193
189
|
// We found nullifier index which implies that the note has already been nullified.
|
|
194
190
|
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
195
|
-
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]
|
|
191
|
+
await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
|
|
196
192
|
}
|
|
197
193
|
}
|
|
198
194
|
}
|
package/src/oracle_version.ts
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
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 = 6;
|
|
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
|
-
|
|
12
|
-
export const ORACLE_INTERFACE_HASH = 'f13e672b47b84b54c43610e22559dd16fb12a74983af8b5a87a0d45dff31b330';
|
|
10
|
+
/// which in turn implies that you need to update the ORACLE_VERSION constant.
|
|
11
|
+
export const ORACLE_INTERFACE_HASH = '8fb18d1fa560c4844b22c55a3e79c32ffcb71ded9ac409911470ee0296a84d72';
|
package/src/pxe.ts
CHANGED
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
ContractFunctionSimulator,
|
|
60
60
|
generateSimulatedProvingResult,
|
|
61
61
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
|
-
import {
|
|
62
|
+
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
63
63
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
64
64
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
65
65
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
@@ -138,7 +138,7 @@ export class PXE {
|
|
|
138
138
|
const addressStore = new AddressStore(store);
|
|
139
139
|
const privateEventStore = new PrivateEventStore(store);
|
|
140
140
|
const contractStore = new ContractStore(store);
|
|
141
|
-
const noteStore =
|
|
141
|
+
const noteStore = await NoteStore.create(store);
|
|
142
142
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
143
143
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
144
144
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -158,13 +158,7 @@ export class PXE {
|
|
|
158
158
|
);
|
|
159
159
|
|
|
160
160
|
const jobCoordinator = new JobCoordinator(store);
|
|
161
|
-
jobCoordinator.registerStores([
|
|
162
|
-
capsuleStore,
|
|
163
|
-
senderTaggingStore,
|
|
164
|
-
recipientTaggingStore,
|
|
165
|
-
privateEventStore,
|
|
166
|
-
noteStore,
|
|
167
|
-
]);
|
|
161
|
+
jobCoordinator.registerStores([capsuleStore, senderTaggingStore, recipientTaggingStore, privateEventStore]);
|
|
168
162
|
|
|
169
163
|
const debugUtils = new PXEDebugUtils(contractStore, noteStore);
|
|
170
164
|
|
|
@@ -295,15 +289,6 @@ export class PXE {
|
|
|
295
289
|
try {
|
|
296
290
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
297
291
|
|
|
298
|
-
await ensureContractSynced(
|
|
299
|
-
contractAddress,
|
|
300
|
-
functionSelector,
|
|
301
|
-
privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
302
|
-
this.node,
|
|
303
|
-
this.contractStore,
|
|
304
|
-
anchorBlockHeader,
|
|
305
|
-
);
|
|
306
|
-
|
|
307
292
|
const result = await contractFunctionSimulator.run(
|
|
308
293
|
txRequest,
|
|
309
294
|
contractAddress,
|
|
@@ -443,6 +428,7 @@ export class PXE {
|
|
|
443
428
|
}
|
|
444
429
|
|
|
445
430
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
431
|
+
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
446
432
|
return accountCompleteAddress;
|
|
447
433
|
}
|
|
448
434
|
|
|
@@ -962,14 +948,8 @@ export class PXE {
|
|
|
962
948
|
const functionTimer = new Timer();
|
|
963
949
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
964
950
|
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
call.to,
|
|
968
|
-
call.selector,
|
|
969
|
-
privateSyncCall => this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
970
|
-
this.node,
|
|
971
|
-
this.contractStore,
|
|
972
|
-
anchorBlockHeader,
|
|
951
|
+
await this.contractStore.syncPrivateState(call.to, call.selector, privateSyncCall =>
|
|
952
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
973
953
|
);
|
|
974
954
|
|
|
975
955
|
const executionResult = await this.#simulateUtility(
|
|
@@ -1028,19 +1008,15 @@ export class PXE {
|
|
|
1028
1008
|
await this.#putInJobQueue(async jobId => {
|
|
1029
1009
|
await this.blockStateSynchronizer.sync();
|
|
1030
1010
|
|
|
1031
|
-
|
|
1032
|
-
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
1011
|
+
anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
1033
1012
|
|
|
1034
1013
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1035
1014
|
|
|
1036
|
-
await
|
|
1015
|
+
await this.contractStore.syncPrivateState(
|
|
1037
1016
|
filter.contractAddress,
|
|
1038
1017
|
null,
|
|
1039
1018
|
async privateSyncCall =>
|
|
1040
1019
|
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
1041
|
-
this.node,
|
|
1042
|
-
this.contractStore,
|
|
1043
|
-
anchorBlockHeader,
|
|
1044
1020
|
);
|
|
1045
1021
|
});
|
|
1046
1022
|
|