@aztec/pxe 0.61.0 → 0.63.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/index.d.ts +2 -3
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +4 -5
- package/dest/contract_data_oracle/index.d.ts +1 -0
- package/dest/contract_data_oracle/index.d.ts.map +1 -1
- package/dest/contract_data_oracle/index.js +5 -1
- package/dest/database/incoming_note_dao.d.ts +4 -4
- package/dest/database/incoming_note_dao.d.ts.map +1 -1
- package/dest/database/incoming_note_dao.js +6 -6
- package/dest/database/kv_pxe_database.d.ts +10 -14
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +82 -94
- package/dest/database/outgoing_note_dao.d.ts +2 -2
- package/dest/database/outgoing_note_dao.d.ts.map +1 -1
- package/dest/database/outgoing_note_dao.js +2 -2
- package/dest/database/pxe_database.d.ts +42 -20
- package/dest/database/pxe_database.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.js +11 -11
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/kernel_oracle/index.d.ts +3 -3
- package/dest/kernel_oracle/index.d.ts.map +1 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +12 -4
- package/dest/kernel_prover/kernel_prover.d.ts +3 -1
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +39 -7
- package/dest/kernel_prover/test/test_circuit_prover.d.ts +1 -0
- package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/kernel_prover/test/test_circuit_prover.js +5 -1
- package/dest/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.d.ts +1 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +1 -0
- package/dest/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.js +1 -1
- package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -0
- package/dest/{note_processor/utils → note_decryption_utils}/brute_force_note_info.js +1 -1
- package/dest/note_decryption_utils/index.d.ts.map +1 -0
- package/dest/{note_processor/utils → note_decryption_utils}/index.js +1 -1
- package/dest/{note_processor/utils → note_decryption_utils}/produce_note_daos.d.ts +6 -9
- package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -0
- package/dest/note_decryption_utils/produce_note_daos.js +47 -0
- package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +8 -0
- package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -0
- package/dest/note_decryption_utils/produce_note_daos_for_key.js +17 -0
- package/dest/pxe_http/pxe_http_server.d.ts +1 -2
- package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
- package/dest/pxe_http/pxe_http_server.js +5 -49
- package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/create_pxe_service.js +7 -4
- package/dest/pxe_service/error_enriching.d.ts.map +1 -1
- package/dest/pxe_service/error_enriching.js +7 -6
- package/dest/pxe_service/pxe_service.d.ts +13 -19
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +79 -79
- package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
- package/dest/pxe_service/test/pxe_test_suite.js +5 -34
- package/dest/simulator_oracle/index.d.ts +32 -10
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +223 -30
- package/dest/synchronizer/synchronizer.d.ts +0 -48
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +3 -201
- package/package.json +16 -14
- package/src/config/index.ts +4 -7
- package/src/contract_data_oracle/index.ts +5 -0
- package/src/database/incoming_note_dao.ts +5 -5
- package/src/database/kv_pxe_database.ts +95 -106
- package/src/database/outgoing_note_dao.ts +3 -3
- package/src/database/pxe_database.ts +47 -22
- package/src/database/pxe_database_test_suite.ts +12 -20
- package/src/index.ts +1 -1
- package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +13 -3
- package/src/kernel_prover/kernel_prover.ts +49 -5
- package/src/kernel_prover/test/test_circuit_prover.ts +8 -4
- package/src/{note_processor/utils → note_decryption_utils}/add_public_values_to_payload.ts +1 -1
- package/src/{note_processor/utils → note_decryption_utils}/produce_note_daos.ts +12 -22
- package/src/{note_processor/utils → note_decryption_utils}/produce_note_daos_for_key.ts +6 -15
- package/src/pxe_http/pxe_http_server.ts +5 -81
- package/src/pxe_service/create_pxe_service.ts +9 -3
- package/src/pxe_service/error_enriching.ts +12 -5
- package/src/pxe_service/pxe_service.ts +102 -113
- package/src/pxe_service/test/pxe_test_suite.ts +7 -55
- package/src/simulator_oracle/index.ts +322 -23
- package/src/synchronizer/synchronizer.ts +3 -253
- package/dest/database/deferred_note_dao.d.ts +0 -40
- package/dest/database/deferred_note_dao.d.ts.map +0 -1
- package/dest/database/deferred_note_dao.js +0 -38
- package/dest/note_processor/index.d.ts +0 -2
- package/dest/note_processor/index.d.ts.map +0 -1
- package/dest/note_processor/index.js +0 -2
- package/dest/note_processor/note_processor.d.ts +0 -83
- package/dest/note_processor/note_processor.d.ts.map +0 -1
- package/dest/note_processor/note_processor.js +0 -230
- package/dest/note_processor/utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_processor/utils/brute_force_note_info.d.ts.map +0 -1
- package/dest/note_processor/utils/index.d.ts.map +0 -1
- package/dest/note_processor/utils/produce_note_daos.d.ts.map +0 -1
- package/dest/note_processor/utils/produce_note_daos.js +0 -51
- package/dest/note_processor/utils/produce_note_daos_for_key.d.ts +0 -9
- package/dest/note_processor/utils/produce_note_daos_for_key.d.ts.map +0 -1
- package/dest/note_processor/utils/produce_note_daos_for_key.js +0 -26
- package/src/database/deferred_note_dao.ts +0 -47
- package/src/note_processor/index.ts +0 -1
- package/src/note_processor/note_processor.ts +0 -355
- /package/dest/{note_processor/utils → note_decryption_utils}/brute_force_note_info.d.ts +0 -0
- /package/dest/{note_processor/utils → note_decryption_utils}/index.d.ts +0 -0
- /package/src/{note_processor/utils → note_decryption_utils}/brute_force_note_info.ts +0 -0
- /package/src/{note_processor/utils → note_decryption_utils}/index.ts +0 -0
|
@@ -23,7 +23,9 @@ import {
|
|
|
23
23
|
VK_TREE_HEIGHT,
|
|
24
24
|
VerificationKeyAsFields,
|
|
25
25
|
} from '@aztec/circuits.js';
|
|
26
|
+
import { hashVK } from '@aztec/circuits.js/hash';
|
|
26
27
|
import { makeTuple } from '@aztec/foundation/array';
|
|
28
|
+
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
27
29
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
28
30
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
29
31
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
@@ -45,6 +47,7 @@ const NULL_PROVE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicI
|
|
|
45
47
|
outputWitness: new Map(),
|
|
46
48
|
bytecode: Buffer.from([]),
|
|
47
49
|
};
|
|
50
|
+
|
|
48
51
|
/**
|
|
49
52
|
* The KernelProver class is responsible for generating kernel proofs.
|
|
50
53
|
* It takes a transaction request, its signature, and the simulation result as inputs, and outputs a proof
|
|
@@ -64,18 +67,30 @@ export class KernelProver {
|
|
|
64
67
|
*
|
|
65
68
|
* @param txRequest - The authenticated transaction request object.
|
|
66
69
|
* @param executionResult - The execution result object containing nested executions and preimages.
|
|
70
|
+
* @param profile - Set true to profile the gate count for each circuit
|
|
71
|
+
* @param dryRun - Set true to skip the IVC proof generation (only simulation is run). Useful for profiling gate count without proof gen.
|
|
67
72
|
* @returns A Promise that resolves to a KernelProverOutput object containing proof, public inputs, and output notes.
|
|
68
73
|
* TODO(#7368) this should be refactored to not recreate the ACIR bytecode now that it operates on a program stack
|
|
69
74
|
*/
|
|
70
75
|
async prove(
|
|
71
76
|
txRequest: TxRequest,
|
|
72
77
|
executionResult: PrivateExecutionResult,
|
|
78
|
+
profile: boolean = false,
|
|
79
|
+
dryRun: boolean = false,
|
|
73
80
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
74
81
|
const executionStack = [executionResult];
|
|
75
82
|
let firstIteration = true;
|
|
76
83
|
|
|
77
84
|
let output = NULL_PROVE_OUTPUT;
|
|
78
85
|
|
|
86
|
+
const gateCounts: { circuitName: string; gateCount: number }[] = [];
|
|
87
|
+
const addGateCount = async (circuitName: string, bytecode: Buffer) => {
|
|
88
|
+
const gateCount = (await this.proofCreator.computeGateCountForCircuit(bytecode, circuitName)) as number;
|
|
89
|
+
gateCounts.push({ circuitName, gateCount });
|
|
90
|
+
|
|
91
|
+
this.log.info(`Tx ${txRequest.hash()}: bb gates for ${circuitName} - ${gateCount}`);
|
|
92
|
+
};
|
|
93
|
+
|
|
79
94
|
const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
|
|
80
95
|
const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
|
|
81
96
|
const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(executionResult);
|
|
@@ -100,6 +115,9 @@ export class KernelProver {
|
|
|
100
115
|
// TODO(#7368) consider refactoring this redundant bytecode pushing
|
|
101
116
|
acirs.push(output.bytecode);
|
|
102
117
|
witnessStack.push(output.outputWitness);
|
|
118
|
+
if (profile) {
|
|
119
|
+
await addGateCount('private_kernel_reset', output.bytecode);
|
|
120
|
+
}
|
|
103
121
|
|
|
104
122
|
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
|
|
105
123
|
output,
|
|
@@ -111,6 +129,7 @@ export class KernelProver {
|
|
|
111
129
|
}
|
|
112
130
|
|
|
113
131
|
const currentExecution = executionStack.pop()!;
|
|
132
|
+
|
|
114
133
|
executionStack.push(...[...currentExecution.nestedExecutions].reverse());
|
|
115
134
|
|
|
116
135
|
const functionName = await this.oracle.getDebugFunctionName(
|
|
@@ -118,13 +137,15 @@ export class KernelProver {
|
|
|
118
137
|
currentExecution.publicInputs.callContext.functionSelector,
|
|
119
138
|
);
|
|
120
139
|
|
|
121
|
-
const appVk = await this.proofCreator.computeAppCircuitVerificationKey(currentExecution.acir, functionName);
|
|
122
140
|
// TODO(#7368): This used to be associated with getDebugFunctionName
|
|
123
141
|
// TODO(#7368): Is there any way to use this with client IVC proving?
|
|
124
142
|
acirs.push(currentExecution.acir);
|
|
125
143
|
witnessStack.push(currentExecution.partialWitness);
|
|
144
|
+
if (profile) {
|
|
145
|
+
await addGateCount(functionName as string, currentExecution.acir);
|
|
146
|
+
}
|
|
126
147
|
|
|
127
|
-
const privateCallData = await this.createPrivateCallData(currentExecution
|
|
148
|
+
const privateCallData = await this.createPrivateCallData(currentExecution);
|
|
128
149
|
|
|
129
150
|
if (firstIteration) {
|
|
130
151
|
const proofInput = new PrivateKernelInitCircuitPrivateInputs(
|
|
@@ -135,8 +156,12 @@ export class KernelProver {
|
|
|
135
156
|
);
|
|
136
157
|
pushTestData('private-kernel-inputs-init', proofInput);
|
|
137
158
|
output = await this.proofCreator.simulateProofInit(proofInput);
|
|
159
|
+
|
|
138
160
|
acirs.push(output.bytecode);
|
|
139
161
|
witnessStack.push(output.outputWitness);
|
|
162
|
+
if (profile) {
|
|
163
|
+
await addGateCount('private_kernel_init', output.bytecode);
|
|
164
|
+
}
|
|
140
165
|
} else {
|
|
141
166
|
const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey);
|
|
142
167
|
const previousKernelData = new PrivateKernelData(
|
|
@@ -148,8 +173,12 @@ export class KernelProver {
|
|
|
148
173
|
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
149
174
|
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
150
175
|
output = await this.proofCreator.simulateProofInner(proofInput);
|
|
176
|
+
|
|
151
177
|
acirs.push(output.bytecode);
|
|
152
178
|
witnessStack.push(output.outputWitness);
|
|
179
|
+
if (profile) {
|
|
180
|
+
await addGateCount('private_kernel_inner', output.bytecode);
|
|
181
|
+
}
|
|
153
182
|
}
|
|
154
183
|
firstIteration = false;
|
|
155
184
|
}
|
|
@@ -164,8 +193,12 @@ export class KernelProver {
|
|
|
164
193
|
while (resetBuilder.needsReset()) {
|
|
165
194
|
const privateInputs = await resetBuilder.build(this.oracle, noteHashLeafIndexMap);
|
|
166
195
|
output = await this.proofCreator.simulateProofReset(privateInputs);
|
|
196
|
+
|
|
167
197
|
acirs.push(output.bytecode);
|
|
168
198
|
witnessStack.push(output.outputWitness);
|
|
199
|
+
if (profile) {
|
|
200
|
+
await addGateCount('private_kernel_reset', output.bytecode);
|
|
201
|
+
}
|
|
169
202
|
|
|
170
203
|
resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
|
|
171
204
|
output,
|
|
@@ -192,18 +225,29 @@ export class KernelProver {
|
|
|
192
225
|
|
|
193
226
|
pushTestData('private-kernel-inputs-ordering', privateInputs);
|
|
194
227
|
const tailOutput = await this.proofCreator.simulateProofTail(privateInputs);
|
|
228
|
+
|
|
195
229
|
acirs.push(tailOutput.bytecode);
|
|
196
230
|
witnessStack.push(tailOutput.outputWitness);
|
|
231
|
+
if (profile) {
|
|
232
|
+
await addGateCount('private_kernel_tail', tailOutput.bytecode);
|
|
233
|
+
tailOutput.profileResult = { gateCounts };
|
|
234
|
+
}
|
|
197
235
|
|
|
198
236
|
// TODO(#7368) how do we 'bincode' encode these inputs?
|
|
199
|
-
|
|
200
|
-
|
|
237
|
+
if (!dryRun) {
|
|
238
|
+
const ivcProof = await this.proofCreator.createClientIvcProof(acirs, witnessStack);
|
|
239
|
+
tailOutput.clientIvcProof = ivcProof;
|
|
240
|
+
}
|
|
241
|
+
|
|
201
242
|
return tailOutput;
|
|
202
243
|
}
|
|
203
244
|
|
|
204
|
-
private async createPrivateCallData({ publicInputs
|
|
245
|
+
private async createPrivateCallData({ publicInputs, vk: vkAsBuffer }: PrivateExecutionResult) {
|
|
205
246
|
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
206
247
|
|
|
248
|
+
const vkAsFields = vkAsFieldsMegaHonk(vkAsBuffer);
|
|
249
|
+
const vk = new VerificationKeyAsFields(vkAsFields, hashVK(vkAsFields));
|
|
250
|
+
|
|
207
251
|
const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(
|
|
208
252
|
contractAddress,
|
|
209
253
|
functionSelector,
|
|
@@ -107,6 +107,11 @@ export class TestPrivateKernelProver implements PrivateKernelProver {
|
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
public computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
111
|
+
// No gates in test prover
|
|
112
|
+
return Promise.resolve(0);
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
computeAppCircuitVerificationKey(
|
|
111
116
|
_bytecode: Buffer,
|
|
112
117
|
_appCircuitName?: string | undefined,
|
|
@@ -117,10 +122,9 @@ export class TestPrivateKernelProver implements PrivateKernelProver {
|
|
|
117
122
|
return Promise.resolve(appCircuitProofOutput);
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
private makeEmptyKernelSimulateOutput<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
) {
|
|
125
|
+
private makeEmptyKernelSimulateOutput<
|
|
126
|
+
PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs,
|
|
127
|
+
>(publicInputs: PublicInputsType, circuitType: ProtocolArtifact) {
|
|
124
128
|
const kernelProofOutput: PrivateKernelSimulateOutput<PublicInputsType> = {
|
|
125
129
|
publicInputs,
|
|
126
130
|
verificationKey: ProtocolCircuitVks[circuitType].keyAsFields,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type L1NotePayload, Note } from '@aztec/circuit-types';
|
|
2
2
|
import { ContractNotFoundError } from '@aztec/simulator';
|
|
3
3
|
|
|
4
|
-
import { type PxeDatabase } from '
|
|
4
|
+
import { type PxeDatabase } from '../database/pxe_database.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Merges privately and publicly delivered note values.
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type L1NotePayload, type PublicKey, type TxHash
|
|
1
|
+
import { type L1NotePayload, type PublicKey, type TxHash } from '@aztec/circuit-types';
|
|
2
2
|
import { type Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { type AcirSimulator } from '@aztec/simulator';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { type PxeDatabase } from '../../database/pxe_database.js';
|
|
6
|
+
import { IncomingNoteDao } from '../database/incoming_note_dao.js';
|
|
7
|
+
import { OutgoingNoteDao } from '../database/outgoing_note_dao.js';
|
|
8
|
+
import { type PxeDatabase } from '../database/pxe_database.js';
|
|
10
9
|
import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
|
|
11
10
|
|
|
12
11
|
/**
|
|
@@ -17,7 +16,7 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
|
|
|
17
16
|
*
|
|
18
17
|
* @param simulator - An instance of AcirSimulator.
|
|
19
18
|
* @param db - An instance of PxeDatabase.
|
|
20
|
-
* @param
|
|
19
|
+
* @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
|
|
21
20
|
* @param ovpkM - The public counterpart to the secret key to be used in the decryption of outgoing note logs.
|
|
22
21
|
* @param payload - An instance of l1NotePayload.
|
|
23
22
|
* @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
|
|
@@ -31,7 +30,7 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
|
|
|
31
30
|
export async function produceNoteDaos(
|
|
32
31
|
simulator: AcirSimulator,
|
|
33
32
|
db: PxeDatabase,
|
|
34
|
-
|
|
33
|
+
addressPoint: PublicKey | undefined,
|
|
35
34
|
ovpkM: PublicKey | undefined,
|
|
36
35
|
payload: L1NotePayload,
|
|
37
36
|
txHash: TxHash,
|
|
@@ -39,34 +38,28 @@ export async function produceNoteDaos(
|
|
|
39
38
|
dataStartIndexForTx: number,
|
|
40
39
|
excludedIndices: Set<number>,
|
|
41
40
|
logger: Logger,
|
|
42
|
-
unencryptedLogs: UnencryptedTxL2Logs,
|
|
43
41
|
): Promise<{
|
|
44
42
|
incomingNote: IncomingNoteDao | undefined;
|
|
45
43
|
outgoingNote: OutgoingNoteDao | undefined;
|
|
46
|
-
incomingDeferredNote: DeferredNoteDao | undefined;
|
|
47
|
-
outgoingDeferredNote: DeferredNoteDao | undefined;
|
|
48
44
|
}> {
|
|
49
|
-
if (!
|
|
50
|
-
throw new Error('Both
|
|
45
|
+
if (!addressPoint && !ovpkM) {
|
|
46
|
+
throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.');
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
let incomingNote: IncomingNoteDao | undefined;
|
|
54
50
|
let outgoingNote: OutgoingNoteDao | undefined;
|
|
55
|
-
let incomingDeferredNote: DeferredNoteDao | undefined;
|
|
56
|
-
let outgoingDeferredNote: DeferredNoteDao | undefined;
|
|
57
51
|
|
|
58
|
-
if (
|
|
59
|
-
|
|
52
|
+
if (addressPoint) {
|
|
53
|
+
incomingNote = await produceNoteDaosForKey(
|
|
60
54
|
simulator,
|
|
61
55
|
db,
|
|
62
|
-
|
|
56
|
+
addressPoint,
|
|
63
57
|
payload,
|
|
64
58
|
txHash,
|
|
65
59
|
noteHashes,
|
|
66
60
|
dataStartIndexForTx,
|
|
67
61
|
excludedIndices,
|
|
68
62
|
logger,
|
|
69
|
-
unencryptedLogs,
|
|
70
63
|
IncomingNoteDao.fromPayloadAndNoteInfo,
|
|
71
64
|
);
|
|
72
65
|
}
|
|
@@ -87,7 +80,7 @@ export async function produceNoteDaos(
|
|
|
87
80
|
ovpkM,
|
|
88
81
|
);
|
|
89
82
|
} else {
|
|
90
|
-
|
|
83
|
+
outgoingNote = await produceNoteDaosForKey(
|
|
91
84
|
simulator,
|
|
92
85
|
db,
|
|
93
86
|
ovpkM,
|
|
@@ -97,7 +90,6 @@ export async function produceNoteDaos(
|
|
|
97
90
|
dataStartIndexForTx,
|
|
98
91
|
excludedIndices,
|
|
99
92
|
logger,
|
|
100
|
-
unencryptedLogs,
|
|
101
93
|
OutgoingNoteDao.fromPayloadAndNoteInfo,
|
|
102
94
|
);
|
|
103
95
|
}
|
|
@@ -106,7 +98,5 @@ export async function produceNoteDaos(
|
|
|
106
98
|
return {
|
|
107
99
|
incomingNote,
|
|
108
100
|
outgoingNote,
|
|
109
|
-
incomingDeferredNote,
|
|
110
|
-
outgoingDeferredNote,
|
|
111
101
|
};
|
|
112
102
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { type L1NotePayload, type Note, type TxHash
|
|
1
|
+
import { type L1NotePayload, type Note, type TxHash } from '@aztec/circuit-types';
|
|
2
2
|
import { type Fr, type PublicKey } from '@aztec/circuits.js';
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
|
-
import { type AcirSimulator
|
|
4
|
+
import { type AcirSimulator } from '@aztec/simulator';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { type PxeDatabase } from '../../database/pxe_database.js';
|
|
6
|
+
import { type PxeDatabase } from '../database/pxe_database.js';
|
|
8
7
|
import { getOrderedNoteItems } from './add_public_values_to_payload.js';
|
|
9
8
|
import { type NoteInfo, bruteForceNoteInfo } from './brute_force_note_info.js';
|
|
10
9
|
|
|
@@ -18,7 +17,6 @@ export async function produceNoteDaosForKey<T>(
|
|
|
18
17
|
dataStartIndexForTx: number,
|
|
19
18
|
excludedIndices: Set<number>,
|
|
20
19
|
logger: Logger,
|
|
21
|
-
unencryptedLogs: UnencryptedTxL2Logs,
|
|
22
20
|
daoConstructor: (
|
|
23
21
|
note: Note,
|
|
24
22
|
payload: L1NotePayload,
|
|
@@ -26,9 +24,8 @@ export async function produceNoteDaosForKey<T>(
|
|
|
26
24
|
dataStartIndexForTx: number,
|
|
27
25
|
pkM: PublicKey,
|
|
28
26
|
) => T,
|
|
29
|
-
): Promise<
|
|
27
|
+
): Promise<T | undefined> {
|
|
30
28
|
let noteDao: T | undefined;
|
|
31
|
-
let deferredNoteDao: DeferredNoteDao | undefined;
|
|
32
29
|
|
|
33
30
|
try {
|
|
34
31
|
// We get the note by merging publicly and privately delivered note values.
|
|
@@ -49,14 +46,8 @@ export async function produceNoteDaosForKey<T>(
|
|
|
49
46
|
|
|
50
47
|
noteDao = daoConstructor(note, payload, noteInfo, dataStartIndexForTx, pkM);
|
|
51
48
|
} catch (e) {
|
|
52
|
-
|
|
53
|
-
logger.warn(e.message);
|
|
54
|
-
|
|
55
|
-
deferredNoteDao = new DeferredNoteDao(pkM, payload, txHash, noteHashes, dataStartIndexForTx, unencryptedLogs);
|
|
56
|
-
} else {
|
|
57
|
-
logger.error(`Could not process note because of "${e}". Discarding note...`);
|
|
58
|
-
}
|
|
49
|
+
logger.error(`Could not process note because of "${e}". Discarding note...`);
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
return
|
|
52
|
+
return noteDao;
|
|
62
53
|
}
|
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
CompleteAddress,
|
|
4
|
-
CountedNoteLog,
|
|
5
|
-
CountedPublicExecutionRequest,
|
|
6
|
-
EncryptedL2Log,
|
|
7
|
-
EncryptedL2NoteLog,
|
|
8
|
-
EncryptedNoteL2BlockL2Logs,
|
|
9
|
-
ExtendedNote,
|
|
10
|
-
ExtendedUnencryptedL2Log,
|
|
11
|
-
L2Block,
|
|
12
|
-
LogId,
|
|
13
|
-
Note,
|
|
14
|
-
NullifierMembershipWitness,
|
|
15
|
-
type PXE,
|
|
16
|
-
PrivateExecutionResult,
|
|
17
|
-
SiblingPath,
|
|
18
|
-
Tx,
|
|
19
|
-
TxEffect,
|
|
20
|
-
TxExecutionRequest,
|
|
21
|
-
TxHash,
|
|
22
|
-
TxProvingResult,
|
|
23
|
-
TxReceipt,
|
|
24
|
-
TxSimulationResult,
|
|
25
|
-
UnencryptedL2BlockL2Logs,
|
|
26
|
-
UnencryptedL2Log,
|
|
27
|
-
UniqueNote,
|
|
28
|
-
} from '@aztec/circuit-types';
|
|
29
|
-
import { FunctionSelector, PrivateCircuitPublicInputs, PublicKeys } from '@aztec/circuits.js';
|
|
30
|
-
import { NoteSelector } from '@aztec/foundation/abi';
|
|
31
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
32
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
33
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
34
|
-
import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
35
|
-
import { JsonRpcServer, createNamespacedJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
1
|
+
import { type PXE, PXESchema } from '@aztec/circuit-types';
|
|
2
|
+
import { createNamespacedSafeJsonRpcServer, createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
36
3
|
|
|
37
4
|
import http from 'http';
|
|
38
5
|
|
|
@@ -40,50 +7,8 @@ import http from 'http';
|
|
|
40
7
|
* Wraps an instance of Private eXecution Environment (PXE) implementation to a JSON RPC HTTP interface.
|
|
41
8
|
* @returns A new instance of the HTTP server.
|
|
42
9
|
*/
|
|
43
|
-
export function createPXERpcServer(pxeService: PXE)
|
|
44
|
-
return
|
|
45
|
-
pxeService,
|
|
46
|
-
{
|
|
47
|
-
CompleteAddress,
|
|
48
|
-
AztecAddress,
|
|
49
|
-
TxExecutionRequest,
|
|
50
|
-
ExtendedUnencryptedL2Log,
|
|
51
|
-
FunctionSelector,
|
|
52
|
-
TxHash,
|
|
53
|
-
Buffer32,
|
|
54
|
-
EthAddress,
|
|
55
|
-
Point,
|
|
56
|
-
Fr,
|
|
57
|
-
GrumpkinScalar,
|
|
58
|
-
Note,
|
|
59
|
-
ExtendedNote,
|
|
60
|
-
PublicKeys,
|
|
61
|
-
UniqueNote,
|
|
62
|
-
SiblingPath,
|
|
63
|
-
AuthWitness,
|
|
64
|
-
L2Block,
|
|
65
|
-
TxEffect,
|
|
66
|
-
LogId,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
EncryptedNoteL2BlockL2Logs,
|
|
70
|
-
EncryptedL2NoteLog,
|
|
71
|
-
EncryptedL2Log,
|
|
72
|
-
UnencryptedL2Log,
|
|
73
|
-
NoteSelector,
|
|
74
|
-
NullifierMembershipWitness,
|
|
75
|
-
TxSimulationResult,
|
|
76
|
-
TxProvingResult,
|
|
77
|
-
PrivateCircuitPublicInputs,
|
|
78
|
-
PrivateExecutionResult,
|
|
79
|
-
CountedPublicExecutionRequest,
|
|
80
|
-
CountedNoteLog,
|
|
81
|
-
Tx,
|
|
82
|
-
TxReceipt,
|
|
83
|
-
UnencryptedL2BlockL2Logs,
|
|
84
|
-
},
|
|
85
|
-
['start', 'stop'],
|
|
86
|
-
);
|
|
10
|
+
export function createPXERpcServer(pxeService: PXE) {
|
|
11
|
+
return createSafeJsonRpcServer(pxeService, PXESchema);
|
|
87
12
|
}
|
|
88
13
|
|
|
89
14
|
/**
|
|
@@ -93,8 +18,7 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
|
|
|
93
18
|
* @returns A running http server.
|
|
94
19
|
*/
|
|
95
20
|
export function startPXEHttpServer(pxeService: PXE, port: string | number): http.Server {
|
|
96
|
-
const
|
|
97
|
-
const rpcServer = createNamespacedJsonRpcServer([{ pxe: pxeServer }]);
|
|
21
|
+
const rpcServer = createNamespacedSafeJsonRpcServer({ pxe: [pxeService, PXESchema] });
|
|
98
22
|
|
|
99
23
|
const app = rpcServer.getApp();
|
|
100
24
|
const httpServer = http.createServer(app.callback());
|
|
@@ -31,11 +31,17 @@ export async function createPXEService(
|
|
|
31
31
|
typeof useLogSuffix === 'boolean' ? (useLogSuffix ? randomBytes(3).toString('hex') : undefined) : useLogSuffix;
|
|
32
32
|
|
|
33
33
|
const l1Contracts = await aztecNode.getL1ContractAddresses();
|
|
34
|
-
const
|
|
34
|
+
const configWithContracts = {
|
|
35
|
+
...config,
|
|
36
|
+
l1Contracts,
|
|
37
|
+
} as PXEServiceConfig;
|
|
38
|
+
|
|
35
39
|
const keyStore = new KeyStore(
|
|
36
|
-
await createStore('pxe_key_store',
|
|
40
|
+
await createStore('pxe_key_store', configWithContracts, createDebugLogger('aztec:pxe:keystore:lmdb')),
|
|
41
|
+
);
|
|
42
|
+
const db = new KVPxeDatabase(
|
|
43
|
+
await createStore('pxe_data', configWithContracts, createDebugLogger('aztec:pxe:data:lmdb')),
|
|
37
44
|
);
|
|
38
|
-
const db = new KVPxeDatabase(await createStore('pxe_data', storeConfig, createDebugLogger('aztec:pxe:data:lmdb')));
|
|
39
45
|
|
|
40
46
|
const prover = proofCreator ?? (await createProver(config, logSuffix));
|
|
41
47
|
const server = new PXEService(keyStore, aztecNode, db, prover, config, logSuffix);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SimulationError, isNoirCallStackUnresolved } from '@aztec/circuit-types';
|
|
2
2
|
import { AztecAddress, Fr, FunctionSelector, PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js';
|
|
3
3
|
import { type DebugLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@aztec/simulator';
|
|
5
5
|
|
|
6
6
|
import { type ContractDataOracle, type PxeDatabase } from '../index.js';
|
|
7
7
|
|
|
@@ -64,17 +64,24 @@ export async function enrichPublicSimulationError(
|
|
|
64
64
|
// To be able to resolve the assertion message, we need to use the information from the public dispatch function,
|
|
65
65
|
// no matter what the call stack selector points to (since we've modified it to point to the target function).
|
|
66
66
|
// We should remove this because the AVM (or public protocol) shouldn't be aware of the public dispatch calling convention.
|
|
67
|
+
|
|
68
|
+
const artifact = await contractDataOracle.getFunctionArtifact(
|
|
69
|
+
originalFailingFunction.contractAddress,
|
|
70
|
+
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
71
|
+
);
|
|
72
|
+
const assertionMessage = resolveAssertionMessageFromRevertData(err.revertData, artifact);
|
|
73
|
+
if (assertionMessage) {
|
|
74
|
+
err.setOriginalMessage(err.getOriginalMessage() + `${assertionMessage}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
67
77
|
const debugInfo = await contractDataOracle.getFunctionDebugMetadata(
|
|
68
78
|
originalFailingFunction.contractAddress,
|
|
69
79
|
FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
|
|
70
80
|
);
|
|
81
|
+
|
|
71
82
|
const noirCallStack = err.getNoirCallStack();
|
|
72
83
|
if (debugInfo) {
|
|
73
84
|
if (isNoirCallStackUnresolved(noirCallStack)) {
|
|
74
|
-
const assertionMessage = resolveAssertionMessage(noirCallStack, debugInfo);
|
|
75
|
-
if (assertionMessage) {
|
|
76
|
-
err.setOriginalMessage(err.getOriginalMessage() + `: ${assertionMessage}`);
|
|
77
|
-
}
|
|
78
85
|
try {
|
|
79
86
|
// Public functions are simulated as a single Brillig entry point.
|
|
80
87
|
// Thus, we can safely assume here that the Brillig function id is `0`.
|