@aztec/pxe 0.81.0 → 0.82.1-alpha-testnet.1

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.
Files changed (86) hide show
  1. package/dest/config/index.js +1 -1
  2. package/dest/config/package_info.js +1 -1
  3. package/dest/entrypoints/server/utils.d.ts +15 -7
  4. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  5. package/dest/entrypoints/server/utils.js +17 -9
  6. package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
  7. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -0
  8. package/dest/private_kernel/hints/index.d.ts.map +1 -0
  9. package/dest/private_kernel/index.d.ts +3 -0
  10. package/dest/private_kernel/index.d.ts.map +1 -0
  11. package/dest/private_kernel/index.js +2 -0
  12. package/dest/private_kernel/private_kernel_execution_prover.d.ts +36 -0
  13. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -0
  14. package/dest/{kernel_prover/kernel_prover.js → private_kernel/private_kernel_execution_prover.js} +67 -76
  15. package/dest/{kernel_prover/proving_data_oracle.d.ts → private_kernel/private_kernel_oracle.d.ts} +17 -28
  16. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -0
  17. package/dest/private_kernel/private_kernel_oracle.js +4 -0
  18. package/dest/{kernel_oracle/index.d.ts → private_kernel/private_kernel_oracle_impl.d.ts} +6 -6
  19. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -0
  20. package/dest/{kernel_oracle/index.js → private_kernel/private_kernel_oracle_impl.js} +13 -3
  21. package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts +7 -16
  22. package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
  23. package/dest/pxe_oracle_interface/pxe_oracle_interface.js +17 -32
  24. package/dest/pxe_service/error_enriching.d.ts.map +1 -1
  25. package/dest/pxe_service/error_enriching.js +5 -8
  26. package/dest/pxe_service/pxe_service.d.ts +13 -27
  27. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  28. package/dest/pxe_service/pxe_service.js +215 -239
  29. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +10 -44
  30. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  31. package/dest/storage/contract_data_provider/contract_data_provider.js +93 -68
  32. package/dest/storage/contract_data_provider/index.d.ts +0 -1
  33. package/dest/storage/contract_data_provider/index.d.ts.map +1 -1
  34. package/dest/storage/contract_data_provider/index.js +0 -1
  35. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +2 -41
  36. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  37. package/dest/storage/contract_data_provider/private_functions_tree.js +9 -61
  38. package/dest/storage/index.d.ts +1 -2
  39. package/dest/storage/index.d.ts.map +1 -1
  40. package/dest/storage/index.js +1 -2
  41. package/dest/storage/metadata.d.ts +2 -0
  42. package/dest/storage/metadata.d.ts.map +1 -0
  43. package/dest/storage/metadata.js +1 -0
  44. package/dest/test/pxe_test_suite.d.ts.map +1 -1
  45. package/dest/test/pxe_test_suite.js +1 -1
  46. package/package.json +15 -15
  47. package/src/config/index.ts +1 -1
  48. package/src/config/package_info.ts +1 -1
  49. package/src/entrypoints/server/utils.ts +25 -11
  50. package/src/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.ts +4 -4
  51. package/src/private_kernel/index.ts +2 -0
  52. package/src/{kernel_prover/kernel_prover.ts → private_kernel/private_kernel_execution_prover.ts} +80 -91
  53. package/src/{kernel_prover/proving_data_oracle.ts → private_kernel/private_kernel_oracle.ts} +17 -29
  54. package/src/{kernel_oracle/index.ts → private_kernel/private_kernel_oracle_impl.ts} +19 -6
  55. package/src/pxe_oracle_interface/pxe_oracle_interface.ts +31 -40
  56. package/src/pxe_service/error_enriching.ts +8 -14
  57. package/src/pxe_service/pxe_service.ts +289 -297
  58. package/src/storage/contract_data_provider/contract_data_provider.ts +114 -75
  59. package/src/storage/contract_data_provider/index.ts +0 -1
  60. package/src/storage/contract_data_provider/private_functions_tree.ts +11 -75
  61. package/src/storage/index.ts +1 -3
  62. package/src/storage/metadata.ts +1 -0
  63. package/src/test/pxe_test_suite.ts +3 -1
  64. package/dest/kernel_oracle/index.d.ts.map +0 -1
  65. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  66. package/dest/kernel_prover/hints/index.d.ts.map +0 -1
  67. package/dest/kernel_prover/index.d.ts +0 -3
  68. package/dest/kernel_prover/index.d.ts.map +0 -1
  69. package/dest/kernel_prover/index.js +0 -2
  70. package/dest/kernel_prover/kernel_prover.d.ts +0 -38
  71. package/dest/kernel_prover/kernel_prover.d.ts.map +0 -1
  72. package/dest/kernel_prover/proving_data_oracle.d.ts.map +0 -1
  73. package/dest/kernel_prover/proving_data_oracle.js +0 -4
  74. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts +0 -11
  75. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.d.ts.map +0 -1
  76. package/dest/storage/auth_witness_data_provider/auth_witness_data_provider.js +0 -20
  77. package/dest/storage/auth_witness_data_provider/index.d.ts +0 -2
  78. package/dest/storage/auth_witness_data_provider/index.d.ts.map +0 -1
  79. package/dest/storage/auth_witness_data_provider/index.js +0 -1
  80. package/src/kernel_prover/index.ts +0 -2
  81. package/src/storage/auth_witness_data_provider/auth_witness_data_provider.ts +0 -34
  82. package/src/storage/auth_witness_data_provider/index.ts +0 -1
  83. /package/dest/{kernel_prover → private_kernel}/hints/build_private_kernel_reset_private_inputs.js +0 -0
  84. /package/dest/{kernel_prover → private_kernel}/hints/index.d.ts +0 -0
  85. /package/dest/{kernel_prover → private_kernel}/hints/index.js +0 -0
  86. /package/src/{kernel_prover → private_kernel}/hints/index.ts +0 -0
@@ -12,6 +12,7 @@ import {
12
12
  } from '@aztec/simulator/client';
13
13
  import {
14
14
  type FunctionArtifact,
15
+ type FunctionArtifactWithContractName,
15
16
  FunctionCall,
16
17
  FunctionSelector,
17
18
  FunctionType,
@@ -33,7 +34,6 @@ import type { BlockHeader } from '@aztec/stdlib/tx';
33
34
  import { TxHash } from '@aztec/stdlib/tx';
34
35
 
35
36
  import type { AddressDataProvider } from '../storage/address_data_provider/address_data_provider.js';
36
- import type { AuthWitnessDataProvider } from '../storage/auth_witness_data_provider/auth_witness_data_provider.js';
37
37
  import type { CapsuleDataProvider } from '../storage/capsule_data_provider/capsule_data_provider.js';
38
38
  import type { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
39
39
  import { NoteDao } from '../storage/note_data_provider/note_dao.js';
@@ -56,8 +56,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
56
56
  private syncDataProvider: SyncDataProvider,
57
57
  private taggingDataProvider: TaggingDataProvider,
58
58
  private addressDataProvider: AddressDataProvider,
59
- private authWitnessDataProvider: AuthWitnessDataProvider,
60
- private log = createLogger('pxe:pxe_data_manager'),
59
+ private log = createLogger('pxe:pxe_oracle_interface'),
61
60
  ) {}
62
61
 
63
62
  getKeyValidationRequest(pkMHash: Fr, contractAddress: AztecAddress): Promise<KeyValidationRequest> {
@@ -83,11 +82,6 @@ export class PXEOracleInterface implements ExecutionDataProvider {
83
82
  return instance;
84
83
  }
85
84
 
86
- async getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
87
- const witness = await this.authWitnessDataProvider.getAuthWitness(messageHash);
88
- return witness;
89
- }
90
-
91
85
  async getNotes(contractAddress: AztecAddress, storageSlot: Fr, status: NoteStatus, scopes?: AztecAddress[]) {
92
86
  const noteDaos = await this.noteDataProvider.getNotes({
93
87
  contractAddress,
@@ -107,8 +101,14 @@ export class PXEOracleInterface implements ExecutionDataProvider {
107
101
  }));
108
102
  }
109
103
 
110
- async getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifact> {
104
+ async getFunctionArtifact(
105
+ contractAddress: AztecAddress,
106
+ selector: FunctionSelector,
107
+ ): Promise<FunctionArtifactWithContractName> {
111
108
  const artifact = await this.contractDataProvider.getFunctionArtifact(contractAddress, selector);
109
+ if (!artifact) {
110
+ throw new Error(`Function artifact not found for contract ${contractAddress} and selector ${selector}.`);
111
+ }
112
112
  const debug = await this.contractDataProvider.getFunctionDebugMetadata(contractAddress, selector);
113
113
  return {
114
114
  ...artifact,
@@ -119,8 +119,11 @@ export class PXEOracleInterface implements ExecutionDataProvider {
119
119
  async getFunctionArtifactByName(
120
120
  contractAddress: AztecAddress,
121
121
  functionName: string,
122
- ): Promise<FunctionArtifact | undefined> {
122
+ ): Promise<FunctionArtifactWithContractName | undefined> {
123
123
  const instance = await this.contractDataProvider.getContractInstance(contractAddress);
124
+ if (!instance) {
125
+ return;
126
+ }
124
127
  const artifact = await this.contractDataProvider.getContractArtifact(instance.currentContractClassId);
125
128
  return artifact && getFunctionArtifact(artifact, functionName);
126
129
  }
@@ -150,21 +153,12 @@ export class PXEOracleInterface implements ExecutionDataProvider {
150
153
  }
151
154
 
152
155
  // Only used in public.
153
- public getL1ToL2LeafValue(_leafIndex: bigint): Promise<Fr | undefined> {
156
+ public getL1ToL2MessageHash(_leafIndex: bigint): Promise<Fr | undefined> {
154
157
  throw new Error('Unimplemented in private!');
155
158
  }
156
159
 
157
- /**
158
- * Gets the index of a commitment in the note hash tree.
159
- * @param commitment - The commitment.
160
- * @returns - The index of the commitment. Undefined if it does not exist in the tree.
161
- */
162
- async getCommitmentIndex(commitment: Fr) {
163
- return await this.#findLeafIndex('latest', MerkleTreeId.NOTE_HASH_TREE, commitment);
164
- }
165
-
166
160
  // We need this in public as part of the EXISTS calls - but isn't used in private
167
- public getCommitmentValue(_leafIndex: bigint): Promise<Fr | undefined> {
161
+ public getNoteHash(_leafIndex: bigint): Promise<Fr | undefined> {
168
162
  throw new Error('Unimplemented in private!');
169
163
  }
170
164
 
@@ -174,7 +168,7 @@ export class PXEOracleInterface implements ExecutionDataProvider {
174
168
 
175
169
  async #findLeafIndex(blockNumber: L2BlockNumber, treeId: MerkleTreeId, leafValue: Fr): Promise<bigint | undefined> {
176
170
  const [leafIndex] = await this.aztecNode.findLeavesIndexes(blockNumber, treeId, [leafValue]);
177
- return leafIndex;
171
+ return leafIndex?.data;
178
172
  }
179
173
 
180
174
  public async getMembershipWitness(blockNumber: number, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[]> {
@@ -225,8 +219,8 @@ export class PXEOracleInterface implements ExecutionDataProvider {
225
219
  return await this.aztecNode.getBlock(blockNumber);
226
220
  }
227
221
 
228
- public async getPublicDataTreeWitness(blockNumber: number, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
229
- return await this.aztecNode.getPublicDataTreeWitness(blockNumber, leafSlot);
222
+ public async getPublicDataWitness(blockNumber: number, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
223
+ return await this.aztecNode.getPublicDataWitness(blockNumber, leafSlot);
230
224
  }
231
225
 
232
226
  public async getPublicStorageAt(blockNumber: number, contract: AztecAddress, slot: Fr): Promise<Fr> {
@@ -667,26 +661,17 @@ export class PXEOracleInterface implements ExecutionDataProvider {
667
661
 
668
662
  // We store notes by their index in the global note hash tree, which has the convenient side effect of validating
669
663
  // note existence in said tree.
670
- const [uniqueNoteHashTreeIndex] = await this.aztecNode.findLeavesIndexes(
664
+ const [uniqueNoteHashTreeIndexInBlock] = await this.aztecNode.findLeavesIndexes(
671
665
  syncedBlockNumber,
672
666
  MerkleTreeId.NOTE_HASH_TREE,
673
667
  [uniqueNoteHash],
674
668
  );
675
- if (uniqueNoteHashTreeIndex === undefined) {
669
+ if (uniqueNoteHashTreeIndexInBlock === undefined) {
676
670
  throw new Error(
677
671
  `Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`,
678
672
  );
679
673
  }
680
674
 
681
- // TODO (#12550): findLeavesIndexes should probably return an InBlock, same as findNullifiersIndexesWithBlock. This
682
- // would save us from having to then query the tx receipt in order to get the block hash and number. Note regardless
683
- // that we're not validating that the note was indeed created in this tx (which would require inspecting the tx
684
- // effects), so maybe what we really want is an InTx.
685
- const txReceipt = await this.aztecNode.getTxReceipt(new TxHash(txHash));
686
- if (txReceipt === undefined) {
687
- throw new Error(`Failed to fetch tx receipt for tx hash ${txHash} when searching for note hashes`);
688
- }
689
-
690
675
  const noteDao = new NoteDao(
691
676
  new Note(content),
692
677
  contractAddress,
@@ -695,9 +680,9 @@ export class PXEOracleInterface implements ExecutionDataProvider {
695
680
  noteHash,
696
681
  siloedNullifier,
697
682
  new TxHash(txHash),
698
- txReceipt.blockNumber!,
699
- txReceipt.blockHash!.toString(),
700
- uniqueNoteHashTreeIndex,
683
+ uniqueNoteHashTreeIndexInBlock?.l2BlockNumber,
684
+ uniqueNoteHashTreeIndexInBlock?.l2BlockHash,
685
+ uniqueNoteHashTreeIndexInBlock?.data,
701
686
  recipient,
702
687
  );
703
688
 
@@ -709,7 +694,9 @@ export class PXEOracleInterface implements ExecutionDataProvider {
709
694
  nullifier: noteDao.siloedNullifier.toString(),
710
695
  });
711
696
 
712
- const [nullifierIndex] = await this.aztecNode.findNullifiersIndexesWithBlock(syncedBlockNumber, [siloedNullifier]);
697
+ const [nullifierIndex] = await this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
698
+ siloedNullifier,
699
+ ]);
713
700
  if (nullifierIndex !== undefined) {
714
701
  const { data: _, ...blockHashAndNum } = nullifierIndex;
715
702
  await this.noteDataProvider.removeNullifiedNotes([{ data: siloedNullifier, ...blockHashAndNum }], recipient);
@@ -766,7 +753,11 @@ export class PXEOracleInterface implements ExecutionDataProvider {
766
753
  for (const recipient of await this.keyStore.getAccounts()) {
767
754
  const currentNotesForRecipient = await this.noteDataProvider.getNotes({ contractAddress, recipient });
768
755
  const nullifiersToCheck = currentNotesForRecipient.map(note => note.siloedNullifier);
769
- const nullifierIndexes = await this.aztecNode.findNullifiersIndexesWithBlock('latest', nullifiersToCheck);
756
+ const nullifierIndexes = await this.aztecNode.findLeavesIndexes(
757
+ 'latest',
758
+ MerkleTreeId.NULLIFIER_TREE,
759
+ nullifiersToCheck,
760
+ );
770
761
 
771
762
  const foundNullifiers = nullifiersToCheck
772
763
  .map((nullifier, i) => {
@@ -1,5 +1,3 @@
1
- import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
3
1
  import type { Logger } from '@aztec/foundation/log';
4
2
  import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@aztec/simulator/client';
5
3
  import { FunctionSelector } from '@aztec/stdlib/abi';
@@ -66,24 +64,20 @@ export async function enrichPublicSimulationError(
66
64
  ) {
67
65
  const callStack = err.getCallStack();
68
66
  const originalFailingFunction = callStack[callStack.length - 1];
69
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Properly fix this.
70
- // To be able to resolve the assertion message, we need to use the information from the public dispatch function,
71
- // no matter what the call stack selector points to (since we've modified it to point to the target function).
72
- // We should remove this because the AVM (or public protocol) shouldn't be aware of the public dispatch calling convention.
73
67
 
74
- const artifact = await contractDataProvider.getFunctionArtifact(
75
- originalFailingFunction.contractAddress,
76
- FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
77
- );
68
+ const artifact = await contractDataProvider.getPublicFunctionArtifact(originalFailingFunction.contractAddress);
69
+ if (!artifact) {
70
+ throw new Error(
71
+ `Artifact not found when enriching public simulation error. Contract address: ${originalFailingFunction.contractAddress}.`,
72
+ );
73
+ }
74
+
78
75
  const assertionMessage = resolveAssertionMessageFromRevertData(err.revertData, artifact);
79
76
  if (assertionMessage) {
80
77
  err.setOriginalMessage(err.getOriginalMessage() + `${assertionMessage}`);
81
78
  }
82
79
 
83
- const debugInfo = await contractDataProvider.getFunctionDebugMetadata(
84
- originalFailingFunction.contractAddress,
85
- FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
86
- );
80
+ const debugInfo = await contractDataProvider.getPublicFunctionDebugMetadata(originalFailingFunction.contractAddress);
87
81
 
88
82
  const noirCallStack = err.getNoirCallStack();
89
83
  if (debugInfo) {