@aztec/pxe 3.0.0-nightly.20251222 → 3.0.0-nightly.20251224
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/contract_function_simulator.d.ts +31 -6
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +35 -11
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +7 -6
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -3
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +6 -8
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +10 -9
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +14 -5
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +19 -14
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +44 -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 +135 -30
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +2 -2
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +18 -0
- package/dest/debug/pxe_debug_utils.d.ts +3 -2
- 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/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/server/index.d.ts +2 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -1
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +47 -0
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/logs/log_service.d.ts +43 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +239 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +152 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/public_storage/public_storage_service.d.ts +24 -0
- package/dest/public_storage/public_storage_service.d.ts.map +1 -0
- package/dest/public_storage/public_storage_service.js +26 -0
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +3 -5
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +33 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +32 -4
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +2 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +11 -0
- package/dest/storage/tagging_data_provider/sender_tagging_data_provider.js +3 -3
- package/dest/tagging/index.d.ts +2 -4
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts +21 -0
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/new_recipient_tagging_data_provider.js +42 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts +2 -2
- package/dest/tagging/sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sync/sync_sender_tagging_indexes.js +3 -3
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sync/utils/load_and_store_new_tagging_indexes.js +3 -5
- package/dest/tree_membership/tree_membership_service.d.ts +52 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +84 -0
- package/package.json +16 -16
- package/src/contract_function_simulator/contract_function_simulator.ts +59 -10
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +5 -4
- package/src/contract_function_simulator/oracle/interfaces.ts +1 -2
- package/src/contract_function_simulator/oracle/private_execution.ts +13 -10
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +81 -21
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +199 -38
- package/src/contract_function_simulator/proxied_contract_data_source.ts +18 -1
- package/src/debug/pxe_debug_utils.ts +2 -1
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/server/index.ts +1 -1
- package/src/events/event_service.ts +77 -0
- package/src/events/private_event_filter_validator.ts +2 -1
- package/src/logs/log_service.ts +364 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +200 -0
- package/src/private_kernel/private_kernel_oracle_impl.ts +1 -1
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +13 -11
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +32 -0
- package/src/storage/contract_data_provider/contract_data_provider.ts +15 -0
- package/src/storage/tagging_data_provider/sender_tagging_data_provider.ts +3 -3
- package/src/tagging/index.ts +1 -3
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
- package/src/tagging/recipient_sync/new_recipient_tagging_data_provider.ts +53 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
- package/src/tagging/sync/sync_sender_tagging_indexes.ts +3 -3
- package/src/tagging/sync/utils/load_and_store_new_tagging_indexes.ts +3 -5
- package/src/tree_membership/tree_membership_service.ts +112 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -248
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -113
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -648
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/src/contract_function_simulator/execution_data_provider.ts +0 -322
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -967
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
|
@@ -21,6 +21,7 @@ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
|
21
21
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
22
22
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
23
23
|
import { Timer } from '@aztec/foundation/timer';
|
|
24
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
24
25
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
25
26
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
26
27
|
import {
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
siloNoteHash,
|
|
45
46
|
siloNullifier,
|
|
46
47
|
} from '@aztec/stdlib/hash';
|
|
48
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
47
49
|
import {
|
|
48
50
|
PartialPrivateTailPublicInputsForPublic,
|
|
49
51
|
PartialPrivateTailPublicInputsForRollup,
|
|
@@ -69,8 +71,14 @@ import {
|
|
|
69
71
|
getFinalMinRevertibleSideEffectCounter,
|
|
70
72
|
} from '@aztec/stdlib/tx';
|
|
71
73
|
|
|
72
|
-
import type {
|
|
73
|
-
import type {
|
|
74
|
+
import type { AddressDataProvider } from '../storage/address_data_provider/address_data_provider.js';
|
|
75
|
+
import type { AnchorBlockDataProvider } from '../storage/anchor_block_data_provider/anchor_block_data_provider.js';
|
|
76
|
+
import type { CapsuleDataProvider } from '../storage/capsule_data_provider/capsule_data_provider.js';
|
|
77
|
+
import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
|
|
78
|
+
import type { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
|
|
79
|
+
import type { PrivateEventDataProvider } from '../storage/private_event_data_provider/private_event_data_provider.js';
|
|
80
|
+
import type { RecipientTaggingDataProvider } from '../storage/tagging_data_provider/recipient_tagging_data_provider.js';
|
|
81
|
+
import type { SenderTaggingDataProvider } from '../storage/tagging_data_provider/sender_tagging_data_provider.js';
|
|
74
82
|
import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
75
83
|
import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
|
|
76
84
|
import { HashedValuesCache } from './hashed_values_cache.js';
|
|
@@ -78,6 +86,7 @@ import { Oracle } from './oracle/oracle.js';
|
|
|
78
86
|
import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
|
|
79
87
|
import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
80
88
|
import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
89
|
+
import type { ProxiedNode } from './proxied_node.js';
|
|
81
90
|
|
|
82
91
|
/**
|
|
83
92
|
* The contract function simulator.
|
|
@@ -86,7 +95,16 @@ export class ContractFunctionSimulator {
|
|
|
86
95
|
private log: Logger;
|
|
87
96
|
|
|
88
97
|
constructor(
|
|
89
|
-
private
|
|
98
|
+
private contractDataProvider: ContractDataProvider,
|
|
99
|
+
private noteDataProvider: NoteDataProvider,
|
|
100
|
+
private keyStore: KeyStore,
|
|
101
|
+
private addressDataProvider: AddressDataProvider,
|
|
102
|
+
private aztecNode: AztecNode,
|
|
103
|
+
private anchorBlockDataProvider: AnchorBlockDataProvider,
|
|
104
|
+
private senderTaggingDataProvider: SenderTaggingDataProvider,
|
|
105
|
+
private recipientTaggingDataProvider: RecipientTaggingDataProvider,
|
|
106
|
+
private capsuleDataProvider: CapsuleDataProvider,
|
|
107
|
+
private privateEventDataProvider: PrivateEventDataProvider,
|
|
90
108
|
private simulator: CircuitSimulator,
|
|
91
109
|
) {
|
|
92
110
|
this.log = createLogger('simulator');
|
|
@@ -116,9 +134,12 @@ export class ContractFunctionSimulator {
|
|
|
116
134
|
): Promise<PrivateExecutionResult> {
|
|
117
135
|
const simulatorSetupTimer = new Timer();
|
|
118
136
|
|
|
119
|
-
await verifyCurrentClassId(contractAddress, this.
|
|
137
|
+
await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractDataProvider, anchorBlockHeader);
|
|
120
138
|
|
|
121
|
-
const entryPointArtifact = await this.
|
|
139
|
+
const entryPointArtifact = await this.contractDataProvider.getFunctionArtifactWithDebugMetadata(
|
|
140
|
+
contractAddress,
|
|
141
|
+
selector,
|
|
142
|
+
);
|
|
122
143
|
|
|
123
144
|
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
124
145
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
|
|
@@ -154,7 +175,16 @@ export class ContractFunctionSimulator {
|
|
|
154
175
|
HashedValuesCache.create(request.argsOfCalls),
|
|
155
176
|
noteCache,
|
|
156
177
|
taggingIndexCache,
|
|
157
|
-
this.
|
|
178
|
+
this.contractDataProvider,
|
|
179
|
+
this.noteDataProvider,
|
|
180
|
+
this.keyStore,
|
|
181
|
+
this.addressDataProvider,
|
|
182
|
+
this.aztecNode,
|
|
183
|
+
this.anchorBlockDataProvider,
|
|
184
|
+
this.senderTaggingDataProvider,
|
|
185
|
+
this.recipientTaggingDataProvider,
|
|
186
|
+
this.capsuleDataProvider,
|
|
187
|
+
this.privateEventDataProvider,
|
|
158
188
|
0, // totalPublicArgsCount
|
|
159
189
|
startSideEffectCounter,
|
|
160
190
|
undefined, // log
|
|
@@ -226,9 +256,12 @@ export class ContractFunctionSimulator {
|
|
|
226
256
|
anchorBlockHeader: BlockHeader,
|
|
227
257
|
scopes?: AztecAddress[],
|
|
228
258
|
): Promise<Fr[]> {
|
|
229
|
-
await verifyCurrentClassId(call.to, this.
|
|
259
|
+
await verifyCurrentClassId(call.to, this.aztecNode, this.contractDataProvider, anchorBlockHeader);
|
|
230
260
|
|
|
231
|
-
const entryPointArtifact = await this.
|
|
261
|
+
const entryPointArtifact = await this.contractDataProvider.getFunctionArtifactWithDebugMetadata(
|
|
262
|
+
call.to,
|
|
263
|
+
call.selector,
|
|
264
|
+
);
|
|
232
265
|
|
|
233
266
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
234
267
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -239,7 +272,16 @@ export class ContractFunctionSimulator {
|
|
|
239
272
|
authwits,
|
|
240
273
|
[],
|
|
241
274
|
anchorBlockHeader,
|
|
242
|
-
this.
|
|
275
|
+
this.contractDataProvider,
|
|
276
|
+
this.noteDataProvider,
|
|
277
|
+
this.keyStore,
|
|
278
|
+
this.addressDataProvider,
|
|
279
|
+
this.aztecNode,
|
|
280
|
+
this.anchorBlockDataProvider,
|
|
281
|
+
this.senderTaggingDataProvider,
|
|
282
|
+
this.recipientTaggingDataProvider,
|
|
283
|
+
this.capsuleDataProvider,
|
|
284
|
+
this.privateEventDataProvider,
|
|
243
285
|
undefined,
|
|
244
286
|
scopes,
|
|
245
287
|
);
|
|
@@ -274,8 +316,15 @@ export class ContractFunctionSimulator {
|
|
|
274
316
|
}
|
|
275
317
|
// docs:end:execute_utility_function
|
|
276
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Returns the execution statistics collected during the simulator run.
|
|
321
|
+
* @returns The execution statistics.
|
|
322
|
+
*/
|
|
277
323
|
getStats() {
|
|
278
|
-
|
|
324
|
+
const nodeRPCCalls =
|
|
325
|
+
typeof (this.aztecNode as ProxiedNode).getStats === 'function' ? (this.aztecNode as ProxiedNode).getStats() : {};
|
|
326
|
+
|
|
327
|
+
return { nodeRPCCalls };
|
|
279
328
|
}
|
|
280
329
|
}
|
|
281
330
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import { Tag } from '@aztec/stdlib/logs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle expects values of this
|
|
@@ -9,19 +10,19 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
9
10
|
export class LogRetrievalRequest {
|
|
10
11
|
constructor(
|
|
11
12
|
public contractAddress: AztecAddress,
|
|
12
|
-
public
|
|
13
|
+
public tag: Tag,
|
|
13
14
|
) {}
|
|
14
15
|
|
|
15
16
|
toFields(): Fr[] {
|
|
16
|
-
return [this.contractAddress.toField(), this.
|
|
17
|
+
return [this.contractAddress.toField(), this.tag.value];
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
static fromFields(fields: Fr[] | FieldReader): LogRetrievalRequest {
|
|
20
21
|
const reader = FieldReader.asReader(fields);
|
|
21
22
|
|
|
22
23
|
const contractAddress = AztecAddress.fromField(reader.readField());
|
|
23
|
-
const
|
|
24
|
+
const tag = new Tag(reader.readField());
|
|
24
25
|
|
|
25
|
-
return new LogRetrievalRequest(contractAddress,
|
|
26
|
+
return new LogRetrievalRequest(contractAddress, tag);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -6,12 +6,11 @@ import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
|
6
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
8
8
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
9
|
-
import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
9
|
+
import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
|
|
10
10
|
import type { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
11
11
|
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
12
12
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
13
13
|
|
|
14
|
-
import type { Tag } from '../../tagging/tag.js';
|
|
15
14
|
import type { UtilityContext } from '../noir-structs/utility_context.js';
|
|
16
15
|
import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
17
16
|
|
|
@@ -27,7 +27,7 @@ import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
|
27
27
|
import { BlockHeader, PrivateCallExecutionResult } from '@aztec/stdlib/tx';
|
|
28
28
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
29
29
|
|
|
30
|
-
import
|
|
30
|
+
import { ContractDataProvider } from '../../storage/contract_data_provider/index.js';
|
|
31
31
|
import { Oracle } from './oracle.js';
|
|
32
32
|
import type { PrivateExecutionOracle } from './private_execution_oracle.js';
|
|
33
33
|
|
|
@@ -162,13 +162,13 @@ export function extractPrivateCircuitPublicInputs(
|
|
|
162
162
|
export async function readCurrentClassId(
|
|
163
163
|
contractAddress: AztecAddress,
|
|
164
164
|
instance: ContractInstance,
|
|
165
|
-
|
|
165
|
+
aztecNode: AztecNode,
|
|
166
166
|
blockNumber: BlockNumber,
|
|
167
167
|
timestamp: UInt64,
|
|
168
168
|
) {
|
|
169
169
|
const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
170
170
|
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
|
|
171
|
-
|
|
171
|
+
aztecNode.getPublicStorageAt(blockNumber, ProtocolContractAddress.ContractInstanceRegistry, slot),
|
|
172
172
|
);
|
|
173
173
|
let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
|
|
174
174
|
if (currentClassId.isZero()) {
|
|
@@ -178,23 +178,26 @@ export async function readCurrentClassId(
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in
|
|
182
|
-
* provider (i.e. PXE).
|
|
183
|
-
* @param contractAddress - The address of the contract to verify class id for.
|
|
184
|
-
* @param executionDataProvider - The execution data provider.
|
|
181
|
+
* Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
|
|
182
|
+
* provider (i.e. PXE's own storage).
|
|
185
183
|
* @param header - The header of the block at which to verify the current class id. If not provided, the anchor block
|
|
186
184
|
* header of the execution data provider is used.
|
|
187
185
|
*/
|
|
188
186
|
export async function verifyCurrentClassId(
|
|
189
187
|
contractAddress: AztecAddress,
|
|
190
|
-
|
|
188
|
+
aztecNode: AztecNode,
|
|
189
|
+
contractDataProvider: ContractDataProvider,
|
|
191
190
|
header: BlockHeader,
|
|
192
191
|
) {
|
|
193
|
-
const instance = await
|
|
192
|
+
const instance = await contractDataProvider.getContractInstance(contractAddress);
|
|
193
|
+
if (!instance) {
|
|
194
|
+
throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
194
197
|
const currentClassId = await readCurrentClassId(
|
|
195
198
|
contractAddress,
|
|
196
199
|
instance,
|
|
197
|
-
|
|
200
|
+
aztecNode,
|
|
198
201
|
header.globalVariables.blockNumber,
|
|
199
202
|
header.globalVariables.timestamp,
|
|
200
203
|
);
|
|
@@ -2,6 +2,7 @@ import { MAX_FR_CALLDATA_TO_ALL_ENQUEUED_CALLS, PRIVATE_CONTEXT_INPUTS_LENGTH }
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
|
+
import type { KeyStore } from '@aztec/key-store';
|
|
5
6
|
import { type CircuitSimulator, toACVMWitness } from '@aztec/simulator/client';
|
|
6
7
|
import {
|
|
7
8
|
type FunctionAbi,
|
|
@@ -13,8 +14,10 @@ import {
|
|
|
13
14
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
14
15
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
16
|
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
17
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
16
18
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
17
|
-
import type
|
|
19
|
+
import { type ContractClassLog, DirectionalAppTaggingSecret, type PreTag } from '@aztec/stdlib/logs';
|
|
20
|
+
import { Tag } from '@aztec/stdlib/logs';
|
|
18
21
|
import { Note, type NoteStatus } from '@aztec/stdlib/note';
|
|
19
22
|
import {
|
|
20
23
|
type BlockHeader,
|
|
@@ -26,9 +29,16 @@ import {
|
|
|
26
29
|
type TxContext,
|
|
27
30
|
} from '@aztec/stdlib/tx';
|
|
28
31
|
|
|
32
|
+
import { NoteService } from '../../notes/note_service.js';
|
|
33
|
+
import type { AddressDataProvider } from '../../storage/address_data_provider/address_data_provider.js';
|
|
34
|
+
import type { AnchorBlockDataProvider } from '../../storage/anchor_block_data_provider/anchor_block_data_provider.js';
|
|
35
|
+
import type { CapsuleDataProvider } from '../../storage/capsule_data_provider/capsule_data_provider.js';
|
|
36
|
+
import type { ContractDataProvider } from '../../storage/contract_data_provider/contract_data_provider.js';
|
|
37
|
+
import type { NoteDataProvider } from '../../storage/note_data_provider/note_data_provider.js';
|
|
38
|
+
import type { PrivateEventDataProvider } from '../../storage/private_event_data_provider/private_event_data_provider.js';
|
|
39
|
+
import type { RecipientTaggingDataProvider } from '../../storage/tagging_data_provider/recipient_tagging_data_provider.js';
|
|
40
|
+
import type { SenderTaggingDataProvider } from '../../storage/tagging_data_provider/sender_tagging_data_provider.js';
|
|
29
41
|
import { syncSenderTaggingIndexes } from '../../tagging/sync/sync_sender_tagging_indexes.js';
|
|
30
|
-
import { Tag } from '../../tagging/tag.js';
|
|
31
|
-
import type { ExecutionDataProvider } from '../execution_data_provider.js';
|
|
32
42
|
import type { ExecutionNoteCache } from '../execution_note_cache.js';
|
|
33
43
|
import { ExecutionTaggingIndexCache } from '../execution_tagging_index_cache.js';
|
|
34
44
|
import type { HashedValuesCache } from '../hashed_values_cache.js';
|
|
@@ -79,7 +89,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
79
89
|
private readonly executionCache: HashedValuesCache,
|
|
80
90
|
private readonly noteCache: ExecutionNoteCache,
|
|
81
91
|
private readonly taggingIndexCache: ExecutionTaggingIndexCache,
|
|
82
|
-
|
|
92
|
+
contractDataProvider: ContractDataProvider,
|
|
93
|
+
noteDataProvider: NoteDataProvider,
|
|
94
|
+
keyStore: KeyStore,
|
|
95
|
+
addressDataProvider: AddressDataProvider,
|
|
96
|
+
aztecNode: AztecNode,
|
|
97
|
+
anchorBlockDataProvider: AnchorBlockDataProvider,
|
|
98
|
+
senderTaggingDataProvider: SenderTaggingDataProvider,
|
|
99
|
+
recipientTaggingDataProvider: RecipientTaggingDataProvider,
|
|
100
|
+
capsuleDataProvider: CapsuleDataProvider,
|
|
101
|
+
privateEventDataProvider: PrivateEventDataProvider,
|
|
83
102
|
private totalPublicCalldataCount: number = 0,
|
|
84
103
|
protected sideEffectCounter: number = 0,
|
|
85
104
|
log = createLogger('simulator:client_execution_context'),
|
|
@@ -87,7 +106,24 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
87
106
|
private senderForTags?: AztecAddress,
|
|
88
107
|
private simulator?: CircuitSimulator,
|
|
89
108
|
) {
|
|
90
|
-
super(
|
|
109
|
+
super(
|
|
110
|
+
callContext.contractAddress,
|
|
111
|
+
authWitnesses,
|
|
112
|
+
capsules,
|
|
113
|
+
anchorBlockHeader,
|
|
114
|
+
contractDataProvider,
|
|
115
|
+
noteDataProvider,
|
|
116
|
+
keyStore,
|
|
117
|
+
addressDataProvider,
|
|
118
|
+
aztecNode,
|
|
119
|
+
anchorBlockDataProvider,
|
|
120
|
+
senderTaggingDataProvider,
|
|
121
|
+
recipientTaggingDataProvider,
|
|
122
|
+
capsuleDataProvider,
|
|
123
|
+
privateEventDataProvider,
|
|
124
|
+
log,
|
|
125
|
+
scopes,
|
|
126
|
+
);
|
|
91
127
|
}
|
|
92
128
|
|
|
93
129
|
public getPrivateContextInputs(): PrivateContextInputs {
|
|
@@ -203,11 +239,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
203
239
|
* @returns An app tag to be used in a log.
|
|
204
240
|
*/
|
|
205
241
|
public async privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag> {
|
|
206
|
-
const secret = await this
|
|
207
|
-
this.contractAddress,
|
|
208
|
-
sender,
|
|
209
|
-
recipient,
|
|
210
|
-
);
|
|
242
|
+
const secret = await this.#calculateDirectionalAppTaggingSecret(this.contractAddress, sender, recipient);
|
|
211
243
|
|
|
212
244
|
const index = await this.#getIndexToUseForSecret(secret);
|
|
213
245
|
this.log.debug(
|
|
@@ -218,6 +250,22 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
218
250
|
return Tag.compute({ secret, index });
|
|
219
251
|
}
|
|
220
252
|
|
|
253
|
+
async #calculateDirectionalAppTaggingSecret(
|
|
254
|
+
contractAddress: AztecAddress,
|
|
255
|
+
sender: AztecAddress,
|
|
256
|
+
recipient: AztecAddress,
|
|
257
|
+
) {
|
|
258
|
+
const senderCompleteAddress = await this.getCompleteAddress(sender);
|
|
259
|
+
const senderIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(sender);
|
|
260
|
+
return DirectionalAppTaggingSecret.compute(
|
|
261
|
+
senderCompleteAddress,
|
|
262
|
+
senderIvsk,
|
|
263
|
+
recipient,
|
|
264
|
+
contractAddress,
|
|
265
|
+
recipient,
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
221
269
|
async #getIndexToUseForSecret(secret: DirectionalAppTaggingSecret): Promise<number> {
|
|
222
270
|
// If we have the tagging index in the cache, we use it. If not we obtain it from the execution data provider.
|
|
223
271
|
const lastUsedIndexInTx = this.taggingIndexCache.getLastUsedIndex(secret);
|
|
@@ -225,16 +273,12 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
225
273
|
if (lastUsedIndexInTx !== undefined) {
|
|
226
274
|
return lastUsedIndexInTx + 1;
|
|
227
275
|
} else {
|
|
228
|
-
// TODO(#17776): Don't access the Aztec node and senderTaggingDataProvider via the executionDataProvider.
|
|
229
|
-
const aztecNode = this.executionDataProvider.aztecNode;
|
|
230
|
-
const senderTaggingDataProvider = this.executionDataProvider.senderTaggingDataProvider;
|
|
231
|
-
|
|
232
276
|
// This is a tagging secret we've not yet used in this tx, so first sync our store to make sure its indices
|
|
233
277
|
// are up to date. We do this here because this store is not synced as part of the global sync because
|
|
234
278
|
// that'd be wasteful as most tagging secrets are not used in each tx.
|
|
235
|
-
await syncSenderTaggingIndexes(secret, this.contractAddress, aztecNode, senderTaggingDataProvider);
|
|
279
|
+
await syncSenderTaggingIndexes(secret, this.contractAddress, this.aztecNode, this.senderTaggingDataProvider);
|
|
236
280
|
|
|
237
|
-
const lastUsedIndex = await senderTaggingDataProvider.getLastUsedIndex(secret);
|
|
281
|
+
const lastUsedIndex = await this.senderTaggingDataProvider.getLastUsedIndex(secret);
|
|
238
282
|
// If lastUsedIndex is undefined, we've never used this secret, so start from 0
|
|
239
283
|
// Otherwise, the next index to use is one past the last used index
|
|
240
284
|
return lastUsedIndex === undefined ? 0 : lastUsedIndex + 1;
|
|
@@ -322,7 +366,9 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
322
366
|
const pendingNotes = this.noteCache.getNotes(this.callContext.contractAddress, owner, storageSlot);
|
|
323
367
|
|
|
324
368
|
const pendingNullifiers = this.noteCache.getNullifiers(this.callContext.contractAddress);
|
|
325
|
-
|
|
369
|
+
|
|
370
|
+
const noteService = new NoteService(this.noteDataProvider, this.aztecNode, this.anchorBlockDataProvider);
|
|
371
|
+
const dbNotes = await noteService.getNotes(
|
|
326
372
|
this.callContext.contractAddress,
|
|
327
373
|
owner,
|
|
328
374
|
storageSlot,
|
|
@@ -500,9 +546,14 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
500
546
|
|
|
501
547
|
isStaticCall = isStaticCall || this.callContext.isStaticCall;
|
|
502
548
|
|
|
503
|
-
await verifyCurrentClassId(
|
|
549
|
+
await verifyCurrentClassId(
|
|
550
|
+
targetContractAddress,
|
|
551
|
+
this.aztecNode,
|
|
552
|
+
this.contractDataProvider,
|
|
553
|
+
this.anchorBlockHeader,
|
|
554
|
+
);
|
|
504
555
|
|
|
505
|
-
const targetArtifact = await this.
|
|
556
|
+
const targetArtifact = await this.contractDataProvider.getFunctionArtifactWithDebugMetadata(
|
|
506
557
|
targetContractAddress,
|
|
507
558
|
functionSelector,
|
|
508
559
|
);
|
|
@@ -521,7 +572,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
521
572
|
this.executionCache,
|
|
522
573
|
this.noteCache,
|
|
523
574
|
this.taggingIndexCache,
|
|
524
|
-
this.
|
|
575
|
+
this.contractDataProvider,
|
|
576
|
+
this.noteDataProvider,
|
|
577
|
+
this.keyStore,
|
|
578
|
+
this.addressDataProvider,
|
|
579
|
+
this.aztecNode,
|
|
580
|
+
this.anchorBlockDataProvider,
|
|
581
|
+
this.senderTaggingDataProvider,
|
|
582
|
+
this.recipientTaggingDataProvider,
|
|
583
|
+
this.capsuleDataProvider,
|
|
584
|
+
this.privateEventDataProvider,
|
|
525
585
|
this.totalPublicCalldataCount,
|
|
526
586
|
sideEffectCounter,
|
|
527
587
|
this.log,
|
|
@@ -634,7 +694,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
634
694
|
}
|
|
635
695
|
|
|
636
696
|
public getDebugFunctionName() {
|
|
637
|
-
return this.
|
|
697
|
+
return this.contractDataProvider.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
|
|
638
698
|
}
|
|
639
699
|
|
|
640
700
|
public utilityEmitOffchainEffect(data: Fr[]): Promise<void> {
|