@aztec/pxe 0.0.1-commit.c7c42ec → 0.0.1-commit.f295ac2
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 +6 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +21 -13
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -9
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +33 -16
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- 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 +5 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +9 -8
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +4 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +5 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +20 -19
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +5 -9
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +11 -10
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +8 -18
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +10 -35
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +14 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +54 -52
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/events/event_service.d.ts +4 -3
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +17 -19
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +74 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +93 -0
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +5 -3
- package/dest/notes/note_service.d.ts +3 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +23 -28
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/index.d.ts +2 -2
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
- 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_execution_prover.js +4 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +8 -36
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +65 -87
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +132 -23
- package/dest/storage/contract_store/contract_store.d.ts +2 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +12 -0
- package/dest/storage/note_store/note_store.d.ts +6 -5
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +89 -94
- package/dest/storage/private_event_store/private_event_store.d.ts +33 -6
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +139 -32
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +69 -12
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +110 -28
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +2 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
- 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 +2 -2
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -2
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +4 -2
- package/dest/tree_membership/tree_membership_service.d.ts +9 -11
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -1
- package/dest/tree_membership/tree_membership_service.js +25 -34
- package/package.json +18 -18
- package/src/block_synchronizer/block_synchronizer.ts +30 -12
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +42 -16
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +4 -0
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +8 -7
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +6 -6
- package/src/contract_function_simulator/oracle/oracle.ts +24 -22
- package/src/contract_function_simulator/oracle/private_execution.ts +10 -19
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +13 -38
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +56 -50
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/events/event_service.ts +17 -21
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +149 -0
- package/src/logs/log_service.ts +3 -1
- package/src/notes/note_service.ts +23 -29
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
- package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +98 -116
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +20 -0
- package/src/storage/note_store/note_store.ts +98 -95
- package/src/storage/private_event_store/private_event_store.ts +199 -37
- package/src/storage/tagging_store/recipient_tagging_store.ts +89 -13
- package/src/storage/tagging_store/sender_tagging_store.ts +129 -28
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/index.ts +1 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +10 -6
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +8 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +6 -2
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -1
- package/src/tree_membership/tree_membership_service.ts +27 -42
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
|
@@ -32,19 +32,22 @@ export class ExecutionNoteCache {
|
|
|
32
32
|
private nullifierMap: Map<bigint, Set<bigint>> = new Map();
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Nullifiers emitted by private calls in this transaction.
|
|
36
36
|
*/
|
|
37
|
-
private
|
|
37
|
+
private emittedNullifiers: Set<bigint> = new Set();
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* The counter that separates non-revertible side effects (which persist even if the tx reverts) from revertible ones.
|
|
41
|
+
*/
|
|
39
42
|
private minRevertibleSideEffectCounter = 0;
|
|
40
43
|
|
|
41
44
|
private inRevertiblePhase = false;
|
|
42
45
|
|
|
43
46
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
47
|
+
* Whether the protocol nullifier was used for nonce generation.
|
|
48
|
+
* We don't need to use the protocol nullifier if a non-revertible nullifier is emitted.
|
|
46
49
|
*/
|
|
47
|
-
private usedProtocolNullifierForNonces
|
|
50
|
+
private usedProtocolNullifierForNonces: boolean | undefined;
|
|
48
51
|
|
|
49
52
|
constructor(private readonly protocolNullifier: Fr) {}
|
|
50
53
|
|
|
@@ -60,17 +63,18 @@ export class ExecutionNoteCache {
|
|
|
60
63
|
}
|
|
61
64
|
this.inRevertiblePhase = true;
|
|
62
65
|
this.minRevertibleSideEffectCounter = minRevertibleSideEffectCounter;
|
|
63
|
-
|
|
64
|
-
const nullifiers = this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
|
|
67
|
+
const nullifiers = this.getEmittedNullifiers();
|
|
68
|
+
// If there are no nullifiers emitted by private calls so far, we use the protocol nullifier as the nonce generator.
|
|
69
|
+
// Note: There could still be nullifiers emitted after the counter is set, but those nullifiers are revertible, so
|
|
70
|
+
// we don't want to use them as the nonce generator.
|
|
71
|
+
this.usedProtocolNullifierForNonces = nullifiers.length === 0;
|
|
72
|
+
const nonceGenerator = this.usedProtocolNullifierForNonces ? this.protocolNullifier : new Fr(nullifiers[0]);
|
|
69
73
|
|
|
70
74
|
// The existing pending notes are all non-revertible.
|
|
71
75
|
// They cannot be squashed by nullifiers emitted after minRevertibleSideEffectCounter is set.
|
|
72
76
|
// Their indexes in the tx are known at this point and won't change. So we can assign a nonce to each one of them.
|
|
73
|
-
// The nonces will be used to create the "
|
|
77
|
+
// The nonces will be used to create the "unique" note hashes.
|
|
74
78
|
const updatedNotes = await Promise.all(
|
|
75
79
|
this.notes.map(async ({ note, counter }, i) => {
|
|
76
80
|
const noteNonce = await computeNoteHashNonce(nonceGenerator, i);
|
|
@@ -99,15 +103,11 @@ export class ExecutionNoteCache {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
public finish() {
|
|
102
|
-
// If we never entered the revertible phase,
|
|
103
|
-
//
|
|
106
|
+
// If we never entered the revertible phase, and there are no nullifiers emitted, we need to use the protocol
|
|
107
|
+
// nullifier as the nonce generator.
|
|
104
108
|
if (!this.inRevertiblePhase) {
|
|
105
|
-
this.usedProtocolNullifierForNonces = this.
|
|
109
|
+
this.usedProtocolNullifierForNonces = this.getEmittedNullifiers().length === 0;
|
|
106
110
|
}
|
|
107
|
-
// If we entered the revertible phase, the nonce generator was decided based on wether or not a nullifier was emitted before entering.
|
|
108
|
-
return {
|
|
109
|
-
usedProtocolNullifierForNonces: this.usedProtocolNullifierForNonces,
|
|
110
|
-
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -150,11 +150,11 @@ export class ExecutionNoteCache {
|
|
|
150
150
|
|
|
151
151
|
// If the note is non revertible and the nullifier was emitted in the revertible phase, both the note hash and the nullifier will be emitted
|
|
152
152
|
if (this.inRevertiblePhase && note.counter < this.minRevertibleSideEffectCounter) {
|
|
153
|
-
this
|
|
153
|
+
this.#recordNullifier(contractAddress, siloedNullifier);
|
|
154
154
|
}
|
|
155
155
|
} else {
|
|
156
156
|
// If the note being nullified comes from a previous tx the nullifier will be emitted.
|
|
157
|
-
this
|
|
157
|
+
this.#recordNullifier(contractAddress, siloedNullifier);
|
|
158
158
|
}
|
|
159
159
|
return nullifiedNoteHashCounter;
|
|
160
160
|
}
|
|
@@ -166,7 +166,7 @@ export class ExecutionNoteCache {
|
|
|
166
166
|
*/
|
|
167
167
|
public async nullifierCreated(contractAddress: AztecAddress, innerNullifier: Fr) {
|
|
168
168
|
const siloedNullifier = (await siloNullifier(contractAddress, innerNullifier)).toBigInt();
|
|
169
|
-
this
|
|
169
|
+
this.#recordNullifier(contractAddress, siloedNullifier);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -215,11 +215,30 @@ export class ExecutionNoteCache {
|
|
|
215
215
|
return this.notes;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* @returns All nullifiers emitted by private calls in this transaction.
|
|
220
|
+
*/
|
|
221
|
+
getEmittedNullifiers(): Fr[] {
|
|
222
|
+
return [...this.emittedNullifiers].map(n => new Fr(n));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @returns All nullifiers emitted by private calls in this transaction. If the protocol nullifier was used as the
|
|
227
|
+
* nonce generator, it is injected as the first nullifier.
|
|
228
|
+
*/
|
|
218
229
|
getAllNullifiers(): Fr[] {
|
|
219
|
-
|
|
230
|
+
if (this.usedProtocolNullifierForNonces === undefined) {
|
|
231
|
+
throw new Error('usedProtocolNullifierForNonces is not set yet. Call finish() to complete the transaction.');
|
|
232
|
+
}
|
|
233
|
+
const allNullifiers = this.getEmittedNullifiers();
|
|
234
|
+
return [...(this.usedProtocolNullifierForNonces ? [this.protocolNullifier] : []), ...allNullifiers];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
getNonceGenerator(): Fr {
|
|
238
|
+
return this.getAllNullifiers()[0];
|
|
220
239
|
}
|
|
221
240
|
|
|
222
|
-
recordNullifier(contractAddress: AztecAddress, siloedNullifier: bigint) {
|
|
241
|
+
#recordNullifier(contractAddress: AztecAddress, siloedNullifier: bigint) {
|
|
223
242
|
const nullifiers = this.getNullifiers(contractAddress);
|
|
224
243
|
|
|
225
244
|
if (nullifiers.has(siloedNullifier)) {
|
|
@@ -228,6 +247,6 @@ export class ExecutionNoteCache {
|
|
|
228
247
|
|
|
229
248
|
nullifiers.add(siloedNullifier);
|
|
230
249
|
this.nullifierMap.set(contractAddress.toBigInt(), nullifiers);
|
|
231
|
-
this.
|
|
250
|
+
this.emittedNullifiers.add(siloedNullifier);
|
|
232
251
|
}
|
|
233
252
|
}
|
|
@@ -15,6 +15,7 @@ export class EventValidationRequest {
|
|
|
15
15
|
constructor(
|
|
16
16
|
public contractAddress: AztecAddress,
|
|
17
17
|
public eventTypeId: EventSelector,
|
|
18
|
+
public randomness: Fr,
|
|
18
19
|
public serializedEvent: Fr[],
|
|
19
20
|
public eventCommitment: Fr,
|
|
20
21
|
public txHash: TxHash,
|
|
@@ -27,6 +28,8 @@ export class EventValidationRequest {
|
|
|
27
28
|
const contractAddress = AztecAddress.fromField(reader.readField());
|
|
28
29
|
const eventTypeId = EventSelector.fromField(reader.readField());
|
|
29
30
|
|
|
31
|
+
const randomness = reader.readField();
|
|
32
|
+
|
|
30
33
|
const eventStorage = reader.readFieldArray(MAX_EVENT_SERIALIZED_LEN);
|
|
31
34
|
const eventLen = reader.readField().toNumber();
|
|
32
35
|
const serializedEvent = eventStorage.slice(0, eventLen);
|
|
@@ -38,6 +41,7 @@ export class EventValidationRequest {
|
|
|
38
41
|
return new EventValidationRequest(
|
|
39
42
|
contractAddress,
|
|
40
43
|
eventTypeId,
|
|
44
|
+
randomness,
|
|
41
45
|
serializedEvent,
|
|
42
46
|
eventCommitment,
|
|
43
47
|
txHash,
|
|
@@ -1,42 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
1
|
+
import { toACVMField } from '@aztec/simulator/client';
|
|
3
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type {
|
|
3
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* TypeScript counterpart of utility_context.nr. Used only as a return value for the utilityGetUtilityContext oracle.
|
|
8
7
|
*/
|
|
9
8
|
export class UtilityContext {
|
|
10
|
-
|
|
11
|
-
public readonly
|
|
12
|
-
public readonly timestamp: UInt64,
|
|
9
|
+
constructor(
|
|
10
|
+
public readonly blockHeader: BlockHeader,
|
|
13
11
|
public readonly contractAddress: AztecAddress,
|
|
14
|
-
public readonly version: Fr,
|
|
15
|
-
public readonly chainId: Fr,
|
|
16
12
|
) {}
|
|
17
13
|
|
|
18
|
-
static from(fields: FieldsOf<UtilityContext>) {
|
|
19
|
-
return new UtilityContext(
|
|
20
|
-
fields.blockNumber,
|
|
21
|
-
fields.timestamp,
|
|
22
|
-
fields.contractAddress,
|
|
23
|
-
fields.version,
|
|
24
|
-
fields.chainId,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
14
|
/**
|
|
29
15
|
* Returns a representation of the utility context as expected by intrinsic Noir deserialization.
|
|
30
16
|
* The order of the fields has to be the same as the order of the fields in the utility_context.nr.
|
|
31
17
|
*/
|
|
32
18
|
public toNoirRepresentation(): (string | string[])[] {
|
|
33
19
|
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
new Fr(this.timestamp).toString() as string,
|
|
37
|
-
this.contractAddress.toString() as string,
|
|
38
|
-
this.version.toString() as string,
|
|
39
|
-
this.chainId.toString() as string,
|
|
40
|
-
];
|
|
20
|
+
const blockHeaderFields = this.blockHeader.toFields().map(toACVMField);
|
|
21
|
+
return [...blockHeaderFields, this.contractAddress.toString() as string];
|
|
41
22
|
}
|
|
42
23
|
}
|
|
@@ -4,6 +4,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
4
4
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
5
5
|
import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
6
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
7
8
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
8
9
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
9
10
|
import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
|
|
@@ -32,10 +33,10 @@ export interface NoteData {
|
|
|
32
33
|
noteNonce: Fr;
|
|
33
34
|
/** A hash of the note as it gets stored in the note hash tree. */
|
|
34
35
|
noteHash: Fr;
|
|
36
|
+
/** True if the note is pending, false if settled. */
|
|
37
|
+
isPending: boolean;
|
|
35
38
|
/** The corresponding nullifier of the note. Undefined for pending notes. */
|
|
36
39
|
siloedNullifier?: Fr;
|
|
37
|
-
/** The note's leaf index in the note hash tree. Undefined for pending notes. */
|
|
38
|
-
index?: bigint;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
// These interfaces contain the list of oracles required by aztec-nr in order to simulate and execute transactions, i.e.
|
|
@@ -65,14 +66,14 @@ export interface IUtilityExecutionOracle {
|
|
|
65
66
|
utilityGetUtilityContext(): UtilityContext;
|
|
66
67
|
utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
|
|
67
68
|
utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
|
|
68
|
-
utilityGetMembershipWitness(
|
|
69
|
+
utilityGetMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[] | undefined>;
|
|
69
70
|
utilityGetNullifierMembershipWitness(
|
|
70
|
-
|
|
71
|
+
blockHash: L2BlockHash,
|
|
71
72
|
nullifier: Fr,
|
|
72
73
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
73
|
-
utilityGetPublicDataWitness(
|
|
74
|
+
utilityGetPublicDataWitness(blockHash: L2BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
74
75
|
utilityGetLowNullifierMembershipWitness(
|
|
75
|
-
|
|
76
|
+
blockHash: L2BlockHash,
|
|
76
77
|
nullifier: Fr,
|
|
77
78
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
78
79
|
utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
|
|
@@ -102,9 +103,9 @@ export interface IUtilityExecutionOracle {
|
|
|
102
103
|
secret: Fr,
|
|
103
104
|
): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
104
105
|
utilityStorageRead(
|
|
106
|
+
blockHash: L2BlockHash,
|
|
105
107
|
contractAddress: AztecAddress,
|
|
106
108
|
startStorageSlot: Fr,
|
|
107
|
-
blockNumber: BlockNumber,
|
|
108
109
|
numberOfElements: number,
|
|
109
110
|
): Promise<Fr[]>;
|
|
110
111
|
utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
|
|
@@ -28,7 +28,7 @@ function fromRawData(nonzeroNoteHashCounter: boolean, maybeNoteNonce: Fr): { sta
|
|
|
28
28
|
* @param randomness - The randomness injected into the note to get the hiding property of commitments
|
|
29
29
|
* @param storageSlot - The storage slot of the note
|
|
30
30
|
* @param noteNonce - The nonce injected into the note hash preimage by kernels.
|
|
31
|
-
* @param
|
|
31
|
+
* @param isPending - True if the note is pending, false if settled
|
|
32
32
|
* @param note - The note content containing the actual note data
|
|
33
33
|
* @returns The packed note as an array of field elements
|
|
34
34
|
*/
|
|
@@ -38,7 +38,7 @@ export function packAsRetrievedNote({
|
|
|
38
38
|
randomness,
|
|
39
39
|
storageSlot,
|
|
40
40
|
noteNonce,
|
|
41
|
-
|
|
41
|
+
isPending,
|
|
42
42
|
note,
|
|
43
43
|
}: {
|
|
44
44
|
contractAddress: AztecAddress;
|
|
@@ -46,14 +46,14 @@ export function packAsRetrievedNote({
|
|
|
46
46
|
randomness: Fr;
|
|
47
47
|
storageSlot: Fr;
|
|
48
48
|
noteNonce: Fr;
|
|
49
|
-
|
|
49
|
+
isPending: boolean;
|
|
50
50
|
note: Note;
|
|
51
51
|
}) {
|
|
52
|
-
// If
|
|
53
|
-
const
|
|
52
|
+
// If the note is pending it means it has a non-zero note hash counter associated with it.
|
|
53
|
+
const nonZeroNoteHashCounter = isPending;
|
|
54
54
|
|
|
55
55
|
// To pack the note as retrieved note we first need to reconstruct the note metadata.
|
|
56
|
-
const noteMetadata = fromRawData(
|
|
56
|
+
const noteMetadata = fromRawData(nonZeroNoteHashCounter, noteNonce);
|
|
57
57
|
|
|
58
58
|
// Pack in order: note, contract_address, owner, randomness, storage_slot, metadata (stage, maybe_note_nonce)
|
|
59
59
|
return [
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from '@aztec/simulator/client';
|
|
13
13
|
import { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
15
16
|
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
16
17
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
17
18
|
|
|
@@ -138,76 +139,77 @@ export class Oracle {
|
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
async utilityGetMembershipWitness(
|
|
141
|
-
[
|
|
142
|
+
[blockHash]: ACVMField[],
|
|
142
143
|
[treeId]: ACVMField[],
|
|
143
144
|
[leafValue]: ACVMField[],
|
|
144
145
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
145
|
-
const
|
|
146
|
+
const parsedBlockHash = L2BlockHash.fromString(blockHash);
|
|
146
147
|
const parsedTreeId = Fr.fromString(treeId).toNumber();
|
|
147
148
|
const parsedLeafValue = Fr.fromString(leafValue);
|
|
148
149
|
|
|
149
150
|
const witness = await this.handlerAsUtility().utilityGetMembershipWitness(
|
|
150
|
-
|
|
151
|
+
parsedBlockHash,
|
|
151
152
|
parsedTreeId,
|
|
152
153
|
parsedLeafValue,
|
|
153
154
|
);
|
|
154
155
|
if (!witness) {
|
|
155
156
|
throw new Error(
|
|
156
|
-
`Leaf ${leafValue} not found in the tree ${MerkleTreeId[parsedTreeId]} at block ${
|
|
157
|
+
`Leaf ${leafValue} not found in the tree ${MerkleTreeId[parsedTreeId]} at block hash ${parsedBlockHash.toString()}.`,
|
|
157
158
|
);
|
|
158
159
|
}
|
|
159
160
|
return [toACVMField(witness[0]), witness.slice(1).map(toACVMField)];
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
async utilityGetNullifierMembershipWitness(
|
|
163
|
-
[
|
|
164
|
+
[blockHash]: ACVMField[],
|
|
164
165
|
[nullifier]: ACVMField[], // nullifier, we try to find the witness for (to prove inclusion)
|
|
165
166
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
166
|
-
const
|
|
167
|
+
const parsedBlockHash = L2BlockHash.fromString(blockHash);
|
|
167
168
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
168
169
|
|
|
169
170
|
const witness = await this.handlerAsUtility().utilityGetNullifierMembershipWitness(
|
|
170
|
-
|
|
171
|
+
parsedBlockHash,
|
|
171
172
|
parsedNullifier,
|
|
172
173
|
);
|
|
173
174
|
if (!witness) {
|
|
174
|
-
throw new Error(
|
|
175
|
+
throw new Error(
|
|
176
|
+
`Nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
177
|
+
);
|
|
175
178
|
}
|
|
176
179
|
return witness.toNoirRepresentation();
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
async utilityGetLowNullifierMembershipWitness(
|
|
180
|
-
[
|
|
183
|
+
[blockHash]: ACVMField[],
|
|
181
184
|
[nullifier]: ACVMField[], // nullifier, we try to find the low nullifier witness for (to prove non-inclusion)
|
|
182
185
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
183
|
-
const
|
|
186
|
+
const parsedBlockHash = L2BlockHash.fromString(blockHash);
|
|
184
187
|
const parsedNullifier = Fr.fromString(nullifier);
|
|
185
188
|
|
|
186
189
|
const witness = await this.handlerAsUtility().utilityGetLowNullifierMembershipWitness(
|
|
187
|
-
|
|
190
|
+
parsedBlockHash,
|
|
188
191
|
parsedNullifier,
|
|
189
192
|
);
|
|
190
193
|
if (!witness) {
|
|
191
194
|
throw new Error(
|
|
192
|
-
`Low nullifier witness not found for nullifier ${parsedNullifier} at block ${
|
|
195
|
+
`Low nullifier witness not found for nullifier ${parsedNullifier} at block hash ${parsedBlockHash.toString()}.`,
|
|
193
196
|
);
|
|
194
197
|
}
|
|
195
198
|
return witness.toNoirRepresentation();
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
async utilityGetPublicDataWitness(
|
|
199
|
-
[
|
|
202
|
+
[blockHash]: ACVMField[],
|
|
200
203
|
[leafSlot]: ACVMField[],
|
|
201
204
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
202
|
-
const
|
|
205
|
+
const parsedBlockHash = L2BlockHash.fromString(blockHash);
|
|
203
206
|
const parsedLeafSlot = Fr.fromString(leafSlot);
|
|
204
207
|
|
|
205
|
-
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(
|
|
206
|
-
BlockNumber(parsedBlockNumber),
|
|
207
|
-
parsedLeafSlot,
|
|
208
|
-
);
|
|
208
|
+
const witness = await this.handlerAsUtility().utilityGetPublicDataWitness(parsedBlockHash, parsedLeafSlot);
|
|
209
209
|
if (!witness) {
|
|
210
|
-
throw new Error(
|
|
210
|
+
throw new Error(
|
|
211
|
+
`Public data witness not found for slot ${parsedLeafSlot} at block hash ${parsedBlockHash.toString()}.`,
|
|
212
|
+
);
|
|
211
213
|
}
|
|
212
214
|
return witness.toNoirRepresentation();
|
|
213
215
|
}
|
|
@@ -286,7 +288,7 @@ export class Oracle {
|
|
|
286
288
|
randomness: noteData.randomness,
|
|
287
289
|
storageSlot: noteData.storageSlot,
|
|
288
290
|
noteNonce: noteData.noteNonce,
|
|
289
|
-
|
|
291
|
+
isPending: noteData.isPending,
|
|
290
292
|
note: noteData.note,
|
|
291
293
|
}),
|
|
292
294
|
);
|
|
@@ -358,15 +360,15 @@ export class Oracle {
|
|
|
358
360
|
}
|
|
359
361
|
|
|
360
362
|
async utilityStorageRead(
|
|
363
|
+
[blockHash]: ACVMField[],
|
|
361
364
|
[contractAddress]: ACVMField[],
|
|
362
365
|
[startStorageSlot]: ACVMField[],
|
|
363
|
-
[blockNumber]: ACVMField[],
|
|
364
366
|
[numberOfElements]: ACVMField[],
|
|
365
367
|
): Promise<ACVMField[][]> {
|
|
366
368
|
const values = await this.handlerAsUtility().utilityStorageRead(
|
|
369
|
+
L2BlockHash.fromString(blockHash),
|
|
367
370
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
368
371
|
Fr.fromString(startStorageSlot),
|
|
369
|
-
BlockNumber(+blockNumber),
|
|
370
372
|
+numberOfElements,
|
|
371
373
|
);
|
|
372
374
|
return [values.map(toACVMField)];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, PRIVATE_CONTEXT_INPUTS_LENGTH } from '@aztec/constants';
|
|
2
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -19,13 +18,13 @@ import {
|
|
|
19
18
|
countArgumentsSize,
|
|
20
19
|
} from '@aztec/stdlib/abi';
|
|
21
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
22
22
|
import type { ContractInstance } from '@aztec/stdlib/contract';
|
|
23
23
|
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
24
24
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
25
25
|
import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
26
26
|
import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
27
27
|
import { BlockHeader, PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
28
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
29
28
|
|
|
30
29
|
import { ContractStore } from '../../storage/contract_store/index.js';
|
|
31
30
|
import { Oracle } from './oracle.js';
|
|
@@ -85,7 +84,6 @@ export async function executePrivateFunction(
|
|
|
85
84
|
|
|
86
85
|
const rawReturnValues = await privateExecutionOracle.privateLoadFromExecutionCache(publicInputs.returnsHash);
|
|
87
86
|
|
|
88
|
-
const noteHashLeafIndexMap = privateExecutionOracle.getNoteHashLeafIndexMap();
|
|
89
87
|
const newNotes = privateExecutionOracle.getNewNotes();
|
|
90
88
|
const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
|
|
91
89
|
const offchainEffects = privateExecutionOracle.getOffchainEffects();
|
|
@@ -108,7 +106,6 @@ export async function executePrivateFunction(
|
|
|
108
106
|
Buffer.from(artifact.verificationKey!, 'base64'),
|
|
109
107
|
partialWitness,
|
|
110
108
|
publicInputs,
|
|
111
|
-
noteHashLeafIndexMap,
|
|
112
109
|
newNotes,
|
|
113
110
|
noteHashNullifierCounterMap,
|
|
114
111
|
rawReturnValues,
|
|
@@ -154,21 +151,22 @@ export function extractPrivateCircuitPublicInputs(
|
|
|
154
151
|
* from the instance is used.
|
|
155
152
|
* @param contractAddress - The address of the contract to read the class id for.
|
|
156
153
|
* @param instance - The instance of the contract.
|
|
157
|
-
* @param
|
|
158
|
-
* @param
|
|
159
|
-
* @param timestamp - The timestamp at which to obtain the class id from the DelayedPublicMutable.
|
|
154
|
+
* @param aztecNode - The Aztec node to query for storage.
|
|
155
|
+
* @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
|
|
160
156
|
* @returns The current class id.
|
|
161
157
|
*/
|
|
162
158
|
export async function readCurrentClassId(
|
|
163
159
|
contractAddress: AztecAddress,
|
|
164
160
|
instance: ContractInstance,
|
|
165
161
|
aztecNode: AztecNode,
|
|
166
|
-
|
|
167
|
-
timestamp: UInt64,
|
|
162
|
+
header: BlockHeader,
|
|
168
163
|
) {
|
|
164
|
+
const blockHashFr = await header.hash();
|
|
165
|
+
const blockHash = L2BlockHash.fromField(blockHashFr);
|
|
166
|
+
const timestamp = header.globalVariables.timestamp;
|
|
169
167
|
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
170
168
|
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
171
|
-
aztecNode.getPublicStorageAt(
|
|
169
|
+
aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
172
170
|
);
|
|
173
171
|
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
174
172
|
if (currentClassId.isZero()) {
|
|
@@ -180,8 +178,7 @@ export async function readCurrentClassId(
|
|
|
180
178
|
/**
|
|
181
179
|
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
182
180
|
* provider (i.e. PXE's own storage).
|
|
183
|
-
* @param header - The header of the block at which to verify the current class id.
|
|
184
|
-
* header of the execution data provider is used.
|
|
181
|
+
* @param header - The header of the block at which to verify the current class id.
|
|
185
182
|
*/
|
|
186
183
|
export async function verifyCurrentClassId(
|
|
187
184
|
contractAddress: AztecAddress,
|
|
@@ -194,13 +191,7 @@ export async function verifyCurrentClassId(
|
|
|
194
191
|
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
const currentClassId = await readCurrentClassId(
|
|
198
|
-
contractAddress,
|
|
199
|
-
instance,
|
|
200
|
-
aztecNode,
|
|
201
|
-
header.globalVariables.blockNumber,
|
|
202
|
-
header.globalVariables.timestamp,
|
|
203
|
-
);
|
|
194
|
+
const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
|
|
204
195
|
if (!instance.currentContractClassId.equals(currentClassId)) {
|
|
205
196
|
throw new Error(
|
|
206
197
|
`Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
|
|
@@ -7,13 +7,14 @@ import { type CircuitSimulator, toACVMWitness } from '@aztec/simulator/client';
|
|
|
7
7
|
import {
|
|
8
8
|
type FunctionAbi,
|
|
9
9
|
type FunctionArtifact,
|
|
10
|
+
type FunctionCall,
|
|
10
11
|
FunctionSelector,
|
|
11
12
|
type NoteSelector,
|
|
12
13
|
countArgumentsSize,
|
|
13
14
|
} from '@aztec/stdlib/abi';
|
|
14
15
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
15
16
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
|
-
import {
|
|
17
|
+
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
17
18
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
18
19
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
19
20
|
import { type ContractClassLog, DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
@@ -63,16 +64,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
63
64
|
* Users can also use this to get a clearer idea of what's happened during a simulation.
|
|
64
65
|
*/
|
|
65
66
|
private newNotes: NoteAndSlot[] = [];
|
|
66
|
-
/**
|
|
67
|
-
* Notes from previous transactions that are returned to the oracle call `getNotes` during this execution.
|
|
68
|
-
* The mapping maps from the unique siloed note hash to the index for notes created in private executions.
|
|
69
|
-
* It maps from siloed note hash to the index for notes created by public functions.
|
|
70
|
-
*
|
|
71
|
-
* They are not part of the ExecutionNoteCache and being forwarded to nested contexts via `extend()`
|
|
72
|
-
* because these notes are meant to be maintained on a per-call basis
|
|
73
|
-
* They should act as references for the read requests output by an app circuit via public inputs.
|
|
74
|
-
*/
|
|
75
|
-
private noteHashLeafIndexMap: Map<bigint, bigint> = new Map();
|
|
76
67
|
private noteHashNullifierCounterMap: Map<number, number> = new Map();
|
|
77
68
|
private contractClassLogs: CountedContractClassLog[] = [];
|
|
78
69
|
private offchainEffects: { data: Fr[] }[] = [];
|
|
@@ -84,6 +75,8 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
84
75
|
private readonly callContext: CallContext,
|
|
85
76
|
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
86
77
|
protected override readonly anchorBlockHeader: BlockHeader,
|
|
78
|
+
/** Needed to trigger contract synchronization before nested calls */
|
|
79
|
+
private readonly utilityExecutor: (call: FunctionCall) => Promise<void>,
|
|
87
80
|
/** List of transient auth witnesses to be used during this simulation */
|
|
88
81
|
authWitnesses: AuthWitness[],
|
|
89
82
|
capsules: Capsule[],
|
|
@@ -101,6 +94,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
101
94
|
senderAddressBookStore: SenderAddressBookStore,
|
|
102
95
|
capsuleStore: CapsuleStore,
|
|
103
96
|
privateEventStore: PrivateEventStore,
|
|
97
|
+
jobId: string,
|
|
104
98
|
private totalPublicCalldataCount: number = 0,
|
|
105
99
|
protected sideEffectCounter: number = 0,
|
|
106
100
|
log = createLogger('simulator:client_execution_context'),
|
|
@@ -123,6 +117,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
123
117
|
senderAddressBookStore,
|
|
124
118
|
capsuleStore,
|
|
125
119
|
privateEventStore,
|
|
120
|
+
jobId,
|
|
126
121
|
log,
|
|
127
122
|
scopes,
|
|
128
123
|
);
|
|
@@ -157,14 +152,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
157
152
|
return toACVMWitness(0, fields);
|
|
158
153
|
}
|
|
159
154
|
|
|
160
|
-
/**
|
|
161
|
-
* The KernelProver will use this to fully populate witnesses and provide hints to the kernel circuit
|
|
162
|
-
* regarding which note hash each settled read request corresponds to.
|
|
163
|
-
*/
|
|
164
|
-
public getNoteHashLeafIndexMap() {
|
|
165
|
-
return this.noteHashLeafIndexMap;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
155
|
/**
|
|
169
156
|
* Get the data for the newly created notes.
|
|
170
157
|
*/
|
|
@@ -278,9 +265,9 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
278
265
|
// This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
|
|
279
266
|
// are up to date. We do this here because this store is not synced as part of the global sync because
|
|
280
267
|
// that'd be wasteful as most tagging secrets are not used in each tx.
|
|
281
|
-
await syncSenderTaggingIndexes(secret, this.contractAddress, this.aztecNode, this.senderTaggingStore);
|
|
268
|
+
await syncSenderTaggingIndexes(secret, this.contractAddress, this.aztecNode, this.senderTaggingStore, this.jobId);
|
|
282
269
|
|
|
283
|
-
const lastUsedIndex = await this.senderTaggingStore.getLastUsedIndex(secret);
|
|
270
|
+
const lastUsedIndex = await this.senderTaggingStore.getLastUsedIndex(secret, this.jobId);
|
|
284
271
|
// If lastUsedIndex is undefined, we've never used this secret, so start from 0
|
|
285
272
|
// Otherwise, the next index to use is one past the last used index
|
|
286
273
|
return lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
|
|
@@ -399,23 +386,6 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
399
386
|
.join(', ')}`,
|
|
400
387
|
);
|
|
401
388
|
|
|
402
|
-
const noteHashesAndIndexes = await Promise.all(
|
|
403
|
-
notes.map(async n => {
|
|
404
|
-
if (n.index !== undefined) {
|
|
405
|
-
const siloedNoteHash = await siloNoteHash(n.contractAddress, n.noteHash);
|
|
406
|
-
const uniqueNoteHash = await computeUniqueNoteHash(n.noteNonce, siloedNoteHash);
|
|
407
|
-
|
|
408
|
-
return { hash: uniqueNoteHash, index: n.index };
|
|
409
|
-
}
|
|
410
|
-
}),
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
noteHashesAndIndexes
|
|
414
|
-
.filter(n => n !== undefined)
|
|
415
|
-
.forEach(n => {
|
|
416
|
-
this.noteHashLeafIndexMap.set(n!.hash.toBigInt(), n!.index);
|
|
417
|
-
});
|
|
418
|
-
|
|
419
389
|
return notes;
|
|
420
390
|
}
|
|
421
391
|
|
|
@@ -458,6 +428,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
458
428
|
note,
|
|
459
429
|
siloedNullifier: undefined, // Siloed nullifier cannot be known for newly created note.
|
|
460
430
|
noteHash,
|
|
431
|
+
isPending: true, // This note has just been created and hence is not settled yet.
|
|
461
432
|
},
|
|
462
433
|
counter,
|
|
463
434
|
);
|
|
@@ -550,6 +521,8 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
550
521
|
|
|
551
522
|
await verifyCurrentClassId(targetContractAddress, this.aztecNode, this.contractStore, this.anchorBlockHeader);
|
|
552
523
|
|
|
524
|
+
await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, this.utilityExecutor);
|
|
525
|
+
|
|
553
526
|
const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(
|
|
554
527
|
targetContractAddress,
|
|
555
528
|
functionSelector,
|
|
@@ -564,6 +537,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
564
537
|
derivedTxContext,
|
|
565
538
|
derivedCallContext,
|
|
566
539
|
this.anchorBlockHeader,
|
|
540
|
+
this.utilityExecutor,
|
|
567
541
|
this.authWitnesses,
|
|
568
542
|
this.capsules,
|
|
569
543
|
this.executionCache,
|
|
@@ -580,6 +554,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
580
554
|
this.senderAddressBookStore,
|
|
581
555
|
this.capsuleStore,
|
|
582
556
|
this.privateEventStore,
|
|
557
|
+
this.jobId,
|
|
583
558
|
this.totalPublicCalldataCount,
|
|
584
559
|
sideEffectCounter,
|
|
585
560
|
this.log,
|