@aztec/pxe 0.0.1-commit.0c875d939 → 0.0.1-commit.10bd49492
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/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +4 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +16 -12
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- 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 +49 -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 +52 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +44 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +141 -93
- package/dest/contract_function_simulator/oracle/private_execution.js +3 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +23 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +41 -67
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +40 -34
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +83 -50
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/debug/pxe_debug_utils.d.ts +2 -2
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +4 -4
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/logs/log_service.d.ts +1 -1
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +4 -4
- 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/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- 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 +19 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +9 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +49 -36
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- 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/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- 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/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
- 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 +5 -7
- 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 +36 -24
- package/package.json +16 -16
- package/src/config/index.ts +1 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +25 -21
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- 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 +53 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +77 -0
- package/src/contract_function_simulator/oracle/oracle.ts +154 -137
- package/src/contract_function_simulator/oracle/private_execution.ts +3 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +46 -83
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +117 -59
- package/src/contract_logging.ts +39 -0
- package/src/debug/pxe_debug_utils.ts +4 -4
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/logs/log_service.ts +10 -5
- package/src/messages/message_context_service.ts +45 -0
- package/src/oracle_version.ts +3 -3
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +53 -40
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- 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 +27 -26
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
package/src/pxe.ts
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
TxProfileResult,
|
|
48
48
|
TxProvingResult,
|
|
49
49
|
TxSimulationResult,
|
|
50
|
-
|
|
50
|
+
UtilityExecutionResult,
|
|
51
51
|
} from '@aztec/stdlib/tx';
|
|
52
52
|
|
|
53
53
|
import { inspect } from 'util';
|
|
@@ -61,12 +61,14 @@ import {
|
|
|
61
61
|
generateSimulatedProvingResult,
|
|
62
62
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
63
63
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
64
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
64
65
|
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
65
66
|
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
66
67
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
67
68
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
68
69
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
69
70
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
71
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
70
72
|
import {
|
|
71
73
|
PrivateKernelExecutionProver,
|
|
72
74
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -111,8 +113,8 @@ export type SimulateTxOpts = {
|
|
|
111
113
|
scopes: AccessScopes;
|
|
112
114
|
};
|
|
113
115
|
|
|
114
|
-
/** Options for PXE.
|
|
115
|
-
export type
|
|
116
|
+
/** Options for PXE.executeUtility. */
|
|
117
|
+
export type ExecuteUtilityOpts = {
|
|
116
118
|
/** The authentication witnesses required for the function call. */
|
|
117
119
|
authwits?: AuthWitness[];
|
|
118
120
|
/** The accounts whose notes we can access in this call */
|
|
@@ -144,6 +146,7 @@ export type PXECreateArgs = {
|
|
|
144
146
|
export class PXE {
|
|
145
147
|
private constructor(
|
|
146
148
|
private node: AztecNode,
|
|
149
|
+
private db: AztecAsyncKVStore,
|
|
147
150
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
148
151
|
private keyStore: KeyStore,
|
|
149
152
|
private contractStore: ContractStore,
|
|
@@ -156,6 +159,7 @@ export class PXE {
|
|
|
156
159
|
private addressStore: AddressStore,
|
|
157
160
|
private privateEventStore: PrivateEventStore,
|
|
158
161
|
private contractSyncService: ContractSyncService,
|
|
162
|
+
private messageContextService: MessageContextService,
|
|
159
163
|
private simulator: CircuitSimulator,
|
|
160
164
|
private proverEnabled: boolean,
|
|
161
165
|
private proofCreator: PrivateKernelProver,
|
|
@@ -211,6 +215,8 @@ export class PXE {
|
|
|
211
215
|
noteStore,
|
|
212
216
|
createLogger('pxe:contract_sync', bindings),
|
|
213
217
|
);
|
|
218
|
+
const messageContextService = new MessageContextService(node);
|
|
219
|
+
|
|
214
220
|
const synchronizer = new BlockSynchronizer(
|
|
215
221
|
node,
|
|
216
222
|
store,
|
|
@@ -239,6 +245,7 @@ export class PXE {
|
|
|
239
245
|
|
|
240
246
|
const pxe = new PXE(
|
|
241
247
|
node,
|
|
248
|
+
store,
|
|
242
249
|
synchronizer,
|
|
243
250
|
keyStore,
|
|
244
251
|
contractStore,
|
|
@@ -251,6 +258,7 @@ export class PXE {
|
|
|
251
258
|
addressStore,
|
|
252
259
|
privateEventStore,
|
|
253
260
|
contractSyncService,
|
|
261
|
+
messageContextService,
|
|
254
262
|
simulator,
|
|
255
263
|
proverEnabled,
|
|
256
264
|
proofCreator,
|
|
@@ -264,7 +272,7 @@ export class PXE {
|
|
|
264
272
|
debugUtils.setPXEHelpers(
|
|
265
273
|
pxe.#putInJobQueue.bind(pxe),
|
|
266
274
|
pxe.#getSimulatorForTx.bind(pxe),
|
|
267
|
-
pxe.#
|
|
275
|
+
pxe.#executeUtility.bind(pxe),
|
|
268
276
|
);
|
|
269
277
|
|
|
270
278
|
pxe.jobQueue.start();
|
|
@@ -292,6 +300,7 @@ export class PXE {
|
|
|
292
300
|
privateEventStore: this.privateEventStore,
|
|
293
301
|
simulator: this.simulator,
|
|
294
302
|
contractSyncService: this.contractSyncService,
|
|
303
|
+
messageContextService: this.messageContextService,
|
|
295
304
|
});
|
|
296
305
|
}
|
|
297
306
|
|
|
@@ -344,9 +353,8 @@ export class PXE {
|
|
|
344
353
|
async #registerProtocolContracts() {
|
|
345
354
|
const registered: Record<string, string> = {};
|
|
346
355
|
for (const name of protocolContractNames) {
|
|
347
|
-
const { address,
|
|
348
|
-
|
|
349
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
356
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
357
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
350
358
|
await this.contractStore.addContractInstance(instance);
|
|
351
359
|
registered[name] = address.toString();
|
|
352
360
|
}
|
|
@@ -370,7 +378,7 @@ export class PXE {
|
|
|
370
378
|
contractAddress,
|
|
371
379
|
functionSelector,
|
|
372
380
|
(privateSyncCall, execScopes) =>
|
|
373
|
-
this.#
|
|
381
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
374
382
|
anchorBlockHeader,
|
|
375
383
|
jobId,
|
|
376
384
|
scopes,
|
|
@@ -394,16 +402,16 @@ export class PXE {
|
|
|
394
402
|
}
|
|
395
403
|
|
|
396
404
|
/**
|
|
397
|
-
*
|
|
405
|
+
* Execute a utility function call on the given contract.
|
|
398
406
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
399
407
|
* @param call - The function call to execute.
|
|
400
408
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
401
409
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
402
410
|
* accounts if not specified.
|
|
403
411
|
* @param jobId - The job ID for staged writes.
|
|
404
|
-
* @returns The
|
|
412
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
405
413
|
*/
|
|
406
|
-
async #
|
|
414
|
+
async #executeUtility(
|
|
407
415
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
408
416
|
call: FunctionCall,
|
|
409
417
|
authWitnesses: AuthWitness[] | undefined,
|
|
@@ -601,8 +609,7 @@ export class PXE {
|
|
|
601
609
|
* @param artifact - The build artifact for the contract class.
|
|
602
610
|
*/
|
|
603
611
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
604
|
-
const
|
|
605
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
612
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
606
613
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
607
614
|
}
|
|
608
615
|
|
|
@@ -621,17 +628,17 @@ export class PXE {
|
|
|
621
628
|
if (artifact) {
|
|
622
629
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
623
630
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
624
|
-
|
|
625
|
-
if (!contractClassId.equals(instance.currentContractClassId)) {
|
|
631
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
626
632
|
throw new Error(
|
|
627
|
-
`Artifact does not match expected class id (computed ${
|
|
633
|
+
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
628
634
|
);
|
|
629
635
|
}
|
|
630
636
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
631
637
|
if (!computedAddress.equals(instance.address)) {
|
|
632
638
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
633
639
|
}
|
|
634
|
-
|
|
640
|
+
|
|
641
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
635
642
|
|
|
636
643
|
const publicFunctionSignatures = artifact.functions
|
|
637
644
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -680,15 +687,16 @@ export class PXE {
|
|
|
680
687
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
681
688
|
}
|
|
682
689
|
|
|
683
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
684
|
-
|
|
685
690
|
const publicFunctionSignatures = artifact.functions
|
|
686
691
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
687
692
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
688
693
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
689
694
|
|
|
690
695
|
currentInstance.currentContractClassId = contractClass.id;
|
|
691
|
-
await
|
|
696
|
+
await Promise.all([
|
|
697
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
698
|
+
this.contractStore.addContractInstance(currentInstance),
|
|
699
|
+
]);
|
|
692
700
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
693
701
|
});
|
|
694
702
|
}
|
|
@@ -764,17 +772,17 @@ export class PXE {
|
|
|
764
772
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
765
773
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
766
774
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
775
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
776
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
769
777
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
770
778
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
771
779
|
|
|
772
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
773
|
-
this.log.debug(`Stored used
|
|
774
|
-
|
|
780
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
781
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
782
|
+
taggingIndexRangesUsedInTheTx,
|
|
775
783
|
});
|
|
776
784
|
} else {
|
|
777
|
-
this.log.debug(`No
|
|
785
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
778
786
|
}
|
|
779
787
|
|
|
780
788
|
return txProvingResult;
|
|
@@ -947,6 +955,9 @@ export class PXE {
|
|
|
947
955
|
const publicSimulationTimer = new Timer();
|
|
948
956
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
949
957
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
958
|
+
if (publicOutput?.debugLogs?.length) {
|
|
959
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
|
|
960
|
+
}
|
|
950
961
|
}
|
|
951
962
|
|
|
952
963
|
let validationTime: number | undefined;
|
|
@@ -955,7 +966,8 @@ export class PXE {
|
|
|
955
966
|
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
956
967
|
validationTime = validationTimer.ms();
|
|
957
968
|
if (validationResult.result === 'invalid') {
|
|
958
|
-
|
|
969
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
970
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
959
971
|
}
|
|
960
972
|
}
|
|
961
973
|
|
|
@@ -1013,16 +1025,16 @@ export class PXE {
|
|
|
1013
1025
|
}
|
|
1014
1026
|
|
|
1015
1027
|
/**
|
|
1016
|
-
*
|
|
1028
|
+
* Executes a contract utility function.
|
|
1017
1029
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
1018
1030
|
*/
|
|
1019
|
-
public
|
|
1031
|
+
public executeUtility(
|
|
1020
1032
|
call: FunctionCall,
|
|
1021
|
-
{ authwits, scopes }:
|
|
1022
|
-
): Promise<
|
|
1023
|
-
// We disable concurrent
|
|
1033
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
1034
|
+
): Promise<UtilityExecutionResult> {
|
|
1035
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1024
1036
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1025
|
-
// delete the same read value, or reading values that another
|
|
1037
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1026
1038
|
return this.#putInJobQueue(async jobId => {
|
|
1027
1039
|
try {
|
|
1028
1040
|
const totalTimer = new Timer();
|
|
@@ -1037,13 +1049,13 @@ export class PXE {
|
|
|
1037
1049
|
call.to,
|
|
1038
1050
|
call.selector,
|
|
1039
1051
|
(privateSyncCall, execScopes) =>
|
|
1040
|
-
this.#
|
|
1052
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1041
1053
|
anchorBlockHeader,
|
|
1042
1054
|
jobId,
|
|
1043
1055
|
scopes,
|
|
1044
1056
|
);
|
|
1045
1057
|
|
|
1046
|
-
const executionResult = await this.#
|
|
1058
|
+
const executionResult = await this.#executeUtility(
|
|
1047
1059
|
contractFunctionSimulator,
|
|
1048
1060
|
call,
|
|
1049
1061
|
authwits ?? [],
|
|
@@ -1070,7 +1082,7 @@ export class PXE {
|
|
|
1070
1082
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1071
1083
|
throw this.#contextualizeError(
|
|
1072
1084
|
err,
|
|
1073
|
-
`
|
|
1085
|
+
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1074
1086
|
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1075
1087
|
);
|
|
1076
1088
|
}
|
|
@@ -1108,7 +1120,7 @@ export class PXE {
|
|
|
1108
1120
|
filter.contractAddress,
|
|
1109
1121
|
null,
|
|
1110
1122
|
async (privateSyncCall, execScopes) =>
|
|
1111
|
-
await this.#
|
|
1123
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1112
1124
|
anchorBlockHeader,
|
|
1113
1125
|
jobId,
|
|
1114
1126
|
filter.scopes,
|
|
@@ -1126,9 +1138,10 @@ export class PXE {
|
|
|
1126
1138
|
}
|
|
1127
1139
|
|
|
1128
1140
|
/**
|
|
1129
|
-
* Stops the PXE's job queue.
|
|
1141
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
1130
1142
|
*/
|
|
1131
|
-
public stop(): Promise<void> {
|
|
1132
|
-
|
|
1143
|
+
public async stop(): Promise<void> {
|
|
1144
|
+
await this.jobQueue.end();
|
|
1145
|
+
await this.db.close();
|
|
1133
1146
|
}
|
|
1134
1147
|
}
|