@aztec/pxe 0.80.0 → 0.82.0
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/package_info.js +1 -1
- package/dest/entrypoints/server/utils.d.ts +15 -7
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +17 -9
- package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
- package/dest/private_kernel/hints/index.d.ts.map +1 -0
- package/dest/private_kernel/index.d.ts +3 -0
- package/dest/private_kernel/index.d.ts.map +1 -0
- package/dest/private_kernel/index.js +2 -0
- package/dest/{kernel_prover/kernel_prover.d.ts → private_kernel/private_kernel_execution_prover.d.ts} +13 -14
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
- package/dest/{kernel_prover/kernel_prover.js → private_kernel/private_kernel_execution_prover.js} +64 -64
- package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
- package/dest/private_kernel/private_kernel_oracle.js +4 -0
- package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +5 -5
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
- package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +2 -2
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts +14 -22
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.js +51 -107
- package/dest/pxe_service/pxe_service.d.ts +13 -27
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +213 -241
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +2 -2
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +6 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -2
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/index.d.ts +1 -2
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +1 -2
- package/dest/storage/metadata.d.ts +2 -0
- package/dest/storage/metadata.d.ts.map +1 -0
- package/dest/storage/metadata.js +1 -0
- package/dest/storage/note_data_provider/note_dao.d.ts +9 -13
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_dao.js +11 -15
- package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +18 -19
- package/dest/synchronizer/synchronizer.js +1 -1
- package/package.json +15 -15
- package/src/config/package_info.ts +1 -1
- package/src/entrypoints/server/utils.ts +25 -11
- package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +4 -4
- package/src/private_kernel/index.ts +2 -0
- package/src/{kernel_prover/kernel_prover.ts → private_kernel/private_kernel_execution_prover.ts} +76 -71
- package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
- package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +6 -5
- package/src/pxe_oracle_interface/pxe_oracle_interface.ts +77 -153
- package/src/pxe_service/pxe_service.ts +289 -310
- package/src/storage/contract_data_provider/contract_data_provider.ts +11 -2
- package/src/storage/contract_data_provider/private_functions_tree.ts +2 -2
- package/src/storage/index.ts +1 -3
- package/src/storage/metadata.ts +1 -0
- package/src/storage/note_data_provider/note_dao.ts +9 -18
- package/src/storage/note_data_provider/note_data_provider.ts +22 -28
- package/src/synchronizer/synchronizer.ts +1 -1
- package/dest/kernel_oracle/index.d.ts.map +0 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/kernel_prover/hints/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.d.ts +0 -3
- package/dest/kernel_prover/index.d.ts.map +0 -1
- package/dest/kernel_prover/index.js +0 -2
- package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
- package/dest/kernel_prover/proving_data_oracle.js +0 -4
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
- package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
- package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
- package/dest/storage/auth_witness_data_provider/index.js +0 -1
- package/src/kernel_prover/index.ts +0 -2
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
- package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
- package/src/storage/auth_witness_data_provider/index.ts +0 -1
- /package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.js +0 -0
- /package/dest/{kernel_prover → private_kernel}/hints/index.d.ts +0 -0
- /package/dest/{kernel_prover → private_kernel}/hints/index.js +0 -0
- /package/src/{kernel_prover → private_kernel}/hints/index.ts +0 -0
|
@@ -15,14 +15,13 @@ import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
|
15
15
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
16
16
|
import { UniqueNote } from '@aztec/stdlib/note';
|
|
17
17
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
18
|
-
import { PrivateSimulationResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
18
|
+
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
19
19
|
import { inspect } from 'util';
|
|
20
20
|
import { getPackageInfo } from '../config/package_info.js';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { PrivateKernelExecutionProver } from '../private_kernel/private_kernel_execution_prover.js';
|
|
22
|
+
import { PrivateKernelOracleImpl } from '../private_kernel/private_kernel_oracle_impl.js';
|
|
23
23
|
import { PXEOracleInterface } from '../pxe_oracle_interface/pxe_oracle_interface.js';
|
|
24
24
|
import { AddressDataProvider } from '../storage/address_data_provider/address_data_provider.js';
|
|
25
|
-
import { AuthWitnessDataProvider } from '../storage/auth_witness_data_provider/auth_witness_data_provider.js';
|
|
26
25
|
import { CapsuleDataProvider } from '../storage/capsule_data_provider/capsule_data_provider.js';
|
|
27
26
|
import { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
|
|
28
27
|
import { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
|
|
@@ -42,7 +41,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
42
41
|
syncDataProvider;
|
|
43
42
|
taggingDataProvider;
|
|
44
43
|
addressDataProvider;
|
|
45
|
-
authWitnessDataProvider;
|
|
46
44
|
simulator;
|
|
47
45
|
packageVersion;
|
|
48
46
|
proverEnabled;
|
|
@@ -50,7 +48,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
50
48
|
protocolContractsProvider;
|
|
51
49
|
log;
|
|
52
50
|
jobQueue;
|
|
53
|
-
constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider,
|
|
51
|
+
constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue){
|
|
54
52
|
this.node = node;
|
|
55
53
|
this.synchronizer = synchronizer;
|
|
56
54
|
this.keyStore = keyStore;
|
|
@@ -60,7 +58,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
60
58
|
this.syncDataProvider = syncDataProvider;
|
|
61
59
|
this.taggingDataProvider = taggingDataProvider;
|
|
62
60
|
this.addressDataProvider = addressDataProvider;
|
|
63
|
-
this.authWitnessDataProvider = authWitnessDataProvider;
|
|
64
61
|
this.simulator = simulator;
|
|
65
62
|
this.packageVersion = packageVersion;
|
|
66
63
|
this.proverEnabled = proverEnabled;
|
|
@@ -80,7 +77,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
80
77
|
const packageVersion = getPackageInfo().version;
|
|
81
78
|
const proverEnabled = !!config.proverEnabled;
|
|
82
79
|
const addressDataProvider = new AddressDataProvider(store);
|
|
83
|
-
const authWitnessDataProvider = new AuthWitnessDataProvider(store);
|
|
84
80
|
const contractDataProvider = new ContractDataProvider(store);
|
|
85
81
|
const noteDataProvider = await NoteDataProvider.create(store);
|
|
86
82
|
const syncDataProvider = new SyncDataProvider(store);
|
|
@@ -89,16 +85,61 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
89
85
|
const keyStore = new KeyStore(store);
|
|
90
86
|
const tipsStore = new L2TipsStore(store, 'pxe');
|
|
91
87
|
const synchronizer = new Synchronizer(node, syncDataProvider, noteDataProvider, taggingDataProvider, tipsStore, config, loggerOrSuffix);
|
|
92
|
-
const pxeOracleInterface = new PXEOracleInterface(node, keyStore, simulationProvider, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider,
|
|
88
|
+
const pxeOracleInterface = new PXEOracleInterface(node, keyStore, simulationProvider, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, log);
|
|
93
89
|
const simulator = new AcirSimulator(pxeOracleInterface, simulationProvider);
|
|
94
90
|
const jobQueue = new SerialQueue();
|
|
95
|
-
const pxeService = new PXEService(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider,
|
|
91
|
+
const pxeService = new PXEService(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue);
|
|
96
92
|
pxeService.jobQueue.start();
|
|
97
93
|
await pxeService.#registerProtocolContracts();
|
|
98
94
|
const info = await pxeService.getNodeInfo();
|
|
99
95
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
|
|
100
96
|
return pxeService;
|
|
101
97
|
}
|
|
98
|
+
// Aztec node proxy methods
|
|
99
|
+
isL1ToL2MessageSynced(l1ToL2Message) {
|
|
100
|
+
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
101
|
+
}
|
|
102
|
+
getL2ToL1MembershipWitness(blockNumber, l2Tol1Message) {
|
|
103
|
+
return this.node.getL2ToL1MessageMembershipWitness(blockNumber, l2Tol1Message);
|
|
104
|
+
}
|
|
105
|
+
getTxReceipt(txHash) {
|
|
106
|
+
return this.node.getTxReceipt(txHash);
|
|
107
|
+
}
|
|
108
|
+
getTxEffect(txHash) {
|
|
109
|
+
return this.node.getTxEffect(txHash);
|
|
110
|
+
}
|
|
111
|
+
getBlockNumber() {
|
|
112
|
+
return this.node.getBlockNumber();
|
|
113
|
+
}
|
|
114
|
+
getProvenBlockNumber() {
|
|
115
|
+
return this.node.getProvenBlockNumber();
|
|
116
|
+
}
|
|
117
|
+
getPublicLogs(filter) {
|
|
118
|
+
return this.node.getPublicLogs(filter);
|
|
119
|
+
}
|
|
120
|
+
getContractClassLogs(filter) {
|
|
121
|
+
return this.node.getContractClassLogs(filter);
|
|
122
|
+
}
|
|
123
|
+
getPublicStorageAt(contract, slot) {
|
|
124
|
+
return this.node.getPublicStorageAt('latest', contract, slot);
|
|
125
|
+
}
|
|
126
|
+
async getL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
|
|
127
|
+
return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret);
|
|
128
|
+
}
|
|
129
|
+
// Internal methods
|
|
130
|
+
#contextualizeError(err, ...context) {
|
|
131
|
+
let contextStr = '';
|
|
132
|
+
if (context.length > 0) {
|
|
133
|
+
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
134
|
+
}
|
|
135
|
+
if (err instanceof SimulationError) {
|
|
136
|
+
err.setAztecContext(contextStr);
|
|
137
|
+
} else {
|
|
138
|
+
this.log.error(err.name, err);
|
|
139
|
+
this.log.debug(contextStr);
|
|
140
|
+
}
|
|
141
|
+
return err;
|
|
142
|
+
}
|
|
102
143
|
/**
|
|
103
144
|
* Enqueues a job for execution once no other jobs are running. Returns a promise that will resolve once the job is
|
|
104
145
|
* complete.
|
|
@@ -111,14 +152,127 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
111
152
|
}
|
|
112
153
|
return this.jobQueue.put(fn);
|
|
113
154
|
}
|
|
114
|
-
|
|
115
|
-
|
|
155
|
+
async #registerProtocolContracts() {
|
|
156
|
+
const registered = {};
|
|
157
|
+
for (const name of protocolContractNames){
|
|
158
|
+
const { address, contractClass, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
159
|
+
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
160
|
+
await this.contractDataProvider.addContractInstance(instance);
|
|
161
|
+
registered[name] = address.toString();
|
|
162
|
+
}
|
|
163
|
+
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
164
|
+
}
|
|
165
|
+
async #isContractClassPubliclyRegistered(id) {
|
|
166
|
+
return !!await this.node.getContractClass(id);
|
|
167
|
+
}
|
|
168
|
+
async #isContractPubliclyDeployed(address) {
|
|
169
|
+
return !!await this.node.getContract(address);
|
|
170
|
+
}
|
|
171
|
+
async #isContractInitialized(address) {
|
|
172
|
+
const initNullifier = await siloNullifier(address, address.toField());
|
|
173
|
+
return !!await this.node.getNullifierMembershipWitness('latest', initNullifier);
|
|
174
|
+
}
|
|
175
|
+
async #getFunctionCall(functionName, args, to) {
|
|
176
|
+
const contract = await this.contractDataProvider.getContract(to);
|
|
177
|
+
if (!contract) {
|
|
178
|
+
throw new Error(`Unknown contract ${to}: add it to PXE Service by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/reference/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`);
|
|
179
|
+
}
|
|
180
|
+
const functionDao = contract.functions.find((f)=>f.name === functionName);
|
|
181
|
+
if (!functionDao) {
|
|
182
|
+
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
name: functionDao.name,
|
|
186
|
+
args: encodeArguments(functionDao, args),
|
|
187
|
+
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
188
|
+
type: functionDao.functionType,
|
|
189
|
+
to,
|
|
190
|
+
isStatic: functionDao.isStatic,
|
|
191
|
+
returnTypes: functionDao.returnTypes
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
async #executePrivate(txRequest, msgSender, scopes) {
|
|
195
|
+
const { origin: contractAddress, functionSelector } = txRequest;
|
|
196
|
+
try {
|
|
197
|
+
const result = await this.simulator.run(txRequest, contractAddress, functionSelector, msgSender, scopes);
|
|
198
|
+
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
199
|
+
return result;
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (err instanceof SimulationError) {
|
|
202
|
+
await enrichSimulationError(err, this.contractDataProvider, this.log);
|
|
203
|
+
}
|
|
204
|
+
throw err;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Simulate an unconstrained transaction on the given contract, without considering constraints set by ACIR.
|
|
209
|
+
* The simulation parameters are fetched using ContractDataProvider and executed using AcirSimulator.
|
|
210
|
+
* Returns the simulation result containing the outputs of the unconstrained function.
|
|
211
|
+
*
|
|
212
|
+
* @param execRequest - The transaction request object containing the target contract and function data.
|
|
213
|
+
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
214
|
+
* @returns The simulation result containing the outputs of the unconstrained function.
|
|
215
|
+
*/ async #simulateUnconstrained(execRequest, authWitnesses, scopes) {
|
|
216
|
+
const { to: contractAddress, selector: functionSelector } = execRequest;
|
|
217
|
+
this.log.debug('Executing unconstrained simulator...');
|
|
218
|
+
try {
|
|
219
|
+
const result = await this.simulator.runUnconstrained(execRequest, contractAddress, functionSelector, authWitnesses ?? [], scopes);
|
|
220
|
+
this.log.verbose(`Unconstrained simulation for ${contractAddress}.${functionSelector} completed`);
|
|
221
|
+
return result;
|
|
222
|
+
} catch (err) {
|
|
223
|
+
if (err instanceof SimulationError) {
|
|
224
|
+
await enrichSimulationError(err, this.contractDataProvider, this.log);
|
|
225
|
+
}
|
|
226
|
+
throw err;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Simulate the public part of a transaction.
|
|
231
|
+
* This allows to catch public execution errors before submitting the transaction.
|
|
232
|
+
* It can also be used for estimating gas in the future.
|
|
233
|
+
* @param tx - The transaction to be simulated.
|
|
234
|
+
*/ async #simulatePublicCalls(tx, skipFeeEnforcement) {
|
|
235
|
+
// Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
|
|
236
|
+
// Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
|
|
237
|
+
try {
|
|
238
|
+
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement);
|
|
239
|
+
if (result.revertReason) {
|
|
240
|
+
throw result.revertReason;
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
} catch (err) {
|
|
244
|
+
if (err instanceof SimulationError) {
|
|
245
|
+
try {
|
|
246
|
+
await enrichPublicSimulationError(err, this.contractDataProvider, this.log);
|
|
247
|
+
} catch (enrichErr) {
|
|
248
|
+
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
throw err;
|
|
252
|
+
}
|
|
116
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Generate a kernel proof, and create a private kernel output.
|
|
256
|
+
* The function takes in a transaction execution request, and the result of private execution
|
|
257
|
+
* and then generates a kernel proof.
|
|
258
|
+
*
|
|
259
|
+
* @param txExecutionRequest - The transaction request to be simulated and proved.
|
|
260
|
+
* @param proofCreator - The proof creator to use for proving the execution.
|
|
261
|
+
* @param privateExecutionResult - The result of the private execution
|
|
262
|
+
* @param config - The configuration for the kernel execution prover.
|
|
263
|
+
* @returns An object that contains the output of the kernel execution, including the ClientIvcProof if proving is enabled.
|
|
264
|
+
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
265
|
+
const block = privateExecutionResult.getSimulationBlockNumber();
|
|
266
|
+
const kernelOracle = new PrivateKernelOracleImpl(this.contractDataProvider, this.keyStore, this.node, block);
|
|
267
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
268
|
+
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
269
|
+
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
270
|
+
}
|
|
271
|
+
// Public API
|
|
117
272
|
/** Returns an estimate of the db size in bytes. */ async estimateDbSize() {
|
|
118
273
|
const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
|
|
119
274
|
const dbSizes = await Promise.all([
|
|
120
275
|
this.addressDataProvider.getSize(),
|
|
121
|
-
this.authWitnessDataProvider.getSize(),
|
|
122
276
|
this.capsuleDataProvider.getSize(),
|
|
123
277
|
this.contractDataProvider.getSize(),
|
|
124
278
|
this.noteDataProvider.getSize(),
|
|
@@ -130,15 +284,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
130
284
|
treeRootsSize
|
|
131
285
|
].reduce((sum, size)=>sum + size, 0);
|
|
132
286
|
}
|
|
133
|
-
addAuthWitness(witness) {
|
|
134
|
-
return this.authWitnessDataProvider.addAuthWitness(witness.requestHash, witness.witness);
|
|
135
|
-
}
|
|
136
|
-
getAuthWitness(messageHash) {
|
|
137
|
-
return this.authWitnessDataProvider.getAuthWitness(messageHash);
|
|
138
|
-
}
|
|
139
|
-
storeCapsule(contract, storageSlot, capsule) {
|
|
140
|
-
return this.capsuleDataProvider.storeCapsule(contract, storageSlot, capsule);
|
|
141
|
-
}
|
|
142
287
|
getContractInstance(address) {
|
|
143
288
|
return this.contractDataProvider.getContractInstance(address);
|
|
144
289
|
}
|
|
@@ -197,8 +342,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
197
342
|
return address;
|
|
198
343
|
}
|
|
199
344
|
getSenders() {
|
|
200
|
-
|
|
201
|
-
return Promise.resolve(senders);
|
|
345
|
+
return this.taggingDataProvider.getSenderAddresses();
|
|
202
346
|
}
|
|
203
347
|
async removeSender(address) {
|
|
204
348
|
const wasRemoved = await this.taggingDataProvider.removeSenderAddress(address);
|
|
@@ -207,7 +351,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
207
351
|
} else {
|
|
208
352
|
this.log.info(`Sender:\n "${address.toString()}"\n not in address book.`);
|
|
209
353
|
}
|
|
210
|
-
return Promise.resolve();
|
|
211
354
|
}
|
|
212
355
|
async getRegisteredAccounts() {
|
|
213
356
|
// Get complete addresses of both the recipients and the accounts
|
|
@@ -238,12 +381,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
238
381
|
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
239
382
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
240
383
|
await this.node.registerContractFunctionSignatures(instance.address, publicFunctionSignatures);
|
|
241
|
-
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
242
|
-
await this.node.addContractClass({
|
|
243
|
-
...contractClass,
|
|
244
|
-
privateFunctions: [],
|
|
245
|
-
unconstrainedFunctions: []
|
|
246
|
-
});
|
|
247
384
|
} else {
|
|
248
385
|
// Otherwise, make sure there is an artifact already registered for that class id
|
|
249
386
|
artifact = await this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
|
|
@@ -266,12 +403,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
266
403
|
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
267
404
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
268
405
|
await this.node.registerContractFunctionSignatures(contractAddress, publicFunctionSignatures);
|
|
269
|
-
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
270
|
-
await this.node.addContractClass({
|
|
271
|
-
...contractClass,
|
|
272
|
-
privateFunctions: [],
|
|
273
|
-
unconstrainedFunctions: []
|
|
274
|
-
});
|
|
275
406
|
currentInstance.currentContractClassId = contractClass.id;
|
|
276
407
|
await this.contractDataProvider.addContractInstance(currentInstance);
|
|
277
408
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
@@ -280,32 +411,23 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
280
411
|
getContracts() {
|
|
281
412
|
return this.contractDataProvider.getContractsAddresses();
|
|
282
413
|
}
|
|
283
|
-
async getPublicStorageAt(contract, slot) {
|
|
284
|
-
return await this.node.getPublicStorageAt('latest', contract, slot);
|
|
285
|
-
}
|
|
286
414
|
async getNotes(filter) {
|
|
287
415
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
288
416
|
const extendedNotes = noteDaos.map(async (dao)=>{
|
|
289
|
-
let
|
|
290
|
-
if (
|
|
417
|
+
let recipient = filter.recipient;
|
|
418
|
+
if (recipient === undefined) {
|
|
291
419
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
292
|
-
const completeAddressIndex =
|
|
420
|
+
const completeAddressIndex = completeAddresses.findIndex((completeAddress)=>completeAddress.address.equals(dao.recipient));
|
|
293
421
|
const completeAddress = completeAddresses[completeAddressIndex];
|
|
294
422
|
if (completeAddress === undefined) {
|
|
295
|
-
throw new Error(`Cannot find complete address for
|
|
423
|
+
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
296
424
|
}
|
|
297
|
-
|
|
425
|
+
recipient = completeAddress.address;
|
|
298
426
|
}
|
|
299
|
-
return new UniqueNote(dao.note,
|
|
427
|
+
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.nonce);
|
|
300
428
|
});
|
|
301
429
|
return Promise.all(extendedNotes);
|
|
302
430
|
}
|
|
303
|
-
async getL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
|
|
304
|
-
return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret);
|
|
305
|
-
}
|
|
306
|
-
getL2ToL1MembershipWitness(blockNumber, l2Tol1Message) {
|
|
307
|
-
return this.node.getL2ToL1MessageMembershipWitness(blockNumber, l2Tol1Message);
|
|
308
|
-
}
|
|
309
431
|
async getBlock(blockNumber) {
|
|
310
432
|
// If a negative block number is provided the current block number is fetched.
|
|
311
433
|
if (blockNumber < 0) {
|
|
@@ -324,16 +446,43 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
324
446
|
const { publicInputs, clientIvcProof } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
325
447
|
simulate: false,
|
|
326
448
|
skipFeeEnforcement: false,
|
|
327
|
-
|
|
449
|
+
profileMode: 'none'
|
|
328
450
|
});
|
|
329
451
|
return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof);
|
|
330
452
|
} catch (err) {
|
|
331
|
-
throw this
|
|
453
|
+
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
profileTx(txRequest, profileMode, msgSender) {
|
|
458
|
+
// We disable concurrent profiles for consistency with simulateTx.
|
|
459
|
+
return this.#putInJobQueue(async ()=>{
|
|
460
|
+
try {
|
|
461
|
+
const txInfo = {
|
|
462
|
+
origin: txRequest.origin,
|
|
463
|
+
functionSelector: txRequest.functionSelector,
|
|
464
|
+
simulatePublic: false,
|
|
465
|
+
msgSender,
|
|
466
|
+
chainId: txRequest.txContext.chainId,
|
|
467
|
+
version: txRequest.txContext.version,
|
|
468
|
+
authWitnesses: txRequest.authWitnesses.map((w)=>w.requestHash)
|
|
469
|
+
};
|
|
470
|
+
this.log.info(`Profiling transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
471
|
+
await this.synchronizer.sync();
|
|
472
|
+
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender);
|
|
473
|
+
const { executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
474
|
+
simulate: true,
|
|
475
|
+
skipFeeEnforcement: false,
|
|
476
|
+
profileMode
|
|
477
|
+
});
|
|
478
|
+
return new TxProfileResult(executionSteps);
|
|
479
|
+
} catch (err) {
|
|
480
|
+
throw this.#contextualizeError(err, inspect(txRequest), `profileMode=${profileMode}`, `msgSender=${msgSender?.toString() ?? 'undefined'}`);
|
|
332
481
|
}
|
|
333
482
|
});
|
|
334
483
|
}
|
|
335
484
|
// TODO(#7456) Prevent msgSender being defined here for the first call
|
|
336
|
-
simulateTx(txRequest, simulatePublic, msgSender = undefined, skipTxValidation = false, skipFeeEnforcement = false,
|
|
485
|
+
simulateTx(txRequest, simulatePublic, msgSender = undefined, skipTxValidation = false, skipFeeEnforcement = false, scopes) {
|
|
337
486
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
338
487
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
339
488
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -352,10 +501,10 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
352
501
|
const timer = new Timer();
|
|
353
502
|
await this.synchronizer.sync();
|
|
354
503
|
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
|
|
355
|
-
const { publicInputs
|
|
356
|
-
simulate:
|
|
504
|
+
const { publicInputs } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
505
|
+
simulate: true,
|
|
357
506
|
skipFeeEnforcement,
|
|
358
|
-
|
|
507
|
+
profileMode: 'none'
|
|
359
508
|
});
|
|
360
509
|
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
361
510
|
const simulatedTx = privateSimulationResult.toSimulatedTx();
|
|
@@ -376,18 +525,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
376
525
|
this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
|
|
377
526
|
txHash,
|
|
378
527
|
...txInfo,
|
|
379
|
-
...profileResult ? {
|
|
380
|
-
gateCounts: profileResult.gateCounts
|
|
381
|
-
} : {},
|
|
382
528
|
...publicOutput ? {
|
|
383
529
|
gasUsed: publicOutput.gasUsed,
|
|
384
530
|
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
385
531
|
revertReason: publicOutput.revertReason
|
|
386
532
|
} : {}
|
|
387
533
|
});
|
|
388
|
-
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput
|
|
534
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput);
|
|
389
535
|
} catch (err) {
|
|
390
|
-
throw this
|
|
536
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `msgSender=${msgSender?.toString() ?? 'undefined'}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
391
537
|
}
|
|
392
538
|
});
|
|
393
539
|
}
|
|
@@ -398,12 +544,12 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
398
544
|
}
|
|
399
545
|
this.log.debug(`Sending transaction ${txHash}`);
|
|
400
546
|
await this.node.sendTx(tx).catch((err)=>{
|
|
401
|
-
throw this
|
|
547
|
+
throw this.#contextualizeError(err, inspect(tx));
|
|
402
548
|
});
|
|
403
549
|
this.log.info(`Sent transaction ${txHash}`);
|
|
404
550
|
return txHash;
|
|
405
551
|
}
|
|
406
|
-
simulateUnconstrained(functionName, args, to, _from, scopes) {
|
|
552
|
+
simulateUnconstrained(functionName, args, to, authwits, _from, scopes) {
|
|
407
553
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
408
554
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
409
555
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -412,60 +558,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
412
558
|
await this.synchronizer.sync();
|
|
413
559
|
// TODO - Should check if `from` has the permission to call the view function.
|
|
414
560
|
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
415
|
-
const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
|
|
561
|
+
const executionResult = await this.#simulateUnconstrained(functionCall, authwits ?? [], scopes);
|
|
416
562
|
// TODO - Return typed result based on the function artifact.
|
|
417
563
|
return executionResult;
|
|
418
564
|
} catch (err) {
|
|
419
565
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
420
|
-
throw this
|
|
566
|
+
throw this.#contextualizeError(err, `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
|
|
421
567
|
}
|
|
422
568
|
});
|
|
423
569
|
}
|
|
424
|
-
getTxReceipt(txHash) {
|
|
425
|
-
return this.node.getTxReceipt(txHash);
|
|
426
|
-
}
|
|
427
|
-
getTxEffect(txHash) {
|
|
428
|
-
return this.node.getTxEffect(txHash);
|
|
429
|
-
}
|
|
430
|
-
async getBlockNumber() {
|
|
431
|
-
return await this.node.getBlockNumber();
|
|
432
|
-
}
|
|
433
|
-
async getProvenBlockNumber() {
|
|
434
|
-
return await this.node.getProvenBlockNumber();
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Gets public logs based on the provided filter.
|
|
438
|
-
* @param filter - The filter to apply to the logs.
|
|
439
|
-
* @returns The requested logs.
|
|
440
|
-
*/ getPublicLogs(filter) {
|
|
441
|
-
return this.node.getPublicLogs(filter);
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Gets contract class logs based on the provided filter.
|
|
445
|
-
* @param filter - The filter to apply to the logs.
|
|
446
|
-
* @returns The requested logs.
|
|
447
|
-
*/ getContractClassLogs(filter) {
|
|
448
|
-
return this.node.getContractClassLogs(filter);
|
|
449
|
-
}
|
|
450
|
-
async #getFunctionCall(functionName, args, to) {
|
|
451
|
-
const contract = await this.contractDataProvider.getContract(to);
|
|
452
|
-
if (!contract) {
|
|
453
|
-
throw new Error(`Unknown contract ${to}: add it to PXE Service by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/reference/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`);
|
|
454
|
-
}
|
|
455
|
-
const functionDao = contract.functions.find((f)=>f.name === functionName);
|
|
456
|
-
if (!functionDao) {
|
|
457
|
-
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
458
|
-
}
|
|
459
|
-
return {
|
|
460
|
-
name: functionDao.name,
|
|
461
|
-
args: encodeArguments(functionDao, args),
|
|
462
|
-
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
463
|
-
type: functionDao.functionType,
|
|
464
|
-
to,
|
|
465
|
-
isStatic: functionDao.isStatic,
|
|
466
|
-
returnTypes: functionDao.returnTypes
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
570
|
async getNodeInfo() {
|
|
470
571
|
const [nodeVersion, protocolVersion, chainId, enr, contractAddresses, protocolContractAddresses] = await Promise.all([
|
|
471
572
|
this.node.getNodeVersion(),
|
|
@@ -496,122 +597,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
496
597
|
}
|
|
497
598
|
});
|
|
498
599
|
}
|
|
499
|
-
async #registerProtocolContracts() {
|
|
500
|
-
const registered = {};
|
|
501
|
-
for (const name of protocolContractNames){
|
|
502
|
-
const { address, contractClass, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
503
|
-
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
504
|
-
await this.contractDataProvider.addContractInstance(instance);
|
|
505
|
-
registered[name] = address.toString();
|
|
506
|
-
}
|
|
507
|
-
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Retrieves the simulation parameters required to run an ACIR simulation.
|
|
511
|
-
* This includes the contract address, function artifact, and historical tree roots.
|
|
512
|
-
*
|
|
513
|
-
* @param execRequest - The transaction request object containing details of the contract call.
|
|
514
|
-
* @returns An object containing the contract address, function artifact, and historical tree roots.
|
|
515
|
-
*/ #getSimulationParameters(execRequest) {
|
|
516
|
-
const contractAddress = execRequest.to ?? execRequest.origin;
|
|
517
|
-
const functionSelector = execRequest.selector ?? execRequest.functionSelector;
|
|
518
|
-
return {
|
|
519
|
-
contractAddress,
|
|
520
|
-
functionSelector
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
async #executePrivate(txRequest, msgSender, scopes) {
|
|
524
|
-
// TODO - Pause syncing while simulating.
|
|
525
|
-
const { contractAddress, functionSelector } = this.#getSimulationParameters(txRequest);
|
|
526
|
-
try {
|
|
527
|
-
const result = await this.simulator.run(txRequest, contractAddress, functionSelector, msgSender, scopes);
|
|
528
|
-
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
529
|
-
return result;
|
|
530
|
-
} catch (err) {
|
|
531
|
-
if (err instanceof SimulationError) {
|
|
532
|
-
await enrichSimulationError(err, this.contractDataProvider, this.log);
|
|
533
|
-
}
|
|
534
|
-
throw err;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Simulate an unconstrained transaction on the given contract, without considering constraints set by ACIR.
|
|
539
|
-
* The simulation parameters are fetched using ContractDataProvider and executed using AcirSimulator.
|
|
540
|
-
* Returns the simulation result containing the outputs of the unconstrained function.
|
|
541
|
-
*
|
|
542
|
-
* @param execRequest - The transaction request object containing the target contract and function data.
|
|
543
|
-
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
544
|
-
* @returns The simulation result containing the outputs of the unconstrained function.
|
|
545
|
-
*/ async #simulateUnconstrained(execRequest, scopes) {
|
|
546
|
-
const { contractAddress, functionSelector } = this.#getSimulationParameters(execRequest);
|
|
547
|
-
this.log.debug('Executing unconstrained simulator...');
|
|
548
|
-
try {
|
|
549
|
-
const result = await this.simulator.runUnconstrained(execRequest, contractAddress, functionSelector, scopes);
|
|
550
|
-
this.log.verbose(`Unconstrained simulation for ${contractAddress}.${functionSelector} completed`);
|
|
551
|
-
return result;
|
|
552
|
-
} catch (err) {
|
|
553
|
-
if (err instanceof SimulationError) {
|
|
554
|
-
await enrichSimulationError(err, this.contractDataProvider, this.log);
|
|
555
|
-
}
|
|
556
|
-
throw err;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Simulate the public part of a transaction.
|
|
561
|
-
* This allows to catch public execution errors before submitting the transaction.
|
|
562
|
-
* It can also be used for estimating gas in the future.
|
|
563
|
-
* @param tx - The transaction to be simulated.
|
|
564
|
-
*/ async #simulatePublicCalls(tx, skipFeeEnforcement) {
|
|
565
|
-
// Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
|
|
566
|
-
// Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
|
|
567
|
-
try {
|
|
568
|
-
const result = await this.node.simulatePublicCalls(tx, skipFeeEnforcement);
|
|
569
|
-
if (result.revertReason) {
|
|
570
|
-
throw result.revertReason;
|
|
571
|
-
}
|
|
572
|
-
return result;
|
|
573
|
-
} catch (err) {
|
|
574
|
-
if (err instanceof SimulationError) {
|
|
575
|
-
try {
|
|
576
|
-
await enrichPublicSimulationError(err, this.contractDataProvider, this.log);
|
|
577
|
-
} catch (enrichErr) {
|
|
578
|
-
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
throw err;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Generate a kernel proof, and create a private kernel output.
|
|
586
|
-
* The function takes in a transaction execution request, and the result of private execution
|
|
587
|
-
* and then generates a kernel proof.
|
|
588
|
-
*
|
|
589
|
-
* @param txExecutionRequest - The transaction request to be simulated and proved.
|
|
590
|
-
* @param proofCreator - The proof creator to use for proving the execution.
|
|
591
|
-
* @param privateExecutionResult - The result of the private execution
|
|
592
|
-
* @returns An object that contains the output of the kernel execution, including the ClientIvcProof if proving is enabled.
|
|
593
|
-
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, { simulate, skipFeeEnforcement, profile }) {
|
|
594
|
-
// use the block the tx was simulated against
|
|
595
|
-
const block = privateExecutionResult.entrypoint.publicInputs.historicalHeader.globalVariables.blockNumber.toNumber();
|
|
596
|
-
const kernelOracle = new KernelOracle(this.contractDataProvider, this.keyStore, this.node, block);
|
|
597
|
-
const kernelProver = new KernelProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
598
|
-
this.log.debug(`Executing kernel prover (simulate: ${simulate}, profile: ${profile})...`);
|
|
599
|
-
return await kernelProver.prove(txExecutionRequest.toTxRequest(), privateExecutionResult, {
|
|
600
|
-
simulate,
|
|
601
|
-
skipFeeEnforcement,
|
|
602
|
-
profile
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
async #isContractClassPubliclyRegistered(id) {
|
|
606
|
-
return !!await this.node.getContractClass(id);
|
|
607
|
-
}
|
|
608
|
-
async #isContractPubliclyDeployed(address) {
|
|
609
|
-
return !!await this.node.getContract(address);
|
|
610
|
-
}
|
|
611
|
-
async #isContractInitialized(address) {
|
|
612
|
-
const initNullifier = await siloNullifier(address, address.toField());
|
|
613
|
-
return !!await this.node.getNullifierMembershipWitness('latest', initNullifier);
|
|
614
|
-
}
|
|
615
600
|
async getPrivateEvents(eventMetadataDef, from, limit, // TODO (#9272): Make this better, we should be able to only pass an address now
|
|
616
601
|
vpks) {
|
|
617
602
|
const eventMetadata = new EventMetadata(eventMetadataDef);
|
|
@@ -683,17 +668,4 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
683
668
|
async resetNoteSyncData() {
|
|
684
669
|
return await this.taggingDataProvider.resetNoteSyncData();
|
|
685
670
|
}
|
|
686
|
-
contextualizeError(err, ...context) {
|
|
687
|
-
let contextStr = '';
|
|
688
|
-
if (context.length > 0) {
|
|
689
|
-
contextStr = `\nContext:\n${context.join('\n')}`;
|
|
690
|
-
}
|
|
691
|
-
if (err instanceof SimulationError) {
|
|
692
|
-
err.setAztecContext(contextStr);
|
|
693
|
-
} else {
|
|
694
|
-
this.log.error(err.name, err);
|
|
695
|
-
this.log.debug(contextStr);
|
|
696
|
-
}
|
|
697
|
-
return err;
|
|
698
|
-
}
|
|
699
671
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
5
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
6
|
-
import { type ContractArtifact, type FunctionArtifact, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
|
+
import { type ContractArtifact, type FunctionArtifact, type FunctionArtifactWithContractName, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { type ContractClass, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
9
9
|
import type { DataProvider } from '../data_provider.js';
|
|
@@ -59,7 +59,7 @@ export declare class ContractDataProvider implements DataProvider {
|
|
|
59
59
|
* @param selector - The function selector.
|
|
60
60
|
* @returns The corresponding function's artifact as an object.
|
|
61
61
|
*/
|
|
62
|
-
getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<
|
|
62
|
+
getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifactWithContractName>;
|
|
63
63
|
/**
|
|
64
64
|
* Retrieves the artifact of a specified function within a given contract.
|
|
65
65
|
* The function is identified by its name, which is unique within a contract.
|