@aztec/pxe 0.0.1-commit.3469e52 → 0.0.1-commit.59e663cd

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 (127) hide show
  1. package/dest/bin/check_oracle_version.js +1 -1
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +6 -4
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +53 -13
  5. package/dest/config/index.d.ts +3 -1
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +17 -0
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +1 -4
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  12. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  13. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  14. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  15. package/dest/contract_function_simulator/oracle/interfaces.d.ts +13 -10
  16. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -3
  18. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/oracle/oracle.js +27 -17
  20. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  21. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
  23. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +9 -1
  24. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +16 -5
  26. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -12
  27. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +34 -36
  29. package/dest/contract_sync/index.d.ts +23 -0
  30. package/dest/contract_sync/index.d.ts.map +1 -0
  31. package/dest/contract_sync/index.js +54 -0
  32. package/dest/debug/pxe_debug_utils.d.ts +16 -6
  33. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  34. package/dest/debug/pxe_debug_utils.js +20 -10
  35. package/dest/entrypoints/server/index.d.ts +2 -1
  36. package/dest/entrypoints/server/index.d.ts.map +1 -1
  37. package/dest/entrypoints/server/index.js +1 -0
  38. package/dest/events/event_service.d.ts +2 -2
  39. package/dest/events/event_service.d.ts.map +1 -1
  40. package/dest/events/event_service.js +1 -1
  41. package/dest/logs/log_service.d.ts +1 -1
  42. package/dest/logs/log_service.d.ts.map +1 -1
  43. package/dest/logs/log_service.js +17 -11
  44. package/dest/notes/note_service.d.ts +4 -3
  45. package/dest/notes/note_service.d.ts.map +1 -1
  46. package/dest/notes/note_service.js +11 -10
  47. package/dest/oracle_version.d.ts +3 -3
  48. package/dest/oracle_version.d.ts.map +1 -1
  49. package/dest/oracle_version.js +4 -3
  50. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -3
  51. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  52. package/dest/pxe.d.ts +1 -1
  53. package/dest/pxe.d.ts.map +1 -1
  54. package/dest/pxe.js +13 -11
  55. package/dest/storage/contract_store/contract_store.d.ts +1 -2
  56. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  57. package/dest/storage/contract_store/contract_store.js +0 -12
  58. package/dest/storage/note_store/note_store.d.ts +43 -55
  59. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  60. package/dest/storage/note_store/note_store.js +238 -252
  61. package/dest/storage/note_store/stored_note.d.ts +16 -0
  62. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  63. package/dest/storage/note_store/stored_note.js +43 -0
  64. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  65. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  66. package/dest/storage/private_event_store/private_event_store.js +163 -135
  67. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  68. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  69. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  70. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  71. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  72. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  73. package/dest/tagging/index.d.ts +2 -1
  74. package/dest/tagging/index.d.ts.map +1 -1
  75. package/dest/tagging/index.js +1 -0
  76. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
  77. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  78. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +2 -2
  79. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
  80. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  81. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
  82. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
  83. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  84. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +2 -2
  85. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  86. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  87. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  88. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +3 -2
  89. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  90. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +7 -4
  91. package/package.json +16 -16
  92. package/src/bin/check_oracle_version.ts +1 -0
  93. package/src/block_synchronizer/block_synchronizer.ts +55 -21
  94. package/src/config/index.ts +14 -0
  95. package/src/contract_function_simulator/contract_function_simulator.ts +1 -9
  96. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  97. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  98. package/src/contract_function_simulator/oracle/interfaces.ts +18 -9
  99. package/src/contract_function_simulator/oracle/oracle.ts +34 -21
  100. package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
  101. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -6
  102. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +53 -45
  103. package/src/contract_sync/index.ts +98 -0
  104. package/src/debug/pxe_debug_utils.ts +26 -11
  105. package/src/entrypoints/server/index.ts +1 -0
  106. package/src/events/event_service.ts +1 -1
  107. package/src/logs/log_service.ts +24 -8
  108. package/src/notes/note_service.ts +18 -15
  109. package/src/oracle_version.ts +4 -3
  110. package/src/private_kernel/private_kernel_oracle.ts +2 -2
  111. package/src/pxe.ts +35 -12
  112. package/src/storage/contract_store/contract_store.ts +0 -20
  113. package/src/storage/note_store/note_store.ts +279 -313
  114. package/src/storage/note_store/stored_note.ts +48 -0
  115. package/src/storage/private_event_store/private_event_store.ts +214 -175
  116. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  117. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  118. package/src/tagging/index.ts +1 -0
  119. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +11 -1
  120. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
  121. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +3 -1
  122. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
  123. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +12 -3
  124. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  125. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  126. package/dest/tree_membership/tree_membership_service.js +0 -75
  127. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -1 +1 @@
1
- {"version":3,"file":"load_private_logs_for_sender_recipient_pair.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAKpG;;;;;;GAMG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,qBAAqB,EACnC,iBAAiB,EAAE,WAAW,EAC9B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,EAAE,CAAC,CA4G1B"}
1
+ {"version":3,"file":"load_private_logs_for_sender_recipient_pair.d.ts","sourceRoot":"","sources":["../../../src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAKpG;;;;;;GAMG;AACH,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,qBAAqB,EACnC,iBAAiB,EAAE,WAAW,EAC9B,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,EAAE,CAAC,CAoH1B"}
@@ -7,7 +7,7 @@ import { loadLogsForRange } from './utils/load_logs_for_range.js';
7
7
  *
8
8
  * @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
9
9
  * in the tagging data provider is indexed by the secret and hence completely disjoint.
10
- */ export async function loadPrivateLogsForSenderRecipientPair(secret, app, aztecNode, taggingStore, anchorBlockNumber, jobId) {
10
+ */ export async function loadPrivateLogsForSenderRecipientPair(secret, app, aztecNode, taggingStore, anchorBlockNumber, anchorBlockHash, jobId) {
11
11
  // # Explanation of how the algorithm works
12
12
  // When we perform the sync we will look at logs that correspond to the tagging index range
13
13
  // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
@@ -72,7 +72,7 @@ import { loadLogsForRange } from './utils/load_logs_for_range.js';
72
72
  const logs = [];
73
73
  while(true){
74
74
  // Get private logs with their block timestamps and corresponding tagging indexes
75
- const privateLogsWithIndexes = await loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber);
75
+ const privateLogsWithIndexes = await loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber, anchorBlockHash);
76
76
  if (privateLogsWithIndexes.length === 0) {
77
77
  break;
78
78
  }
@@ -1,5 +1,6 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { BlockHash } from '@aztec/stdlib/block';
3
4
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
5
  import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
6
  /**
@@ -7,8 +8,8 @@ import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/l
7
8
  * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
8
9
  * exclusive.
9
10
  */
10
- export declare function loadLogsForRange(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, start: number, end: number, anchorBlockNumber: BlockNumber): Promise<Array<{
11
+ export declare function loadLogsForRange(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, start: number, end: number, anchorBlockNumber: BlockNumber, anchorBlockHash: BlockHash): Promise<Array<{
11
12
  log: TxScopedL2Log;
12
13
  taggingIndex: number;
13
14
  }>>;
14
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9sb2dzX2Zvcl9yYW5nZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvdXRpbHMvbG9hZF9sb2dzX2Zvcl9yYW5nZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUc3Rjs7OztHQUlHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUNwQyxNQUFNLEVBQUUsMkJBQTJCLEVBQ25DLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxpQkFBaUIsRUFBRSxXQUFXLEdBQzdCLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDO0lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsQ0FBQyxDQXdCOUQifQ==
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9sb2dzX2Zvcl9yYW5nZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvcmVjaXBpZW50X3N5bmMvdXRpbHMvbG9hZF9sb2dzX2Zvcl9yYW5nZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNuRSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxhQUFhLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUs3Rjs7OztHQUlHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUNwQyxNQUFNLEVBQUUsMkJBQTJCLEVBQ25DLEdBQUcsRUFBRSxZQUFZLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLEtBQUssRUFBRSxNQUFNLEVBQ2IsR0FBRyxFQUFFLE1BQU0sRUFDWCxpQkFBaUIsRUFBRSxXQUFXLEVBQzlCLGVBQWUsRUFBRSxTQUFTLEdBQ3pCLE9BQU8sQ0FBQyxLQUFLLENBQUM7SUFBRSxHQUFHLEVBQUUsYUFBYSxDQUFDO0lBQUMsWUFBWSxFQUFFLE1BQU0sQ0FBQTtDQUFFLENBQUMsQ0FBQyxDQTBCOUQifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"load_logs_for_range.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/load_logs_for_range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAG7F;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,WAAW,GAC7B,OAAO,CAAC,KAAK,CAAC;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAwB9D"}
1
+ {"version":3,"file":"load_logs_for_range.d.ts","sourceRoot":"","sources":["../../../../src/tagging/recipient_sync/utils/load_logs_for_range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK7F;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,WAAW,EAC9B,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,KAAK,CAAC;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CA0B9D"}
@@ -1,16 +1,19 @@
1
1
  import { SiloedTag, Tag } from '@aztec/stdlib/logs';
2
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
2
3
  /**
3
4
  * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
4
5
  * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
5
6
  * exclusive.
6
- */ export async function loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber) {
7
+ */ export async function loadLogsForRange(secret, app, aztecNode, start, end, anchorBlockNumber, anchorBlockHash) {
7
8
  // Derive tags for the window
8
9
  const preTags = Array(end - start).fill(0).map((_, i)=>({
9
10
  secret,
10
11
  index: start + i
11
12
  }));
12
13
  const siloedTags = await Promise.all(preTags.map((preTag)=>Tag.compute(preTag))).then((tags)=>Promise.all(tags.map((tag)=>SiloedTag.compute(tag, app))));
13
- const logs = await aztecNode.getPrivateLogsByTags(siloedTags);
14
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
15
+ // pagination here.
16
+ const logs = await getAllPrivateLogsByTags(aztecNode, siloedTags, anchorBlockHash);
14
17
  // Pair logs with their corresponding tagging indexes
15
18
  const logsWithIndexes = [];
16
19
  for(let i = 0; i < logs.length; i++){
@@ -1,4 +1,5 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
2
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
4
  import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
5
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
@@ -16,5 +17,5 @@ import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagg
16
17
  * @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
17
18
  * updates its status accordingly.
18
19
  */
19
- export declare function syncSenderTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, taggingStore: SenderTaggingStore, jobId: string): Promise<void>;
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7Ozs7O0dBYUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSwyQkFBMkIsRUFDbkMsR0FBRyxFQUFFLFlBQVksRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FtRWYifQ==
20
+ export declare function syncSenderTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3luY19zZW5kZXJfdGFnZ2luZ19pbmRleGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGFnZ2luZy9zZW5kZXJfc3luYy9zeW5jX3NlbmRlcl90YWdnaW5nX2luZGV4ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDckQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHFEQUFxRCxDQUFDO0FBSzlGOzs7Ozs7Ozs7Ozs7O0dBYUc7QUFDSCx3QkFBc0Isd0JBQXdCLENBQzVDLE1BQU0sRUFBRSwyQkFBMkIsRUFDbkMsR0FBRyxFQUFFLFlBQVksRUFDakIsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxHQUNaLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FtRWYifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;;;;GAaG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}
1
+ {"version":3,"file":"sync_sender_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../src/tagging/sender_sync/sync_sender_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAK9F;;;;;;;;;;;;;GAaG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}
@@ -14,7 +14,7 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
14
14
  * is simply the highest pending index plus one (or finalized if pending is undefined).
15
15
  * @dev This function looks for new indexes, adds them to pending, then it checks status of each pending index and
16
16
  * updates its status accordingly.
17
- */ export async function syncSenderTaggingIndexes(secret, app, aztecNode, taggingStore, jobId) {
17
+ */ export async function syncSenderTaggingIndexes(secret, app, aztecNode, taggingStore, anchorBlockHash, jobId) {
18
18
  // # Explanation of how syncing works
19
19
  //
20
20
  // When choosing an index, we select: highest pending index + 1 (or highest finalized index + 1 if no pending).
@@ -40,7 +40,7 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
40
40
  while(true){
41
41
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
42
42
  // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
43
- await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, jobId);
43
+ await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
44
44
  // Retrieve all indexes within the current window from storage and update their status accordingly.
45
45
  const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
46
46
  if (pendingTxHashes.length === 0) {
@@ -8,4 +8,4 @@ export declare function getStatusChangeOfPending(pending: TxHash[], aztecNode: A
8
8
  txHashesToFinalize: TxHash[];
9
9
  txHashesToDrop: TxHash[];
10
10
  }>;
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUFFLGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQUMsY0FBYyxFQUFFLE1BQU0sRUFBRSxDQUFBO0NBQUUsQ0FBQyxDQXFDckUifQ==
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvZ2V0X3N0YXR1c19jaGFuZ2Vfb2ZfcGVuZGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsTUFBTSxFQUFZLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQ7OztHQUdHO0FBQ0gsd0JBQXNCLHdCQUF3QixDQUM1QyxPQUFPLEVBQUUsTUFBTSxFQUFFLEVBQ2pCLFNBQVMsRUFBRSxTQUFTLEdBQ25CLE9BQU8sQ0FBQztJQUFFLGtCQUFrQixFQUFFLE1BQU0sRUFBRSxDQUFDO0lBQUMsY0FBYyxFQUFFLE1BQU0sRUFBRSxDQUFBO0NBQUUsQ0FBQyxDQXlCckUifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAqCrE"}
1
+ {"version":3,"file":"get_status_change_of_pending.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/get_status_change_of_pending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAY,MAAM,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC;IAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAyBrE"}
@@ -3,26 +3,23 @@ import { TxStatus } from '@aztec/stdlib/tx';
3
3
  * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
4
4
  * dropped.
5
5
  */ export async function getStatusChangeOfPending(pending, aztecNode) {
6
- // Get receipts for all pending tx hashes and the finalized block number.
7
- const [receipts, tips] = await Promise.all([
8
- Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash))),
9
- aztecNode.getL2Tips()
10
- ]);
6
+ // Get receipts for all pending tx hashes.
7
+ const receipts = await Promise.all(pending.map((pendingTxHash)=>aztecNode.getTxReceipt(pendingTxHash)));
11
8
  const txHashesToFinalize = [];
12
9
  const txHashesToDrop = [];
13
10
  for(let i = 0; i < receipts.length; i++){
14
11
  const receipt = receipts[i];
15
12
  const txHash = pending[i];
16
- if (receipt.status === TxStatus.SUCCESS && receipt.blockNumber && receipt.blockNumber <= tips.finalized.block.number) {
13
+ if (receipt.status === TxStatus.FINALIZED && receipt.hasExecutionSucceeded()) {
17
14
  // Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
18
15
  // finalized.
19
16
  txHashesToFinalize.push(txHash);
20
- } else if (receipt.status === TxStatus.DROPPED || receipt.status === TxStatus.APP_LOGIC_REVERTED || receipt.status === TxStatus.TEARDOWN_REVERTED || receipt.status === TxStatus.BOTH_REVERTED) {
17
+ } else if (receipt.isDropped() || receipt.hasExecutionReverted()) {
21
18
  // Tx was dropped or reverted --> we drop the corresponding pending indexes.
22
19
  // TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
23
20
  txHashesToDrop.push(txHash);
24
21
  } else {
25
- // Tx is still pending or the corresponding block is not yet finalized --> we don't do anything.
22
+ // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
26
23
  }
27
24
  }
28
25
  return {
@@ -1,4 +1,5 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
+ import type { BlockHash } from '@aztec/stdlib/block';
2
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
3
4
  import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
5
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
@@ -16,5 +17,5 @@ import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_t
16
17
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
17
18
  * preserving way.
18
19
  */
19
- export declare function loadAndStoreNewTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, jobId: string): Promise<void>;
20
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFFakc7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILHdCQUFzQiw2QkFBNkIsQ0FDakQsTUFBTSxFQUFFLDJCQUEyQixFQUNuQyxHQUFHLEVBQUUsWUFBWSxFQUNqQixLQUFLLEVBQUUsTUFBTSxFQUNiLEdBQUcsRUFBRSxNQUFNLEVBQ1gsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxLQUFLLEVBQUUsTUFBTSxpQkFrQmQifQ==
20
+ export declare function loadAndStoreNewTaggingIndexes(secret: DirectionalAppTaggingSecret, app: AztecAddress, start: number, end: number, aztecNode: AztecNode, taggingStore: SenderTaggingStore, anchorBlockHash: BlockHash, jobId: string): Promise<void>;
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL3RhZ2dpbmcvc2VuZGVyX3N5bmMvdXRpbHMvbG9hZF9hbmRfc3RvcmVfbmV3X3RhZ2dpbmdfaW5kZXhlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBVSxNQUFNLG9CQUFvQixDQUFDO0FBSTlFLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0RBQXdELENBQUM7QUFHakc7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILHdCQUFzQiw2QkFBNkIsQ0FDakQsTUFBTSxFQUFFLDJCQUEyQixFQUNuQyxHQUFHLEVBQUUsWUFBWSxFQUNqQixLQUFLLEVBQUUsTUFBTSxFQUNiLEdBQUcsRUFBRSxNQUFNLEVBQ1gsU0FBUyxFQUFFLFNBQVMsRUFDcEIsWUFBWSxFQUFFLGtCQUFrQixFQUNoQyxlQUFlLEVBQUUsU0FBUyxFQUMxQixLQUFLLEVBQUUsTUFBTSxpQkFrQmQifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAEjG;;;;;;;;;;;;;GAaG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,KAAK,EAAE,MAAM,iBAkBd"}
1
+ {"version":3,"file":"load_and_store_new_tagging_indexes.d.ts","sourceRoot":"","sources":["../../../../src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAU,MAAM,oBAAoB,CAAC;AAI9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAGjG;;;;;;;;;;;;;GAaG;AACH,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,2BAA2B,EACnC,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,kBAAkB,EAChC,eAAe,EAAE,SAAS,EAC1B,KAAK,EAAE,MAAM,iBAkBd"}
@@ -1,5 +1,6 @@
1
1
  import { SiloedTag, Tag } from '@aztec/stdlib/logs';
2
2
  import { TxHash } from '@aztec/stdlib/tx';
3
+ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
3
4
  /**
4
5
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
5
6
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
@@ -13,14 +14,14 @@ import { TxHash } from '@aztec/stdlib/tx';
13
14
  * @param taggingStore - The data provider to store pending indexes.
14
15
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
15
16
  * preserving way.
16
- */ export async function loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, jobId) {
17
+ */ export async function loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId) {
17
18
  // We compute the tags for the current window of indexes
18
19
  const preTagsForWindow = Array(end - start).fill(0).map((_, i)=>({
19
20
  secret,
20
21
  index: start + i
21
22
  }));
22
23
  const siloedTagsForWindow = await Promise.all(preTagsForWindow.map(async (preTag)=>SiloedTag.compute(await Tag.compute(preTag), app)));
23
- const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode);
24
+ const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
24
25
  const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
25
26
  // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
26
27
  for (const [txHashStr, highestIndex] of highestIndexMap.entries()){
@@ -35,8 +36,10 @@ import { TxHash } from '@aztec/stdlib/tx';
35
36
  }
36
37
  // Returns txs that used the given tags. A tag might have been used in multiple txs and for this reason we return
37
38
  // an array for each tag.
38
- async function getTxsContainingTags(tags, aztecNode) {
39
- const allLogs = await aztecNode.getPrivateLogsByTags(tags);
39
+ async function getTxsContainingTags(tags, aztecNode, anchorBlockHash) {
40
+ // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
41
+ // pagination here.
42
+ const allLogs = await getAllPrivateLogsByTags(aztecNode, tags, anchorBlockHash);
40
43
  return allLogs.map((logs)=>logs.map((log)=>log.txHash));
41
44
  }
42
45
  // Returns a map of txHash to the highest index for that txHash.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/pxe",
3
- "version": "0.0.1-commit.3469e52",
3
+ "version": "0.0.1-commit.59e663cd",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./server": "./dest/entrypoints/server/index.js",
@@ -61,19 +61,19 @@
61
61
  ]
62
62
  },
63
63
  "dependencies": {
64
- "@aztec/bb-prover": "0.0.1-commit.3469e52",
65
- "@aztec/bb.js": "0.0.1-commit.3469e52",
66
- "@aztec/builder": "0.0.1-commit.3469e52",
67
- "@aztec/constants": "0.0.1-commit.3469e52",
68
- "@aztec/ethereum": "0.0.1-commit.3469e52",
69
- "@aztec/foundation": "0.0.1-commit.3469e52",
70
- "@aztec/key-store": "0.0.1-commit.3469e52",
71
- "@aztec/kv-store": "0.0.1-commit.3469e52",
72
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.3469e52",
73
- "@aztec/noir-types": "0.0.1-commit.3469e52",
74
- "@aztec/protocol-contracts": "0.0.1-commit.3469e52",
75
- "@aztec/simulator": "0.0.1-commit.3469e52",
76
- "@aztec/stdlib": "0.0.1-commit.3469e52",
64
+ "@aztec/bb-prover": "0.0.1-commit.59e663cd",
65
+ "@aztec/bb.js": "0.0.1-commit.59e663cd",
66
+ "@aztec/builder": "0.0.1-commit.59e663cd",
67
+ "@aztec/constants": "0.0.1-commit.59e663cd",
68
+ "@aztec/ethereum": "0.0.1-commit.59e663cd",
69
+ "@aztec/foundation": "0.0.1-commit.59e663cd",
70
+ "@aztec/key-store": "0.0.1-commit.59e663cd",
71
+ "@aztec/kv-store": "0.0.1-commit.59e663cd",
72
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.59e663cd",
73
+ "@aztec/noir-types": "0.0.1-commit.59e663cd",
74
+ "@aztec/protocol-contracts": "0.0.1-commit.59e663cd",
75
+ "@aztec/simulator": "0.0.1-commit.59e663cd",
76
+ "@aztec/stdlib": "0.0.1-commit.59e663cd",
77
77
  "koa": "^2.16.1",
78
78
  "koa-router": "^13.1.1",
79
79
  "lodash.omit": "^4.5.0",
@@ -82,8 +82,8 @@
82
82
  "viem": "npm:@aztec/viem@2.38.2"
83
83
  },
84
84
  "devDependencies": {
85
- "@aztec/merkle-tree": "0.0.1-commit.3469e52",
86
- "@aztec/noir-test-contracts.js": "0.0.1-commit.3469e52",
85
+ "@aztec/merkle-tree": "0.0.1-commit.59e663cd",
86
+ "@aztec/noir-test-contracts.js": "0.0.1-commit.59e663cd",
87
87
  "@jest/globals": "^30.0.0",
88
88
  "@types/jest": "^30.0.0",
89
89
  "@types/lodash.omit": "^4.5.7",
@@ -1,3 +1,4 @@
1
+ /* eslint-disable import-x/no-named-as-default-member */
1
2
  import { keccak256String } from '@aztec/foundation/crypto/keccak';
2
3
 
3
4
  import { readFileSync } from 'fs';
@@ -2,15 +2,11 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
2
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
4
  import type { L2TipsKVStore } from '@aztec/kv-store/stores';
5
- import {
6
- L2BlockHash,
7
- L2BlockStream,
8
- type L2BlockStreamEvent,
9
- type L2BlockStreamEventHandler,
10
- } from '@aztec/stdlib/block';
5
+ import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
11
6
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
+ import type { BlockHeader } from '@aztec/stdlib/tx';
12
8
 
13
- import type { PXEConfig } from '../config/index.js';
9
+ import type { BlockSynchronizerConfig } from '../config/index.js';
14
10
  import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
15
11
  import type { NoteStore } from '../storage/note_store/note_store.js';
16
12
  import type { PrivateEventStore } from '../storage/private_event_store/private_event_store.js';
@@ -32,7 +28,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
32
28
  private noteStore: NoteStore,
33
29
  private privateEventStore: PrivateEventStore,
34
30
  private l2TipsStore: L2TipsKVStore,
35
- config: Partial<Pick<PXEConfig, 'l2BlockBatchSize'>> = {},
31
+ private config: Partial<BlockSynchronizerConfig> = {},
36
32
  loggerOrSuffix?: string | Logger,
37
33
  ) {
38
34
  this.log =
@@ -42,7 +38,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
42
38
  this.blockStream = this.createBlockStream(config);
43
39
  }
44
40
 
45
- protected createBlockStream(config: Partial<Pick<PXEConfig, 'l2BlockBatchSize'>>) {
41
+ protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
46
42
  return new L2BlockStream(this.node, this.l2TipsStore, this, createLogger('pxe:block_stream'), {
47
43
  batchSize: config.l2BlockBatchSize,
48
44
  // Skipping finalized blocks makes us sync much faster - we only need to download blocks other than the latest one
@@ -57,23 +53,55 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
57
53
 
58
54
  switch (event.type) {
59
55
  case 'blocks-added': {
60
- const lastBlock = event.blocks.at(-1)!;
61
- this.log.verbose(`Updated pxe last block to ${lastBlock.number}`, {
62
- blockHash: lastBlock.hash(),
63
- archive: lastBlock.archive.root.toString(),
64
- header: lastBlock.header.toInspect(),
65
- });
66
- await this.anchorBlockStore.setHeader(lastBlock.header);
56
+ if (this.config.syncChainTip === undefined || this.config.syncChainTip === 'proposed') {
57
+ const lastBlock = event.blocks.at(-1)!;
58
+ await this.updateAnchorBlockHeader(lastBlock.header);
59
+ }
60
+ break;
61
+ }
62
+ case 'chain-checkpointed': {
63
+ if (this.config.syncChainTip === 'checkpointed') {
64
+ // Get the last block header from the checkpoint
65
+ const lastBlock = event.checkpoint.checkpoint.blocks.at(-1)!;
66
+ await this.updateAnchorBlockHeader(lastBlock.header);
67
+ }
68
+ break;
69
+ }
70
+ case 'chain-proven': {
71
+ if (this.config.syncChainTip === 'proven') {
72
+ const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
73
+ if (blockHeader) {
74
+ await this.updateAnchorBlockHeader(blockHeader);
75
+ }
76
+ }
77
+ break;
78
+ }
79
+ case 'chain-finalized': {
80
+ if (this.config.syncChainTip === 'finalized') {
81
+ const blockHeader = await this.node.getBlockHeader(BlockNumber(event.block.number));
82
+ if (blockHeader) {
83
+ await this.updateAnchorBlockHeader(blockHeader);
84
+ }
85
+ }
67
86
  break;
68
87
  }
69
88
  case 'chain-pruned': {
89
+ const currentAnchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
90
+ const currentAnchorBlockNumber = currentAnchorBlockHeader.getBlockNumber();
91
+ if (currentAnchorBlockNumber <= event.block.number) {
92
+ this.log.verbose(
93
+ `Ignoring prune event to block ${event.block.number} greater than current anchor block ${currentAnchorBlockNumber}`,
94
+ { pruneEvent: event, currentAnchorBlockHeader: currentAnchorBlockHeader.toInspect() },
95
+ );
96
+ return;
97
+ }
98
+
70
99
  this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
71
100
 
72
- const oldAnchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
73
101
  // Note that the following is not necessarily the anchor block that will be used in the transaction - if
74
102
  // the chain has already moved past the reorg, we'll also see blocks-added events that will push the anchor
75
103
  // forward.
76
- const newAnchorBlockHeader = await this.node.getBlockHeader(L2BlockHash.fromString(event.block.hash));
104
+ const newAnchorBlockHeader = await this.node.getBlockHeader(BlockHash.fromString(event.block.hash));
77
105
 
78
106
  if (!newAnchorBlockHeader) {
79
107
  throw new Error(
@@ -83,15 +111,21 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
83
111
 
84
112
  // Operations are wrapped in a single transaction to ensure atomicity.
85
113
  await this.store.transactionAsync(async () => {
86
- await this.noteStore.rollback(event.block.number, oldAnchorBlockNumber);
87
- await this.privateEventStore.rollback(event.block.number, oldAnchorBlockNumber);
88
- await this.anchorBlockStore.setHeader(newAnchorBlockHeader);
114
+ await this.noteStore.rollback(event.block.number, currentAnchorBlockNumber);
115
+ await this.privateEventStore.rollback(event.block.number, currentAnchorBlockNumber);
116
+ await this.updateAnchorBlockHeader(newAnchorBlockHeader);
89
117
  });
90
118
  break;
91
119
  }
92
120
  }
93
121
  }
94
122
 
123
+ /** Updates the anchor block header to the target block */
124
+ private async updateAnchorBlockHeader(blockHeader: BlockHeader) {
125
+ this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
126
+ await this.anchorBlockStore.setHeader(blockHeader);
127
+ }
128
+
95
129
  /**
96
130
  * Syncs PXE and the node by downloading the metadata of the latest blocks, allowing simulations to use
97
131
  * recent data (e.g. notes), and handling any reorgs that might have occurred.
@@ -24,6 +24,8 @@ export interface KernelProverConfig {
24
24
  export interface BlockSynchronizerConfig {
25
25
  /** Maximum amount of blocks to pull from the stream in one request when synchronizing */
26
26
  l2BlockBatchSize: number;
27
+ /** Which chain tip to sync to (proposed, checkpointed, proven, finalized) */
28
+ syncChainTip?: 'proposed' | 'checkpointed' | 'proven' | 'finalized';
27
29
  }
28
30
 
29
31
  export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & BlockSynchronizerConfig;
@@ -53,6 +55,18 @@ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
53
55
  description: 'Enable real proofs',
54
56
  ...booleanConfigHelper(true),
55
57
  },
58
+ syncChainTip: {
59
+ env: 'PXE_SYNC_CHAIN_TIP',
60
+ description: 'Which chain tip to sync to (proposed, checkpointed, proven, finalized)',
61
+ defaultValue: 'proposed',
62
+ parseEnv: (val: string) => {
63
+ const allowedValues = ['proposed', 'checkpointed', 'proven', 'finalized'];
64
+ if (allowedValues.includes(val)) {
65
+ return val;
66
+ }
67
+ throw new Error(`Invalid value for PXE_SYNC_CHAIN_TIP: ${val}. Allowed values are: ${allowedValues.join(', ')}`);
68
+ },
69
+ },
56
70
  };
57
71
 
58
72
  /**
@@ -85,7 +85,7 @@ import { ExecutionNoteCache } from './execution_note_cache.js';
85
85
  import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
86
86
  import { HashedValuesCache } from './hashed_values_cache.js';
87
87
  import { Oracle } from './oracle/oracle.js';
88
- import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
88
+ import { executePrivateFunction } from './oracle/private_execution.js';
89
89
  import { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
90
90
  import { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
91
91
 
@@ -138,12 +138,6 @@ export class ContractFunctionSimulator {
138
138
  ): Promise<PrivateExecutionResult> {
139
139
  const simulatorSetupTimer = new Timer();
140
140
 
141
- await this.contractStore.syncPrivateState(contractAddress, selector, privateSyncCall =>
142
- this.runUtility(privateSyncCall, [], anchorBlockHeader, scopes, jobId),
143
- );
144
-
145
- await verifyCurrentClassId(contractAddress, this.aztecNode, this.contractStore, anchorBlockHeader);
146
-
147
141
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(contractAddress, selector);
148
142
 
149
143
  if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
@@ -268,8 +262,6 @@ export class ContractFunctionSimulator {
268
262
  scopes: AztecAddress[] | undefined,
269
263
  jobId: string,
270
264
  ): Promise<Fr[]> {
271
- await verifyCurrentClassId(call.to, this.aztecNode, this.contractStore, anchorBlockHeader);
272
-
273
265
  const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
274
266
 
275
267
  if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
@@ -8,7 +8,7 @@ import { TxHash } from '@aztec/stdlib/tx';
8
8
  const MAX_EVENT_SERIALIZED_LEN = 12;
9
9
 
10
10
  /**
11
- * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateEnqueuedNotesAndEvents` oracle
11
+ * Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
12
12
  * expects for values of this type to be stored in a `CapsuleArray`.
13
13
  */
14
14
  export class EventValidationRequest {
@@ -7,7 +7,7 @@ import { TxHash } from '@aztec/stdlib/tx';
7
7
  export const MAX_NOTE_PACKED_LEN = 10;
8
8
 
9
9
  /**
10
- * Intermediate struct used to perform batch note validation by PXE. The `utilityValidateEnqueuedNotesAndEvents` oracle
10
+ * Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
11
11
  * expects for values of this type to be stored in a `CapsuleArray`.
12
12
  */
13
13
  export class NoteValidationRequest {
@@ -1,15 +1,16 @@
1
- import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
1
+ import type { ARCHIVE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { BlockNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { Point } from '@aztec/foundation/curves/grumpkin';
5
+ import { MembershipWitness } from '@aztec/foundation/trees';
5
6
  import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
6
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import { L2BlockHash } from '@aztec/stdlib/block';
8
+ import { BlockHash } from '@aztec/stdlib/block';
8
9
  import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
9
10
  import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
10
11
  import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
11
12
  import type { Note, NoteStatus } from '@aztec/stdlib/note';
12
- import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
13
+ import { type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
13
14
  import type { BlockHeader } from '@aztec/stdlib/tx';
14
15
 
15
16
  import type { UtilityContext } from '../noir-structs/utility_context.js';
@@ -66,14 +67,21 @@ export interface IUtilityExecutionOracle {
66
67
  utilityGetUtilityContext(): UtilityContext;
67
68
  utilityGetKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
68
69
  utilityGetContractInstance(address: AztecAddress): Promise<ContractInstance>;
69
- utilityGetMembershipWitness(blockHash: L2BlockHash, treeId: MerkleTreeId, leafValue: Fr): Promise<Fr[] | undefined>;
70
+ utilityGetNoteHashMembershipWitness(
71
+ blockHash: BlockHash,
72
+ leafValue: Fr,
73
+ ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
74
+ utilityGetArchiveMembershipWitness(
75
+ blockHash: BlockHash,
76
+ leafValue: Fr,
77
+ ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
70
78
  utilityGetNullifierMembershipWitness(
71
- blockHash: L2BlockHash,
79
+ blockHash: BlockHash,
72
80
  nullifier: Fr,
73
81
  ): Promise<NullifierMembershipWitness | undefined>;
74
- utilityGetPublicDataWitness(blockHash: L2BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
82
+ utilityGetPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
75
83
  utilityGetLowNullifierMembershipWitness(
76
- blockHash: L2BlockHash,
84
+ blockHash: BlockHash,
77
85
  nullifier: Fr,
78
86
  ): Promise<NullifierMembershipWitness | undefined>;
79
87
  utilityGetBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
@@ -103,13 +111,13 @@ export interface IUtilityExecutionOracle {
103
111
  secret: Fr,
104
112
  ): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
105
113
  utilityStorageRead(
106
- blockHash: L2BlockHash,
114
+ blockHash: BlockHash,
107
115
  contractAddress: AztecAddress,
108
116
  startStorageSlot: Fr,
109
117
  numberOfElements: number,
110
118
  ): Promise<Fr[]>;
111
119
  utilityFetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
112
- utilityValidateEnqueuedNotesAndEvents(
120
+ utilityValidateAndStoreEnqueuedNotesAndEvents(
113
121
  contractAddress: AztecAddress,
114
122
  noteValidationRequestsArrayBaseSlot: Fr,
115
123
  eventValidationRequestsArrayBaseSlot: Fr,
@@ -147,6 +155,7 @@ export interface IPrivateExecutionOracle {
147
155
  ): void;
148
156
  privateNotifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
149
157
  privateNotifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
158
+ privateIsNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean>;
150
159
  privateNotifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
151
160
  privateCallPrivateFunction(
152
161
  targetContractAddress: AztecAddress,