@aztec/pxe 0.87.7 → 1.0.0-nightly.20250605
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/event_validation_request.d.ts +22 -0
- package/dest/contract_function_simulator/event_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/event_validation_request.js +43 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +25 -28
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/note_validation_request.d.ts +21 -0
- package/dest/contract_function_simulator/note_validation_request.d.ts.map +1 -0
- package/dest/contract_function_simulator/note_validation_request.js +42 -0
- 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 -19
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +7 -7
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +5 -6
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +8 -8
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +7 -5
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +81 -32
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +30 -30
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +9 -7
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +10 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +4 -2
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +46 -7
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +14 -14
- package/package.json +16 -16
- package/src/contract_function_simulator/event_validation_request.ts +53 -0
- package/src/contract_function_simulator/execution_data_provider.ts +29 -50
- package/src/contract_function_simulator/note_validation_request.ts +52 -0
- package/src/contract_function_simulator/oracle/oracle.ts +27 -50
- package/src/contract_function_simulator/oracle/typed_oracle.ts +18 -26
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +15 -42
- package/src/contract_function_simulator/pxe_oracle_interface.ts +157 -51
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +35 -34
- package/src/private_kernel/private_kernel_execution_prover.ts +11 -10
- package/src/pxe_service/pxe_service.ts +10 -3
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +56 -7
- package/src/storage/note_data_provider/note_data_provider.ts +22 -22
|
@@ -62,11 +62,11 @@ export class NoteDataProvider {
|
|
|
62
62
|
this.#notesByRecipientAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_recipient`));
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
if (!await this.#scopes.hasAsync(scope.toString())) {
|
|
67
|
-
await this.addScope(scope);
|
|
68
|
-
}
|
|
65
|
+
addNotes(notes, scope = AztecAddress.ZERO) {
|
|
69
66
|
return this.#store.transactionAsync(async ()=>{
|
|
67
|
+
if (!await this.#scopes.hasAsync(scope.toString())) {
|
|
68
|
+
await this.addScope(scope);
|
|
69
|
+
}
|
|
70
70
|
for (const dao of notes){
|
|
71
71
|
// store notes by their index in the notes hash tree
|
|
72
72
|
// this provides the uniqueness we need to store individual notes
|
|
@@ -105,17 +105,17 @@ export class NoteDataProvider {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
async unnullifyNotesAfter(blockNumber, synchedBlockNumber) {
|
|
108
|
-
const nullifiersToUndo = [];
|
|
109
|
-
const currentBlockNumber = blockNumber + 1;
|
|
110
|
-
const maxBlockNumber = synchedBlockNumber ?? currentBlockNumber;
|
|
111
|
-
for(let i = currentBlockNumber; i <= maxBlockNumber; i++){
|
|
112
|
-
nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
|
|
113
|
-
}
|
|
114
|
-
const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
|
|
115
|
-
const notNullNoteIndexes = notesIndexesToReinsert.filter((noteIndex)=>noteIndex != undefined);
|
|
116
|
-
const nullifiedNoteBuffers = await Promise.all(notNullNoteIndexes.map((noteIndex)=>this.#nullifiedNotes.getAsync(noteIndex)));
|
|
117
|
-
const noteDaos = nullifiedNoteBuffers.filter((buffer)=>buffer != undefined).map((buffer)=>NoteDao.fromBuffer(buffer));
|
|
118
108
|
await this.#store.transactionAsync(async ()=>{
|
|
109
|
+
const nullifiersToUndo = [];
|
|
110
|
+
const currentBlockNumber = blockNumber + 1;
|
|
111
|
+
const maxBlockNumber = synchedBlockNumber ?? currentBlockNumber;
|
|
112
|
+
for(let i = currentBlockNumber; i <= maxBlockNumber; i++){
|
|
113
|
+
nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
|
|
114
|
+
}
|
|
115
|
+
const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
|
|
116
|
+
const notNullNoteIndexes = notesIndexesToReinsert.filter((noteIndex)=>noteIndex != undefined);
|
|
117
|
+
const nullifiedNoteBuffers = await Promise.all(notNullNoteIndexes.map((noteIndex)=>this.#nullifiedNotes.getAsync(noteIndex)));
|
|
118
|
+
const noteDaos = nullifiedNoteBuffers.filter((buffer)=>buffer != undefined).map((buffer)=>NoteDao.fromBuffer(buffer));
|
|
119
119
|
for (const dao of noteDaos){
|
|
120
120
|
const noteIndex = toBufferBE(dao.index, 32).toString('hex');
|
|
121
121
|
await this.#notes.set(noteIndex, dao.toBuffer());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-nightly.20250605",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/entrypoints/server/index.js",
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@aztec/bb-prover": "0.
|
|
62
|
-
"@aztec/bb.js": "0.
|
|
63
|
-
"@aztec/builder": "0.
|
|
64
|
-
"@aztec/constants": "0.
|
|
65
|
-
"@aztec/ethereum": "0.
|
|
66
|
-
"@aztec/foundation": "0.
|
|
67
|
-
"@aztec/key-store": "0.
|
|
68
|
-
"@aztec/kv-store": "0.
|
|
69
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
70
|
-
"@aztec/noir-types": "0.
|
|
71
|
-
"@aztec/protocol-contracts": "0.
|
|
72
|
-
"@aztec/simulator": "0.
|
|
73
|
-
"@aztec/stdlib": "0.
|
|
61
|
+
"@aztec/bb-prover": "1.0.0-nightly.20250605",
|
|
62
|
+
"@aztec/bb.js": "1.0.0-nightly.20250605",
|
|
63
|
+
"@aztec/builder": "1.0.0-nightly.20250605",
|
|
64
|
+
"@aztec/constants": "1.0.0-nightly.20250605",
|
|
65
|
+
"@aztec/ethereum": "1.0.0-nightly.20250605",
|
|
66
|
+
"@aztec/foundation": "1.0.0-nightly.20250605",
|
|
67
|
+
"@aztec/key-store": "1.0.0-nightly.20250605",
|
|
68
|
+
"@aztec/kv-store": "1.0.0-nightly.20250605",
|
|
69
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0-nightly.20250605",
|
|
70
|
+
"@aztec/noir-types": "1.0.0-nightly.20250605",
|
|
71
|
+
"@aztec/protocol-contracts": "1.0.0-nightly.20250605",
|
|
72
|
+
"@aztec/simulator": "1.0.0-nightly.20250605",
|
|
73
|
+
"@aztec/stdlib": "1.0.0-nightly.20250605",
|
|
74
74
|
"koa": "^2.16.1",
|
|
75
75
|
"koa-router": "^12.0.0",
|
|
76
76
|
"lodash.omit": "^4.5.0",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"viem": "2.23.7"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@aztec/merkle-tree": "0.
|
|
83
|
-
"@aztec/noir-test-contracts.js": "0.
|
|
82
|
+
"@aztec/merkle-tree": "1.0.0-nightly.20250605",
|
|
83
|
+
"@aztec/noir-test-contracts.js": "1.0.0-nightly.20250605",
|
|
84
84
|
"@jest/globals": "^29.5.0",
|
|
85
85
|
"@types/jest": "^29.5.0",
|
|
86
86
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { EventSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
8
|
+
const MAX_EVENT_SERIALIZED_LEN = 12;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Intermediate struct used to perform batch event validation by PXE. The `validateEnqueuedNotesAndEvents` oracle
|
|
12
|
+
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
13
|
+
*/
|
|
14
|
+
export class EventValidationRequest {
|
|
15
|
+
constructor(
|
|
16
|
+
public contractAddress: AztecAddress,
|
|
17
|
+
public eventTypeId: EventSelector,
|
|
18
|
+
public serializedEvent: Fr[],
|
|
19
|
+
public eventCommitment: Fr,
|
|
20
|
+
public txHash: TxHash,
|
|
21
|
+
public recipient: AztecAddress,
|
|
22
|
+
public logIndexInTx: number,
|
|
23
|
+
public txIndexInBlock: number,
|
|
24
|
+
) {}
|
|
25
|
+
|
|
26
|
+
static fromFields(fields: Fr[] | FieldReader): EventValidationRequest {
|
|
27
|
+
const reader = FieldReader.asReader(fields);
|
|
28
|
+
|
|
29
|
+
const contractAddress = AztecAddress.fromField(reader.readField());
|
|
30
|
+
const eventTypeId = EventSelector.fromField(reader.readField());
|
|
31
|
+
|
|
32
|
+
const eventStorage = reader.readFieldArray(MAX_EVENT_SERIALIZED_LEN);
|
|
33
|
+
const eventLen = reader.readField().toNumber();
|
|
34
|
+
const serializedEvent = eventStorage.slice(0, eventLen);
|
|
35
|
+
|
|
36
|
+
const eventCommitment = reader.readField();
|
|
37
|
+
const txHash = TxHash.fromField(reader.readField());
|
|
38
|
+
const recipient = AztecAddress.fromField(reader.readField());
|
|
39
|
+
const logIndexInTx = reader.readField().toNumber();
|
|
40
|
+
const txIndexInBlock = reader.readField().toNumber();
|
|
41
|
+
|
|
42
|
+
return new EventValidationRequest(
|
|
43
|
+
contractAddress,
|
|
44
|
+
eventTypeId,
|
|
45
|
+
serializedEvent,
|
|
46
|
+
eventCommitment,
|
|
47
|
+
txHash,
|
|
48
|
+
recipient,
|
|
49
|
+
logIndexInTx,
|
|
50
|
+
txIndexInBlock,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import type { Fr, Point } from '@aztec/foundation/fields';
|
|
3
|
-
import type {
|
|
4
|
-
EventSelector,
|
|
5
|
-
FunctionArtifact,
|
|
6
|
-
FunctionArtifactWithContractName,
|
|
7
|
-
FunctionSelector,
|
|
8
|
-
} from '@aztec/stdlib/abi';
|
|
3
|
+
import type { FunctionArtifact, FunctionArtifactWithContractName, FunctionSelector } from '@aztec/stdlib/abi';
|
|
9
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
5
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
11
6
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
12
7
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
13
|
-
import { IndexedTaggingSecret,
|
|
8
|
+
import { IndexedTaggingSecret, PrivateLogWithTxData, PublicLogWithTxData } from '@aztec/stdlib/logs';
|
|
14
9
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
15
10
|
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
16
|
-
import type { BlockHeader, NodeStats
|
|
11
|
+
import type { BlockHeader, NodeStats } from '@aztec/stdlib/tx';
|
|
17
12
|
|
|
18
13
|
import type { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
|
|
19
14
|
import type { NoteData } from './oracle/typed_oracle.js';
|
|
@@ -265,8 +260,8 @@ export interface ExecutionDataProvider {
|
|
|
265
260
|
): Promise<void>;
|
|
266
261
|
|
|
267
262
|
/**
|
|
268
|
-
* Synchronizes the logs tagged with scoped addresses and all the senders in the address book. Stores the found
|
|
269
|
-
* in CapsuleArray ready for a later retrieval in Aztec.nr.
|
|
263
|
+
* Synchronizes the private logs tagged with scoped addresses and all the senders in the address book. Stores the found
|
|
264
|
+
* logs in CapsuleArray ready for a later retrieval in Aztec.nr.
|
|
270
265
|
* @param contractAddress - The address of the contract that the logs are tagged for.
|
|
271
266
|
* @param pendingTaggedLogArrayBaseSlot - The base slot of the pending tagged log capsule array in which found logs will be stored.
|
|
272
267
|
* @param scopes - The scoped addresses to sync logs for. If not provided, all accounts in the address book will be
|
|
@@ -279,27 +274,19 @@ export interface ExecutionDataProvider {
|
|
|
279
274
|
): Promise<void>;
|
|
280
275
|
|
|
281
276
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
277
|
+
* Validates all note and event validation requests enqueued via `enqueue_note_for_validation` and
|
|
278
|
+
* `enqueue_event_for_validation`, inserting them into the note database and event store respectively, making them
|
|
279
|
+
* queryable via `get_notes` and `getPrivateEvents`.
|
|
284
280
|
*
|
|
285
|
-
*
|
|
286
|
-
* @param
|
|
287
|
-
* @param
|
|
288
|
-
* @param
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
* @param txHash - The transaction in which the note was added to the note hash tree
|
|
292
|
-
* @param recipient - The account that discovered the note
|
|
293
|
-
*/
|
|
294
|
-
deliverNote(
|
|
281
|
+
* This automatically clears both validation request queues, so no further work needs to be done by the caller.
|
|
282
|
+
* @param contractAddress - The address of the contract that the logs are tagged for.
|
|
283
|
+
* @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
|
|
284
|
+
* @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
|
|
285
|
+
*/
|
|
286
|
+
validateEnqueuedNotesAndEvents(
|
|
295
287
|
contractAddress: AztecAddress,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
content: Fr[],
|
|
299
|
-
noteHash: Fr,
|
|
300
|
-
nullifier: Fr,
|
|
301
|
-
txHash: TxHash,
|
|
302
|
-
recipient: AztecAddress,
|
|
288
|
+
noteValidationRequestsArrayBaseSlot: Fr,
|
|
289
|
+
eventValidationRequestsArrayBaseSlot: Fr,
|
|
303
290
|
): Promise<void>;
|
|
304
291
|
|
|
305
292
|
/**
|
|
@@ -307,8 +294,20 @@ export interface ExecutionDataProvider {
|
|
|
307
294
|
* Returns null if no such log exists, and throws if more than one exists.
|
|
308
295
|
*
|
|
309
296
|
* @param tag - The log tag to search for.
|
|
297
|
+
* @param contractAddress - The contract address to search for the log in.
|
|
298
|
+
* @returns The public log with transaction data if found, null otherwise.
|
|
299
|
+
* @throws If more than one log with that tag exists.
|
|
300
|
+
*/
|
|
301
|
+
getPublicLogByTag(tag: Fr, contractAddress: AztecAddress): Promise<PublicLogWithTxData | null>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Searches for a private log with the corresponding `siloedTag` and returns it along with contextual transaction
|
|
305
|
+
* information.
|
|
306
|
+
*
|
|
307
|
+
* @param siloedTag - The siloed log tag to search for.
|
|
308
|
+
* @returns The private log with transaction data if found, null otherwise.
|
|
310
309
|
*/
|
|
311
|
-
|
|
310
|
+
getPrivateLogByTag(siloedTag: Fr): Promise<PrivateLogWithTxData | null>;
|
|
312
311
|
|
|
313
312
|
/**
|
|
314
313
|
* Removes all of a contract's notes that have been nullified from the note database.
|
|
@@ -363,26 +362,6 @@ export interface ExecutionDataProvider {
|
|
|
363
362
|
*/
|
|
364
363
|
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
|
|
365
364
|
|
|
366
|
-
/**
|
|
367
|
-
* Stores an event log in the database.
|
|
368
|
-
* @param contractAddress - The address of the contract that emitted the log.
|
|
369
|
-
* @param recipient - The address of the recipient.
|
|
370
|
-
* @param eventSelector - The event selector of the event.
|
|
371
|
-
* @param msgContent - The content of the private event message.
|
|
372
|
-
* @param txHash - The hash of the transaction that emitted the log.
|
|
373
|
-
* @param logIndexInTx - The index of the log within the transaction.
|
|
374
|
-
* @param txIndexInBlock - The index of the transaction in which the log was emitted in the block.
|
|
375
|
-
*/
|
|
376
|
-
storePrivateEventLog(
|
|
377
|
-
contractAddress: AztecAddress,
|
|
378
|
-
recipient: AztecAddress,
|
|
379
|
-
eventSelector: EventSelector,
|
|
380
|
-
msgContent: Fr[],
|
|
381
|
-
txHash: TxHash,
|
|
382
|
-
logIndexInTx: number,
|
|
383
|
-
txIndexInBlock: number,
|
|
384
|
-
): Promise<void>;
|
|
385
|
-
|
|
386
365
|
/**
|
|
387
366
|
* Returns the execution statistics collected during the simulator run.
|
|
388
367
|
* @returns The execution statistics.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
7
|
+
const MAX_NOTE_PACKED_LEN = 12;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Intermediate struct used to perform batch note validation by PXE. The `validateEnqueuedNotesAndEvents` oracle
|
|
11
|
+
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
12
|
+
*/
|
|
13
|
+
export class NoteValidationRequest {
|
|
14
|
+
constructor(
|
|
15
|
+
public contractAddress: AztecAddress,
|
|
16
|
+
public storageSlot: Fr,
|
|
17
|
+
public nonce: Fr,
|
|
18
|
+
public content: Fr[],
|
|
19
|
+
public noteHash: Fr,
|
|
20
|
+
public nullifier: Fr,
|
|
21
|
+
public txHash: TxHash,
|
|
22
|
+
public recipient: AztecAddress,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
static fromFields(fields: Fr[] | FieldReader): NoteValidationRequest {
|
|
26
|
+
const reader = FieldReader.asReader(fields);
|
|
27
|
+
|
|
28
|
+
const contractAddress = AztecAddress.fromField(reader.readField());
|
|
29
|
+
const storageSlot = reader.readField();
|
|
30
|
+
const nonce = reader.readField();
|
|
31
|
+
|
|
32
|
+
const contentStorage = reader.readFieldArray(MAX_NOTE_PACKED_LEN);
|
|
33
|
+
const contentLen = reader.readField().toNumber();
|
|
34
|
+
const content = contentStorage.slice(0, contentLen);
|
|
35
|
+
|
|
36
|
+
const noteHash = reader.readField();
|
|
37
|
+
const nullifier = reader.readField();
|
|
38
|
+
const txHash = TxHash.fromField(reader.readField());
|
|
39
|
+
const recipient = AztecAddress.fromField(reader.readField());
|
|
40
|
+
|
|
41
|
+
return new NoteValidationRequest(
|
|
42
|
+
contractAddress,
|
|
43
|
+
storageSlot,
|
|
44
|
+
nonce,
|
|
45
|
+
content,
|
|
46
|
+
noteHash,
|
|
47
|
+
nullifier,
|
|
48
|
+
txHash,
|
|
49
|
+
recipient,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -4,17 +4,20 @@ import {
|
|
|
4
4
|
type ACVMField,
|
|
5
5
|
arrayOfArraysToBoundedVecOfArrays,
|
|
6
6
|
bufferToBoundedVec,
|
|
7
|
-
fromBoundedVec,
|
|
8
7
|
fromUintArray,
|
|
9
8
|
fromUintBoundedVec,
|
|
10
9
|
toACVMField,
|
|
11
10
|
toACVMFieldSingleOrArray,
|
|
12
11
|
} from '@aztec/simulator/client';
|
|
13
|
-
import {
|
|
12
|
+
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
14
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ContractClassLog,
|
|
16
|
+
ContractClassLogFields,
|
|
17
|
+
PrivateLogWithTxData,
|
|
18
|
+
PublicLogWithTxData,
|
|
19
|
+
} from '@aztec/stdlib/logs';
|
|
16
20
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
17
|
-
import { TxHash } from '@aztec/stdlib/tx';
|
|
18
21
|
|
|
19
22
|
import type { TypedOracle } from './typed_oracle.js';
|
|
20
23
|
|
|
@@ -402,39 +405,35 @@ export class Oracle {
|
|
|
402
405
|
return [];
|
|
403
406
|
}
|
|
404
407
|
|
|
405
|
-
async
|
|
408
|
+
async validateEnqueuedNotesAndEvents(
|
|
406
409
|
[contractAddress]: ACVMField[],
|
|
407
|
-
[
|
|
408
|
-
[
|
|
409
|
-
content: ACVMField[],
|
|
410
|
-
[contentLength]: ACVMField[],
|
|
411
|
-
[noteHash]: ACVMField[],
|
|
412
|
-
[nullifier]: ACVMField[],
|
|
413
|
-
[txHash]: ACVMField[],
|
|
414
|
-
[recipient]: ACVMField[],
|
|
410
|
+
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
411
|
+
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
415
412
|
): Promise<ACVMField[]> {
|
|
416
|
-
|
|
417
|
-
// to do if a note fails delivery (e.g. not increment the tagging index, or add it to some pending work list).
|
|
418
|
-
// Delivery might fail due to temporary issues, such as poor node connectivity.
|
|
419
|
-
await this.typedOracle.deliverNote(
|
|
413
|
+
await this.typedOracle.validateEnqueuedNotesAndEvents(
|
|
420
414
|
AztecAddress.fromString(contractAddress),
|
|
421
|
-
Fr.fromString(
|
|
422
|
-
Fr.fromString(
|
|
423
|
-
fromBoundedVec(content, contentLength),
|
|
424
|
-
Fr.fromString(noteHash),
|
|
425
|
-
Fr.fromString(nullifier),
|
|
426
|
-
TxHash.fromString(txHash),
|
|
427
|
-
AztecAddress.fromString(recipient),
|
|
415
|
+
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
416
|
+
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
428
417
|
);
|
|
429
418
|
|
|
430
|
-
return [
|
|
419
|
+
return [];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
async getPublicLogByTag([tag]: ACVMField[], [contractAddress]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
423
|
+
const log = await this.typedOracle.getPublicLogByTag(Fr.fromString(tag), AztecAddress.fromString(contractAddress));
|
|
424
|
+
|
|
425
|
+
if (log == null) {
|
|
426
|
+
return [toACVMField(0), ...PublicLogWithTxData.noirSerializationOfEmpty().map(toACVMFieldSingleOrArray)];
|
|
427
|
+
} else {
|
|
428
|
+
return [toACVMField(1), ...log.toNoirSerialization().map(toACVMFieldSingleOrArray)];
|
|
429
|
+
}
|
|
431
430
|
}
|
|
432
431
|
|
|
433
|
-
async
|
|
434
|
-
const log = await this.typedOracle.
|
|
432
|
+
async getPrivateLogByTag([siloedTag]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
433
|
+
const log = await this.typedOracle.getPrivateLogByTag(Fr.fromString(siloedTag));
|
|
435
434
|
|
|
436
435
|
if (log == null) {
|
|
437
|
-
return [toACVMField(0), ...
|
|
436
|
+
return [toACVMField(0), ...PrivateLogWithTxData.noirSerializationOfEmpty().map(toACVMFieldSingleOrArray)];
|
|
438
437
|
} else {
|
|
439
438
|
return [toACVMField(1), ...log.toNoirSerialization().map(toACVMFieldSingleOrArray)];
|
|
440
439
|
}
|
|
@@ -516,26 +515,4 @@ export class Oracle {
|
|
|
516
515
|
);
|
|
517
516
|
return secret.toFields().map(toACVMField);
|
|
518
517
|
}
|
|
519
|
-
|
|
520
|
-
async storePrivateEventLog(
|
|
521
|
-
[contractAddress]: ACVMField[],
|
|
522
|
-
[recipient]: ACVMField[],
|
|
523
|
-
[eventSelector]: ACVMField[],
|
|
524
|
-
msgContentBVecStorage: ACVMField[],
|
|
525
|
-
[msgContentLength]: ACVMField[],
|
|
526
|
-
[txHash]: ACVMField[],
|
|
527
|
-
[logIndexInTx]: ACVMField[],
|
|
528
|
-
[txIndexInBlock]: ACVMField[],
|
|
529
|
-
) {
|
|
530
|
-
await this.typedOracle.storePrivateEventLog(
|
|
531
|
-
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
532
|
-
AztecAddress.fromField(Fr.fromString(recipient)),
|
|
533
|
-
EventSelector.fromField(Fr.fromString(eventSelector)),
|
|
534
|
-
fromBoundedVec(msgContentBVecStorage, msgContentLength),
|
|
535
|
-
new TxHash(Fr.fromString(txHash)),
|
|
536
|
-
Fr.fromString(logIndexInTx).toNumber(),
|
|
537
|
-
Fr.fromString(txIndexInBlock).toNumber(),
|
|
538
|
-
);
|
|
539
|
-
return [];
|
|
540
|
-
}
|
|
541
518
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
|
-
import type {
|
|
3
|
+
import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
ContractClassLog,
|
|
9
|
+
IndexedTaggingSecret,
|
|
10
|
+
PrivateLogWithTxData,
|
|
11
|
+
PublicLogWithTxData,
|
|
12
|
+
} from '@aztec/stdlib/logs';
|
|
8
13
|
import type { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
9
14
|
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
10
|
-
import type { BlockHeader
|
|
15
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
11
16
|
|
|
12
17
|
import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
13
18
|
|
|
@@ -218,21 +223,20 @@ export abstract class TypedOracle {
|
|
|
218
223
|
return Promise.reject(new OracleMethodNotAvailableError('fetchTaggedLogs'));
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
|
|
226
|
+
validateEnqueuedNotesAndEvents(
|
|
222
227
|
_contractAddress: AztecAddress,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
_content: Fr[],
|
|
226
|
-
_noteHash: Fr,
|
|
227
|
-
_nullifier: Fr,
|
|
228
|
-
_txHash: TxHash,
|
|
229
|
-
_recipient: AztecAddress,
|
|
228
|
+
_noteValidationRequestsArrayBaseSlot: Fr,
|
|
229
|
+
_eventValidationRequestsArrayBaseSlot: Fr,
|
|
230
230
|
): Promise<void> {
|
|
231
|
-
return Promise.reject(new OracleMethodNotAvailableError('
|
|
231
|
+
return Promise.reject(new OracleMethodNotAvailableError('validateEnqueuedNotesAndEvents'));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
getPublicLogByTag(_tag: Fr, _contractAddress: AztecAddress): Promise<PublicLogWithTxData | null> {
|
|
235
|
+
throw new OracleMethodNotAvailableError('getPublicLogByTag');
|
|
232
236
|
}
|
|
233
237
|
|
|
234
|
-
|
|
235
|
-
throw new OracleMethodNotAvailableError('
|
|
238
|
+
getPrivateLogByTag(_siloedTag: Fr): Promise<PrivateLogWithTxData | null> {
|
|
239
|
+
throw new OracleMethodNotAvailableError('getPrivateLogByTag');
|
|
236
240
|
}
|
|
237
241
|
|
|
238
242
|
storeCapsule(_contractAddress: AztecAddress, _key: Fr, _capsule: Fr[]): Promise<void> {
|
|
@@ -258,16 +262,4 @@ export abstract class TypedOracle {
|
|
|
258
262
|
getSharedSecret(_address: AztecAddress, _ephPk: Point): Promise<Point> {
|
|
259
263
|
return Promise.reject(new OracleMethodNotAvailableError('getSharedSecret'));
|
|
260
264
|
}
|
|
261
|
-
|
|
262
|
-
storePrivateEventLog(
|
|
263
|
-
_contractAddress: AztecAddress,
|
|
264
|
-
_recipient: AztecAddress,
|
|
265
|
-
_eventSelector: EventSelector,
|
|
266
|
-
_logContent: Fr[],
|
|
267
|
-
_txHash: TxHash,
|
|
268
|
-
_logIndexInTx: number,
|
|
269
|
-
_txIndexInBlock: number,
|
|
270
|
-
): Promise<void> {
|
|
271
|
-
return Promise.reject(new OracleMethodNotAvailableError('storePrivateEventLog'));
|
|
272
|
-
}
|
|
273
265
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Aes128 } from '@aztec/foundation/crypto';
|
|
2
2
|
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
3
|
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
5
4
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
6
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
8
7
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
9
8
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
10
|
-
import { IndexedTaggingSecret,
|
|
9
|
+
import { IndexedTaggingSecret, PrivateLogWithTxData, PublicLogWithTxData } from '@aztec/stdlib/logs';
|
|
11
10
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
12
11
|
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
13
|
-
import type { BlockHeader, Capsule
|
|
12
|
+
import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
|
|
14
13
|
|
|
15
14
|
import type { ExecutionDataProvider } from '../execution_data_provider.js';
|
|
16
15
|
import { pickNotes } from '../pick_notes.js';
|
|
@@ -280,35 +279,29 @@ export class UtilityExecutionOracle extends TypedOracle {
|
|
|
280
279
|
await this.executionDataProvider.removeNullifiedNotes(this.contractAddress);
|
|
281
280
|
}
|
|
282
281
|
|
|
283
|
-
public override async
|
|
282
|
+
public override async validateEnqueuedNotesAndEvents(
|
|
284
283
|
contractAddress: AztecAddress,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
content: Fr[],
|
|
288
|
-
noteHash: Fr,
|
|
289
|
-
nullifier: Fr,
|
|
290
|
-
txHash: TxHash,
|
|
291
|
-
recipient: AztecAddress,
|
|
284
|
+
noteValidationRequestsArrayBaseSlot: Fr,
|
|
285
|
+
eventValidationRequestsArrayBaseSlot: Fr,
|
|
292
286
|
) {
|
|
293
287
|
// TODO(#10727): allow other contracts to deliver notes
|
|
294
288
|
if (!this.contractAddress.equals(contractAddress)) {
|
|
295
|
-
throw new Error(`Got a note
|
|
289
|
+
throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
|
|
296
290
|
}
|
|
297
291
|
|
|
298
|
-
await this.executionDataProvider.
|
|
292
|
+
await this.executionDataProvider.validateEnqueuedNotesAndEvents(
|
|
299
293
|
contractAddress,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
content,
|
|
303
|
-
noteHash,
|
|
304
|
-
nullifier,
|
|
305
|
-
txHash,
|
|
306
|
-
recipient,
|
|
294
|
+
noteValidationRequestsArrayBaseSlot,
|
|
295
|
+
eventValidationRequestsArrayBaseSlot,
|
|
307
296
|
);
|
|
308
297
|
}
|
|
309
298
|
|
|
310
|
-
public override
|
|
311
|
-
return this.executionDataProvider.
|
|
299
|
+
public override getPublicLogByTag(tag: Fr, contractAddress: AztecAddress): Promise<PublicLogWithTxData | null> {
|
|
300
|
+
return this.executionDataProvider.getPublicLogByTag(tag, contractAddress);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
public override getPrivateLogByTag(siloedTag: Fr): Promise<PrivateLogWithTxData | null> {
|
|
304
|
+
return this.executionDataProvider.getPrivateLogByTag(siloedTag);
|
|
312
305
|
}
|
|
313
306
|
|
|
314
307
|
public override storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
|
|
@@ -361,24 +354,4 @@ export class UtilityExecutionOracle extends TypedOracle {
|
|
|
361
354
|
public override getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
|
|
362
355
|
return this.executionDataProvider.getSharedSecret(address, ephPk);
|
|
363
356
|
}
|
|
364
|
-
|
|
365
|
-
public override storePrivateEventLog(
|
|
366
|
-
contractAddress: AztecAddress,
|
|
367
|
-
recipient: AztecAddress,
|
|
368
|
-
eventSelector: EventSelector,
|
|
369
|
-
msgContent: Fr[],
|
|
370
|
-
txHash: TxHash,
|
|
371
|
-
logIndexInTx: number,
|
|
372
|
-
txIndexInBlock: number,
|
|
373
|
-
): Promise<void> {
|
|
374
|
-
return this.executionDataProvider.storePrivateEventLog(
|
|
375
|
-
contractAddress,
|
|
376
|
-
recipient,
|
|
377
|
-
eventSelector,
|
|
378
|
-
msgContent,
|
|
379
|
-
txHash,
|
|
380
|
-
logIndexInTx,
|
|
381
|
-
txIndexInBlock,
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
357
|
}
|