@aztec/pxe 0.8.8 → 0.8.10
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/contract_data_oracle/index.d.ts +4 -4
- package/dest/contract_data_oracle/index.d.ts.map +1 -1
- package/dest/contract_data_oracle/index.js +9 -9
- package/dest/contract_tree/index.d.ts +10 -10
- package/dest/contract_tree/index.d.ts.map +1 -1
- package/dest/contract_tree/index.js +21 -21
- package/dest/database/database.d.ts +5 -0
- package/dest/database/database.d.ts.map +1 -1
- package/dest/database/memory_db.d.ts +1 -0
- package/dest/database/memory_db.d.ts.map +1 -1
- package/dest/database/memory_db.js +10 -2
- package/dest/database/note_spending_info_dao.d.ts +6 -0
- package/dest/database/note_spending_info_dao.d.ts.map +1 -1
- package/dest/database/note_spending_info_dao.js +11 -1
- package/dest/kernel_prover/proof_creator.d.ts.map +1 -1
- package/dest/kernel_prover/proof_creator.js +7 -7
- package/dest/note_processor/note_processor.d.ts +1 -10
- package/dest/note_processor/note_processor.d.ts.map +1 -1
- package/dest/note_processor/note_processor.js +4 -2
- package/dest/pxe_service/pxe_service.d.ts +2 -0
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +19 -15
- package/dest/simulator_oracle/index.d.ts +2 -2
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +4 -4
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +2 -1
- package/package.json +8 -8
- package/src/contract_data_oracle/index.ts +8 -8
- package/src/contract_tree/index.ts +21 -21
- package/src/database/database.ts +6 -0
- package/src/database/memory_db.ts +9 -1
- package/src/database/note_spending_info_dao.ts +11 -0
- package/src/kernel_prover/proof_creator.ts +10 -9
- package/src/note_processor/note_processor.ts +4 -11
- package/src/pxe_service/pxe_service.ts +19 -14
- package/src/simulator_oracle/index.ts +5 -5
- package/src/synchronizer/synchronizer.ts +3 -1
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
computeVarArgsHash,
|
|
23
23
|
hashConstructor,
|
|
24
24
|
} from '@aztec/circuits.js/abis';
|
|
25
|
-
import {
|
|
25
|
+
import { ContractArtifact, FunctionSelector } from '@aztec/foundation/abi';
|
|
26
26
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
27
27
|
import { AztecNode, ContractDao, MerkleTreeId, PublicKey, StateInfoProvider } from '@aztec/types';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* The ContractTree class represents a Merkle tree of functions for a particular contract.
|
|
31
31
|
* It manages the construction of the function tree, computes its root, and generates membership witnesses
|
|
32
|
-
* for constrained functions. This class also enables lookup of specific function
|
|
32
|
+
* for constrained functions. This class also enables lookup of specific function artifact using selectors.
|
|
33
33
|
* It is used in combination with the AztecNode to compute various data for executing private transactions.
|
|
34
34
|
*/
|
|
35
35
|
export class ContractTree {
|
|
@@ -40,7 +40,7 @@ export class ContractTree {
|
|
|
40
40
|
|
|
41
41
|
constructor(
|
|
42
42
|
/**
|
|
43
|
-
* The contract data object containing the
|
|
43
|
+
* The contract data object containing the artifact and contract address.
|
|
44
44
|
*/
|
|
45
45
|
public readonly contract: ContractDao,
|
|
46
46
|
private stateInfoProvider: StateInfoProvider,
|
|
@@ -52,13 +52,13 @@ export class ContractTree {
|
|
|
52
52
|
) {}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Create a new ContractTree instance from the provided contract
|
|
55
|
+
* Create a new ContractTree instance from the provided contract artifact, constructor arguments, and related data.
|
|
56
56
|
* The function generates function leaves for constrained functions, computes the function tree root,
|
|
57
57
|
* and hashes the constructor's verification key. It then computes the contract address using the contract
|
|
58
58
|
* and portal contract addresses, contract address salt, and generated data. Finally, it returns a new
|
|
59
59
|
* ContractTree instance containing the contract data and computed values.
|
|
60
60
|
*
|
|
61
|
-
* @param
|
|
61
|
+
* @param artifact - The contract's build artifact containing the functions and their metadata.
|
|
62
62
|
* @param args - An array of Fr elements representing the constructor's arguments.
|
|
63
63
|
* @param portalContract - The Ethereum address of the portal smart contract.
|
|
64
64
|
* @param contractAddressSalt - An Fr element representing the salt used to compute the contract address.
|
|
@@ -67,7 +67,7 @@ export class ContractTree {
|
|
|
67
67
|
* @returns A new ContractTree instance containing the contract data and computed values.
|
|
68
68
|
*/
|
|
69
69
|
public static async new(
|
|
70
|
-
|
|
70
|
+
artifact: ContractArtifact,
|
|
71
71
|
args: Fr[],
|
|
72
72
|
portalContract: EthAddress,
|
|
73
73
|
contractAddressSalt: Fr,
|
|
@@ -75,29 +75,29 @@ export class ContractTree {
|
|
|
75
75
|
node: AztecNode,
|
|
76
76
|
) {
|
|
77
77
|
const wasm = await CircuitsWasm.get();
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
78
|
+
const constructorArtifact = artifact.functions.find(isConstructor);
|
|
79
|
+
if (!constructorArtifact) {
|
|
80
80
|
throw new Error('Constructor not found.');
|
|
81
81
|
}
|
|
82
|
-
if (!
|
|
82
|
+
if (!constructorArtifact.verificationKey) {
|
|
83
83
|
throw new Error('Missing verification key for the constructor.');
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const functions =
|
|
86
|
+
const functions = artifact.functions.map(f => ({
|
|
87
87
|
...f,
|
|
88
88
|
selector: FunctionSelector.fromNameAndParameters(f.name, f.parameters),
|
|
89
89
|
}));
|
|
90
90
|
const leaves = generateFunctionLeaves(functions, wasm);
|
|
91
91
|
const root = computeFunctionTreeRoot(wasm, leaves);
|
|
92
|
-
const functionData = FunctionData.fromAbi(
|
|
93
|
-
const vkHash = hashVKStr(
|
|
92
|
+
const functionData = FunctionData.fromAbi(constructorArtifact);
|
|
93
|
+
const vkHash = hashVKStr(constructorArtifact.verificationKey, wasm);
|
|
94
94
|
const argsHash = await computeVarArgsHash(wasm, args);
|
|
95
95
|
const constructorHash = hashConstructor(wasm, functionData, argsHash, vkHash);
|
|
96
96
|
|
|
97
97
|
const completeAddress = computeCompleteAddress(wasm, from, contractAddressSalt, root, constructorHash);
|
|
98
98
|
|
|
99
99
|
const contractDao: ContractDao = {
|
|
100
|
-
...
|
|
100
|
+
...artifact,
|
|
101
101
|
completeAddress,
|
|
102
102
|
functions,
|
|
103
103
|
portalContract,
|
|
@@ -110,23 +110,23 @@ export class ContractTree {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
* Retrieve the
|
|
113
|
+
* Retrieve the artifact of a given function.
|
|
114
114
|
* The function is identified by its selector, which represents a unique identifier for the function's signature.
|
|
115
115
|
* Throws an error if the function with the provided selector is not found in the contract.
|
|
116
116
|
*
|
|
117
117
|
* @param selector - The function selector.
|
|
118
|
-
* @returns The
|
|
118
|
+
* @returns The artifact object containing relevant information about the targeted function.
|
|
119
119
|
*/
|
|
120
|
-
public
|
|
121
|
-
const
|
|
122
|
-
if (!
|
|
120
|
+
public getFunctionArtifact(selector: FunctionSelector) {
|
|
121
|
+
const artifact = this.contract.functions.find(f => f.selector.equals(selector));
|
|
122
|
+
if (!artifact) {
|
|
123
123
|
throw new Error(
|
|
124
|
-
`Unknown function. Selector ${selector.toString()} not found in the
|
|
124
|
+
`Unknown function. Selector ${selector.toString()} not found in the artifact of contract ${this.contract.completeAddress.address.toString()}. Expected one of: ${this.contract.functions
|
|
125
125
|
.map(f => f.selector.toString())
|
|
126
126
|
.join(', ')}`,
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
|
-
return
|
|
129
|
+
return artifact;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
@@ -138,7 +138,7 @@ export class ContractTree {
|
|
|
138
138
|
* @returns The bytecode of the function as a string.
|
|
139
139
|
*/
|
|
140
140
|
public getBytecode(selector: FunctionSelector) {
|
|
141
|
-
return this.
|
|
141
|
+
return this.getFunctionArtifact(selector).bytecode;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
package/src/database/database.ts
CHANGED
|
@@ -128,4 +128,10 @@ export interface Database extends ContractDatabase {
|
|
|
128
128
|
* @returns A promise that resolves to an array of AztecAddress instances.
|
|
129
129
|
*/
|
|
130
130
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns the estimated size in bytes of this db.
|
|
134
|
+
* @returns The estimated size in bytes of this db.
|
|
135
|
+
*/
|
|
136
|
+
estimateSize(): number;
|
|
131
137
|
}
|
|
@@ -6,7 +6,7 @@ import { MerkleTreeId, PublicKey } from '@aztec/types';
|
|
|
6
6
|
|
|
7
7
|
import { MemoryContractDatabase } from '../contract_database/index.js';
|
|
8
8
|
import { Database } from './database.js';
|
|
9
|
-
import { NoteSpendingInfoDao } from './note_spending_info_dao.js';
|
|
9
|
+
import { NoteSpendingInfoDao, getNoteSpendingInfoDaoSize } from './note_spending_info_dao.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The MemoryDB class provides an in-memory implementation of a database to manage transactions and auxiliary data.
|
|
@@ -144,4 +144,12 @@ export class MemoryDB extends MemoryContractDatabase implements Database {
|
|
|
144
144
|
public getCompleteAddresses(): Promise<CompleteAddress[]> {
|
|
145
145
|
return Promise.resolve(this.addresses);
|
|
146
146
|
}
|
|
147
|
+
|
|
148
|
+
public estimateSize() {
|
|
149
|
+
const notesSize = this.noteSpendingInfoTable.reduce((sum, note) => sum + getNoteSpendingInfoDaoSize(note), 0);
|
|
150
|
+
const treeRootsSize = this.treeRoots ? Object.entries(this.treeRoots).length * Fr.SIZE_IN_BYTES : 0;
|
|
151
|
+
const authWits = Object.entries(this.authWitnesses);
|
|
152
|
+
const authWitsSize = authWits.reduce((sum, [key, value]) => sum + key.length + value.length * Fr.SIZE_IN_BYTES, 0);
|
|
153
|
+
return notesSize + treeRootsSize + authWitsSize + this.addresses.length * CompleteAddress.SIZE_IN_BYTES;
|
|
154
|
+
}
|
|
147
155
|
}
|
|
@@ -62,3 +62,14 @@ export const createRandomNoteSpendingInfoDao = ({
|
|
|
62
62
|
index,
|
|
63
63
|
publicKey,
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns the size in bytes of a note spending info dao.
|
|
68
|
+
* @param note - The note.
|
|
69
|
+
* @returns - Its size in bytes.
|
|
70
|
+
*/
|
|
71
|
+
export function getNoteSpendingInfoDaoSize(note: NoteSpendingInfoDao) {
|
|
72
|
+
// 7 fields + 1 bigint + 1 buffer size (4 bytes) + 1 buffer
|
|
73
|
+
const indexSize = Math.ceil(Math.log2(Number(note.index)));
|
|
74
|
+
return 7 * Fr.SIZE_IN_BYTES + indexSize + 4 + note.notePreimage.items.length * Fr.SIZE_IN_BYTES;
|
|
75
|
+
}
|
|
@@ -17,6 +17,7 @@ import { siloCommitment } from '@aztec/circuits.js/abis';
|
|
|
17
17
|
import { Fr } from '@aztec/foundation/fields';
|
|
18
18
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
19
19
|
import { elapsed } from '@aztec/foundation/timer';
|
|
20
|
+
import { CircuitSimulationStats } from '@aztec/types/stats';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Represents the output of the proof creation process for init and inner private kernel circuit.
|
|
@@ -109,17 +110,17 @@ export class KernelProofCreator implements ProofCreator {
|
|
|
109
110
|
|
|
110
111
|
public async createProofInit(privateInputs: PrivateKernelInputsInit): Promise<ProofOutput> {
|
|
111
112
|
const wasm = await CircuitsWasm.get();
|
|
112
|
-
const [
|
|
113
|
+
const [duration, result] = await elapsed(() => privateKernelSimInit(wasm, privateInputs));
|
|
113
114
|
if (result instanceof CircuitError) {
|
|
114
115
|
throw new CircuitError(result.code, result.message);
|
|
115
116
|
}
|
|
116
117
|
this.log(`Simulated private kernel init`, {
|
|
117
118
|
eventName: 'circuit-simulation',
|
|
118
119
|
circuitName: 'private-kernel-init',
|
|
119
|
-
duration
|
|
120
|
+
duration,
|
|
120
121
|
inputSize: privateInputs.toBuffer().length,
|
|
121
122
|
outputSize: result.toBuffer().length,
|
|
122
|
-
});
|
|
123
|
+
} satisfies CircuitSimulationStats);
|
|
123
124
|
this.log('Skipping private kernel init proving...');
|
|
124
125
|
const proof = makeEmptyProof();
|
|
125
126
|
|
|
@@ -131,17 +132,17 @@ export class KernelProofCreator implements ProofCreator {
|
|
|
131
132
|
|
|
132
133
|
public async createProofInner(privateInputs: PrivateKernelInputsInner): Promise<ProofOutput> {
|
|
133
134
|
const wasm = await CircuitsWasm.get();
|
|
134
|
-
const [
|
|
135
|
+
const [duration, result] = await elapsed(() => privateKernelSimInner(wasm, privateInputs));
|
|
135
136
|
if (result instanceof CircuitError) {
|
|
136
137
|
throw new CircuitError(result.code, result.message);
|
|
137
138
|
}
|
|
138
139
|
this.log(`Simulated private kernel inner`, {
|
|
139
140
|
eventName: 'circuit-simulation',
|
|
140
141
|
circuitName: 'private-kernel-inner',
|
|
141
|
-
duration
|
|
142
|
+
duration,
|
|
142
143
|
inputSize: privateInputs.toBuffer().length,
|
|
143
144
|
outputSize: result.toBuffer().length,
|
|
144
|
-
});
|
|
145
|
+
} satisfies CircuitSimulationStats);
|
|
145
146
|
this.log('Skipping private kernel inner proving...');
|
|
146
147
|
const proof = makeEmptyProof();
|
|
147
148
|
|
|
@@ -154,17 +155,17 @@ export class KernelProofCreator implements ProofCreator {
|
|
|
154
155
|
public async createProofOrdering(privateInputs: PrivateKernelInputsOrdering): Promise<ProofOutputFinal> {
|
|
155
156
|
const wasm = await CircuitsWasm.get();
|
|
156
157
|
this.log('Executing private kernel simulation ordering...');
|
|
157
|
-
const [
|
|
158
|
+
const [duration, result] = await elapsed(() => privateKernelSimOrdering(wasm, privateInputs));
|
|
158
159
|
if (result instanceof CircuitError) {
|
|
159
160
|
throw new CircuitError(result.code, result.message);
|
|
160
161
|
}
|
|
161
162
|
this.log(`Simulated private kernel ordering`, {
|
|
162
163
|
eventName: 'circuit-simulation',
|
|
163
164
|
circuitName: 'private-kernel-ordering',
|
|
164
|
-
duration
|
|
165
|
+
duration,
|
|
165
166
|
inputSize: privateInputs.toBuffer().length,
|
|
166
167
|
outputSize: result.toBuffer().length,
|
|
167
|
-
});
|
|
168
|
+
} satisfies CircuitSimulationStats);
|
|
168
169
|
this.log('Skipping private kernel ordering proving...');
|
|
169
170
|
const proof = makeEmptyProof();
|
|
170
171
|
|
|
@@ -5,6 +5,7 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
5
5
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { Timer } from '@aztec/foundation/timer';
|
|
7
7
|
import { AztecNode, KeyStore, L2BlockContext, L2BlockL2Logs, NoteSpendingInfo, PublicKey } from '@aztec/types';
|
|
8
|
+
import { NoteProcessorStats } from '@aztec/types/stats';
|
|
8
9
|
|
|
9
10
|
import { Database, NoteSpendingInfoDao } from '../database/index.js';
|
|
10
11
|
import { getAcirSimulator } from '../simulator/index.js';
|
|
@@ -23,16 +24,6 @@ interface ProcessedData {
|
|
|
23
24
|
noteSpendingInfoDaos: NoteSpendingInfoDao[];
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
/** Accumulated stats for a note processor. */
|
|
27
|
-
type NoteProcessorStats = {
|
|
28
|
-
/** How many notes have been seen and trial-decrypted. */
|
|
29
|
-
seen: number;
|
|
30
|
-
/** How many notes were successfully decrypted. */
|
|
31
|
-
decrypted: number;
|
|
32
|
-
/** How many notes failed processing. */
|
|
33
|
-
failed: number;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
27
|
/**
|
|
37
28
|
* NoteProcessor is responsible for decrypting logs and converting them to notes via their originating contracts
|
|
38
29
|
* before storing them against their owner.
|
|
@@ -45,7 +36,7 @@ export class NoteProcessor {
|
|
|
45
36
|
public readonly timer: Timer = new Timer();
|
|
46
37
|
|
|
47
38
|
/** Stats accumulated for this processor. */
|
|
48
|
-
public readonly stats: NoteProcessorStats = { seen: 0, decrypted: 0, failed: 0 };
|
|
39
|
+
public readonly stats: NoteProcessorStats = { seen: 0, decrypted: 0, failed: 0, blocks: 0, txs: 0 };
|
|
49
40
|
|
|
50
41
|
constructor(
|
|
51
42
|
/**
|
|
@@ -106,6 +97,7 @@ export class NoteProcessor {
|
|
|
106
97
|
|
|
107
98
|
// Iterate over both blocks and encrypted logs.
|
|
108
99
|
for (let blockIndex = 0; blockIndex < encryptedL2BlockLogs.length; ++blockIndex) {
|
|
100
|
+
this.stats.blocks++;
|
|
109
101
|
const { txLogs } = encryptedL2BlockLogs[blockIndex];
|
|
110
102
|
const block = l2BlockContexts[blockIndex].block;
|
|
111
103
|
const dataStartIndexForBlock = block.startPrivateDataTreeSnapshot.nextAvailableLeafIndex;
|
|
@@ -117,6 +109,7 @@ export class NoteProcessor {
|
|
|
117
109
|
|
|
118
110
|
// Iterate over all the encrypted logs and try decrypting them. If successful, store the note spending info.
|
|
119
111
|
for (let indexOfTxInABlock = 0; indexOfTxInABlock < txLogs.length; ++indexOfTxInABlock) {
|
|
112
|
+
this.stats.txs++;
|
|
120
113
|
const dataStartIndexForTx = dataStartIndexForBlock + indexOfTxInABlock * MAX_NEW_COMMITMENTS_PER_TX;
|
|
121
114
|
const newCommitments = block.newCommitments.slice(
|
|
122
115
|
indexOfTxInABlock * MAX_NEW_COMMITMENTS_PER_TX,
|
|
@@ -110,6 +110,11 @@ export class PXEService implements PXE {
|
|
|
110
110
|
this.log.info('Stopped');
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/** Returns an estimate of the db size in bytes. */
|
|
114
|
+
public estimateDbSize() {
|
|
115
|
+
return this.db.estimateSize();
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
public addAuthWitness(witness: AuthWitness) {
|
|
114
119
|
return this.db.addAuthWitness(witness.requestHash, witness.witness);
|
|
115
120
|
}
|
|
@@ -168,7 +173,7 @@ export class PXEService implements PXE {
|
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
public async addContracts(contracts: DeployedContract[]) {
|
|
171
|
-
const contractDaos = contracts.map(c => toContractDao(c.
|
|
176
|
+
const contractDaos = contracts.map(c => toContractDao(c.artifact, c.completeAddress, c.portalContract));
|
|
172
177
|
await Promise.all(contractDaos.map(c => this.db.addContract(c)));
|
|
173
178
|
for (const contract of contractDaos) {
|
|
174
179
|
const portalInfo =
|
|
@@ -334,7 +339,7 @@ export class PXEService implements PXE {
|
|
|
334
339
|
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
335
340
|
const executionResult = await this.#simulateUnconstrained(functionCall);
|
|
336
341
|
|
|
337
|
-
// TODO - Return typed result based on the function
|
|
342
|
+
// TODO - Return typed result based on the function artifact.
|
|
338
343
|
return executionResult;
|
|
339
344
|
}
|
|
340
345
|
|
|
@@ -420,14 +425,14 @@ export class PXEService implements PXE {
|
|
|
420
425
|
|
|
421
426
|
/**
|
|
422
427
|
* Retrieves the simulation parameters required to run an ACIR simulation.
|
|
423
|
-
* This includes the contract address, function
|
|
428
|
+
* This includes the contract address, function artifact, portal contract address, and historic tree roots.
|
|
424
429
|
*
|
|
425
430
|
* @param execRequest - The transaction request object containing details of the contract call.
|
|
426
|
-
* @returns An object containing the contract address, function
|
|
431
|
+
* @returns An object containing the contract address, function artifact, portal contract address, and historic tree roots.
|
|
427
432
|
*/
|
|
428
433
|
async #getSimulationParameters(execRequest: FunctionCall | TxExecutionRequest) {
|
|
429
434
|
const contractAddress = (execRequest as FunctionCall).to ?? (execRequest as TxExecutionRequest).origin;
|
|
430
|
-
const
|
|
435
|
+
const functionArtifact = await this.contractDataOracle.getFunctionArtifact(
|
|
431
436
|
contractAddress,
|
|
432
437
|
execRequest.functionData.selector,
|
|
433
438
|
);
|
|
@@ -439,8 +444,8 @@ export class PXEService implements PXE {
|
|
|
439
444
|
|
|
440
445
|
return {
|
|
441
446
|
contractAddress,
|
|
442
|
-
|
|
443
|
-
...
|
|
447
|
+
functionArtifact: {
|
|
448
|
+
...functionArtifact,
|
|
444
449
|
debug,
|
|
445
450
|
},
|
|
446
451
|
portalContract,
|
|
@@ -450,11 +455,11 @@ export class PXEService implements PXE {
|
|
|
450
455
|
async #simulate(txRequest: TxExecutionRequest): Promise<ExecutionResult> {
|
|
451
456
|
// TODO - Pause syncing while simulating.
|
|
452
457
|
|
|
453
|
-
const { contractAddress,
|
|
458
|
+
const { contractAddress, functionArtifact, portalContract } = await this.#getSimulationParameters(txRequest);
|
|
454
459
|
|
|
455
460
|
this.log('Executing simulator...');
|
|
456
461
|
try {
|
|
457
|
-
const result = await this.simulator.run(txRequest,
|
|
462
|
+
const result = await this.simulator.run(txRequest, functionArtifact, contractAddress, portalContract);
|
|
458
463
|
this.log('Simulation completed!');
|
|
459
464
|
return result;
|
|
460
465
|
} catch (err) {
|
|
@@ -474,11 +479,11 @@ export class PXEService implements PXE {
|
|
|
474
479
|
* @returns The simulation result containing the outputs of the unconstrained function.
|
|
475
480
|
*/
|
|
476
481
|
async #simulateUnconstrained(execRequest: FunctionCall) {
|
|
477
|
-
const { contractAddress,
|
|
482
|
+
const { contractAddress, functionArtifact } = await this.#getSimulationParameters(execRequest);
|
|
478
483
|
|
|
479
484
|
this.log('Executing unconstrained simulator...');
|
|
480
485
|
try {
|
|
481
|
-
const result = await this.simulator.runUnconstrained(execRequest,
|
|
486
|
+
const result = await this.simulator.runUnconstrained(execRequest, functionArtifact, contractAddress, this.node);
|
|
482
487
|
this.log('Unconstrained simulation completed!');
|
|
483
488
|
|
|
484
489
|
return result;
|
|
@@ -590,9 +595,9 @@ export class PXEService implements PXE {
|
|
|
590
595
|
if (contract) {
|
|
591
596
|
err.enrichWithContractName(parsedContractAddress, contract.name);
|
|
592
597
|
selectors.forEach(selector => {
|
|
593
|
-
const
|
|
594
|
-
if (
|
|
595
|
-
err.enrichWithFunctionName(parsedContractAddress,
|
|
598
|
+
const functionArtifact = contract.functions.find(f => f.selector.toString() === selector);
|
|
599
|
+
if (functionArtifact) {
|
|
600
|
+
err.enrichWithFunctionName(parsedContractAddress, functionArtifact.selector, functionArtifact.name);
|
|
596
601
|
}
|
|
597
602
|
});
|
|
598
603
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DBOracle,
|
|
1
|
+
import { DBOracle, FunctionArtifactWithDebugMetadata, MessageLoadOracleInputs } from '@aztec/acir-simulator';
|
|
2
2
|
import {
|
|
3
3
|
AztecAddress,
|
|
4
4
|
CompleteAddress,
|
|
@@ -60,14 +60,14 @@ export class SimulatorOracle implements DBOracle {
|
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
async
|
|
63
|
+
async getFunctionArtifact(
|
|
64
64
|
contractAddress: AztecAddress,
|
|
65
65
|
selector: FunctionSelector,
|
|
66
|
-
): Promise<
|
|
67
|
-
const
|
|
66
|
+
): Promise<FunctionArtifactWithDebugMetadata> {
|
|
67
|
+
const artifact = await this.contractDataOracle.getFunctionArtifact(contractAddress, selector);
|
|
68
68
|
const debug = await this.contractDataOracle.getFunctionDebugMetadata(contractAddress, selector);
|
|
69
69
|
return {
|
|
70
|
-
...
|
|
70
|
+
...artifact,
|
|
71
71
|
debug,
|
|
72
72
|
};
|
|
73
73
|
}
|
|
@@ -3,6 +3,7 @@ import { computeGlobalsHash } from '@aztec/circuits.js/abis';
|
|
|
3
3
|
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { InterruptableSleep } from '@aztec/foundation/sleep';
|
|
5
5
|
import { AztecNode, INITIAL_L2_BLOCK_NUM, KeyStore, L2BlockContext, L2BlockL2Logs, LogType } from '@aztec/types';
|
|
6
|
+
import { NoteProcessorCaughtUpStats } from '@aztec/types/stats';
|
|
6
7
|
|
|
7
8
|
import { Database } from '../database/index.js';
|
|
8
9
|
import { NoteProcessor } from '../note_processor/index.js';
|
|
@@ -182,8 +183,9 @@ export class Synchronizer {
|
|
|
182
183
|
eventName: 'note-processor-caught-up',
|
|
183
184
|
publicKey: noteProcessor.publicKey.toString(),
|
|
184
185
|
duration: noteProcessor.timer.ms(),
|
|
186
|
+
dbSize: this.db.estimateSize(),
|
|
185
187
|
...noteProcessor.stats,
|
|
186
|
-
});
|
|
188
|
+
} satisfies NoteProcessorCaughtUpStats);
|
|
187
189
|
this.noteProcessorsToCatchUp.shift();
|
|
188
190
|
this.noteProcessors.push(noteProcessor);
|
|
189
191
|
}
|