@aztec-labs/pxe 6.0.0-rc.3 → 6.0.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 +1 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +2 -1
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts +6 -12
- package/dest/contract_function_simulator/noir-structs/fact_collection.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/fact_collection.js +1 -15
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +5 -5
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_registry.js +5 -5
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +16 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -0
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +3 -2
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -0
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.d.ts +1 -1
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.d.ts.map +1 -1
- package/dest/entrypoints/server/circuit_recording/simulator_recorder_wrapper.js +1 -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 +3 -1
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +3 -3
- 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 -0
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +1 -0
- 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 +1 -0
- package/dest/pxe.d.ts +27 -2
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +201 -128
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -1
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +23 -1
- package/dest/storage/contract_store/contract_store.d.ts +2 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +1 -0
- package/dest/storage/fact_store/fact_scope.d.ts +19 -0
- package/dest/storage/fact_store/fact_scope.d.ts.map +1 -0
- package/dest/storage/fact_store/fact_scope.js +37 -0
- package/dest/storage/fact_store/fact_service.d.ts +2 -2
- package/dest/storage/fact_store/fact_service.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_service.js +19 -5
- package/dest/storage/fact_store/fact_store_keys.d.ts +6 -5
- package/dest/storage/fact_store/fact_store_keys.d.ts.map +1 -1
- package/dest/storage/fact_store/fact_store_keys.js +24 -8
- package/dest/storage/fact_store/index.d.ts +2 -1
- package/dest/storage/fact_store/index.d.ts.map +1 -1
- package/dest/storage/fact_store/index.js +1 -0
- package/dest/storage/fact_store/stored_fact.d.ts +9 -3
- package/dest/storage/fact_store/stored_fact.d.ts.map +1 -1
- package/dest/storage/fact_store/stored_fact.js +45 -3
- package/dest/storage/store_identity.d.ts +1 -1
- package/dest/storage/store_identity.d.ts.map +1 -1
- package/dest/storage/store_identity.js +1 -0
- package/package.json +21 -20
- package/src/config/index.ts +2 -1
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/fact_collection.ts +6 -22
- package/src/contract_function_simulator/oracle/oracle_registry.ts +5 -4
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +15 -1
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -0
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +8 -7
- package/src/contract_function_simulator/pick_notes.ts +1 -0
- package/src/entrypoints/server/circuit_recording/simulator_recorder_wrapper.ts +1 -0
- package/src/entrypoints/server/utils.ts +4 -2
- package/src/oracle_version.ts +3 -3
- package/src/private_kernel/batch_planner.ts +1 -0
- package/src/private_kernel/hints/test_utils.ts +1 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +1 -0
- package/src/pxe.ts +291 -189
- package/src/storage/address_store/address_store.ts +1 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/FactStore.json +20 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +1 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +18 -1
- package/src/storage/contract_store/contract_store.ts +1 -0
- package/src/storage/fact_store/fact_scope.ts +39 -0
- package/src/storage/fact_store/fact_service.ts +20 -5
- package/src/storage/fact_store/fact_store_keys.ts +28 -15
- package/src/storage/fact_store/index.ts +1 -0
- package/src/storage/fact_store/stored_fact.ts +50 -14
- package/src/storage/store_identity.ts +1 -0
package/dest/pxe.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec-labs/foundation/branded-types';
|
|
2
2
|
import { Point } from '@aztec-labs/foundation/curves/grumpkin';
|
|
3
|
+
import { inspect } from '@aztec-labs/foundation/inspect';
|
|
3
4
|
import { createLogger } from '@aztec-labs/foundation/log';
|
|
4
5
|
import { allToCompletion } from '@aztec-labs/foundation/promise';
|
|
5
6
|
import { Timer } from '@aztec-labs/foundation/timer';
|
|
@@ -11,7 +12,6 @@ import { SimulationError } from '@aztec-labs/stdlib/errors';
|
|
|
11
12
|
import { computeAddressSecret } from '@aztec-labs/stdlib/keys';
|
|
12
13
|
import { deriveEcdhSharedSecretPoint, protectFromForgery } from '@aztec-labs/stdlib/logs';
|
|
13
14
|
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec-labs/stdlib/tx';
|
|
14
|
-
import { inspect } from 'util';
|
|
15
15
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
16
16
|
import { ContractClassService } from './contract/contract_class_service.js';
|
|
17
17
|
import { ContractSyncService } from './contract/contract_sync_service.js';
|
|
@@ -313,6 +313,141 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
313
313
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
314
314
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
315
315
|
}
|
|
316
|
+
/** Simulates `txRequest` within an already-open operation, using its anchor block and change set. */ async #simulateTx({ changeSetId, syncTime, anchorBlockHeader, recording, totalMs }, txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes, senderForTags }) {
|
|
317
|
+
const txInfo = {
|
|
318
|
+
origin: txRequest.origin,
|
|
319
|
+
functionSelector: txRequest.functionSelector,
|
|
320
|
+
simulatePublic,
|
|
321
|
+
chainId: txRequest.txContext.chainId,
|
|
322
|
+
version: txRequest.txContext.version,
|
|
323
|
+
authWitnesses: txRequest.authWitnesses.map((w)=>w.requestHash)
|
|
324
|
+
};
|
|
325
|
+
this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
326
|
+
if (overrides?.contracts && Object.keys(overrides.contracts).length > 0 && !skipKernels) {
|
|
327
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
328
|
+
}
|
|
329
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
330
|
+
// Execution of private functions only; no proving, and no kernel logic.
|
|
331
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
332
|
+
contractFunctionSimulator,
|
|
333
|
+
txRequest,
|
|
334
|
+
anchorBlockHeader,
|
|
335
|
+
scopes,
|
|
336
|
+
changeSetId,
|
|
337
|
+
senderForTags
|
|
338
|
+
});
|
|
339
|
+
let publicInputs;
|
|
340
|
+
let executionSteps = [];
|
|
341
|
+
if (skipKernels) {
|
|
342
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.#getDebugFunctionName(addr, sel, anchorBlockHeader), this.node));
|
|
343
|
+
} else {
|
|
344
|
+
// Kernel logic, plus proving of all private functions and kernels.
|
|
345
|
+
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
346
|
+
simulate: true,
|
|
347
|
+
skipFeeEnforcement,
|
|
348
|
+
profileMode: 'none'
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
352
|
+
const simulatedTx = await privateSimulationResult.toSimulatedTx();
|
|
353
|
+
let publicSimulationTime;
|
|
354
|
+
let publicOutput;
|
|
355
|
+
if (simulatePublic && publicInputs.forPublic) {
|
|
356
|
+
const publicSimulationTimer = new Timer();
|
|
357
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement, overrides);
|
|
358
|
+
publicSimulationTime = publicSimulationTimer.ms();
|
|
359
|
+
if (publicOutput?.debugLogs?.length) {
|
|
360
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.#getDebugContractName(addr, anchorBlockHeader));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
let validationTime;
|
|
364
|
+
if (!skipTxValidation) {
|
|
365
|
+
const validationTimer = new Timer();
|
|
366
|
+
const validationResult = await this.node.isValidTx(simulatedTx, {
|
|
367
|
+
isSimulation: true,
|
|
368
|
+
skipFeeEnforcement
|
|
369
|
+
});
|
|
370
|
+
validationTime = validationTimer.ms();
|
|
371
|
+
if (validationResult.result === 'invalid') {
|
|
372
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
373
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const txHash = simulatedTx.getTxHash();
|
|
377
|
+
const totalTime = totalMs();
|
|
378
|
+
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
379
|
+
functionName,
|
|
380
|
+
time: witgen,
|
|
381
|
+
oracles
|
|
382
|
+
}));
|
|
383
|
+
const timings = {
|
|
384
|
+
total: totalTime,
|
|
385
|
+
sync: syncTime,
|
|
386
|
+
publicSimulation: publicSimulationTime,
|
|
387
|
+
validation: validationTime,
|
|
388
|
+
perFunction,
|
|
389
|
+
unaccounted: totalTime - (syncTime + (publicSimulationTime ?? 0) + (validationTime ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
390
|
+
};
|
|
391
|
+
this.log.info(`Simulation completed for ${txHash.toString()} in ${totalTime}ms`, {
|
|
392
|
+
txHash,
|
|
393
|
+
...txInfo,
|
|
394
|
+
...publicOutput ? {
|
|
395
|
+
gasUsed: publicOutput.gasUsed,
|
|
396
|
+
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
397
|
+
revertReason: publicOutput.revertReason
|
|
398
|
+
} : {}
|
|
399
|
+
});
|
|
400
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
401
|
+
timings,
|
|
402
|
+
nodeRPCCalls: recording.stats()
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
/** Describes a simulation of `txRequest` for the errors it throws. */ #simulateTxErrorContext(txRequest, opts) {
|
|
406
|
+
return [
|
|
407
|
+
inspect(txRequest),
|
|
408
|
+
`simulatePublic=${opts.simulatePublic}`,
|
|
409
|
+
`skipTxValidation=${opts.skipTxValidation ?? false}`,
|
|
410
|
+
`scopes=${opts.scopes.map((s)=>s.toString()).join(', ')}`
|
|
411
|
+
];
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Proves `privateExecutionResult`, the private execution of `txRequest`, within an already-open operation, and stages
|
|
415
|
+
* the sender tagging indices the tx uses.
|
|
416
|
+
*/ async #proveTx({ changeSetId, syncTime, anchorBlockHeader, recording, totalMs }, txRequest, privateExecutionResult) {
|
|
417
|
+
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
418
|
+
simulate: false,
|
|
419
|
+
skipFeeEnforcement: false,
|
|
420
|
+
profileMode: 'none'
|
|
421
|
+
});
|
|
422
|
+
const totalTime = totalMs();
|
|
423
|
+
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
424
|
+
functionName,
|
|
425
|
+
time: witgen,
|
|
426
|
+
oracles
|
|
427
|
+
}));
|
|
428
|
+
const timings = {
|
|
429
|
+
total: totalTime,
|
|
430
|
+
sync: syncTime,
|
|
431
|
+
proving,
|
|
432
|
+
perFunction,
|
|
433
|
+
unaccounted: totalTime - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
434
|
+
};
|
|
435
|
+
this.log.debug(`Proving completed in ${totalTime}ms`, {
|
|
436
|
+
timings
|
|
437
|
+
});
|
|
438
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof, {
|
|
439
|
+
timings,
|
|
440
|
+
nodeRPCCalls: recording.stats()
|
|
441
|
+
});
|
|
442
|
+
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
443
|
+
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
444
|
+
// onchain).
|
|
445
|
+
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
446
|
+
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
447
|
+
// actually used to being reduced.
|
|
448
|
+
await persistSenderTaggingIndexRangesForTx(this.senderTaggingStore, privateExecutionResult.entrypoint.taggingIndexRanges, publicInputs, ()=>txProvingResult.getTxHash(), changeSetId, this.log);
|
|
449
|
+
return txProvingResult;
|
|
450
|
+
}
|
|
316
451
|
// Public API
|
|
317
452
|
/**
|
|
318
453
|
* Triggers a sync of PXE state with the node, regardless of the `autoSync` config flag. Use this to
|
|
@@ -574,49 +709,17 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
574
709
|
let privateExecutionResult;
|
|
575
710
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
576
711
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
577
|
-
return this.operationQueue.runSynced(async (
|
|
712
|
+
return this.operationQueue.runSynced(async (ctx)=>{
|
|
578
713
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
579
714
|
privateExecutionResult = await this.#executePrivate({
|
|
580
715
|
contractFunctionSimulator,
|
|
581
716
|
txRequest,
|
|
582
|
-
anchorBlockHeader,
|
|
717
|
+
anchorBlockHeader: ctx.anchorBlockHeader,
|
|
583
718
|
scopes,
|
|
584
|
-
changeSetId,
|
|
719
|
+
changeSetId: ctx.changeSetId,
|
|
585
720
|
senderForTags
|
|
586
721
|
});
|
|
587
|
-
|
|
588
|
-
simulate: false,
|
|
589
|
-
skipFeeEnforcement: false,
|
|
590
|
-
profileMode: 'none'
|
|
591
|
-
});
|
|
592
|
-
const totalTime = totalMs();
|
|
593
|
-
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
594
|
-
functionName,
|
|
595
|
-
time: witgen,
|
|
596
|
-
oracles
|
|
597
|
-
}));
|
|
598
|
-
const timings = {
|
|
599
|
-
total: totalTime,
|
|
600
|
-
sync: syncTime,
|
|
601
|
-
proving,
|
|
602
|
-
perFunction,
|
|
603
|
-
unaccounted: totalTime - ((syncTime ?? 0) + (proving ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
604
|
-
};
|
|
605
|
-
this.log.debug(`Proving completed in ${totalTime}ms`, {
|
|
606
|
-
timings
|
|
607
|
-
});
|
|
608
|
-
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof, {
|
|
609
|
-
timings,
|
|
610
|
-
nodeRPCCalls: recording.stats()
|
|
611
|
-
});
|
|
612
|
-
// We keep track of which tagging indices we've used in this tx so that we don't repeat them in future txs
|
|
613
|
-
// (which would link them) without having to rely on this tx being mined (and us seeing the indices being used
|
|
614
|
-
// onchain).
|
|
615
|
-
// Note that this must happen _after_ proving as it requires the proof's public inputs, from which the kernels
|
|
616
|
-
// may have removed some logs due to note-nullifier squashing - this may lead to range of tagging indices we've
|
|
617
|
-
// actually used to being reduced.
|
|
618
|
-
await persistSenderTaggingIndexRangesForTx(this.senderTaggingStore, privateExecutionResult.entrypoint.taggingIndexRanges, publicInputs, ()=>txProvingResult.getTxHash(), changeSetId, this.log);
|
|
619
|
-
return txProvingResult;
|
|
722
|
+
return this.#proveTx(ctx, txRequest, privateExecutionResult);
|
|
620
723
|
}, {
|
|
621
724
|
errorContext: ()=>[
|
|
622
725
|
inspect(txRequest),
|
|
@@ -701,104 +804,74 @@ import { persistSenderTaggingIndexRangesForTx } from './tagging/index.js';
|
|
|
701
804
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
702
805
|
*
|
|
703
806
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
704
|
-
*/ simulateTx(txRequest,
|
|
807
|
+
*/ simulateTx(txRequest, opts) {
|
|
705
808
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
706
809
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
707
810
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
708
|
-
return this.operationQueue.runSynced(
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
const validationTimer = new Timer();
|
|
758
|
-
const validationResult = await this.node.isValidTx(simulatedTx, {
|
|
759
|
-
isSimulation: true,
|
|
760
|
-
skipFeeEnforcement
|
|
811
|
+
return this.operationQueue.runSynced((ctx)=>this.#simulateTx(ctx, txRequest, opts), {
|
|
812
|
+
errorContext: ()=>this.#simulateTxErrorContext(txRequest, opts)
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Combination of `simulateTx` and `proveTx`: a simulation is executed, its results inspected to produce a provable
|
|
817
|
+
* transaction, followed by witness generation and proof.
|
|
818
|
+
*
|
|
819
|
+
* The entire sequence runs as a single atomic PXE operation, with no private state sync between simulation and
|
|
820
|
+
* witness generation, resulting in them running over identical environments (e.g. the note store, tagging indices,
|
|
821
|
+
* etc.).
|
|
822
|
+
*
|
|
823
|
+
* The simulation result is passed to a `prepareProve` callback, which then returns the input to the equivalent
|
|
824
|
+
* `proveTx` call. Due to the atomic nature of this function, `prepareProve` must NOT call any PXE function, as that
|
|
825
|
+
* would result in a deadlock.
|
|
826
|
+
*/ simulateAndProveTx(simulationTxRequest, { prepareProve, ...simulateOpts }) {
|
|
827
|
+
let proveTxRequest;
|
|
828
|
+
let privateExecutionResult;
|
|
829
|
+
// We run the entire thing as a single operation, which blocks the queue. There are two other possible paths we
|
|
830
|
+
// could take here:
|
|
831
|
+
// a) decouple the queue from a changeset to commit. This would let us hold the queue and have two changesets, one
|
|
832
|
+
// for the simulation and its corresponding sync, and one for the prove. In case of failure of either the
|
|
833
|
+
// `prepareProve` callback (e.g. user rejection) or the proof itself, we'd still have committed the simulation
|
|
834
|
+
// work, including the private state sync, which could save time in future runs.
|
|
835
|
+
// b) make this be two separate jobs, releasing the queue in between, but holding a second lock which would prevent
|
|
836
|
+
// PXE from updating its anchor block and therefore re-syncing contracts. In the case of a long-running
|
|
837
|
+
// callback, other unrelated operations (e.g. utility call invocations) would still be able to go through.
|
|
838
|
+
//
|
|
839
|
+
// We're not currently taking either of these paths due to uncertainty on this even being a good primitive for PXE
|
|
840
|
+
// to expose to wallets, and to not invest too heavily in this direction (as both approaches would require
|
|
841
|
+
// refactoring). Additionally, the gains those approaches provide are currently not valuable: for a) we expect it to
|
|
842
|
+
// be unlikely for a follow-up simulation to be executed on the same anchor block as the first one, so committing
|
|
843
|
+
// the sync achieves little if anything, and for b) the callback is expected to be fairly quick, and for there to be
|
|
844
|
+
// no need to execute any other PXE calls while it runs.
|
|
845
|
+
return this.operationQueue.runSynced(async (ctx)=>{
|
|
846
|
+
const simulationResult = await this.#simulateTx(ctx, simulationTxRequest, simulateOpts);
|
|
847
|
+
let proveOpts;
|
|
848
|
+
({ proveTxRequest, proveOpts } = await prepareProve(simulationResult));
|
|
849
|
+
// The proving result's timings and node stats must cover proving alone, not the simulation before it.
|
|
850
|
+
const provingTimer = new Timer();
|
|
851
|
+
const recording = this.node.startRecording();
|
|
852
|
+
try {
|
|
853
|
+
privateExecutionResult = await this.#executePrivate({
|
|
854
|
+
contractFunctionSimulator: this.#getSimulatorForTx(),
|
|
855
|
+
txRequest: proveTxRequest,
|
|
856
|
+
anchorBlockHeader: ctx.anchorBlockHeader,
|
|
857
|
+
scopes: proveOpts.scopes,
|
|
858
|
+
changeSetId: ctx.changeSetId,
|
|
859
|
+
senderForTags: proveOpts.senderForTags
|
|
761
860
|
});
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
861
|
+
return await this.#proveTx({
|
|
862
|
+
...ctx,
|
|
863
|
+
syncTime: 0,
|
|
864
|
+
recording,
|
|
865
|
+
totalMs: ()=>provingTimer.ms()
|
|
866
|
+
}, proveTxRequest, privateExecutionResult);
|
|
867
|
+
} finally{
|
|
868
|
+
recording.stop();
|
|
767
869
|
}
|
|
768
|
-
const txHash = simulatedTx.getTxHash();
|
|
769
|
-
const totalTime = totalMs();
|
|
770
|
-
const perFunction = executionSteps.map(({ functionName, timings: { witgen, oracles } })=>({
|
|
771
|
-
functionName,
|
|
772
|
-
time: witgen,
|
|
773
|
-
oracles
|
|
774
|
-
}));
|
|
775
|
-
const timings = {
|
|
776
|
-
total: totalTime,
|
|
777
|
-
sync: syncTime,
|
|
778
|
-
publicSimulation: publicSimulationTime,
|
|
779
|
-
validation: validationTime,
|
|
780
|
-
perFunction,
|
|
781
|
-
unaccounted: totalTime - (syncTime + (publicSimulationTime ?? 0) + (validationTime ?? 0) + perFunction.reduce((acc, { time })=>acc + time, 0))
|
|
782
|
-
};
|
|
783
|
-
this.log.info(`Simulation completed for ${txHash.toString()} in ${totalTime}ms`, {
|
|
784
|
-
txHash,
|
|
785
|
-
...txInfo,
|
|
786
|
-
...publicOutput ? {
|
|
787
|
-
gasUsed: publicOutput.gasUsed,
|
|
788
|
-
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
789
|
-
revertReason: publicOutput.revertReason
|
|
790
|
-
} : {}
|
|
791
|
-
});
|
|
792
|
-
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, {
|
|
793
|
-
timings,
|
|
794
|
-
nodeRPCCalls: recording.stats()
|
|
795
|
-
});
|
|
796
870
|
}, {
|
|
797
871
|
errorContext: ()=>[
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
`scopes=${scopes.map((s)=>s.toString()).join(', ')}`
|
|
872
|
+
...this.#simulateTxErrorContext(simulationTxRequest, simulateOpts),
|
|
873
|
+
inspect(proveTxRequest),
|
|
874
|
+
inspect(privateExecutionResult)
|
|
802
875
|
]
|
|
803
876
|
});
|
|
804
877
|
}
|
|
@@ -8,4 +8,4 @@ export declare class AddressStore {
|
|
|
8
8
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
9
9
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvYWRkcmVzc19zdG9yZS9hZGRyZXNzX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFtQixpQkFBaUIsRUFBaUIsTUFBTSxzQkFBc0IsQ0FBQztBQUM5RixPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUNyRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFHOUQscUJBQWEsWUFBWTs7SUFLdkIsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBS25DO0lBRUQsa0JBQWtCLENBQUMsZUFBZSxFQUFFLGVBQWUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBMEJyRTtJQUVELGtCQUFrQixDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLGVBQWUsR0FBRyxTQUFTLENBQUMsQ0FVOUU7SUFFRCxvQkFBb0IsSUFBSSxPQUFPLENBQUMsZUFBZSxFQUFFLENBQUMsQ0FNakQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAED,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAU9E;IAED,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAMjD;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toArray } from '@aztec-labs/foundation/iterable';
|
|
2
2
|
import { allToCompletion } from '@aztec-labs/foundation/promise';
|
|
3
3
|
import { CompleteAddress } from '@aztec-labs/stdlib/contract';
|
|
4
|
+
import { Buffer } from 'buffer';
|
|
4
5
|
export class AddressStore {
|
|
5
6
|
#store;
|
|
6
7
|
#completeAddresses;
|
|
@@ -39,4 +39,4 @@ export declare function snapshotMap<K extends Key, V>(map: AztecAsyncMap<K, V>):
|
|
|
39
39
|
export declare function snapshotArray<V>(array: AztecAsyncArray<V>): Promise<ArrayEntry[]>;
|
|
40
40
|
/** Returns the singleton's value rendered as a string, or `null` if unset. */
|
|
41
41
|
export declare function snapshotSingleton<V>(singleton: AztecAsyncSingleton<V>): Promise<string | null>;
|
|
42
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia3Zfc3RvcmVfc25hcHNob3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2JhY2t3YXJkc19jb21wYXRpYmlsaXR5X3Rlc3RzL2t2X3N0b3JlX3NuYXBzaG90LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxhQUFhLEVBQUUsbUJBQW1CLEVBQUUsR0FBRyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFHckc7Ozs7Ozs7Ozs7Ozs7OztHQWVHO0FBRUgsZ0ZBQWdGO0FBQ2hGLE1BQU0sTUFBTSxRQUFRLEdBQUc7SUFBRSxHQUFHLEVBQUUsTUFBTSxDQUFDO0lBQUMsS0FBSyxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUM7QUFFdEQsMEVBQTBFO0FBQzFFLE1BQU0sTUFBTSxVQUFVLEdBQUc7SUFBRSxLQUFLLEVBQUUsTUFBTSxDQUFDO0lBQUMsS0FBSyxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUM7QUFFMUQ7OztHQUdHO0FBQ0gsd0JBQXNCLFdBQVcsQ0FBQyxDQUFDLFNBQVMsR0FBRyxFQUFFLENBQUMsRUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDLENBQUMsRUFBRSxDQUFDLENBQUMsR0FBRyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FNakc7QUFFRDs7Ozs7R0FLRztBQUNILHdCQUFzQixhQUFhLENBQUMsQ0FBQyxFQUFFLEtBQUssRUFBRSxlQUFlLENBQUMsQ0FBQyxDQUFDLEdBQUcsT0FBTyxDQUFDLFVBQVUsRUFBRSxDQUFDLENBT3ZGO0FBRUQsOEVBQThFO0FBQzlFLHdCQUFzQixpQkFBaUIsQ0FBQyxDQUFDLEVBQUUsU0FBUyxFQUFFLG1CQUFtQixDQUFDLENBQUMsQ0FBQyxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFDLENBR3BHIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv_store_snapshot.d.ts","sourceRoot":"","sources":["../../../src/storage/backwards_compatibility_tests/kv_store_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"kv_store_snapshot.d.ts","sourceRoot":"","sources":["../../../src/storage/backwards_compatibility_tests/kv_store_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAGrG;;;;;;;;;;;;;;;GAeG;AAEH,gFAAgF;AAChF,MAAM,MAAM,QAAQ,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;;GAGG;AACH,wBAAsB,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAMjG;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAOvF;AAED,8EAA8E;AAC9E,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGpG"}
|
|
@@ -12,4 +12,4 @@ export type SchemaTest = {
|
|
|
12
12
|
snapshotStore: (kvStore: AztecAsyncKVStore) => Promise<Record<string, unknown>>;
|
|
13
13
|
};
|
|
14
14
|
export declare const SCHEMA_TESTS: readonly SchemaTest[];
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hX3Rlc3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9iYWNrd2FyZHNfY29tcGF0aWJpbGl0eV90ZXN0cy9zY2hlbWFfdGVzdHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBY0EsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQWtEOUQ7Ozs7OztHQU1HO0FBQ0gsTUFBTSxNQUFNLFVBQVUsR0FBRztJQUN2QixJQUFJLEVBQUUsTUFBTSxDQUFDO0lBQ2IsWUFBWSxFQUFFLENBQUMsT0FBTyxFQUFFLGlCQUFpQixLQUFLLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUM1RCxhQUFhLEVBQUUsQ0FBQyxPQUFPLEVBQUUsaUJBQWlCLEtBQUssT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQztDQUNqRixDQUFDO0FBRUYsZUFBTyxNQUFNLFlBQVksRUFBRSxTQUFTLFVBQVUsRUEybkI3QyxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_tests.d.ts","sourceRoot":"","sources":["../../../src/storage/backwards_compatibility_tests/schema_tests.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema_tests.d.ts","sourceRoot":"","sources":["../../../src/storage/backwards_compatibility_tests/schema_tests.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkD9D;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,aAAa,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACjF,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EA2nB7C,CAAC"}
|
|
@@ -18,6 +18,7 @@ import { Note, NoteDao } from '@aztec-labs/stdlib/note';
|
|
|
18
18
|
import { CheckpointHeader } from '@aztec-labs/stdlib/rollup';
|
|
19
19
|
import { AppendOnlyTreeSnapshot } from '@aztec-labs/stdlib/trees';
|
|
20
20
|
import { BlockHeader, GlobalVariables, PartialStateReference, StateReference, TxEffect, TxHash } from '@aztec-labs/stdlib/tx';
|
|
21
|
+
import { Buffer } from 'buffer';
|
|
21
22
|
import { AddressStore } from '../address_store/address_store.js';
|
|
22
23
|
import { AnchorBlockStore } from '../anchor_block_store/index.js';
|
|
23
24
|
import { CapsuleStore } from '../capsule_store/capsule_store.js';
|
|
@@ -155,7 +156,10 @@ export const SCHEMA_TESTS = [
|
|
|
155
156
|
const changeSetId = 'fixture-change-set';
|
|
156
157
|
factStore.beginChangeSet(changeSetId);
|
|
157
158
|
const contract = AztecAddress.fromBigIntUnsafe(100n);
|
|
158
|
-
const scope =
|
|
159
|
+
const scope = {
|
|
160
|
+
type: 'account',
|
|
161
|
+
account: AztecAddress.fromBigIntUnsafe(1n)
|
|
162
|
+
};
|
|
159
163
|
const factCollectionTypeId = new Fr(7n);
|
|
160
164
|
const keyA = FactCollectionKey.from({
|
|
161
165
|
contractAddress: contract,
|
|
@@ -184,6 +188,24 @@ export const SCHEMA_TESTS = [
|
|
|
184
188
|
blockNumber: 5,
|
|
185
189
|
blockHash: new Fr(1n)
|
|
186
190
|
}, changeSetId);
|
|
191
|
+
// A collection under the public scope, with a non-retractable and a retractable fact.
|
|
192
|
+
const publicKey = FactCollectionKey.from({
|
|
193
|
+
contractAddress: contract,
|
|
194
|
+
scope: {
|
|
195
|
+
type: 'public'
|
|
196
|
+
},
|
|
197
|
+
factCollectionTypeId,
|
|
198
|
+
factCollectionId: new Fr(0xccn)
|
|
199
|
+
});
|
|
200
|
+
await factStore.recordFact(publicKey, new Fr(4n), [
|
|
201
|
+
new Fr(8n)
|
|
202
|
+
], undefined, changeSetId);
|
|
203
|
+
await factStore.recordFact(publicKey, new Fr(5n), [
|
|
204
|
+
new Fr(10n)
|
|
205
|
+
], {
|
|
206
|
+
blockNumber: 7,
|
|
207
|
+
blockHash: new Fr(3n)
|
|
208
|
+
}, changeSetId);
|
|
187
209
|
await kvStore.transactionAsync(()=>factStore.commitChangeSet(changeSetId));
|
|
188
210
|
},
|
|
189
211
|
snapshotStore: async (kvStore)=>({
|
|
@@ -6,6 +6,7 @@ import type { AztecAsyncKVStore } from '@aztec-labs/kv-store';
|
|
|
6
6
|
import { type ContractArtifact, type FunctionArtifactWithContractName, FunctionCall, type FunctionDebugMetadata, FunctionSelector } from '@aztec-labs/stdlib/abi';
|
|
7
7
|
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
8
8
|
import { type ContractClassIdPreimage, type ContractClassWithId, type ContractInstancePreimageWithAddress } from '@aztec-labs/stdlib/contract';
|
|
9
|
+
import { Buffer } from 'buffer';
|
|
9
10
|
/**
|
|
10
11
|
* All contract class data except the large packedBytecode.
|
|
11
12
|
* The expensive data from the ContractClass is precomputed and stored in this format to avoid redundant hashing.
|
|
@@ -93,4 +94,4 @@ export declare class ContractStore {
|
|
|
93
94
|
getDebugFunctionName(contractClassId: Fr, selector: FunctionSelector): Promise<string>;
|
|
94
95
|
getFunctionCall(functionName: string, args: any[], to: AztecAddress, contractClassId: Fr): Promise<FunctionCall>;
|
|
95
96
|
}
|
|
96
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3Rfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NvbnRyYWN0X3N0b3JlL2NvbnRyYWN0X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJB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FBb0IsQ0FBQyxlQUFlLEVBQUUsRUFBRSxFQUFFLFFBQVEsRUFBRSxnQkFBZ0IsbUJBSWhGO0lBRVksZUFBZSxDQUMxQixZQUFZLEVBQUUsTUFBTSxFQUNwQixJQUFJLEVBQUUsR0FBRyxFQUFFLEVBQ1gsRUFBRSxFQUFFLFlBQVksRUFDaEIsZUFBZSxFQUFFLEVBQUUsR0FDbEIsT0FBTyxDQUFDLFlBQVksQ0FBQyxDQTBCdkI7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_store.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_store/contract_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAiC,MAAM,kCAAkC,CAAC;AAC/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gCAAgC,EACrC,YAAY,EACZ,KAAK,qBAAqB,EAC1B,gBAAgB,EASjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,mCAAmC,EAGzC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"contract_store.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_store/contract_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAiC,MAAM,kCAAkC,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,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAGrE;IAEY,oBAAoB,CAAC,eAAe,EAAE,EAAE,+BAGpD;IAEY,oBAAoB,CAAC,eAAe,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,mBAIhF;IAEY,eAAe,CAC1B,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,GAAG,EAAE,EACX,EAAE,EAAE,YAAY,EAChB,eAAe,EAAE,EAAE,GAClB,OAAO,CAAC,YAAY,CAAC,CA0BvB;CACF"}
|
|
@@ -5,6 +5,7 @@ import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec-labs/foundat
|
|
|
5
5
|
import { FunctionCall, FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, findFunctionAbiBySelector, findFunctionArtifactBySelector, getFunctionDebugMetadata, getFunctionReturnType } from '@aztec-labs/stdlib/abi';
|
|
6
6
|
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
7
7
|
import { SerializableContractInstancePreimage, getContractClassFromArtifact } from '@aztec-labs/stdlib/contract';
|
|
8
|
+
import { Buffer } from 'buffer';
|
|
8
9
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
9
10
|
const VERSION = 1;
|
|
10
11
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
+
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
3
|
+
/**
|
|
4
|
+
* The scope a fact collection belongs to.
|
|
5
|
+
*
|
|
6
|
+
* - `account`: only executions where `account` is in scope can access the collection.
|
|
7
|
+
* - `public`: shared by all accounts, so any execution of the owning contract can access the collection.
|
|
8
|
+
*/
|
|
9
|
+
export type FactScope = {
|
|
10
|
+
type: 'account';
|
|
11
|
+
account: AztecAddress;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'public';
|
|
14
|
+
};
|
|
15
|
+
/** Serializes a {@link FactScope} to its Noir `[kind, account]` field layout. */
|
|
16
|
+
export declare function factScopeToFields(scope: FactScope): Fr[];
|
|
17
|
+
/** Deserializes a {@link FactScope}, rejecting malformed values. */
|
|
18
|
+
export declare function factScopeFromFields(kind: number, account: Fr): FactScope;
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdF9zY29wZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvZmFjdF9zdG9yZS9mYWN0X3Njb3BlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUN6RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sa0NBQWtDLENBQUM7QUFFaEU7Ozs7O0dBS0c7QUFDSCxNQUFNLE1BQU0sU0FBUyxHQUFHO0lBQUUsSUFBSSxFQUFFLFNBQVMsQ0FBQztJQUFDLE9BQU8sRUFBRSxZQUFZLENBQUE7Q0FBRSxHQUFHO0lBQUUsSUFBSSxFQUFFLFFBQVEsQ0FBQTtDQUFFLENBQUM7QUFNeEYsaUZBQWlGO0FBQ2pGLHdCQUFnQixpQkFBaUIsQ0FBQyxLQUFLLEVBQUUsU0FBUyxHQUFHLEVBQUUsRUFBRSxDQU94RDtBQUVELG9FQUFvRTtBQUNwRSx3QkFBZ0IsbUJBQW1CLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxPQUFPLEVBQUUsRUFBRSxHQUFHLFNBQVMsQ0FZeEUifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fact_scope.d.ts","sourceRoot":"","sources":["../../../src/storage/fact_store/fact_scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,qCAAqC,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAMxF,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,CAOxD;AAED,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,SAAS,CAYxE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Fr } from '@aztec-labs/foundation/curves/bn254';
|
|
2
|
+
import { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
|
|
3
|
+
// Noir decodes these discriminants, so their values are part of the oracle interface.
|
|
4
|
+
const ACCOUNT = 1;
|
|
5
|
+
const PUBLIC = 2;
|
|
6
|
+
/** Serializes a {@link FactScope} to its Noir `[kind, account]` field layout. */ export function factScopeToFields(scope) {
|
|
7
|
+
switch(scope.type){
|
|
8
|
+
case 'account':
|
|
9
|
+
return [
|
|
10
|
+
new Fr(ACCOUNT),
|
|
11
|
+
scope.account.toField()
|
|
12
|
+
];
|
|
13
|
+
case 'public':
|
|
14
|
+
return [
|
|
15
|
+
new Fr(PUBLIC),
|
|
16
|
+
Fr.ZERO
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Deserializes a {@link FactScope}, rejecting malformed values. */ export function factScopeFromFields(kind, account) {
|
|
21
|
+
switch(kind){
|
|
22
|
+
case ACCOUNT:
|
|
23
|
+
return {
|
|
24
|
+
type: 'account',
|
|
25
|
+
account: AztecAddress.fromFieldUnsafe(account)
|
|
26
|
+
};
|
|
27
|
+
case PUBLIC:
|
|
28
|
+
if (!account.isZero()) {
|
|
29
|
+
throw new Error(`Public fact scope must not name an account, got ${account}`);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
type: 'public'
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Unrecognized fact scope kind: ${kind}`);
|
|
36
|
+
}
|
|
37
|
+
}
|