@aztec/stdlib 0.0.1-commit.6c91f13 → 0.0.1-commit.7d4e6cd

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 (240) hide show
  1. package/dest/abi/contract_artifact.d.ts +2 -2
  2. package/dest/abi/contract_artifact.d.ts.map +1 -1
  3. package/dest/abi/contract_artifact.js +1 -1
  4. package/dest/abi/selector.js +3 -1
  5. package/dest/avm/avm_accumulated_data.js +5 -2
  6. package/dest/avm/avm_circuit_public_inputs.js +3 -1
  7. package/dest/avm/public_data_update_request.js +3 -1
  8. package/dest/avm/public_inner_call_request.js +3 -1
  9. package/dest/avm/revert_code.js +3 -1
  10. package/dest/aztec-address/index.js +4 -2
  11. package/dest/block/attestation_info.d.ts +5 -5
  12. package/dest/block/attestation_info.d.ts.map +1 -1
  13. package/dest/block/attestation_info.js +4 -4
  14. package/dest/block/body.js +3 -1
  15. package/dest/block/l2_block.d.ts +6 -3
  16. package/dest/block/l2_block.d.ts.map +1 -1
  17. package/dest/block/l2_block.js +6 -4
  18. package/dest/block/l2_block_code_to_purge.d.ts +2 -3
  19. package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
  20. package/dest/block/l2_block_code_to_purge.js +2 -8
  21. package/dest/block/l2_block_header.d.ts +8 -12
  22. package/dest/block/l2_block_header.d.ts.map +1 -1
  23. package/dest/block/l2_block_header.js +25 -18
  24. package/dest/block/l2_block_new.d.ts +1 -2
  25. package/dest/block/l2_block_new.d.ts.map +1 -1
  26. package/dest/block/l2_block_new.js +4 -1
  27. package/dest/block/l2_block_source.d.ts +245 -41
  28. package/dest/block/l2_block_source.d.ts.map +1 -1
  29. package/dest/block/l2_block_source.js +23 -5
  30. package/dest/block/l2_block_stream/index.d.ts +2 -1
  31. package/dest/block/l2_block_stream/index.d.ts.map +1 -1
  32. package/dest/block/l2_block_stream/index.js +1 -0
  33. package/dest/block/l2_block_stream/interfaces.d.ts +12 -5
  34. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  35. package/dest/block/l2_block_stream/l2_block_stream.d.ts +4 -2
  36. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  37. package/dest/block/l2_block_stream/l2_block_stream.js +102 -30
  38. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +24 -16
  39. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
  40. package/dest/block/l2_block_stream/l2_tips_memory_store.js +55 -61
  41. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +49 -0
  42. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -0
  43. package/dest/block/l2_block_stream/l2_tips_store_base.js +179 -0
  44. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  45. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  46. package/dest/block/test/l2_tips_store_test_suite.js +483 -38
  47. package/dest/block/validate_block_result.d.ts +24 -24
  48. package/dest/block/validate_block_result.d.ts.map +1 -1
  49. package/dest/block/validate_block_result.js +13 -13
  50. package/dest/checkpoint/checkpoint.d.ts +1 -1
  51. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  52. package/dest/checkpoint/checkpoint.js +1 -0
  53. package/dest/checkpoint/checkpoint_info.d.ts +32 -3
  54. package/dest/checkpoint/checkpoint_info.d.ts.map +1 -1
  55. package/dest/checkpoint/checkpoint_info.js +34 -1
  56. package/dest/checkpoint/index.d.ts +2 -1
  57. package/dest/checkpoint/index.d.ts.map +1 -1
  58. package/dest/checkpoint/index.js +1 -0
  59. package/dest/database-version/version_manager.js +3 -1
  60. package/dest/gas/gas.js +3 -1
  61. package/dest/gas/gas_fees.js +3 -1
  62. package/dest/interfaces/api_limit.d.ts +2 -1
  63. package/dest/interfaces/api_limit.d.ts.map +1 -1
  64. package/dest/interfaces/api_limit.js +1 -0
  65. package/dest/interfaces/archiver.d.ts +6 -6
  66. package/dest/interfaces/archiver.d.ts.map +1 -1
  67. package/dest/interfaces/archiver.js +6 -4
  68. package/dest/interfaces/aztec-node-admin.d.ts +12 -6
  69. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  70. package/dest/interfaces/aztec-node-admin.js +2 -2
  71. package/dest/interfaces/aztec-node.d.ts +11 -10
  72. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  73. package/dest/interfaces/aztec-node.js +10 -5
  74. package/dest/interfaces/configs.d.ts +6 -1
  75. package/dest/interfaces/configs.d.ts.map +1 -1
  76. package/dest/interfaces/configs.js +2 -1
  77. package/dest/interfaces/p2p.d.ts +7 -9
  78. package/dest/interfaces/p2p.d.ts.map +1 -1
  79. package/dest/interfaces/p2p.js +3 -4
  80. package/dest/interfaces/proving-job.d.ts +170 -170
  81. package/dest/interfaces/proving-job.d.ts.map +1 -1
  82. package/dest/interfaces/proving-job.js +1 -7
  83. package/dest/interfaces/server_circuit_prover.d.ts +4 -3
  84. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  85. package/dest/interfaces/validator.d.ts +41 -7
  86. package/dest/interfaces/validator.d.ts.map +1 -1
  87. package/dest/interfaces/validator.js +3 -1
  88. package/dest/kernel/claimed_length_array.js +3 -1
  89. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -5
  90. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  91. package/dest/kernel/hints/build_note_hash_read_request_hints.js +5 -6
  92. package/dest/kernel/hints/transient_data_squashing_hint.js +3 -1
  93. package/dest/kernel/log_hash.js +3 -1
  94. package/dest/kernel/private_log_data.js +5 -2
  95. package/dest/kernel/private_to_avm_accumulated_data.js +5 -2
  96. package/dest/kernel/private_to_public_accumulated_data.js +3 -1
  97. package/dest/kernel/private_to_rollup_accumulated_data.js +3 -1
  98. package/dest/kernel/private_validation_requests.js +3 -1
  99. package/dest/kernel/public_call_request.js +5 -2
  100. package/dest/logs/contract_class_log.js +3 -1
  101. package/dest/logs/private_log.js +3 -1
  102. package/dest/logs/public_log.js +3 -1
  103. package/dest/messaging/in_hash.d.ts +4 -2
  104. package/dest/messaging/in_hash.d.ts.map +1 -1
  105. package/dest/messaging/in_hash.js +3 -1
  106. package/dest/messaging/l2_to_l1_membership.d.ts +88 -6
  107. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  108. package/dest/messaging/l2_to_l1_membership.js +158 -42
  109. package/dest/messaging/out_hash.d.ts +2 -1
  110. package/dest/messaging/out_hash.d.ts.map +1 -1
  111. package/dest/messaging/out_hash.js +13 -4
  112. package/dest/p2p/attestation_utils.d.ts +3 -3
  113. package/dest/p2p/attestation_utils.d.ts.map +1 -1
  114. package/dest/p2p/attestation_utils.js +1 -1
  115. package/dest/p2p/block_proposal.d.ts +85 -21
  116. package/dest/p2p/block_proposal.d.ts.map +1 -1
  117. package/dest/p2p/block_proposal.js +120 -37
  118. package/dest/p2p/checkpoint_attestation.d.ts +77 -0
  119. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -0
  120. package/dest/p2p/{block_attestation.js → checkpoint_attestation.js} +22 -19
  121. package/dest/p2p/checkpoint_proposal.d.ts +154 -0
  122. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -0
  123. package/dest/p2p/checkpoint_proposal.js +217 -0
  124. package/dest/p2p/consensus_payload.d.ts +6 -7
  125. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  126. package/dest/p2p/consensus_payload.js +3 -2
  127. package/dest/p2p/gossipable.d.ts +4 -3
  128. package/dest/p2p/gossipable.d.ts.map +1 -1
  129. package/dest/p2p/gossipable.js +16 -5
  130. package/dest/p2p/index.d.ts +4 -2
  131. package/dest/p2p/index.d.ts.map +1 -1
  132. package/dest/p2p/index.js +3 -1
  133. package/dest/p2p/signature_utils.d.ts +5 -3
  134. package/dest/p2p/signature_utils.d.ts.map +1 -1
  135. package/dest/p2p/signature_utils.js +3 -1
  136. package/dest/p2p/signed_txs.d.ts +40 -0
  137. package/dest/p2p/signed_txs.d.ts.map +1 -0
  138. package/dest/p2p/signed_txs.js +70 -0
  139. package/dest/p2p/topic_type.d.ts +3 -2
  140. package/dest/p2p/topic_type.d.ts.map +1 -1
  141. package/dest/p2p/topic_type.js +8 -2
  142. package/dest/rollup/block_rollup_public_inputs.d.ts +4 -9
  143. package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -1
  144. package/dest/rollup/block_rollup_public_inputs.js +6 -10
  145. package/dest/rollup/checkpoint_constant_data.js +3 -1
  146. package/dest/rollup/checkpoint_header.d.ts +15 -12
  147. package/dest/rollup/checkpoint_header.d.ts.map +1 -1
  148. package/dest/rollup/checkpoint_header.js +33 -19
  149. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +6 -1
  150. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
  151. package/dest/rollup/checkpoint_rollup_public_inputs.js +6 -2
  152. package/dest/rollup/root_rollup_public_inputs.d.ts +8 -3
  153. package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
  154. package/dest/rollup/root_rollup_public_inputs.js +6 -3
  155. package/dest/tests/factories.d.ts +15 -7
  156. package/dest/tests/factories.d.ts.map +1 -1
  157. package/dest/tests/factories.js +57 -13
  158. package/dest/tests/mocks.d.ts +59 -10
  159. package/dest/tests/mocks.d.ts.map +1 -1
  160. package/dest/tests/mocks.js +89 -41
  161. package/dest/trees/append_only_tree_snapshot.js +3 -1
  162. package/dest/tx/block_header.js +3 -1
  163. package/dest/tx/call_context.js +3 -1
  164. package/dest/tx/global_variable_builder.d.ts +2 -2
  165. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  166. package/dest/tx/global_variables.js +3 -1
  167. package/dest/tx/index.d.ts +1 -2
  168. package/dest/tx/index.d.ts.map +1 -1
  169. package/dest/tx/index.js +0 -1
  170. package/dest/tx/private_execution_result.d.ts +1 -5
  171. package/dest/tx/private_execution_result.d.ts.map +1 -1
  172. package/dest/tx/private_execution_result.js +3 -20
  173. package/dest/tx/public_call_request_with_calldata.js +3 -1
  174. package/dest/tx/state_reference.js +3 -1
  175. package/dest/tx/tree_snapshots.js +3 -1
  176. package/dest/tx/tx.d.ts +1 -1
  177. package/dest/tx/tx.d.ts.map +1 -1
  178. package/dest/tx/tx.js +3 -1
  179. package/dest/tx/tx_effect.js +3 -1
  180. package/dest/tx/tx_execution_request.d.ts +1 -1
  181. package/dest/tx/tx_execution_request.d.ts.map +1 -1
  182. package/dest/tx/tx_execution_request.js +6 -2
  183. package/package.json +8 -8
  184. package/src/abi/contract_artifact.ts +10 -10
  185. package/src/block/attestation_info.ts +9 -6
  186. package/src/block/l2_block.ts +6 -5
  187. package/src/block/l2_block_code_to_purge.ts +3 -11
  188. package/src/block/l2_block_header.ts +26 -17
  189. package/src/block/l2_block_new.ts +5 -1
  190. package/src/block/l2_block_source.ts +66 -16
  191. package/src/block/l2_block_stream/index.ts +1 -0
  192. package/src/block/l2_block_stream/interfaces.ts +12 -4
  193. package/src/block/l2_block_stream/l2_block_stream.ts +121 -38
  194. package/src/block/l2_block_stream/l2_tips_memory_store.ts +62 -56
  195. package/src/block/l2_block_stream/l2_tips_store_base.ts +226 -0
  196. package/src/block/test/l2_tips_store_test_suite.ts +485 -36
  197. package/src/block/validate_block_result.ts +35 -31
  198. package/src/checkpoint/checkpoint.ts +1 -0
  199. package/src/checkpoint/checkpoint_info.ts +45 -2
  200. package/src/checkpoint/index.ts +1 -0
  201. package/src/interfaces/api_limit.ts +1 -0
  202. package/src/interfaces/archiver.ts +14 -6
  203. package/src/interfaces/aztec-node-admin.ts +5 -2
  204. package/src/interfaces/aztec-node.ts +43 -13
  205. package/src/interfaces/configs.ts +5 -0
  206. package/src/interfaces/p2p.ts +8 -12
  207. package/src/interfaces/proving-job.ts +2 -11
  208. package/src/interfaces/server_circuit_prover.ts +3 -2
  209. package/src/interfaces/validator.ts +57 -7
  210. package/src/kernel/hints/build_note_hash_read_request_hints.ts +5 -8
  211. package/src/messaging/in_hash.ts +3 -1
  212. package/src/messaging/l2_to_l1_membership.ts +176 -52
  213. package/src/messaging/out_hash.ts +17 -7
  214. package/src/p2p/attestation_utils.ts +3 -3
  215. package/src/p2p/block_proposal.ts +185 -41
  216. package/src/p2p/{block_attestation.ts → checkpoint_attestation.ts} +31 -25
  217. package/src/p2p/checkpoint_proposal.ts +337 -0
  218. package/src/p2p/consensus_payload.ts +5 -2
  219. package/src/p2p/gossipable.ts +14 -4
  220. package/src/p2p/index.ts +3 -1
  221. package/src/p2p/signature_utils.ts +3 -1
  222. package/src/p2p/signed_txs.ts +83 -0
  223. package/src/p2p/topic_type.ts +3 -2
  224. package/src/rollup/block_rollup_public_inputs.ts +3 -9
  225. package/src/rollup/checkpoint_header.ts +43 -20
  226. package/src/rollup/checkpoint_rollup_public_inputs.ts +6 -0
  227. package/src/rollup/root_rollup_public_inputs.ts +6 -0
  228. package/src/tests/factories.ts +53 -17
  229. package/src/tests/mocks.ts +166 -64
  230. package/src/tx/global_variable_builder.ts +1 -1
  231. package/src/tx/index.ts +0 -1
  232. package/src/tx/private_execution_result.ts +0 -15
  233. package/src/tx/tx.ts +2 -0
  234. package/src/tx/tx_execution_request.ts +2 -0
  235. package/dest/p2p/block_attestation.d.ts +0 -80
  236. package/dest/p2p/block_attestation.d.ts.map +0 -1
  237. package/dest/tx/content_commitment.d.ts +0 -49
  238. package/dest/tx/content_commitment.d.ts.map +0 -1
  239. package/dest/tx/content_commitment.js +0 -90
  240. package/src/tx/content_commitment.ts +0 -113
@@ -5,57 +5,61 @@ 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';
9
14
  import { CommitteeAttestation } from './proposal/committee_attestation.js';
10
15
 
11
- /** Subtype for invalid block validation results */
12
- export type ValidateBlockNegativeResult =
16
+ /** Subtype for invalid checkpoint validation results */
17
+ export type ValidateCheckpointNegativeResult =
13
18
  | {
14
19
  valid: false;
15
- /** Identifiers from the invalid block */
16
- block: L2BlockInfo;
17
- /** Committee members at the epoch this block was proposed */
20
+ /** Identifiers from the invalid checkpoint */
21
+ checkpoint: CheckpointInfo;
22
+ /** Committee members at the epoch this checkpoint was proposed */
18
23
  committee: EthAddress[];
19
- /** Epoch in which this block was proposed */
24
+ /** Epoch in which this checkpoint was proposed */
20
25
  epoch: EpochNumber;
21
26
  /** Proposer selection seed for the epoch */
22
27
  seed: bigint;
23
- /** List of committee members who signed this block proposal */
28
+ /** List of committee members who signed this checkpoint proposal */
24
29
  attestors: EthAddress[];
25
- /** Committee attestations for this block as they were posted to L1 */
30
+ /** Committee attestations for this checkpoint as they were posted to L1 */
26
31
  attestations: CommitteeAttestation[];
27
- /** Reason for the block being invalid: not enough attestations were posted */
32
+ /** Reason for the checkpoint being invalid: not enough attestations were posted */
28
33
  reason: 'insufficient-attestations';
29
34
  }
30
35
  | {
31
36
  valid: false;
32
- /** Identifiers from the invalid block */
33
- block: L2BlockInfo;
34
- /** Committee members at the epoch this block was proposed */
37
+ /** Identifiers from the invalid checkpoint */
38
+ checkpoint: CheckpointInfo;
39
+ /** Committee members at the epoch this checkpoint was proposed */
35
40
  committee: EthAddress[];
36
- /** Epoch in which this block was proposed */
41
+ /** Epoch in which this checkpoint was proposed */
37
42
  epoch: EpochNumber;
38
43
  /** Proposer selection seed for the epoch */
39
44
  seed: bigint;
40
- /** List of committee members who signed this block proposal */
45
+ /** List of committee members who signed this checkpoint proposal */
41
46
  attestors: EthAddress[];
42
- /** Committee attestations for this block as they were posted to L1 */
47
+ /** Committee attestations for this checkpoint as they were posted to L1 */
43
48
  attestations: CommitteeAttestation[];
44
- /** Reason for the block being invalid: an invalid attestation was posted */
49
+ /** Reason for the checkpoint being invalid: an invalid attestation was posted */
45
50
  reason: 'invalid-attestation';
46
51
  /** Index in the attestations array of the invalid attestation posted */
47
52
  invalidIndex: number;
48
53
  };
49
54
 
50
- // TODO: Rename to ValidateAttestationsResult
51
- /** Result type for validating a block attestations */
52
- export type ValidateBlockResult = { valid: true } | ValidateBlockNegativeResult;
55
+ /** Result type for validating checkpoint attestations */
56
+ export type ValidateCheckpointResult = { valid: true } | ValidateCheckpointNegativeResult;
53
57
 
54
- export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
58
+ export const ValidateCheckpointResultSchema: ZodFor<ValidateCheckpointResult> = z.union([
55
59
  z.object({ valid: z.literal(true) }),
56
60
  z.object({
57
61
  valid: z.literal(false),
58
- block: BlockInfoSchema,
62
+ checkpoint: CheckpointInfoSchema,
59
63
  committee: z.array(schemas.EthAddress),
60
64
  epoch: EpochNumberSchema,
61
65
  seed: schemas.BigInt,
@@ -65,7 +69,7 @@ export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
65
69
  }),
66
70
  z.object({
67
71
  valid: z.literal(false),
68
- block: BlockInfoSchema,
72
+ checkpoint: CheckpointInfoSchema,
69
73
  committee: z.array(schemas.EthAddress),
70
74
  epoch: EpochNumberSchema,
71
75
  seed: schemas.BigInt,
@@ -76,17 +80,17 @@ export const ValidateBlockResultSchema: ZodFor<ValidateBlockResult> = z.union([
76
80
  }),
77
81
  ]);
78
82
 
79
- export function serializeValidateBlockResult(result: ValidateBlockResult): Buffer {
83
+ export function serializeValidateCheckpointResult(result: ValidateCheckpointResult): Buffer {
80
84
  if (result.valid) {
81
85
  return serializeToBuffer(true);
82
86
  }
83
87
 
84
- const l2Block = serializeBlockInfo(result.block);
88
+ const checkpointBuffer = serializeCheckpointInfo(result.checkpoint);
85
89
  return serializeToBuffer(
86
90
  result.valid,
87
91
  result.reason,
88
- l2Block.length,
89
- l2Block,
92
+ checkpointBuffer.length,
93
+ checkpointBuffer,
90
94
  result.committee.length,
91
95
  result.committee,
92
96
  result.epoch,
@@ -99,14 +103,14 @@ export function serializeValidateBlockResult(result: ValidateBlockResult): Buffe
99
103
  );
100
104
  }
101
105
 
102
- export function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferReader): ValidateBlockResult {
106
+ export function deserializeValidateCheckpointResult(bufferOrReader: Buffer | BufferReader): ValidateCheckpointResult {
103
107
  const reader = BufferReader.asReader(bufferOrReader);
104
108
  const valid = reader.readBoolean();
105
109
  if (valid) {
106
110
  return { valid };
107
111
  }
108
112
  const reason = reader.readString() as 'insufficient-attestations' | 'invalid-attestation';
109
- const block = deserializeBlockInfo(reader.readBuffer());
113
+ const checkpoint = deserializeCheckpointInfo(reader.readBuffer());
110
114
  const committee = reader.readVector(EthAddress);
111
115
  const epoch = EpochNumber(reader.readNumber());
112
116
  const seed = reader.readBigInt();
@@ -114,9 +118,9 @@ export function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferRe
114
118
  const attestations = reader.readVector(CommitteeAttestation);
115
119
  const invalidIndex = reader.readNumber();
116
120
  if (reason === 'insufficient-attestations') {
117
- return { valid, reason, block, committee, epoch, seed, attestors, attestations: attestations };
121
+ return { valid, reason, checkpoint, committee, epoch, seed, attestors, attestations };
118
122
  } else if (reason === 'invalid-attestation') {
119
- return { valid, reason, block, committee, epoch, seed, attestors, invalidIndex, attestations: attestations };
123
+ return { valid, reason, checkpoint, committee, epoch, seed, attestors, invalidIndex, attestations };
120
124
  } else {
121
125
  const _: never = reason;
122
126
  throw new Error(`Unknown reason: ${reason}`);
@@ -73,6 +73,7 @@ export class Checkpoint {
73
73
  public toCheckpointInfo(): CheckpointInfo {
74
74
  return {
75
75
  archive: this.archive.root,
76
+ lastArchive: this.header.lastArchiveRoot,
76
77
  slotNumber: this.header.slotNumber,
77
78
  checkpointNumber: this.number,
78
79
  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';
@@ -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,9 @@ import {
10
10
  BlockNumber,
11
11
  BlockNumberPositiveSchema,
12
12
  BlockNumberSchema,
13
+ CheckpointNumberPositiveSchema,
14
+ EpochNumber,
15
+ EpochNumberSchema,
13
16
  type SlotNumber,
14
17
  } from '@aztec/foundation/branded-types';
15
18
  import type { Fr } from '@aztec/foundation/curves/bn254';
@@ -21,10 +24,12 @@ import { z } from 'zod';
21
24
 
22
25
  import type { AztecAddress } from '../aztec-address/index.js';
23
26
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
24
- import { PublishedL2Block } from '../block/checkpointed_l2_block.js';
27
+ import { CheckpointedL2Block, PublishedL2Block } from '../block/checkpointed_l2_block.js';
25
28
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
26
29
  import { L2Block } from '../block/l2_block.js';
30
+ import { L2BlockNew } from '../block/l2_block_new.js';
27
31
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
32
+ import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
28
33
  import {
29
34
  type ContractClassPublic,
30
35
  ContractClassPublicSchema,
@@ -57,7 +62,7 @@ import { SingleValidatorStatsSchema, ValidatorsStatsSchema } from '../validators
57
62
  import type { SingleValidatorStats, ValidatorsStats } from '../validators/types.js';
58
63
  import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
59
64
  import { type AllowedElement, AllowedElementSchema } from './allowed_element.js';
60
- 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';
61
66
  import {
62
67
  type GetContractClassLogsResponse,
63
68
  GetContractClassLogsResponseSchema,
@@ -71,7 +76,16 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
71
76
  * We will probably implement the additional interfaces by means other than Aztec Node as it's currently a privacy leak
72
77
  */
73
78
  export interface AztecNode
74
- 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
+ > {
75
89
  /**
76
90
  * Returns the tips of the L2 chain.
77
91
  */
@@ -216,11 +230,12 @@ export interface AztecNode
216
230
  isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
217
231
 
218
232
  /**
219
- * Returns all the L2 to L1 messages in a block.
220
- * @param blockNumber - The block number at which to get the data.
221
- * @returns The L2 to L1 messages (undefined if the block number is not found).
233
+ * Returns all the L2 to L1 messages in an epoch.
234
+ * @param epoch - The epoch at which to get the data.
235
+ * @returns A nested array of the L2 to L1 messages in each tx of each block in each checkpoint in the epoch (empty
236
+ * array if the epoch is not found).
222
237
  */
223
- getL2ToL1Messages(blockNumber: BlockParameter): Promise<Fr[][] | undefined>;
238
+ getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]>;
224
239
 
225
240
  /**
226
241
  * Get a block specified by its number.
@@ -277,10 +292,10 @@ export interface AztecNode
277
292
  getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
278
293
 
279
294
  /**
280
- * Method to fetch the current base fees.
281
- * @returns The current base fees.
295
+ * Method to fetch the current min fees.
296
+ * @returns The current min fees.
282
297
  */
283
- getCurrentBaseFees(): Promise<GasFees>;
298
+ getCurrentMinFees(): Promise<GasFees>;
284
299
 
285
300
  /**
286
301
  * Method to fetch the current max priority fee of txs in the mempool.
@@ -552,8 +567,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
552
567
 
553
568
  getL2ToL1Messages: z
554
569
  .function()
555
- .args(BlockParameterSchema)
556
- .returns(z.array(z.array(schemas.Fr)).optional()),
570
+ .args(EpochNumberSchema)
571
+ .returns(z.array(z.array(z.array(z.array(schemas.Fr))))),
557
572
 
558
573
  getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
559
574
 
@@ -579,7 +594,22 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
579
594
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
580
595
  .returns(z.array(PublishedL2Block.schema)),
581
596
 
582
- getCurrentBaseFees: z.function().returns(GasFees.schema),
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
+
612
+ getCurrentMinFees: z.function().returns(GasFees.schema),
583
613
 
584
614
  getMaxPriorityFees: z.function().returns(GasFees.schema),
585
615
 
@@ -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
  };
@@ -47,15 +47,6 @@ export type ProofAndVerificationKey<N extends number> = {
47
47
  verificationKey: VerificationKeyData;
48
48
  };
49
49
 
50
- function schemaForRecursiveProofAndVerificationKey<N extends number>(
51
- proofLength: N,
52
- ): ZodFor<ProofAndVerificationKey<N>> {
53
- return z.object({
54
- proof: RecursiveProof.schemaFor(proofLength),
55
- verificationKey: VerificationKeyData.schema,
56
- });
57
- }
58
-
59
50
  export function makeProofAndVerificationKey<N extends number>(
60
51
  proof: RecursiveProof<N>,
61
52
  verificationKey: VerificationKeyData,
@@ -213,7 +204,7 @@ export type ProvingJobInputsMap = {
213
204
  export const ProvingJobResult = z.discriminatedUnion('type', [
214
205
  z.object({
215
206
  type: z.literal(ProvingRequestType.PUBLIC_VM),
216
- result: schemaForRecursiveProofAndVerificationKey(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
207
+ result: RecursiveProof.schemaFor(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
217
208
  }),
218
209
  z.object({
219
210
  type: z.literal(ProvingRequestType.PUBLIC_CHONK_VERIFIER),
@@ -328,7 +319,7 @@ export const ProvingJobResult = z.discriminatedUnion('type', [
328
319
  ]);
329
320
  export type ProvingJobResult = z.infer<typeof ProvingJobResult>;
330
321
  export type ProvingJobResultsMap = {
331
- [ProvingRequestType.PUBLIC_VM]: ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>;
322
+ [ProvingRequestType.PUBLIC_VM]: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>;
332
323
  [ProvingRequestType.PUBLIC_CHONK_VERIFIER]: PublicInputsAndRecursiveProof<
333
324
  PublicChonkVerifierPublicInputs,
334
325
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
@@ -9,6 +9,7 @@ import type { AvmCircuitInputs } from '../avm/avm.js';
9
9
  import type { ParityBasePrivateInputs } from '../parity/parity_base_private_inputs.js';
10
10
  import type { ParityPublicInputs } from '../parity/parity_public_inputs.js';
11
11
  import type { ParityRootPrivateInputs } from '../parity/parity_root_private_inputs.js';
12
+ import type { RecursiveProof } from '../proofs/recursive_proof.js';
12
13
  import type { BlockMergeRollupPrivateInputs } from '../rollup/block_merge_rollup_private_inputs.js';
13
14
  import type { BlockRollupPublicInputs } from '../rollup/block_rollup_public_inputs.js';
14
15
  import type {
@@ -34,7 +35,7 @@ import type { RootRollupPublicInputs } from '../rollup/root_rollup_public_inputs
34
35
  import type { TxMergeRollupPrivateInputs } from '../rollup/tx_merge_rollup_private_inputs.js';
35
36
  import type { TxRollupPublicInputs } from '../rollup/tx_rollup_public_inputs.js';
36
37
  import type { Tx } from '../tx/tx.js';
37
- import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from './proving-job.js';
38
+ import type { PublicInputsAndRecursiveProof } from './proving-job.js';
38
39
 
39
40
  /**
40
41
  * Generates proofs for parity and rollup circuits.
@@ -188,7 +189,7 @@ export interface ServerCircuitProver {
188
189
  inputs: AvmCircuitInputs,
189
190
  signal?: AbortSignal,
190
191
  epochNumber?: number,
191
- ): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>>;
192
+ ): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>>;
192
193
  }
193
194
 
194
195
  export type IVCProofVerificationResult = {