@aztec/pxe 0.0.1-commit.858058eac → 0.0.1-commit.85d7d01
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -6
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +111 -41
- 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 +3 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
- 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 +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +9 -9
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +14 -12
- 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/contract_sync/contract_sync_service.d.ts +4 -2
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +34 -19
- package/dest/contract_sync/helpers.d.ts +3 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +3 -3
- package/dest/debug/pxe_debug_utils.d.ts +5 -4
- 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 +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/server/index.d.ts +3 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -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 +9 -14
- package/dest/notes/note_service.d.ts +4 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +3 -2
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- 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 +16 -12
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +38 -30
- 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/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- 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 +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
- 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 +2 -2
- 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 +3 -6
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -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 +14 -15
- package/package.json +16 -16
- package/src/access_scopes.ts +9 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +217 -60
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +16 -11
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +21 -14
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +49 -26
- package/src/contract_sync/helpers.ts +7 -2
- package/src/debug/pxe_debug_utils.ts +11 -9
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/server/index.ts +2 -0
- package/src/logs/log_service.ts +17 -24
- package/src/notes/note_service.ts +4 -3
- package/src/notes_filter.ts +26 -0
- 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 +58 -49
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/note_store/note_store.ts +8 -5
- package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +1 -1
- 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 +4 -9
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
- 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,11 +47,12 @@ 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';
|
|
54
54
|
|
|
55
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
55
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
57
|
import type { PXEConfig } from './config/index.js';
|
|
57
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -60,6 +61,7 @@ import {
|
|
|
60
61
|
generateSimulatedProvingResult,
|
|
61
62
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
63
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
64
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
63
65
|
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
64
66
|
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
65
67
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
@@ -92,6 +94,8 @@ export type ProfileTxOpts = {
|
|
|
92
94
|
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
93
95
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
94
96
|
skipProofGeneration?: boolean;
|
|
97
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
98
|
+
scopes: AccessScopes;
|
|
95
99
|
};
|
|
96
100
|
|
|
97
101
|
/** Options for PXE.simulateTx. */
|
|
@@ -104,16 +108,16 @@ export type SimulateTxOpts = {
|
|
|
104
108
|
skipFeeEnforcement?: boolean;
|
|
105
109
|
/** State overrides for the simulation, such as contract instances and artifacts. */
|
|
106
110
|
overrides?: SimulationOverrides;
|
|
107
|
-
/**
|
|
108
|
-
scopes
|
|
111
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
112
|
+
scopes: AccessScopes;
|
|
109
113
|
};
|
|
110
114
|
|
|
111
|
-
/** Options for PXE.
|
|
112
|
-
export type
|
|
115
|
+
/** Options for PXE.executeUtility. */
|
|
116
|
+
export type ExecuteUtilityOpts = {
|
|
113
117
|
/** The authentication witnesses required for the function call. */
|
|
114
118
|
authwits?: AuthWitness[];
|
|
115
|
-
/** The accounts whose notes we can access in this call
|
|
116
|
-
scopes
|
|
119
|
+
/** The accounts whose notes we can access in this call */
|
|
120
|
+
scopes: AccessScopes;
|
|
117
121
|
};
|
|
118
122
|
|
|
119
123
|
/** Args for PXE.create. */
|
|
@@ -261,7 +265,7 @@ export class PXE {
|
|
|
261
265
|
debugUtils.setPXEHelpers(
|
|
262
266
|
pxe.#putInJobQueue.bind(pxe),
|
|
263
267
|
pxe.#getSimulatorForTx.bind(pxe),
|
|
264
|
-
pxe.#
|
|
268
|
+
pxe.#executeUtility.bind(pxe),
|
|
265
269
|
);
|
|
266
270
|
|
|
267
271
|
pxe.jobQueue.start();
|
|
@@ -341,9 +345,8 @@ export class PXE {
|
|
|
341
345
|
async #registerProtocolContracts() {
|
|
342
346
|
const registered: Record<string, string> = {};
|
|
343
347
|
for (const name of protocolContractNames) {
|
|
344
|
-
const { address,
|
|
345
|
-
|
|
346
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
348
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
349
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
347
350
|
await this.contractStore.addContractInstance(instance);
|
|
348
351
|
registered[name] = address.toString();
|
|
349
352
|
}
|
|
@@ -355,7 +358,7 @@ export class PXE {
|
|
|
355
358
|
async #executePrivate(
|
|
356
359
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
357
360
|
txRequest: TxExecutionRequest,
|
|
358
|
-
scopes:
|
|
361
|
+
scopes: AccessScopes,
|
|
359
362
|
jobId: string,
|
|
360
363
|
): Promise<PrivateExecutionResult> {
|
|
361
364
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -366,9 +369,11 @@ export class PXE {
|
|
|
366
369
|
await this.contractSyncService.ensureContractSynced(
|
|
367
370
|
contractAddress,
|
|
368
371
|
functionSelector,
|
|
369
|
-
|
|
372
|
+
(privateSyncCall, execScopes) =>
|
|
373
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
370
374
|
anchorBlockHeader,
|
|
371
375
|
jobId,
|
|
376
|
+
scopes,
|
|
372
377
|
);
|
|
373
378
|
|
|
374
379
|
const result = await contractFunctionSimulator.run(txRequest, {
|
|
@@ -389,20 +394,20 @@ export class PXE {
|
|
|
389
394
|
}
|
|
390
395
|
|
|
391
396
|
/**
|
|
392
|
-
*
|
|
397
|
+
* Execute a utility function call on the given contract.
|
|
393
398
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
394
399
|
* @param call - The function call to execute.
|
|
395
400
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
396
401
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
397
402
|
* accounts if not specified.
|
|
398
403
|
* @param jobId - The job ID for staged writes.
|
|
399
|
-
* @returns The
|
|
404
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
400
405
|
*/
|
|
401
|
-
async #
|
|
406
|
+
async #executeUtility(
|
|
402
407
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
403
408
|
call: FunctionCall,
|
|
404
409
|
authWitnesses: AuthWitness[] | undefined,
|
|
405
|
-
scopes:
|
|
410
|
+
scopes: AccessScopes,
|
|
406
411
|
jobId: string,
|
|
407
412
|
) {
|
|
408
413
|
try {
|
|
@@ -596,8 +601,7 @@ export class PXE {
|
|
|
596
601
|
* @param artifact - The build artifact for the contract class.
|
|
597
602
|
*/
|
|
598
603
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
599
|
-
const
|
|
600
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
604
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
601
605
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
602
606
|
}
|
|
603
607
|
|
|
@@ -616,17 +620,17 @@ export class PXE {
|
|
|
616
620
|
if (artifact) {
|
|
617
621
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
618
622
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
619
|
-
|
|
620
|
-
if (!contractClassId.equals(instance.currentContractClassId)) {
|
|
623
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
621
624
|
throw new Error(
|
|
622
|
-
`Artifact does not match expected class id (computed ${
|
|
625
|
+
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
623
626
|
);
|
|
624
627
|
}
|
|
625
628
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
626
629
|
if (!computedAddress.equals(instance.address)) {
|
|
627
630
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
628
631
|
}
|
|
629
|
-
|
|
632
|
+
|
|
633
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
630
634
|
|
|
631
635
|
const publicFunctionSignatures = artifact.functions
|
|
632
636
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -675,15 +679,16 @@ export class PXE {
|
|
|
675
679
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
676
680
|
}
|
|
677
681
|
|
|
678
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
679
|
-
|
|
680
682
|
const publicFunctionSignatures = artifact.functions
|
|
681
683
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
682
684
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
683
685
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
684
686
|
|
|
685
687
|
currentInstance.currentContractClassId = contractClass.id;
|
|
686
|
-
await
|
|
688
|
+
await Promise.all([
|
|
689
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
690
|
+
this.contractStore.addContractInstance(currentInstance),
|
|
691
|
+
]);
|
|
687
692
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
688
693
|
});
|
|
689
694
|
}
|
|
@@ -701,11 +706,12 @@ export class PXE {
|
|
|
701
706
|
* (where validators prove the public portion).
|
|
702
707
|
*
|
|
703
708
|
* @param txRequest - An authenticated tx request ready for proving
|
|
709
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
704
710
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
705
711
|
* @throws If contract code not found, or public simulation reverts.
|
|
706
712
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
707
713
|
*/
|
|
708
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
714
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
709
715
|
let privateExecutionResult: PrivateExecutionResult;
|
|
710
716
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
711
717
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -716,7 +722,7 @@ export class PXE {
|
|
|
716
722
|
await this.blockStateSynchronizer.sync();
|
|
717
723
|
const syncTime = syncTimer.ms();
|
|
718
724
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
719
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
725
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
720
726
|
|
|
721
727
|
const {
|
|
722
728
|
publicInputs,
|
|
@@ -786,7 +792,7 @@ export class PXE {
|
|
|
786
792
|
*/
|
|
787
793
|
public profileTx(
|
|
788
794
|
txRequest: TxExecutionRequest,
|
|
789
|
-
{ profileMode, skipProofGeneration = true }: ProfileTxOpts,
|
|
795
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
790
796
|
): Promise<TxProfileResult> {
|
|
791
797
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
792
798
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -809,12 +815,7 @@ export class PXE {
|
|
|
809
815
|
const syncTime = syncTimer.ms();
|
|
810
816
|
|
|
811
817
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
812
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
813
|
-
contractFunctionSimulator,
|
|
814
|
-
txRequest,
|
|
815
|
-
undefined,
|
|
816
|
-
jobId,
|
|
817
|
-
);
|
|
818
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
818
819
|
|
|
819
820
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
820
821
|
txRequest,
|
|
@@ -927,6 +928,7 @@ export class PXE {
|
|
|
927
928
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
928
929
|
privateExecutionResult,
|
|
929
930
|
(addr, sel) => this.contractStore.getDebugFunctionName(addr, sel),
|
|
931
|
+
this.node,
|
|
930
932
|
));
|
|
931
933
|
} else {
|
|
932
934
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -945,6 +947,9 @@ export class PXE {
|
|
|
945
947
|
const publicSimulationTimer = new Timer();
|
|
946
948
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
947
949
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
950
|
+
if (publicOutput?.debugLogs?.length) {
|
|
951
|
+
await displayDebugLogs(publicOutput.debugLogs, addr => this.contractStore.getDebugContractName(addr));
|
|
952
|
+
}
|
|
948
953
|
}
|
|
949
954
|
|
|
950
955
|
let validationTime: number | undefined;
|
|
@@ -953,7 +958,8 @@ export class PXE {
|
|
|
953
958
|
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
954
959
|
validationTime = validationTimer.ms();
|
|
955
960
|
if (validationResult.result === 'invalid') {
|
|
956
|
-
|
|
961
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
962
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
957
963
|
}
|
|
958
964
|
}
|
|
959
965
|
|
|
@@ -1004,23 +1010,23 @@ export class PXE {
|
|
|
1004
1010
|
inspect(txRequest),
|
|
1005
1011
|
`simulatePublic=${simulatePublic}`,
|
|
1006
1012
|
`skipTxValidation=${skipTxValidation}`,
|
|
1007
|
-
`scopes=${scopes
|
|
1013
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1008
1014
|
);
|
|
1009
1015
|
}
|
|
1010
1016
|
});
|
|
1011
1017
|
}
|
|
1012
1018
|
|
|
1013
1019
|
/**
|
|
1014
|
-
*
|
|
1020
|
+
* Executes a contract utility function.
|
|
1015
1021
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
1016
1022
|
*/
|
|
1017
|
-
public
|
|
1023
|
+
public executeUtility(
|
|
1018
1024
|
call: FunctionCall,
|
|
1019
|
-
{ authwits, scopes }:
|
|
1020
|
-
): Promise<
|
|
1021
|
-
// We disable concurrent
|
|
1025
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
1026
|
+
): Promise<UtilityExecutionResult> {
|
|
1027
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1022
1028
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1023
|
-
// delete the same read value, or reading values that another
|
|
1029
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1024
1030
|
return this.#putInJobQueue(async jobId => {
|
|
1025
1031
|
try {
|
|
1026
1032
|
const totalTimer = new Timer();
|
|
@@ -1034,12 +1040,14 @@ export class PXE {
|
|
|
1034
1040
|
await this.contractSyncService.ensureContractSynced(
|
|
1035
1041
|
call.to,
|
|
1036
1042
|
call.selector,
|
|
1037
|
-
|
|
1043
|
+
(privateSyncCall, execScopes) =>
|
|
1044
|
+
this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1038
1045
|
anchorBlockHeader,
|
|
1039
1046
|
jobId,
|
|
1047
|
+
scopes,
|
|
1040
1048
|
);
|
|
1041
1049
|
|
|
1042
|
-
const executionResult = await this.#
|
|
1050
|
+
const executionResult = await this.#executeUtility(
|
|
1043
1051
|
contractFunctionSimulator,
|
|
1044
1052
|
call,
|
|
1045
1053
|
authwits ?? [],
|
|
@@ -1066,8 +1074,8 @@ export class PXE {
|
|
|
1066
1074
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1067
1075
|
throw this.#contextualizeError(
|
|
1068
1076
|
err,
|
|
1069
|
-
`
|
|
1070
|
-
`scopes=${scopes
|
|
1077
|
+
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1078
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1071
1079
|
);
|
|
1072
1080
|
}
|
|
1073
1081
|
});
|
|
@@ -1103,10 +1111,11 @@ export class PXE {
|
|
|
1103
1111
|
await this.contractSyncService.ensureContractSynced(
|
|
1104
1112
|
filter.contractAddress,
|
|
1105
1113
|
null,
|
|
1106
|
-
async privateSyncCall =>
|
|
1107
|
-
await this.#
|
|
1114
|
+
async (privateSyncCall, execScopes) =>
|
|
1115
|
+
await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1108
1116
|
anchorBlockHeader,
|
|
1109
1117
|
jobId,
|
|
1118
|
+
filter.scopes,
|
|
1110
1119
|
);
|
|
1111
1120
|
});
|
|
1112
1121
|
|