@aztec/stdlib 0.0.1-commit.cd76b27 → 0.0.1-commit.d117d021b

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 (234) hide show
  1. package/dest/abi/decoder.d.ts +2 -2
  2. package/dest/abi/decoder.d.ts.map +1 -1
  3. package/dest/abi/decoder.js +7 -5
  4. package/dest/abi/encoder.d.ts +1 -1
  5. package/dest/abi/encoder.d.ts.map +1 -1
  6. package/dest/abi/encoder.js +37 -6
  7. package/dest/abi/event_metadata_definition.d.ts +3 -1
  8. package/dest/abi/event_metadata_definition.d.ts.map +1 -1
  9. package/dest/abi/event_metadata_definition.js +1 -1
  10. package/dest/abi/utils.d.ts +14 -1
  11. package/dest/abi/utils.d.ts.map +1 -1
  12. package/dest/abi/utils.js +15 -0
  13. package/dest/avm/avm.d.ts +300 -300
  14. package/dest/avm/avm_proving_request.d.ts +166 -166
  15. package/dest/avm/revert_code.d.ts +16 -1
  16. package/dest/avm/revert_code.d.ts.map +1 -1
  17. package/dest/avm/revert_code.js +15 -5
  18. package/dest/block/l2_block.d.ts +9 -1
  19. package/dest/block/l2_block.d.ts.map +1 -1
  20. package/dest/block/l2_block.js +12 -2
  21. package/dest/block/l2_block_source.d.ts +6 -1
  22. package/dest/block/l2_block_source.d.ts.map +1 -1
  23. package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
  24. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  25. package/dest/block/l2_block_stream/l2_block_stream.js +10 -0
  26. package/dest/checkpoint/checkpoint.d.ts +2 -1
  27. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  28. package/dest/checkpoint/checkpoint.js +9 -4
  29. package/dest/checkpoint/index.d.ts +2 -1
  30. package/dest/checkpoint/index.d.ts.map +1 -1
  31. package/dest/checkpoint/index.js +1 -0
  32. package/dest/checkpoint/validate.d.ts +36 -0
  33. package/dest/checkpoint/validate.d.ts.map +1 -0
  34. package/dest/checkpoint/validate.js +120 -0
  35. package/dest/config/sequencer-config.d.ts +4 -2
  36. package/dest/config/sequencer-config.d.ts.map +1 -1
  37. package/dest/config/sequencer-config.js +6 -0
  38. package/dest/contract/contract_class.d.ts +2 -3
  39. package/dest/contract/contract_class.d.ts.map +1 -1
  40. package/dest/gas/gas_fees.d.ts +1 -1
  41. package/dest/gas/gas_fees.d.ts.map +1 -1
  42. package/dest/gas/gas_fees.js +4 -1
  43. package/dest/ha-signing/config.d.ts +136 -0
  44. package/dest/ha-signing/config.d.ts.map +1 -0
  45. package/dest/ha-signing/config.js +97 -0
  46. package/dest/ha-signing/index.d.ts +4 -0
  47. package/dest/ha-signing/index.d.ts.map +1 -0
  48. package/dest/ha-signing/index.js +3 -0
  49. package/dest/ha-signing/local_config.d.ts +63 -0
  50. package/dest/ha-signing/local_config.d.ts.map +1 -0
  51. package/dest/ha-signing/local_config.js +24 -0
  52. package/dest/ha-signing/types.d.ts +85 -0
  53. package/dest/ha-signing/types.d.ts.map +1 -0
  54. package/dest/ha-signing/types.js +32 -0
  55. package/dest/interfaces/allowed_element.d.ts +26 -20
  56. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  57. package/dest/interfaces/allowed_element.js +8 -8
  58. package/dest/interfaces/archiver.d.ts +1 -1
  59. package/dest/interfaces/archiver.d.ts.map +1 -1
  60. package/dest/interfaces/archiver.js +1 -0
  61. package/dest/interfaces/aztec-node-admin.d.ts +70 -30
  62. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  63. package/dest/interfaces/aztec-node.d.ts +10 -5
  64. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  65. package/dest/interfaces/aztec-node.js +3 -2
  66. package/dest/interfaces/block-builder.d.ts +11 -5
  67. package/dest/interfaces/block-builder.d.ts.map +1 -1
  68. package/dest/interfaces/block-builder.js +7 -2
  69. package/dest/interfaces/configs.d.ts +57 -32
  70. package/dest/interfaces/configs.d.ts.map +1 -1
  71. package/dest/interfaces/configs.js +5 -2
  72. package/dest/interfaces/p2p.d.ts +3 -8
  73. package/dest/interfaces/p2p.d.ts.map +1 -1
  74. package/dest/interfaces/validator.d.ts +103 -41
  75. package/dest/interfaces/validator.d.ts.map +1 -1
  76. package/dest/interfaces/validator.js +8 -4
  77. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +3 -3
  78. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  79. package/dest/kernel/hints/build_note_hash_read_request_hints.js +13 -10
  80. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
  81. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  82. package/dest/kernel/hints/build_nullifier_read_request_hints.js +13 -10
  83. package/dest/kernel/hints/build_transient_data_hints.d.ts +5 -2
  84. package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
  85. package/dest/kernel/hints/build_transient_data_hints.js +9 -3
  86. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
  87. package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
  88. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
  89. package/dest/kv-store/config.d.ts +17 -0
  90. package/dest/kv-store/config.d.ts.map +1 -0
  91. package/dest/kv-store/config.js +26 -0
  92. package/dest/kv-store/index.d.ts +2 -0
  93. package/dest/kv-store/index.d.ts.map +1 -0
  94. package/dest/kv-store/index.js +1 -0
  95. package/dest/logs/debug_log_store.d.ts +30 -0
  96. package/dest/logs/debug_log_store.d.ts.map +1 -0
  97. package/dest/logs/debug_log_store.js +30 -0
  98. package/dest/logs/extended_directional_app_tagging_secret.d.ts +47 -0
  99. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -0
  100. package/dest/logs/{directional_app_tagging_secret.js → extended_directional_app_tagging_secret.js} +23 -15
  101. package/dest/logs/index.d.ts +3 -2
  102. package/dest/logs/index.d.ts.map +1 -1
  103. package/dest/logs/index.js +2 -1
  104. package/dest/logs/pre_tag.d.ts +16 -11
  105. package/dest/logs/pre_tag.d.ts.map +1 -1
  106. package/dest/logs/pre_tag.js +2 -2
  107. package/dest/logs/public_log.d.ts +4 -3
  108. package/dest/logs/public_log.d.ts.map +1 -1
  109. package/dest/logs/public_log.js +2 -1
  110. package/dest/logs/siloed_tag.d.ts +5 -3
  111. package/dest/logs/siloed_tag.d.ts.map +1 -1
  112. package/dest/logs/siloed_tag.js +6 -1
  113. package/dest/logs/tag.js +1 -1
  114. package/dest/p2p/attestation_utils.d.ts +11 -1
  115. package/dest/p2p/attestation_utils.d.ts.map +1 -1
  116. package/dest/p2p/attestation_utils.js +45 -0
  117. package/dest/p2p/block_proposal.d.ts +2 -2
  118. package/dest/p2p/block_proposal.d.ts.map +1 -1
  119. package/dest/p2p/block_proposal.js +1 -1
  120. package/dest/p2p/checkpoint_proposal.d.ts +2 -7
  121. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  122. package/dest/p2p/checkpoint_proposal.js +1 -13
  123. package/dest/p2p/client_type.d.ts +2 -5
  124. package/dest/p2p/client_type.d.ts.map +1 -1
  125. package/dest/p2p/client_type.js +0 -7
  126. package/dest/p2p/index.d.ts +1 -2
  127. package/dest/p2p/index.d.ts.map +1 -1
  128. package/dest/p2p/index.js +0 -1
  129. package/dest/p2p/peer_error.d.ts +3 -1
  130. package/dest/p2p/peer_error.d.ts.map +1 -1
  131. package/dest/p2p/peer_error.js +5 -0
  132. package/dest/p2p/topic_type.d.ts +3 -4
  133. package/dest/p2p/topic_type.d.ts.map +1 -1
  134. package/dest/p2p/topic_type.js +7 -24
  135. package/dest/slashing/tally.d.ts +7 -2
  136. package/dest/slashing/tally.d.ts.map +1 -1
  137. package/dest/slashing/tally.js +30 -2
  138. package/dest/tests/factories.d.ts +3 -1
  139. package/dest/tests/factories.d.ts.map +1 -1
  140. package/dest/tests/factories.js +8 -0
  141. package/dest/tests/mocks.d.ts +5 -3
  142. package/dest/tests/mocks.d.ts.map +1 -1
  143. package/dest/tests/mocks.js +18 -13
  144. package/dest/tx/block_header.d.ts +3 -1
  145. package/dest/tx/block_header.d.ts.map +1 -1
  146. package/dest/tx/block_header.js +4 -0
  147. package/dest/tx/public_simulation_output.d.ts +4 -2
  148. package/dest/tx/public_simulation_output.d.ts.map +1 -1
  149. package/dest/tx/public_simulation_output.js +7 -3
  150. package/dest/tx/simulated_tx.d.ts +5 -2
  151. package/dest/tx/simulated_tx.d.ts.map +1 -1
  152. package/dest/tx/simulated_tx.js +4 -1
  153. package/dest/tx/tx.d.ts +6 -5
  154. package/dest/tx/tx.d.ts.map +1 -1
  155. package/dest/tx/tx.js +18 -6
  156. package/dest/tx/tx_receipt.d.ts +16 -2
  157. package/dest/tx/tx_receipt.d.ts.map +1 -1
  158. package/dest/tx/tx_receipt.js +11 -3
  159. package/dest/tx/validator/error_texts.d.ts +5 -1
  160. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  161. package/dest/tx/validator/error_texts.js +4 -0
  162. package/dest/update-checker/index.d.ts +3 -2
  163. package/dest/update-checker/index.d.ts.map +1 -1
  164. package/dest/update-checker/index.js +2 -1
  165. package/dest/update-checker/package_version.d.ts +3 -0
  166. package/dest/update-checker/package_version.d.ts.map +1 -0
  167. package/dest/update-checker/package_version.js +11 -0
  168. package/dest/update-checker/version_checker.d.ts +25 -0
  169. package/dest/update-checker/version_checker.d.ts.map +1 -0
  170. package/dest/update-checker/version_checker.js +50 -0
  171. package/package.json +12 -11
  172. package/src/abi/decoder.ts +15 -6
  173. package/src/abi/encoder.ts +49 -6
  174. package/src/abi/event_metadata_definition.ts +2 -0
  175. package/src/abi/utils.ts +25 -0
  176. package/src/avm/revert_code.ts +15 -0
  177. package/src/block/l2_block.ts +13 -1
  178. package/src/block/l2_block_source.ts +6 -0
  179. package/src/block/l2_block_stream/l2_block_stream.ts +21 -0
  180. package/src/checkpoint/checkpoint.ts +12 -3
  181. package/src/checkpoint/index.ts +1 -0
  182. package/src/checkpoint/validate.ts +230 -0
  183. package/src/config/sequencer-config.ts +9 -1
  184. package/src/contract/contract_class.ts +3 -3
  185. package/src/gas/gas_fees.ts +7 -1
  186. package/src/ha-signing/config.ts +156 -0
  187. package/src/ha-signing/index.ts +27 -0
  188. package/src/ha-signing/local_config.ts +46 -0
  189. package/src/ha-signing/types.ts +112 -0
  190. package/src/interfaces/allowed_element.ts +29 -9
  191. package/src/interfaces/archiver.ts +1 -0
  192. package/src/interfaces/aztec-node.ts +14 -4
  193. package/src/interfaces/block-builder.ts +25 -5
  194. package/src/interfaces/configs.ts +22 -8
  195. package/src/interfaces/p2p.ts +2 -13
  196. package/src/interfaces/validator.ts +50 -28
  197. package/src/kernel/hints/build_note_hash_read_request_hints.ts +14 -18
  198. package/src/kernel/hints/build_nullifier_read_request_hints.ts +15 -18
  199. package/src/kernel/hints/build_transient_data_hints.ts +17 -2
  200. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
  201. package/src/kv-store/config.ts +36 -0
  202. package/src/kv-store/index.ts +1 -0
  203. package/src/logs/debug_log_store.ts +54 -0
  204. package/src/logs/{directional_app_tagging_secret.ts → extended_directional_app_tagging_secret.ts} +24 -16
  205. package/src/logs/index.ts +2 -1
  206. package/src/logs/pre_tag.ts +5 -5
  207. package/src/logs/public_log.ts +4 -2
  208. package/src/logs/siloed_tag.ts +8 -2
  209. package/src/logs/tag.ts +1 -1
  210. package/src/p2p/attestation_utils.ts +56 -0
  211. package/src/p2p/block_proposal.ts +1 -1
  212. package/src/p2p/checkpoint_proposal.ts +1 -18
  213. package/src/p2p/client_type.ts +0 -6
  214. package/src/p2p/index.ts +0 -1
  215. package/src/p2p/peer_error.ts +7 -0
  216. package/src/p2p/topic_type.ts +8 -15
  217. package/src/slashing/tally.ts +34 -1
  218. package/src/tests/factories.ts +9 -0
  219. package/src/tests/mocks.ts +25 -10
  220. package/src/tx/block_header.ts +6 -0
  221. package/src/tx/public_simulation_output.ts +4 -0
  222. package/src/tx/simulated_tx.ts +8 -1
  223. package/src/tx/tx.ts +20 -11
  224. package/src/tx/tx_receipt.ts +10 -0
  225. package/src/tx/validator/error_texts.ts +4 -0
  226. package/src/update-checker/index.ts +2 -1
  227. package/src/update-checker/package_version.ts +17 -0
  228. package/src/update-checker/version_checker.ts +65 -0
  229. package/dest/logs/directional_app_tagging_secret.d.ts +0 -40
  230. package/dest/logs/directional_app_tagging_secret.d.ts.map +0 -1
  231. package/dest/update-checker/update-checker.d.ts +0 -49
  232. package/dest/update-checker/update-checker.d.ts.map +0 -1
  233. package/dest/update-checker/update-checker.js +0 -130
  234. package/src/update-checker/update-checker.ts +0 -166
@@ -0,0 +1,54 @@
1
+ import type { TxReceipt } from '../tx/tx_receipt.js';
2
+ import type { DebugLog } from './debug_log.js';
3
+
4
+ /**
5
+ * Store for debug logs emitted by public functions during transaction execution.
6
+ *
7
+ * Uses the Null Object pattern: production code uses NullDebugLogStore (no-op), while test mode uses
8
+ * InMemoryDebugLogStore (stores and serves logs).
9
+ */
10
+ export interface DebugLogStore {
11
+ /** Store debug logs for a processed transaction. */
12
+ storeLogs(txHash: string, logs: DebugLog[]): void;
13
+ /** Decorate a TxReceipt with any stored debug logs for the given tx. */
14
+ decorateReceiptWithLogs(txHash: string, receipt: TxReceipt): void;
15
+ /** Whether debug log collection is enabled. */
16
+ readonly isEnabled: boolean;
17
+ }
18
+
19
+ /** No-op implementation for production mode. */
20
+ export class NullDebugLogStore implements DebugLogStore {
21
+ storeLogs(_txHash: string, _logs: DebugLog[]): void {
22
+ return;
23
+ }
24
+ decorateReceiptWithLogs(_txHash: string, _receipt: TxReceipt): void {
25
+ return;
26
+ }
27
+ get isEnabled(): boolean {
28
+ return false;
29
+ }
30
+ }
31
+
32
+ /** In-memory implementation for test mode that stores and serves debug logs. */
33
+ export class InMemoryDebugLogStore implements DebugLogStore {
34
+ private map = new Map<string, DebugLog[]>();
35
+
36
+ storeLogs(txHash: string, logs: DebugLog[]): void {
37
+ if (logs.length > 0) {
38
+ this.map.set(txHash, logs);
39
+ }
40
+ }
41
+
42
+ decorateReceiptWithLogs(txHash: string, receipt: TxReceipt): void {
43
+ if (receipt.isMined()) {
44
+ const debugLogs = this.map.get(txHash);
45
+ if (debugLogs) {
46
+ receipt.debugLogs = debugLogs;
47
+ }
48
+ }
49
+ }
50
+
51
+ get isEnabled(): boolean {
52
+ return true;
53
+ }
54
+ }
@@ -5,22 +5,28 @@ import type { Point } from '@aztec/foundation/curves/grumpkin';
5
5
 
6
6
  import { z } from 'zod';
7
7
 
8
- import type { AztecAddress } from '../aztec-address/index.js';
8
+ import { AztecAddress } from '../aztec-address/index.js';
9
9
  import type { CompleteAddress } from '../contract/complete_address.js';
10
10
  import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
11
11
 
12
12
  /**
13
- * Directional application tagging secret used for log tagging.
13
+ * Extended directional application tagging secret used for log tagging.
14
14
  *
15
- * "Directional" because the derived secret is bound to the recipient
16
- * address: A→B differs from B→A even with the same participants and app.
15
+ * "Extended" because it bundles the directional app tagging secret with the app (contract) address. This bundling was
16
+ * done because where this type is used we commonly need access to both the secret and the address.
17
17
  *
18
- * Note: It's a bit unfortunate that this type resides in `stdlib` as the rest of the tagging functionality resides
19
- * in `pxe/src/tagging`. We need to use this type in `PreTag` that in turn is used by other types
20
- * in stdlib hence there doesn't seem to be a good way around this.
18
+ * "Directional" because the derived secret is bound to the recipient address: A→B differs from B→A even with the same
19
+ * participants and app.
20
+ *
21
+ * Note: It's a bit unfortunate that this type resides in `stdlib` as the rest of the tagging functionality resides in
22
+ * `pxe/src/tagging`. We need to use this type in `PreTag` that in turn is used by other types in stdlib hence there
23
+ * doesn't seem to be a good way around this.
21
24
  */
22
- export class DirectionalAppTaggingSecret {
23
- private constructor(public readonly value: Fr) {}
25
+ export class ExtendedDirectionalAppTaggingSecret {
26
+ private constructor(
27
+ public readonly secret: Fr,
28
+ public readonly app: AztecAddress,
29
+ ) {}
24
30
 
25
31
  /**
26
32
  * Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
@@ -39,20 +45,21 @@ export class DirectionalAppTaggingSecret {
39
45
  externalAddress: AztecAddress,
40
46
  app: AztecAddress,
41
47
  recipient: AztecAddress,
42
- ): Promise<DirectionalAppTaggingSecret> {
48
+ ): Promise<ExtendedDirectionalAppTaggingSecret> {
43
49
  const taggingSecretPoint = await computeSharedTaggingSecret(localAddress, localIvsk, externalAddress);
44
50
  const appTaggingSecret = await poseidon2Hash([taggingSecretPoint.x, taggingSecretPoint.y, app]);
45
51
  const directionalAppTaggingSecret = await poseidon2Hash([appTaggingSecret, recipient]);
46
52
 
47
- return new DirectionalAppTaggingSecret(directionalAppTaggingSecret);
53
+ return new ExtendedDirectionalAppTaggingSecret(directionalAppTaggingSecret, app);
48
54
  }
49
55
 
50
56
  toString(): string {
51
- return this.value.toString();
57
+ return `${this.secret.toString()}:${this.app.toString()}`;
52
58
  }
53
59
 
54
- static fromString(str: string): DirectionalAppTaggingSecret {
55
- return new DirectionalAppTaggingSecret(Fr.fromString(str));
60
+ static fromString(str: string): ExtendedDirectionalAppTaggingSecret {
61
+ const [secretStr, appStr] = str.split(':');
62
+ return new ExtendedDirectionalAppTaggingSecret(Fr.fromString(secretStr), AztecAddress.fromString(appStr));
56
63
  }
57
64
  }
58
65
 
@@ -74,6 +81,7 @@ async function computeSharedTaggingSecret(
74
81
  return Grumpkin.mul(externalAddressPoint, await computeAddressSecret(knownPreaddress, localIvsk));
75
82
  }
76
83
 
77
- export const DirectionalAppTaggingSecretSchema = z.object({
78
- value: Fr.schema,
84
+ export const ExtendedDirectionalAppTaggingSecretSchema = z.object({
85
+ secret: Fr.schema,
86
+ app: AztecAddress.schema,
79
87
  });
package/src/logs/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './directional_app_tagging_secret.js';
1
+ export * from './extended_directional_app_tagging_secret.js';
2
2
  export * from './pre_tag.js';
3
3
  export * from './contract_class_log.js';
4
4
  export * from './public_log.js';
@@ -12,5 +12,6 @@ export * from './shared_secret_derivation.js';
12
12
  export * from './tx_scoped_l2_log.js';
13
13
  export * from './message_context.js';
14
14
  export * from './debug_log.js';
15
+ export * from './debug_log_store.js';
15
16
  export * from './tag.js';
16
17
  export * from './siloed_tag.js';
@@ -3,9 +3,9 @@ import { schemas } from '@aztec/foundation/schemas';
3
3
  import { z } from 'zod';
4
4
 
5
5
  import {
6
- type DirectionalAppTaggingSecret,
7
- DirectionalAppTaggingSecretSchema,
8
- } from './directional_app_tagging_secret.js';
6
+ type ExtendedDirectionalAppTaggingSecret,
7
+ ExtendedDirectionalAppTaggingSecretSchema,
8
+ } from './extended_directional_app_tagging_secret.js';
9
9
 
10
10
  /**
11
11
  * Represents a preimage of a private log tag (see `Tag` in `pxe/src/tagging`).
@@ -15,11 +15,11 @@ import {
15
15
  * around this.
16
16
  */
17
17
  export type PreTag = {
18
- secret: DirectionalAppTaggingSecret;
18
+ extendedSecret: ExtendedDirectionalAppTaggingSecret;
19
19
  index: number;
20
20
  };
21
21
 
22
22
  export const PreTagSchema = z.object({
23
- secret: DirectionalAppTaggingSecretSchema,
23
+ extendedSecret: ExtendedDirectionalAppTaggingSecretSchema,
24
24
  index: schemas.Integer,
25
25
  });
@@ -120,8 +120,8 @@ export class FlatPublicLogs {
120
120
 
121
121
  export class PublicLog {
122
122
  constructor(
123
- public contractAddress: AztecAddress,
124
- public fields: Fr[],
123
+ public readonly contractAddress: AztecAddress,
124
+ public readonly fields: Fr[],
125
125
  ) {}
126
126
 
127
127
  static from(fields: FieldsOf<PublicLog>) {
@@ -146,7 +146,9 @@ export class PublicLog {
146
146
  return this.fields.length + PUBLIC_LOG_HEADER_LENGTH;
147
147
  }
148
148
 
149
+ /** Returns the serialized log (field as in noir field and not a struct field). */
149
150
  getEmittedFields() {
151
+ // We slice from 0 to return a shallow copy.
150
152
  return this.fields.slice(0);
151
153
  }
152
154
 
@@ -4,7 +4,8 @@ import type { ZodFor } from '@aztec/foundation/schemas';
4
4
  import type { AztecAddress } from '../aztec-address/index.js';
5
5
  import { computeSiloedPrivateLogFirstField } from '../hash/hash.js';
6
6
  import { schemas } from '../schemas/schemas.js';
7
- import type { Tag } from './tag.js';
7
+ import type { PreTag } from './pre_tag.js';
8
+ import { Tag } from './tag.js';
8
9
 
9
10
  /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
10
11
 
@@ -21,7 +22,12 @@ export interface SiloedTag {
21
22
  export class SiloedTag {
22
23
  constructor(public readonly value: Fr) {}
23
24
 
24
- static async compute(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
25
+ static async compute(preTag: PreTag): Promise<SiloedTag> {
26
+ const tag = await Tag.compute(preTag);
27
+ return SiloedTag.computeFromTagAndApp(tag, preTag.extendedSecret.app);
28
+ }
29
+
30
+ static async computeFromTagAndApp(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
25
31
  const siloedTag = await computeSiloedPrivateLogFirstField(app, tag.value);
26
32
  return new SiloedTag(siloedTag);
27
33
  }
package/src/logs/tag.ts CHANGED
@@ -20,7 +20,7 @@ export class Tag {
20
20
  constructor(public readonly value: Fr) {}
21
21
 
22
22
  static async compute(preTag: PreTag): Promise<Tag> {
23
- const tag = await poseidon2Hash([preTag.secret.value, preTag.index]);
23
+ const tag = await poseidon2Hash([preTag.extendedSecret.secret, preTag.index]);
24
24
  return new Tag(tag);
25
25
  }
26
26
 
@@ -33,3 +33,59 @@ export function orderAttestations(
33
33
 
34
34
  return orderedAttestations;
35
35
  }
36
+
37
+ /**
38
+ * Trims attestations to the minimum required number to save L1 calldata gas.
39
+ * Each signature costs 65 bytes of calldata vs 20 bytes for just an address.
40
+ *
41
+ * Priority order for keeping attestations:
42
+ * 1. The proposer's attestation (required by L1 contract - MissingProposerSignature revert)
43
+ * 2. Attestations from the local node's validator keys
44
+ * 3. Remaining attestations filled to reach the required count
45
+ */
46
+ export function trimAttestations(
47
+ attestations: CheckpointAttestation[],
48
+ required: number,
49
+ proposerAddress: EthAddress,
50
+ localAddresses: EthAddress[],
51
+ ): CheckpointAttestation[] {
52
+ if (attestations.length <= required) {
53
+ return attestations;
54
+ }
55
+
56
+ const proposerAttestation: CheckpointAttestation[] = [];
57
+ const localAttestations: CheckpointAttestation[] = [];
58
+ const otherAttestations: CheckpointAttestation[] = [];
59
+
60
+ for (const attestation of attestations) {
61
+ const sender = attestation.getSender();
62
+ if (!sender) {
63
+ continue;
64
+ }
65
+ if (sender.equals(proposerAddress)) {
66
+ proposerAttestation.push(attestation);
67
+ } else if (localAddresses.some(addr => addr.equals(sender))) {
68
+ localAttestations.push(attestation);
69
+ } else {
70
+ otherAttestations.push(attestation);
71
+ }
72
+ }
73
+
74
+ const result: CheckpointAttestation[] = [...proposerAttestation];
75
+
76
+ for (const att of localAttestations) {
77
+ if (result.length >= required) {
78
+ break;
79
+ }
80
+ result.push(att);
81
+ }
82
+
83
+ for (const att of otherAttestations) {
84
+ if (result.length >= required) {
85
+ break;
86
+ }
87
+ result.push(att);
88
+ }
89
+
90
+ return result;
91
+ }
@@ -6,11 +6,11 @@ import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
9
- import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
10
9
 
11
10
  import type { L2Block } from '../block/l2_block.js';
12
11
  import type { L2BlockInfo } from '../block/l2_block_info.js';
13
12
  import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
13
+ import { DutyType, type SigningContext } from '../ha-signing/index.js';
14
14
  import { BlockHeader } from '../tx/block_header.js';
15
15
  import { TxHash } from '../tx/index.js';
16
16
  import type { Tx } from '../tx/tx.js';
@@ -6,10 +6,10 @@ import { Fr } from '@aztec/foundation/curves/bn254';
6
6
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import { BufferReader, serializeSignedBigInt, serializeToBuffer } from '@aztec/foundation/serialize';
9
- import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
10
9
 
11
10
  import type { L2BlockInfo } from '../block/l2_block_info.js';
12
11
  import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
12
+ import { DutyType, type SigningContext } from '../ha-signing/index.js';
13
13
  import { CheckpointHeader } from '../rollup/checkpoint_header.js';
14
14
  import { BlockHeader } from '../tx/block_header.js';
15
15
  import { TxHash } from '../tx/index.js';
@@ -101,23 +101,6 @@ export class CheckpointProposal extends Gossipable {
101
101
  return this.checkpointHeader.slotNumber;
102
102
  }
103
103
 
104
- get blockNumber(): BlockNumber {
105
- if (!this.lastBlock) {
106
- throw new Error('Cannot get blockNumber without lastBlock');
107
- }
108
- return this.lastBlock.blockHeader.getBlockNumber();
109
- }
110
-
111
- /** Convenience getter for txHashes from lastBlock */
112
- get txHashes(): TxHash[] {
113
- return this.lastBlock?.txHashes ?? [];
114
- }
115
-
116
- /** Convenience getter for txs from lastBlock */
117
- get txs(): Tx[] | undefined {
118
- return this.lastBlock?.signedTxs?.txs;
119
- }
120
-
121
104
  /**
122
105
  * Extract a BlockProposal from the last block info.
123
106
  * Uses inHash from checkpointHeader.contentCommitment.inHash
@@ -1,6 +0,0 @@
1
- export enum P2PClientType {
2
- // Full p2p clients will subscribe to all gossip topics
3
- Full,
4
- // Prove p2p clients will only subscribe to transaction and proving topics
5
- Prover,
6
- }
package/src/p2p/index.ts CHANGED
@@ -8,7 +8,6 @@ export * from './interface.js';
8
8
  export * from './signature_utils.js';
9
9
  export * from './signed_txs.js';
10
10
  export * from './topic_type.js';
11
- export * from './client_type.js';
12
11
  export * from './message_validator.js';
13
12
  export * from './peer_error.js';
14
13
  export * from './constants.js';
@@ -15,3 +15,10 @@ export enum PeerErrorSeverity {
15
15
  */
16
16
  HighToleranceError = 'HighToleranceError',
17
17
  }
18
+
19
+ /** Severities ordered from mildest to harshest. */
20
+ export const PeerErrorSeverityByHarshness = [
21
+ PeerErrorSeverity.HighToleranceError,
22
+ PeerErrorSeverity.MidToleranceError,
23
+ PeerErrorSeverity.LowToleranceError,
24
+ ] as const;
@@ -1,5 +1,3 @@
1
- import { P2PClientType } from './client_type.js';
2
-
3
1
  /**
4
2
  * Creates the topic channel identifier string from a given topic type
5
3
  */
@@ -27,19 +25,14 @@ export enum TopicType {
27
25
  checkpoint_attestation = 'checkpoint_attestation',
28
26
  }
29
27
 
30
- export function getTopicTypeForClientType(clientType: P2PClientType) {
31
- if (clientType === P2PClientType.Full) {
32
- return [TopicType.tx, TopicType.block_proposal, TopicType.checkpoint_proposal, TopicType.checkpoint_attestation];
33
- } else if (clientType === P2PClientType.Prover) {
34
- return [TopicType.tx, TopicType.block_proposal, TopicType.checkpoint_proposal];
35
- } else {
36
- const _: never = clientType;
37
- return [TopicType.tx];
38
- }
39
- }
40
-
41
- export function getTopicsForClientAndConfig(clientType: P2PClientType, disableTransactions: boolean) {
42
- const topics = getTopicTypeForClientType(clientType);
28
+ /** Returns all gossip topics, optionally filtering out transactions. */
29
+ export function getTopicsForConfig(disableTransactions: boolean) {
30
+ const topics = [
31
+ TopicType.tx,
32
+ TopicType.block_proposal,
33
+ TopicType.checkpoint_proposal,
34
+ TopicType.checkpoint_attestation,
35
+ ];
43
36
  if (disableTransactions) {
44
37
  return topics.filter(topic => topic !== TopicType.tx);
45
38
  }
@@ -1,6 +1,7 @@
1
1
  import { sumBigint } from '@aztec/foundation/bigint';
2
2
  import { padArrayEnd } from '@aztec/foundation/collection';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
+ import { type Logger, createLogger } from '@aztec/foundation/log';
4
5
  import type { PartialBy } from '@aztec/foundation/types';
5
6
 
6
7
  import { getEpochForOffense } from './helpers.js';
@@ -12,6 +13,9 @@ import type { Offense, ValidatorSlashVote } from './types.js';
12
13
  * @param committees - Array of committees (each containing array of validator addresses)
13
14
  * @param epochsForCommittees - Array of epochs corresponding to each committee
14
15
  * @param settings - Settings including slashingAmounts and optional validator override lists
16
+ * @param settings.maxSlashedValidators - If set, limits the total number of [validator, epoch] pairs
17
+ * with non-zero votes. The lowest-vote pairs are zeroed out to stay within the limit.
18
+ * @param logger - Logger, logs which validators were dropped.
15
19
  * @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
16
20
  */
17
21
  export function getSlashConsensusVotesFromOffenses(
@@ -22,9 +26,11 @@ export function getSlashConsensusVotesFromOffenses(
22
26
  slashingAmounts: [bigint, bigint, bigint];
23
27
  epochDuration: number;
24
28
  targetCommitteeSize: number;
29
+ maxSlashedValidators?: number;
25
30
  },
31
+ logger: Logger = createLogger('slasher:tally'),
26
32
  ): ValidatorSlashVote[] {
27
- const { slashingAmounts, targetCommitteeSize } = settings;
33
+ const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
28
34
 
29
35
  if (committees.length !== epochsForCommittees.length) {
30
36
  throw new Error('committees and epochsForCommittees must have the same length');
@@ -53,6 +59,33 @@ export function getSlashConsensusVotesFromOffenses(
53
59
  return padArrayEnd(votes, 0, targetCommitteeSize);
54
60
  });
55
61
 
62
+ // if a cap is set, zero out the lowest-vote [validator, epoch] pairs so that the most severe slashes stay.
63
+ if (maxSlashedValidators === undefined) {
64
+ return votes;
65
+ }
66
+
67
+ const nonZeroByDescendingVote = [...votes.entries()].filter(([, vote]) => vote > 0).sort(([, a], [, b]) => b - a);
68
+
69
+ const toTruncate = nonZeroByDescendingVote.slice(maxSlashedValidators);
70
+ for (const [idx] of toTruncate) {
71
+ votes[idx] = 0;
72
+ }
73
+
74
+ if (toTruncate.length > 0) {
75
+ const truncated = toTruncate.map(([idx]) => {
76
+ const committeeIndex = Math.floor(idx / targetCommitteeSize);
77
+ const positionInCommittee = idx % targetCommitteeSize;
78
+ return {
79
+ validator: committees[committeeIndex][positionInCommittee].toString(),
80
+ epoch: epochsForCommittees[committeeIndex],
81
+ };
82
+ });
83
+ logger.warn(
84
+ `Truncated ${toTruncate.length} validator-epoch pairs to stay within limit of ${maxSlashedValidators}`,
85
+ { truncated },
86
+ );
87
+ }
88
+
56
89
  return votes;
57
90
  }
58
91
 
@@ -128,6 +128,7 @@ import {
128
128
  PublicCallRequestArrayLengths,
129
129
  } from '../kernel/public_call_request.js';
130
130
  import { PublicKeys, computeAddress } from '../keys/index.js';
131
+ import { ExtendedDirectionalAppTaggingSecret } from '../logs/extended_directional_app_tagging_secret.js';
131
132
  import { ContractClassLog, ContractClassLogFields } from '../logs/index.js';
132
133
  import { PrivateLog } from '../logs/private_log.js';
133
134
  import { FlatPublicLogs, PublicLog } from '../logs/public_log.js';
@@ -1757,3 +1758,11 @@ export function makeL2Tips(
1757
1758
  },
1758
1759
  };
1759
1760
  }
1761
+
1762
+ export async function randomExtendedDirectionalAppTaggingSecret(): Promise<ExtendedDirectionalAppTaggingSecret> {
1763
+ const resolvedApp = await AztecAddress.random();
1764
+ // Using the fromString method like this is messy as it leaks the underlying serialization format but I don't want to
1765
+ // expose the type's constructor just for tests since in prod the secret is always constructed via compute. Also this
1766
+ // method is tested in extended_directional_app_tagging_secret.test.ts hence all should be fine.
1767
+ return ExtendedDirectionalAppTaggingSecret.fromString(`${Fr.random().toString()}:${resolvedApp.toString()}`);
1768
+ }
@@ -1,10 +1,11 @@
1
1
  import {
2
- FIXED_DA_GAS,
3
- FIXED_L2_GAS,
4
2
  MAX_ENQUEUED_CALLS_PER_TX,
5
3
  MAX_NULLIFIERS_PER_TX,
6
4
  MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
7
5
  MAX_TX_LIFETIME,
6
+ PRIVATE_TX_L2_GAS_OVERHEAD,
7
+ PUBLIC_TX_L2_GAS_OVERHEAD,
8
+ TX_DA_GAS_OVERHEAD,
8
9
  } from '@aztec/constants';
9
10
  import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
10
11
  import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
@@ -97,6 +98,7 @@ export const mockTx = async (
97
98
  publicCalldataSize = 2,
98
99
  feePayer,
99
100
  chonkProof = ChonkProof.random(),
101
+ gasLimits,
100
102
  maxFeesPerGas = new GasFees(10, 10),
101
103
  maxPriorityFeesPerGas,
102
104
  gasUsed = Gas.empty(),
@@ -113,6 +115,7 @@ export const mockTx = async (
113
115
  publicCalldataSize?: number;
114
116
  feePayer?: AztecAddress;
115
117
  chonkProof?: ChonkProof;
118
+ gasLimits?: Gas;
116
119
  maxFeesPerGas?: GasFees;
117
120
  maxPriorityFeesPerGas?: GasFees;
118
121
  gasUsed?: Gas;
@@ -131,7 +134,7 @@ export const mockTx = async (
131
134
  const data = PrivateKernelTailCircuitPublicInputs.empty();
132
135
  const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
133
136
  data.constants.anchorBlockHeader = anchorBlockHeader;
134
- data.constants.txContext.gasSettings = GasSettings.default({ maxFeesPerGas, maxPriorityFeesPerGas });
137
+ data.constants.txContext.gasSettings = GasSettings.default({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
135
138
  data.feePayer = feePayer ?? (await AztecAddress.random());
136
139
  data.gasUsed = gasUsed;
137
140
  data.constants.txContext.chainId = chainId;
@@ -205,8 +208,11 @@ export async function mockProcessedTx({
205
208
  feePayer,
206
209
  feePaymentPublicDataWrite,
207
210
  // The default gasUsed is the tx overhead.
208
- gasUsed = Gas.from({ daGas: FIXED_DA_GAS, l2Gas: FIXED_L2_GAS }),
209
211
  privateOnly = false,
212
+ gasUsed = Gas.from({
213
+ daGas: TX_DA_GAS_OVERHEAD,
214
+ l2Gas: privateOnly ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
215
+ }),
210
216
  avmAccumulatedData,
211
217
  ...mockTxOpts
212
218
  }: {
@@ -421,10 +427,13 @@ export async function mockCheckpointAndMessages(
421
427
  Partial<Parameters<typeof L2Block.random>[1]> = {},
422
428
  ) {
423
429
  const slotNumber = options.slotNumber ?? SlotNumber(Number(checkpointNumber) * 10);
430
+ const globals = GlobalVariables.random({ slotNumber, ...options });
424
431
  const blocksAndMessages = [];
432
+
425
433
  // Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
426
434
  // The current block's header.lastArchive must equal the previous block's archive.
427
435
  let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
436
+
428
437
  // Pass maxEffects via txOptions so it reaches TxEffect.random
429
438
  const txOptions = maxEffects !== undefined ? { maxEffects } : {};
430
439
  for (let i = 0; i < (blocks?.length ?? numBlocks); i++) {
@@ -433,11 +442,11 @@ export async function mockCheckpointAndMessages(
433
442
  block:
434
443
  blocks?.[i] ??
435
444
  (await L2Block.random(blockNumber, {
445
+ ...globals,
436
446
  checkpointNumber,
437
447
  indexWithinCheckpoint: IndexWithinCheckpoint(i),
438
448
  txsPerBlock: numTxsPerBlock,
439
449
  txOptions,
440
- slotNumber,
441
450
  ...options,
442
451
  ...makeBlockOptions(blockNumber),
443
452
  ...(lastArchive ? { lastArchive } : {}),
@@ -451,12 +460,18 @@ export async function mockCheckpointAndMessages(
451
460
 
452
461
  const messages = blocksAndMessages[0].messages;
453
462
  const inHash = computeInHashFromL1ToL2Messages(messages);
454
- const checkpoint = await Checkpoint.random(checkpointNumber, { numBlocks: 0, slotNumber, inHash, ...options });
463
+ const firstBlockLastArchive = blocksAndMessages[0].block.header.lastArchive;
464
+ const checkpoint = await Checkpoint.random(checkpointNumber, {
465
+ numBlocks: 0,
466
+ inHash,
467
+ ...options,
468
+ ...globals,
469
+ lastArchive: firstBlockLastArchive,
470
+ lastArchiveRoot: firstBlockLastArchive.root,
471
+ archive: lastArchive,
472
+ });
473
+
455
474
  checkpoint.blocks = blocksAndMessages.map(({ block }) => block);
456
- // Set the checkpoint's archive to match the last block's archive for proper chaining.
457
- // When the archiver reconstructs checkpoints from L1, it uses the checkpoint's archive root
458
- // from the L1 event to set the last block's archive. Without this, the archive chain breaks.
459
- checkpoint.archive = lastArchive!;
460
475
 
461
476
  // Return lastArchive so callers can chain it across multiple checkpoints
462
477
  return { checkpoint, messages, lastArchive };
@@ -176,6 +176,12 @@ export class BlockHeader {
176
176
  this._cachedHash = Promise.resolve(new BlockHash(hashed));
177
177
  }
178
178
 
179
+ /** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */
180
+ recomputeHash(): Promise<BlockHash> {
181
+ this._cachedHash = undefined;
182
+ return this.hash();
183
+ }
184
+
179
185
  static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
180
186
  return BlockHeader.from({
181
187
  lastArchive: AppendOnlyTreeSnapshot.random(),
@@ -7,6 +7,7 @@ import { z } from 'zod';
7
7
  import { SimulationError } from '../errors/simulation_error.js';
8
8
  import { Gas } from '../gas/gas.js';
9
9
  import type { GasUsed } from '../gas/gas_used.js';
10
+ import { DebugLog } from '../logs/debug_log.js';
10
11
  import { NullishToUndefined } from '../schemas/schemas.js';
11
12
  import { TxEffect } from '../tx/tx_effect.js';
12
13
  import { GlobalVariables } from './global_variables.js';
@@ -71,6 +72,7 @@ export class PublicSimulationOutput {
71
72
  public txEffect: TxEffect,
72
73
  public publicReturnValues: NestedProcessReturnValues[],
73
74
  public gasUsed: GasUsed,
75
+ public debugLogs: DebugLog[] = [],
74
76
  ) {}
75
77
 
76
78
  static get schema(): ZodFor<PublicSimulationOutput> {
@@ -86,6 +88,7 @@ export class PublicSimulationOutput {
86
88
  publicGas: Gas.schema,
87
89
  billedGas: Gas.schema,
88
90
  }),
91
+ debugLogs: z.array(DebugLog.schema).default([]),
89
92
  })
90
93
  .transform(
91
94
  fields =>
@@ -95,6 +98,7 @@ export class PublicSimulationOutput {
95
98
  fields.txEffect,
96
99
  fields.publicReturnValues,
97
100
  fields.gasUsed,
101
+ fields.debugLogs,
98
102
  ),
99
103
  );
100
104
  }
@@ -12,9 +12,11 @@ import { Gas } from '../gas/gas.js';
12
12
  import type { GasUsed } from '../gas/gas_used.js';
13
13
  import { PrivateKernelTailCircuitPublicInputs } from '../kernel/private_kernel_tail_circuit_public_inputs.js';
14
14
  import { ChonkProof } from '../proofs/chonk_proof.js';
15
+ import type { OffchainEffect } from './offchain_effect.js';
15
16
  import {
16
17
  PrivateCallExecutionResult,
17
18
  PrivateExecutionResult,
19
+ collectOffchainEffects,
18
20
  collectSortedContractClassLogs,
19
21
  } from './private_execution_result.js';
20
22
  import { type SimulationStats, SimulationStatsSchema } from './profiling.js';
@@ -84,6 +86,11 @@ export class TxSimulationResult {
84
86
  public stats?: SimulationStats,
85
87
  ) {}
86
88
 
89
+ /** Returns offchain effects collected from private execution. */
90
+ get offchainEffects(): OffchainEffect[] {
91
+ return collectOffchainEffects(this.privateExecutionResult);
92
+ }
93
+
87
94
  get gasUsed(): GasUsed {
88
95
  return (
89
96
  this.publicOutput?.gasUsed ?? {
@@ -106,7 +113,7 @@ export class TxSimulationResult {
106
113
  .transform(TxSimulationResult.from);
107
114
  }
108
115
 
109
- static from(fields: Omit<FieldsOf<TxSimulationResult>, 'gasUsed'>) {
116
+ static from(fields: Omit<FieldsOf<TxSimulationResult>, 'gasUsed' | 'offchainEffects'>) {
110
117
  return new TxSimulationResult(
111
118
  fields.privateExecutionResult,
112
119
  fields.publicInputs,