@aztec/pxe 0.62.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 +1 -1
- package/dest/database/incoming_note_dao.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.d.ts +5 -12
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +31 -62
- package/dest/database/outgoing_note_dao.d.ts +1 -1
- package/dest/database/outgoing_note_dao.d.ts.map +1 -1
- package/dest/database/pxe_database.d.ts +17 -25
- package/dest/database/pxe_database.d.ts.map +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 +5 -8
- 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 -51
- 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 +11 -25
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +45 -48
- package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
- package/dest/pxe_service/test/pxe_test_suite.js +4 -3
- package/dest/simulator_oracle/index.d.ts +15 -16
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +195 -65
- 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 +14 -14
- package/src/config/index.ts +4 -7
- package/src/contract_data_oracle/index.ts +5 -0
- package/src/database/incoming_note_dao.ts +1 -1
- package/src/database/kv_pxe_database.ts +33 -70
- package/src/database/outgoing_note_dao.ts +1 -1
- package/src/database/pxe_database.ts +19 -28
- 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 +6 -16
- 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 -84
- 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 +61 -78
- package/src/pxe_service/test/pxe_test_suite.ts +6 -2
- package/src/simulator_oracle/index.ts +280 -60
- 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 -231
- 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 -358
- /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
|
@@ -424,7 +424,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
424
424
|
throw new Error('`needsResetTransientData` must be run before `needsSiloNoteHashes`.');
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
const numNoteHashes = this.previousKernel.end.noteHashes.filter(n => !n.contractAddress.
|
|
427
|
+
const numNoteHashes = this.previousKernel.end.noteHashes.filter(n => !n.contractAddress.isZero()).length;
|
|
428
428
|
const numToSilo = Math.max(0, numNoteHashes - this.numTransientData);
|
|
429
429
|
this.requestedDimensions.NOTE_HASH_SILOING_AMOUNT = numToSilo;
|
|
430
430
|
|
|
@@ -436,7 +436,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
436
436
|
throw new Error('`needsResetTransientData` must be run before `needsSiloNullifiers`.');
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
const numNullifiers = this.previousKernel.end.nullifiers.filter(n => !n.contractAddress.
|
|
439
|
+
const numNullifiers = this.previousKernel.end.nullifiers.filter(n => !n.contractAddress.isZero()).length;
|
|
440
440
|
const numToSilo = Math.max(0, numNullifiers - this.numTransientData);
|
|
441
441
|
// Include the first nullifier if there's something to silo.
|
|
442
442
|
// The reset circuit checks that capped_size must be greater than or equal to all non-empty nullifiers.
|
|
@@ -454,7 +454,17 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
454
454
|
|
|
455
455
|
const numLogs = this.previousKernel.end.encryptedLogsHashes.filter(l => !l.logHash.randomness.isZero()).length;
|
|
456
456
|
const numToSilo = Math.max(0, numLogs - this.numTransientData);
|
|
457
|
-
|
|
457
|
+
// The reset circuit checks that capped_size must be greater than or equal to all non-empty logs.
|
|
458
|
+
// Since there is no current config with ENCRYPTED_LOG_SILOING_AMOUNT = 0 (only 1+), it defaults to 1,
|
|
459
|
+
// so the circuit fails when we have more than 1 log and require no siloing.
|
|
460
|
+
const numLogsNoSiloing = this.previousKernel.end.encryptedLogsHashes.filter(
|
|
461
|
+
l => !l.logHash.isEmpty() && l.logHash.randomness.isZero(),
|
|
462
|
+
).length;
|
|
463
|
+
const cappedSize = !numToSilo && numLogsNoSiloing > 1 ? numLogsNoSiloing : numToSilo;
|
|
464
|
+
// NB: This is a little flimsy, and only works because we have either ENCRYPTED_LOG_SILOING_AMOUNT=1 or 8.
|
|
465
|
+
// e.g. if we have 2 logs that need siloing, and 2 that dont, then numLogs = ENCRYPTED_LOG_SILOING_AMOUNT = 2
|
|
466
|
+
// This would fail because the circuit thinks that cappedSize = 2, but we have 4 logs.
|
|
467
|
+
this.requestedDimensions.ENCRYPTED_LOG_SILOING_AMOUNT = cappedSize;
|
|
458
468
|
|
|
459
469
|
return numToSilo > 0;
|
|
460
470
|
}
|
|
@@ -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
|
/**
|
|
@@ -39,12 +38,9 @@ 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
45
|
if (!addressPoint && !ovpkM) {
|
|
50
46
|
throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.');
|
|
@@ -52,11 +48,9 @@ export async function produceNoteDaos(
|
|
|
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
52
|
if (addressPoint) {
|
|
59
|
-
|
|
53
|
+
incomingNote = await produceNoteDaosForKey(
|
|
60
54
|
simulator,
|
|
61
55
|
db,
|
|
62
56
|
addressPoint,
|
|
@@ -66,7 +60,6 @@ export async function produceNoteDaos(
|
|
|
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,39 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
CompleteAddress,
|
|
4
|
-
CountedNoteLog,
|
|
5
|
-
CountedPublicExecutionRequest,
|
|
6
|
-
EncryptedL2Log,
|
|
7
|
-
EncryptedL2NoteLog,
|
|
8
|
-
EncryptedNoteL2BlockL2Logs,
|
|
9
|
-
EventMetadata,
|
|
10
|
-
ExtendedNote,
|
|
11
|
-
ExtendedUnencryptedL2Log,
|
|
12
|
-
L2Block,
|
|
13
|
-
LogId,
|
|
14
|
-
Note,
|
|
15
|
-
NullifierMembershipWitness,
|
|
16
|
-
type PXE,
|
|
17
|
-
PrivateExecutionResult,
|
|
18
|
-
SiblingPath,
|
|
19
|
-
Tx,
|
|
20
|
-
TxEffect,
|
|
21
|
-
TxExecutionRequest,
|
|
22
|
-
TxHash,
|
|
23
|
-
TxProvingResult,
|
|
24
|
-
TxReceipt,
|
|
25
|
-
TxSimulationResult,
|
|
26
|
-
UnencryptedL2BlockL2Logs,
|
|
27
|
-
UnencryptedL2Log,
|
|
28
|
-
UniqueNote,
|
|
29
|
-
} from '@aztec/circuit-types';
|
|
30
|
-
import { FunctionSelector, PrivateCircuitPublicInputs, PublicKeys } from '@aztec/circuits.js';
|
|
31
|
-
import { EventSelector, NoteSelector } from '@aztec/foundation/abi';
|
|
32
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
33
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
34
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
35
|
-
import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
|
|
36
|
-
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';
|
|
37
3
|
|
|
38
4
|
import http from 'http';
|
|
39
5
|
|
|
@@ -41,52 +7,8 @@ import http from 'http';
|
|
|
41
7
|
* Wraps an instance of Private eXecution Environment (PXE) implementation to a JSON RPC HTTP interface.
|
|
42
8
|
* @returns A new instance of the HTTP server.
|
|
43
9
|
*/
|
|
44
|
-
export function createPXERpcServer(pxeService: PXE)
|
|
45
|
-
return
|
|
46
|
-
pxeService,
|
|
47
|
-
{
|
|
48
|
-
AuthWitness,
|
|
49
|
-
AztecAddress,
|
|
50
|
-
Buffer32,
|
|
51
|
-
CompleteAddress,
|
|
52
|
-
EthAddress,
|
|
53
|
-
EventSelector,
|
|
54
|
-
ExtendedNote,
|
|
55
|
-
ExtendedUnencryptedL2Log,
|
|
56
|
-
Fr,
|
|
57
|
-
FunctionSelector,
|
|
58
|
-
GrumpkinScalar,
|
|
59
|
-
L2Block,
|
|
60
|
-
LogId,
|
|
61
|
-
Note,
|
|
62
|
-
Point,
|
|
63
|
-
PublicKeys,
|
|
64
|
-
SiblingPath,
|
|
65
|
-
TxEffect,
|
|
66
|
-
TxExecutionRequest,
|
|
67
|
-
TxHash,
|
|
68
|
-
UniqueNote,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
CountedPublicExecutionRequest,
|
|
72
|
-
CountedNoteLog,
|
|
73
|
-
EncryptedL2Log,
|
|
74
|
-
EncryptedL2NoteLog,
|
|
75
|
-
EncryptedNoteL2BlockL2Logs,
|
|
76
|
-
EventMetadata,
|
|
77
|
-
NoteSelector,
|
|
78
|
-
NullifierMembershipWitness,
|
|
79
|
-
PrivateCircuitPublicInputs,
|
|
80
|
-
PrivateExecutionResult,
|
|
81
|
-
TxSimulationResult,
|
|
82
|
-
TxProvingResult,
|
|
83
|
-
Tx,
|
|
84
|
-
TxReceipt,
|
|
85
|
-
UnencryptedL2BlockL2Logs,
|
|
86
|
-
UnencryptedL2Log,
|
|
87
|
-
},
|
|
88
|
-
['start', 'stop'],
|
|
89
|
-
);
|
|
10
|
+
export function createPXERpcServer(pxeService: PXE) {
|
|
11
|
+
return createSafeJsonRpcServer(pxeService, PXESchema);
|
|
90
12
|
}
|
|
91
13
|
|
|
92
14
|
/**
|
|
@@ -96,8 +18,7 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
|
|
|
96
18
|
* @returns A running http server.
|
|
97
19
|
*/
|
|
98
20
|
export function startPXEHttpServer(pxeService: PXE, port: string | number): http.Server {
|
|
99
|
-
const
|
|
100
|
-
const rpcServer = createNamespacedJsonRpcServer([{ pxe: pxeServer }]);
|
|
21
|
+
const rpcServer = createNamespacedSafeJsonRpcServer({ pxe: [pxeService, PXESchema] });
|
|
101
22
|
|
|
102
23
|
const app = rpcServer.getApp();
|
|
103
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`.
|