@aztec/stdlib 4.0.0-nightly.20260112 → 4.0.0-nightly.20260114

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 (219) hide show
  1. package/dest/abi/utils.d.ts +7 -1
  2. package/dest/abi/utils.d.ts.map +1 -1
  3. package/dest/abi/utils.js +7 -0
  4. package/dest/avm/avm.d.ts +300 -300
  5. package/dest/block/attestation_info.d.ts +5 -5
  6. package/dest/block/attestation_info.d.ts.map +1 -1
  7. package/dest/block/attestation_info.js +4 -4
  8. package/dest/block/body.d.ts +1 -1
  9. package/dest/block/body.d.ts.map +1 -1
  10. package/dest/block/body.js +2 -1
  11. package/dest/block/checkpointed_l2_block.d.ts +1 -1
  12. package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
  13. package/dest/block/checkpointed_l2_block.js +5 -4
  14. package/dest/block/l2_block.d.ts +6 -3
  15. package/dest/block/l2_block.d.ts.map +1 -1
  16. package/dest/block/l2_block.js +3 -3
  17. package/dest/block/l2_block_code_to_purge.d.ts +1 -1
  18. package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
  19. package/dest/block/l2_block_code_to_purge.js +1 -1
  20. package/dest/block/l2_block_header.d.ts +6 -2
  21. package/dest/block/l2_block_header.d.ts.map +1 -1
  22. package/dest/block/l2_block_header.js +14 -7
  23. package/dest/block/l2_block_new.d.ts +1 -2
  24. package/dest/block/l2_block_new.d.ts.map +1 -1
  25. package/dest/block/l2_block_new.js +4 -1
  26. package/dest/block/l2_block_source.d.ts +247 -42
  27. package/dest/block/l2_block_source.d.ts.map +1 -1
  28. package/dest/block/l2_block_source.js +23 -5
  29. package/dest/block/l2_block_stream/index.d.ts +2 -1
  30. package/dest/block/l2_block_stream/index.d.ts.map +1 -1
  31. package/dest/block/l2_block_stream/index.js +1 -0
  32. package/dest/block/l2_block_stream/interfaces.d.ts +16 -5
  33. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  34. package/dest/block/l2_block_stream/l2_block_stream.d.ts +4 -2
  35. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  36. package/dest/block/l2_block_stream/l2_block_stream.js +102 -30
  37. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +24 -16
  38. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
  39. package/dest/block/l2_block_stream/l2_tips_memory_store.js +55 -61
  40. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +49 -0
  41. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -0
  42. package/dest/block/l2_block_stream/l2_tips_store_base.js +179 -0
  43. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  44. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  45. package/dest/block/test/l2_tips_store_test_suite.js +483 -38
  46. package/dest/block/validate_block_result.d.ts +24 -24
  47. package/dest/block/validate_block_result.d.ts.map +1 -1
  48. package/dest/block/validate_block_result.js +18 -17
  49. package/dest/checkpoint/checkpoint.d.ts +2 -1
  50. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  51. package/dest/checkpoint/checkpoint.js +11 -1
  52. package/dest/checkpoint/checkpoint_info.d.ts +32 -3
  53. package/dest/checkpoint/checkpoint_info.d.ts.map +1 -1
  54. package/dest/checkpoint/checkpoint_info.js +34 -1
  55. package/dest/checkpoint/index.d.ts +2 -1
  56. package/dest/checkpoint/index.d.ts.map +1 -1
  57. package/dest/checkpoint/index.js +1 -0
  58. package/dest/checkpoint/published_checkpoint.d.ts +1 -1
  59. package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
  60. package/dest/checkpoint/published_checkpoint.js +4 -3
  61. package/dest/contract/index.d.ts +1 -3
  62. package/dest/contract/index.d.ts.map +1 -1
  63. package/dest/contract/index.js +0 -2
  64. package/dest/deserialization/index.d.ts +11 -0
  65. package/dest/deserialization/index.d.ts.map +1 -0
  66. package/dest/deserialization/index.js +10 -0
  67. package/dest/interfaces/api_limit.d.ts +2 -1
  68. package/dest/interfaces/api_limit.d.ts.map +1 -1
  69. package/dest/interfaces/api_limit.js +1 -0
  70. package/dest/interfaces/archiver.d.ts +6 -6
  71. package/dest/interfaces/archiver.d.ts.map +1 -1
  72. package/dest/interfaces/archiver.js +6 -4
  73. package/dest/interfaces/aztec-node-admin.d.ts +12 -9
  74. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  75. package/dest/interfaces/aztec-node-admin.js +2 -2
  76. package/dest/interfaces/aztec-node.d.ts +2 -2
  77. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  78. package/dest/interfaces/aztec-node.js +8 -3
  79. package/dest/interfaces/block-builder.d.ts +2 -2
  80. package/dest/interfaces/block-builder.d.ts.map +1 -1
  81. package/dest/interfaces/configs.d.ts +6 -1
  82. package/dest/interfaces/configs.d.ts.map +1 -1
  83. package/dest/interfaces/configs.js +2 -1
  84. package/dest/interfaces/p2p.d.ts +7 -9
  85. package/dest/interfaces/p2p.d.ts.map +1 -1
  86. package/dest/interfaces/p2p.js +3 -4
  87. package/dest/interfaces/validator.d.ts +41 -15
  88. package/dest/interfaces/validator.d.ts.map +1 -1
  89. package/dest/interfaces/validator.js +3 -2
  90. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -5
  91. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  92. package/dest/kernel/hints/build_note_hash_read_request_hints.js +5 -6
  93. package/dest/messaging/l2_to_l1_membership.d.ts +1 -1
  94. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  95. package/dest/messaging/l2_to_l1_membership.js +5 -3
  96. package/dest/messaging/out_hash.d.ts +41 -4
  97. package/dest/messaging/out_hash.d.ts.map +1 -1
  98. package/dest/messaging/out_hash.js +52 -26
  99. package/dest/note/note_dao.d.ts +8 -5
  100. package/dest/note/note_dao.d.ts.map +1 -1
  101. package/dest/note/note_dao.js +15 -12
  102. package/dest/p2p/attestation_utils.d.ts +3 -3
  103. package/dest/p2p/attestation_utils.d.ts.map +1 -1
  104. package/dest/p2p/attestation_utils.js +1 -1
  105. package/dest/p2p/block_proposal.d.ts +85 -21
  106. package/dest/p2p/block_proposal.d.ts.map +1 -1
  107. package/dest/p2p/block_proposal.js +126 -38
  108. package/dest/p2p/checkpoint_attestation.d.ts +78 -0
  109. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -0
  110. package/dest/p2p/{block_attestation.js → checkpoint_attestation.js} +22 -19
  111. package/dest/p2p/checkpoint_proposal.d.ts +155 -0
  112. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -0
  113. package/dest/p2p/checkpoint_proposal.js +222 -0
  114. package/dest/p2p/consensus_payload.d.ts +5 -2
  115. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  116. package/dest/p2p/consensus_payload.js +3 -2
  117. package/dest/p2p/index.d.ts +4 -2
  118. package/dest/p2p/index.d.ts.map +1 -1
  119. package/dest/p2p/index.js +3 -1
  120. package/dest/p2p/signature_utils.d.ts +5 -3
  121. package/dest/p2p/signature_utils.d.ts.map +1 -1
  122. package/dest/p2p/signature_utils.js +3 -1
  123. package/dest/p2p/signed_txs.d.ts +40 -0
  124. package/dest/p2p/signed_txs.d.ts.map +1 -0
  125. package/dest/p2p/signed_txs.js +75 -0
  126. package/dest/p2p/topic_type.d.ts +3 -2
  127. package/dest/p2p/topic_type.d.ts.map +1 -1
  128. package/dest/p2p/topic_type.js +8 -2
  129. package/dest/rollup/block_headers_hash.js +1 -1
  130. package/dest/rollup/block_rollup_public_inputs.d.ts +2 -2
  131. package/dest/rollup/block_rollup_public_inputs.js +2 -2
  132. package/dest/rollup/checkpoint_header.d.ts +16 -2
  133. package/dest/rollup/checkpoint_header.d.ts.map +1 -1
  134. package/dest/rollup/checkpoint_header.js +25 -5
  135. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +11 -6
  136. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
  137. package/dest/rollup/checkpoint_rollup_public_inputs.js +10 -6
  138. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +14 -3
  139. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
  140. package/dest/rollup/checkpoint_root_rollup_private_inputs.js +13 -2
  141. package/dest/rollup/root_rollup_public_inputs.d.ts +5 -2
  142. package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
  143. package/dest/rollup/root_rollup_public_inputs.js +4 -1
  144. package/dest/tests/factories.d.ts +13 -1
  145. package/dest/tests/factories.d.ts.map +1 -1
  146. package/dest/tests/factories.js +53 -3
  147. package/dest/tests/mocks.d.ts +55 -9
  148. package/dest/tests/mocks.d.ts.map +1 -1
  149. package/dest/tests/mocks.js +84 -35
  150. package/dest/tx/private_execution_result.d.ts +1 -5
  151. package/dest/tx/private_execution_result.d.ts.map +1 -1
  152. package/dest/tx/private_execution_result.js +3 -20
  153. package/dest/tx/tx_effect.d.ts +1 -6
  154. package/dest/tx/tx_effect.d.ts.map +1 -1
  155. package/dest/tx/tx_effect.js +0 -7
  156. package/package.json +9 -8
  157. package/src/abi/utils.ts +17 -0
  158. package/src/block/attestation_info.ts +9 -6
  159. package/src/block/body.ts +2 -1
  160. package/src/block/checkpointed_l2_block.ts +5 -4
  161. package/src/block/l2_block.ts +4 -3
  162. package/src/block/l2_block_code_to_purge.ts +1 -0
  163. package/src/block/l2_block_header.ts +13 -0
  164. package/src/block/l2_block_new.ts +5 -1
  165. package/src/block/l2_block_source.ts +69 -17
  166. package/src/block/l2_block_stream/index.ts +1 -0
  167. package/src/block/l2_block_stream/interfaces.ts +16 -4
  168. package/src/block/l2_block_stream/l2_block_stream.ts +121 -38
  169. package/src/block/l2_block_stream/l2_tips_memory_store.ts +62 -56
  170. package/src/block/l2_block_stream/l2_tips_store_base.ts +226 -0
  171. package/src/block/test/l2_tips_store_test_suite.ts +485 -36
  172. package/src/block/validate_block_result.ts +40 -35
  173. package/src/checkpoint/checkpoint.ts +12 -1
  174. package/src/checkpoint/checkpoint_info.ts +45 -2
  175. package/src/checkpoint/index.ts +1 -0
  176. package/src/checkpoint/published_checkpoint.ts +4 -3
  177. package/src/contract/index.ts +0 -2
  178. package/src/deserialization/index.ts +21 -0
  179. package/src/interfaces/api_limit.ts +1 -0
  180. package/src/interfaces/archiver.ts +14 -6
  181. package/src/interfaces/aztec-node-admin.ts +5 -2
  182. package/src/interfaces/aztec-node.ts +30 -3
  183. package/src/interfaces/block-builder.ts +1 -0
  184. package/src/interfaces/configs.ts +5 -0
  185. package/src/interfaces/p2p.ts +8 -12
  186. package/src/interfaces/validator.ts +57 -11
  187. package/src/kernel/hints/build_note_hash_read_request_hints.ts +5 -8
  188. package/src/messaging/l2_to_l1_membership.ts +5 -3
  189. package/src/messaging/out_hash.ts +60 -29
  190. package/src/note/note_dao.ts +18 -13
  191. package/src/p2p/attestation_utils.ts +3 -3
  192. package/src/p2p/block_proposal.ts +191 -42
  193. package/src/p2p/{block_attestation.ts → checkpoint_attestation.ts} +31 -25
  194. package/src/p2p/checkpoint_proposal.ts +342 -0
  195. package/src/p2p/consensus_payload.ts +5 -2
  196. package/src/p2p/index.ts +3 -1
  197. package/src/p2p/signature_utils.ts +3 -1
  198. package/src/p2p/signed_txs.ts +88 -0
  199. package/src/p2p/topic_type.ts +3 -2
  200. package/src/rollup/block_headers_hash.ts +1 -1
  201. package/src/rollup/block_rollup_public_inputs.ts +2 -2
  202. package/src/rollup/checkpoint_header.ts +33 -0
  203. package/src/rollup/checkpoint_rollup_public_inputs.ts +12 -6
  204. package/src/rollup/checkpoint_root_rollup_private_inputs.ts +14 -1
  205. package/src/rollup/root_rollup_public_inputs.ts +4 -1
  206. package/src/tests/factories.ts +46 -2
  207. package/src/tests/mocks.ts +146 -50
  208. package/src/tx/private_execution_result.ts +0 -15
  209. package/src/tx/tx_effect.ts +0 -9
  210. package/dest/contract/contract_class_metadata.d.ts +0 -8
  211. package/dest/contract/contract_class_metadata.d.ts.map +0 -1
  212. package/dest/contract/contract_class_metadata.js +0 -1
  213. package/dest/contract/contract_metadata.d.ts +0 -7
  214. package/dest/contract/contract_metadata.d.ts.map +0 -1
  215. package/dest/contract/contract_metadata.js +0 -1
  216. package/dest/p2p/block_attestation.d.ts +0 -77
  217. package/dest/p2p/block_attestation.d.ts.map +0 -1
  218. package/src/contract/contract_class_metadata.ts +0 -8
  219. package/src/contract/contract_metadata.ts +0 -7
@@ -5,57 +5,62 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
 
6
6
  import { z } from 'zod';
7
7
 
8
- import { BlockInfoSchema, type L2BlockInfo, deserializeBlockInfo, serializeBlockInfo } from './l2_block_info.js';
8
+ import {
9
+ type CheckpointInfo,
10
+ CheckpointInfoSchema,
11
+ deserializeCheckpointInfo,
12
+ serializeCheckpointInfo,
13
+ } from '../checkpoint/checkpoint_info.js';
14
+ import { MAX_COMMITTEE_SIZE } from '../deserialization/index.js';
9
15
  import { CommitteeAttestation } from './proposal/committee_attestation.js';
10
16
 
11
- /** Subtype for invalid block validation results */
12
- export type ValidateBlockNegativeResult =
17
+ /** Subtype for invalid checkpoint validation results */
18
+ export type ValidateCheckpointNegativeResult =
13
19
  | {
14
20
  valid: false;
15
- /** Identifiers from the invalid block */
16
- block: L2BlockInfo;
17
- /** Committee members at the epoch this block was proposed */
21
+ /** Identifiers from the invalid checkpoint */
22
+ checkpoint: CheckpointInfo;
23
+ /** Committee members at the epoch this checkpoint was proposed */
18
24
  committee: EthAddress[];
19
- /** Epoch in which this block was proposed */
25
+ /** Epoch in which this checkpoint was proposed */
20
26
  epoch: EpochNumber;
21
27
  /** Proposer selection seed for the epoch */
22
28
  seed: bigint;
23
- /** List of committee members who signed this block proposal */
29
+ /** List of committee members who signed this checkpoint proposal */
24
30
  attestors: EthAddress[];
25
- /** Committee attestations for this block as they were posted to L1 */
31
+ /** Committee attestations for this checkpoint as they were posted to L1 */
26
32
  attestations: CommitteeAttestation[];
27
- /** Reason for the block being invalid: not enough attestations were posted */
33
+ /** Reason for the checkpoint being invalid: not enough attestations were posted */
28
34
  reason: 'insufficient-attestations';
29
35
  }
30
36
  | {
31
37
  valid: false;
32
- /** Identifiers from the invalid block */
33
- block: L2BlockInfo;
34
- /** Committee members at the epoch this block was proposed */
38
+ /** Identifiers from the invalid checkpoint */
39
+ checkpoint: CheckpointInfo;
40
+ /** Committee members at the epoch this checkpoint was proposed */
35
41
  committee: EthAddress[];
36
- /** Epoch in which this block was proposed */
42
+ /** Epoch in which this checkpoint was proposed */
37
43
  epoch: EpochNumber;
38
44
  /** Proposer selection seed for the epoch */
39
45
  seed: bigint;
40
- /** List of committee members who signed this block proposal */
46
+ /** List of committee members who signed this checkpoint proposal */
41
47
  attestors: EthAddress[];
42
- /** Committee attestations for this block as they were posted to L1 */
48
+ /** Committee attestations for this checkpoint as they were posted to L1 */
43
49
  attestations: CommitteeAttestation[];
44
- /** Reason for the block being invalid: an invalid attestation was posted */
50
+ /** Reason for the checkpoint being invalid: an invalid attestation was posted */
45
51
  reason: 'invalid-attestation';
46
52
  /** Index in the attestations array of the invalid attestation posted */
47
53
  invalidIndex: number;
48
54
  };
49
55
 
50
- // TODO: Rename to ValidateAttestationsResult
51
- /** Result type for validating a block attestations */
52
- export type ValidateBlockResult = { valid: true } | ValidateBlockNegativeResult;
56
+ /** Result type for validating checkpoint attestations */
57
+ export type ValidateCheckpointResult = { valid: true } | ValidateCheckpointNegativeResult;
53
58
 
54
- export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
59
+ export const ValidateCheckpointResultSchema: ZodFor<ValidateCheckpointResult> = z.union([
55
60
  z.object({ valid: z.literal(true) }),
56
61
  z.object({
57
62
  valid: z.literal(false),
58
- block: BlockInfoSchema,
63
+ checkpoint: CheckpointInfoSchema,
59
64
  committee: z.array(schemas.EthAddress),
60
65
  epoch: EpochNumberSchema,
61
66
  seed: schemas.BigInt,
@@ -65,7 +70,7 @@ export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
65
70
  }),
66
71
  z.object({
67
72
  valid: z.literal(false),
68
- block: BlockInfoSchema,
73
+ checkpoint: CheckpointInfoSchema,
69
74
  committee: z.array(schemas.EthAddress),
70
75
  epoch: EpochNumberSchema,
71
76
  seed: schemas.BigInt,
@@ -76,17 +81,17 @@ export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
76
81
  }),
77
82
  ]);
78
83
 
79
- export function serializeValidateBlockResult(result: ValidateBlockResult): Buffer {
84
+ export function serializeValidateCheckpointResult(result: ValidateCheckpointResult): Buffer {
80
85
  if (result.valid) {
81
86
  return serializeToBuffer(true);
82
87
  }
83
88
 
84
- const l2Block = serializeBlockInfo(result.block);
89
+ const checkpointBuffer = serializeCheckpointInfo(result.checkpoint);
85
90
  return serializeToBuffer(
86
91
  result.valid,
87
92
  result.reason,
88
- l2Block.length,
89
- l2Block,
93
+ checkpointBuffer.length,
94
+ checkpointBuffer,
90
95
  result.committee.length,
91
96
  result.committee,
92
97
  result.epoch,
@@ -99,24 +104,24 @@ export function serializeValidateBlockResult(result: ValidateBlockResult): Buffe
99
104
  );
100
105
  }
101
106
 
102
- export function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferReader): ValidateBlockResult {
107
+ export function deserializeValidateCheckpointResult(bufferOrReader: Buffer | BufferReader): ValidateCheckpointResult {
103
108
  const reader = BufferReader.asReader(bufferOrReader);
104
109
  const valid = reader.readBoolean();
105
110
  if (valid) {
106
111
  return { valid };
107
112
  }
108
- const reason = reader.readString() as 'insufficient-attestations' | 'invalid-attestation';
109
- const block = deserializeBlockInfo(reader.readBuffer());
110
- const committee = reader.readVector(EthAddress);
113
+ const reason = reader.readString(64) as 'insufficient-attestations' | 'invalid-attestation';
114
+ const checkpoint = deserializeCheckpointInfo(reader.readBuffer());
115
+ const committee = reader.readVector(EthAddress, MAX_COMMITTEE_SIZE);
111
116
  const epoch = EpochNumber(reader.readNumber());
112
117
  const seed = reader.readBigInt();
113
- const attestors = reader.readVector(EthAddress);
114
- const attestations = reader.readVector(CommitteeAttestation);
118
+ const attestors = reader.readVector(EthAddress, MAX_COMMITTEE_SIZE);
119
+ const attestations = reader.readVector(CommitteeAttestation, MAX_COMMITTEE_SIZE);
115
120
  const invalidIndex = reader.readNumber();
116
121
  if (reason === 'insufficient-attestations') {
117
- return { valid, reason, block, committee, epoch, seed, attestors, attestations: attestations };
122
+ return { valid, reason, checkpoint, committee, epoch, seed, attestors, attestations };
118
123
  } else if (reason === 'invalid-attestation') {
119
- return { valid, reason, block, committee, epoch, seed, attestors, invalidIndex, attestations: attestations };
124
+ return { valid, reason, checkpoint, committee, epoch, seed, attestors, invalidIndex, attestations };
120
125
  } else {
121
126
  const _: never = reason;
122
127
  throw new Error(`Unknown reason: ${reason}`);
@@ -8,6 +8,8 @@ import type { FieldsOf } from '@aztec/foundation/types';
8
8
  import { z } from 'zod';
9
9
 
10
10
  import { L2BlockNew } from '../block/l2_block_new.js';
11
+ import { MAX_BLOCKS_PER_CHECKPOINT } from '../deserialization/index.js';
12
+ import { computeCheckpointOutHash } from '../messaging/out_hash.js';
11
13
  import { CheckpointHeader } from '../rollup/checkpoint_header.js';
12
14
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
13
15
  import type { CheckpointInfo } from './checkpoint_info.js';
@@ -48,7 +50,7 @@ export class Checkpoint {
48
50
  return new Checkpoint(
49
51
  reader.readObject(AppendOnlyTreeSnapshot),
50
52
  reader.readObject(CheckpointHeader),
51
- reader.readVector(L2BlockNew),
53
+ reader.readVector(L2BlockNew, MAX_BLOCKS_PER_CHECKPOINT),
52
54
  CheckpointNumber(reader.readNumber()),
53
55
  );
54
56
  }
@@ -66,6 +68,14 @@ export class Checkpoint {
66
68
  return this.header.hash();
67
69
  }
68
70
 
71
+ // Returns the out hash computed from all l2-to-l1 messages in this checkpoint.
72
+ // Note: This value is different from the out hash in the header, which is the **accumulated** out hash over all
73
+ // checkpoints up to and including this one in the epoch.
74
+ public getCheckpointOutHash(): Fr {
75
+ const msgs = this.blocks.map(block => block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
76
+ return computeCheckpointOutHash(msgs);
77
+ }
78
+
69
79
  public getState() {
70
80
  return this.blocks.at(-1)!.header.state;
71
81
  }
@@ -73,6 +83,7 @@ export class Checkpoint {
73
83
  public toCheckpointInfo(): CheckpointInfo {
74
84
  return {
75
85
  archive: this.archive.root,
86
+ lastArchive: this.header.lastArchiveRoot,
76
87
  slotNumber: this.header.slotNumber,
77
88
  checkpointNumber: this.number,
78
89
  timestamp: this.header.timestamp,
@@ -1,9 +1,52 @@
1
- import type { CheckpointNumber } from '@aztec/foundation/branded-types';
2
- import type { Fr, SlotNumber } from '@aztec/foundation/schemas';
1
+ import {
2
+ CheckpointNumber,
3
+ CheckpointNumberSchema,
4
+ SlotNumber,
5
+ SlotNumberSchema,
6
+ } from '@aztec/foundation/branded-types';
7
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
+ import { schemas } from '@aztec/foundation/schemas';
9
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
10
+
11
+ import { z } from 'zod';
3
12
 
4
13
  export type CheckpointInfo = {
5
14
  archive: Fr;
15
+ lastArchive: Fr;
6
16
  slotNumber: SlotNumber;
7
17
  checkpointNumber: CheckpointNumber;
8
18
  timestamp: bigint;
9
19
  };
20
+
21
+ export function randomCheckpointInfo(checkpointNumber?: CheckpointNumber | number): CheckpointInfo {
22
+ return {
23
+ archive: Fr.random(),
24
+ lastArchive: Fr.random(),
25
+ slotNumber: SlotNumber(Math.floor(Math.random() * 100000) + 1),
26
+ checkpointNumber: CheckpointNumber(checkpointNumber ?? Math.floor(Math.random() * 100000) + 1),
27
+ timestamp: BigInt(Math.floor(Date.now() / 1000)),
28
+ };
29
+ }
30
+
31
+ export const CheckpointInfoSchema = z.object({
32
+ archive: schemas.Fr,
33
+ lastArchive: schemas.Fr,
34
+ slotNumber: SlotNumberSchema,
35
+ checkpointNumber: CheckpointNumberSchema,
36
+ timestamp: schemas.BigInt,
37
+ });
38
+
39
+ export function serializeCheckpointInfo(info: CheckpointInfo): Buffer {
40
+ return serializeToBuffer(info.archive, info.lastArchive, info.slotNumber, info.checkpointNumber, info.timestamp);
41
+ }
42
+
43
+ export function deserializeCheckpointInfo(buffer: Buffer | BufferReader): CheckpointInfo {
44
+ const reader = BufferReader.asReader(buffer);
45
+ return {
46
+ archive: reader.readObject(Fr),
47
+ lastArchive: reader.readObject(Fr),
48
+ slotNumber: SlotNumber(reader.readNumber()),
49
+ checkpointNumber: CheckpointNumber(reader.readNumber()),
50
+ timestamp: reader.readBigInt(),
51
+ };
52
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './checkpoint.js';
2
+ export * from './checkpoint_info.js';
2
3
  export * from './published_checkpoint.js';
@@ -8,6 +8,7 @@ import type { FieldsOf } from '@aztec/foundation/types';
8
8
  import { z } from 'zod';
9
9
 
10
10
  import { CommitteeAttestation } from '../block/proposal/committee_attestation.js';
11
+ import { MAX_BLOCK_HASH_STRING_LENGTH, MAX_COMMITTEE_SIZE } from '../deserialization/index.js';
11
12
  import { Checkpoint } from './checkpoint.js';
12
13
 
13
14
  export class L1PublishedData {
@@ -42,7 +43,7 @@ export class L1PublishedData {
42
43
  static fromBuffer(bufferOrReader: Buffer | BufferReader): L1PublishedData {
43
44
  const reader = BufferReader.asReader(bufferOrReader);
44
45
  const l1BlockNumber = reader.readBigInt();
45
- const l1BlockHash = reader.readString();
46
+ const l1BlockHash = reader.readString(MAX_BLOCK_HASH_STRING_LENGTH);
46
47
  const l1Timestamp = reader.readBigInt();
47
48
  return new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash);
48
49
  }
@@ -82,9 +83,9 @@ export class PublishedCheckpoint {
82
83
  const reader = BufferReader.asReader(bufferOrReader);
83
84
  const checkpoint = reader.readObject(Checkpoint);
84
85
  const l1BlockNumber = reader.readBigInt();
85
- const l1BlockHash = reader.readString();
86
+ const l1BlockHash = reader.readString(MAX_BLOCK_HASH_STRING_LENGTH);
86
87
  const l1Timestamp = reader.readBigInt();
87
- const attestations = reader.readVector(CommitteeAttestation);
88
+ const attestations = reader.readVector(CommitteeAttestation, MAX_COMMITTEE_SIZE);
88
89
  return new PublishedCheckpoint(
89
90
  checkpoint,
90
91
  new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash),
@@ -1,11 +1,9 @@
1
1
  export * from './artifact_hash.js';
2
2
  export * from './contract_address.js';
3
3
  export * from './contract_class.js';
4
- export * from './contract_class_metadata.js';
5
4
  export * from './contract_class_id.js';
6
5
  export * from './contract_deployment_data.js';
7
6
  export * from './contract_instance.js';
8
- export * from './contract_metadata.js';
9
7
  export * from './contract_instance_update.js';
10
8
  export * from './private_function.js';
11
9
  export * from './private_function_membership_proof.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Constants for deserialization bounds checking.
3
+ * These constants define maximum allowed sizes during deserialization
4
+ * to prevent DoS attacks via maliciously crafted messages.
5
+ */
6
+ import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB } from '@aztec/constants';
7
+
8
+ /** Max transactions per block for deserialization validation */
9
+ export const MAX_TXS_PER_BLOCK = 2 ** 16;
10
+
11
+ /** Max committee size - theoretical max from bitmap design (256 bytes × 8 bits) */
12
+ export const MAX_COMMITTEE_SIZE = 2048;
13
+
14
+ /** Max blocks per checkpoint */
15
+ export const MAX_BLOCKS_PER_CHECKPOINT = 72;
16
+
17
+ /** Max tx effects per body (based on blob capacity per checkpoint) */
18
+ export const MAX_TX_EFFECTS_PER_BODY = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB;
19
+
20
+ /** Max block hash string length (hex: 0x + 64 chars, with generous headroom) */
21
+ export const MAX_BLOCK_HASH_STRING_LENGTH = 128;
@@ -1,3 +1,4 @@
1
1
  export const MAX_RPC_LEN = 100;
2
2
  export const MAX_RPC_TXS_LEN = 50;
3
3
  export const MAX_RPC_BLOCKS_LEN = 50;
4
+ export const MAX_RPC_CHECKPOINTS_LEN = 50;
@@ -8,7 +8,7 @@ import { CheckpointedL2Block, PublishedL2Block } from '../block/checkpointed_l2_
8
8
  import { L2Block } from '../block/l2_block.js';
9
9
  import { L2BlockNew } from '../block/l2_block_new.js';
10
10
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
11
- import { ValidateBlockResultSchema } from '../block/validate_block_result.js';
11
+ import { ValidateCheckpointResultSchema } from '../block/validate_block_result.js';
12
12
  import { Checkpoint } from '../checkpoint/checkpoint.js';
13
13
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
14
14
  import {
@@ -52,14 +52,14 @@ export type ArchiverSpecificConfig = {
52
52
  /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb. */
53
53
  archiverStoreMapSizeKb?: number;
54
54
 
55
- /** Whether to skip validating block attestations (use only for testing). */
56
- skipValidateBlockAttestations?: boolean;
57
-
58
55
  /** Maximum allowed drift in seconds between the Ethereum client and current time. */
59
56
  maxAllowedEthClientDriftSeconds?: number;
60
57
 
61
58
  /** Whether to allow starting the archiver without debug/trace method support on Ethereum hosts */
62
59
  ethereumAllowNoDebugHosts?: boolean;
60
+
61
+ /** Skip validating checkpoint attestations (for testing purposes only) */
62
+ skipValidateCheckpointAttestations?: boolean;
63
63
  };
64
64
 
65
65
  export const ArchiverSpecificConfigSchema = z.object({
@@ -68,9 +68,9 @@ export const ArchiverSpecificConfigSchema = z.object({
68
68
  viemPollingIntervalMS: schemas.Integer.optional(),
69
69
  maxLogs: schemas.Integer.optional(),
70
70
  archiverStoreMapSizeKb: schemas.Integer.optional(),
71
- skipValidateBlockAttestations: z.boolean().optional(),
72
71
  maxAllowedEthClientDriftSeconds: schemas.Integer.optional(),
73
72
  ethereumAllowNoDebugHosts: z.boolean().optional(),
73
+ skipValidateCheckpointAttestations: z.boolean().optional(),
74
74
  });
75
75
 
76
76
  export type ArchiverApi = Omit<
@@ -89,6 +89,10 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
89
89
  .args(z.union([BlockNumberSchema, z.literal('latest')]))
90
90
  .returns(BlockHeader.schema.optional()),
91
91
  getCheckpointedBlock: z.function().args(BlockNumberSchema).returns(CheckpointedL2Block.schema.optional()),
92
+ getCheckpointedBlocks: z
93
+ .function()
94
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
95
+ .returns(z.array(CheckpointedL2Block.schema)),
92
96
  getBlocks: z
93
97
  .function()
94
98
  .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
@@ -101,6 +105,10 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
101
105
  .function()
102
106
  .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
103
107
  .returns(z.array(PublishedL2Block.schema)),
108
+ getL2BlocksNew: z
109
+ .function()
110
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
111
+ .returns(z.array(L2BlockNew.schema)),
104
112
  getPublishedBlockByHash: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
105
113
  getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
106
114
  getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
@@ -144,5 +152,5 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
144
152
  getL1Timestamp: z.function().args().returns(schemas.BigInt.optional()),
145
153
  syncImmediate: z.function().args().returns(z.void()),
146
154
  isPendingChainInvalid: z.function().args().returns(z.boolean()),
147
- getPendingChainValidationStatus: z.function().args().returns(ValidateBlockResultSchema),
155
+ getPendingChainValidationStatus: z.function().args().returns(ValidateCheckpointResultSchema),
148
156
  };
@@ -56,7 +56,10 @@ export type AztecNodeAdminConfig = ValidatorClientFullConfig &
56
56
  SequencerConfig &
57
57
  ProverConfig &
58
58
  SlasherConfig &
59
- Pick<ArchiverSpecificConfig, 'archiverPollingIntervalMS' | 'skipValidateBlockAttestations' | 'archiverBatchSize'> & {
59
+ Pick<
60
+ ArchiverSpecificConfig,
61
+ 'archiverPollingIntervalMS' | 'archiverBatchSize' | 'skipValidateCheckpointAttestations'
62
+ > & {
60
63
  maxPendingTxCount: number;
61
64
  };
62
65
 
@@ -66,8 +69,8 @@ export const AztecNodeAdminConfigSchema = SequencerConfigSchema.merge(ProverConf
66
69
  .merge(
67
70
  ArchiverSpecificConfigSchema.pick({
68
71
  archiverPollingIntervalMS: true,
69
- skipValidateBlockAttestations: true,
70
72
  archiverBatchSize: true,
73
+ skipValidateCheckpointAttestations: true,
71
74
  }),
72
75
  )
73
76
  .merge(z.object({ maxPendingTxCount: z.number() }));
@@ -10,6 +10,7 @@ import {
10
10
  BlockNumber,
11
11
  BlockNumberPositiveSchema,
12
12
  BlockNumberSchema,
13
+ CheckpointNumberPositiveSchema,
13
14
  EpochNumber,
14
15
  EpochNumberSchema,
15
16
  type SlotNumber,
@@ -23,10 +24,12 @@ import { z } from 'zod';
23
24
 
24
25
  import type { AztecAddress } from '../aztec-address/index.js';
25
26
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
26
- import { PublishedL2Block } from '../block/checkpointed_l2_block.js';
27
+ import { CheckpointedL2Block, PublishedL2Block } from '../block/checkpointed_l2_block.js';
27
28
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
28
29
  import { L2Block } from '../block/l2_block.js';
30
+ import { L2BlockNew } from '../block/l2_block_new.js';
29
31
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
32
+ import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
30
33
  import {
31
34
  type ContractClassPublic,
32
35
  ContractClassPublicSchema,
@@ -59,7 +62,7 @@ import { SingleValidatorStatsSchema, ValidatorsStatsSchema } from '../validators
59
62
  import type { SingleValidatorStats, ValidatorsStats } from '../validators/types.js';
60
63
  import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
61
64
  import { type AllowedElement, AllowedElementSchema } from './allowed_element.js';
62
- import { MAX_RPC_BLOCKS_LEN, MAX_RPC_LEN, MAX_RPC_TXS_LEN } from './api_limit.js';
65
+ import { MAX_RPC_BLOCKS_LEN, MAX_RPC_CHECKPOINTS_LEN, MAX_RPC_LEN, MAX_RPC_TXS_LEN } from './api_limit.js';
63
66
  import {
64
67
  type GetContractClassLogsResponse,
65
68
  GetContractClassLogsResponseSchema,
@@ -73,7 +76,16 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
73
76
  * We will probably implement the additional interfaces by means other than Aztec Node as it's currently a privacy leak
74
77
  */
75
78
  export interface AztecNode
76
- extends Pick<L2BlockSource, 'getBlocks' | 'getPublishedBlocks' | 'getBlockHeader' | 'getL2Tips'> {
79
+ extends Pick<
80
+ L2BlockSource,
81
+ | 'getBlocks'
82
+ | 'getL2BlocksNew'
83
+ | 'getPublishedBlocks'
84
+ | 'getPublishedCheckpoints'
85
+ | 'getBlockHeader'
86
+ | 'getL2Tips'
87
+ | 'getCheckpointedBlocks'
88
+ > {
77
89
  /**
78
90
  * Returns the tips of the L2 chain.
79
91
  */
@@ -582,6 +594,21 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
582
594
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
583
595
  .returns(z.array(PublishedL2Block.schema)),
584
596
 
597
+ getPublishedCheckpoints: z
598
+ .function()
599
+ .args(CheckpointNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_CHECKPOINTS_LEN))
600
+ .returns(z.array(PublishedCheckpoint.schema)),
601
+
602
+ getL2BlocksNew: z
603
+ .function()
604
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
605
+ .returns(z.array(L2BlockNew.schema)),
606
+
607
+ getCheckpointedBlocks: z
608
+ .function()
609
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN), optional(z.boolean()))
610
+ .returns(z.array(CheckpointedL2Block.schema)),
611
+
585
612
  getCurrentMinFees: z.function().returns(GasFees.schema),
586
613
 
587
614
  getMaxPriorityFees: z.function().returns(GasFees.schema),
@@ -80,6 +80,7 @@ export interface IFullNodeBlockBuilder {
80
80
  buildBlock(
81
81
  txs: Iterable<Tx> | AsyncIterable<Tx>,
82
82
  l1ToL2Messages: Fr[],
83
+ previousCheckpointOutHashes: Fr[],
83
84
  globalVariables: GlobalVariables,
84
85
  options: PublicProcessorLimits,
85
86
  fork?: MerkleTreeWriteOperations,
@@ -67,6 +67,10 @@ export interface SequencerConfig {
67
67
  blockDurationMs?: number;
68
68
  /** Have sequencer build and publish an empty checkpoint if there are no txs */
69
69
  buildCheckpointIfEmpty?: boolean;
70
+
71
+ // TODO(palla/mbps): Change default to false once block sync is stable
72
+ /** Skip pushing proposed blocks to archiver (default: true) */
73
+ skipPushProposedBlocksToArchiver?: boolean;
70
74
  }
71
75
 
72
76
  export const SequencerConfigSchema = zodFor<SequencerConfig>()(
@@ -100,6 +104,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
100
104
  shuffleAttestationOrdering: z.boolean().optional(),
101
105
  blockDurationMs: z.number().positive().optional(),
102
106
  buildCheckpointIfEmpty: z.boolean().optional(),
107
+ skipPushProposedBlocksToArchiver: z.boolean().optional(),
103
108
  }),
104
109
  );
105
110
 
@@ -2,7 +2,7 @@ import type { SlotNumber } from '@aztec/foundation/branded-types';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
5
- import { BlockAttestation } from '../p2p/block_attestation.js';
5
+ import { CheckpointAttestation } from '../p2p/checkpoint_attestation.js';
6
6
  import type { P2PClientType } from '../p2p/client_type.js';
7
7
  import { type ApiSchemaFor, optional, schemas } from '../schemas/index.js';
8
8
  import { Tx } from '../tx/tx.js';
@@ -52,21 +52,18 @@ export interface P2PApiWithoutAttestations {
52
52
 
53
53
  export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
54
54
  /**
55
- * Queries the Attestation pool for attestations for the given slot
55
+ * Queries the Attestation pool for checkpoint attestations for the given slot
56
56
  *
57
57
  * @param slot - the slot to query
58
58
  * @param proposalId - the proposal id to query, or undefined to query all proposals for the slot
59
- * @returns BlockAttestations
59
+ * @returns CheckpointAttestations
60
60
  */
61
- getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]>;
62
-
63
- /** Deletes a given attestation manually from the p2p client attestation pool. */
64
- deleteAttestation(attestation: BlockAttestation): Promise<void>;
61
+ getCheckpointAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<CheckpointAttestation[]>;
65
62
  }
66
63
 
67
64
  export interface P2PClient extends P2PApiWithAttestations {
68
- /** Manually adds an attestation to the p2p client attestation pool. */
69
- addAttestations(attestations: BlockAttestation[]): Promise<void>;
65
+ /** Manually adds checkpoint attestations to the p2p client attestation pool. */
66
+ addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
70
67
  }
71
68
 
72
69
  export type P2PApi<T extends P2PClientType = P2PClientType.Full> = T extends P2PClientType.Full
@@ -78,10 +75,10 @@ export type P2PApiFull<T extends P2PClientType = P2PClientType.Full> = T extends
78
75
  : P2PApiWithoutAttestations;
79
76
 
80
77
  export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
81
- getAttestationsForSlot: z
78
+ getCheckpointAttestationsForSlot: z
82
79
  .function()
83
80
  .args(schemas.SlotNumber, optional(z.string()))
84
- .returns(z.array(BlockAttestation.schema)),
81
+ .returns(z.array(CheckpointAttestation.schema)),
85
82
  getPendingTxs: z
86
83
  .function()
87
84
  .args(optional(z.number().gte(1).lte(MAX_RPC_TXS_LEN).default(MAX_RPC_TXS_LEN)), optional(TxHash.schema))
@@ -90,5 +87,4 @@ export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
90
87
  getPendingTxCount: z.function().returns(schemas.Integer),
91
88
  getEncodedEnr: z.function().returns(z.string().optional()),
92
89
  getPeers: z.function().args(optional(z.boolean())).returns(z.array(PeerInfoSchema)),
93
- deleteAttestation: z.function().args(BlockAttestation.schema).returns(z.void()),
94
90
  };