@aztec/pxe 0.0.1-commit.6230a0c → 0.0.1-commit.64b6bbb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/block_synchronizer/block_synchronizer.d.ts +4 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +7 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +50 -26
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +66 -30
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +3 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -35
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +64 -19
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +31 -11
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +53 -29
- package/dest/contract_sync/contract_sync_service.d.ts +41 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +82 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +6 -12
- package/dest/debug/pxe_debug_utils.d.ts +12 -9
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +16 -15
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +9 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +9 -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/entrypoints/server/utils.js +9 -1
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/pxe.d.ts +64 -22
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +62 -37
- package/dest/storage/contract_store/contract_store.js +5 -5
- package/dest/storage/note_store/note_store.d.ts +1 -1
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -0
- package/package.json +25 -16
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +109 -71
- package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
- package/src/contract_function_simulator/oracle/oracle.ts +3 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +83 -96
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +94 -28
- package/src/contract_sync/contract_sync_service.ts +129 -0
- package/src/contract_sync/{index.ts → helpers.ts} +6 -32
- package/src/debug/pxe_debug_utils.ts +45 -17
- package/src/entrypoints/client/bundle/utils.ts +9 -1
- package/src/entrypoints/client/lazy/utils.ts +9 -1
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +124 -72
- package/src/storage/contract_store/contract_store.ts +4 -4
- package/src/storage/note_store/note_store.ts +4 -0
- package/dest/contract_sync/index.d.ts +0 -24
- package/dest/contract_sync/index.d.ts.map +0 -1
package/dest/pxe.js
CHANGED
|
@@ -13,7 +13,8 @@ import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
|
13
13
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
14
14
|
import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
|
|
15
15
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
16
|
-
import {
|
|
16
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
17
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
17
18
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
18
19
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
19
20
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
@@ -45,6 +46,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
45
46
|
recipientTaggingStore;
|
|
46
47
|
addressStore;
|
|
47
48
|
privateEventStore;
|
|
49
|
+
contractSyncService;
|
|
48
50
|
simulator;
|
|
49
51
|
proverEnabled;
|
|
50
52
|
proofCreator;
|
|
@@ -53,7 +55,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
53
55
|
jobQueue;
|
|
54
56
|
jobCoordinator;
|
|
55
57
|
debug;
|
|
56
|
-
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
58
|
+
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
57
59
|
this.node = node;
|
|
58
60
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
59
61
|
this.keyStore = keyStore;
|
|
@@ -66,6 +68,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
66
68
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
67
69
|
this.addressStore = addressStore;
|
|
68
70
|
this.privateEventStore = privateEventStore;
|
|
71
|
+
this.contractSyncService = contractSyncService;
|
|
69
72
|
this.simulator = simulator;
|
|
70
73
|
this.proverEnabled = proverEnabled;
|
|
71
74
|
this.proofCreator = proofCreator;
|
|
@@ -81,7 +84,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
81
84
|
* can be contacted.
|
|
82
85
|
*
|
|
83
86
|
* @returns A promise that resolves PXE is ready to be used.
|
|
84
|
-
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
87
|
+
*/ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
|
|
85
88
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
86
89
|
const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
87
90
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
@@ -97,19 +100,21 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
97
100
|
const capsuleStore = new CapsuleStore(store);
|
|
98
101
|
const keyStore = new KeyStore(store);
|
|
99
102
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
100
|
-
const
|
|
103
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
104
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
|
|
101
105
|
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
102
106
|
jobCoordinator.registerStores([
|
|
103
107
|
capsuleStore,
|
|
104
108
|
senderTaggingStore,
|
|
105
109
|
recipientTaggingStore,
|
|
106
110
|
privateEventStore,
|
|
107
|
-
noteStore
|
|
111
|
+
noteStore,
|
|
112
|
+
contractSyncService
|
|
108
113
|
]);
|
|
109
|
-
const debugUtils = new PXEDebugUtils(
|
|
114
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
110
115
|
const jobQueue = new SerialQueue();
|
|
111
|
-
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
112
|
-
debugUtils.
|
|
116
|
+
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
117
|
+
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#simulateUtility.bind(pxe));
|
|
113
118
|
pxe.jobQueue.start();
|
|
114
119
|
await pxe.#registerProtocolContracts();
|
|
115
120
|
const info = await node.getNodeInfo();
|
|
@@ -119,7 +124,20 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
119
124
|
// Internal methods
|
|
120
125
|
#getSimulatorForTx(overrides) {
|
|
121
126
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
122
|
-
return new ContractFunctionSimulator(
|
|
127
|
+
return new ContractFunctionSimulator({
|
|
128
|
+
contractStore: proxyContractStore,
|
|
129
|
+
noteStore: this.noteStore,
|
|
130
|
+
keyStore: this.keyStore,
|
|
131
|
+
addressStore: this.addressStore,
|
|
132
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
133
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
134
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
135
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
136
|
+
capsuleStore: this.capsuleStore,
|
|
137
|
+
privateEventStore: this.privateEventStore,
|
|
138
|
+
simulator: this.simulator,
|
|
139
|
+
contractSyncService: this.contractSyncService
|
|
140
|
+
});
|
|
123
141
|
}
|
|
124
142
|
#contextualizeError(err, ...context) {
|
|
125
143
|
let contextStr = '';
|
|
@@ -175,10 +193,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
175
193
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
176
194
|
try {
|
|
177
195
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
178
|
-
await ensureContractSynced(contractAddress, functionSelector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
179
|
-
const result = await contractFunctionSimulator.run(txRequest,
|
|
180
|
-
|
|
181
|
-
|
|
196
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), anchorBlockHeader, jobId);
|
|
197
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
198
|
+
contractAddress,
|
|
199
|
+
selector: functionSelector,
|
|
200
|
+
anchorBlockHeader,
|
|
201
|
+
scopes,
|
|
202
|
+
jobId
|
|
203
|
+
});
|
|
182
204
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
183
205
|
return result;
|
|
184
206
|
} catch (err) {
|
|
@@ -252,7 +274,17 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
252
274
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
253
275
|
}
|
|
254
276
|
// Public API
|
|
255
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Returns the block header up to which the PXE has synced.
|
|
279
|
+
* @returns The synced block header
|
|
280
|
+
*/ getSyncedBlockHeader() {
|
|
281
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
285
|
+
* @param address - The contract address.
|
|
286
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
287
|
+
*/ getContractInstance(address) {
|
|
256
288
|
return this.contractStore.getContractInstance(address);
|
|
257
289
|
}
|
|
258
290
|
/**
|
|
@@ -483,13 +515,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
483
515
|
}
|
|
484
516
|
/**
|
|
485
517
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
486
|
-
*
|
|
487
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
488
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
489
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
518
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
490
519
|
* @returns A trace of the program execution with gate counts.
|
|
491
520
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
492
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
521
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true }) {
|
|
493
522
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
494
523
|
return this.#putInJobQueue(async (jobId)=>{
|
|
495
524
|
const totalTimer = new Timer();
|
|
@@ -552,18 +581,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
552
581
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
553
582
|
*
|
|
554
583
|
*
|
|
555
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
556
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
557
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
558
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
559
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
560
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
584
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
561
585
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
562
586
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
563
587
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
564
588
|
*
|
|
565
589
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
566
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
590
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }) {
|
|
567
591
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
568
592
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
569
593
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -586,13 +610,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
586
610
|
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
587
611
|
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
588
612
|
// or not.
|
|
589
|
-
const
|
|
613
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
614
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
615
|
+
const skipKernels = hasOverriddenContracts;
|
|
616
|
+
// Set overridden contracts on the sync service so it knows to skip syncing them
|
|
617
|
+
if (hasOverriddenContracts) {
|
|
618
|
+
this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
|
|
619
|
+
}
|
|
590
620
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
591
621
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
592
622
|
let publicInputs;
|
|
593
623
|
let executionSteps = [];
|
|
594
624
|
if (skipKernels) {
|
|
595
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
|
|
625
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel)));
|
|
596
626
|
} else {
|
|
597
627
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
598
628
|
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -657,14 +687,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
657
687
|
});
|
|
658
688
|
}
|
|
659
689
|
/**
|
|
660
|
-
*
|
|
661
|
-
*
|
|
690
|
+
* Simulates the execution of a contract utility function.
|
|
662
691
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
663
|
-
|
|
664
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
665
|
-
* default to all.
|
|
666
|
-
* @returns The result of the utility function call, structured based on the function ABI.
|
|
667
|
-
*/ simulateUtility(call, authwits, scopes) {
|
|
692
|
+
*/ simulateUtility(call, { authwits, scopes } = {}) {
|
|
668
693
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
669
694
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
670
695
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -677,7 +702,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
677
702
|
const functionTimer = new Timer();
|
|
678
703
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
679
704
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
680
|
-
await ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
705
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), anchorBlockHeader, jobId);
|
|
681
706
|
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
682
707
|
const functionTime = functionTimer.ms();
|
|
683
708
|
const totalTime = totalTimer.ms();
|
|
@@ -727,7 +752,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
727
752
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
728
753
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
729
754
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
730
|
-
await ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId),
|
|
755
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], undefined, jobId), anchorBlockHeader, jobId);
|
|
731
756
|
});
|
|
732
757
|
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
733
758
|
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toArray } from '@aztec/foundation/iterable';
|
|
2
|
-
import { FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
2
|
+
import { FunctionCall, FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
5
5
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
@@ -219,15 +219,15 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
219
219
|
if (!functionDao) {
|
|
220
220
|
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
221
221
|
}
|
|
222
|
-
return {
|
|
222
|
+
return FunctionCall.from({
|
|
223
223
|
name: functionDao.name,
|
|
224
|
-
|
|
224
|
+
to,
|
|
225
225
|
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
226
226
|
type: functionDao.functionType,
|
|
227
|
-
to,
|
|
228
227
|
hideMsgSender: false,
|
|
229
228
|
isStatic: functionDao.isStatic,
|
|
229
|
+
args: encodeArguments(functionDao, args),
|
|
230
230
|
returnTypes: functionDao.returnTypes
|
|
231
|
-
};
|
|
231
|
+
});
|
|
232
232
|
}
|
|
233
233
|
}
|
|
@@ -80,4 +80,4 @@ export declare class NoteStore implements StagedStore {
|
|
|
80
80
|
commit(jobId: string): Promise<void>;
|
|
81
81
|
discardStaged(jobId: string): Promise<void>;
|
|
82
82
|
}
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2Uvbm90ZV9zdG9yZS9ub3RlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQ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AMpF;IA6ED;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1C;CAkCF"}
|
|
@@ -173,6 +173,9 @@ import { StoredNote } from './stored_note.js';
|
|
|
173
173
|
if (nullifiers.length === 0) {
|
|
174
174
|
return Promise.resolve([]);
|
|
175
175
|
}
|
|
176
|
+
if (nullifiers.some((n)=>n.l2BlockNumber === 0)) {
|
|
177
|
+
return Promise.reject(new Error('applyNullifiers: nullifiers cannot have been emitted at block 0'));
|
|
178
|
+
}
|
|
176
179
|
return this.#withJobLock(jobId, ()=>this.#store.transactionAsync(async ()=>{
|
|
177
180
|
const notesToNullify = await Promise.all(nullifiers.map(async (nullifierInBlock)=>{
|
|
178
181
|
const nullifier = nullifierInBlock.data.toString();
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.64b6bbb",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"typedocOptions": {
|
|
6
|
+
"entryPoints": [
|
|
7
|
+
"./src/entrypoints/server/index.ts",
|
|
8
|
+
"./src/entrypoints/client/lazy/index.ts",
|
|
9
|
+
"./src/config/index.ts"
|
|
10
|
+
],
|
|
11
|
+
"name": "PXE",
|
|
12
|
+
"tsconfig": "./tsconfig.json"
|
|
13
|
+
},
|
|
5
14
|
"exports": {
|
|
6
15
|
"./server": "./dest/entrypoints/server/index.js",
|
|
7
16
|
"./client/lazy": "./dest/entrypoints/client/lazy/index.js",
|
|
@@ -61,19 +70,19 @@
|
|
|
61
70
|
]
|
|
62
71
|
},
|
|
63
72
|
"dependencies": {
|
|
64
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
65
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
66
|
-
"@aztec/builder": "0.0.1-commit.
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
69
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
70
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
71
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
73
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
74
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
75
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
76
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
73
|
+
"@aztec/bb-prover": "0.0.1-commit.64b6bbb",
|
|
74
|
+
"@aztec/bb.js": "0.0.1-commit.64b6bbb",
|
|
75
|
+
"@aztec/builder": "0.0.1-commit.64b6bbb",
|
|
76
|
+
"@aztec/constants": "0.0.1-commit.64b6bbb",
|
|
77
|
+
"@aztec/ethereum": "0.0.1-commit.64b6bbb",
|
|
78
|
+
"@aztec/foundation": "0.0.1-commit.64b6bbb",
|
|
79
|
+
"@aztec/key-store": "0.0.1-commit.64b6bbb",
|
|
80
|
+
"@aztec/kv-store": "0.0.1-commit.64b6bbb",
|
|
81
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.64b6bbb",
|
|
82
|
+
"@aztec/noir-types": "0.0.1-commit.64b6bbb",
|
|
83
|
+
"@aztec/protocol-contracts": "0.0.1-commit.64b6bbb",
|
|
84
|
+
"@aztec/simulator": "0.0.1-commit.64b6bbb",
|
|
85
|
+
"@aztec/stdlib": "0.0.1-commit.64b6bbb",
|
|
77
86
|
"koa": "^2.16.1",
|
|
78
87
|
"koa-router": "^13.1.1",
|
|
79
88
|
"lodash.omit": "^4.5.0",
|
|
@@ -82,8 +91,8 @@
|
|
|
82
91
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
83
92
|
},
|
|
84
93
|
"devDependencies": {
|
|
85
|
-
"@aztec/merkle-tree": "0.0.1-commit.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
94
|
+
"@aztec/merkle-tree": "0.0.1-commit.64b6bbb",
|
|
95
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.64b6bbb",
|
|
87
96
|
"@jest/globals": "^30.0.0",
|
|
88
97
|
"@types/jest": "^30.0.0",
|
|
89
98
|
"@types/lodash.omit": "^4.5.7",
|
|
@@ -7,6 +7,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
7
7
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
8
8
|
|
|
9
9
|
import type { BlockSynchronizerConfig } from '../config/index.js';
|
|
10
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
10
11
|
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
11
12
|
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
12
13
|
import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
|
|
@@ -28,6 +29,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
28
29
|
private noteStore: NoteStore,
|
|
29
30
|
private privateEventStore: PrivateEventStore,
|
|
30
31
|
private l2TipsStore: L2TipsKVStore,
|
|
32
|
+
private contractSyncService: ContractSyncService,
|
|
31
33
|
private config: Partial<BlockSynchronizerConfig> = {},
|
|
32
34
|
bindings?: LoggerBindings,
|
|
33
35
|
) {
|
|
@@ -125,6 +127,10 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
125
127
|
|
|
126
128
|
/** Updates the anchor block header to the target block */
|
|
127
129
|
private async updateAnchorBlockHeader(blockHeader: BlockHeader) {
|
|
130
|
+
// Whenever the anchor block header is updated, we need to synchronize the private state of contracts again.
|
|
131
|
+
// Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
|
|
132
|
+
// execution.
|
|
133
|
+
this.contractSyncService.wipe();
|
|
128
134
|
this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
|
|
129
135
|
await this.anchorBlockStore.setHeader(blockHeader);
|
|
130
136
|
}
|
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
getFinalMinRevertibleSideEffectCounter,
|
|
73
73
|
} from '@aztec/stdlib/tx';
|
|
74
74
|
|
|
75
|
+
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
75
76
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
76
77
|
import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
77
78
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
@@ -89,51 +90,89 @@ import { executePrivateFunction } from './oracle/private_execution.js';
|
|
|
89
90
|
import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
90
91
|
import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
91
92
|
|
|
93
|
+
/** Options for ContractFunctionSimulator.run. */
|
|
94
|
+
export type ContractSimulatorRunOpts = {
|
|
95
|
+
/** The address of the contract (should match request.origin). */
|
|
96
|
+
contractAddress: AztecAddress;
|
|
97
|
+
/** The function selector of the entry point. */
|
|
98
|
+
selector: FunctionSelector;
|
|
99
|
+
/** The address calling the function. Can be replaced to simulate a call from another contract or account. */
|
|
100
|
+
msgSender?: AztecAddress;
|
|
101
|
+
/** The block header to use as base state for this run. */
|
|
102
|
+
anchorBlockHeader: BlockHeader;
|
|
103
|
+
/** The address used as a tagging sender when emitting private logs. */
|
|
104
|
+
senderForTags?: AztecAddress;
|
|
105
|
+
/** The accounts whose notes we can access in this call. Defaults to all. */
|
|
106
|
+
scopes?: AztecAddress[];
|
|
107
|
+
/** The job ID for staged writes. */
|
|
108
|
+
jobId: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** Args for ContractFunctionSimulator constructor. */
|
|
112
|
+
export type ContractFunctionSimulatorArgs = {
|
|
113
|
+
contractStore: ContractStore;
|
|
114
|
+
noteStore: NoteStore;
|
|
115
|
+
keyStore: KeyStore;
|
|
116
|
+
addressStore: AddressStore;
|
|
117
|
+
aztecNode: AztecNode;
|
|
118
|
+
senderTaggingStore: SenderTaggingStore;
|
|
119
|
+
recipientTaggingStore: RecipientTaggingStore;
|
|
120
|
+
senderAddressBookStore: SenderAddressBookStore;
|
|
121
|
+
capsuleStore: CapsuleStore;
|
|
122
|
+
privateEventStore: PrivateEventStore;
|
|
123
|
+
simulator: CircuitSimulator;
|
|
124
|
+
contractSyncService: ContractSyncService;
|
|
125
|
+
};
|
|
126
|
+
|
|
92
127
|
/**
|
|
93
128
|
* The contract function simulator.
|
|
94
129
|
*/
|
|
95
130
|
export class ContractFunctionSimulator {
|
|
96
|
-
private log: Logger;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
) {
|
|
131
|
+
private readonly log: Logger;
|
|
132
|
+
private readonly contractStore: ContractStore;
|
|
133
|
+
private readonly noteStore: NoteStore;
|
|
134
|
+
private readonly keyStore: KeyStore;
|
|
135
|
+
private readonly addressStore: AddressStore;
|
|
136
|
+
private readonly aztecNode: AztecNode;
|
|
137
|
+
private readonly senderTaggingStore: SenderTaggingStore;
|
|
138
|
+
private readonly recipientTaggingStore: RecipientTaggingStore;
|
|
139
|
+
private readonly senderAddressBookStore: SenderAddressBookStore;
|
|
140
|
+
private readonly capsuleStore: CapsuleStore;
|
|
141
|
+
private readonly privateEventStore: PrivateEventStore;
|
|
142
|
+
private readonly simulator: CircuitSimulator;
|
|
143
|
+
private readonly contractSyncService: ContractSyncService;
|
|
144
|
+
|
|
145
|
+
constructor(args: ContractFunctionSimulatorArgs) {
|
|
146
|
+
this.contractStore = args.contractStore;
|
|
147
|
+
this.noteStore = args.noteStore;
|
|
148
|
+
this.keyStore = args.keyStore;
|
|
149
|
+
this.addressStore = args.addressStore;
|
|
150
|
+
this.aztecNode = args.aztecNode;
|
|
151
|
+
this.senderTaggingStore = args.senderTaggingStore;
|
|
152
|
+
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
153
|
+
this.senderAddressBookStore = args.senderAddressBookStore;
|
|
154
|
+
this.capsuleStore = args.capsuleStore;
|
|
155
|
+
this.privateEventStore = args.privateEventStore;
|
|
156
|
+
this.simulator = args.simulator;
|
|
157
|
+
this.contractSyncService = args.contractSyncService;
|
|
111
158
|
this.log = createLogger('simulator');
|
|
112
159
|
}
|
|
113
160
|
|
|
114
161
|
/**
|
|
115
162
|
* Runs a private function.
|
|
116
163
|
* @param request - The transaction request.
|
|
117
|
-
* @param entryPointArtifact - The artifact of the entry point function.
|
|
118
|
-
* @param contractAddress - The address of the contract (should match request.origin)
|
|
119
|
-
* @param msgSender - The address calling the function. This can be replaced to simulate a call from another contract
|
|
120
|
-
* or a specific account.
|
|
121
|
-
* @param anchorBlockHeader - The block header to use as base state for this run.
|
|
122
|
-
* @param senderForTags - The address that is used as a tagging sender when emitting private logs. Returned from
|
|
123
|
-
* the `privateGetSenderForTags` oracle.
|
|
124
|
-
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
125
|
-
* @param jobId - The job ID for staged writes.
|
|
126
|
-
* @returns The result of the execution.
|
|
127
164
|
*/
|
|
128
165
|
public async run(
|
|
129
166
|
request: TxExecutionRequest,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
167
|
+
{
|
|
168
|
+
contractAddress,
|
|
169
|
+
selector,
|
|
170
|
+
msgSender = AztecAddress.fromField(Fr.MAX_FIELD_VALUE),
|
|
171
|
+
anchorBlockHeader,
|
|
172
|
+
senderForTags,
|
|
173
|
+
scopes,
|
|
174
|
+
jobId,
|
|
175
|
+
}: ContractSimulatorRunOpts,
|
|
137
176
|
): Promise<PrivateExecutionResult> {
|
|
138
177
|
const simulatorSetupTimer = new Timer();
|
|
139
178
|
|
|
@@ -163,37 +202,37 @@ export class ContractFunctionSimulator {
|
|
|
163
202
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
164
203
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
165
204
|
|
|
166
|
-
const privateExecutionOracle = new PrivateExecutionOracle(
|
|
167
|
-
request.firstCallArgsHash,
|
|
168
|
-
request.txContext,
|
|
205
|
+
const privateExecutionOracle = new PrivateExecutionOracle({
|
|
206
|
+
argsHash: request.firstCallArgsHash,
|
|
207
|
+
txContext: request.txContext,
|
|
169
208
|
callContext,
|
|
170
209
|
anchorBlockHeader,
|
|
171
|
-
async call => {
|
|
210
|
+
utilityExecutor: async call => {
|
|
172
211
|
await this.runUtility(call, [], anchorBlockHeader, scopes, jobId);
|
|
173
212
|
},
|
|
174
|
-
request.authWitnesses,
|
|
175
|
-
request.capsules,
|
|
176
|
-
HashedValuesCache.create(request.argsOfCalls),
|
|
213
|
+
authWitnesses: request.authWitnesses,
|
|
214
|
+
capsules: request.capsules,
|
|
215
|
+
executionCache: HashedValuesCache.create(request.argsOfCalls),
|
|
177
216
|
noteCache,
|
|
178
217
|
taggingIndexCache,
|
|
179
|
-
this.contractStore,
|
|
180
|
-
this.noteStore,
|
|
181
|
-
this.keyStore,
|
|
182
|
-
this.addressStore,
|
|
183
|
-
this.aztecNode,
|
|
184
|
-
this.senderTaggingStore,
|
|
185
|
-
this.recipientTaggingStore,
|
|
186
|
-
this.senderAddressBookStore,
|
|
187
|
-
this.capsuleStore,
|
|
188
|
-
this.privateEventStore,
|
|
218
|
+
contractStore: this.contractStore,
|
|
219
|
+
noteStore: this.noteStore,
|
|
220
|
+
keyStore: this.keyStore,
|
|
221
|
+
addressStore: this.addressStore,
|
|
222
|
+
aztecNode: this.aztecNode,
|
|
223
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
224
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
225
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
226
|
+
capsuleStore: this.capsuleStore,
|
|
227
|
+
privateEventStore: this.privateEventStore,
|
|
228
|
+
contractSyncService: this.contractSyncService,
|
|
189
229
|
jobId,
|
|
190
|
-
0,
|
|
191
|
-
startSideEffectCounter,
|
|
192
|
-
undefined, // log
|
|
230
|
+
totalPublicCalldataCount: 0,
|
|
231
|
+
sideEffectCounter: startSideEffectCounter,
|
|
193
232
|
scopes,
|
|
194
233
|
senderForTags,
|
|
195
|
-
this.simulator,
|
|
196
|
-
);
|
|
234
|
+
simulator: this.simulator,
|
|
235
|
+
});
|
|
197
236
|
|
|
198
237
|
const setupTime = simulatorSetupTimer.ms();
|
|
199
238
|
|
|
@@ -266,24 +305,23 @@ export class ContractFunctionSimulator {
|
|
|
266
305
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
267
306
|
}
|
|
268
307
|
|
|
269
|
-
const oracle = new UtilityExecutionOracle(
|
|
270
|
-
call.to,
|
|
271
|
-
authwits,
|
|
272
|
-
[],
|
|
308
|
+
const oracle = new UtilityExecutionOracle({
|
|
309
|
+
contractAddress: call.to,
|
|
310
|
+
authWitnesses: authwits,
|
|
311
|
+
capsules: [],
|
|
273
312
|
anchorBlockHeader,
|
|
274
|
-
this.contractStore,
|
|
275
|
-
this.noteStore,
|
|
276
|
-
this.keyStore,
|
|
277
|
-
this.addressStore,
|
|
278
|
-
this.aztecNode,
|
|
279
|
-
this.recipientTaggingStore,
|
|
280
|
-
this.senderAddressBookStore,
|
|
281
|
-
this.capsuleStore,
|
|
282
|
-
this.privateEventStore,
|
|
313
|
+
contractStore: this.contractStore,
|
|
314
|
+
noteStore: this.noteStore,
|
|
315
|
+
keyStore: this.keyStore,
|
|
316
|
+
addressStore: this.addressStore,
|
|
317
|
+
aztecNode: this.aztecNode,
|
|
318
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
319
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
320
|
+
capsuleStore: this.capsuleStore,
|
|
321
|
+
privateEventStore: this.privateEventStore,
|
|
283
322
|
jobId,
|
|
284
|
-
undefined,
|
|
285
323
|
scopes,
|
|
286
|
-
);
|
|
324
|
+
});
|
|
287
325
|
|
|
288
326
|
try {
|
|
289
327
|
this.log.verbose(`Executing utility function ${entryPointArtifact.name}`, {
|
|
@@ -356,7 +394,7 @@ class OrderedSideEffect<T> {
|
|
|
356
394
|
*/
|
|
357
395
|
export async function generateSimulatedProvingResult(
|
|
358
396
|
privateExecutionResult: PrivateExecutionResult,
|
|
359
|
-
|
|
397
|
+
debugFunctionNameGetter: (contractAddress: AztecAddress, functionSelector: FunctionSelector) => Promise<string>,
|
|
360
398
|
minRevertibleSideEffectCounterOverride?: number,
|
|
361
399
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
362
400
|
const siloedNoteHashes: OrderedSideEffect<Fr>[] = [];
|
|
@@ -437,7 +475,7 @@ export async function generateSimulatedProvingResult(
|
|
|
437
475
|
: execution.publicInputs.publicTeardownCallRequest;
|
|
438
476
|
|
|
439
477
|
executionSteps.push({
|
|
440
|
-
functionName: await
|
|
478
|
+
functionName: await debugFunctionNameGetter(
|
|
441
479
|
execution.publicInputs.callContext.contractAddress,
|
|
442
480
|
execution.publicInputs.callContext.functionSelector,
|
|
443
481
|
),
|
|
@@ -54,7 +54,7 @@ export interface IMiscOracle {
|
|
|
54
54
|
|
|
55
55
|
utilityGetRandomField(): Fr;
|
|
56
56
|
utilityAssertCompatibleOracleVersion(version: number): void;
|
|
57
|
-
|
|
57
|
+
utilityLog(level: number, message: string, fields: Fr[]): Promise<void>;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|