@aztec/pxe 0.0.1-commit.9b94fc1 → 0.0.1-commit.d3ec352c
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/contract_function_simulator/execution_data_provider.d.ts +10 -8
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +3 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +3 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -3
- 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 +6 -3
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +12 -9
- 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 +11 -10
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +5 -4
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +7 -5
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +10 -8
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +3 -2
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +11 -10
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +11 -9
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +3 -3
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +4 -4
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +4 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +3 -2
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.d.ts +3 -2
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +2 -1
- package/package.json +17 -17
- package/src/contract_function_simulator/execution_data_provider.ts +15 -6
- package/src/contract_function_simulator/execution_note_cache.ts +3 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +11 -6
- package/src/contract_function_simulator/oracle/oracle.ts +14 -6
- package/src/contract_function_simulator/oracle/private_execution.ts +2 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +7 -2
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +19 -7
- package/src/contract_function_simulator/pxe_oracle_interface.ts +35 -20
- package/src/private_kernel/private_kernel_execution_prover.ts +1 -0
- package/src/private_kernel/private_kernel_oracle_impl.ts +2 -2
- package/src/storage/note_data_provider/note_data_provider.ts +7 -3
- package/src/storage/sync_data_provider/sync_data_provider.ts +2 -1
- package/src/synchronizer/synchronizer.ts +2 -1
|
@@ -5,7 +5,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
5
5
|
import type { KeyStore } from '@aztec/key-store';
|
|
6
6
|
import { EventSelector, type FunctionArtifactWithContractName, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type {
|
|
8
|
+
import type { BlockParameter, DataInBlock, L2Block } from '@aztec/stdlib/block';
|
|
9
9
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
10
10
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier, siloPrivateLog } from '@aztec/stdlib/hash';
|
|
11
11
|
import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
@@ -90,16 +90,24 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
90
90
|
return instance;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
async getNotes(
|
|
93
|
+
async getNotes(
|
|
94
|
+
contractAddress: AztecAddress,
|
|
95
|
+
owner: AztecAddress,
|
|
96
|
+
storageSlot: Fr,
|
|
97
|
+
status: NoteStatus,
|
|
98
|
+
scopes?: AztecAddress[],
|
|
99
|
+
) {
|
|
94
100
|
const noteDaos = await this.noteDataProvider.getNotes({
|
|
95
101
|
contractAddress,
|
|
102
|
+
owner,
|
|
96
103
|
storageSlot,
|
|
97
104
|
status,
|
|
98
105
|
scopes,
|
|
99
106
|
});
|
|
100
107
|
return noteDaos.map(
|
|
101
|
-
({ contractAddress, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index }) => ({
|
|
108
|
+
({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index }) => ({
|
|
102
109
|
contractAddress,
|
|
110
|
+
owner,
|
|
103
111
|
storageSlot,
|
|
104
112
|
randomness,
|
|
105
113
|
noteNonce,
|
|
@@ -155,12 +163,12 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
155
163
|
return await this.#findLeafIndex('latest', MerkleTreeId.NULLIFIER_TREE, nullifier);
|
|
156
164
|
}
|
|
157
165
|
|
|
158
|
-
async #findLeafIndex(blockNumber:
|
|
166
|
+
async #findLeafIndex(blockNumber: BlockParameter, treeId: MerkleTreeId, leafValue: Fr): Promise<bigint | undefined> {
|
|
159
167
|
const [leafIndex] = await this.aztecNode.findLeavesIndexes(blockNumber, treeId, [leafValue]);
|
|
160
168
|
return leafIndex?.data;
|
|
161
169
|
}
|
|
162
170
|
|
|
163
|
-
public async getMembershipWitness(blockNumber:
|
|
171
|
+
public async getMembershipWitness(blockNumber: BlockParameter, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
|
|
164
172
|
const witness = await this.#tryGetMembershipWitness(blockNumber, treeId, leafValue);
|
|
165
173
|
if (!witness) {
|
|
166
174
|
throw new Error(`Leaf value ${leafValue} not found in tree ${MerkleTreeId[treeId]} at block ${blockNumber}`);
|
|
@@ -168,7 +176,11 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
168
176
|
return witness;
|
|
169
177
|
}
|
|
170
178
|
|
|
171
|
-
async #tryGetMembershipWitness(
|
|
179
|
+
async #tryGetMembershipWitness(
|
|
180
|
+
blockNumber: BlockParameter,
|
|
181
|
+
treeId: MerkleTreeId,
|
|
182
|
+
value: Fr,
|
|
183
|
+
): Promise<Fr[] | undefined> {
|
|
172
184
|
switch (treeId) {
|
|
173
185
|
case MerkleTreeId.NULLIFIER_TREE:
|
|
174
186
|
return (await this.aztecNode.getNullifierMembershipWitness(blockNumber, value))?.withoutPreimage().toFields();
|
|
@@ -189,42 +201,42 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
189
201
|
}
|
|
190
202
|
|
|
191
203
|
public getNullifierMembershipWitness(
|
|
192
|
-
blockNumber:
|
|
204
|
+
blockNumber: BlockParameter,
|
|
193
205
|
nullifier: Fr,
|
|
194
206
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
195
207
|
return this.aztecNode.getNullifierMembershipWitness(blockNumber, nullifier);
|
|
196
208
|
}
|
|
197
209
|
|
|
198
210
|
public async getLowNullifierMembershipWitness(
|
|
199
|
-
blockNumber:
|
|
211
|
+
blockNumber: BlockParameter,
|
|
200
212
|
nullifier: Fr,
|
|
201
213
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
202
214
|
const header = await this.getAnchorBlockHeader();
|
|
203
|
-
if (blockNumber > header.globalVariables.blockNumber) {
|
|
215
|
+
if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
|
|
204
216
|
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
205
217
|
}
|
|
206
218
|
return this.aztecNode.getLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
207
219
|
}
|
|
208
220
|
|
|
209
|
-
public async getBlock(blockNumber:
|
|
221
|
+
public async getBlock(blockNumber: BlockParameter): Promise<L2Block | undefined> {
|
|
210
222
|
const header = await this.getAnchorBlockHeader();
|
|
211
|
-
if (blockNumber > header.globalVariables.blockNumber) {
|
|
223
|
+
if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
|
|
212
224
|
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
213
225
|
}
|
|
214
226
|
return await this.aztecNode.getBlock(blockNumber);
|
|
215
227
|
}
|
|
216
228
|
|
|
217
|
-
public async getPublicDataWitness(blockNumber:
|
|
229
|
+
public async getPublicDataWitness(blockNumber: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
218
230
|
const header = await this.getAnchorBlockHeader();
|
|
219
|
-
if (blockNumber > header.globalVariables.blockNumber) {
|
|
231
|
+
if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
|
|
220
232
|
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
221
233
|
}
|
|
222
234
|
return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
|
|
223
235
|
}
|
|
224
236
|
|
|
225
|
-
public async getPublicStorageAt(blockNumber:
|
|
237
|
+
public async getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
226
238
|
const header = await this.getAnchorBlockHeader();
|
|
227
|
-
if (blockNumber > header.globalVariables.blockNumber) {
|
|
239
|
+
if (blockNumber !== 'latest' && blockNumber > header.globalVariables.blockNumber) {
|
|
228
240
|
throw new Error(`Block number ${blockNumber} is higher than current block ${header.globalVariables.blockNumber}`);
|
|
229
241
|
}
|
|
230
242
|
return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
|
|
@@ -599,6 +611,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
599
611
|
const noteDeliveries = noteValidationRequests.map(request =>
|
|
600
612
|
this.deliverNote(
|
|
601
613
|
request.contractAddress,
|
|
614
|
+
request.owner,
|
|
602
615
|
request.storageSlot,
|
|
603
616
|
request.randomness,
|
|
604
617
|
request.noteNonce,
|
|
@@ -630,6 +643,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
630
643
|
|
|
631
644
|
async deliverNote(
|
|
632
645
|
contractAddress: AztecAddress,
|
|
646
|
+
owner: AztecAddress,
|
|
633
647
|
storageSlot: Fr,
|
|
634
648
|
randomness: Fr,
|
|
635
649
|
noteNonce: Fr,
|
|
@@ -682,15 +696,16 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
682
696
|
const noteDao = new NoteDao(
|
|
683
697
|
new Note(content),
|
|
684
698
|
contractAddress,
|
|
699
|
+
owner,
|
|
685
700
|
storageSlot,
|
|
686
701
|
randomness,
|
|
687
702
|
noteNonce,
|
|
688
703
|
noteHash,
|
|
689
704
|
siloedNullifier,
|
|
690
705
|
txHash,
|
|
691
|
-
uniqueNoteHashTreeIndexInBlock
|
|
692
|
-
uniqueNoteHashTreeIndexInBlock
|
|
693
|
-
uniqueNoteHashTreeIndexInBlock
|
|
706
|
+
uniqueNoteHashTreeIndexInBlock.l2BlockNumber,
|
|
707
|
+
uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(),
|
|
708
|
+
uniqueNoteHashTreeIndexInBlock.data,
|
|
694
709
|
);
|
|
695
710
|
|
|
696
711
|
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
@@ -941,10 +956,10 @@ export class PXEOracleInterface implements ExecutionDataProvider {
|
|
|
941
956
|
const foundNullifiers = nullifiersToCheck
|
|
942
957
|
.map((nullifier, i) => {
|
|
943
958
|
if (nullifierIndexes[i] !== undefined) {
|
|
944
|
-
return { ...nullifierIndexes[i], ...{ data: nullifier } } as
|
|
959
|
+
return { ...nullifierIndexes[i], ...{ data: nullifier } } as DataInBlock<Fr>;
|
|
945
960
|
}
|
|
946
961
|
})
|
|
947
|
-
.filter(nullifier => nullifier !== undefined) as
|
|
962
|
+
.filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
|
|
948
963
|
|
|
949
964
|
const nullifiedNotes = await this.noteDataProvider.applyNullifiers(foundNullifiers);
|
|
950
965
|
nullifiedNotes.forEach(noteDao => {
|
|
@@ -415,6 +415,7 @@ export class PrivateKernelExecutionProver {
|
|
|
415
415
|
await this.oracle.getContractClassIdPreimage(currentContractClassId);
|
|
416
416
|
|
|
417
417
|
const updatedClassIdHints = await this.oracle.getUpdatedClassIdHints(contractAddress);
|
|
418
|
+
|
|
418
419
|
return PrivateCallData.from({
|
|
419
420
|
publicInputs,
|
|
420
421
|
vk,
|
|
@@ -8,7 +8,7 @@ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-type
|
|
|
8
8
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
9
9
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
10
10
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import type {
|
|
11
|
+
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
12
12
|
import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
13
13
|
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
14
14
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
@@ -31,7 +31,7 @@ export class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
|
31
31
|
private contractDataProvider: ContractDataProvider,
|
|
32
32
|
private keyStore: KeyStore,
|
|
33
33
|
private node: AztecNode,
|
|
34
|
-
private blockNumber:
|
|
34
|
+
private blockNumber: BlockParameter = 'latest',
|
|
35
35
|
private log = createLogger('pxe:kernel_oracle'),
|
|
36
36
|
) {}
|
|
37
37
|
|
|
@@ -3,7 +3,7 @@ import type { Fr } from '@aztec/foundation/fields';
|
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type {
|
|
6
|
+
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
7
7
|
import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
|
|
8
8
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
9
9
|
|
|
@@ -224,7 +224,7 @@ export class NoteDataProvider {
|
|
|
224
224
|
* parameters.
|
|
225
225
|
*
|
|
226
226
|
* @param filter - Filter criteria including contractAddress (required), and optional
|
|
227
|
-
* storageSlot, status, scopes and siloedNullifier.
|
|
227
|
+
* owner, storageSlot, status, scopes, and siloedNullifier.
|
|
228
228
|
* @returns Promise resolving to array of NoteDao objects matching the filter
|
|
229
229
|
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
230
230
|
*/
|
|
@@ -307,6 +307,10 @@ export class NoteDataProvider {
|
|
|
307
307
|
continue;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
if (filter.owner && !note.owner.equals(filter.owner)) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
|
|
310
314
|
if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot!)) {
|
|
311
315
|
continue;
|
|
312
316
|
}
|
|
@@ -333,7 +337,7 @@ export class NoteDataProvider {
|
|
|
333
337
|
* @returns Promise resolving to array of nullified NoteDao objects
|
|
334
338
|
* @throws Error if any nullifier is not found in the active notes
|
|
335
339
|
*/
|
|
336
|
-
applyNullifiers(nullifiers:
|
|
340
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[]): Promise<NoteDao[]> {
|
|
337
341
|
if (nullifiers.length === 0) {
|
|
338
342
|
return Promise.resolve([]);
|
|
339
343
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
2
3
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
@@ -14,7 +15,7 @@ export class SyncDataProvider {
|
|
|
14
15
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
async getBlockNumber(): Promise<
|
|
18
|
+
async getBlockNumber(): Promise<BlockNumber> {
|
|
18
19
|
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
19
20
|
if (!headerBuffer) {
|
|
20
21
|
throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
3
4
|
import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
@@ -109,7 +110,7 @@ export class Synchronizer implements L2BlockStreamEventHandler {
|
|
|
109
110
|
}
|
|
110
111
|
if (!currentHeader) {
|
|
111
112
|
// REFACTOR: We should know the header of the genesis block without having to request it from the node.
|
|
112
|
-
await this.syncDataProvider.setHeader((await this.node.getBlockHeader(
|
|
113
|
+
await this.syncDataProvider.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
|
|
113
114
|
}
|
|
114
115
|
await this.blockStream.sync();
|
|
115
116
|
}
|