@aztec/stdlib 0.0.1-commit.2b2662070 → 0.0.1-commit.2c0ee1788

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 (178) hide show
  1. package/dest/abi/encoder.d.ts +1 -1
  2. package/dest/abi/encoder.d.ts.map +1 -1
  3. package/dest/abi/encoder.js +32 -6
  4. package/dest/avm/avm.d.ts +300 -300
  5. package/dest/block/attestation_info.d.ts +3 -2
  6. package/dest/block/attestation_info.d.ts.map +1 -1
  7. package/dest/block/attestation_info.js +7 -5
  8. package/dest/block/block_data.d.ts +290 -1
  9. package/dest/block/block_data.d.ts.map +1 -1
  10. package/dest/block/block_data.js +14 -0
  11. package/dest/block/block_parameter.d.ts +30 -3
  12. package/dest/block/block_parameter.d.ts.map +1 -1
  13. package/dest/block/block_parameter.js +36 -2
  14. package/dest/block/l2_block_source.d.ts +39 -4
  15. package/dest/block/l2_block_source.d.ts.map +1 -1
  16. package/dest/block/proposal/attestations_and_signers.d.ts +13 -6
  17. package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -1
  18. package/dest/block/proposal/attestations_and_signers.js +26 -18
  19. package/dest/checkpoint/checkpoint_data.d.ts +7 -1
  20. package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
  21. package/dest/checkpoint/checkpoint_data.js +2 -0
  22. package/dest/config/chain-config.d.ts +2 -2
  23. package/dest/config/chain-config.d.ts.map +1 -1
  24. package/dest/config/chain-config.js +2 -2
  25. package/dest/config/sequencer-config.d.ts +5 -3
  26. package/dest/config/sequencer-config.d.ts.map +1 -1
  27. package/dest/config/sequencer-config.js +13 -6
  28. package/dest/contract/contract_address.d.ts +1 -1
  29. package/dest/contract/contract_address.js +2 -2
  30. package/dest/contract/private_function.d.ts +1 -1
  31. package/dest/contract/private_function.d.ts.map +1 -1
  32. package/dest/contract/private_function.js +2 -4
  33. package/dest/gas/gas_fees.d.ts +5 -1
  34. package/dest/gas/gas_fees.d.ts.map +1 -1
  35. package/dest/ha-signing/config.d.ts +6 -6
  36. package/dest/ha-signing/config.d.ts.map +1 -1
  37. package/dest/ha-signing/config.js +4 -3
  38. package/dest/ha-signing/local_config.d.ts +1 -1
  39. package/dest/ha-signing/local_config.d.ts.map +1 -1
  40. package/dest/ha-signing/local_config.js +2 -2
  41. package/dest/hash/hash.d.ts +16 -1
  42. package/dest/hash/hash.d.ts.map +1 -1
  43. package/dest/hash/hash.js +32 -0
  44. package/dest/interfaces/archiver.d.ts +11 -1
  45. package/dest/interfaces/archiver.d.ts.map +1 -1
  46. package/dest/interfaces/archiver.js +10 -4
  47. package/dest/interfaces/aztec-node-admin.d.ts +19 -4
  48. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  49. package/dest/interfaces/aztec-node-admin.js +2 -1
  50. package/dest/interfaces/aztec-node.d.ts +45 -55
  51. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  52. package/dest/interfaces/aztec-node.js +18 -16
  53. package/dest/interfaces/block_response.d.ts +156 -0
  54. package/dest/interfaces/block_response.d.ts.map +1 -0
  55. package/dest/interfaces/block_response.js +24 -0
  56. package/dest/interfaces/chain_tips.d.ts +304 -0
  57. package/dest/interfaces/chain_tips.d.ts.map +1 -0
  58. package/dest/interfaces/chain_tips.js +11 -0
  59. package/dest/interfaces/checkpoint_parameter.d.ts +27 -0
  60. package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -0
  61. package/dest/interfaces/checkpoint_parameter.js +20 -0
  62. package/dest/interfaces/checkpoint_response.d.ts +312 -0
  63. package/dest/interfaces/checkpoint_response.d.ts.map +1 -0
  64. package/dest/interfaces/checkpoint_response.js +26 -0
  65. package/dest/interfaces/client.d.ts +6 -1
  66. package/dest/interfaces/client.d.ts.map +1 -1
  67. package/dest/interfaces/client.js +5 -0
  68. package/dest/interfaces/configs.d.ts +12 -2
  69. package/dest/interfaces/configs.d.ts.map +1 -1
  70. package/dest/interfaces/configs.js +3 -1
  71. package/dest/interfaces/l1_publish_info.d.ts +43 -0
  72. package/dest/interfaces/l1_publish_info.d.ts.map +1 -0
  73. package/dest/interfaces/l1_publish_info.js +26 -0
  74. package/dest/interfaces/proving-job.d.ts +166 -166
  75. package/dest/interfaces/server.d.ts +6 -1
  76. package/dest/interfaces/server.d.ts.map +1 -1
  77. package/dest/interfaces/server.js +5 -0
  78. package/dest/interfaces/validator.d.ts +20 -8
  79. package/dest/interfaces/validator.d.ts.map +1 -1
  80. package/dest/interfaces/validator.js +2 -0
  81. package/dest/p2p/block_proposal.d.ts +19 -9
  82. package/dest/p2p/block_proposal.d.ts.map +1 -1
  83. package/dest/p2p/block_proposal.js +42 -32
  84. package/dest/p2p/checkpoint_attestation.d.ts +7 -3
  85. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  86. package/dest/p2p/checkpoint_attestation.js +15 -17
  87. package/dest/p2p/checkpoint_proposal.d.ts +15 -7
  88. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  89. package/dest/p2p/checkpoint_proposal.js +31 -29
  90. package/dest/p2p/consensus_payload.d.ts +18 -7
  91. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  92. package/dest/p2p/consensus_payload.js +31 -19
  93. package/dest/p2p/signature_utils.d.ts +28 -19
  94. package/dest/p2p/signature_utils.d.ts.map +1 -1
  95. package/dest/p2p/signature_utils.js +118 -21
  96. package/dest/p2p/signed_txs.d.ts +15 -13
  97. package/dest/p2p/signed_txs.d.ts.map +1 -1
  98. package/dest/p2p/signed_txs.js +26 -24
  99. package/dest/parity/parity_base_private_inputs.d.ts +7 -3
  100. package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
  101. package/dest/parity/parity_base_private_inputs.js +7 -5
  102. package/dest/parity/parity_public_inputs.d.ts +7 -3
  103. package/dest/parity/parity_public_inputs.d.ts.map +1 -1
  104. package/dest/parity/parity_public_inputs.js +6 -3
  105. package/dest/rollup/block_headers_hash.d.ts +1 -1
  106. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  107. package/dest/rollup/block_headers_hash.js +8 -2
  108. package/dest/tests/factories.d.ts +2 -7
  109. package/dest/tests/factories.d.ts.map +1 -1
  110. package/dest/tests/factories.js +8 -18
  111. package/dest/tests/mocks.d.ts +7 -1
  112. package/dest/tests/mocks.d.ts.map +1 -1
  113. package/dest/tests/mocks.js +28 -14
  114. package/dest/timetable/index.d.ts +1 -1
  115. package/dest/timetable/index.d.ts.map +1 -1
  116. package/dest/timetable/index.js +25 -11
  117. package/dest/trees/nullifier_leaf.d.ts +2 -1
  118. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  119. package/dest/trees/nullifier_leaf.js +3 -0
  120. package/dest/tx/profiling.js +4 -4
  121. package/dest/types/shared.d.ts +1 -10
  122. package/dest/types/shared.d.ts.map +1 -1
  123. package/dest/types/shared.js +0 -9
  124. package/dest/vks/verification_key.d.ts +2 -137
  125. package/dest/vks/verification_key.d.ts.map +1 -1
  126. package/dest/vks/verification_key.js +5 -126
  127. package/dest/world-state/world_state_revision.d.ts +8 -1
  128. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  129. package/dest/world-state/world_state_revision.js +7 -1
  130. package/package.json +8 -8
  131. package/src/abi/encoder.ts +42 -6
  132. package/src/block/attestation_info.ts +11 -11
  133. package/src/block/block_data.ts +17 -0
  134. package/src/block/block_parameter.ts +35 -2
  135. package/src/block/l2_block_source.ts +43 -3
  136. package/src/block/proposal/attestations_and_signers.ts +32 -17
  137. package/src/checkpoint/checkpoint_data.ts +4 -0
  138. package/src/config/chain-config.ts +2 -3
  139. package/src/config/sequencer-config.ts +25 -7
  140. package/src/contract/contract_address.ts +2 -2
  141. package/src/contract/private_function.ts +3 -1
  142. package/src/gas/gas_fees.ts +5 -0
  143. package/src/ha-signing/config.ts +5 -2
  144. package/src/ha-signing/local_config.ts +2 -2
  145. package/src/hash/hash.ts +27 -0
  146. package/src/interfaces/archiver.ts +21 -3
  147. package/src/interfaces/aztec-node-admin.ts +3 -1
  148. package/src/interfaces/aztec-node.ts +105 -95
  149. package/src/interfaces/block_response.ts +79 -0
  150. package/src/interfaces/chain_tips.ts +24 -0
  151. package/src/interfaces/checkpoint_parameter.ts +22 -0
  152. package/src/interfaces/checkpoint_response.ts +84 -0
  153. package/src/interfaces/client.ts +5 -0
  154. package/src/interfaces/configs.ts +8 -1
  155. package/src/interfaces/l1_publish_info.ts +40 -0
  156. package/src/interfaces/server.ts +5 -0
  157. package/src/interfaces/validator.ts +7 -1
  158. package/src/p2p/block_proposal.ts +84 -28
  159. package/src/p2p/checkpoint_attestation.ts +15 -20
  160. package/src/p2p/checkpoint_proposal.ts +69 -37
  161. package/src/p2p/consensus_payload.ts +50 -28
  162. package/src/p2p/signature_utils.ts +110 -25
  163. package/src/p2p/signed_txs.ts +46 -28
  164. package/src/parity/parity_base_private_inputs.ts +10 -4
  165. package/src/parity/parity_public_inputs.ts +9 -2
  166. package/src/rollup/block_headers_hash.ts +11 -2
  167. package/src/tests/factories.ts +14 -20
  168. package/src/tests/mocks.ts +46 -26
  169. package/src/timetable/index.ts +26 -11
  170. package/src/trees/nullifier_leaf.ts +4 -0
  171. package/src/tx/profiling.ts +4 -4
  172. package/src/types/shared.ts +0 -10
  173. package/src/vks/verification_key.ts +5 -184
  174. package/src/world-state/world_state_revision.ts +9 -1
  175. package/dest/abi/mocked_keys.d.ts +0 -2
  176. package/dest/abi/mocked_keys.d.ts.map +0 -1
  177. package/dest/abi/mocked_keys.js +0 -1
  178. package/src/abi/mocked_keys.ts +0 -2
@@ -3,9 +3,12 @@ import type { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
+ import { CheckpointDataSchema } from '../checkpoint/checkpoint_data.js';
7
+ import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
6
8
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
7
9
  import { BlockHeader } from '../tx/block_header.js';
8
10
  import { BlockHash } from './block_hash.js';
11
+ import { CommitteeAttestation } from './proposal/committee_attestation.js';
9
12
 
10
13
  /** L2Block metadata. Equivalent to L2Block but without block body containing tx data. */
11
14
  export type BlockData = {
@@ -23,3 +26,17 @@ export const BlockDataSchema = z.object({
23
26
  checkpointNumber: CheckpointNumberSchema,
24
27
  indexWithinCheckpoint: IndexWithinCheckpointSchema,
25
28
  });
29
+
30
+ export const BlockDataWithCheckpointContextSchema = z
31
+ .object({
32
+ data: BlockDataSchema,
33
+ checkpoint: CheckpointDataSchema.optional(),
34
+ l1: L1PublishedData.schema.optional(),
35
+ attestations: z.array(CommitteeAttestation.schema),
36
+ })
37
+ .transform(obj => ({
38
+ data: obj.data,
39
+ checkpoint: obj.checkpoint,
40
+ l1: obj.l1,
41
+ attestations: obj.attestations,
42
+ }));
@@ -1,10 +1,43 @@
1
1
  import { BlockNumberSchema } from '@aztec/foundation/branded-types';
2
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
3
+ import { schemas } from '@aztec/foundation/schemas';
2
4
 
3
5
  import { z } from 'zod';
4
6
 
7
+ import { ChainTipSchema } from '../interfaces/chain_tips.js';
5
8
  import { BlockHash } from './block_hash.js';
6
9
 
7
- export const BlockParameterSchema = z.union([BlockHash.schema, BlockNumberSchema, z.literal('latest')]);
10
+ /**
11
+ * Selector for a block in RPC calls.
12
+ *
13
+ * Accepts a block number, a {@link BlockHash}, a chain-tip name (e.g. `'proven'`, `'checkpointed'`),
14
+ * `'latest'` (alias for `'proposed'`), or the explicit object variants `{ number }`, `{ hash }`,
15
+ * and `{ archive }`.
16
+ */
17
+ export const BlockParameterSchema = z.union([
18
+ BlockHash.schema,
19
+ BlockNumberSchema,
20
+ ChainTipSchema,
21
+ z.literal('latest'),
22
+ z.object({ number: BlockNumberSchema }),
23
+ z.object({ hash: BlockHash.schema }),
24
+ z.object({ archive: schemas.Fr }),
25
+ ]);
8
26
 
9
- /** Block parameter - either a specific BlockNumber, block hash (BlockHash), or 'latest' */
10
27
  export type BlockParameter = z.infer<typeof BlockParameterSchema>;
28
+
29
+ export function inspectBlockParameter(param: BlockParameter) {
30
+ if (typeof param === 'number') {
31
+ return param.toString();
32
+ } else if (typeof param === 'string') {
33
+ return param;
34
+ } else if ('number' in param) {
35
+ return `number=${param.number.toString()}`;
36
+ } else if ('hash' in param) {
37
+ return `hash=${param.hash.toString()}`;
38
+ } else if ('archive' in param) {
39
+ return `archive=${param.archive.toString()}`;
40
+ } else {
41
+ return jsonStringify(param);
42
+ }
43
+ }
@@ -14,7 +14,7 @@ import { z } from 'zod';
14
14
 
15
15
  import type { Checkpoint } from '../checkpoint/checkpoint.js';
16
16
  import type { CheckpointData, CommonCheckpointData, ProposedCheckpointData } from '../checkpoint/checkpoint_data.js';
17
- import type { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
17
+ import type { L1PublishedData, PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
18
18
  import type { L1RollupConstants } from '../epoch-helpers/index.js';
19
19
  import { CheckpointHeader } from '../rollup/checkpoint_header.js';
20
20
  import type { BlockHeader } from '../tx/block_header.js';
@@ -25,8 +25,17 @@ import type { BlockData } from './block_data.js';
25
25
  import type { BlockHash } from './block_hash.js';
26
26
  import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
27
27
  import type { L2Block } from './l2_block.js';
28
+ import type { CommitteeAttestation } from './proposal/committee_attestation.js';
28
29
  import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
29
30
 
31
+ /** Block metadata plus checkpoint-derived context (L1 publish info, attestations). */
32
+ export type BlockDataWithCheckpointContext = {
33
+ data: BlockData;
34
+ checkpoint?: CheckpointData;
35
+ l1?: L1PublishedData;
36
+ attestations: CommitteeAttestation[];
37
+ };
38
+
30
39
  /**
31
40
  * Interface of classes allowing for the retrieval of L2 blocks.
32
41
  */
@@ -111,6 +120,37 @@ export interface L2BlockSource {
111
120
  */
112
121
  getCheckpointsDataForEpoch(epochNumber: EpochNumber): Promise<CheckpointData[]>;
113
122
 
123
+ /**
124
+ * Gets lightweight checkpoint metadata for a single checkpoint.
125
+ * Cheap passthrough for metadata-only queries (no block body reads).
126
+ * @param checkpointNumber - The checkpoint number to retrieve.
127
+ * @returns The requested checkpoint data (or undefined if not found).
128
+ */
129
+ getCheckpointData(checkpointNumber: CheckpointNumber): Promise<CheckpointData | undefined>;
130
+
131
+ /**
132
+ * Gets up to `limit` amount of checkpoint metadata entries starting from `from`.
133
+ * Cheap passthrough for metadata-only queries (no block body reads).
134
+ * @param from - The first checkpoint number to return (inclusive).
135
+ * @param limit - The maximum number of checkpoints to return.
136
+ */
137
+ getCheckpointDataRange(from: CheckpointNumber, limit: number): Promise<CheckpointData[]>;
138
+
139
+ /**
140
+ * Looks up the checkpoint number that contains the given slot.
141
+ * @param slot - The slot number to look up.
142
+ * @returns The checkpoint number (or undefined if not found).
143
+ */
144
+ getCheckpointNumberBySlot(slot: SlotNumber): Promise<CheckpointNumber | undefined>;
145
+
146
+ /**
147
+ * Gets block metadata plus checkpoint-derived context (L1 publish info, attestations)
148
+ * without deserializing tx bodies. Uses checkpoint-level values when the block is
149
+ * checkpointed; otherwise returns `l1: undefined` and empty attestations.
150
+ * @param number - The block number to retrieve.
151
+ */
152
+ getBlockDataWithCheckpointContext(number: BlockNumber): Promise<BlockDataWithCheckpointContext | undefined>;
153
+
114
154
  /**
115
155
  * Gets a block header by its hash.
116
156
  * @param blockHash - The block hash to retrieve.
@@ -230,10 +270,10 @@ export interface L2BlockSource {
230
270
  getPendingChainValidationStatus(): Promise<ValidateCheckpointResult>;
231
271
 
232
272
  /** Returns the checkpoint at the proposed chain tip. */
233
- getProposedCheckpoint(): Promise<CommonCheckpointData | undefined>;
273
+ getLastCheckpoint(): Promise<CommonCheckpointData | undefined>;
234
274
 
235
275
  /** Returns proposed checkpoint, if set, undefined if not*/
236
- getProposedCheckpointOnly(): Promise<ProposedCheckpointData | undefined>;
276
+ getLastProposedCheckpoint(): Promise<ProposedCheckpointData | undefined>;
237
277
 
238
278
  /** Force a sync. */
239
279
  syncImmediate(): Promise<void>;
@@ -4,26 +4,37 @@ import { hexToBuffer } from '@aztec/foundation/string';
4
4
  import { encodeAbiParameters, parseAbiParameters } from 'viem';
5
5
  import { z } from 'zod';
6
6
 
7
- import type { Signable, SignatureDomainSeparator } from '../../p2p/signature_utils.js';
7
+ import {
8
+ type CoordinationSignatureContext,
9
+ type CoordinationSignatureType,
10
+ type Signable,
11
+ coordinationSignatureContextSchema,
12
+ } from '../../p2p/signature_utils.js';
8
13
  import { CommitteeAttestation, EthAddress } from './committee_attestation.js';
9
14
 
10
15
  export class CommitteeAttestationsAndSigners implements Signable {
11
- constructor(public attestations: CommitteeAttestation[]) {}
16
+ readonly primaryType: CoordinationSignatureType = 'AttestationsAndSigners';
17
+
18
+ constructor(
19
+ public attestations: CommitteeAttestation[],
20
+ public readonly signatureContext: CoordinationSignatureContext,
21
+ ) {}
12
22
 
13
23
  static get schema() {
14
24
  return z
15
25
  .object({
16
26
  attestations: CommitteeAttestation.schema.array(),
27
+ signatureContext: coordinationSignatureContextSchema,
17
28
  })
18
- .transform(obj => new CommitteeAttestationsAndSigners(obj.attestations));
29
+ .transform(obj => new CommitteeAttestationsAndSigners(obj.attestations, obj.signatureContext));
19
30
  }
20
31
 
21
- getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
22
- const abi = parseAbiParameters('uint8,(bytes,bytes),address[]');
32
+ getPayloadToSign(): Buffer {
33
+ // Matches the L1 abi.encode(attestations, signers) in AttestationLib.sol#getAttestationsAndSignersDigest.
34
+ const abi = parseAbiParameters('(bytes,bytes),address[]');
23
35
  const packed = this.getPackedAttestations();
24
36
 
25
37
  const encodedData = encodeAbiParameters(abi, [
26
- domainSeparator,
27
38
  [packed.signatureIndices, packed.signaturesOrAddresses],
28
39
  this.getSigners().map(s => s.toString()),
29
40
  ]);
@@ -31,8 +42,8 @@ export class CommitteeAttestationsAndSigners implements Signable {
31
42
  return hexToBuffer(encodedData);
32
43
  }
33
44
 
34
- static empty(): CommitteeAttestationsAndSigners {
35
- return new CommitteeAttestationsAndSigners([]);
45
+ static empty(signatureContext: CoordinationSignatureContext): CommitteeAttestationsAndSigners {
46
+ return new CommitteeAttestationsAndSigners([], signatureContext);
36
47
  }
37
48
 
38
49
  toString() {
@@ -53,9 +64,9 @@ export class CommitteeAttestationsAndSigners implements Signable {
53
64
  * @param attestations - Array of committee attestations with addresses and signatures
54
65
  * @returns Packed attestations with bitmap and tightly packed signature/address data
55
66
  */
56
- getPackedAttestations(): ViemCommitteeAttestations {
57
- const length = this.attestations.length;
58
- const attestations = this.attestations.map(a => a.toViem());
67
+ static packAttestations(attestations: CommitteeAttestation[]): ViemCommitteeAttestations {
68
+ const length = attestations.length;
69
+ const viemAttestations = attestations.map(a => a.toViem());
59
70
 
60
71
  // Calculate bitmap size (1 bit per attestation, rounded up to nearest byte)
61
72
  const bitmapSize = Math.ceil(length / 8);
@@ -63,8 +74,8 @@ export class CommitteeAttestationsAndSigners implements Signable {
63
74
 
64
75
  // Calculate total data size needed
65
76
  let totalDataSize = 0;
66
- for (let i = 0; i < length; i++) {
67
- const signature = attestations[i].signature;
77
+ for (const attestation of viemAttestations) {
78
+ const signature = attestation.signature;
68
79
  // Check if signature is empty (v = 0)
69
80
  const isEmpty = signature.v === 0;
70
81
 
@@ -79,8 +90,7 @@ export class CommitteeAttestationsAndSigners implements Signable {
79
90
  let dataIndex = 0;
80
91
 
81
92
  // Pack the data
82
- for (let i = 0; i < length; i++) {
83
- const attestation = attestations[i];
93
+ for (const [i, attestation] of viemAttestations.entries()) {
84
94
  const signature = attestation.signature;
85
95
 
86
96
  // Check if signature is empty
@@ -90,7 +100,7 @@ export class CommitteeAttestationsAndSigners implements Signable {
90
100
  // Set bit in bitmap (bit 7-0 in each byte, left to right)
91
101
  const byteIndex = Math.floor(i / 8);
92
102
  const bitIndex = 7 - (i % 8);
93
- signatureIndices[byteIndex] |= 1 << bitIndex;
103
+ signatureIndices[byteIndex] = (signatureIndices[byteIndex] ?? 0) | (1 << bitIndex);
94
104
 
95
105
  // Pack signature: v + r + s
96
106
  signaturesOrAddresses[dataIndex] = signature.v;
@@ -118,6 +128,10 @@ export class CommitteeAttestationsAndSigners implements Signable {
118
128
  signaturesOrAddresses: `0x${Buffer.from(signaturesOrAddresses).toString('hex')}`,
119
129
  };
120
130
  }
131
+
132
+ getPackedAttestations(): ViemCommitteeAttestations {
133
+ return CommitteeAttestationsAndSigners.packAttestations(this.attestations);
134
+ }
121
135
  }
122
136
 
123
137
  /**
@@ -130,8 +144,9 @@ export class MaliciousCommitteeAttestationsAndSigners extends CommitteeAttestati
130
144
  constructor(
131
145
  attestations: CommitteeAttestation[],
132
146
  private signers: EthAddress[],
147
+ signatureContext: CoordinationSignatureContext,
133
148
  ) {
134
- super(attestations);
149
+ super(attestations, signatureContext);
135
150
  }
136
151
 
137
152
  override getSigners(): EthAddress[] {
@@ -32,6 +32,8 @@ export type L1EnrichedCheckpointData = {
32
32
  export type StorageEnrichedCheckpointData = {
33
33
  archive: AppendOnlyTreeSnapshot;
34
34
  checkpointOutHash: Fr;
35
+ /** Fee asset price modifier in basis points. Defaults to 0 (no change) when not explicitly set. */
36
+ feeAssetPriceModifier: bigint;
35
37
  };
36
38
 
37
39
  /** Data stored only with proposed checkpoint data */
@@ -70,6 +72,7 @@ export const CheckpointDataSchema = z
70
72
  checkpointOutHash: schemas.Fr,
71
73
  startBlock: BlockNumberSchema,
72
74
  blockCount: schemas.Integer,
75
+ feeAssetPriceModifier: schemas.BigInt,
73
76
  attestations: z.array(CommitteeAttestation.schema),
74
77
  l1: L1PublishedData.schema,
75
78
  })
@@ -81,6 +84,7 @@ export const CheckpointDataSchema = z
81
84
  checkpointOutHash: obj.checkpointOutHash,
82
85
  startBlock: obj.startBlock,
83
86
  blockCount: obj.blockCount,
87
+ feeAssetPriceModifier: obj.feeAssetPriceModifier,
84
88
  attestations: obj.attestations,
85
89
  l1: obj.l1,
86
90
  }),
@@ -1,5 +1,5 @@
1
1
  import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
2
- import type { ConfigMappingsType } from '@aztec/foundation/config';
2
+ import { type ConfigMappingsType, numberConfigHelper } from '@aztec/foundation/config';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
 
5
5
  export { type SequencerConfig, SequencerConfigSchema } from '../interfaces/configs.js';
@@ -14,8 +14,7 @@ export const emptyChainConfig: ChainConfig = {
14
14
  export const chainConfigMappings: ConfigMappingsType<ChainConfig> = {
15
15
  l1ChainId: {
16
16
  env: 'L1_CHAIN_ID',
17
- parseEnv: (val: string) => +val,
18
- defaultValue: 31337,
17
+ ...numberConfigHelper(31337),
19
18
  description: 'The chain ID of the ethereum host.',
20
19
  },
21
20
  rollupVersion: {
@@ -1,4 +1,9 @@
1
- import type { ConfigMappingsType } from '@aztec/foundation/config';
1
+ import {
2
+ type ConfigMappingsType,
3
+ floatConfigHelper,
4
+ numberConfigHelper,
5
+ optionalNumberConfigHelper,
6
+ } from '@aztec/foundation/config';
2
7
 
3
8
  import type { SequencerConfig } from '../interfaces/configs.js';
4
9
  import { DEFAULT_P2P_PROPAGATION_TIME } from '../timetable/index.js';
@@ -6,6 +11,9 @@ import { DEFAULT_P2P_PROPAGATION_TIME } from '../timetable/index.js';
6
11
  /** Default maximum number of transactions per block. */
7
12
  export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
8
13
 
14
+ /** Default maximum number of blocks the sequencer packs into a single checkpoint. */
15
+ export const DEFAULT_MAX_BLOCKS_PER_CHECKPOINT = 24;
16
+
9
17
  /**
10
18
  * Partial sequencer config mappings for fields that need to be shared across packages.
11
19
  * The full sequencer config mappings remain in sequencer-client, but shared fields
@@ -15,7 +23,11 @@ export const DEFAULT_MAX_TXS_PER_BLOCK = 32;
15
23
  export const sharedSequencerConfigMappings: ConfigMappingsType<
16
24
  Pick<
17
25
  SequencerConfig,
18
- 'blockDurationMs' | 'expectedBlockProposalsPerSlot' | 'maxTxsPerBlock' | 'attestationPropagationTime'
26
+ | 'blockDurationMs'
27
+ | 'expectedBlockProposalsPerSlot'
28
+ | 'maxTxsPerBlock'
29
+ | 'attestationPropagationTime'
30
+ | 'maxBlocksPerCheckpoint'
19
31
  >
20
32
  > = {
21
33
  blockDurationMs: {
@@ -23,25 +35,31 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
23
35
  description:
24
36
  'Duration per block in milliseconds when building multiple blocks per slot. ' +
25
37
  'If undefined (default), builds a single block per slot using the full slot duration.',
26
- parseEnv: (val: string) => parseInt(val, 10),
38
+ ...optionalNumberConfigHelper(),
27
39
  },
28
40
  expectedBlockProposalsPerSlot: {
29
41
  env: 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT',
30
42
  description:
31
43
  'Expected number of block proposals per slot for P2P peer scoring. ' +
32
44
  '0 (default) disables block proposal scoring. Set to a positive value to enable.',
33
- parseEnv: (val: string) => parseInt(val, 10),
34
- defaultValue: 0,
45
+ ...numberConfigHelper(0),
35
46
  },
36
47
  maxTxsPerBlock: {
37
48
  env: 'SEQ_MAX_TX_PER_BLOCK',
38
49
  description: 'The maximum number of txs to include in a block.',
39
- parseEnv: (val: string) => parseInt(val, 10),
50
+ ...optionalNumberConfigHelper(),
40
51
  },
41
52
  attestationPropagationTime: {
42
53
  env: 'SEQ_ATTESTATION_PROPAGATION_TIME',
43
54
  description: 'How many seconds it takes for proposals and attestations to travel across the p2p layer (one-way).',
44
- parseEnv: (val: string) => parseFloat(val),
45
55
  defaultValue: DEFAULT_P2P_PROPAGATION_TIME,
56
+ ...floatConfigHelper(DEFAULT_P2P_PROPAGATION_TIME),
57
+ },
58
+ maxBlocksPerCheckpoint: {
59
+ env: 'MAX_BLOCKS_PER_CHECKPOINT',
60
+ description:
61
+ 'Maximum number of blocks the sequencer packs into a single checkpoint, and the maximum indexWithinCheckpoint accepted on inbound block proposals.',
62
+ parseEnv: (val: string) => parseInt(val, 10),
63
+ defaultValue: DEFAULT_MAX_BLOCKS_PER_CHECKPOINT,
46
64
  },
47
65
  };
@@ -13,7 +13,7 @@ import type { ContractInstance } from './interfaces/contract_instance.js';
13
13
  /**
14
14
  * Returns the deployment address for a given contract instance.
15
15
  * ```
16
- * salted_initialization_hash = poseidon2(DOM_SEP__PARTIAL_ADDRESS, [salt, initialization_hash, deployer])
16
+ * salted_initialization_hash = poseidon2(DOM_SEP__SALTED_INITIALIZATION_HASH, [salt, initialization_hash, deployer])
17
17
  * partial_address = poseidon2(DOM_SEP__PARTIAL_ADDRESS, [contract_class_id, salted_initialization_hash])
18
18
  * address = ((poseidon2(DOM_SEP__CONTRACT_ADDRESS_V1, [public_keys_hash, partial_address]) * G) + ivpk_m).x <- the x-coordinate of the address point
19
19
  * ```
@@ -57,7 +57,7 @@ export function computeSaltedInitializationHash(
57
57
  ): Promise<Fr> {
58
58
  return poseidon2HashWithSeparator(
59
59
  [instance.salt, instance.initializationHash, instance.deployer],
60
- DomainSeparator.PARTIAL_ADDRESS,
60
+ DomainSeparator.SALTED_INITIALIZATION_HASH,
61
61
  );
62
62
  }
63
63
 
@@ -3,6 +3,7 @@ import { poseidon2Hash, poseidon2HashWithSeparator } from '@aztec/foundation/cry
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { type MerkleTree, MerkleTreeCalculator } from '@aztec/foundation/trees';
5
5
 
6
+ import { computeMerkleHash } from '../hash/hash.js';
6
7
  import type { PrivateFunction } from './interfaces/contract_class.js';
7
8
 
8
9
  // Memoize the merkle tree calculators to avoid re-computing the zero-hash for each level in each call
@@ -42,7 +43,8 @@ async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator>
42
43
  privateFunctionTreeCalculator = await MerkleTreeCalculator.create(
43
44
  FUNCTION_TREE_HEIGHT,
44
45
  functionTreeZeroLeaf,
45
- async (left, right) => (await poseidon2Hash([left, right])).toBuffer() as Buffer<ArrayBuffer>,
46
+ async (left, right) =>
47
+ (await computeMerkleHash(Fr.fromBuffer(left), Fr.fromBuffer(right))).toBuffer() as Buffer<ArrayBuffer>,
46
48
  );
47
49
  }
48
50
  return privateFunctionTreeCalculator;
@@ -134,3 +134,8 @@ export class GasFees {
134
134
  return `GasFees { feePerDaGas=${this.feePerDaGas} feePerL2Gas=${this.feePerL2Gas} }`;
135
135
  }
136
136
  }
137
+
138
+ /** Provides projected minimum gas fees for the next block. */
139
+ export interface BlockMinFeesProvider {
140
+ getCurrentMinFees(): Promise<GasFees>;
141
+ }
@@ -1,11 +1,13 @@
1
1
  import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
2
  import {
3
3
  type ConfigMappingsType,
4
+ SecretValue,
4
5
  booleanConfigHelper,
5
6
  getConfigFromMappings,
6
7
  getDefaultConfig,
7
8
  numberConfigHelper,
8
9
  optionalNumberConfigHelper,
10
+ secretStringConfigHelper,
9
11
  } from '@aztec/foundation/config';
10
12
  import { EthAddress } from '@aztec/foundation/eth-address';
11
13
  import type { ZodFor } from '@aztec/foundation/schemas';
@@ -88,7 +90,7 @@ export interface ValidatorHASignerConfig extends BaseSignerConfig {
88
90
  * PostgreSQL connection string
89
91
  * Format: postgresql://user:password@host:port/database
90
92
  */
91
- databaseUrl?: string;
93
+ databaseUrl?: SecretValue<string>;
92
94
  /** Maximum number of clients in the pool (default: 10) */
93
95
  poolMaxCount?: number;
94
96
  /** Minimum number of clients in the pool (default: 0) */
@@ -110,6 +112,7 @@ export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASign
110
112
  env: 'VALIDATOR_HA_DATABASE_URL',
111
113
  description:
112
114
  'PostgreSQL connection string for validator HA signer (format: postgresql://user:password@host:port/database)',
115
+ ...secretStringConfigHelper(),
113
116
  },
114
117
  poolMaxCount: {
115
118
  env: 'VALIDATOR_HA_POOL_MAX',
@@ -148,7 +151,7 @@ export function getConfigEnvVars(): ValidatorHASignerConfig {
148
151
 
149
152
  export const ValidatorHASignerConfigSchema = BaseSignerConfigSchema.extend({
150
153
  haSigningEnabled: z.boolean(),
151
- databaseUrl: z.string().optional(),
154
+ databaseUrl: SecretValue.schema(z.string()).optional(),
152
155
  poolMaxCount: z.number().min(0).optional(),
153
156
  poolMinCount: z.number().min(0).optional(),
154
157
  poolIdleTimeoutMs: z.number().min(0).optional(),
@@ -1,4 +1,4 @@
1
- import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
1
+ import { type ConfigMappingsType, getConfigFromMappings, optionalNumberConfigHelper } from '@aztec/foundation/config';
2
2
  import { zodFor } from '@aztec/foundation/schemas';
3
3
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
4
4
 
@@ -26,7 +26,7 @@ export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> =
26
26
  env: 'SIGNING_PROTECTION_MAP_SIZE_KB',
27
27
  description:
28
28
  'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
29
- parseEnv: (val: string) => +val,
29
+ ...optionalNumberConfigHelper(),
30
30
  },
31
31
  };
32
32
 
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
  }
@@ -4,7 +4,7 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import { z } from 'zod';
6
6
 
7
- import { BlockDataSchema } from '../block/block_data.js';
7
+ import { BlockDataSchema, BlockDataWithCheckpointContextSchema } from '../block/block_data.js';
8
8
  import { BlockHash } from '../block/block_hash.js';
9
9
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
10
10
  import { L2Block } from '../block/l2_block.js';
@@ -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<
@@ -109,6 +117,16 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
109
117
  getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
110
118
  getBlockData: z.function().args(BlockNumberSchema).returns(BlockDataSchema.optional()),
111
119
  getBlockDataByArchive: z.function().args(schemas.Fr).returns(BlockDataSchema.optional()),
120
+ getBlockDataWithCheckpointContext: z
121
+ .function()
122
+ .args(BlockNumberSchema)
123
+ .returns(BlockDataWithCheckpointContextSchema.optional()),
124
+ getCheckpointData: z.function().args(CheckpointNumberSchema).returns(CheckpointDataSchema.optional()),
125
+ getCheckpointDataRange: z
126
+ .function()
127
+ .args(CheckpointNumberSchema, schemas.Integer)
128
+ .returns(z.array(CheckpointDataSchema)),
129
+ getCheckpointNumberBySlot: z.function().args(schemas.SlotNumber).returns(CheckpointNumberSchema.optional()),
112
130
  getL2Block: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
113
131
  getL2BlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
114
132
  getL2BlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
@@ -150,8 +168,8 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
150
168
  .args()
151
169
  .returns(z.object({ genesisArchiveRoot: schemas.Fr })),
152
170
  getL1Timestamp: z.function().args().returns(schemas.BigInt.optional()),
153
- getProposedCheckpoint: z.function().args().returns(ProposedCheckpointDataSchema.optional()),
154
- getProposedCheckpointOnly: z.function().args().returns(ProposedCheckpointDataSchema.optional()),
171
+ getLastCheckpoint: z.function().args().returns(ProposedCheckpointDataSchema.optional()),
172
+ getLastProposedCheckpoint: z.function().args().returns(ProposedCheckpointDataSchema.optional()),
155
173
  syncImmediate: z.function().args().returns(z.void()),
156
174
  isPendingChainInvalid: z.function().args().returns(z.boolean()),
157
175
  getPendingChainValidationStatus: z.function().args().returns(ValidateCheckpointResultSchema),
@@ -81,6 +81,8 @@ export type AztecNodeAdminConfig = Omit<ValidatorClientFullConfig, 'l1Contracts'
81
81
  'archiverPollingIntervalMS' | 'archiverBatchSize' | 'skipValidateCheckpointAttestations'
82
82
  > & {
83
83
  maxPendingTxCount: number;
84
+ // Keep in sync with P2PConfig.skipIncomingProposals (circular dep prevents Pick<P2PConfig, ...> here)
85
+ skipIncomingProposals?: boolean;
84
86
  };
85
87
 
86
88
  export const AztecNodeAdminConfigSchema = SequencerConfigSchema.merge(ProverConfigSchema)
@@ -93,7 +95,7 @@ export const AztecNodeAdminConfigSchema = SequencerConfigSchema.merge(ProverConf
93
95
  skipValidateCheckpointAttestations: true,
94
96
  }),
95
97
  )
96
- .merge(z.object({ maxPendingTxCount: z.number() }));
98
+ .merge(z.object({ maxPendingTxCount: z.number(), skipIncomingProposals: z.boolean().optional() }));
97
99
 
98
100
  export const AztecNodeAdminApiSchema: ApiSchemaFor<AztecNodeAdmin> = {
99
101
  getConfig: z.function().returns(AztecNodeAdminConfigSchema),