@aztec/pxe 0.0.1-commit.dbf9cec → 0.0.1-commit.df81a97b5
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/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +28 -6
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
- 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 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -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 -5
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +163 -94
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -47
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +30 -62
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +53 -35
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +101 -43
- package/dest/contract_sync/contract_sync_service.d.ts +5 -3
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +47 -30
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +3 -3
- package/dest/pxe.d.ts +8 -4
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +39 -22
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
- 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 +24 -11
- package/package.json +16 -16
- package/src/config/index.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +39 -7
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
- package/src/contract_function_simulator/oracle/interfaces.ts +54 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
- package/src/contract_function_simulator/oracle/oracle.ts +176 -138
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -80
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +136 -53
- package/src/contract_sync/contract_sync_service.ts +67 -38
- package/src/messages/message_context_service.ts +45 -0
- package/src/oracle_version.ts +3 -3
- package/src/pxe.ts +57 -21
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
- package/src/tagging/index.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
package/src/oracle_version.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
/// to version the oracle interface to ensure that developers get a reasonable error message if they use incompatible
|
|
3
3
|
/// versions of Aztec.nr and PXE. The Noir counterpart is in `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
4
4
|
///
|
|
5
|
-
/// @dev Whenever a contract function or Noir test is run, the `
|
|
5
|
+
/// @dev Whenever a contract function or Noir test is run, the `aztec_utl_assertCompatibleOracleVersion` oracle is called
|
|
6
6
|
/// and if the oracle version is incompatible an error is thrown.
|
|
7
|
-
export const ORACLE_VERSION =
|
|
7
|
+
export const ORACLE_VERSION = 18;
|
|
8
8
|
|
|
9
9
|
/// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
|
|
10
10
|
/// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
|
|
11
11
|
/// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
|
|
12
|
-
export const ORACLE_INTERFACE_HASH = '
|
|
12
|
+
export const ORACLE_INTERFACE_HASH = '57e5b07c6d55fb167ef90f8d0f410f9bdb5b154a31159c624a061be40b02a2c2';
|
package/src/pxe.ts
CHANGED
|
@@ -68,6 +68,7 @@ import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
|
68
68
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
69
69
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
70
70
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
71
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
71
72
|
import {
|
|
72
73
|
PrivateKernelExecutionProver,
|
|
73
74
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -106,7 +107,9 @@ export type SimulateTxOpts = {
|
|
|
106
107
|
skipTxValidation?: boolean;
|
|
107
108
|
/** If false, fees are enforced. */
|
|
108
109
|
skipFeeEnforcement?: boolean;
|
|
109
|
-
/**
|
|
110
|
+
/** If true, kernel logic is emulated in TS for simulation */
|
|
111
|
+
skipKernels?: boolean;
|
|
112
|
+
/** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
|
|
110
113
|
overrides?: SimulationOverrides;
|
|
111
114
|
/** Addresses whose private state and keys are accessible during private execution */
|
|
112
115
|
scopes: AccessScopes;
|
|
@@ -145,6 +148,7 @@ export type PXECreateArgs = {
|
|
|
145
148
|
export class PXE {
|
|
146
149
|
private constructor(
|
|
147
150
|
private node: AztecNode,
|
|
151
|
+
private db: AztecAsyncKVStore,
|
|
148
152
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
149
153
|
private keyStore: KeyStore,
|
|
150
154
|
private contractStore: ContractStore,
|
|
@@ -157,6 +161,7 @@ export class PXE {
|
|
|
157
161
|
private addressStore: AddressStore,
|
|
158
162
|
private privateEventStore: PrivateEventStore,
|
|
159
163
|
private contractSyncService: ContractSyncService,
|
|
164
|
+
private messageContextService: MessageContextService,
|
|
160
165
|
private simulator: CircuitSimulator,
|
|
161
166
|
private proverEnabled: boolean,
|
|
162
167
|
private proofCreator: PrivateKernelProver,
|
|
@@ -212,6 +217,8 @@ export class PXE {
|
|
|
212
217
|
noteStore,
|
|
213
218
|
createLogger('pxe:contract_sync', bindings),
|
|
214
219
|
);
|
|
220
|
+
const messageContextService = new MessageContextService(node);
|
|
221
|
+
|
|
215
222
|
const synchronizer = new BlockSynchronizer(
|
|
216
223
|
node,
|
|
217
224
|
store,
|
|
@@ -240,6 +247,7 @@ export class PXE {
|
|
|
240
247
|
|
|
241
248
|
const pxe = new PXE(
|
|
242
249
|
node,
|
|
250
|
+
store,
|
|
243
251
|
synchronizer,
|
|
244
252
|
keyStore,
|
|
245
253
|
contractStore,
|
|
@@ -252,6 +260,7 @@ export class PXE {
|
|
|
252
260
|
addressStore,
|
|
253
261
|
privateEventStore,
|
|
254
262
|
contractSyncService,
|
|
263
|
+
messageContextService,
|
|
255
264
|
simulator,
|
|
256
265
|
proverEnabled,
|
|
257
266
|
proofCreator,
|
|
@@ -293,6 +302,7 @@ export class PXE {
|
|
|
293
302
|
privateEventStore: this.privateEventStore,
|
|
294
303
|
simulator: this.simulator,
|
|
295
304
|
contractSyncService: this.contractSyncService,
|
|
305
|
+
messageContextService: this.messageContextService,
|
|
296
306
|
});
|
|
297
307
|
}
|
|
298
308
|
|
|
@@ -412,7 +422,14 @@ export class PXE {
|
|
|
412
422
|
) {
|
|
413
423
|
try {
|
|
414
424
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
415
|
-
|
|
425
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(
|
|
426
|
+
call,
|
|
427
|
+
authWitnesses ?? [],
|
|
428
|
+
anchorBlockHeader,
|
|
429
|
+
scopes,
|
|
430
|
+
jobId,
|
|
431
|
+
);
|
|
432
|
+
return { result, offchainEffects };
|
|
416
433
|
} catch (err) {
|
|
417
434
|
if (err instanceof SimulationError) {
|
|
418
435
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -552,6 +569,9 @@ export class PXE {
|
|
|
552
569
|
|
|
553
570
|
if (wasAdded) {
|
|
554
571
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
572
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
573
|
+
// all contracts must re-sync to discover them.
|
|
574
|
+
this.contractSyncService.wipe();
|
|
555
575
|
} else {
|
|
556
576
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
557
577
|
}
|
|
@@ -764,17 +784,17 @@ export class PXE {
|
|
|
764
784
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
765
785
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
766
786
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
787
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
788
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
769
789
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
770
790
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
771
791
|
|
|
772
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
773
|
-
this.log.debug(`Stored used
|
|
774
|
-
|
|
792
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
793
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
794
|
+
taggingIndexRangesUsedInTheTx,
|
|
775
795
|
});
|
|
776
796
|
} else {
|
|
777
|
-
this.log.debug(`No
|
|
797
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
778
798
|
}
|
|
779
799
|
|
|
780
800
|
return txProvingResult;
|
|
@@ -881,7 +901,14 @@ export class PXE {
|
|
|
881
901
|
*/
|
|
882
902
|
public simulateTx(
|
|
883
903
|
txRequest: TxExecutionRequest,
|
|
884
|
-
{
|
|
904
|
+
{
|
|
905
|
+
simulatePublic,
|
|
906
|
+
skipTxValidation = false,
|
|
907
|
+
skipFeeEnforcement = false,
|
|
908
|
+
skipKernels = true,
|
|
909
|
+
overrides,
|
|
910
|
+
scopes,
|
|
911
|
+
}: SimulateTxOpts,
|
|
885
912
|
): Promise<TxSimulationResult> {
|
|
886
913
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
887
914
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -905,17 +932,20 @@ export class PXE {
|
|
|
905
932
|
await this.blockStateSynchronizer.sync();
|
|
906
933
|
const syncTime = syncTimer.ms();
|
|
907
934
|
|
|
908
|
-
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
909
|
-
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
910
|
-
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
911
|
-
// or not.
|
|
912
935
|
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
913
936
|
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
914
|
-
const skipKernels = hasOverriddenContracts;
|
|
915
937
|
|
|
916
|
-
|
|
938
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
939
|
+
throw new Error(
|
|
940
|
+
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
944
|
+
|
|
917
945
|
if (hasOverriddenContracts) {
|
|
918
|
-
|
|
946
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
947
|
+
// We exclude them so the sync service skips them entirely.
|
|
948
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
919
949
|
}
|
|
920
950
|
|
|
921
951
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
@@ -1047,7 +1077,7 @@ export class PXE {
|
|
|
1047
1077
|
scopes,
|
|
1048
1078
|
);
|
|
1049
1079
|
|
|
1050
|
-
const executionResult = await this.#executeUtility(
|
|
1080
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(
|
|
1051
1081
|
contractFunctionSimulator,
|
|
1052
1082
|
call,
|
|
1053
1083
|
authwits ?? [],
|
|
@@ -1068,7 +1098,12 @@ export class PXE {
|
|
|
1068
1098
|
};
|
|
1069
1099
|
|
|
1070
1100
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1071
|
-
return {
|
|
1101
|
+
return {
|
|
1102
|
+
result: executionResult,
|
|
1103
|
+
offchainEffects,
|
|
1104
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1105
|
+
stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls },
|
|
1106
|
+
};
|
|
1072
1107
|
} catch (err: any) {
|
|
1073
1108
|
const { to, name, args } = call;
|
|
1074
1109
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
@@ -1130,9 +1165,10 @@ export class PXE {
|
|
|
1130
1165
|
}
|
|
1131
1166
|
|
|
1132
1167
|
/**
|
|
1133
|
-
* Stops the PXE's job queue.
|
|
1168
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
1134
1169
|
*/
|
|
1135
|
-
public stop(): Promise<void> {
|
|
1136
|
-
|
|
1170
|
+
public async stop(): Promise<void> {
|
|
1171
|
+
await this.jobQueue.end();
|
|
1172
|
+
await this.db.close();
|
|
1137
1173
|
}
|
|
1138
1174
|
}
|
package/src/storage/metadata.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 4;
|