@aztec/pxe 0.65.2 → 0.67.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.
Files changed (97) hide show
  1. package/dest/bin/index.js +5 -6
  2. package/dest/config/index.d.ts +0 -9
  3. package/dest/config/index.d.ts.map +1 -1
  4. package/dest/config/index.js +1 -17
  5. package/dest/config/package_info.d.ts +5 -0
  6. package/dest/config/package_info.d.ts.map +1 -0
  7. package/dest/config/package_info.js +4 -0
  8. package/dest/contract_data_oracle/index.js +2 -2
  9. package/dest/database/incoming_note_dao.d.ts +1 -1
  10. package/dest/database/incoming_note_dao.d.ts.map +1 -1
  11. package/dest/database/incoming_note_dao.js +2 -2
  12. package/dest/database/kv_pxe_database.d.ts +10 -13
  13. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  14. package/dest/database/kv_pxe_database.js +153 -230
  15. package/dest/database/outgoing_note_dao.js +2 -2
  16. package/dest/database/pxe_database.d.ts +7 -25
  17. package/dest/database/pxe_database.d.ts.map +1 -1
  18. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  19. package/dest/database/pxe_database_test_suite.js +18 -59
  20. package/dest/index.d.ts +2 -0
  21. package/dest/index.d.ts.map +1 -1
  22. package/dest/index.js +3 -1
  23. package/dest/kernel_oracle/index.d.ts.map +1 -1
  24. package/dest/kernel_oracle/index.js +3 -3
  25. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts +1 -1
  26. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  27. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +13 -15
  28. package/dest/kernel_prover/index.d.ts +1 -0
  29. package/dest/kernel_prover/index.d.ts.map +1 -1
  30. package/dest/kernel_prover/index.js +2 -1
  31. package/dest/kernel_prover/kernel_prover.d.ts +1 -0
  32. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  33. package/dest/kernel_prover/kernel_prover.js +38 -4
  34. package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
  35. package/dest/kernel_prover/test/test_circuit_prover.js +4 -4
  36. package/dest/note_decryption_utils/add_public_values_to_payload.js +2 -2
  37. package/dest/note_decryption_utils/brute_force_note_info.d.ts +3 -3
  38. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -1
  39. package/dest/note_decryption_utils/brute_force_note_info.js +8 -8
  40. package/dest/note_decryption_utils/produce_note_daos.d.ts +3 -6
  41. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -1
  42. package/dest/note_decryption_utils/produce_note_daos.js +5 -19
  43. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +1 -1
  44. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -1
  45. package/dest/pxe_service/error_enriching.d.ts +3 -3
  46. package/dest/pxe_service/error_enriching.d.ts.map +1 -1
  47. package/dest/pxe_service/error_enriching.js +10 -10
  48. package/dest/pxe_service/index.d.ts +0 -1
  49. package/dest/pxe_service/index.d.ts.map +1 -1
  50. package/dest/pxe_service/index.js +1 -2
  51. package/dest/pxe_service/pxe_service.d.ts +4 -16
  52. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  53. package/dest/pxe_service/pxe_service.js +86 -101
  54. package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
  55. package/dest/pxe_service/test/pxe_test_suite.js +1 -3
  56. package/dest/simulator/index.d.ts +1 -1
  57. package/dest/simulator/index.d.ts.map +1 -1
  58. package/dest/simulator/index.js +2 -2
  59. package/dest/simulator_oracle/index.d.ts +7 -6
  60. package/dest/simulator_oracle/index.d.ts.map +1 -1
  61. package/dest/simulator_oracle/index.js +65 -44
  62. package/dest/synchronizer/synchronizer.d.ts +10 -40
  63. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  64. package/dest/synchronizer/synchronizer.js +35 -69
  65. package/dest/{pxe_service → utils}/create_pxe_service.d.ts +1 -1
  66. package/dest/utils/create_pxe_service.d.ts.map +1 -0
  67. package/dest/utils/create_pxe_service.js +49 -0
  68. package/package.json +31 -19
  69. package/src/bin/index.ts +4 -5
  70. package/src/config/index.ts +0 -21
  71. package/src/config/package_info.ts +3 -0
  72. package/src/contract_data_oracle/index.ts +1 -1
  73. package/src/database/incoming_note_dao.ts +2 -2
  74. package/src/database/kv_pxe_database.ts +212 -309
  75. package/src/database/outgoing_note_dao.ts +1 -1
  76. package/src/database/pxe_database.ts +7 -28
  77. package/src/database/pxe_database_test_suite.ts +20 -75
  78. package/src/index.ts +2 -0
  79. package/src/kernel_oracle/index.ts +2 -2
  80. package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +14 -16
  81. package/src/kernel_prover/index.ts +2 -0
  82. package/src/kernel_prover/kernel_prover.ts +61 -2
  83. package/src/kernel_prover/test/test_circuit_prover.ts +5 -3
  84. package/src/note_decryption_utils/add_public_values_to_payload.ts +1 -1
  85. package/src/note_decryption_utils/brute_force_note_info.ts +9 -9
  86. package/src/note_decryption_utils/produce_note_daos.ts +5 -48
  87. package/src/note_decryption_utils/produce_note_daos_for_key.ts +1 -1
  88. package/src/pxe_service/error_enriching.ts +14 -12
  89. package/src/pxe_service/index.ts +0 -1
  90. package/src/pxe_service/pxe_service.ts +137 -160
  91. package/src/pxe_service/test/pxe_test_suite.ts +0 -3
  92. package/src/simulator/index.ts +1 -1
  93. package/src/simulator_oracle/index.ts +71 -75
  94. package/src/synchronizer/synchronizer.ts +37 -77
  95. package/src/{pxe_service → utils}/create_pxe_service.ts +10 -10
  96. package/dest/pxe_service/create_pxe_service.d.ts.map +0 -1
  97. package/dest/pxe_service/create_pxe_service.js +0 -49
@@ -1,10 +1,9 @@
1
1
  import { type L1NotePayload, type PublicKey, type TxHash } from '@aztec/circuit-types';
2
2
  import { type Fr } from '@aztec/foundation/fields';
3
3
  import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator';
4
+ import { type AcirSimulator } from '@aztec/simulator/client';
5
5
 
6
6
  import { IncomingNoteDao } from '../database/incoming_note_dao.js';
7
- import { OutgoingNoteDao } from '../database/outgoing_note_dao.js';
8
7
  import { type PxeDatabase } from '../database/pxe_database.js';
9
8
  import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
10
9
 
@@ -17,7 +16,6 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
17
16
  * @param simulator - An instance of AcirSimulator.
18
17
  * @param db - An instance of PxeDatabase.
19
18
  * @param addressPoint - The public counterpart to the address secret, which is used in the decryption of incoming note logs.
20
- * @param ovpkM - The public counterpart to the secret key to be used in the decryption of outgoing note logs.
21
19
  * @param payload - An instance of l1NotePayload.
22
20
  * @param txHash - The hash of the transaction that created the note. Equivalent to the first nullifier of the transaction.
23
21
  * @param noteHashes - New note hashes in this transaction, one of which belongs to this note.
@@ -25,13 +23,12 @@ import { produceNoteDaosForKey } from './produce_note_daos_for_key.js';
25
23
  * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same l1NotePayload, we need to find a different index for each replicate.
26
24
  * @param logger - An instance of Logger.
27
25
  * @param unencryptedLogs - Unencrypted logs for the transaction (used to complete partial notes).
28
- * @returns An object containing the incoming, outgoing, and deferred notes.
26
+ * @returns An object containing the incoming notes.
29
27
  */
30
28
  export async function produceNoteDaos(
31
29
  simulator: AcirSimulator,
32
30
  db: PxeDatabase,
33
31
  addressPoint: PublicKey | undefined,
34
- ovpkM: PublicKey | undefined,
35
32
  payload: L1NotePayload,
36
33
  txHash: TxHash,
37
34
  l2BlockNumber: number,
@@ -40,16 +37,12 @@ export async function produceNoteDaos(
40
37
  dataStartIndexForTx: number,
41
38
  excludedIndices: Set<number>,
42
39
  logger: Logger,
43
- ): Promise<{
44
- incomingNote: IncomingNoteDao | undefined;
45
- outgoingNote: OutgoingNoteDao | undefined;
46
- }> {
47
- if (!addressPoint && !ovpkM) {
48
- throw new Error('Both addressPoint and ovpkM are undefined. Cannot create note.');
40
+ ): Promise<{ incomingNote: IncomingNoteDao | undefined }> {
41
+ if (!addressPoint) {
42
+ throw new Error('addressPoint is undefined. Cannot create note.');
49
43
  }
50
44
 
51
45
  let incomingNote: IncomingNoteDao | undefined;
52
- let outgoingNote: OutgoingNoteDao | undefined;
53
46
 
54
47
  if (addressPoint) {
55
48
  incomingNote = await produceNoteDaosForKey(
@@ -68,43 +61,7 @@ export async function produceNoteDaos(
68
61
  );
69
62
  }
70
63
 
71
- if (ovpkM) {
72
- if (incomingNote) {
73
- // Incoming note is defined meaning that this PXE has both the incoming and outgoing keys. We can skip computing
74
- // note hash and note index since we already have them in the incoming note.
75
- outgoingNote = new OutgoingNoteDao(
76
- incomingNote.note,
77
- incomingNote.contractAddress,
78
- incomingNote.storageSlot,
79
- incomingNote.noteTypeId,
80
- incomingNote.txHash,
81
- incomingNote.l2BlockNumber,
82
- incomingNote.l2BlockHash,
83
- incomingNote.nonce,
84
- incomingNote.noteHash,
85
- incomingNote.index,
86
- ovpkM,
87
- );
88
- } else {
89
- outgoingNote = await produceNoteDaosForKey(
90
- simulator,
91
- db,
92
- ovpkM,
93
- payload,
94
- txHash,
95
- l2BlockNumber,
96
- l2BlockHash,
97
- noteHashes,
98
- dataStartIndexForTx,
99
- excludedIndices,
100
- logger,
101
- OutgoingNoteDao.fromPayloadAndNoteInfo,
102
- );
103
- }
104
- }
105
-
106
64
  return {
107
65
  incomingNote,
108
- outgoingNote,
109
66
  };
110
67
  }
@@ -1,7 +1,7 @@
1
1
  import { type L1NotePayload, type Note, type TxHash } from '@aztec/circuit-types';
2
2
  import { type Fr, type PublicKey } from '@aztec/circuits.js';
3
3
  import { type Logger } from '@aztec/foundation/log';
4
- import { type AcirSimulator } from '@aztec/simulator';
4
+ import { type AcirSimulator } from '@aztec/simulator/client';
5
5
 
6
6
  import { type PxeDatabase } from '../database/pxe_database.js';
7
7
  import { getOrderedNoteItems } from './add_public_values_to_payload.js';
@@ -1,7 +1,7 @@
1
1
  import { type SimulationError, isNoirCallStackUnresolved } from '@aztec/circuit-types';
2
2
  import { AztecAddress, Fr, FunctionSelector, PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js';
3
- import { type DebugLogger } from '@aztec/foundation/log';
4
- import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@aztec/simulator';
3
+ import { type Logger } from '@aztec/foundation/log';
4
+ import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@aztec/simulator/errors';
5
5
 
6
6
  import { type ContractDataOracle, type PxeDatabase } from '../index.js';
7
7
 
@@ -10,27 +10,27 @@ import { type ContractDataOracle, type PxeDatabase } from '../index.js';
10
10
  * can be found in the PXE database
11
11
  * @param err - The error to enrich.
12
12
  */
13
- export async function enrichSimulationError(err: SimulationError, db: PxeDatabase, logger: DebugLogger) {
14
- // Maps contract addresses to the set of functions selectors that were in error.
13
+ export async function enrichSimulationError(err: SimulationError, db: PxeDatabase, logger: Logger) {
14
+ // Maps contract addresses to the set of function names that were in error.
15
15
  // Map and Set do reference equality for their keys instead of value equality, so we store the string
16
16
  // representation to get e.g. different contract address objects with the same address value to match.
17
17
  const mentionedFunctions: Map<string, Set<string>> = new Map();
18
18
 
19
- err.getCallStack().forEach(({ contractAddress, functionSelector }) => {
19
+ err.getCallStack().forEach(({ contractAddress, functionName }) => {
20
20
  if (!mentionedFunctions.has(contractAddress.toString())) {
21
21
  mentionedFunctions.set(contractAddress.toString(), new Set());
22
22
  }
23
- mentionedFunctions.get(contractAddress.toString())!.add(functionSelector.toString());
23
+ mentionedFunctions.get(contractAddress.toString())!.add(functionName?.toString() ?? '');
24
24
  });
25
25
 
26
26
  await Promise.all(
27
- [...mentionedFunctions.entries()].map(async ([contractAddress, selectors]) => {
27
+ [...mentionedFunctions.entries()].map(async ([contractAddress, fnNames]) => {
28
28
  const parsedContractAddress = AztecAddress.fromString(contractAddress);
29
29
  const contract = await db.getContract(parsedContractAddress);
30
30
  if (contract) {
31
31
  err.enrichWithContractName(parsedContractAddress, contract.name);
32
- selectors.forEach(selector => {
33
- const functionArtifact = contract.functions.find(f => FunctionSelector.fromString(selector).equals(f));
32
+ fnNames.forEach(fnName => {
33
+ const functionArtifact = contract.functions.find(f => fnName === f.name);
34
34
  if (functionArtifact) {
35
35
  err.enrichWithFunctionName(
36
36
  parsedContractAddress,
@@ -39,7 +39,7 @@ export async function enrichSimulationError(err: SimulationError, db: PxeDatabas
39
39
  );
40
40
  } else {
41
41
  logger.warn(
42
- `Could not function artifact in contract ${contract.name} for selector ${selector} when enriching error callstack`,
42
+ `Could not function artifact in contract ${contract.name} for function '${fnName}' when enriching error callstack`,
43
43
  );
44
44
  }
45
45
  });
@@ -56,7 +56,7 @@ export async function enrichPublicSimulationError(
56
56
  err: SimulationError,
57
57
  contractDataOracle: ContractDataOracle,
58
58
  db: PxeDatabase,
59
- logger: DebugLogger,
59
+ logger: Logger,
60
60
  ) {
61
61
  const callStack = err.getCallStack();
62
62
  const originalFailingFunction = callStack[callStack.length - 1];
@@ -89,7 +89,9 @@ export async function enrichPublicSimulationError(
89
89
  err.setNoirCallStack(parsedCallStack);
90
90
  } catch (err) {
91
91
  logger.warn(
92
- `Could not resolve noir call stack for ${originalFailingFunction.contractAddress.toString()}:${originalFailingFunction.functionSelector.toString()}: ${err}`,
92
+ `Could not resolve noir call stack for ${originalFailingFunction.contractAddress.toString()}:${
93
+ originalFailingFunction.functionName?.toString() ?? ''
94
+ }: ${err}`,
93
95
  );
94
96
  }
95
97
  }
@@ -1,4 +1,3 @@
1
1
  export * from './pxe_service.js';
2
- export * from './create_pxe_service.js';
3
2
  export { enrichPublicSimulationError } from './error_enriching.js';
4
3
  export { pxeTestSuite } from './test/pxe_test_suite.js';