@aztec/stdlib 3.0.0-nightly.20250916 → 3.0.0-nightly.20250918

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 (202) hide show
  1. package/dest/avm/avm.d.ts +78 -1
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm.js +20 -2
  4. package/dest/avm/avm_circuit_public_inputs.d.ts +6 -1
  5. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  6. package/dest/avm/avm_circuit_public_inputs.js +11 -6
  7. package/dest/avm/avm_proving_request.d.ts +41 -0
  8. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  9. package/dest/block/body.d.ts +4 -1
  10. package/dest/block/body.d.ts.map +1 -1
  11. package/dest/block/body.js +16 -5
  12. package/dest/block/index.d.ts +1 -0
  13. package/dest/block/index.d.ts.map +1 -1
  14. package/dest/block/index.js +1 -0
  15. package/dest/block/l2_block.d.ts +8 -5
  16. package/dest/block/l2_block.d.ts.map +1 -1
  17. package/dest/block/l2_block.js +14 -7
  18. package/dest/block/l2_block_code_to_purge.d.ts +3 -14
  19. package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
  20. package/dest/block/l2_block_code_to_purge.js +23 -13
  21. package/dest/block/l2_block_header.d.ts +100 -0
  22. package/dest/block/l2_block_header.d.ts.map +1 -0
  23. package/dest/block/l2_block_header.js +146 -0
  24. package/dest/block/l2_block_stream/l2_tips_memory_store.js +1 -1
  25. package/dest/block/published_l2_block.d.ts +2 -2
  26. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  27. package/dest/block/test/l2_tips_store_test_suite.js +1 -3
  28. package/dest/interfaces/aztec-node.d.ts +5 -2
  29. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  30. package/dest/interfaces/aztec-node.js +1 -0
  31. package/dest/interfaces/block-builder.d.ts +1 -2
  32. package/dest/interfaces/block-builder.d.ts.map +1 -1
  33. package/dest/interfaces/epoch-prover.d.ts +25 -8
  34. package/dest/interfaces/epoch-prover.d.ts.map +1 -1
  35. package/dest/interfaces/proving-job.d.ts +204 -61
  36. package/dest/interfaces/proving-job.d.ts.map +1 -1
  37. package/dest/interfaces/proving-job.js +101 -39
  38. package/dest/interfaces/pxe.d.ts +8 -1
  39. package/dest/interfaces/pxe.d.ts.map +1 -1
  40. package/dest/interfaces/pxe.js +1 -0
  41. package/dest/interfaces/server_circuit_prover.d.ts +19 -16
  42. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  43. package/dest/interfaces/validator.d.ts +3 -2
  44. package/dest/interfaces/validator.d.ts.map +1 -1
  45. package/dest/kernel/private_circuit_public_inputs.d.ts +4 -4
  46. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  47. package/dest/kernel/private_circuit_public_inputs.js +7 -7
  48. package/dest/kernel/private_context_inputs.d.ts +2 -2
  49. package/dest/kernel/private_context_inputs.d.ts.map +1 -1
  50. package/dest/kernel/private_context_inputs.js +4 -4
  51. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +1 -1
  52. package/dest/messaging/inbox_leaf.d.ts +2 -0
  53. package/dest/messaging/inbox_leaf.d.ts.map +1 -1
  54. package/dest/messaging/inbox_leaf.js +3 -0
  55. package/dest/p2p/consensus_payload.d.ts +7 -6
  56. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  57. package/dest/p2p/consensus_payload.js +7 -6
  58. package/dest/parity/root_parity_input.d.ts +1 -1
  59. package/dest/proofs/proof_data.d.ts +1 -1
  60. package/dest/proofs/proof_data.d.ts.map +1 -1
  61. package/dest/proofs/proof_data.js +2 -2
  62. package/dest/proofs/proving_request_type.d.ts +13 -8
  63. package/dest/proofs/proving_request_type.d.ts.map +1 -1
  64. package/dest/proofs/proving_request_type.js +13 -8
  65. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +1 -1
  66. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
  67. package/dest/rollup/base_or_merge_rollup_public_inputs.js +1 -1
  68. package/dest/rollup/base_rollup_hints.d.ts +12 -3
  69. package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
  70. package/dest/rollup/base_rollup_hints.js +11 -5
  71. package/dest/rollup/block_constant_data.d.ts +20 -6
  72. package/dest/rollup/block_constant_data.d.ts.map +1 -1
  73. package/dest/rollup/block_constant_data.js +15 -7
  74. package/dest/rollup/block_merge_rollup.d.ts +10 -9
  75. package/dest/rollup/block_merge_rollup.d.ts.map +1 -1
  76. package/dest/rollup/block_merge_rollup.js +14 -13
  77. package/dest/rollup/block_rollup_public_inputs.d.ts +124 -0
  78. package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -0
  79. package/dest/rollup/block_rollup_public_inputs.js +85 -0
  80. package/dest/rollup/block_root_rollup.d.ts +148 -184
  81. package/dest/rollup/block_root_rollup.d.ts.map +1 -1
  82. package/dest/rollup/block_root_rollup.js +211 -260
  83. package/dest/rollup/checkpoint_constant_data.d.ts +54 -0
  84. package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -0
  85. package/dest/rollup/checkpoint_constant_data.js +55 -0
  86. package/dest/{tx/proposed_block_header.d.ts → rollup/checkpoint_header.d.ts} +11 -12
  87. package/dest/rollup/checkpoint_header.d.ts.map +1 -0
  88. package/dest/{tx/proposed_block_header.js → rollup/checkpoint_header.js} +9 -9
  89. package/dest/rollup/checkpoint_merge_rollup.d.ts +30 -0
  90. package/dest/rollup/checkpoint_merge_rollup.d.ts.map +1 -0
  91. package/dest/rollup/checkpoint_merge_rollup.js +37 -0
  92. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +105 -0
  93. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -0
  94. package/dest/rollup/checkpoint_rollup_public_inputs.js +105 -0
  95. package/dest/rollup/checkpoint_root_rollup.d.ts +117 -0
  96. package/dest/rollup/checkpoint_root_rollup.d.ts.map +1 -0
  97. package/dest/rollup/checkpoint_root_rollup.js +178 -0
  98. package/dest/rollup/epoch_constant_data.d.ts +19 -2
  99. package/dest/rollup/epoch_constant_data.d.ts.map +1 -1
  100. package/dest/rollup/epoch_constant_data.js +20 -7
  101. package/dest/rollup/index.d.ts +8 -5
  102. package/dest/rollup/index.d.ts.map +1 -1
  103. package/dest/rollup/index.js +8 -5
  104. package/dest/rollup/rollup_proof_data.d.ts +10 -0
  105. package/dest/rollup/rollup_proof_data.d.ts.map +1 -0
  106. package/dest/rollup/rollup_proof_data.js +1 -0
  107. package/dest/rollup/root_rollup.d.ts +26 -23
  108. package/dest/rollup/root_rollup.d.ts.map +1 -1
  109. package/dest/rollup/root_rollup.js +28 -39
  110. package/dest/stats/stats.d.ts +1 -1
  111. package/dest/stats/stats.d.ts.map +1 -1
  112. package/dest/tests/factories.d.ts +17 -41
  113. package/dest/tests/factories.d.ts.map +1 -1
  114. package/dest/tests/factories.js +76 -80
  115. package/dest/tests/mocks.d.ts +3 -2
  116. package/dest/tests/mocks.d.ts.map +1 -1
  117. package/dest/tests/mocks.js +3 -3
  118. package/dest/tx/block_header.d.ts +12 -13
  119. package/dest/tx/block_header.d.ts.map +1 -1
  120. package/dest/tx/block_header.js +16 -21
  121. package/dest/tx/global_variables.d.ts.map +1 -1
  122. package/dest/tx/global_variables.js +0 -1
  123. package/dest/tx/index.d.ts +0 -1
  124. package/dest/tx/index.d.ts.map +1 -1
  125. package/dest/tx/index.js +0 -1
  126. package/dest/tx/private_execution_result.d.ts +2 -2
  127. package/dest/tx/private_execution_result.d.ts.map +1 -1
  128. package/dest/tx/private_execution_result.js +3 -3
  129. package/dest/tx/tx_constant_data.d.ts +4 -4
  130. package/dest/tx/tx_constant_data.d.ts.map +1 -1
  131. package/dest/tx/tx_constant_data.js +6 -6
  132. package/dest/tx/tx_effect.d.ts +0 -3
  133. package/dest/tx/tx_effect.d.ts.map +1 -1
  134. package/dest/tx/tx_effect.js +2 -7
  135. package/dest/zkpassport/index.d.ts +3 -3
  136. package/dest/zkpassport/index.d.ts.map +1 -1
  137. package/dest/zkpassport/index.js +7 -7
  138. package/package.json +8 -8
  139. package/src/avm/avm.ts +22 -0
  140. package/src/avm/avm_circuit_public_inputs.ts +10 -0
  141. package/src/block/body.ts +23 -6
  142. package/src/block/index.ts +1 -0
  143. package/src/block/l2_block.ts +18 -8
  144. package/src/block/l2_block_code_to_purge.ts +30 -31
  145. package/src/block/l2_block_header.ts +232 -0
  146. package/src/block/l2_block_stream/l2_tips_memory_store.ts +1 -1
  147. package/src/block/test/l2_tips_store_test_suite.ts +1 -2
  148. package/src/interfaces/aztec-node.ts +8 -2
  149. package/src/interfaces/block-builder.ts +1 -6
  150. package/src/interfaces/epoch-prover.ts +34 -10
  151. package/src/interfaces/proving-job.ts +166 -51
  152. package/src/interfaces/pxe.ts +10 -1
  153. package/src/interfaces/server_circuit_prover.ts +65 -29
  154. package/src/interfaces/validator.ts +3 -2
  155. package/src/kernel/private_circuit_public_inputs.ts +5 -5
  156. package/src/kernel/private_context_inputs.ts +2 -2
  157. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +1 -1
  158. package/src/messaging/inbox_leaf.ts +5 -0
  159. package/src/p2p/consensus_payload.ts +8 -7
  160. package/src/proofs/proof_data.ts +1 -6
  161. package/src/proofs/proving_request_type.ts +8 -3
  162. package/src/rollup/base_or_merge_rollup_public_inputs.ts +1 -1
  163. package/src/rollup/base_rollup_hints.ts +9 -1
  164. package/src/rollup/block_constant_data.ts +13 -3
  165. package/src/rollup/block_merge_rollup.ts +13 -11
  166. package/src/rollup/block_rollup_public_inputs.ts +123 -0
  167. package/src/rollup/block_root_rollup.ts +209 -264
  168. package/src/rollup/checkpoint_constant_data.ts +84 -0
  169. package/src/{tx/proposed_block_header.ts → rollup/checkpoint_header.ts} +16 -17
  170. package/src/rollup/checkpoint_merge_rollup.ts +50 -0
  171. package/src/rollup/{block_root_or_block_merge_public_inputs.ts → checkpoint_rollup_public_inputs.ts} +26 -52
  172. package/src/rollup/checkpoint_root_rollup.ts +216 -0
  173. package/src/rollup/epoch_constant_data.ts +32 -8
  174. package/src/rollup/index.ts +8 -5
  175. package/src/rollup/rollup_proof_data.ts +12 -0
  176. package/src/rollup/root_rollup.ts +30 -41
  177. package/src/stats/stats.ts +8 -3
  178. package/src/tests/factories.ts +139 -135
  179. package/src/tests/mocks.ts +6 -13
  180. package/src/tx/block_header.ts +17 -32
  181. package/src/tx/global_variables.ts +0 -1
  182. package/src/tx/index.ts +0 -1
  183. package/src/tx/private_execution_result.ts +3 -3
  184. package/src/tx/tx_constant_data.ts +4 -4
  185. package/src/tx/tx_effect.ts +2 -7
  186. package/src/zkpassport/index.ts +6 -6
  187. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +0 -134
  188. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +0 -1
  189. package/dest/rollup/block_root_or_block_merge_public_inputs.js +0 -125
  190. package/dest/rollup/empty_block_root_rollup_inputs.d.ts +0 -51
  191. package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +0 -1
  192. package/dest/rollup/empty_block_root_rollup_inputs.js +0 -65
  193. package/dest/rollup/padding_block_root_rollup_inputs.d.ts +0 -20
  194. package/dest/rollup/padding_block_root_rollup_inputs.d.ts.map +0 -1
  195. package/dest/rollup/padding_block_root_rollup_inputs.js +0 -39
  196. package/dest/rollup/previous_rollup_block_data.d.ts +0 -47
  197. package/dest/rollup/previous_rollup_block_data.d.ts.map +0 -1
  198. package/dest/rollup/previous_rollup_block_data.js +0 -37
  199. package/dest/tx/proposed_block_header.d.ts.map +0 -1
  200. package/src/rollup/empty_block_root_rollup_inputs.ts +0 -80
  201. package/src/rollup/padding_block_root_rollup_inputs.ts +0 -47
  202. package/src/rollup/previous_rollup_block_data.ts +0 -48
@@ -1,380 +1,325 @@
1
- import { BlobAccumulatorPublicInputs, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
2
- import {
3
- ARCHIVE_HEIGHT,
4
- BLOBS_PER_BLOCK,
5
- FIELDS_PER_BLOB,
6
- L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
7
- NESTED_RECURSIVE_PROOF_LENGTH,
8
- } from '@aztec/constants';
9
- import { BLS12Point, Fr } from '@aztec/foundation/fields';
1
+ import { SpongeBlob } from '@aztec/blob-lib/types';
2
+ import { ARCHIVE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH } from '@aztec/constants';
3
+ import { Fr } from '@aztec/foundation/fields';
10
4
  import { bufferSchemaFor } from '@aztec/foundation/schemas';
11
- import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
12
- import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
5
+ import { BufferReader, type Tuple, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
13
6
  import type { FieldsOf } from '@aztec/foundation/types';
14
7
 
15
- import { RootParityInput } from '../parity/root_parity_input.js';
16
- import { BlockHeader } from '../tx/block_header.js';
17
- import { PreviousRollupData } from './previous_rollup_data.js';
8
+ import { ParityPublicInputs } from '../parity/parity_public_inputs.js';
9
+ import { ProofData } from '../proofs/proof_data.js';
10
+ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
11
+ import { StateReference } from '../tx/state_reference.js';
12
+ import type { UInt64 } from '../types/shared.js';
13
+ import { BaseOrMergeRollupPublicInputs } from './base_or_merge_rollup_public_inputs.js';
14
+ import { CheckpointConstantData } from './checkpoint_constant_data.js';
15
+ import type { RollupProofData, RootParityProofData } from './rollup_proof_data.js';
18
16
 
19
- export class BlockRootRollupData {
17
+ export class BlockRootFirstRollupPrivateInputs {
20
18
  constructor(
21
19
  /**
22
20
  * The original and converted roots of the L1 to L2 messages subtrees.
23
21
  */
24
- public l1ToL2Roots: RootParityInput<typeof NESTED_RECURSIVE_PROOF_LENGTH>,
22
+ public l1ToL2Roots: RootParityProofData,
25
23
  /**
26
- * Hint for inserting the new l1 to l2 message subtree.
24
+ * The previous rollup proof data from base or merge rollup circuits.
25
+ */
26
+ public previousRollups: [
27
+ RollupProofData<BaseOrMergeRollupPublicInputs>,
28
+ RollupProofData<BaseOrMergeRollupPublicInputs>,
29
+ ],
30
+ /**
31
+ * The l1 to l2 message tree snapshot immediately before this block.
27
32
  */
28
- public l1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
33
+ public previousL1ToL2: AppendOnlyTreeSnapshot,
29
34
  /**
30
- * Hint for checking the hash of previous_block_header is the last leaf of the previous archive.
35
+ * Hint for inserting the new l1 to l2 message subtree into `previousL1ToL2`.
31
36
  */
32
- public previousArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
37
+ public newL1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
33
38
  /**
34
39
  * Hint for inserting the new block hash to the last archive.
35
40
  */
36
41
  public newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
42
+ ) {}
43
+
44
+ static from(fields: FieldsOf<BlockRootFirstRollupPrivateInputs>) {
45
+ return new BlockRootFirstRollupPrivateInputs(...BlockRootFirstRollupPrivateInputs.getFields(fields));
46
+ }
47
+
48
+ static getFields(fields: FieldsOf<BlockRootFirstRollupPrivateInputs>) {
49
+ return [
50
+ fields.l1ToL2Roots,
51
+ fields.previousRollups,
52
+ fields.previousL1ToL2,
53
+ fields.newL1ToL2MessageSubtreeSiblingPath,
54
+ fields.newArchiveSiblingPath,
55
+ ] as const;
56
+ }
57
+
58
+ toBuffer() {
59
+ return serializeToBuffer(...BlockRootFirstRollupPrivateInputs.getFields(this));
60
+ }
61
+
62
+ static fromBuffer(buffer: Buffer | BufferReader) {
63
+ const reader = BufferReader.asReader(buffer);
64
+ return new BlockRootFirstRollupPrivateInputs(
65
+ ProofData.fromBuffer(reader, ParityPublicInputs),
66
+ [
67
+ ProofData.fromBuffer(reader, BaseOrMergeRollupPublicInputs),
68
+ ProofData.fromBuffer(reader, BaseOrMergeRollupPublicInputs),
69
+ ],
70
+ AppendOnlyTreeSnapshot.fromBuffer(reader),
71
+ reader.readArray(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, Fr),
72
+ reader.readArray(ARCHIVE_HEIGHT, Fr),
73
+ );
74
+ }
75
+
76
+ toJSON() {
77
+ return this.toBuffer();
78
+ }
79
+
80
+ static get schema() {
81
+ return bufferSchemaFor(BlockRootFirstRollupPrivateInputs);
82
+ }
83
+ }
84
+
85
+ export class BlockRootSingleTxFirstRollupPrivateInputs {
86
+ constructor(
37
87
  /**
38
- * The header of the previous block.
88
+ * The original and converted roots of the L1 to L2 messages subtrees.
39
89
  */
40
- public previousBlockHeader: BlockHeader,
90
+ public l1ToL2Roots: RootParityProofData,
41
91
  /**
42
- * The current blob accumulation state across the epoch.
92
+ * The previous rollup proof data from base or merge rollup circuits.
43
93
  */
44
- public startBlobAccumulator: BlobAccumulatorPublicInputs,
94
+ public previousRollup: RollupProofData<BaseOrMergeRollupPublicInputs>,
45
95
  /**
46
- * Finalized challenges z and gamma for performing blob batching. Shared value across the epoch.
96
+ * The l1 to l2 message tree snapshot immediately before this block.
47
97
  */
48
- public finalBlobChallenges: FinalBlobBatchingChallenges,
98
+ public previousL1ToL2: AppendOnlyTreeSnapshot,
49
99
  /**
50
- * Identifier of the prover.
100
+ * Hint for inserting the new l1 to l2 message subtree.
51
101
  */
52
- public proverId: Fr,
102
+ public newL1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
103
+ /**
104
+ * Hint for inserting the new block hash to the last archive.
105
+ */
106
+ public newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
53
107
  ) {}
54
108
 
55
- /**
56
- * Serializes the inputs to a buffer.
57
- * @returns - The inputs serialized to a buffer.
58
- */
59
- toBuffer() {
60
- return serializeToBuffer(...BlockRootRollupData.getFields(this));
61
- }
62
-
63
- /**
64
- * Serializes the inputs to a hex string.
65
- * @returns The instance serialized to a hex string.
66
- */
67
- toString() {
68
- return bufferToHex(this.toBuffer());
69
- }
70
-
71
- /**
72
- * Creates a new instance from fields.
73
- * @param fields - Fields to create the instance from.
74
- * @returns A new RootRollupInputs instance.
75
- */
76
- static from(fields: FieldsOf<BlockRootRollupData>): BlockRootRollupData {
77
- return new BlockRootRollupData(...BlockRootRollupData.getFields(fields));
109
+ static from(fields: FieldsOf<BlockRootSingleTxFirstRollupPrivateInputs>) {
110
+ return new BlockRootSingleTxFirstRollupPrivateInputs(
111
+ ...BlockRootSingleTxFirstRollupPrivateInputs.getFields(fields),
112
+ );
78
113
  }
79
114
 
80
- /**
81
- * Extracts fields from an instance.
82
- * @param fields - Fields to create the instance from.
83
- * @returns An array of fields.
84
- */
85
- static getFields(fields: FieldsOf<BlockRootRollupData>) {
115
+ static getFields(fields: FieldsOf<BlockRootSingleTxFirstRollupPrivateInputs>) {
86
116
  return [
87
117
  fields.l1ToL2Roots,
88
- fields.l1ToL2MessageSubtreeSiblingPath,
89
- fields.previousArchiveSiblingPath,
118
+ fields.previousRollup,
119
+ fields.previousL1ToL2,
120
+ fields.newL1ToL2MessageSubtreeSiblingPath,
90
121
  fields.newArchiveSiblingPath,
91
- fields.previousBlockHeader,
92
- fields.startBlobAccumulator,
93
- fields.finalBlobChallenges,
94
- fields.proverId,
95
122
  ] as const;
96
123
  }
97
124
 
98
- /**
99
- * Deserializes the inputs from a buffer.
100
- * @param buffer - A buffer to deserialize from.
101
- * @returns A new RootRollupInputs instance.
102
- */
103
- static fromBuffer(buffer: Buffer | BufferReader): BlockRootRollupData {
125
+ toBuffer() {
126
+ return serializeToBuffer(...BlockRootSingleTxFirstRollupPrivateInputs.getFields(this));
127
+ }
128
+
129
+ static fromBuffer(buffer: Buffer | BufferReader) {
104
130
  const reader = BufferReader.asReader(buffer);
105
- return new BlockRootRollupData(
106
- RootParityInput.fromBuffer(reader, NESTED_RECURSIVE_PROOF_LENGTH),
131
+ return new BlockRootSingleTxFirstRollupPrivateInputs(
132
+ ProofData.fromBuffer(reader, ParityPublicInputs),
133
+ ProofData.fromBuffer(reader, BaseOrMergeRollupPublicInputs),
134
+ AppendOnlyTreeSnapshot.fromBuffer(reader),
107
135
  reader.readArray(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, Fr),
108
136
  reader.readArray(ARCHIVE_HEIGHT, Fr),
109
- reader.readArray(ARCHIVE_HEIGHT, Fr),
110
- BlockHeader.fromBuffer(reader),
111
- reader.readObject(BlobAccumulatorPublicInputs),
112
- reader.readObject(FinalBlobBatchingChallenges),
113
- Fr.fromBuffer(reader),
114
137
  );
115
138
  }
116
139
 
117
- /**
118
- * Deserializes the inputs from a hex string.
119
- * @param str - A hex string to deserialize from.
120
- * @returns A new RootRollupInputs instance.
121
- */
122
- static fromString(str: string) {
123
- return BlockRootRollupData.fromBuffer(hexToBuffer(str));
124
- }
125
-
126
- /** Returns a buffer representation for JSON serialization. */
127
140
  toJSON() {
128
141
  return this.toBuffer();
129
142
  }
130
143
 
131
- /** Creates an instance from a hex string. */
132
144
  static get schema() {
133
- return bufferSchemaFor(BlockRootRollupData);
145
+ return bufferSchemaFor(BlockRootSingleTxFirstRollupPrivateInputs);
134
146
  }
135
147
  }
136
148
 
137
- export class BlockRootRollupBlobData {
149
+ export class BlockRootEmptyTxFirstRollupPrivateInputs {
138
150
  constructor(
139
151
  /**
140
- * Flat list of all tx effects which will be added to the blob.
141
- * Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
142
- * Tuple<Fr, FIELDS_PER_BLOB * BLOBS_PER_BLOCK>
152
+ * The original and converted roots of the L1 to L2 messages subtrees.
143
153
  */
144
- public blobFields: Fr[],
154
+ public l1ToL2Roots: RootParityProofData,
145
155
  /**
146
- * KZG commitments representing the blob (precomputed in ts, injected to use inside circuit).
156
+ * The archive after applying the previous block.
147
157
  */
148
- public blobCommitments: Tuple<BLS12Point, typeof BLOBS_PER_BLOCK>,
158
+ public previousArchive: AppendOnlyTreeSnapshot,
149
159
  /**
150
- * The hash of eth blob hashes for this block
151
- * See yarn-project/foundation/src/blob/index.ts or body.ts for calculation
160
+ * The state reference of the previous block.
152
161
  */
153
- public blobsHash: Fr,
162
+ public previousState: StateReference,
163
+ /**
164
+ * The constants of the checkpoint.
165
+ */
166
+ public constants: CheckpointConstantData,
167
+ /**
168
+ * The start sponge blob of this block. No data has been absorbed into it yet, since it's the first block. But the
169
+ * number of expected fields must be set to the total number of fields in the entire checkpoint.
170
+ */
171
+ public startSpongeBlob: SpongeBlob,
172
+ /**
173
+ * The timestamp of this block.
174
+ */
175
+ public timestamp: UInt64,
176
+ /**
177
+ * Hint for inserting the new l1 to l2 message subtree.
178
+ */
179
+ public newL1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
180
+ /**
181
+ * Hint for inserting the new block hash to the last archive.
182
+ */
183
+ public newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
154
184
  ) {}
155
185
 
156
- /**
157
- * Serializes the inputs to a buffer.
158
- * @returns - The inputs serialized to a buffer.
159
- */
160
- toBuffer() {
161
- return serializeToBuffer(...BlockRootRollupBlobData.getFields(this));
186
+ static from(fields: FieldsOf<BlockRootEmptyTxFirstRollupPrivateInputs>) {
187
+ return new BlockRootEmptyTxFirstRollupPrivateInputs(...BlockRootEmptyTxFirstRollupPrivateInputs.getFields(fields));
162
188
  }
163
189
 
164
- /**
165
- * Serializes the inputs to a hex string.
166
- * @returns The instance serialized to a hex string.
167
- */
168
- toString() {
169
- return bufferToHex(this.toBuffer());
170
- }
171
-
172
- /**
173
- * Creates a new instance from fields.
174
- * @param fields - Fields to create the instance from.
175
- * @returns A new RootRollupInputs instance.
176
- */
177
- static from(fields: FieldsOf<BlockRootRollupBlobData>): BlockRootRollupBlobData {
178
- return new BlockRootRollupBlobData(...BlockRootRollupBlobData.getFields(fields));
179
- }
180
-
181
- /**
182
- * Extracts fields from an instance.
183
- * @param fields - Fields to create the instance from.
184
- * @returns An array of fields.
185
- */
186
- static getFields(fields: FieldsOf<BlockRootRollupBlobData>) {
187
- return [fields.blobFields, fields.blobCommitments, fields.blobsHash] as const;
190
+ static getFields(fields: FieldsOf<BlockRootEmptyTxFirstRollupPrivateInputs>) {
191
+ return [
192
+ fields.l1ToL2Roots,
193
+ fields.previousArchive,
194
+ fields.previousState,
195
+ fields.constants,
196
+ fields.startSpongeBlob,
197
+ fields.timestamp,
198
+ fields.newL1ToL2MessageSubtreeSiblingPath,
199
+ fields.newArchiveSiblingPath,
200
+ ] as const;
188
201
  }
189
202
 
190
- /**
191
- * Deserializes the inputs from a buffer.
192
- * @param buffer - A buffer to deserialize from.
193
- * @returns A new RootRollupInputs instance.
194
- */
195
- static fromBuffer(buffer: Buffer | BufferReader): BlockRootRollupBlobData {
203
+ toBuffer() {
204
+ return serializeToBuffer([
205
+ this.l1ToL2Roots,
206
+ this.previousArchive,
207
+ this.previousState,
208
+ this.constants,
209
+ this.startSpongeBlob,
210
+ bigintToUInt64BE(this.timestamp),
211
+ this.newL1ToL2MessageSubtreeSiblingPath,
212
+ this.newArchiveSiblingPath,
213
+ ]);
214
+ }
215
+
216
+ static fromBuffer(buffer: Buffer | BufferReader) {
196
217
  const reader = BufferReader.asReader(buffer);
197
- return new BlockRootRollupBlobData(
198
- // Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
199
- // reader.readArray(FIELDS_PER_BLOB, Fr),
200
- Array.from({ length: FIELDS_PER_BLOB * BLOBS_PER_BLOCK }, () => Fr.fromBuffer(reader)),
201
- reader.readArray(BLOBS_PER_BLOCK, BLS12Point),
202
- Fr.fromBuffer(reader),
218
+ return new BlockRootEmptyTxFirstRollupPrivateInputs(
219
+ ProofData.fromBuffer(reader, ParityPublicInputs),
220
+ AppendOnlyTreeSnapshot.fromBuffer(reader),
221
+ StateReference.fromBuffer(reader),
222
+ CheckpointConstantData.fromBuffer(reader),
223
+ SpongeBlob.fromBuffer(reader),
224
+ reader.readUInt64(),
225
+ reader.readArray(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, Fr),
226
+ reader.readArray(ARCHIVE_HEIGHT, Fr),
203
227
  );
204
228
  }
205
229
 
206
- /**
207
- * Deserializes the inputs from a hex string.
208
- * @param str - A hex string to deserialize from.
209
- * @returns A new RootRollupInputs instance.
210
- */
211
- static fromString(str: string) {
212
- return BlockRootRollupBlobData.fromBuffer(hexToBuffer(str));
213
- }
214
-
215
- /** Returns a buffer representation for JSON serialization. */
216
230
  toJSON() {
217
231
  return this.toBuffer();
218
232
  }
219
233
 
220
- /** Creates an instance from a hex string. */
221
234
  static get schema() {
222
- return bufferSchemaFor(BlockRootRollupBlobData);
235
+ return bufferSchemaFor(BlockRootEmptyTxFirstRollupPrivateInputs);
223
236
  }
224
237
  }
225
238
 
226
- /**
227
- * Represents inputs of the block root rollup circuit.
228
- */
229
- export class BlockRootRollupInputs {
239
+ export class BlockRootRollupPrivateInputs {
230
240
  constructor(
231
241
  /**
232
- * The previous rollup data from 2 merge or base rollup circuits.
242
+ * The previous rollup proof data from base or merge rollup circuits.
243
+ */
244
+ public previousRollups: [
245
+ RollupProofData<BaseOrMergeRollupPublicInputs>,
246
+ RollupProofData<BaseOrMergeRollupPublicInputs>,
247
+ ],
248
+ /**
249
+ * Hint for inserting the new block hash to the last archive.
233
250
  */
234
- public previousRollupData: [PreviousRollupData, PreviousRollupData],
235
- public data: BlockRootRollupData,
236
- public blobData: BlockRootRollupBlobData,
251
+ public newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
237
252
  ) {}
238
253
 
239
- /**
240
- * Serializes the inputs to a buffer.
241
- * @returns - The inputs serialized to a buffer.
242
- */
243
- toBuffer() {
244
- return serializeToBuffer(...BlockRootRollupInputs.getFields(this));
254
+ static from(fields: FieldsOf<BlockRootRollupPrivateInputs>) {
255
+ return new BlockRootRollupPrivateInputs(...BlockRootRollupPrivateInputs.getFields(fields));
245
256
  }
246
257
 
247
- /**
248
- * Serializes the inputs to a hex string.
249
- * @returns The instance serialized to a hex string.
250
- */
251
- toString() {
252
- return bufferToHex(this.toBuffer());
258
+ static getFields(fields: FieldsOf<BlockRootRollupPrivateInputs>) {
259
+ return [fields.previousRollups, fields.newArchiveSiblingPath] as const;
253
260
  }
254
261
 
255
- /**
256
- * Creates a new instance from fields.
257
- * @param fields - Fields to create the instance from.
258
- * @returns A new RootRollupInputs instance.
259
- */
260
- static from(fields: FieldsOf<BlockRootRollupInputs>): BlockRootRollupInputs {
261
- return new BlockRootRollupInputs(...BlockRootRollupInputs.getFields(fields));
262
- }
263
-
264
- /**
265
- * Extracts fields from an instance.
266
- * @param fields - Fields to create the instance from.
267
- * @returns An array of fields.
268
- */
269
- static getFields(fields: FieldsOf<BlockRootRollupInputs>) {
270
- return [fields.previousRollupData, fields.data, fields.blobData] as const;
262
+ toBuffer() {
263
+ return serializeToBuffer(...BlockRootRollupPrivateInputs.getFields(this));
271
264
  }
272
265
 
273
- /**
274
- * Deserializes the inputs from a buffer.
275
- * @param buffer - A buffer to deserialize from.
276
- * @returns A new RootRollupInputs instance.
277
- */
278
- static fromBuffer(buffer: Buffer | BufferReader): BlockRootRollupInputs {
266
+ static fromBuffer(buffer: Buffer | BufferReader) {
279
267
  const reader = BufferReader.asReader(buffer);
280
- return new BlockRootRollupInputs(
281
- [reader.readObject(PreviousRollupData), reader.readObject(PreviousRollupData)],
282
- reader.readObject(BlockRootRollupData),
283
- reader.readObject(BlockRootRollupBlobData),
268
+ return new BlockRootRollupPrivateInputs(
269
+ [
270
+ ProofData.fromBuffer(reader, BaseOrMergeRollupPublicInputs),
271
+ ProofData.fromBuffer(reader, BaseOrMergeRollupPublicInputs),
272
+ ],
273
+ reader.readArray(ARCHIVE_HEIGHT, Fr),
284
274
  );
285
275
  }
286
276
 
287
- /**
288
- * Deserializes the inputs from a hex string.
289
- * @param str - A hex string to deserialize from.
290
- * @returns A new RootRollupInputs instance.
291
- */
292
- static fromString(str: string) {
293
- return BlockRootRollupInputs.fromBuffer(hexToBuffer(str));
294
- }
295
-
296
- /** Returns a buffer representation for JSON serialization. */
297
277
  toJSON() {
298
278
  return this.toBuffer();
299
279
  }
300
280
 
301
- /** Creates an instance from a hex string. */
302
281
  static get schema() {
303
- return bufferSchemaFor(BlockRootRollupInputs);
282
+ return bufferSchemaFor(BlockRootRollupPrivateInputs);
304
283
  }
305
284
  }
306
285
 
307
- export class SingleTxBlockRootRollupInputs {
286
+ export class BlockRootSingleTxRollupPrivateInputs {
308
287
  constructor(
309
- public previousRollupData: [PreviousRollupData],
310
- public data: BlockRootRollupData,
311
- public blobData: BlockRootRollupBlobData,
288
+ /**
289
+ * The previous rollup proof data from base or merge rollup circuits.
290
+ */
291
+ public previousRollup: RollupProofData<BaseOrMergeRollupPublicInputs>,
292
+ /**
293
+ * Hint for inserting the new block hash to the last archive.
294
+ */
295
+ public newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
312
296
  ) {}
313
297
 
314
- /**
315
- * Serializes the inputs to a buffer.
316
- * @returns - The inputs serialized to a buffer.
317
- */
318
- toBuffer() {
319
- return serializeToBuffer(...SingleTxBlockRootRollupInputs.getFields(this));
320
- }
321
-
322
- /**
323
- * Serializes the inputs to a hex string.
324
- * @returns The instance serialized to a hex string.
325
- */
326
- toString() {
327
- return bufferToHex(this.toBuffer());
298
+ static from(fields: FieldsOf<BlockRootSingleTxRollupPrivateInputs>) {
299
+ return new BlockRootSingleTxRollupPrivateInputs(...BlockRootSingleTxRollupPrivateInputs.getFields(fields));
328
300
  }
329
301
 
330
- /**
331
- * Creates a new instance from fields.
332
- * @param fields - Fields to create the instance from.
333
- * @returns A new RootRollupInputs instance.
334
- */
335
- static from(fields: FieldsOf<SingleTxBlockRootRollupInputs>): SingleTxBlockRootRollupInputs {
336
- return new SingleTxBlockRootRollupInputs(...SingleTxBlockRootRollupInputs.getFields(fields));
302
+ static getFields(fields: FieldsOf<BlockRootSingleTxRollupPrivateInputs>) {
303
+ return [fields.previousRollup, fields.newArchiveSiblingPath] as const;
337
304
  }
338
305
 
339
- /**
340
- * Extracts fields from an instance.
341
- * @param fields - Fields to create the instance from.
342
- * @returns An array of fields.
343
- */
344
- static getFields(fields: FieldsOf<SingleTxBlockRootRollupInputs>) {
345
- return [fields.previousRollupData, fields.data, fields.blobData] as const;
306
+ toBuffer() {
307
+ return serializeToBuffer(...BlockRootSingleTxRollupPrivateInputs.getFields(this));
346
308
  }
347
309
 
348
- /**
349
- * Deserializes the inputs from a buffer.
350
- * @param buffer - A buffer to deserialize from.
351
- * @returns A new RootRollupInputs instance.
352
- */
353
- static fromBuffer(buffer: Buffer | BufferReader): SingleTxBlockRootRollupInputs {
310
+ static fromBuffer(buffer: Buffer | BufferReader) {
354
311
  const reader = BufferReader.asReader(buffer);
355
- return new SingleTxBlockRootRollupInputs(
356
- [reader.readObject(PreviousRollupData)],
357
- reader.readObject(BlockRootRollupData),
358
- reader.readObject(BlockRootRollupBlobData),
312
+ return new BlockRootSingleTxRollupPrivateInputs(
313
+ ProofData.fromBuffer(reader, BaseOrMergeRollupPublicInputs),
314
+ reader.readArray(ARCHIVE_HEIGHT, Fr),
359
315
  );
360
316
  }
361
317
 
362
- /**
363
- * Deserializes the inputs from a hex string.
364
- * @param str - A hex string to deserialize from.
365
- * @returns A new RootRollupInputs instance.
366
- */
367
- static fromString(str: string) {
368
- return SingleTxBlockRootRollupInputs.fromBuffer(hexToBuffer(str));
369
- }
370
-
371
- /** Returns a buffer representation for JSON serialization. */
372
318
  toJSON() {
373
319
  return this.toBuffer();
374
320
  }
375
321
 
376
- /** Creates an instance from a hex string. */
377
322
  static get schema() {
378
- return bufferSchemaFor(SingleTxBlockRootRollupInputs);
323
+ return bufferSchemaFor(BlockRootSingleTxRollupPrivateInputs);
379
324
  }
380
325
  }
@@ -0,0 +1,84 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
+ import type { FieldsOf } from '@aztec/foundation/types';
5
+
6
+ import { AztecAddress } from '../aztec-address/index.js';
7
+ import { GasFees } from '../gas/gas_fees.js';
8
+
9
+ /**
10
+ * Constants that are the same for the entire checkpoint.
11
+ */
12
+ export class CheckpointConstantData {
13
+ constructor(
14
+ /** ChainId of the rollup. */
15
+ public chainId: Fr,
16
+ /** Version of the rollup. */
17
+ public version: Fr,
18
+ /** Root of the verification key tree. */
19
+ public vkTreeRoot: Fr,
20
+ /** Root of the protocol contract tree. */
21
+ public protocolContractTreeRoot: Fr,
22
+ /** Identifier of the prover. */
23
+ public proverId: Fr,
24
+ /** Slot number of the checkpoint. */
25
+ public slotNumber: Fr,
26
+ /** Coinbase address of the rollup. */
27
+ public coinbase: EthAddress,
28
+ /** Address to receive fees. */
29
+ public feeRecipient: AztecAddress,
30
+ /** Global gas fees for this checkpoint. */
31
+ public gasFees: GasFees,
32
+ ) {}
33
+
34
+ static from(fields: FieldsOf<CheckpointConstantData>) {
35
+ return new CheckpointConstantData(...CheckpointConstantData.getFields(fields));
36
+ }
37
+
38
+ static getFields(fields: FieldsOf<CheckpointConstantData>) {
39
+ return [
40
+ fields.chainId,
41
+ fields.version,
42
+ fields.vkTreeRoot,
43
+ fields.protocolContractTreeRoot,
44
+ fields.proverId,
45
+ fields.slotNumber,
46
+ fields.coinbase,
47
+ fields.feeRecipient,
48
+ fields.gasFees,
49
+ ] as const;
50
+ }
51
+
52
+ static empty() {
53
+ return new CheckpointConstantData(
54
+ Fr.ZERO,
55
+ Fr.ZERO,
56
+ Fr.ZERO,
57
+ Fr.ZERO,
58
+ Fr.ZERO,
59
+ Fr.ZERO,
60
+ EthAddress.ZERO,
61
+ AztecAddress.ZERO,
62
+ GasFees.empty(),
63
+ );
64
+ }
65
+
66
+ toBuffer() {
67
+ return serializeToBuffer(...CheckpointConstantData.getFields(this));
68
+ }
69
+
70
+ static fromBuffer(buffer: Buffer | BufferReader) {
71
+ const reader = BufferReader.asReader(buffer);
72
+ return new CheckpointConstantData(
73
+ Fr.fromBuffer(reader),
74
+ Fr.fromBuffer(reader),
75
+ Fr.fromBuffer(reader),
76
+ Fr.fromBuffer(reader),
77
+ Fr.fromBuffer(reader),
78
+ Fr.fromBuffer(reader),
79
+ reader.readObject(EthAddress),
80
+ reader.readObject(AztecAddress),
81
+ reader.readObject(GasFees),
82
+ );
83
+ }
84
+ }