@aztec/stdlib 0.0.1-commit.f650c0a5c → 0.0.1-commit.f7ea82942

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 (205) hide show
  1. package/dest/abi/authorization_selector.d.ts +3 -6
  2. package/dest/abi/authorization_selector.d.ts.map +1 -1
  3. package/dest/abi/encoder.d.ts +1 -1
  4. package/dest/abi/encoder.d.ts.map +1 -1
  5. package/dest/abi/encoder.js +32 -6
  6. package/dest/abi/event_selector.d.ts +3 -6
  7. package/dest/abi/event_selector.d.ts.map +1 -1
  8. package/dest/abi/function_selector.d.ts +3 -6
  9. package/dest/abi/function_selector.d.ts.map +1 -1
  10. package/dest/abi/function_selector.js +1 -3
  11. package/dest/abi/note_selector.d.ts +3 -6
  12. package/dest/abi/note_selector.d.ts.map +1 -1
  13. package/dest/abi/note_selector.js +1 -3
  14. package/dest/avm/avm.d.ts +300 -300
  15. package/dest/aztec-address/index.d.ts +3 -6
  16. package/dest/aztec-address/index.d.ts.map +1 -1
  17. package/dest/aztec-address/index.js +2 -4
  18. package/dest/block/block_data.d.ts +8 -8
  19. package/dest/block/block_data.d.ts.map +1 -1
  20. package/dest/block/block_data.js +2 -2
  21. package/dest/block/block_hash.d.ts +11 -10
  22. package/dest/block/block_hash.d.ts.map +1 -1
  23. package/dest/block/block_hash.js +10 -9
  24. package/dest/block/l2_block_info.d.ts +6 -5
  25. package/dest/block/l2_block_info.d.ts.map +1 -1
  26. package/dest/block/l2_block_info.js +6 -5
  27. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  28. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  29. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  30. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  31. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  32. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  33. package/dest/config/chain-config.d.ts +1 -1
  34. package/dest/config/chain-config.d.ts.map +1 -1
  35. package/dest/config/chain-config.js +7 -1
  36. package/dest/config/sequencer-config.d.ts +2 -2
  37. package/dest/config/sequencer-config.d.ts.map +1 -1
  38. package/dest/config/sequencer-config.js +10 -3
  39. package/dest/contract/private_function.d.ts +1 -1
  40. package/dest/contract/private_function.d.ts.map +1 -1
  41. package/dest/contract/private_function.js +2 -4
  42. package/dest/gas/fee_math.d.ts +49 -0
  43. package/dest/gas/fee_math.d.ts.map +1 -0
  44. package/dest/gas/fee_math.js +80 -0
  45. package/dest/gas/gas_fees.d.ts +5 -1
  46. package/dest/gas/gas_fees.d.ts.map +1 -1
  47. package/dest/gas/gas_fees.js +10 -1
  48. package/dest/gas/index.d.ts +2 -1
  49. package/dest/gas/index.d.ts.map +1 -1
  50. package/dest/gas/index.js +1 -0
  51. package/dest/ha-signing/config.d.ts +6 -6
  52. package/dest/ha-signing/config.d.ts.map +1 -1
  53. package/dest/ha-signing/config.js +4 -3
  54. package/dest/ha-signing/index.d.ts +2 -2
  55. package/dest/ha-signing/index.d.ts.map +1 -1
  56. package/dest/ha-signing/index.js +1 -1
  57. package/dest/ha-signing/local_config.js +1 -1
  58. package/dest/ha-signing/types.d.ts +37 -32
  59. package/dest/ha-signing/types.d.ts.map +1 -1
  60. package/dest/ha-signing/types.js +13 -6
  61. package/dest/hash/hash.d.ts +16 -1
  62. package/dest/hash/hash.d.ts.map +1 -1
  63. package/dest/hash/hash.js +32 -0
  64. package/dest/interfaces/archiver.d.ts +11 -1
  65. package/dest/interfaces/archiver.d.ts.map +1 -1
  66. package/dest/interfaces/archiver.js +3 -1
  67. package/dest/interfaces/aztec-node-admin.d.ts +6 -4
  68. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  69. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  70. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  71. package/dest/interfaces/aztec-node-debug.js +18 -0
  72. package/dest/interfaces/aztec-node.d.ts +10 -1
  73. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  74. package/dest/interfaces/aztec-node.js +2 -0
  75. package/dest/interfaces/client.d.ts +2 -1
  76. package/dest/interfaces/client.d.ts.map +1 -1
  77. package/dest/interfaces/client.js +1 -0
  78. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  79. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  80. package/dest/interfaces/prover-client.d.ts +1 -1
  81. package/dest/interfaces/prover-client.d.ts.map +1 -1
  82. package/dest/interfaces/prover-client.js +0 -3
  83. package/dest/interfaces/proving-job.d.ts +166 -166
  84. package/dest/interfaces/validator.d.ts +13 -13
  85. package/dest/interfaces/validator.d.ts.map +1 -1
  86. package/dest/logs/log_id.d.ts +1 -1
  87. package/dest/logs/log_id.d.ts.map +1 -1
  88. package/dest/logs/log_id.js +1 -2
  89. package/dest/logs/siloed_tag.d.ts +5 -7
  90. package/dest/logs/siloed_tag.d.ts.map +1 -1
  91. package/dest/logs/siloed_tag.js +4 -0
  92. package/dest/logs/tag.d.ts +5 -6
  93. package/dest/logs/tag.d.ts.map +1 -1
  94. package/dest/logs/tag.js +4 -0
  95. package/dest/p2p/block_proposal.d.ts +6 -8
  96. package/dest/p2p/block_proposal.d.ts.map +1 -1
  97. package/dest/p2p/block_proposal.js +4 -9
  98. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  99. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  100. package/dest/p2p/checkpoint_attestation.js +2 -7
  101. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  102. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  103. package/dest/p2p/checkpoint_proposal.js +4 -11
  104. package/dest/p2p/gossipable.d.ts +4 -4
  105. package/dest/p2p/gossipable.d.ts.map +1 -1
  106. package/dest/rollup/block_headers_hash.d.ts +1 -1
  107. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  108. package/dest/rollup/block_headers_hash.js +8 -2
  109. package/dest/tests/factories.d.ts +2 -7
  110. package/dest/tests/factories.d.ts.map +1 -1
  111. package/dest/tests/factories.js +1 -7
  112. package/dest/tests/mocks.d.ts +1 -1
  113. package/dest/tests/mocks.d.ts.map +1 -1
  114. package/dest/tests/mocks.js +2 -2
  115. package/dest/timetable/index.d.ts +50 -1
  116. package/dest/timetable/index.d.ts.map +1 -1
  117. package/dest/timetable/index.js +204 -18
  118. package/dest/trees/nullifier_leaf.d.ts +2 -1
  119. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  120. package/dest/trees/nullifier_leaf.js +3 -0
  121. package/dest/tx/block_header.d.ts +2 -2
  122. package/dest/tx/block_header.d.ts.map +1 -1
  123. package/dest/tx/block_header.js +1 -1
  124. package/dest/tx/fee_provider.d.ts +10 -0
  125. package/dest/tx/fee_provider.d.ts.map +1 -0
  126. package/dest/tx/fee_provider.js +1 -0
  127. package/dest/tx/global_variable_builder.d.ts +3 -16
  128. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  129. package/dest/tx/index.d.ts +2 -1
  130. package/dest/tx/index.d.ts.map +1 -1
  131. package/dest/tx/index.js +1 -0
  132. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  133. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  134. package/dest/tx/indexed_tx_effect.js +1 -2
  135. package/dest/tx/simulated_tx.d.ts +1 -1
  136. package/dest/tx/simulated_tx.js +1 -1
  137. package/dest/tx/tx.d.ts +3 -3
  138. package/dest/tx/tx.d.ts.map +1 -1
  139. package/dest/types/shared.d.ts +1 -10
  140. package/dest/types/shared.d.ts.map +1 -1
  141. package/dest/types/shared.js +0 -9
  142. package/dest/vks/verification_key.d.ts +2 -137
  143. package/dest/vks/verification_key.d.ts.map +1 -1
  144. package/dest/vks/verification_key.js +5 -126
  145. package/dest/world-state/world_state_revision.d.ts +8 -1
  146. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  147. package/dest/world-state/world_state_revision.js +7 -1
  148. package/package.json +8 -8
  149. package/src/abi/authorization_selector.ts +2 -8
  150. package/src/abi/encoder.ts +42 -6
  151. package/src/abi/event_selector.ts +2 -8
  152. package/src/abi/function_selector.ts +3 -12
  153. package/src/abi/note_selector.ts +3 -12
  154. package/src/aztec-address/index.ts +4 -10
  155. package/src/block/block_data.ts +3 -4
  156. package/src/block/block_hash.ts +21 -14
  157. package/src/block/l2_block_info.ts +8 -6
  158. package/src/block/l2_block_stream/interfaces.ts +6 -2
  159. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  160. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  161. package/src/config/chain-config.ts +7 -1
  162. package/src/config/sequencer-config.ts +14 -4
  163. package/src/contract/private_function.ts +3 -1
  164. package/src/gas/README.md +31 -0
  165. package/src/gas/fee_math.ts +120 -0
  166. package/src/gas/gas_fees.ts +17 -4
  167. package/src/gas/index.ts +1 -0
  168. package/src/ha-signing/config.ts +5 -2
  169. package/src/ha-signing/index.ts +3 -1
  170. package/src/ha-signing/local_config.ts +1 -1
  171. package/src/ha-signing/types.ts +48 -34
  172. package/src/hash/hash.ts +27 -0
  173. package/src/interfaces/archiver.ts +8 -0
  174. package/src/interfaces/aztec-node-debug.ts +40 -0
  175. package/src/interfaces/aztec-node.ts +15 -0
  176. package/src/interfaces/client.ts +1 -0
  177. package/src/interfaces/merkle_tree_operations.ts +3 -2
  178. package/src/interfaces/prover-client.ts +2 -5
  179. package/src/interfaces/validator.ts +14 -4
  180. package/src/logs/log_id.ts +1 -2
  181. package/src/logs/siloed_tag.ts +8 -9
  182. package/src/logs/tag.ts +8 -8
  183. package/src/p2p/block_proposal.ts +13 -9
  184. package/src/p2p/checkpoint_attestation.ts +5 -9
  185. package/src/p2p/checkpoint_proposal.ts +12 -11
  186. package/src/p2p/gossipable.ts +4 -4
  187. package/src/rollup/block_headers_hash.ts +11 -2
  188. package/src/tests/factories.ts +1 -9
  189. package/src/tests/mocks.ts +2 -0
  190. package/src/timetable/index.ts +291 -16
  191. package/src/trees/nullifier_leaf.ts +4 -0
  192. package/src/tx/block_header.ts +2 -2
  193. package/src/tx/fee_provider.ts +10 -0
  194. package/src/tx/global_variable_builder.ts +2 -18
  195. package/src/tx/index.ts +1 -0
  196. package/src/tx/indexed_tx_effect.ts +1 -2
  197. package/src/tx/simulated_tx.ts +1 -1
  198. package/src/tx/tx.ts +2 -2
  199. package/src/types/shared.ts +0 -10
  200. package/src/vks/verification_key.ts +5 -184
  201. package/src/world-state/world_state_revision.ts +9 -1
  202. package/dest/abi/mocked_keys.d.ts +0 -2
  203. package/dest/abi/mocked_keys.d.ts.map +0 -1
  204. package/dest/abi/mocked_keys.js +0 -1
  205. package/src/abi/mocked_keys.ts +0 -2
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BlockNumber,
3
- type CheckpointNumber,
3
+ CheckpointNumber,
4
4
  type IndexWithinCheckpoint,
5
5
  type SlotNumber,
6
6
  } from '@aztec/foundation/branded-types';
@@ -20,40 +20,40 @@ export enum DutyType {
20
20
  }
21
21
 
22
22
  /**
23
- * Base context for signing operations
23
+ * Signing context for block proposals.
24
+ * Includes both the block number and the checkpoint number the block belongs to.
24
25
  */
25
- interface BaseSigningContext {
26
- /** Slot number for this duty */
26
+ export interface BlockProposalSigningContext {
27
27
  slot: SlotNumber;
28
- /**
29
- * Block or checkpoint number for this duty.
30
- * For block proposals, this is the block number.
31
- * For checkpoint proposals, this is the checkpoint number.
32
- */
33
- blockNumber: BlockNumber | CheckpointNumber;
28
+ blockNumber: BlockNumber;
29
+ checkpointNumber: CheckpointNumber;
30
+ /** Block index within checkpoint (0, 1, 2...). Required for block proposals. */
31
+ blockIndexWithinCheckpoint: IndexWithinCheckpoint;
32
+ dutyType: DutyType.BLOCK_PROPOSAL;
34
33
  }
35
34
 
36
35
  /**
37
- * Signing context for block proposals.
38
- * blockIndexWithinCheckpoint is REQUIRED and must be >= 0.
36
+ * Signing context for checkpoint proposals.
37
+ * Includes the checkpoint number being proposed, but not a block number.
39
38
  */
40
- export interface BlockProposalSigningContext extends BaseSigningContext {
41
- /** Block index within checkpoint (0, 1, 2...). Required for block proposals. */
42
- blockIndexWithinCheckpoint: IndexWithinCheckpoint;
43
- dutyType: DutyType.BLOCK_PROPOSAL;
39
+ export interface CheckpointProposalSigningContext {
40
+ slot: SlotNumber;
41
+ checkpointNumber: CheckpointNumber;
42
+ dutyType: DutyType.CHECKPOINT_PROPOSAL;
44
43
  }
45
44
 
46
45
  /**
47
- * Signing context for non-block-proposal duties that require HA protection.
48
- * blockIndexWithinCheckpoint is not applicable (internally always -1).
46
+ * Signing context for attestation duties (checkpoint attestations).
47
+ * Includes the checkpoint number when available (from proposal validation).
49
48
  */
50
- export interface OtherSigningContext extends BaseSigningContext {
51
- dutyType: DutyType.CHECKPOINT_PROPOSAL | DutyType.ATTESTATION | DutyType.ATTESTATIONS_AND_SIGNERS;
49
+ export interface AttestationSigningContext {
50
+ slot: SlotNumber;
51
+ checkpointNumber: CheckpointNumber;
52
+ dutyType: DutyType.ATTESTATION | DutyType.ATTESTATIONS_AND_SIGNERS;
52
53
  }
53
54
 
54
55
  /**
55
56
  * Signing context for governance/slashing votes which only need slot for HA protection.
56
- * blockNumber is not applicable (internally always 0).
57
57
  */
58
58
  export interface VoteSigningContext {
59
59
  slot: SlotNumber;
@@ -69,18 +69,23 @@ export interface NoHAProtectionSigningContext {
69
69
  }
70
70
 
71
71
  /**
72
- * Signing contexts that require HA protection (excludes AUTH_REQUEST).
72
+ * Signing contexts that require HA protection (excludes AUTH_REQUEST and TXS).
73
73
  * Used by the HA signer's signWithProtection method.
74
74
  */
75
- export type HAProtectedSigningContext = BlockProposalSigningContext | OtherSigningContext | VoteSigningContext;
75
+ export type HAProtectedSigningContext =
76
+ | BlockProposalSigningContext
77
+ | CheckpointProposalSigningContext
78
+ | AttestationSigningContext
79
+ | VoteSigningContext;
76
80
 
77
81
  /**
78
82
  * Context required for slashing protection during signing operations.
79
83
  * Uses discriminated union to enforce type safety:
80
- * - BLOCK_PROPOSAL duties MUST have blockIndexWithinCheckpoint >= 0
81
- * - Other duty types do NOT have blockIndexWithinCheckpoint (internally -1)
82
- * - Vote duties only need slot (blockNumber is internally 0)
83
- * - AUTH_REQUEST and TXS duties don't need slot/blockNumber (no HA protection needed)
84
+ * - BLOCK_PROPOSAL duties have blockNumber, checkpointNumber, and blockIndexWithinCheckpoint
85
+ * - CHECKPOINT_PROPOSAL duties have checkpointNumber
86
+ * - ATTESTATION/ATTESTATIONS_AND_SIGNERS duties have only slot
87
+ * - Vote duties have only slot
88
+ * - AUTH_REQUEST and TXS duties don't need HA protection
84
89
  */
85
90
  export type SigningContext = HAProtectedSigningContext | NoHAProtectionSigningContext;
86
91
 
@@ -94,19 +99,28 @@ export function isHAProtectedContext(context: SigningContext): context is HAProt
94
99
 
95
100
  /**
96
101
  * Gets the block number from a signing context.
97
- * - Vote duties (GOVERNANCE_VOTE, SLASHING_VOTE): returns BlockNumber(0)
98
- * - Other duties: returns the blockNumber from the context
102
+ * Only BLOCK_PROPOSAL duties carry a block number; all others return BlockNumber(0).
99
103
  */
100
- export function getBlockNumberFromSigningContext(context: HAProtectedSigningContext): BlockNumber | CheckpointNumber {
101
- // Check for duty types that have blockNumber
104
+ export function getBlockNumberFromSigningContext(context: HAProtectedSigningContext): BlockNumber {
105
+ if (context.dutyType === DutyType.BLOCK_PROPOSAL) {
106
+ return context.blockNumber;
107
+ }
108
+ return BlockNumber(0);
109
+ }
110
+
111
+ /**
112
+ * Gets the checkpoint number from a signing context.
113
+ * BLOCK_PROPOSAL, CHECKPOINT_PROPOSAL, ATTESTATION, and ATTESTATIONS_AND_SIGNERS duties carry a checkpoint number;
114
+ * vote duties return CheckpointNumber(0).
115
+ */
116
+ export function getCheckpointNumberFromSigningContext(context: HAProtectedSigningContext): CheckpointNumber {
102
117
  if (
103
118
  context.dutyType === DutyType.BLOCK_PROPOSAL ||
104
119
  context.dutyType === DutyType.CHECKPOINT_PROPOSAL ||
105
120
  context.dutyType === DutyType.ATTESTATION ||
106
121
  context.dutyType === DutyType.ATTESTATIONS_AND_SIGNERS
107
122
  ) {
108
- return context.blockNumber;
123
+ return context.checkpointNumber;
109
124
  }
110
- // Vote duties (GOVERNANCE_VOTE, SLASHING_VOTE) don't have blockNumber
111
- return BlockNumber(0);
125
+ return CheckpointNumber(0);
112
126
  }
package/src/hash/hash.ts CHANGED
@@ -6,6 +6,21 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
6
6
 
7
7
  import { AztecAddress } from '../aztec-address/index.js';
8
8
 
9
+ /** Computes a Poseidon2 merkle tree internal node hash for append-only trees (note-hash, L1->L2, archive). */
10
+ export function computeMerkleHash(left: Fr, right: Fr): Promise<Fr> {
11
+ return poseidon2HashWithSeparator([left, right], DomainSeparator.MERKLE_HASH);
12
+ }
13
+
14
+ /** Merkle-node hasher for the nullifier tree's sibling paths. */
15
+ export function computeNullifierMerkleHash(left: Fr, right: Fr): Promise<Fr> {
16
+ return poseidon2HashWithSeparator([left, right], DomainSeparator.NULLIFIER_MERKLE);
17
+ }
18
+
19
+ /** Merkle-node hasher for the public-data tree's sibling paths. */
20
+ export function computePublicDataMerkleHash(left: Fr, right: Fr): Promise<Fr> {
21
+ return poseidon2HashWithSeparator([left, right], DomainSeparator.PUBLIC_DATA_MERKLE);
22
+ }
23
+
9
24
  /**
10
25
  * Computes a hash of a given verification key.
11
26
  * @param keyAsFields - The verification key as fields.
@@ -103,6 +118,18 @@ export function computeLogTag(rawTag: number | bigint | boolean | Fr | Buffer, d
103
118
  return poseidon2HashWithSeparator([new Fr(rawTag)], domSep);
104
119
  }
105
120
 
121
+ /**
122
+ * Computes the commitment of a private event from its preimage.
123
+ * @param randomness - Random value emitted alongside the event to prevent preimage brute-forcing.
124
+ * @param eventSelector - Event selector as an Fr.
125
+ * @param content - Serialized event content.
126
+ *
127
+ * @dev Must match the implementation in aztec-nr/aztec/src/event/event_interface.nr > compute_private_serialized_event_commitment
128
+ */
129
+ export function computePrivateEventCommitment(randomness: Fr, eventSelector: Fr, content: Fr[]): Promise<Fr> {
130
+ return poseidon2HashWithSeparator([randomness, eventSelector, ...content], DomainSeparator.EVENT_COMMITMENT);
131
+ }
132
+
106
133
  export function computeSiloedPrivateLogFirstField(contract: AztecAddress, field: Fr): Promise<Fr> {
107
134
  return poseidon2HashWithSeparator([contract, field], DomainSeparator.PRIVATE_LOG_FIRST_FIELD);
108
135
  }
@@ -60,8 +60,14 @@ export type ArchiverSpecificConfig = {
60
60
  /** Whether to allow starting the archiver without debug/trace method support on Ethereum hosts */
61
61
  ethereumAllowNoDebugHosts?: boolean;
62
62
 
63
+ /** Skip the startup check that probes the L1 RPC for historical logs on the Rollup contract. */
64
+ archiverSkipHistoricalLogsCheck?: boolean;
65
+
63
66
  /** Skip validating checkpoint attestations (for testing purposes only) */
64
67
  skipValidateCheckpointAttestations?: boolean;
68
+
69
+ /** Skip promoting proposed checkpoints during L1 sync (for testing purposes only) */
70
+ skipPromoteProposedCheckpointDuringL1Sync?: boolean;
65
71
  };
66
72
 
67
73
  export const ArchiverSpecificConfigSchema = z.object({
@@ -72,7 +78,9 @@ export const ArchiverSpecificConfigSchema = z.object({
72
78
  archiverStoreMapSizeKb: schemas.Integer.optional(),
73
79
  maxAllowedEthClientDriftSeconds: schemas.Integer.optional(),
74
80
  ethereumAllowNoDebugHosts: z.boolean().optional(),
81
+ archiverSkipHistoricalLogsCheck: z.boolean().optional(),
75
82
  skipValidateCheckpointAttestations: z.boolean().optional(),
83
+ skipPromoteProposedCheckpointDuringL1Sync: z.boolean().optional(),
76
84
  });
77
85
 
78
86
  export type ArchiverApi = Omit<
@@ -0,0 +1,40 @@
1
+ import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
2
+
3
+ import { z } from 'zod';
4
+
5
+ import type { ApiSchemaFor } from '../schemas/schemas.js';
6
+ import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
7
+
8
+ /**
9
+ * Debug interface for Aztec node available in sandbox/local-network mode.
10
+ */
11
+ export interface AztecNodeDebug {
12
+ /**
13
+ * Triggers the sequencer to produce an L2 block and waits for it to appear.
14
+ *
15
+ * **Precondition**: The current L2 slot must not already contain a block. Callers must ensure L1 time has been
16
+ * advanced to a slot with no existing block before calling this method (e.g. via `EthCheatCodes.warp()`).
17
+ * If the slot is already taken, the sequencer will fail to propose and this call will time out.
18
+ *
19
+ * @throws If no sequencer is running.
20
+ */
21
+ mineBlock(): Promise<void>;
22
+ }
23
+
24
+ export const AztecNodeDebugApiSchema: ApiSchemaFor<AztecNodeDebug> = {
25
+ mineBlock: z.function().returns(z.void()),
26
+ };
27
+
28
+ export function createAztecNodeDebugClient(
29
+ url: string,
30
+ versions: Partial<ComponentsVersions> = {},
31
+ fetch = defaultFetch,
32
+ apiKey?: string,
33
+ ): AztecNodeDebug {
34
+ return createSafeJsonRpcClient<AztecNodeDebug>(url, AztecNodeDebugApiSchema, {
35
+ namespaceMethods: 'nodeDebug',
36
+ fetch,
37
+ onResponse: getVersioningResponseHandler(versions),
38
+ ...(apiKey ? { extraHeaders: { 'x-api-key': apiKey } } : {}),
39
+ });
40
+ }
@@ -37,6 +37,7 @@ import {
37
37
  type ProtocolContractAddresses,
38
38
  ProtocolContractAddressesSchema,
39
39
  } from '../contract/index.js';
40
+ import { ManaUsageEstimate } from '../gas/fee_math.js';
40
41
  import { GasFees } from '../gas/gas_fees.js';
41
42
  import { SiloedTag, Tag, TxScopedL2Log } from '../logs/index.js';
42
43
  import { type LogFilter, LogFilterSchema } from '../logs/log_filter.js';
@@ -272,6 +273,15 @@ export interface AztecNode
272
273
  */
273
274
  getCurrentMinFees(): Promise<GasFees>;
274
275
 
276
+ /**
277
+ * Returns predicted min fees for the current slot and next N slots.
278
+ * Each entry accounts for the L1 gas oracle transition and congestion growth based on the
279
+ * given mana usage estimate. Defaults to target usage (steady state).
280
+ * @param manaUsage - Expected mana usage per checkpoint (none, target, or limit).
281
+ * @returns An array of GasFees, one per slot in the prediction window.
282
+ */
283
+ getPredictedMinFees(manaUsage?: ManaUsageEstimate): Promise<GasFees[]>;
284
+
275
285
  /**
276
286
  * Method to fetch the current max priority fee of txs in the mempool.
277
287
  * @returns The current max priority fees.
@@ -578,6 +588,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
578
588
 
579
589
  getCurrentMinFees: z.function().returns(GasFees.schema),
580
590
 
591
+ getPredictedMinFees: z
592
+ .function()
593
+ .args(optional(z.nativeEnum(ManaUsageEstimate)))
594
+ .returns(z.array(GasFees.schema)),
595
+
581
596
  getMaxPriorityFees: z.function().returns(GasFees.schema),
582
597
 
583
598
  getNodeVersion: z.function().returns(z.string()),
@@ -1,5 +1,6 @@
1
1
  export * from './aztec-node.js';
2
2
  export * from './aztec-node-admin.js';
3
+ export * from './aztec-node-debug.js';
3
4
  export * from './private_kernel_prover.js';
4
5
  export * from './get_logs_response.js';
5
6
  export * from './api_limit.js';
@@ -3,6 +3,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
5
5
 
6
+ import type { BlockHash } from '../block/block_hash.js';
6
7
  import type { MerkleTreeId, TreeHeights } from '../trees/merkle_tree_id.js';
7
8
  import type { NullifierLeaf } from '../trees/nullifier_leaf.js';
8
9
  import type { PublicDataTreeLeaf } from '../trees/public_data_leaf.js';
@@ -99,7 +100,7 @@ type LeafTypes = {
99
100
  [MerkleTreeId.NOTE_HASH_TREE]: Fr;
100
101
  [MerkleTreeId.PUBLIC_DATA_TREE]: Buffer;
101
102
  [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
102
- [MerkleTreeId.ARCHIVE]: Fr;
103
+ [MerkleTreeId.ARCHIVE]: BlockHash;
103
104
  };
104
105
 
105
106
  type LeafValueTypes = {
@@ -107,7 +108,7 @@ type LeafValueTypes = {
107
108
  [MerkleTreeId.NOTE_HASH_TREE]: Fr;
108
109
  [MerkleTreeId.PUBLIC_DATA_TREE]: PublicDataTreeLeaf;
109
110
  [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
110
- [MerkleTreeId.ARCHIVE]: Fr;
111
+ [MerkleTreeId.ARCHIVE]: BlockHash;
111
112
  };
112
113
 
113
114
  export type MerkleTreeLeafType<ID extends MerkleTreeId> = LeafTypes[ID];
@@ -71,7 +71,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
71
71
  },
72
72
  proverId: {
73
73
  env: 'PROVER_ID',
74
- parseEnv: (val?: string) => parseProverId(val),
74
+ parseEnv: (val: string) => parseProverId(val),
75
75
  description: 'Hex value that identifies the prover. Defaults to the address used for submitting proofs if not set.',
76
76
  },
77
77
  proverTestDelayType: {
@@ -117,10 +117,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
117
117
  },
118
118
  };
119
119
 
120
- function parseProverId(str?: string) {
121
- if (!str) {
122
- return undefined;
123
- }
120
+ function parseProverId(str: string) {
124
121
  return EthAddress.fromString(str);
125
122
  }
126
123
 
@@ -1,4 +1,4 @@
1
- import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
1
+ import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type { SecretValue } from '@aztec/foundation/config';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
@@ -124,6 +124,7 @@ export interface Validator {
124
124
  // Block validation responsibilities
125
125
  createBlockProposal(
126
126
  blockHeader: BlockHeader,
127
+ checkpointNumber: CheckpointNumber,
127
128
  indexWithinCheckpoint: number,
128
129
  inHash: Fr,
129
130
  archive: Fr,
@@ -136,6 +137,7 @@ export interface Validator {
136
137
  createCheckpointProposal(
137
138
  checkpointHeader: CheckpointHeader,
138
139
  archive: Fr,
140
+ checkpointNumber: CheckpointNumber,
139
141
  feeAssetPriceModifier: bigint,
140
142
  lastBlockProposal: BlockProposal | undefined,
141
143
  proposerAddress: EthAddress | undefined,
@@ -161,15 +163,23 @@ export interface Validator {
161
163
  broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
162
164
 
163
165
  /** Collect own attestations for a checkpoint proposal (used when skipping p2p attestation collection) */
164
- collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]>;
166
+ collectOwnAttestations(
167
+ proposal: CheckpointProposal,
168
+ checkpointNumber: CheckpointNumber,
169
+ ): Promise<CheckpointAttestation[]>;
165
170
 
166
171
  /** Collect attestations from the p2p network for a checkpoint proposal */
167
- collectAttestations(proposal: CheckpointProposal, required: number, deadline: Date): Promise<CheckpointAttestation[]>;
172
+ collectAttestations(
173
+ proposal: CheckpointProposal,
174
+ required: number,
175
+ deadline: Date,
176
+ checkpointNumber: CheckpointNumber,
177
+ ): Promise<CheckpointAttestation[]>;
168
178
 
169
179
  signAttestationsAndSigners(
170
180
  attestationsAndSigners: CommitteeAttestationsAndSigners,
171
181
  proposer: EthAddress,
172
182
  slot: SlotNumber,
173
- blockNumber: BlockNumber | CheckpointNumber,
183
+ checkpointNumber: CheckpointNumber,
174
184
  ): Promise<Signature>;
175
185
  }
@@ -1,7 +1,6 @@
1
1
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
2
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
3
3
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
4
- import { Fr } from '@aztec/foundation/curves/bn254';
5
4
  import { BufferReader } from '@aztec/foundation/serialize';
6
5
 
7
6
  import { z } from 'zod';
@@ -83,7 +82,7 @@ export class LogId {
83
82
  const reader = BufferReader.asReader(buffer);
84
83
 
85
84
  const blockNumber = BlockNumber(reader.readNumber());
86
- const blockHash = new BlockHash(reader.readObject(Fr));
85
+ const blockHash = BlockHash.fromBuffer(reader);
87
86
  const txHash = reader.readObject(TxHash);
88
87
  const txIndex = reader.readNumber();
89
88
  const logIndex = reader.readNumber();
@@ -1,5 +1,5 @@
1
1
  import { DomainSeparator } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ZodFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import type { AztecAddress } from '../aztec-address/index.js';
@@ -8,19 +8,14 @@ import { schemas } from '../schemas/schemas.js';
8
8
  import type { PreTag } from './pre_tag.js';
9
9
  import { Tag } from './tag.js';
10
10
 
11
- /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
12
-
13
- /** Branding to ensure fields are not interchangeable types. */
14
- export interface SiloedTag {
15
- /** Brand. */
16
- _branding: 'SiloedTag';
17
- }
18
-
19
11
  /**
20
12
  * Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
21
13
  * address that emitted the log.
22
14
  */
23
15
  export class SiloedTag {
16
+ /** Branding for nominal typing. */
17
+ declare private readonly _branding: 'SiloedTag';
18
+
24
19
  constructor(public readonly value: Fr) {}
25
20
 
26
21
  static async compute(preTag: PreTag): Promise<SiloedTag> {
@@ -49,6 +44,10 @@ export class SiloedTag {
49
44
  return this.value.equals(other.value);
50
45
  }
51
46
 
47
+ static random(): SiloedTag {
48
+ return new SiloedTag(Fr.random());
49
+ }
50
+
52
51
  static get schema(): ZodFor<SiloedTag> {
53
52
  return schemas.Fr.transform((fr: Fr) => new SiloedTag(fr));
54
53
  }
package/src/logs/tag.ts CHANGED
@@ -1,22 +1,18 @@
1
1
  import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ZodFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import { schemas } from '../schemas/schemas.js';
6
6
  import type { PreTag } from './pre_tag.js';
7
7
 
8
- /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
9
-
10
- export interface Tag {
11
- /** Brand. */
12
- _branding: 'Tag';
13
- }
14
-
15
8
  /**
16
9
  * Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
17
10
  * with a contract address by kernels before being included in the final log.
18
11
  */
19
12
  export class Tag {
13
+ /** Branding for nominal typing. */
14
+ declare private readonly _branding: 'Tag';
15
+
20
16
  constructor(public readonly value: Fr) {}
21
17
 
22
18
  static async compute(preTag: PreTag): Promise<Tag> {
@@ -36,6 +32,10 @@ export class Tag {
36
32
  return this.value.equals(other.value);
37
33
  }
38
34
 
35
+ static random(): Tag {
36
+ return new Tag(Fr.random());
37
+ }
38
+
39
39
  static get schema(): ZodFor<Tag> {
40
40
  return schemas.Fr.transform((fr: Fr) => new Tag(fr));
41
41
  }
@@ -1,5 +1,11 @@
1
- import { BlockNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import {
2
+ BlockNumber,
3
+ BlockProposalHash,
4
+ type CheckpointNumber,
5
+ IndexWithinCheckpoint,
6
+ SlotNumber,
7
+ } from '@aztec/foundation/branded-types';
8
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
9
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
10
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
11
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -23,11 +29,7 @@ import {
23
29
  import { SignedTxs } from './signed_txs.js';
24
30
  import { TopicType } from './topic_type.js';
25
31
 
26
- export class BlockProposalHash extends Buffer32 {
27
- constructor(hash: Buffer) {
28
- super(hash);
29
- }
30
- }
32
+ export type { BlockProposalHash } from '@aztec/foundation/branded-types';
31
33
 
32
34
  export type BlockProposalOptions = {
33
35
  /**
@@ -77,8 +79,8 @@ export class BlockProposal extends Gossipable {
77
79
  super();
78
80
  }
79
81
 
80
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
81
- return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
82
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
83
+ return Promise.resolve(BlockProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
82
84
  }
83
85
 
84
86
  get archive(): Fr {
@@ -126,6 +128,7 @@ export class BlockProposal extends Gossipable {
126
128
 
127
129
  static async createProposalFromSigner(
128
130
  blockHeader: BlockHeader,
131
+ checkpointNumber: CheckpointNumber,
129
132
  indexWithinCheckpoint: IndexWithinCheckpoint,
130
133
  inHash: Fr,
131
134
  archiveRoot: Fr,
@@ -147,6 +150,7 @@ export class BlockProposal extends Gossipable {
147
150
  const blockContext: SigningContext = {
148
151
  slot: blockHeader.globalVariables.slotNumber,
149
152
  blockNumber: blockHeader.globalVariables.blockNumber,
153
+ checkpointNumber,
150
154
  blockIndexWithinCheckpoint: indexWithinCheckpoint,
151
155
  dutyType: DutyType.BLOCK_PROPOSAL,
152
156
  };
@@ -1,5 +1,5 @@
1
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import { CheckpointAttestationHash, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type { BaseBuffer32 } from '@aztec/foundation/buffer';
3
3
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
4
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
5
  import type { Fr } from '@aztec/foundation/curves/bn254';
@@ -16,11 +16,7 @@ import { Gossipable } from './gossipable.js';
16
16
  import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
17
17
  import { TopicType } from './topic_type.js';
18
18
 
19
- export class CheckpointAttestationHash extends Buffer32 {
20
- constructor(hash: Buffer) {
21
- super(hash);
22
- }
23
- }
19
+ export type { CheckpointAttestationHash } from '@aztec/foundation/branded-types';
24
20
 
25
21
  /**
26
22
  * CheckpointAttestation
@@ -57,8 +53,8 @@ export class CheckpointAttestation extends Gossipable {
57
53
  .transform(obj => new CheckpointAttestation(obj.payload, obj.signature, obj.proposerSignature));
58
54
  }
59
55
 
60
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
61
- return Promise.resolve(new CheckpointAttestationHash(keccak256(this.signature.toBuffer())));
56
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
57
+ return Promise.resolve(CheckpointAttestationHash.fromBuffer(keccak256(this.signature.toBuffer())));
62
58
  }
63
59
 
64
60
  get archive(): Fr {
@@ -1,5 +1,10 @@
1
- import { BlockNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import {
2
+ type CheckpointNumber,
3
+ CheckpointProposalHash,
4
+ IndexWithinCheckpoint,
5
+ SlotNumber,
6
+ } from '@aztec/foundation/branded-types';
7
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
8
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
9
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
10
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -24,12 +29,7 @@ import {
24
29
  import { SignedTxs } from './signed_txs.js';
25
30
  import { TopicType } from './topic_type.js';
26
31
 
27
- // REFACTOR(palla): Use a branded type instead of a subclass of Buffer32
28
- export class CheckpointProposalHash extends Buffer32 {
29
- constructor(hash: Buffer) {
30
- super(hash);
31
- }
32
- }
32
+ export type { CheckpointProposalHash } from '@aztec/foundation/branded-types';
33
33
 
34
34
  export type CheckpointProposalOptions = {
35
35
  /**
@@ -93,8 +93,8 @@ export class CheckpointProposal extends Gossipable {
93
93
  super();
94
94
  }
95
95
 
96
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
97
- return Promise.resolve(new CheckpointProposalHash(keccak256(this.signature.toBuffer())));
96
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
97
+ return Promise.resolve(CheckpointProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
98
98
  }
99
99
 
100
100
  get slotNumber(): SlotNumber {
@@ -160,6 +160,7 @@ export class CheckpointProposal extends Gossipable {
160
160
  static async createProposalFromSigner(
161
161
  checkpointHeader: CheckpointHeader,
162
162
  archiveRoot: Fr,
163
+ checkpointNumber: CheckpointNumber,
163
164
  feeAssetPriceModifier: bigint,
164
165
  lastBlockProposal: BlockProposal | undefined,
165
166
  payloadSigner: (payload: Buffer32, context: SigningContext) => Promise<Signature>,
@@ -175,7 +176,7 @@ export class CheckpointProposal extends Gossipable {
175
176
 
176
177
  const checkpointContext: SigningContext = {
177
178
  slot: checkpointHeader.slotNumber,
178
- blockNumber: lastBlockProposal?.blockNumber ?? BlockNumber(0),
179
+ checkpointNumber,
179
180
  dutyType: DutyType.CHECKPOINT_PROPOSAL,
180
181
  };
181
182
 
@@ -1,4 +1,4 @@
1
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import { BaseBuffer32 } from '@aztec/foundation/buffer';
2
2
  import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
3
3
 
4
4
  import type { TopicType } from './topic_type.js';
@@ -46,7 +46,7 @@ export class P2PMessage {
46
46
  * Any class which extends gossipable will be able to be Gossiped over the p2p network
47
47
  */
48
48
  export abstract class Gossipable {
49
- private cachedId: Buffer32 | undefined;
49
+ private cachedId: BaseBuffer32 | undefined;
50
50
  /** The p2p topic identifier, this determines how the message is handled */
51
51
  static p2pTopic: TopicType;
52
52
 
@@ -54,7 +54,7 @@ export abstract class Gossipable {
54
54
  * A digest of the message information **used for logging only**.
55
55
  * The identifier used for deduplication is `getMsgIdFn` as defined in `encoding.ts` which is a hash over topic and data.
56
56
  */
57
- async p2pMessageLoggingIdentifier(): Promise<Buffer32> {
57
+ async p2pMessageLoggingIdentifier(): Promise<BaseBuffer32> {
58
58
  if (this.cachedId) {
59
59
  return this.cachedId;
60
60
  }
@@ -62,7 +62,7 @@ export abstract class Gossipable {
62
62
  return this.cachedId;
63
63
  }
64
64
 
65
- abstract generateP2PMessageIdentifier(): Promise<Buffer32>;
65
+ abstract generateP2PMessageIdentifier(): Promise<BaseBuffer32>;
66
66
 
67
67
  abstract toBuffer(): Buffer;
68
68