@aztec/stdlib 0.0.1-commit.db765a8 → 0.0.1-commit.df81a97b5

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 (232) hide show
  1. package/dest/abi/abi.d.ts +138 -1
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +10 -2
  4. package/dest/abi/buffer.d.ts +14 -4
  5. package/dest/abi/buffer.d.ts.map +1 -1
  6. package/dest/abi/buffer.js +25 -4
  7. package/dest/avm/avm.d.ts +300 -300
  8. package/dest/block/l2_block.d.ts +9 -1
  9. package/dest/block/l2_block.d.ts.map +1 -1
  10. package/dest/block/l2_block.js +12 -2
  11. package/dest/block/l2_block_source.d.ts +16 -8
  12. package/dest/block/l2_block_source.d.ts.map +1 -1
  13. package/dest/checkpoint/checkpoint.d.ts +2 -1
  14. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  15. package/dest/checkpoint/checkpoint.js +9 -4
  16. package/dest/checkpoint/index.d.ts +2 -1
  17. package/dest/checkpoint/index.d.ts.map +1 -1
  18. package/dest/checkpoint/index.js +1 -0
  19. package/dest/checkpoint/validate.d.ts +36 -0
  20. package/dest/checkpoint/validate.d.ts.map +1 -0
  21. package/dest/checkpoint/validate.js +120 -0
  22. package/dest/config/index.d.ts +2 -1
  23. package/dest/config/index.d.ts.map +1 -1
  24. package/dest/config/index.js +1 -0
  25. package/dest/config/pipelining-config.d.ts +19 -0
  26. package/dest/config/pipelining-config.d.ts.map +1 -0
  27. package/dest/config/pipelining-config.js +18 -0
  28. package/dest/config/sequencer-config.d.ts +2 -2
  29. package/dest/config/sequencer-config.d.ts.map +1 -1
  30. package/dest/config/sequencer-config.js +1 -2
  31. package/dest/contract/contract_address.d.ts +3 -3
  32. package/dest/contract/contract_address.js +3 -3
  33. package/dest/contract/contract_class_id.d.ts +2 -2
  34. package/dest/contract/contract_class_id.js +2 -2
  35. package/dest/contract/index.d.ts +1 -3
  36. package/dest/contract/index.d.ts.map +1 -1
  37. package/dest/contract/index.js +0 -2
  38. package/dest/contract/interfaces/contract_class.d.ts +3 -156
  39. package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
  40. package/dest/contract/interfaces/contract_class.js +1 -28
  41. package/dest/epoch-helpers/index.d.ts +7 -1
  42. package/dest/epoch-helpers/index.d.ts.map +1 -1
  43. package/dest/epoch-helpers/index.js +10 -2
  44. package/dest/ha-signing/config.d.ts +49 -14
  45. package/dest/ha-signing/config.d.ts.map +1 -1
  46. package/dest/ha-signing/config.js +20 -15
  47. package/dest/ha-signing/index.d.ts +3 -2
  48. package/dest/ha-signing/index.d.ts.map +1 -1
  49. package/dest/ha-signing/index.js +2 -1
  50. package/dest/ha-signing/local_config.d.ts +63 -0
  51. package/dest/ha-signing/local_config.d.ts.map +1 -0
  52. package/dest/ha-signing/local_config.js +24 -0
  53. package/dest/hash/hash.d.ts +16 -1
  54. package/dest/hash/hash.d.ts.map +1 -1
  55. package/dest/hash/hash.js +24 -0
  56. package/dest/interfaces/allowed_element.d.ts +25 -1
  57. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  58. package/dest/interfaces/allowed_element.js +8 -2
  59. package/dest/interfaces/archiver.d.ts +1 -1
  60. package/dest/interfaces/archiver.d.ts.map +1 -1
  61. package/dest/interfaces/archiver.js +3 -2
  62. package/dest/interfaces/aztec-node-admin.d.ts +70 -10
  63. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  64. package/dest/interfaces/aztec-node.d.ts +12 -6
  65. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  66. package/dest/interfaces/aztec-node.js +5 -2
  67. package/dest/interfaces/block-builder.d.ts +38 -11
  68. package/dest/interfaces/block-builder.d.ts.map +1 -1
  69. package/dest/interfaces/block-builder.js +12 -5
  70. package/dest/interfaces/configs.d.ts +47 -7
  71. package/dest/interfaces/configs.d.ts.map +1 -1
  72. package/dest/interfaces/configs.js +3 -1
  73. package/dest/interfaces/l2_logs_source.d.ts +5 -3
  74. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  75. package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
  76. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  77. package/dest/interfaces/prover-client.d.ts +6 -1
  78. package/dest/interfaces/prover-client.d.ts.map +1 -1
  79. package/dest/interfaces/prover-client.js +7 -1
  80. package/dest/interfaces/proving-job.d.ts +200 -200
  81. package/dest/interfaces/validator.d.ts +100 -21
  82. package/dest/interfaces/validator.d.ts.map +1 -1
  83. package/dest/interfaces/validator.js +7 -4
  84. package/dest/interfaces/world_state.d.ts +5 -4
  85. package/dest/interfaces/world_state.d.ts.map +1 -1
  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/index.d.ts +2 -1
  96. package/dest/logs/index.d.ts.map +1 -1
  97. package/dest/logs/index.js +1 -0
  98. package/dest/logs/log_filter.d.ts +4 -1
  99. package/dest/logs/log_filter.d.ts.map +1 -1
  100. package/dest/logs/log_filter.js +2 -1
  101. package/dest/logs/tagging_index_range.d.ts +40 -0
  102. package/dest/logs/tagging_index_range.d.ts.map +1 -0
  103. package/dest/logs/tagging_index_range.js +8 -0
  104. package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
  105. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  106. package/dest/logs/tx_scoped_l2_log.js +7 -0
  107. package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
  108. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  109. package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
  110. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  111. package/dest/messaging/l2_to_l1_membership.js +69 -26
  112. package/dest/noir/index.d.ts +3 -3
  113. package/dest/noir/index.d.ts.map +1 -1
  114. package/dest/p2p/checkpoint_proposal.d.ts +1 -6
  115. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  116. package/dest/p2p/checkpoint_proposal.js +13 -23
  117. package/dest/p2p/peer_error.d.ts +3 -1
  118. package/dest/p2p/peer_error.d.ts.map +1 -1
  119. package/dest/p2p/peer_error.js +5 -0
  120. package/dest/slashing/tally.d.ts +5 -6
  121. package/dest/slashing/tally.d.ts.map +1 -1
  122. package/dest/slashing/tally.js +19 -10
  123. package/dest/tests/factories.d.ts +2 -4
  124. package/dest/tests/factories.d.ts.map +1 -1
  125. package/dest/tests/factories.js +0 -27
  126. package/dest/tests/mocks.d.ts +4 -2
  127. package/dest/tests/mocks.d.ts.map +1 -1
  128. package/dest/tests/mocks.js +13 -8
  129. package/dest/tx/block_header.d.ts +3 -1
  130. package/dest/tx/block_header.d.ts.map +1 -1
  131. package/dest/tx/block_header.js +4 -0
  132. package/dest/tx/private_execution_result.d.ts +6 -6
  133. package/dest/tx/private_execution_result.d.ts.map +1 -1
  134. package/dest/tx/private_execution_result.js +6 -6
  135. package/dest/tx/profiling.d.ts +14 -2
  136. package/dest/tx/profiling.d.ts.map +1 -1
  137. package/dest/tx/profiling.js +13 -3
  138. package/dest/tx/simulated_tx.d.ts +109 -1
  139. package/dest/tx/simulated_tx.d.ts.map +1 -1
  140. package/dest/tx/tx.d.ts +6 -5
  141. package/dest/tx/tx.d.ts.map +1 -1
  142. package/dest/tx/tx.js +18 -6
  143. package/dest/tx/tx_receipt.d.ts +7 -2
  144. package/dest/tx/tx_receipt.d.ts.map +1 -1
  145. package/dest/tx/tx_receipt.js +6 -3
  146. package/dest/tx/validator/error_texts.d.ts +8 -1
  147. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  148. package/dest/tx/validator/error_texts.js +9 -0
  149. package/dest/update-checker/index.d.ts +3 -2
  150. package/dest/update-checker/index.d.ts.map +1 -1
  151. package/dest/update-checker/index.js +2 -1
  152. package/dest/update-checker/package_version.d.ts +3 -0
  153. package/dest/update-checker/package_version.d.ts.map +1 -0
  154. package/dest/update-checker/package_version.js +24 -0
  155. package/dest/update-checker/version_checker.d.ts +25 -0
  156. package/dest/update-checker/version_checker.d.ts.map +1 -0
  157. package/dest/update-checker/version_checker.js +50 -0
  158. package/dest/validators/errors.d.ts +6 -1
  159. package/dest/validators/errors.d.ts.map +1 -1
  160. package/dest/validators/errors.js +7 -0
  161. package/dest/versioning/versioning.d.ts +4 -2
  162. package/dest/versioning/versioning.d.ts.map +1 -1
  163. package/dest/versioning/versioning.js +4 -1
  164. package/package.json +10 -9
  165. package/src/abi/abi.ts +25 -2
  166. package/src/abi/buffer.ts +25 -4
  167. package/src/block/l2_block.ts +13 -1
  168. package/src/block/l2_block_source.ts +16 -7
  169. package/src/checkpoint/checkpoint.ts +12 -3
  170. package/src/checkpoint/index.ts +1 -0
  171. package/src/checkpoint/validate.ts +230 -0
  172. package/src/config/index.ts +1 -0
  173. package/src/config/pipelining-config.ts +31 -0
  174. package/src/config/sequencer-config.ts +2 -2
  175. package/src/contract/contract_address.ts +3 -3
  176. package/src/contract/contract_class_id.ts +2 -2
  177. package/src/contract/index.ts +0 -2
  178. package/src/contract/interfaces/contract_class.ts +2 -82
  179. package/src/epoch-helpers/index.ts +14 -0
  180. package/src/gas/README.md +123 -0
  181. package/src/ha-signing/config.ts +45 -38
  182. package/src/ha-signing/index.ts +9 -0
  183. package/src/ha-signing/local_config.ts +46 -0
  184. package/src/hash/hash.ts +29 -0
  185. package/src/interfaces/allowed_element.ts +28 -4
  186. package/src/interfaces/archiver.ts +3 -2
  187. package/src/interfaces/aztec-node.ts +24 -5
  188. package/src/interfaces/block-builder.ts +56 -13
  189. package/src/interfaces/configs.ts +15 -4
  190. package/src/interfaces/l2_logs_source.ts +4 -1
  191. package/src/interfaces/merkle_tree_operations.ts +8 -18
  192. package/src/interfaces/prover-client.ts +8 -0
  193. package/src/interfaces/validator.ts +49 -28
  194. package/src/interfaces/world_state.ts +4 -3
  195. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
  196. package/src/kv-store/config.ts +36 -0
  197. package/src/kv-store/index.ts +1 -0
  198. package/src/logs/index.ts +1 -0
  199. package/src/logs/log_filter.ts +5 -0
  200. package/src/logs/tagging_index_range.ts +24 -0
  201. package/src/logs/tx_scoped_l2_log.ts +16 -0
  202. package/src/messaging/l1_to_l2_message_source.ts +3 -1
  203. package/src/messaging/l2_to_l1_membership.ts +98 -33
  204. package/src/noir/index.ts +2 -2
  205. package/src/p2p/checkpoint_proposal.ts +23 -37
  206. package/src/p2p/peer_error.ts +7 -0
  207. package/src/slashing/tally.ts +22 -4
  208. package/src/tests/factories.ts +0 -33
  209. package/src/tests/mocks.ts +18 -7
  210. package/src/tx/block_header.ts +6 -0
  211. package/src/tx/private_execution_result.ts +5 -5
  212. package/src/tx/profiling.ts +11 -2
  213. package/src/tx/tx.ts +20 -11
  214. package/src/tx/tx_receipt.ts +7 -2
  215. package/src/tx/validator/error_texts.ts +11 -0
  216. package/src/update-checker/index.ts +2 -1
  217. package/src/update-checker/package_version.ts +30 -0
  218. package/src/update-checker/version_checker.ts +65 -0
  219. package/src/validators/errors.ts +9 -0
  220. package/src/versioning/versioning.ts +4 -1
  221. package/dest/contract/private_function_membership_proof.d.ts +0 -32
  222. package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
  223. package/dest/contract/private_function_membership_proof.js +0 -124
  224. package/dest/contract/utility_function_membership_proof.d.ts +0 -27
  225. package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
  226. package/dest/contract/utility_function_membership_proof.js +0 -87
  227. package/dest/update-checker/update-checker.d.ts +0 -49
  228. package/dest/update-checker/update-checker.d.ts.map +0 -1
  229. package/dest/update-checker/update-checker.js +0 -130
  230. package/src/contract/private_function_membership_proof.ts +0 -167
  231. package/src/contract/utility_function_membership_proof.ts +0 -118
  232. package/src/update-checker/update-checker.ts +0 -166
@@ -20,49 +20,67 @@ import type { PeerId } from '@libp2p/interface';
20
20
  import { z } from 'zod';
21
21
 
22
22
  import type { CommitteeAttestationsAndSigners } from '../block/index.js';
23
- import { type ValidatorHASignerConfig, ValidatorHASignerConfigSchema } from '../ha-signing/index.js';
23
+ import {
24
+ type LocalSignerConfig,
25
+ LocalSignerConfigSchema,
26
+ type ValidatorHASignerConfig,
27
+ ValidatorHASignerConfigSchema,
28
+ } from '../ha-signing/index.js';
24
29
  import { AllowedElementSchema } from './allowed_element.js';
25
30
 
26
31
  /**
27
32
  * Validator client configuration
28
33
  */
29
- export type ValidatorClientConfig = ValidatorHASignerConfig & {
30
- /** The private keys of the validators participating in attestation duties */
31
- validatorPrivateKeys?: SecretValue<`0x${string}`[]>;
34
+ export type ValidatorClientConfig = ValidatorHASignerConfig &
35
+ LocalSignerConfig & {
36
+ /** The private keys of the validators participating in attestation duties */
37
+ validatorPrivateKeys?: SecretValue<`0x${string}`[]>;
32
38
 
33
- /** The addresses of the validators to use with remote signers */
34
- validatorAddresses?: EthAddress[];
39
+ /** The addresses of the validators to use with remote signers */
40
+ validatorAddresses?: EthAddress[];
35
41
 
36
- /** Do not run the validator */
37
- disableValidator: boolean;
42
+ /** Do not run the validator */
43
+ disableValidator: boolean;
38
44
 
39
- /** Temporarily disable these specific validator addresses */
40
- disabledValidators: EthAddress[];
45
+ /** Temporarily disable these specific validator addresses */
46
+ disabledValidators: EthAddress[];
41
47
 
42
- /** Interval between polling for new attestations from peers */
43
- attestationPollingIntervalMs: number;
48
+ /** Interval between polling for new attestations from peers */
49
+ attestationPollingIntervalMs: number;
44
50
 
45
- /** Whether to re-execute transactions in a block proposal before attesting */
46
- validatorReexecute: boolean;
51
+ /** Whether to re-execute transactions in a block proposal before attesting */
52
+ validatorReexecute: boolean;
47
53
 
48
- /** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
49
- alwaysReexecuteBlockProposals?: boolean;
54
+ /** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
55
+ alwaysReexecuteBlockProposals?: boolean;
50
56
 
51
- /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
52
- fishermanMode?: boolean;
57
+ /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
58
+ fishermanMode?: boolean;
53
59
 
54
- /** Skip checkpoint proposal validation and always attest (default: false) */
55
- skipCheckpointProposalValidation?: boolean;
60
+ /** Skip checkpoint proposal validation and always attest (default: false) */
61
+ skipCheckpointProposalValidation?: boolean;
56
62
 
57
- /** Skip pushing re-executed blocks to archiver (default: false) */
58
- skipPushProposedBlocksToArchiver?: boolean;
63
+ /** Skip pushing re-executed blocks to archiver (default: false) */
64
+ skipPushProposedBlocksToArchiver?: boolean;
59
65
 
60
- /** Agree to attest to equivocated checkpoint proposals (for testing purposes only) */
61
- attestToEquivocatedProposals?: boolean;
62
- };
66
+ /** Agree to attest to equivocated checkpoint proposals (for testing purposes only) */
67
+ attestToEquivocatedProposals?: boolean;
68
+
69
+ /** Maximum L2 gas per block for validation. Proposals exceeding this limit are rejected. */
70
+ validateMaxL2BlockGas?: number;
71
+
72
+ /** Maximum DA gas per block for validation. Proposals exceeding this limit are rejected. */
73
+ validateMaxDABlockGas?: number;
74
+
75
+ /** Maximum transactions per block for validation. Proposals exceeding this limit are rejected. */
76
+ validateMaxTxsPerBlock?: number;
77
+
78
+ /** Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected. */
79
+ validateMaxTxsPerCheckpoint?: number;
80
+ };
63
81
 
64
82
  export type ValidatorClientFullConfig = ValidatorClientConfig &
65
- Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal' | 'maxTxsPerBlock'> &
83
+ Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal'> &
66
84
  Pick<
67
85
  SlasherConfig,
68
86
  'slashBroadcastedInvalidBlockPenalty' | 'slashDuplicateProposalPenalty' | 'slashDuplicateAttestationPenalty'
@@ -75,7 +93,7 @@ export type ValidatorClientFullConfig = ValidatorClientConfig &
75
93
  };
76
94
 
77
95
  export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>()(
78
- ValidatorHASignerConfigSchema.extend({
96
+ ValidatorHASignerConfigSchema.merge(LocalSignerConfigSchema).extend({
79
97
  validatorAddresses: z.array(schemas.EthAddress).optional(),
80
98
  disableValidator: z.boolean(),
81
99
  disabledValidators: z.array(schemas.EthAddress),
@@ -86,6 +104,10 @@ export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'v
86
104
  skipCheckpointProposalValidation: z.boolean().optional(),
87
105
  skipPushProposedBlocksToArchiver: z.boolean().optional(),
88
106
  attestToEquivocatedProposals: z.boolean().optional(),
107
+ validateMaxL2BlockGas: z.number().optional(),
108
+ validateMaxDABlockGas: z.number().optional(),
109
+ validateMaxTxsPerBlock: z.number().optional(),
110
+ validateMaxTxsPerCheckpoint: z.number().optional(),
89
111
  }),
90
112
  );
91
113
 
@@ -93,7 +115,6 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
93
115
  ValidatorClientConfigSchema.extend({
94
116
  txPublicSetupAllowListExtend: z.array(AllowedElementSchema).optional(),
95
117
  broadcastInvalidBlockProposal: z.boolean().optional(),
96
- maxTxsPerBlock: z.number().optional(),
97
118
  slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
98
119
  slashDuplicateProposalPenalty: schemas.BigInt,
99
120
  slashDuplicateAttestationPenalty: schemas.BigInt,
@@ -3,6 +3,7 @@ import type { PromiseWithResolvers } from '@aztec/foundation/promise';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
+ import type { BlockHash } from '../block/block_hash.js';
6
7
  import type { SnapshotDataKeys } from '../snapshots/types.js';
7
8
  import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from './merkle_tree_operations.js';
8
9
 
@@ -80,12 +81,12 @@ export interface WorldStateSynchronizer extends ReadonlyWorldStateAccess, ForkMe
80
81
  resumeSync(): void;
81
82
 
82
83
  /**
83
- * Forces an immediate sync to an optionally provided minimum block number
84
+ * Forces an immediate sync to an optionally provided minimum block number.
84
85
  * @param targetBlockNumber - The target block number that we must sync to. Will download unproven blocks if needed to reach it.
85
- * @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
86
+ * @param blockHash - If provided, verifies the block at targetBlockNumber matches this hash. On mismatch, triggers a resync (reorg detection).
86
87
  * @returns A promise that resolves with the block number the world state was synced to
87
88
  */
88
- syncImmediate(minBlockNumber?: BlockNumber, skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber>;
89
+ syncImmediate(minBlockNumber?: BlockNumber, blockHash?: BlockHash): Promise<BlockNumber>;
89
90
 
90
91
  /** Deletes the db */
91
92
  clear(): Promise<void>;
@@ -234,6 +234,15 @@ export class PrivateKernelTailCircuitPublicInputs {
234
234
  return noteHashes.filter(n => !n.isZero());
235
235
  }
236
236
 
237
+ getNonEmptyL2ToL1Msgs() {
238
+ const l2ToL1Msgs = this.forPublic
239
+ ? this.forPublic.nonRevertibleAccumulatedData.l2ToL1Msgs.concat(
240
+ this.forPublic.revertibleAccumulatedData.l2ToL1Msgs,
241
+ )
242
+ : this.forRollup!.end.l2ToL1Msgs;
243
+ return l2ToL1Msgs.filter(m => !m.isEmpty());
244
+ }
245
+
237
246
  getNonEmptyNullifiers() {
238
247
  const nullifiers = this.forPublic
239
248
  ? this.forPublic.nonRevertibleAccumulatedData.nullifiers.concat(
@@ -0,0 +1,36 @@
1
+ import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
2
+ import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+
5
+ export type DataStoreConfig = {
6
+ dataDirectory?: string;
7
+ dataStoreMapSizeKb: number;
8
+ l1Contracts?: { rollupAddress: EthAddress };
9
+ };
10
+
11
+ export const dataConfigMappings: ConfigMappingsType<DataStoreConfig> = {
12
+ dataDirectory: {
13
+ env: 'DATA_DIRECTORY',
14
+ description: 'Optional dir to store data. If omitted will store in memory.',
15
+ },
16
+ dataStoreMapSizeKb: {
17
+ env: 'DATA_STORE_MAP_SIZE_KB',
18
+ description: 'The maximum possible size of a data store DB in KB. Can be overridden by component-specific options.',
19
+ ...numberConfigHelper(128 * 1_024 * 1_024), // Defaulted to 128 GB
20
+ },
21
+ l1Contracts: {
22
+ description: 'The deployed L1 contract addresses',
23
+ nested: {
24
+ rollupAddress: l1ContractAddressesMapping.rollupAddress,
25
+ },
26
+ },
27
+ };
28
+
29
+ /**
30
+ * Returns the archiver configuration from the environment variables.
31
+ * Note: If an environment variable is not set, the default value is used.
32
+ * @returns The archiver configuration.
33
+ */
34
+ export function getDataConfigFromEnv(): DataStoreConfig {
35
+ return getConfigFromMappings<DataStoreConfig>(dataConfigMappings);
36
+ }
@@ -0,0 +1 @@
1
+ export * from './config.js';
package/src/logs/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './extended_directional_app_tagging_secret.js';
2
2
  export * from './pre_tag.js';
3
+ export * from './tagging_index_range.js';
3
4
  export * from './contract_class_log.js';
4
5
  export * from './public_log.js';
5
6
  export * from './private_log.js';
@@ -1,3 +1,5 @@
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
+
1
3
  import { z } from 'zod';
2
4
 
3
5
  import type { AztecAddress } from '../aztec-address/index.js';
@@ -20,6 +22,8 @@ export type LogFilter = {
20
22
  afterLog?: LogId;
21
23
  /** The contract address to filter logs by. */
22
24
  contractAddress?: AztecAddress;
25
+ /** The tag (first field of the log) to filter logs by. */
26
+ tag?: Fr;
23
27
  };
24
28
 
25
29
  export const LogFilterSchema: ZodFor<LogFilter> = z.object({
@@ -28,4 +32,5 @@ export const LogFilterSchema: ZodFor<LogFilter> = z.object({
28
32
  toBlock: schemas.Integer.optional(),
29
33
  afterLog: LogId.schema.optional(),
30
34
  contractAddress: schemas.AztecAddress.optional(),
35
+ tag: schemas.Fr.optional(),
31
36
  });
@@ -0,0 +1,24 @@
1
+ import { schemas } from '@aztec/foundation/schemas';
2
+
3
+ import { z } from 'zod';
4
+
5
+ import {
6
+ type ExtendedDirectionalAppTaggingSecret,
7
+ ExtendedDirectionalAppTaggingSecretSchema,
8
+ } from './extended_directional_app_tagging_secret.js';
9
+
10
+ /**
11
+ * Represents a range of tagging indexes for a given extended directional app tagging secret. Used to track the lowest
12
+ * and highest indexes used in a transaction for a given (sender, recipient, app/contract) tuple.
13
+ */
14
+ export type TaggingIndexRange = {
15
+ extendedSecret: ExtendedDirectionalAppTaggingSecret;
16
+ lowestIndex: number;
17
+ highestIndex: number;
18
+ };
19
+
20
+ export const TaggingIndexRangeSchema = z.object({
21
+ extendedSecret: ExtendedDirectionalAppTaggingSecretSchema,
22
+ lowestIndex: schemas.Integer,
23
+ highestIndex: schemas.Integer,
24
+ });
@@ -1,4 +1,5 @@
1
1
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
2
+ import { times } from '@aztec/foundation/collection';
2
3
  import { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import { schemas as foundationSchemas } from '@aztec/foundation/schemas';
4
5
  import {
@@ -83,6 +84,21 @@ export class TxScopedL2Log {
83
84
  return new TxScopedL2Log(txHash, blockNumber, blockTimestamp, logData, noteHashes, firstNullifier);
84
85
  }
85
86
 
87
+ static getBlockNumberFromBuffer(buffer: Buffer) {
88
+ return BlockNumber(buffer.readUint32BE(Fr.SIZE_IN_BYTES));
89
+ }
90
+
91
+ static random() {
92
+ return new TxScopedL2Log(
93
+ TxHash.fromField(Fr.random()),
94
+ BlockNumber(Math.floor(Math.random() * 100000) + 1),
95
+ BigInt(Math.floor(Date.now() / 1000)),
96
+ times(3, Fr.random),
97
+ times(3, Fr.random),
98
+ Fr.random(),
99
+ );
100
+ }
101
+
86
102
  equals(other: TxScopedL2Log) {
87
103
  return (
88
104
  this.txHash.equals(other.txHash) &&
@@ -10,7 +10,9 @@ export interface L1ToL2MessageSource {
10
10
  /**
11
11
  * Gets new L1 to L2 message (to be) included in a given checkpoint.
12
12
  * @param checkpointNumber - Checkpoint number to get messages for.
13
- * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
13
+ * @returns The L1 to L2 messages/leaves of the messages subtree.
14
+ * @throws If the message tree for the given checkpoint has not yet been sealed on L1
15
+ * (i.e., checkpointNumber >= inbox treeInProgress).
14
16
  */
15
17
  getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]>;
16
18
 
@@ -3,6 +3,9 @@ import type { EpochNumber } from '@aztec/foundation/branded-types';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { SiblingPath, UnbalancedMerkleTreeCalculator, computeUnbalancedShaRoot } from '@aztec/foundation/trees';
5
5
 
6
+ import type { AztecNode } from '../interfaces/aztec-node.js';
7
+ import { TxHash } from '../tx/tx_hash.js';
8
+
6
9
  /**
7
10
  * # L2-to-L1 Message Tree Structure and Leaf IDs
8
11
  *
@@ -92,59 +95,94 @@ export function getL2ToL1MessageLeafId(
92
95
  return 2n ** BigInt(membershipWitness.siblingPath.pathSize) + membershipWitness.leafIndex;
93
96
  }
94
97
 
95
- export interface MessageRetrieval {
96
- getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]>;
97
- }
98
-
99
98
  export type L2ToL1MembershipWitness = {
100
99
  root: Fr;
101
100
  leafIndex: bigint;
102
101
  siblingPath: SiblingPath<number>;
102
+ epochNumber: EpochNumber;
103
103
  };
104
104
 
105
+ /**
106
+ * Computes the L2 to L1 membership witness for a given message in a transaction.
107
+ *
108
+ * @param node - The Aztec node to query for block/tx/epoch data.
109
+ * @param message - The L2 to L1 message hash to prove membership of.
110
+ * @param txHash - The hash of the transaction that emitted the message.
111
+ * @param messageIndexInTx - Optional index of the message within the transaction's L2-to-L1 messages.
112
+ * If not provided, the message is found by scanning the tx's messages (throws if duplicates exist).
113
+ * @returns The membership witness and epoch number, or undefined if the tx is not yet in a block/epoch.
114
+ */
105
115
  export async function computeL2ToL1MembershipWitness(
106
- messageRetriever: MessageRetrieval,
107
- epoch: EpochNumber,
116
+ node: Pick<
117
+ AztecNode,
118
+ 'getL2ToL1Messages' | 'getTxReceipt' | 'getTxEffect' | 'getBlock' | 'getCheckpointsDataForEpoch'
119
+ >,
108
120
  message: Fr,
121
+ txHash: TxHash,
122
+ messageIndexInTx?: number,
109
123
  ): Promise<L2ToL1MembershipWitness | undefined> {
110
- const messagesInEpoch = await messageRetriever.getL2ToL1Messages(epoch);
111
- if (messagesInEpoch.length === 0) {
124
+ const { epochNumber, blockNumber } = await node.getTxReceipt(txHash);
125
+ if (epochNumber === undefined || blockNumber === undefined) {
126
+ return undefined;
127
+ }
128
+
129
+ const [messagesInEpoch, block, txEffect, checkpointsData] = await Promise.all([
130
+ node.getL2ToL1Messages(epochNumber),
131
+ node.getBlock(blockNumber),
132
+ node.getTxEffect(txHash),
133
+ node.getCheckpointsDataForEpoch(epochNumber),
134
+ ]);
135
+
136
+ if (messagesInEpoch.length === 0 || !block || !txEffect) {
137
+ return undefined;
138
+ }
139
+
140
+ const checkpointIndex = checkpointsData.findIndex(c => c.checkpointNumber === block.checkpointNumber);
141
+ if (checkpointIndex === -1) {
112
142
  return undefined;
113
143
  }
114
144
 
115
- return computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, message);
145
+ const blockIndex = block.indexWithinCheckpoint;
146
+ const txIndex = txEffect.txIndexInBlock;
147
+
148
+ const { root, leafIndex, siblingPath } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(
149
+ messagesInEpoch,
150
+ message,
151
+ checkpointIndex,
152
+ blockIndex,
153
+ txIndex,
154
+ messageIndexInTx,
155
+ );
156
+ return { epochNumber, root, leafIndex, siblingPath };
116
157
  }
117
158
 
118
- // TODO: Allow to specify the message to consume by its index or by an offset, in case there are multiple messages with
119
- // the same value.
159
+ /**
160
+ * Computes a membership witness for a message in the epoch's L2-to-L1 message tree, given explicit position indices.
161
+ *
162
+ * @param messagesInEpoch - All L2-to-L1 messages in the epoch, organized as checkpoints → blocks → txs → messages.
163
+ * @param message - The message hash to prove membership of.
164
+ * @param checkpointIndex - Index of the checkpoint within the epoch's message array.
165
+ * @param blockIndex - Index of the block within the checkpoint.
166
+ * @param txIndex - Index of the transaction within the block.
167
+ * @param messageIndexInTx - Optional index of the message within the transaction's messages.
168
+ * If not provided, the message is found by scanning (throws if duplicates exist within the tx).
169
+ */
170
+ /** @internal Exported for testing only. */
120
171
  export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
121
172
  messagesInEpoch: Fr[][][][],
122
173
  message: Fr,
123
- ): L2ToL1MembershipWitness {
124
- // Find the index of the message in the tx, index of the tx in the block, and index of the block in the epoch.
125
- let messageIndexInTx = -1;
126
- let txIndex = -1;
127
- let blockIndex = -1;
128
- const checkpointIndex = messagesInEpoch.findIndex(messagesInCheckpoint => {
129
- blockIndex = messagesInCheckpoint.findIndex(messagesInBlock => {
130
- txIndex = messagesInBlock.findIndex(messagesInTx => {
131
- messageIndexInTx = messagesInTx.findIndex(msg => msg.equals(message));
132
- return messageIndexInTx !== -1;
133
- });
134
- return txIndex !== -1;
135
- });
136
- return blockIndex !== -1;
137
- });
138
-
139
- if (checkpointIndex === -1) {
140
- throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
141
- }
174
+ checkpointIndex: number,
175
+ blockIndex: number,
176
+ txIndex: number,
177
+ messageIndexInTx?: number,
178
+ ): { root: Fr; leafIndex: bigint; siblingPath: SiblingPath<number> } {
179
+ const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
180
+ const resolvedMessageIndex = resolveMessageIndex(messagesInTx, message, messageIndexInTx);
142
181
 
143
182
  // Build the tx tree.
144
- const messagesInTx = messagesInEpoch[checkpointIndex][blockIndex][txIndex];
145
183
  const txTree = UnbalancedMerkleTreeCalculator.create(messagesInTx.map(msg => msg.toBuffer()));
146
184
  // Get the sibling path of the target message in the tx tree.
147
- const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(messageIndexInTx);
185
+ const pathToMessageInTxSubtree = txTree.getSiblingPathByLeafIndex(resolvedMessageIndex);
148
186
 
149
187
  // Build the tree of the block containing the target message.
150
188
  const blockTree = buildBlockTree(messagesInEpoch[checkpointIndex][blockIndex]);
@@ -189,7 +227,7 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
189
227
  // Compute the combined index.
190
228
  // It is the index of the message in the balanced tree (by filling up the wonky tree with empty nodes) at its current
191
229
  // height. It's used to validate the membership proof.
192
- const messageLeafPosition = txTree.getLeafLocation(messageIndexInTx);
230
+ const messageLeafPosition = txTree.getLeafLocation(resolvedMessageIndex);
193
231
  const txLeafPosition = blockTree.getLeafLocation(txIndex);
194
232
  const blockLeafPosition = checkpointTree.getLeafLocation(blockIndex);
195
233
  const checkpointLeafPosition = epochTree.getLeafLocation(checkpointIndex);
@@ -207,6 +245,33 @@ export function computeL2ToL1MembershipWitnessFromMessagesInEpoch(
207
245
  };
208
246
  }
209
247
 
248
+ function resolveMessageIndex(messagesInTx: Fr[], message: Fr, messageIndexInTx?: number): number {
249
+ if (messageIndexInTx !== undefined) {
250
+ if (!messagesInTx[messageIndexInTx]?.equals(message)) {
251
+ throw new Error(`Message at index ${messageIndexInTx} in tx does not match the expected message ${message}`);
252
+ }
253
+ return messageIndexInTx;
254
+ }
255
+
256
+ const indices = messagesInTx.reduce<number[]>((acc, msg, i) => {
257
+ if (msg.equals(message)) {
258
+ acc.push(i);
259
+ }
260
+ return acc;
261
+ }, []);
262
+
263
+ if (indices.length === 0) {
264
+ throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
265
+ }
266
+ if (indices.length > 1) {
267
+ throw new Error(
268
+ `Multiple messages with the same value ${message} found in tx (indices: ${indices.join(', ')}). ` +
269
+ `Provide messageIndexInTx to disambiguate.`,
270
+ );
271
+ }
272
+ return indices[0];
273
+ }
274
+
210
275
  function buildCheckpointTree(messagesInCheckpoint: Fr[][][]) {
211
276
  const blockOutHashes = messagesInCheckpoint.map(messagesInBlock => buildBlockTree(messagesInBlock).getRoot());
212
277
  return buildCompressedTree(blockOutHashes);
package/src/noir/index.ts CHANGED
@@ -19,7 +19,7 @@ export const AZTEC_VIEW_ATTRIBUTE = 'abi_view';
19
19
  export interface NoirFunctionAbi {
20
20
  /** The parameters of the function. */
21
21
  parameters: ABIParameter[];
22
- /** The return type of the function. */
22
+ /** The return type of the function, or null for void functions. */
23
23
  return_type: {
24
24
  /**
25
25
  * The type of the return value.
@@ -29,7 +29,7 @@ export interface NoirFunctionAbi {
29
29
  * The visibility of the return value.
30
30
  */
31
31
  visibility: ABIParameterVisibility;
32
- };
32
+ } | null;
33
33
  /** Mapping of error selector => error type */
34
34
  error_types: Partial<Record<string, AbiErrorType>>;
35
35
  }
@@ -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
@@ -195,29 +178,32 @@ export class CheckpointProposal extends Gossipable {
195
178
  blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
196
179
  dutyType: DutyType.CHECKPOINT_PROPOSAL,
197
180
  };
198
- const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
199
181
 
200
- if (!lastBlockInfo) {
201
- return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
182
+ if (lastBlockInfo) {
183
+ // Sign block proposal before signing checkpoint proposal to ensure HA protection
184
+ const lastBlockProposal = await BlockProposal.createProposalFromSigner(
185
+ lastBlockInfo.blockHeader,
186
+ lastBlockInfo.indexWithinCheckpoint,
187
+ checkpointHeader.inHash,
188
+ archiveRoot,
189
+ lastBlockInfo.txHashes,
190
+ lastBlockInfo.txs,
191
+ payloadSigner,
192
+ );
193
+
194
+ const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
195
+
196
+ return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
197
+ blockHeader: lastBlockInfo.blockHeader,
198
+ indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
199
+ txHashes: lastBlockInfo.txHashes,
200
+ signature: lastBlockProposal.signature,
201
+ signedTxs: lastBlockProposal.signedTxs,
202
+ });
202
203
  }
203
204
 
204
- const lastBlockProposal = await BlockProposal.createProposalFromSigner(
205
- lastBlockInfo.blockHeader,
206
- lastBlockInfo.indexWithinCheckpoint,
207
- checkpointHeader.inHash,
208
- archiveRoot,
209
- lastBlockInfo.txHashes,
210
- lastBlockInfo.txs,
211
- payloadSigner,
212
- );
213
-
214
- return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
215
- blockHeader: lastBlockInfo.blockHeader,
216
- indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
217
- txHashes: lastBlockInfo.txHashes,
218
- signature: lastBlockProposal.signature,
219
- signedTxs: lastBlockProposal.signedTxs,
220
- });
205
+ const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
206
+ return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
221
207
  }
222
208
 
223
209
  /**
@@ -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,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';
@@ -13,7 +14,8 @@ import type { Offense, ValidatorSlashVote } from './types.js';
13
14
  * @param epochsForCommittees - Array of epochs corresponding to each committee
14
15
  * @param settings - Settings including slashingAmounts and optional validator override lists
15
16
  * @param settings.maxSlashedValidators - If set, limits the total number of [validator, epoch] pairs
16
- * with non-zero votes.
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.
17
19
  * @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
18
20
  */
19
21
  export function getSlashConsensusVotesFromOffenses(
@@ -26,7 +28,8 @@ export function getSlashConsensusVotesFromOffenses(
26
28
  targetCommitteeSize: number;
27
29
  maxSlashedValidators?: number;
28
30
  },
29
- ): { votes: ValidatorSlashVote[]; truncatedCount: number } {
31
+ logger: Logger = createLogger('slasher:tally'),
32
+ ): ValidatorSlashVote[] {
30
33
  const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
31
34
 
32
35
  if (committees.length !== epochsForCommittees.length) {
@@ -58,7 +61,7 @@ export function getSlashConsensusVotesFromOffenses(
58
61
 
59
62
  // if a cap is set, zero out the lowest-vote [validator, epoch] pairs so that the most severe slashes stay.
60
63
  if (maxSlashedValidators === undefined) {
61
- return { votes, truncatedCount: 0 };
64
+ return votes;
62
65
  }
63
66
 
64
67
  const nonZeroByDescendingVote = [...votes.entries()].filter(([, vote]) => vote > 0).sort(([, a], [, b]) => b - a);
@@ -68,7 +71,22 @@ export function getSlashConsensusVotesFromOffenses(
68
71
  votes[idx] = 0;
69
72
  }
70
73
 
71
- return { votes, truncatedCount: toTruncate.length };
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
+
89
+ return votes;
72
90
  }
73
91
 
74
92
  /** Returns the slash vote for the given amount to slash. */