@aztec/pxe 0.0.1-commit.3e3d0c9cd → 0.0.1-commit.3f5453c7b
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 +4 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +3 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +13 -4
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +3 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -4
- 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 +3 -6
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +31 -19
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +28 -24
- package/dest/contract_function_simulator/oracle/oracle.d.ts +50 -19
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +177 -41
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +7 -11
- 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 -9
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +61 -38
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +210 -92
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +9 -2
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +6 -5
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +44 -37
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +7 -2
- package/dest/debug/pxe_debug_utils.d.ts +3 -3
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +2 -2
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +2 -2
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +5 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -37
- package/dest/messages/message_context_service.d.ts +3 -3
- package/dest/messages/message_context_service.d.ts.map +1 -1
- package/dest/messages/message_context_service.js +3 -3
- package/dest/notes/note_service.d.ts +4 -5
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -5
- package/dest/notes_filter.d.ts +2 -3
- package/dest/notes_filter.d.ts.map +1 -1
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/pxe.d.ts +4 -5
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +12 -6
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +1 -1
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +17 -7
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -4
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -4
- package/src/contract_function_simulator/oracle/interfaces.ts +46 -17
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +20 -58
- package/src/contract_function_simulator/oracle/oracle.ts +242 -36
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +19 -14
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +351 -118
- package/src/contract_function_simulator/pick_notes.ts +9 -2
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +77 -59
- package/src/contract_sync/helpers.ts +4 -4
- package/src/debug/pxe_debug_utils.ts +3 -3
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +2 -3
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +2 -3
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -2
- package/src/entrypoints/server/utils.ts +2 -3
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +52 -78
- package/src/messages/message_context_service.ts +3 -4
- package/src/notes/note_service.ts +18 -8
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/pxe.ts +17 -12
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +2 -5
- package/dest/access_scopes.d.ts +0 -9
- package/dest/access_scopes.d.ts.map +0 -1
- package/dest/access_scopes.js +0 -6
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +0 -16
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
- package/src/access_scopes.ts +0 -9
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
|
@@ -89,10 +89,10 @@ import {
|
|
|
89
89
|
getFinalMinRevertibleSideEffectCounter,
|
|
90
90
|
} from '@aztec/stdlib/tx';
|
|
91
91
|
|
|
92
|
-
import type { AccessScopes } from '../access_scopes.js';
|
|
93
92
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
94
93
|
import type { MessageContextService } from '../messages/message_context_service.js';
|
|
95
94
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
95
|
+
import { CapsuleService } from '../storage/capsule_store/capsule_service.js';
|
|
96
96
|
import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
97
97
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
98
98
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
@@ -122,7 +122,7 @@ export type ContractSimulatorRunOpts = {
|
|
|
122
122
|
/** The address used as a tagging sender when emitting private logs. */
|
|
123
123
|
senderForTags?: AztecAddress;
|
|
124
124
|
/** The accounts whose notes we can access in this call. */
|
|
125
|
-
scopes:
|
|
125
|
+
scopes: AztecAddress[];
|
|
126
126
|
/** The job ID for staged writes. */
|
|
127
127
|
jobId: string;
|
|
128
128
|
};
|
|
@@ -245,7 +245,7 @@ export class ContractFunctionSimulator {
|
|
|
245
245
|
senderTaggingStore: this.senderTaggingStore,
|
|
246
246
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
247
247
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
248
|
-
|
|
248
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
249
249
|
privateEventStore: this.privateEventStore,
|
|
250
250
|
messageContextService: this.messageContextService,
|
|
251
251
|
contractSyncService: this.contractSyncService,
|
|
@@ -284,7 +284,7 @@ export class ContractFunctionSimulator {
|
|
|
284
284
|
);
|
|
285
285
|
const publicFunctionsCalldata = await Promise.all(
|
|
286
286
|
publicCallRequests.map(async r => {
|
|
287
|
-
const calldata = await privateExecutionOracle.
|
|
287
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
288
288
|
return new HashedValues(calldata, r.calldataHash);
|
|
289
289
|
}),
|
|
290
290
|
);
|
|
@@ -319,7 +319,7 @@ export class ContractFunctionSimulator {
|
|
|
319
319
|
call: FunctionCall,
|
|
320
320
|
authwits: AuthWitness[],
|
|
321
321
|
anchorBlockHeader: BlockHeader,
|
|
322
|
-
scopes:
|
|
322
|
+
scopes: AztecAddress[],
|
|
323
323
|
jobId: string,
|
|
324
324
|
): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
|
|
325
325
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
@@ -340,9 +340,10 @@ export class ContractFunctionSimulator {
|
|
|
340
340
|
aztecNode: this.aztecNode,
|
|
341
341
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
342
342
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
343
|
-
|
|
343
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
344
344
|
privateEventStore: this.privateEventStore,
|
|
345
345
|
messageContextService: this.messageContextService,
|
|
346
|
+
contractSyncService: this.contractSyncService,
|
|
346
347
|
jobId,
|
|
347
348
|
scopes,
|
|
348
349
|
});
|
|
@@ -448,6 +449,8 @@ export async function generateSimulatedProvingResult(
|
|
|
448
449
|
privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.globalVariables.timestamp +
|
|
449
450
|
BigInt(MAX_TX_LIFETIME);
|
|
450
451
|
|
|
452
|
+
let feePayer = AztecAddress.zero();
|
|
453
|
+
|
|
451
454
|
const executions = [privateExecutionResult.entrypoint];
|
|
452
455
|
|
|
453
456
|
while (executions.length !== 0) {
|
|
@@ -462,6 +465,13 @@ export async function generateSimulatedProvingResult(
|
|
|
462
465
|
|
|
463
466
|
const { contractAddress } = execution.publicInputs.callContext;
|
|
464
467
|
|
|
468
|
+
if (execution.publicInputs.isFeePayer) {
|
|
469
|
+
if (!feePayer.isZero()) {
|
|
470
|
+
throw new Error('Multiple fee payers found in private execution result');
|
|
471
|
+
}
|
|
472
|
+
feePayer = contractAddress;
|
|
473
|
+
}
|
|
474
|
+
|
|
465
475
|
scopedNoteHashes.push(
|
|
466
476
|
...execution.publicInputs.noteHashes
|
|
467
477
|
.getActiveItems()
|
|
@@ -682,7 +692,7 @@ export async function generateSimulatedProvingResult(
|
|
|
682
692
|
daGas: TX_DA_GAS_OVERHEAD,
|
|
683
693
|
}),
|
|
684
694
|
),
|
|
685
|
-
/*feePayer=*/
|
|
695
|
+
/*feePayer=*/ feePayer,
|
|
686
696
|
/*expirationTimestamp=*/ expirationTimestamp,
|
|
687
697
|
hasPublicCalls ? inputsForPublic : undefined,
|
|
688
698
|
!hasPublicCalls ? inputsForRollup : undefined,
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
|
|
3
|
+
/** In-memory store for ephemeral arrays scoped to a single contract call frame. */
|
|
4
|
+
export class EphemeralArrayService {
|
|
5
|
+
/**
|
|
6
|
+
* Maps a slot to the elements of the array stored at that slot. Each element is a serialized representation of
|
|
7
|
+
* the original type.
|
|
8
|
+
*/
|
|
9
|
+
#arrays: Map<string, Fr[][]> = new Map();
|
|
10
|
+
|
|
11
|
+
/** Returns all elements in the array, or an empty array if uninitialized. */
|
|
12
|
+
readArrayAt(slot: Fr): Fr[][] {
|
|
13
|
+
return this.#arrays.get(slot.toString()) ?? [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#setArray(slot: Fr, array: Fr[][]): void {
|
|
17
|
+
this.#arrays.set(slot.toString(), array);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Returns the number of elements in the array at the given slot. */
|
|
21
|
+
len(slot: Fr): number {
|
|
22
|
+
return this.readArrayAt(slot).length;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Appends an element to the array and returns the new length. */
|
|
26
|
+
push(slot: Fr, elements: Fr[]): number {
|
|
27
|
+
const array = this.readArrayAt(slot);
|
|
28
|
+
array.push(elements);
|
|
29
|
+
this.#setArray(slot, array);
|
|
30
|
+
return array.length;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Removes and returns the last element. Throws if empty. */
|
|
34
|
+
pop(slot: Fr): Fr[] {
|
|
35
|
+
const array = this.readArrayAt(slot);
|
|
36
|
+
if (array.length === 0) {
|
|
37
|
+
throw new Error(`Ephemeral array at slot ${slot} is empty`);
|
|
38
|
+
}
|
|
39
|
+
const element = array.pop()!;
|
|
40
|
+
this.#setArray(slot, array);
|
|
41
|
+
return element;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Returns the element at the given index. Throws if out of bounds. */
|
|
45
|
+
get(slot: Fr, index: number): Fr[] {
|
|
46
|
+
const array = this.readArrayAt(slot);
|
|
47
|
+
if (index < 0 || index >= array.length) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Ephemeral array index ${index} out of bounds for array of length ${array.length} at slot ${slot}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return array[index];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Overwrites the element at the given index. Throws if out of bounds. */
|
|
56
|
+
set(slot: Fr, index: number, value: Fr[]): void {
|
|
57
|
+
const array = this.readArrayAt(slot);
|
|
58
|
+
if (index < 0 || index >= array.length) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Ephemeral array index ${index} out of bounds for array of length ${array.length} at slot ${slot}`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
array[index] = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Removes the element at the given index, shifting subsequent elements backward. Throws if out of bounds. */
|
|
67
|
+
remove(slot: Fr, index: number): void {
|
|
68
|
+
const array = this.readArrayAt(slot);
|
|
69
|
+
if (index < 0 || index >= array.length) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Ephemeral array index ${index} out of bounds for array of length ${array.length} at slot ${slot}`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
array.splice(index, 1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Removes all elements from the array. */
|
|
78
|
+
clear(slot: Fr): void {
|
|
79
|
+
this.#arrays.delete(slot.toString());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Allocates a fresh, unused slot for a new ephemeral array. */
|
|
83
|
+
allocateSlot(): Fr {
|
|
84
|
+
let slot: Fr;
|
|
85
|
+
do {
|
|
86
|
+
slot = Fr.random();
|
|
87
|
+
} while (this.#arrays.has(slot.toString()));
|
|
88
|
+
return slot;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Creates a new ephemeral array pre-populated with the given elements and returns its slot. */
|
|
92
|
+
newArray(elements: Fr[][]): Fr {
|
|
93
|
+
const slot = this.allocateSlot();
|
|
94
|
+
this.#setArray(slot, elements);
|
|
95
|
+
return slot;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Copies `count` elements from the source array to the destination array (overwrites destination). */
|
|
99
|
+
copy(srcSlot: Fr, dstSlot: Fr, count: number): void {
|
|
100
|
+
const srcArray = this.readArrayAt(srcSlot);
|
|
101
|
+
if (count > srcArray.length) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Cannot copy ${count} elements from ephemeral array of length ${srcArray.length} at slot ${srcSlot}`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
// Deep copy the elements to avoid aliasing
|
|
107
|
+
const copied = srcArray.slice(0, count).map(el => [...el]);
|
|
108
|
+
this.#setArray(dstSlot, copied);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -6,7 +6,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
9
|
-
* expects for values of this type to be stored in a `
|
|
9
|
+
* expects for values of this type to be stored in a `EphemeralArray`.
|
|
10
10
|
*/
|
|
11
11
|
export class EventValidationRequest {
|
|
12
12
|
constructor(
|
|
@@ -16,7 +16,6 @@ export class EventValidationRequest {
|
|
|
16
16
|
public serializedEvent: Fr[],
|
|
17
17
|
public eventCommitment: Fr,
|
|
18
18
|
public txHash: TxHash,
|
|
19
|
-
public recipient: AztecAddress,
|
|
20
19
|
) {}
|
|
21
20
|
|
|
22
21
|
static fromFields(fields: Fr[], maxEventSerializedLen: number): EventValidationRequest {
|
|
@@ -33,7 +32,6 @@ export class EventValidationRequest {
|
|
|
33
32
|
|
|
34
33
|
const eventCommitment = reader.readField();
|
|
35
34
|
const txHash = TxHash.fromField(reader.readField());
|
|
36
|
-
const recipient = AztecAddress.fromField(reader.readField());
|
|
37
35
|
|
|
38
36
|
if (reader.remainingFields() !== 0) {
|
|
39
37
|
throw new Error(
|
|
@@ -48,7 +46,6 @@ export class EventValidationRequest {
|
|
|
48
46
|
serializedEvent,
|
|
49
47
|
eventCommitment,
|
|
50
48
|
txHash,
|
|
51
|
-
recipient,
|
|
52
49
|
);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
@@ -5,7 +5,7 @@ import { Tag } from '@aztec/stdlib/logs';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle expects values of this
|
|
8
|
-
* type to be stored in a `
|
|
8
|
+
* type to be stored in a `EphemeralArray`.
|
|
9
9
|
*/
|
|
10
10
|
export class LogRetrievalRequest {
|
|
11
11
|
constructor(
|
|
@@ -7,7 +7,7 @@ const MAX_LOG_CONTENT_LEN = PRIVATE_LOG_CIPHERTEXT_LEN;
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
|
|
10
|
-
* type in a `
|
|
10
|
+
* type in a `EphemeralArray`.
|
|
11
11
|
*/
|
|
12
12
|
export class LogRetrievalResponse {
|
|
13
13
|
constructor(
|
|
@@ -5,7 +5,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
8
|
-
* expects for values of this type to be stored in a `
|
|
8
|
+
* expects for values of this type to be stored in a `EphemeralArray`.
|
|
9
9
|
*/
|
|
10
10
|
export class NoteValidationRequest {
|
|
11
11
|
constructor(
|
|
@@ -18,7 +18,6 @@ export class NoteValidationRequest {
|
|
|
18
18
|
public noteHash: Fr,
|
|
19
19
|
public nullifier: Fr,
|
|
20
20
|
public txHash: TxHash,
|
|
21
|
-
public recipient: AztecAddress,
|
|
22
21
|
) {}
|
|
23
22
|
|
|
24
23
|
static fromFields(fields: Fr[], maxNotePackedLen: number): NoteValidationRequest {
|
|
@@ -37,7 +36,6 @@ export class NoteValidationRequest {
|
|
|
37
36
|
const noteHash = reader.readField();
|
|
38
37
|
const nullifier = reader.readField();
|
|
39
38
|
const txHash = TxHash.fromField(reader.readField());
|
|
40
|
-
const recipient = AztecAddress.fromField(reader.readField());
|
|
41
39
|
|
|
42
40
|
if (reader.remainingFields() !== 0) {
|
|
43
41
|
throw new Error(
|
|
@@ -55,7 +53,6 @@ export class NoteValidationRequest {
|
|
|
55
53
|
noteHash,
|
|
56
54
|
nullifier,
|
|
57
55
|
txHash,
|
|
58
|
-
recipient,
|
|
59
56
|
);
|
|
60
57
|
}
|
|
61
58
|
}
|
|
@@ -54,7 +54,7 @@ export interface IMiscOracle {
|
|
|
54
54
|
isMisc: true;
|
|
55
55
|
|
|
56
56
|
getRandomField(): Fr;
|
|
57
|
-
assertCompatibleOracleVersion(
|
|
57
|
+
assertCompatibleOracleVersion(major: number, minor: number): void;
|
|
58
58
|
log(level: number, message: string, fields: Fr[]): Promise<void>;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -86,7 +86,7 @@ export interface IUtilityExecutionOracle {
|
|
|
86
86
|
nullifier: Fr,
|
|
87
87
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
88
88
|
getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
|
|
89
|
-
|
|
89
|
+
getPublicKeysAndPartialAddress(
|
|
90
90
|
account: AztecAddress,
|
|
91
91
|
): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined>;
|
|
92
92
|
getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
|
|
@@ -107,43 +107,72 @@ export interface IUtilityExecutionOracle {
|
|
|
107
107
|
offset: number,
|
|
108
108
|
status: NoteStatus,
|
|
109
109
|
): Promise<NoteData[]>;
|
|
110
|
-
|
|
110
|
+
doesNullifierExist(innerNullifier: Fr): Promise<boolean>;
|
|
111
111
|
getL1ToL2MembershipWitness(
|
|
112
112
|
contractAddress: AztecAddress,
|
|
113
113
|
messageHash: Fr,
|
|
114
114
|
secret: Fr,
|
|
115
115
|
): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
116
|
-
|
|
116
|
+
getFromPublicStorage(
|
|
117
117
|
anchorBlockHash: BlockHash,
|
|
118
118
|
contractAddress: AztecAddress,
|
|
119
119
|
startStorageSlot: Fr,
|
|
120
120
|
numberOfElements: number,
|
|
121
121
|
): Promise<Fr[]>;
|
|
122
|
-
|
|
122
|
+
getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr, scope: AztecAddress): Promise<void>;
|
|
123
|
+
getPendingTaggedLogsV2(scope: AztecAddress): Promise<Fr>;
|
|
123
124
|
validateAndStoreEnqueuedNotesAndEvents(
|
|
124
125
|
contractAddress: AztecAddress,
|
|
125
126
|
noteValidationRequestsArrayBaseSlot: Fr,
|
|
126
127
|
eventValidationRequestsArrayBaseSlot: Fr,
|
|
127
128
|
maxNotePackedLen: number,
|
|
128
129
|
maxEventSerializedLen: number,
|
|
130
|
+
scope: AztecAddress,
|
|
129
131
|
): Promise<void>;
|
|
130
|
-
|
|
132
|
+
getLogsByTag(
|
|
131
133
|
contractAddress: AztecAddress,
|
|
132
134
|
logRetrievalRequestsArrayBaseSlot: Fr,
|
|
133
135
|
logRetrievalResponsesArrayBaseSlot: Fr,
|
|
136
|
+
scope: AztecAddress,
|
|
134
137
|
): Promise<void>;
|
|
135
|
-
|
|
138
|
+
validateAndStoreEnqueuedNotesAndEventsV2(
|
|
139
|
+
noteValidationRequestsArrayBaseSlot: Fr,
|
|
140
|
+
eventValidationRequestsArrayBaseSlot: Fr,
|
|
141
|
+
maxNotePackedLen: number,
|
|
142
|
+
maxEventSerializedLen: number,
|
|
143
|
+
scope: AztecAddress,
|
|
144
|
+
): Promise<void>;
|
|
145
|
+
getLogsByTagV2(requestArrayBaseSlot: Fr): Promise<Fr>;
|
|
146
|
+
getMessageContextsByTxHashV2(requestArrayBaseSlot: Fr): Promise<Fr>;
|
|
147
|
+
getMessageContextsByTxHash(
|
|
136
148
|
contractAddress: AztecAddress,
|
|
137
149
|
messageContextRequestsArrayBaseSlot: Fr,
|
|
138
150
|
messageContextResponsesArrayBaseSlot: Fr,
|
|
151
|
+
scope: AztecAddress,
|
|
152
|
+
): Promise<void>;
|
|
153
|
+
setCapsule(contractAddress: AztecAddress, key: Fr, capsule: Fr[], scope: AztecAddress): void;
|
|
154
|
+
getCapsule(contractAddress: AztecAddress, key: Fr, scope: AztecAddress): Promise<Fr[] | null>;
|
|
155
|
+
deleteCapsule(contractAddress: AztecAddress, key: Fr, scope: AztecAddress): void;
|
|
156
|
+
copyCapsule(
|
|
157
|
+
contractAddress: AztecAddress,
|
|
158
|
+
srcKey: Fr,
|
|
159
|
+
dstKey: Fr,
|
|
160
|
+
numEntries: number,
|
|
161
|
+
scope: AztecAddress,
|
|
139
162
|
): Promise<void>;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
copyCapsule(contractAddress: AztecAddress, srcKey: Fr, dstKey: Fr, numEntries: number): Promise<void>;
|
|
144
|
-
aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
|
|
145
|
-
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
|
|
163
|
+
decryptAes128(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
|
|
164
|
+
getSharedSecret(address: AztecAddress, ephPk: Point, contractAddress: AztecAddress): Promise<Fr>;
|
|
165
|
+
setContractSyncCacheInvalid(contractAddress: AztecAddress, scopes: AztecAddress[]): void;
|
|
146
166
|
emitOffchainEffect(data: Fr[]): Promise<void>;
|
|
167
|
+
|
|
168
|
+
// Ephemeral array methods
|
|
169
|
+
pushEphemeral(slot: Fr, elements: Fr[]): number;
|
|
170
|
+
popEphemeral(slot: Fr): Fr[];
|
|
171
|
+
getEphemeral(slot: Fr, index: number): Fr[];
|
|
172
|
+
setEphemeral(slot: Fr, index: number, elements: Fr[]): void;
|
|
173
|
+
getEphemeralLen(slot: Fr): number;
|
|
174
|
+
removeEphemeral(slot: Fr, index: number): void;
|
|
175
|
+
clearEphemeral(slot: Fr): void;
|
|
147
176
|
}
|
|
148
177
|
|
|
149
178
|
/**
|
|
@@ -153,8 +182,8 @@ export interface IUtilityExecutionOracle {
|
|
|
153
182
|
export interface IPrivateExecutionOracle {
|
|
154
183
|
isPrivate: true;
|
|
155
184
|
|
|
156
|
-
|
|
157
|
-
|
|
185
|
+
setHashPreimage(values: Fr[], hash: Fr): void;
|
|
186
|
+
getHashPreimage(hash: Fr): Promise<Fr[]>;
|
|
158
187
|
notifyCreatedNote(
|
|
159
188
|
owner: AztecAddress,
|
|
160
189
|
storageSlot: Fr,
|
|
@@ -175,9 +204,9 @@ export interface IPrivateExecutionOracle {
|
|
|
175
204
|
sideEffectCounter: number,
|
|
176
205
|
isStaticCall: boolean,
|
|
177
206
|
): Promise<{ endSideEffectCounter: Fr; returnsHash: Fr }>;
|
|
178
|
-
|
|
207
|
+
assertValidPublicCalldata(calldataHash: Fr): Promise<void>;
|
|
179
208
|
notifyRevertiblePhaseStart(minRevertibleSideEffectCounter: number): Promise<void>;
|
|
180
|
-
|
|
209
|
+
isExecutionInRevertiblePhase(sideEffectCounter: number): Promise<boolean>;
|
|
181
210
|
getSenderForTags(): Promise<AztecAddress | undefined>;
|
|
182
211
|
setSenderForTags(senderForTags: AztecAddress): Promise<void>;
|
|
183
212
|
getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toACVMField } from '@aztec/simulator/client';
|
|
2
2
|
import type { ACIRCallback, ACVMField } from '@aztec/simulator/client';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
|
|
4
5
|
import type { Oracle } from './oracle.js';
|
|
5
6
|
|
|
@@ -9,6 +10,8 @@ import type { Oracle } from './oracle.js';
|
|
|
9
10
|
* TODO(F-416): Remove these aliases on v5 when protocol contracts are redeployed.
|
|
10
11
|
*/
|
|
11
12
|
export function buildLegacyOracleCallbacks(oracle: Oracle): ACIRCallback {
|
|
13
|
+
// If you are about to add a new mapping ensure that the old oracle name is different from the new one - this can
|
|
14
|
+
// commonly occur when only the args are getting modified.
|
|
12
15
|
return {
|
|
13
16
|
// Simple prefix renames (privateXxx/utilityXxx → aztec_prv_/aztec_utl_)
|
|
14
17
|
utilityLog: (
|
|
@@ -18,16 +21,21 @@ export function buildLegacyOracleCallbacks(oracle: Oracle): ACIRCallback {
|
|
|
18
21
|
fields: ACVMField[],
|
|
19
22
|
): Promise<ACVMField[]> => oracle.aztec_utl_log(level, message, _ignoredFieldsSize, fields),
|
|
20
23
|
utilityAssertCompatibleOracleVersion: (version: ACVMField[]): Promise<ACVMField[]> =>
|
|
21
|
-
oracle.
|
|
24
|
+
oracle.aztec_utl_assertCompatibleOracleVersionV2(version, [toACVMField(0)]),
|
|
25
|
+
// Old 1-arg oracle before minor/major split. Maps to V2 with minor=0.
|
|
26
|
+
// eslint-disable-next-line camelcase
|
|
27
|
+
aztec_utl_assertCompatibleOracleVersion: (version: ACVMField[]): Promise<ACVMField[]> =>
|
|
28
|
+
oracle.aztec_utl_assertCompatibleOracleVersionV2(version, [toACVMField(0)]),
|
|
22
29
|
utilityLoadCapsule: (
|
|
23
30
|
contractAddress: ACVMField[],
|
|
24
31
|
slot: ACVMField[],
|
|
25
32
|
tSize: ACVMField[],
|
|
26
|
-
): Promise<(ACVMField | ACVMField[])[]> =>
|
|
33
|
+
): Promise<(ACVMField | ACVMField[])[]> =>
|
|
34
|
+
oracle.aztec_utl_getCapsule(contractAddress, slot, tSize, [toACVMField(AztecAddress.ZERO)]),
|
|
27
35
|
privateStoreInExecutionCache: (values: ACVMField[], hash: ACVMField[]): Promise<ACVMField[]> =>
|
|
28
|
-
oracle.
|
|
36
|
+
oracle.aztec_prv_setHashPreimage(values, hash),
|
|
29
37
|
privateLoadFromExecutionCache: (returnsHash: ACVMField[]): Promise<ACVMField[][]> =>
|
|
30
|
-
oracle.
|
|
38
|
+
oracle.aztec_prv_getHashPreimage(returnsHash),
|
|
31
39
|
privateCallPrivateFunction: (
|
|
32
40
|
contractAddress: ACVMField[],
|
|
33
41
|
functionSelector: ACVMField[],
|
|
@@ -60,83 +68,37 @@ export function buildLegacyOracleCallbacks(oracle: Oracle): ACIRCallback {
|
|
|
60
68
|
startStorageSlot: ACVMField[],
|
|
61
69
|
numberOfElements: ACVMField[],
|
|
62
70
|
): Promise<ACVMField[][]> =>
|
|
63
|
-
oracle.
|
|
71
|
+
oracle.aztec_utl_getFromPublicStorage(blockHash, contractAddress, startStorageSlot, numberOfElements),
|
|
64
72
|
utilityStoreCapsule: (
|
|
65
73
|
contractAddress: ACVMField[],
|
|
66
74
|
slot: ACVMField[],
|
|
67
75
|
capsule: ACVMField[],
|
|
68
|
-
): Promise<ACVMField[]> =>
|
|
76
|
+
): Promise<ACVMField[]> =>
|
|
77
|
+
oracle.aztec_utl_setCapsule(contractAddress, slot, capsule, [toACVMField(AztecAddress.ZERO)]),
|
|
69
78
|
utilityCopyCapsule: (
|
|
70
79
|
contractAddress: ACVMField[],
|
|
71
80
|
srcSlot: ACVMField[],
|
|
72
81
|
dstSlot: ACVMField[],
|
|
73
82
|
numEntries: ACVMField[],
|
|
74
|
-
): Promise<ACVMField[]> => oracle.aztec_utl_copyCapsule(contractAddress, srcSlot, dstSlot, numEntries),
|
|
75
|
-
utilityDeleteCapsule: (contractAddress: ACVMField[], slot: ACVMField[]): Promise<ACVMField[]> =>
|
|
76
|
-
oracle.aztec_utl_deleteCapsule(contractAddress, slot),
|
|
77
|
-
utilityAes128Decrypt: (
|
|
78
|
-
ciphertextBVecStorage: ACVMField[],
|
|
79
|
-
ciphertextLength: ACVMField[],
|
|
80
|
-
iv: ACVMField[],
|
|
81
|
-
symKey: ACVMField[],
|
|
82
|
-
): Promise<(ACVMField | ACVMField[])[]> =>
|
|
83
|
-
oracle.aztec_utl_aes128Decrypt(ciphertextBVecStorage, ciphertextLength, iv, symKey),
|
|
84
|
-
utilityGetSharedSecret: (
|
|
85
|
-
address: ACVMField[],
|
|
86
|
-
ephPKField0: ACVMField[],
|
|
87
|
-
ephPKField1: ACVMField[],
|
|
88
|
-
ephPKField2: ACVMField[],
|
|
89
|
-
): Promise<ACVMField[]> => oracle.aztec_utl_getSharedSecret(address, ephPKField0, ephPKField1, ephPKField2),
|
|
90
|
-
utilityFetchTaggedLogs: (pendingTaggedLogArrayBaseSlot: ACVMField[]): Promise<ACVMField[]> =>
|
|
91
|
-
oracle.aztec_utl_fetchTaggedLogs(pendingTaggedLogArrayBaseSlot),
|
|
92
|
-
utilityBulkRetrieveLogs: (
|
|
93
|
-
contractAddress: ACVMField[],
|
|
94
|
-
logRetrievalRequestsArrayBaseSlot: ACVMField[],
|
|
95
|
-
logRetrievalResponsesArrayBaseSlot: ACVMField[],
|
|
96
83
|
): Promise<ACVMField[]> =>
|
|
97
|
-
oracle.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
logRetrievalResponsesArrayBaseSlot,
|
|
101
|
-
),
|
|
84
|
+
oracle.aztec_utl_copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, [toACVMField(AztecAddress.ZERO)]),
|
|
85
|
+
utilityDeleteCapsule: (contractAddress: ACVMField[], slot: ACVMField[]): Promise<ACVMField[]> =>
|
|
86
|
+
oracle.aztec_utl_deleteCapsule(contractAddress, slot, [toACVMField(AztecAddress.ZERO)]),
|
|
102
87
|
utilityGetL1ToL2MembershipWitness: (
|
|
103
88
|
contractAddress: ACVMField[],
|
|
104
89
|
messageHash: ACVMField[],
|
|
105
90
|
secret: ACVMField[],
|
|
106
91
|
): Promise<(ACVMField | ACVMField[])[]> =>
|
|
107
92
|
oracle.aztec_utl_getL1ToL2MembershipWitness(contractAddress, messageHash, secret),
|
|
108
|
-
utilityEmitOffchainEffect: (data: ACVMField[]): Promise<ACVMField[]> => oracle.aztec_utl_emitOffchainEffect(data),
|
|
109
|
-
// Adapter: old 3-param signature → new 5-param with injected constants.
|
|
110
|
-
// Values derived from: MAX_MESSAGE_CONTENT_LEN(11) - RESERVED_FIELDS (3 for notes, 1 for events).
|
|
111
|
-
utilityValidateAndStoreEnqueuedNotesAndEvents: (
|
|
112
|
-
contractAddress: ACVMField[],
|
|
113
|
-
noteValidationRequestsArrayBaseSlot: ACVMField[],
|
|
114
|
-
eventValidationRequestsArrayBaseSlot: ACVMField[],
|
|
115
|
-
): Promise<ACVMField[]> =>
|
|
116
|
-
oracle.aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
117
|
-
contractAddress,
|
|
118
|
-
noteValidationRequestsArrayBaseSlot,
|
|
119
|
-
eventValidationRequestsArrayBaseSlot,
|
|
120
|
-
[new Fr(8).toString()],
|
|
121
|
-
[new Fr(10).toString()],
|
|
122
|
-
),
|
|
123
93
|
// Renames (same signature, different oracle name)
|
|
124
94
|
privateNotifySetMinRevertibleSideEffectCounter: (counter: ACVMField[]): Promise<ACVMField[]> =>
|
|
125
95
|
oracle.aztec_prv_notifyRevertiblePhaseStart(counter),
|
|
126
|
-
privateIsSideEffectCounterRevertible: (sideEffectCounter: ACVMField[]): Promise<ACVMField[]> =>
|
|
127
|
-
oracle.aztec_prv_inRevertiblePhase(sideEffectCounter),
|
|
128
96
|
// Signature changes: old 4-param oracles → new 1-param validatePublicCalldata
|
|
129
97
|
privateNotifyEnqueuedPublicFunctionCall: (
|
|
130
98
|
_contractAddress: ACVMField[],
|
|
131
99
|
calldataHash: ACVMField[],
|
|
132
100
|
_sideEffectCounter: ACVMField[],
|
|
133
101
|
_isStaticCall: ACVMField[],
|
|
134
|
-
): Promise<ACVMField[]> => oracle.
|
|
135
|
-
privateNotifySetPublicTeardownFunctionCall: (
|
|
136
|
-
_contractAddress: ACVMField[],
|
|
137
|
-
calldataHash: ACVMField[],
|
|
138
|
-
_sideEffectCounter: ACVMField[],
|
|
139
|
-
_isStaticCall: ACVMField[],
|
|
140
|
-
): Promise<ACVMField[]> => oracle.aztec_prv_validatePublicCalldata(calldataHash),
|
|
102
|
+
): Promise<ACVMField[]> => oracle.aztec_prv_assertValidPublicCalldata(calldataHash),
|
|
141
103
|
};
|
|
142
104
|
}
|