@aztec/pxe 0.0.1-commit.3100065 → 0.0.1-commit.330febf
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/bin/check_oracle_version.js +5 -46
- package/dest/bin/index.d.ts +2 -2
- package/dest/bin/index.d.ts.map +1 -1
- package/dest/bin/index.js +1 -1
- package/dest/bin/oracle_version_helpers.d.ts +8 -39
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
- package/dest/bin/oracle_version_helpers.js +10 -239
- package/dest/block_synchronizer/block_synchronizer.d.ts +3 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +5 -18
- package/dest/config/package_info.js +1 -1
- package/dest/contract/contract_class_service.d.ts +1 -8
- package/dest/contract/contract_class_service.d.ts.map +1 -1
- package/dest/contract/contract_class_service.js +8 -40
- package/dest/contract/helpers.d.ts +1 -1
- package/dest/contract/helpers.d.ts.map +1 -1
- package/dest/contract/helpers.js +3 -3
- package/dest/contract/skip_sync_contracts.d.ts +11 -0
- package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
- package/dest/contract/skip_sync_contracts.js +18 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -8
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +5 -20
- package/dest/contract_function_simulator/index.d.ts +3 -3
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -2
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +7 -9
- package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/resolved_tx.js +3 -44
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +5 -4
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +4 -3
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +15 -6
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +87 -35
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +297 -287
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +11 -8
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +15 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +168 -53
- package/dest/entrypoints/client/bundle/index.d.ts +2 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +1 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +10 -4
- package/dest/entrypoints/client/lazy/index.d.ts +2 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +1 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +10 -4
- package/dest/entrypoints/client/store.d.ts +14 -0
- package/dest/entrypoints/client/store.d.ts.map +1 -0
- package/dest/entrypoints/client/store.js +42 -0
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/store.d.ts +18 -0
- package/dest/entrypoints/server/store.d.ts.map +1 -0
- package/dest/entrypoints/server/store.js +28 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +8 -2
- package/dest/events/event_service.d.ts +13 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +13 -13
- package/dest/logs/log_service.d.ts +15 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +25 -32
- package/dest/messages/tx_resolver_service.d.ts +18 -7
- package/dest/messages/tx_resolver_service.d.ts.map +1 -1
- package/dest/messages/tx_resolver_service.js +13 -7
- package/dest/node/benchmarked_node.d.ts +20 -0
- package/dest/node/benchmarked_node.d.ts.map +1 -0
- package/dest/node/benchmarked_node.js +94 -0
- package/dest/node/caching_aztec_node.d.ts +24 -0
- package/dest/node/caching_aztec_node.d.ts.map +1 -0
- package/dest/node/caching_aztec_node.js +267 -0
- package/dest/notes/note_service.d.ts +13 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +10 -10
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +5 -5
- package/dest/private_kernel/batch_planner.d.ts +1 -1
- package/dest/private_kernel/batch_planner.d.ts.map +1 -1
- package/dest/private_kernel/batch_planner.js +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +45 -5
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +39 -19
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +2 -2
- package/dest/storage/fact_store/fact_store.d.ts +1 -1
- package/dest/storage/fact_store/fact_store.js +1 -1
- package/dest/storage/fact_store/index.d.ts +2 -2
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -1
- package/dest/storage/fact_store/origin_state.d.ts +4 -2
- package/dest/storage/fact_store/origin_state.d.ts.map +1 -1
- package/dest/storage/fact_store/origin_state.js +8 -1
- package/dest/storage/store_identity.d.ts +35 -0
- package/dest/storage/store_identity.d.ts.map +1 -0
- package/dest/storage/store_identity.js +44 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +41 -10
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +81 -29
- package/dest/tagging/constants.d.ts +10 -1
- package/dest/tagging/constants.d.ts.map +1 -1
- package/dest/tagging/constants.js +19 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +29 -8
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +29 -10
- package/dest/tagging/index.d.ts +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -2
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +10 -5
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +69 -38
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +6 -3
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +23 -38
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts +22 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/classify_pending_txs.js +61 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +15 -5
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -35
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts +29 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/resolve_pending_txs.js +41 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts +16 -0
- package/dest/tagging/sender_sync/utils/test_utils.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/test_utils.js +24 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
- package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
- package/dest/tagging/testing/tag_query_test_utils.js +10 -0
- package/package.json +17 -17
- package/src/bin/check_oracle_version.ts +5 -56
- package/src/bin/index.ts +1 -5
- package/src/bin/oracle_version_helpers.ts +11 -292
- package/src/block_synchronizer/block_synchronizer.ts +6 -23
- package/src/config/package_info.ts +1 -1
- package/src/contract/contract_class_service.ts +8 -46
- package/src/contract/helpers.ts +3 -3
- package/src/contract/skip_sync_contracts.ts +23 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +5 -20
- package/src/contract_function_simulator/index.ts +23 -3
- package/src/contract_function_simulator/noir-structs/resolved_tx.ts +11 -45
- package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +4 -3
- package/src/contract_function_simulator/oracle/oracle_registry.ts +12 -8
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +301 -198
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +19 -9
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +184 -56
- package/src/entrypoints/client/bundle/index.ts +1 -0
- package/src/entrypoints/client/bundle/utils.ts +15 -3
- package/src/entrypoints/client/lazy/index.ts +1 -0
- package/src/entrypoints/client/lazy/utils.ts +15 -3
- package/src/entrypoints/client/store.ts +54 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/store.ts +47 -0
- package/src/entrypoints/server/utils.ts +21 -7
- package/src/events/event_service.ts +24 -14
- package/src/logs/log_service.ts +41 -39
- package/src/messages/tx_resolver_service.ts +26 -15
- package/src/node/benchmarked_node.ts +140 -0
- package/src/node/caching_aztec_node.ts +406 -0
- package/src/notes/note_service.ts +20 -14
- package/src/oracle_version.ts +5 -5
- package/src/private_kernel/batch_planner.ts +0 -1
- package/src/private_kernel/private_kernel_execution_prover.ts +90 -4
- package/src/pxe.ts +40 -21
- package/src/storage/contract_store/contract_store.ts +2 -1
- package/src/storage/fact_store/fact_store.ts +1 -1
- package/src/storage/fact_store/index.ts +1 -0
- package/src/storage/fact_store/origin_state.ts +10 -1
- package/src/storage/store_identity.ts +72 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +113 -41
- package/src/tagging/constants.ts +22 -0
- package/src/tagging/get_all_logs_by_tags.ts +47 -11
- package/src/tagging/index.ts +7 -2
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +116 -62
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +27 -57
- package/src/tagging/sender_sync/utils/classify_pending_txs.ts +91 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +46 -40
- package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +64 -0
- package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
- package/src/tagging/testing/tag_query_test_utils.ts +11 -0
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +0 -39
- package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +0 -1
- package/dest/contract_function_simulator/aztec_node_read_cache.js +0 -60
- package/dest/contract_function_simulator/benchmarked_node.d.ts +0 -9
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/benchmarked_node.js +0 -77
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +0 -17
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +0 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +0 -60
- package/src/contract_function_simulator/aztec_node_read_cache.ts +0 -89
- package/src/contract_function_simulator/benchmarked_node.ts +0 -103
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +0 -66
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { CircuitKind } from '@aztec/bb.js';
|
|
1
2
|
import { MAX_APPS_PER_KERNEL } from '@aztec/constants';
|
|
2
3
|
import { uniqueBy } from '@aztec/foundation/collection';
|
|
3
|
-
import {
|
|
4
|
+
import { vkAsFields } from '@aztec/foundation/crypto/keys';
|
|
4
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
6
7
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
@@ -20,9 +21,13 @@ import {
|
|
|
20
21
|
type PrivateKernelExecutionProofOutput,
|
|
21
22
|
PrivateKernelInit2CircuitPrivateInputs,
|
|
22
23
|
PrivateKernelInit3CircuitPrivateInputs,
|
|
24
|
+
PrivateKernelInit4CircuitPrivateInputs,
|
|
25
|
+
PrivateKernelInit5CircuitPrivateInputs,
|
|
23
26
|
PrivateKernelInitCircuitPrivateInputs,
|
|
24
27
|
PrivateKernelInner2CircuitPrivateInputs,
|
|
25
28
|
PrivateKernelInner3CircuitPrivateInputs,
|
|
29
|
+
PrivateKernelInner4CircuitPrivateInputs,
|
|
30
|
+
PrivateKernelInner5CircuitPrivateInputs,
|
|
26
31
|
PrivateKernelInnerCircuitPrivateInputs,
|
|
27
32
|
PrivateKernelResetTailCircuitPrivateInputs,
|
|
28
33
|
type PrivateKernelSimulateOutput,
|
|
@@ -145,6 +150,7 @@ export class PrivateKernelExecutionProver {
|
|
|
145
150
|
bytecode: output.bytecode,
|
|
146
151
|
witness: output.outputWitness,
|
|
147
152
|
vk: output.verificationKey.keyAsBytes,
|
|
153
|
+
kind: CircuitKind.Kernel,
|
|
148
154
|
timings: {
|
|
149
155
|
witgen: witgenTimer.ms(),
|
|
150
156
|
},
|
|
@@ -230,6 +236,7 @@ export class PrivateKernelExecutionProver {
|
|
|
230
236
|
bytecode: tailOutput.bytecode,
|
|
231
237
|
witness: tailOutput.outputWitness,
|
|
232
238
|
vk: tailOutput.verificationKey.keyAsBytes,
|
|
239
|
+
kind: CircuitKind.Kernel,
|
|
233
240
|
timings: {
|
|
234
241
|
witgen: witgenTimer.ms(),
|
|
235
242
|
},
|
|
@@ -261,6 +268,7 @@ export class PrivateKernelExecutionProver {
|
|
|
261
268
|
bytecode: hidingOutput.bytecode,
|
|
262
269
|
witness: hidingOutput.outputWitness,
|
|
263
270
|
vk: hidingOutput.verificationKey.keyAsBytes,
|
|
271
|
+
kind: CircuitKind.HidingKernel,
|
|
264
272
|
timings: {
|
|
265
273
|
witgen: witgenTimer.ms(),
|
|
266
274
|
},
|
|
@@ -270,7 +278,11 @@ export class PrivateKernelExecutionProver {
|
|
|
270
278
|
if (profileMode == 'gates' || profileMode == 'full') {
|
|
271
279
|
for (const entry of executionSteps) {
|
|
272
280
|
const gateCountTimer = new Timer();
|
|
273
|
-
const gateCount = await this.proofCreator.computeGateCountForCircuit(
|
|
281
|
+
const gateCount = await this.proofCreator.computeGateCountForCircuit(
|
|
282
|
+
entry.bytecode,
|
|
283
|
+
entry.functionName,
|
|
284
|
+
entry.kind,
|
|
285
|
+
);
|
|
274
286
|
entry.gateCount = gateCount;
|
|
275
287
|
entry.timings.gateCount = gateCountTimer.ms();
|
|
276
288
|
}
|
|
@@ -366,6 +378,7 @@ export class PrivateKernelExecutionProver {
|
|
|
366
378
|
bytecode: next.acir,
|
|
367
379
|
witness: next.partialWitness,
|
|
368
380
|
vk: next.vk,
|
|
381
|
+
kind: CircuitKind.App,
|
|
369
382
|
timings: {
|
|
370
383
|
witgen: next.profileResult?.timings.witgen ?? 0,
|
|
371
384
|
oracles: next.profileResult?.timings.oracles,
|
|
@@ -399,8 +412,8 @@ export class PrivateKernelExecutionProver {
|
|
|
399
412
|
) {
|
|
400
413
|
const { contractAddress, functionSelector } = publicInputs.callContext;
|
|
401
414
|
|
|
402
|
-
const
|
|
403
|
-
const vk = await VerificationKeyAsFields.fromKey(
|
|
415
|
+
const vkFields = await vkAsFields(vkAsBuffer, CircuitKind.App);
|
|
416
|
+
const vk = await VerificationKeyAsFields.fromKey(vkFields);
|
|
404
417
|
|
|
405
418
|
const { currentContractClassId, publicKeys, saltedInitializationHash } =
|
|
406
419
|
await this.oracle.getContractAddressPreimage(contractAddress);
|
|
@@ -514,6 +527,47 @@ export class PrivateKernelExecutionProver {
|
|
|
514
527
|
functionName = 'private_kernel_init_3';
|
|
515
528
|
break;
|
|
516
529
|
}
|
|
530
|
+
case 4: {
|
|
531
|
+
const proofInput = new PrivateKernelInit4CircuitPrivateInputs(
|
|
532
|
+
txRequest,
|
|
533
|
+
vkTreeRoot,
|
|
534
|
+
ProtocolContractsList,
|
|
535
|
+
apps[0],
|
|
536
|
+
apps[1],
|
|
537
|
+
apps[2],
|
|
538
|
+
apps[3],
|
|
539
|
+
isPrivateOnlyTx,
|
|
540
|
+
minRevertibleSideEffectCounter,
|
|
541
|
+
);
|
|
542
|
+
this.log.debug(`Calling private kernel init_4 with isPrivateOnly ${isPrivateOnlyTx}`);
|
|
543
|
+
pushTestData('private-kernel-inputs-init-4', proofInput);
|
|
544
|
+
output = generateWitnesses
|
|
545
|
+
? await this.proofCreator.generateInit4Output(proofInput)
|
|
546
|
+
: await this.proofCreator.simulateInit4(proofInput);
|
|
547
|
+
functionName = 'private_kernel_init_4';
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
case 5: {
|
|
551
|
+
const proofInput = new PrivateKernelInit5CircuitPrivateInputs(
|
|
552
|
+
txRequest,
|
|
553
|
+
vkTreeRoot,
|
|
554
|
+
ProtocolContractsList,
|
|
555
|
+
apps[0],
|
|
556
|
+
apps[1],
|
|
557
|
+
apps[2],
|
|
558
|
+
apps[3],
|
|
559
|
+
apps[4],
|
|
560
|
+
isPrivateOnlyTx,
|
|
561
|
+
minRevertibleSideEffectCounter,
|
|
562
|
+
);
|
|
563
|
+
this.log.debug(`Calling private kernel init_5 with isPrivateOnly ${isPrivateOnlyTx}`);
|
|
564
|
+
pushTestData('private-kernel-inputs-init-5', proofInput);
|
|
565
|
+
output = generateWitnesses
|
|
566
|
+
? await this.proofCreator.generateInit5Output(proofInput)
|
|
567
|
+
: await this.proofCreator.simulateInit5(proofInput);
|
|
568
|
+
functionName = 'private_kernel_init_5';
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
517
571
|
default:
|
|
518
572
|
throw new Error(`Unsupported init kernel batch size: ${apps.length}`);
|
|
519
573
|
}
|
|
@@ -548,6 +602,37 @@ export class PrivateKernelExecutionProver {
|
|
|
548
602
|
functionName = 'private_kernel_inner_3';
|
|
549
603
|
break;
|
|
550
604
|
}
|
|
605
|
+
case 4: {
|
|
606
|
+
const proofInput = new PrivateKernelInner4CircuitPrivateInputs(
|
|
607
|
+
previousKernelData,
|
|
608
|
+
apps[0],
|
|
609
|
+
apps[1],
|
|
610
|
+
apps[2],
|
|
611
|
+
apps[3],
|
|
612
|
+
);
|
|
613
|
+
pushTestData('private-kernel-inputs-inner-4', proofInput);
|
|
614
|
+
output = generateWitnesses
|
|
615
|
+
? await this.proofCreator.generateInner4Output(proofInput)
|
|
616
|
+
: await this.proofCreator.simulateInner4(proofInput);
|
|
617
|
+
functionName = 'private_kernel_inner_4';
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
case 5: {
|
|
621
|
+
const proofInput = new PrivateKernelInner5CircuitPrivateInputs(
|
|
622
|
+
previousKernelData,
|
|
623
|
+
apps[0],
|
|
624
|
+
apps[1],
|
|
625
|
+
apps[2],
|
|
626
|
+
apps[3],
|
|
627
|
+
apps[4],
|
|
628
|
+
);
|
|
629
|
+
pushTestData('private-kernel-inputs-inner-5', proofInput);
|
|
630
|
+
output = generateWitnesses
|
|
631
|
+
? await this.proofCreator.generateInner5Output(proofInput)
|
|
632
|
+
: await this.proofCreator.simulateInner5(proofInput);
|
|
633
|
+
functionName = 'private_kernel_inner_5';
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
551
636
|
default:
|
|
552
637
|
throw new Error(`Unsupported inner kernel batch size: ${apps.length}`);
|
|
553
638
|
}
|
|
@@ -558,6 +643,7 @@ export class PrivateKernelExecutionProver {
|
|
|
558
643
|
bytecode: output.bytecode,
|
|
559
644
|
witness: output.outputWitness,
|
|
560
645
|
vk: output.verificationKey.keyAsBytes,
|
|
646
|
+
kind: CircuitKind.Kernel,
|
|
561
647
|
timings: {
|
|
562
648
|
witgen: witgenTimer.ms(),
|
|
563
649
|
},
|
package/src/pxe.ts
CHANGED
|
@@ -37,7 +37,7 @@ import type {
|
|
|
37
37
|
PrivateKernelTailCircuitPublicInputs,
|
|
38
38
|
} from '@aztec/stdlib/kernel';
|
|
39
39
|
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
40
|
-
import { deriveEcdhSharedSecretPoint } from '@aztec/stdlib/logs';
|
|
40
|
+
import { deriveEcdhSharedSecretPoint, protectFromForgery } from '@aztec/stdlib/logs';
|
|
41
41
|
import {
|
|
42
42
|
BlockHeader,
|
|
43
43
|
type ContractOverrides,
|
|
@@ -62,7 +62,6 @@ import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
|
62
62
|
import type { PXEConfig } from './config/index.js';
|
|
63
63
|
import { ContractClassService } from './contract/contract_class_service.js';
|
|
64
64
|
import { ContractSyncService } from './contract/contract_sync_service.js';
|
|
65
|
-
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
66
65
|
import {
|
|
67
66
|
ContractFunctionSimulator,
|
|
68
67
|
generateSimulatedProvingResult,
|
|
@@ -74,6 +73,7 @@ import { PrivateEventFilterValidator } from './events/private_event_filter_valid
|
|
|
74
73
|
import type { ExecutionHooks } from './hooks/index.js';
|
|
75
74
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
76
75
|
import { TxResolverService } from './messages/tx_resolver_service.js';
|
|
76
|
+
import { type CachingAztecNode, withCache } from './node/caching_aztec_node.js';
|
|
77
77
|
import {
|
|
78
78
|
PrivateKernelExecutionProver,
|
|
79
79
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -230,7 +230,7 @@ export type RegisteredTaggingSecretSource =
|
|
|
230
230
|
*/
|
|
231
231
|
export class PXE {
|
|
232
232
|
private constructor(
|
|
233
|
-
private node:
|
|
233
|
+
private node: CachingAztecNode,
|
|
234
234
|
private nodeDebug: AztecNodeDebug | undefined,
|
|
235
235
|
private db: AztecAsyncKVStore,
|
|
236
236
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
@@ -315,18 +315,22 @@ export class PXE {
|
|
|
315
315
|
l2TipsStore,
|
|
316
316
|
factStore,
|
|
317
317
|
} = openPxeStores(store, initialBlockHash);
|
|
318
|
-
|
|
318
|
+
// Every PXE consumer reads through this one wrapper, so a read cached by one is served to the rest. Only
|
|
319
|
+
// immutable, hash-pinned reads are cached (the rule lives on `withCache`), which makes it safe regardless of
|
|
320
|
+
// the consumer's anchor block; the block synchronizer wipes it on anchor updates to bound memory.
|
|
321
|
+
const readCachedNode = withCache(node);
|
|
322
|
+
const contractClassService = new ContractClassService(readCachedNode, contractStore);
|
|
319
323
|
const contractSyncService = new ContractSyncService(
|
|
320
|
-
|
|
324
|
+
readCachedNode,
|
|
321
325
|
contractStore,
|
|
322
326
|
contractClassService,
|
|
323
327
|
noteStore,
|
|
324
328
|
createLogger('pxe:contract_sync', bindings),
|
|
325
329
|
);
|
|
326
|
-
const txResolver = new TxResolverService(
|
|
330
|
+
const txResolver = new TxResolverService(readCachedNode);
|
|
327
331
|
|
|
328
332
|
const synchronizer = new BlockSynchronizer(
|
|
329
|
-
|
|
333
|
+
readCachedNode,
|
|
330
334
|
store,
|
|
331
335
|
anchorBlockStore,
|
|
332
336
|
noteStore,
|
|
@@ -334,7 +338,6 @@ export class PXE {
|
|
|
334
338
|
factStore,
|
|
335
339
|
l2TipsStore,
|
|
336
340
|
contractSyncService,
|
|
337
|
-
contractClassService,
|
|
338
341
|
config,
|
|
339
342
|
bindings,
|
|
340
343
|
);
|
|
@@ -355,7 +358,7 @@ export class PXE {
|
|
|
355
358
|
const jobQueue = new SerialQueue();
|
|
356
359
|
|
|
357
360
|
const pxe = new PXE(
|
|
358
|
-
|
|
361
|
+
readCachedNode,
|
|
359
362
|
nodeDebug,
|
|
360
363
|
store,
|
|
361
364
|
synchronizer,
|
|
@@ -410,7 +413,7 @@ export class PXE {
|
|
|
410
413
|
noteStore: this.noteStore,
|
|
411
414
|
keyStore: this.keyStore,
|
|
412
415
|
addressStore: this.addressStore,
|
|
413
|
-
aztecNode:
|
|
416
|
+
aztecNode: this.node,
|
|
414
417
|
l2TipsStore: this.l2TipsStore,
|
|
415
418
|
senderTaggingStore: this.senderTaggingStore,
|
|
416
419
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
@@ -890,9 +893,11 @@ export class PXE {
|
|
|
890
893
|
}
|
|
891
894
|
|
|
892
895
|
/**
|
|
893
|
-
* Derives the shared secret of a handshake from its ephemeral public key:
|
|
894
|
-
*
|
|
895
|
-
*
|
|
896
|
+
* Derives the shared secret of a handshake from its ephemeral public key: the raw ECDH secret
|
|
897
|
+
* `S = addressSecret(recipient) * ephPk` with the forgery protection applied,
|
|
898
|
+
* matching the protected secret the registry stores and the derivation the recipient-side scan uses for
|
|
899
|
+
* handshakes discovered onchain. The ephemeral key is reconstructed from its x-coordinate with a positive y,
|
|
900
|
+
* matching how the protocol generates it.
|
|
896
901
|
*
|
|
897
902
|
* @throws If `ephPk` is not the x-coordinate of a Grumpkin curve point, or if `recipient` is not an account of
|
|
898
903
|
* this PXE, since the derivation needs its keys.
|
|
@@ -914,7 +919,8 @@ export class PXE {
|
|
|
914
919
|
|
|
915
920
|
const ivskM = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
916
921
|
const addressSecret = await computeAddressSecret(await completeAddress.getPreaddress(), ivskM);
|
|
917
|
-
|
|
922
|
+
const rawSecret = await deriveEcdhSharedSecretPoint(addressSecret, ephPkPoint);
|
|
923
|
+
return protectFromForgery(rawSecret, ephPkPoint, await recipient.toAddressPoint());
|
|
918
924
|
}
|
|
919
925
|
|
|
920
926
|
/** Registers a resolved shared secret scoped to a recipient. Returns whether it was newly added. */
|
|
@@ -1013,6 +1019,7 @@ export class PXE {
|
|
|
1013
1019
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
1014
1020
|
return this.#putInJobQueue(async jobId => {
|
|
1015
1021
|
const totalTimer = new Timer();
|
|
1022
|
+
const recording = this.node.startRecording();
|
|
1016
1023
|
try {
|
|
1017
1024
|
const syncTimer = new Timer();
|
|
1018
1025
|
await this.#maybeSync();
|
|
@@ -1060,7 +1067,7 @@ export class PXE {
|
|
|
1060
1067
|
|
|
1061
1068
|
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
1062
1069
|
timings,
|
|
1063
|
-
nodeRPCCalls:
|
|
1070
|
+
nodeRPCCalls: recording.stop(),
|
|
1064
1071
|
});
|
|
1065
1072
|
|
|
1066
1073
|
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
@@ -1081,6 +1088,9 @@ export class PXE {
|
|
|
1081
1088
|
return txProvingResult;
|
|
1082
1089
|
} catch (err: any) {
|
|
1083
1090
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
1091
|
+
} finally {
|
|
1092
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1093
|
+
recording.stop();
|
|
1084
1094
|
}
|
|
1085
1095
|
});
|
|
1086
1096
|
}
|
|
@@ -1098,6 +1108,7 @@ export class PXE {
|
|
|
1098
1108
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
1099
1109
|
return this.#putInJobQueue(async jobId => {
|
|
1100
1110
|
const totalTimer = new Timer();
|
|
1111
|
+
const recording = this.node.startRecording();
|
|
1101
1112
|
try {
|
|
1102
1113
|
const txInfo = {
|
|
1103
1114
|
origin: txRequest.origin,
|
|
@@ -1163,10 +1174,12 @@ export class PXE {
|
|
|
1163
1174
|
total - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1164
1175
|
};
|
|
1165
1176
|
|
|
1166
|
-
|
|
1167
|
-
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: simulatorStats.nodeRPCCalls });
|
|
1177
|
+
return new TxProfileResult(executionSteps, { timings, nodeRPCCalls: recording.stop() });
|
|
1168
1178
|
} catch (err: any) {
|
|
1169
1179
|
throw this.#contextualizeError(err, inspect(txRequest), `profileMode=${profileMode}`);
|
|
1180
|
+
} finally {
|
|
1181
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1182
|
+
recording.stop();
|
|
1170
1183
|
}
|
|
1171
1184
|
});
|
|
1172
1185
|
}
|
|
@@ -1205,6 +1218,7 @@ export class PXE {
|
|
|
1205
1218
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1206
1219
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
1207
1220
|
return this.#putInJobQueue(async jobId => {
|
|
1221
|
+
const recording = this.node.startRecording();
|
|
1208
1222
|
try {
|
|
1209
1223
|
const totalTimer = new Timer();
|
|
1210
1224
|
const txInfo = {
|
|
@@ -1325,10 +1339,9 @@ export class PXE {
|
|
|
1325
1339
|
: {}),
|
|
1326
1340
|
});
|
|
1327
1341
|
|
|
1328
|
-
const simulatorStats = contractFunctionSimulator.getStats();
|
|
1329
1342
|
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
1330
1343
|
timings,
|
|
1331
|
-
nodeRPCCalls:
|
|
1344
|
+
nodeRPCCalls: recording.stop(),
|
|
1332
1345
|
});
|
|
1333
1346
|
} catch (err: any) {
|
|
1334
1347
|
throw this.#contextualizeError(
|
|
@@ -1338,6 +1351,9 @@ export class PXE {
|
|
|
1338
1351
|
`skipTxValidation=${skipTxValidation}`,
|
|
1339
1352
|
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1340
1353
|
);
|
|
1354
|
+
} finally {
|
|
1355
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1356
|
+
recording.stop();
|
|
1341
1357
|
}
|
|
1342
1358
|
});
|
|
1343
1359
|
}
|
|
@@ -1354,6 +1370,7 @@ export class PXE {
|
|
|
1354
1370
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
1355
1371
|
// delete the same read value, or reading values that another execution is currently modifying).
|
|
1356
1372
|
return this.#putInJobQueue(async jobId => {
|
|
1373
|
+
const recording = this.node.startRecording();
|
|
1357
1374
|
try {
|
|
1358
1375
|
const totalTimer = new Timer();
|
|
1359
1376
|
const syncTimer = new Timer();
|
|
@@ -1393,12 +1410,11 @@ export class PXE {
|
|
|
1393
1410
|
unaccounted: totalTime - (syncTime + perFunction.reduce((acc, { time }) => acc + time, 0)),
|
|
1394
1411
|
};
|
|
1395
1412
|
|
|
1396
|
-
const simulationStats = contractFunctionSimulator.getStats();
|
|
1397
1413
|
return {
|
|
1398
1414
|
result: executionResult,
|
|
1399
1415
|
offchainEffects,
|
|
1400
1416
|
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1401
|
-
stats: { timings, nodeRPCCalls:
|
|
1417
|
+
stats: { timings, nodeRPCCalls: recording.stop() },
|
|
1402
1418
|
};
|
|
1403
1419
|
} catch (err: any) {
|
|
1404
1420
|
const { to, name, args } = call;
|
|
@@ -1408,6 +1424,9 @@ export class PXE {
|
|
|
1408
1424
|
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1409
1425
|
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1410
1426
|
);
|
|
1427
|
+
} finally {
|
|
1428
|
+
// Idempotent cleanup for the error and early-exit paths. The success path already stopped the recording.
|
|
1429
|
+
recording.stop();
|
|
1411
1430
|
}
|
|
1412
1431
|
});
|
|
1413
1432
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
findFunctionAbiBySelector,
|
|
18
18
|
findFunctionArtifactBySelector,
|
|
19
19
|
getFunctionDebugMetadata,
|
|
20
|
+
getFunctionReturnType,
|
|
20
21
|
} from '@aztec/stdlib/abi';
|
|
21
22
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
23
|
import {
|
|
@@ -371,7 +372,7 @@ export class ContractStore {
|
|
|
371
372
|
hideMsgSender: false,
|
|
372
373
|
isStatic: functionDao.isStatic,
|
|
373
374
|
args: encodeArguments(functionDao, args),
|
|
374
|
-
|
|
375
|
+
returnType: getFunctionReturnType(functionDao),
|
|
375
376
|
});
|
|
376
377
|
}
|
|
377
378
|
}
|
|
@@ -82,7 +82,7 @@ export class FactStore implements StagedStore {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* Records a fact in a collection
|
|
85
|
+
* Records a fact in a collection.
|
|
86
86
|
*
|
|
87
87
|
* The collection is created implicitly on the first fact recorded for its key: recording into an existing collection
|
|
88
88
|
* just adds to it.
|
|
@@ -12,7 +12,7 @@ import type { Fact } from './stored_fact.js';
|
|
|
12
12
|
* - `Finalized`: L1-finalized.
|
|
13
13
|
*
|
|
14
14
|
* The numeric discriminants must stay in sync with the Noir `OriginBlockState` in
|
|
15
|
-
* `noir-projects/aztec-nr/aztec/src/facts/origin_state.nr`: PXE serializes this value into the `Fact` oracle response
|
|
15
|
+
* `noir-projects/labs/aztec-nr/aztec/src/facts/origin_state.nr`: PXE serializes this value into the `Fact` oracle response
|
|
16
16
|
* and Noir deserializes it via `from_u8`, which rejects any value outside this set.
|
|
17
17
|
*/
|
|
18
18
|
export enum OriginBlockState {
|
|
@@ -21,6 +21,15 @@ export enum OriginBlockState {
|
|
|
21
21
|
Finalized = 3,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** Parses a numeric origin-block-state discriminant, rejecting unknown values. */
|
|
25
|
+
export function originBlockStateFromNumber(value: number): OriginBlockState {
|
|
26
|
+
if (!(value in OriginBlockState)) {
|
|
27
|
+
const validNames = Object.keys(OriginBlockState).filter(k => isNaN(Number(k)));
|
|
28
|
+
throw new Error(`Invalid OriginBlockState value ${value}, expected one of ${validNames.join(', ')}`);
|
|
29
|
+
}
|
|
30
|
+
return value as OriginBlockState;
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/** The two chain-tip block numbers needed to classify an origin block (`finalized <= proven` always holds). */
|
|
25
34
|
export type TipBlockNumbers = { provenBlockNumber: number; finalizedBlockNumber: number };
|
|
26
35
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import { DatabaseVersion } from '@aztec/stdlib/database-version/version';
|
|
4
|
+
|
|
5
|
+
/** The triple that determine which physical store a logical store name maps to. */
|
|
6
|
+
export type StoreIdentity = {
|
|
7
|
+
/** Chain ID of the L1 the rollup is deployed to. */
|
|
8
|
+
l1ChainId: number;
|
|
9
|
+
/** Address of the rollup contract the store's data pertains to. */
|
|
10
|
+
rollupAddress: EthAddress;
|
|
11
|
+
/** Schema version of the data held in the store. */
|
|
12
|
+
schemaVersion: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Composes the store-name discriminator for a store identity. Two identities map to the same physical store iff
|
|
17
|
+
* their slugs are equal, so the format must stay stable: `<l1ChainId>-<rollupAddress>-v<schemaVersion>` — changing
|
|
18
|
+
* it orphans every existing store.
|
|
19
|
+
*/
|
|
20
|
+
export function storeIdentitySlug({ l1ChainId, rollupAddress, schemaVersion }: StoreIdentity): string {
|
|
21
|
+
return `${l1ChainId}-${rollupAddress.toString()}-v${schemaVersion}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Composes the physical store name for a logical store name and identity. */
|
|
25
|
+
export function effectiveStoreName(name: string, identity: StoreIdentity): string {
|
|
26
|
+
return `${name}_${storeIdentitySlug(identity)}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Invariant check for stores whose physical name carries their identity: the recorded version can
|
|
31
|
+
* only disagree with the expected one if there is a store-naming bug.
|
|
32
|
+
*/
|
|
33
|
+
export async function assertStoreIdentity(
|
|
34
|
+
store: AztecAsyncKVStore,
|
|
35
|
+
storeName: string,
|
|
36
|
+
identity: StoreIdentity,
|
|
37
|
+
): Promise<void> {
|
|
38
|
+
const expected = new DatabaseVersion(identity.schemaVersion, identity.rollupAddress);
|
|
39
|
+
const singleton = store.openSingleton<string>('dbVersion');
|
|
40
|
+
const stored = await singleton.getAsync();
|
|
41
|
+
if (stored === undefined) {
|
|
42
|
+
await singleton.set(expected.toBuffer().toString('utf-8'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let storedVersion: DatabaseVersion;
|
|
46
|
+
try {
|
|
47
|
+
storedVersion = DatabaseVersion.fromBuffer(Buffer.from(stored, 'utf-8'));
|
|
48
|
+
} catch {
|
|
49
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), stored);
|
|
50
|
+
}
|
|
51
|
+
if (!storedVersion.equals(expected)) {
|
|
52
|
+
throw new StoreIdentityMismatchError(storeName, expected.toString(), storedVersion.toString());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Thrown when a store's recorded identity does not match the identity it was opened under. Since the identity is
|
|
58
|
+
* part of the physical store name, this can only indicate a store-naming bug; the store is left untouched.
|
|
59
|
+
*/
|
|
60
|
+
export class StoreIdentityMismatchError extends Error {
|
|
61
|
+
constructor(
|
|
62
|
+
public readonly storeName: string,
|
|
63
|
+
public readonly expected: string,
|
|
64
|
+
public readonly actual: string,
|
|
65
|
+
) {
|
|
66
|
+
super(
|
|
67
|
+
`Store '${storeName}' records identity ${actual} but was opened as ${expected}. ` +
|
|
68
|
+
`Refusing to open; data was NOT modified.`,
|
|
69
|
+
);
|
|
70
|
+
this.name = 'StoreIdentityMismatchError';
|
|
71
|
+
}
|
|
72
|
+
}
|