@aztec/stdlib 3.0.0-nightly.20250917 → 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 (184) hide show
  1. package/dest/avm/avm.d.ts +6 -0
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm_circuit_public_inputs.d.ts +6 -1
  4. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  5. package/dest/avm/avm_circuit_public_inputs.js +11 -6
  6. package/dest/avm/avm_proving_request.d.ts +7 -0
  7. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  8. package/dest/block/body.d.ts +4 -1
  9. package/dest/block/body.d.ts.map +1 -1
  10. package/dest/block/body.js +16 -5
  11. package/dest/block/index.d.ts +1 -0
  12. package/dest/block/index.d.ts.map +1 -1
  13. package/dest/block/index.js +1 -0
  14. package/dest/block/l2_block.d.ts +8 -5
  15. package/dest/block/l2_block.d.ts.map +1 -1
  16. package/dest/block/l2_block.js +14 -7
  17. package/dest/block/l2_block_code_to_purge.d.ts +3 -14
  18. package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
  19. package/dest/block/l2_block_code_to_purge.js +23 -13
  20. package/dest/block/l2_block_header.d.ts +100 -0
  21. package/dest/block/l2_block_header.d.ts.map +1 -0
  22. package/dest/block/l2_block_header.js +146 -0
  23. package/dest/block/l2_block_stream/l2_tips_memory_store.js +1 -1
  24. package/dest/block/published_l2_block.d.ts +2 -2
  25. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  26. package/dest/block/test/l2_tips_store_test_suite.js +1 -3
  27. package/dest/interfaces/block-builder.d.ts +1 -2
  28. package/dest/interfaces/block-builder.d.ts.map +1 -1
  29. package/dest/interfaces/epoch-prover.d.ts +25 -8
  30. package/dest/interfaces/epoch-prover.d.ts.map +1 -1
  31. package/dest/interfaces/proving-job.d.ts +170 -61
  32. package/dest/interfaces/proving-job.d.ts.map +1 -1
  33. package/dest/interfaces/proving-job.js +101 -39
  34. package/dest/interfaces/server_circuit_prover.d.ts +19 -16
  35. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  36. package/dest/interfaces/validator.d.ts +3 -2
  37. package/dest/interfaces/validator.d.ts.map +1 -1
  38. package/dest/kernel/private_circuit_public_inputs.d.ts +4 -4
  39. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  40. package/dest/kernel/private_circuit_public_inputs.js +7 -7
  41. package/dest/kernel/private_context_inputs.d.ts +2 -2
  42. package/dest/kernel/private_context_inputs.d.ts.map +1 -1
  43. package/dest/kernel/private_context_inputs.js +4 -4
  44. package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +1 -1
  45. package/dest/p2p/consensus_payload.d.ts +7 -6
  46. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  47. package/dest/p2p/consensus_payload.js +7 -6
  48. package/dest/parity/root_parity_input.d.ts +1 -1
  49. package/dest/proofs/proof_data.d.ts +1 -1
  50. package/dest/proofs/proof_data.d.ts.map +1 -1
  51. package/dest/proofs/proof_data.js +2 -2
  52. package/dest/proofs/proving_request_type.d.ts +13 -8
  53. package/dest/proofs/proving_request_type.d.ts.map +1 -1
  54. package/dest/proofs/proving_request_type.js +13 -8
  55. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +1 -1
  56. package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
  57. package/dest/rollup/base_or_merge_rollup_public_inputs.js +1 -1
  58. package/dest/rollup/base_rollup_hints.d.ts +12 -3
  59. package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
  60. package/dest/rollup/base_rollup_hints.js +11 -5
  61. package/dest/rollup/block_constant_data.d.ts +20 -6
  62. package/dest/rollup/block_constant_data.d.ts.map +1 -1
  63. package/dest/rollup/block_constant_data.js +15 -7
  64. package/dest/rollup/block_merge_rollup.d.ts +10 -9
  65. package/dest/rollup/block_merge_rollup.d.ts.map +1 -1
  66. package/dest/rollup/block_merge_rollup.js +14 -13
  67. package/dest/rollup/block_rollup_public_inputs.d.ts +124 -0
  68. package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -0
  69. package/dest/rollup/block_rollup_public_inputs.js +85 -0
  70. package/dest/rollup/block_root_rollup.d.ts +148 -184
  71. package/dest/rollup/block_root_rollup.d.ts.map +1 -1
  72. package/dest/rollup/block_root_rollup.js +211 -260
  73. package/dest/rollup/checkpoint_constant_data.d.ts +54 -0
  74. package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -0
  75. package/dest/rollup/checkpoint_constant_data.js +55 -0
  76. package/dest/{tx/proposed_block_header.d.ts → rollup/checkpoint_header.d.ts} +11 -12
  77. package/dest/rollup/checkpoint_header.d.ts.map +1 -0
  78. package/dest/{tx/proposed_block_header.js → rollup/checkpoint_header.js} +9 -9
  79. package/dest/rollup/checkpoint_merge_rollup.d.ts +30 -0
  80. package/dest/rollup/checkpoint_merge_rollup.d.ts.map +1 -0
  81. package/dest/rollup/checkpoint_merge_rollup.js +37 -0
  82. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +105 -0
  83. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -0
  84. package/dest/rollup/checkpoint_rollup_public_inputs.js +105 -0
  85. package/dest/rollup/checkpoint_root_rollup.d.ts +117 -0
  86. package/dest/rollup/checkpoint_root_rollup.d.ts.map +1 -0
  87. package/dest/rollup/checkpoint_root_rollup.js +178 -0
  88. package/dest/rollup/epoch_constant_data.d.ts +19 -2
  89. package/dest/rollup/epoch_constant_data.d.ts.map +1 -1
  90. package/dest/rollup/epoch_constant_data.js +20 -7
  91. package/dest/rollup/index.d.ts +8 -5
  92. package/dest/rollup/index.d.ts.map +1 -1
  93. package/dest/rollup/index.js +8 -5
  94. package/dest/rollup/rollup_proof_data.d.ts +10 -0
  95. package/dest/rollup/rollup_proof_data.d.ts.map +1 -0
  96. package/dest/rollup/rollup_proof_data.js +1 -0
  97. package/dest/rollup/root_rollup.d.ts +26 -23
  98. package/dest/rollup/root_rollup.d.ts.map +1 -1
  99. package/dest/rollup/root_rollup.js +28 -39
  100. package/dest/stats/stats.d.ts +1 -1
  101. package/dest/stats/stats.d.ts.map +1 -1
  102. package/dest/tests/factories.d.ts +15 -40
  103. package/dest/tests/factories.d.ts.map +1 -1
  104. package/dest/tests/factories.js +70 -78
  105. package/dest/tests/mocks.d.ts +3 -2
  106. package/dest/tests/mocks.d.ts.map +1 -1
  107. package/dest/tests/mocks.js +3 -3
  108. package/dest/tx/block_header.d.ts +12 -13
  109. package/dest/tx/block_header.d.ts.map +1 -1
  110. package/dest/tx/block_header.js +16 -21
  111. package/dest/tx/global_variables.d.ts.map +1 -1
  112. package/dest/tx/global_variables.js +0 -1
  113. package/dest/tx/index.d.ts +0 -1
  114. package/dest/tx/index.d.ts.map +1 -1
  115. package/dest/tx/index.js +0 -1
  116. package/dest/tx/private_execution_result.d.ts +2 -2
  117. package/dest/tx/private_execution_result.d.ts.map +1 -1
  118. package/dest/tx/private_execution_result.js +3 -3
  119. package/dest/tx/tx_constant_data.d.ts +4 -4
  120. package/dest/tx/tx_constant_data.d.ts.map +1 -1
  121. package/dest/tx/tx_constant_data.js +6 -6
  122. package/dest/tx/tx_effect.d.ts +0 -3
  123. package/dest/tx/tx_effect.d.ts.map +1 -1
  124. package/dest/tx/tx_effect.js +2 -7
  125. package/package.json +8 -8
  126. package/src/avm/avm_circuit_public_inputs.ts +10 -0
  127. package/src/block/body.ts +23 -6
  128. package/src/block/index.ts +1 -0
  129. package/src/block/l2_block.ts +18 -8
  130. package/src/block/l2_block_code_to_purge.ts +30 -31
  131. package/src/block/l2_block_header.ts +232 -0
  132. package/src/block/l2_block_stream/l2_tips_memory_store.ts +1 -1
  133. package/src/block/test/l2_tips_store_test_suite.ts +1 -2
  134. package/src/interfaces/block-builder.ts +1 -6
  135. package/src/interfaces/epoch-prover.ts +34 -10
  136. package/src/interfaces/proving-job.ts +166 -51
  137. package/src/interfaces/server_circuit_prover.ts +65 -29
  138. package/src/interfaces/validator.ts +3 -2
  139. package/src/kernel/private_circuit_public_inputs.ts +5 -5
  140. package/src/kernel/private_context_inputs.ts +2 -2
  141. package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +1 -1
  142. package/src/p2p/consensus_payload.ts +8 -7
  143. package/src/proofs/proof_data.ts +1 -6
  144. package/src/proofs/proving_request_type.ts +8 -3
  145. package/src/rollup/base_or_merge_rollup_public_inputs.ts +1 -1
  146. package/src/rollup/base_rollup_hints.ts +9 -1
  147. package/src/rollup/block_constant_data.ts +13 -3
  148. package/src/rollup/block_merge_rollup.ts +13 -11
  149. package/src/rollup/block_rollup_public_inputs.ts +123 -0
  150. package/src/rollup/block_root_rollup.ts +209 -264
  151. package/src/rollup/checkpoint_constant_data.ts +84 -0
  152. package/src/{tx/proposed_block_header.ts → rollup/checkpoint_header.ts} +16 -17
  153. package/src/rollup/checkpoint_merge_rollup.ts +50 -0
  154. package/src/rollup/{block_root_or_block_merge_public_inputs.ts → checkpoint_rollup_public_inputs.ts} +26 -52
  155. package/src/rollup/checkpoint_root_rollup.ts +216 -0
  156. package/src/rollup/epoch_constant_data.ts +32 -8
  157. package/src/rollup/index.ts +8 -5
  158. package/src/rollup/rollup_proof_data.ts +12 -0
  159. package/src/rollup/root_rollup.ts +30 -41
  160. package/src/stats/stats.ts +8 -3
  161. package/src/tests/factories.ts +124 -135
  162. package/src/tests/mocks.ts +6 -13
  163. package/src/tx/block_header.ts +17 -32
  164. package/src/tx/global_variables.ts +0 -1
  165. package/src/tx/index.ts +0 -1
  166. package/src/tx/private_execution_result.ts +3 -3
  167. package/src/tx/tx_constant_data.ts +4 -4
  168. package/src/tx/tx_effect.ts +2 -7
  169. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +0 -134
  170. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +0 -1
  171. package/dest/rollup/block_root_or_block_merge_public_inputs.js +0 -125
  172. package/dest/rollup/empty_block_root_rollup_inputs.d.ts +0 -51
  173. package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +0 -1
  174. package/dest/rollup/empty_block_root_rollup_inputs.js +0 -65
  175. package/dest/rollup/padding_block_root_rollup_inputs.d.ts +0 -20
  176. package/dest/rollup/padding_block_root_rollup_inputs.d.ts.map +0 -1
  177. package/dest/rollup/padding_block_root_rollup_inputs.js +0 -39
  178. package/dest/rollup/previous_rollup_block_data.d.ts +0 -47
  179. package/dest/rollup/previous_rollup_block_data.d.ts.map +0 -1
  180. package/dest/rollup/previous_rollup_block_data.js +0 -37
  181. package/dest/tx/proposed_block_header.d.ts.map +0 -1
  182. package/src/rollup/empty_block_root_rollup_inputs.ts +0 -80
  183. package/src/rollup/padding_block_root_rollup_inputs.ts +0 -47
  184. package/src/rollup/previous_rollup_block_data.ts +0 -48
@@ -1,26 +1,35 @@
1
+ import { compact } from '@aztec/foundation/collection';
1
2
  import { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import { Fr } from '@aztec/foundation/fields';
4
+ import type { FieldsOf } from '@aztec/foundation/types';
3
5
 
4
6
  import { AztecAddress } from '../aztec-address/index.js';
5
7
  import { GasFees } from '../gas/gas_fees.js';
6
8
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
7
- import { BlockHeader } from '../tx/block_header.js';
8
9
  import { ContentCommitment } from '../tx/content_commitment.js';
9
10
  import { GlobalVariables } from '../tx/global_variables.js';
10
11
  import { PartialStateReference } from '../tx/partial_state_reference.js';
11
12
  import { StateReference } from '../tx/state_reference.js';
13
+ import { L2BlockHeader } from './l2_block_header.js';
12
14
 
13
- /**
14
- * Makes header.
15
- */
16
- export function makeHeader(seed = 0, blockNumber?: number, slotNumber?: number, inHash?: Fr): BlockHeader {
17
- return new BlockHeader(
15
+ export function makeL2BlockHeader(
16
+ seed = 0,
17
+ blockNumber?: number,
18
+ slotNumber?: number,
19
+ overrides: Partial<FieldsOf<L2BlockHeader>> = {},
20
+ inHash?: Fr,
21
+ ) {
22
+ return new L2BlockHeader(
18
23
  makeAppendOnlyTreeSnapshot(seed + 0x100),
19
- makeContentCommitment(seed + 0x200, inHash),
20
- makeStateReference(seed + 0x600),
21
- makeGlobalVariables((seed += 0x700), blockNumber, slotNumber ?? blockNumber),
24
+ overrides?.contentCommitment ?? makeContentCommitment(seed + 0x200, inHash),
25
+ overrides?.state ?? makeStateReference(seed + 0x600),
26
+ makeGlobalVariables((seed += 0x700), {
27
+ ...(blockNumber ? { blockNumber } : {}),
28
+ ...(slotNumber ? { slotNumber: new Fr(slotNumber) } : {}),
29
+ }),
22
30
  new Fr(seed + 0x800),
23
31
  new Fr(seed + 0x900),
32
+ new Fr(seed + 0xa00),
24
33
  );
25
34
  }
26
35
 
@@ -62,26 +71,16 @@ function makePartialStateReference(seed = 0): PartialStateReference {
62
71
  );
63
72
  }
64
73
 
65
- /**
66
- * Makes global variables.
67
- * @param seed - The seed to use for generating the global variables.
68
- * @param blockNumber - The block number to use for generating the global variables.
69
- * If blockNumber is undefined, it will be set to seed + 2.
70
- * @returns Global variables.
71
- */
72
- export function makeGlobalVariables(
73
- seed = 1,
74
- blockNumber: number | undefined = undefined,
75
- slotNumber: number | undefined = undefined,
76
- ): GlobalVariables {
77
- return new GlobalVariables(
78
- new Fr(seed),
79
- new Fr(seed + 1),
80
- blockNumber ?? seed + 2,
81
- new Fr(slotNumber ?? seed + 3),
82
- BigInt(seed + 4),
83
- EthAddress.fromField(new Fr(seed + 5)),
84
- AztecAddress.fromField(new Fr(seed + 6)),
85
- new GasFees(seed + 7, seed + 8),
86
- );
74
+ function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<GlobalVariables>> = {}): GlobalVariables {
75
+ return GlobalVariables.from({
76
+ chainId: new Fr(seed),
77
+ version: new Fr(seed + 1),
78
+ blockNumber: seed + 2,
79
+ slotNumber: new Fr(seed + 3),
80
+ timestamp: BigInt(seed + 4),
81
+ coinbase: EthAddress.fromField(new Fr(seed + 5)),
82
+ feeRecipient: AztecAddress.fromField(new Fr(seed + 6)),
83
+ gasFees: new GasFees(seed + 7, seed + 8),
84
+ ...compact(overrides),
85
+ });
87
86
  }
@@ -0,0 +1,232 @@
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { type ZodFor, schemas } from '@aztec/foundation/schemas';
3
+ import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
4
+ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
5
+ import type { FieldsOf } from '@aztec/foundation/types';
6
+
7
+ import { inspect } from 'util';
8
+ import { z } from 'zod';
9
+
10
+ import { CheckpointHeader } from '../rollup/checkpoint_header.js';
11
+ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
12
+ import { BlockHeader, ContentCommitment, GlobalVariables, StateReference } from '../tx/index.js';
13
+
14
+ /**
15
+ * TO BE DELETED
16
+ *
17
+ * A header of an L2 block combining the block header and the checkpoint header.
18
+ * This is a temporary workaround to avoid changing too many things before building in chunks is properly implemented.
19
+ * This works for now because we only have one block per checkpoint.
20
+ *
21
+ * @deprecated Use BlockHeader or CheckpointHeader instead.
22
+ */
23
+ export class L2BlockHeader {
24
+ constructor(
25
+ /** Snapshot of archive before the block is applied. */
26
+ public lastArchive: AppendOnlyTreeSnapshot,
27
+ /** Hash of the body of an L2 block. */
28
+ public contentCommitment: ContentCommitment,
29
+ /** State reference. */
30
+ public state: StateReference,
31
+ /** Global variables of an L2 block. */
32
+ public globalVariables: GlobalVariables,
33
+ /** Total fees in the block, computed by the root rollup circuit */
34
+ public totalFees: Fr,
35
+ /** Total mana used in the block, computed by the root rollup circuit */
36
+ public totalManaUsed: Fr,
37
+ /** Hash of the sponge blob of the block. */
38
+ public spongeBlobHash: Fr,
39
+ ) {}
40
+
41
+ static get schema(): ZodFor<L2BlockHeader> {
42
+ return z
43
+ .object({
44
+ lastArchive: AppendOnlyTreeSnapshot.schema,
45
+ contentCommitment: ContentCommitment.schema,
46
+ state: StateReference.schema,
47
+ globalVariables: GlobalVariables.schema,
48
+ totalFees: schemas.Fr,
49
+ totalManaUsed: schemas.Fr,
50
+ spongeBlobHash: schemas.Fr,
51
+ })
52
+ .transform(L2BlockHeader.from);
53
+ }
54
+
55
+ static getFields(fields: FieldsOf<L2BlockHeader>) {
56
+ return [
57
+ fields.lastArchive,
58
+ fields.contentCommitment,
59
+ fields.state,
60
+ fields.globalVariables,
61
+ fields.totalFees,
62
+ fields.totalManaUsed,
63
+ fields.spongeBlobHash,
64
+ ] as const;
65
+ }
66
+
67
+ static from(fields: FieldsOf<L2BlockHeader>) {
68
+ return new L2BlockHeader(...L2BlockHeader.getFields(fields));
69
+ }
70
+
71
+ getSlot() {
72
+ return this.globalVariables.slotNumber.toBigInt();
73
+ }
74
+
75
+ getBlockNumber() {
76
+ return this.globalVariables.blockNumber;
77
+ }
78
+
79
+ getSize() {
80
+ return (
81
+ this.lastArchive.getSize() +
82
+ this.contentCommitment.getSize() +
83
+ this.state.getSize() +
84
+ this.globalVariables.getSize() +
85
+ this.totalFees.size +
86
+ this.totalManaUsed.size +
87
+ this.spongeBlobHash.size
88
+ );
89
+ }
90
+
91
+ toBuffer() {
92
+ return serializeToBuffer(...L2BlockHeader.getFields(this));
93
+ }
94
+
95
+ toFields(): Fr[] {
96
+ return serializeToFields(...L2BlockHeader.getFields(this));
97
+ }
98
+
99
+ clone() {
100
+ return L2BlockHeader.fromBuffer(this.toBuffer());
101
+ }
102
+
103
+ static fromBuffer(buffer: Buffer | BufferReader) {
104
+ const reader = BufferReader.asReader(buffer);
105
+
106
+ return new L2BlockHeader(
107
+ reader.readObject(AppendOnlyTreeSnapshot),
108
+ reader.readObject(ContentCommitment),
109
+ reader.readObject(StateReference),
110
+ reader.readObject(GlobalVariables),
111
+ reader.readObject(Fr),
112
+ reader.readObject(Fr),
113
+ reader.readObject(Fr),
114
+ );
115
+ }
116
+
117
+ static fromFields(fields: Fr[] | FieldReader) {
118
+ const reader = FieldReader.asReader(fields);
119
+
120
+ return new L2BlockHeader(
121
+ AppendOnlyTreeSnapshot.fromFields(reader),
122
+ ContentCommitment.fromFields(reader),
123
+ StateReference.fromFields(reader),
124
+ GlobalVariables.fromFields(reader),
125
+ reader.readField(),
126
+ reader.readField(),
127
+ reader.readField(),
128
+ );
129
+ }
130
+
131
+ static empty(fields: Partial<FieldsOf<L2BlockHeader>> = {}) {
132
+ return L2BlockHeader.from({
133
+ lastArchive: AppendOnlyTreeSnapshot.empty(),
134
+ contentCommitment: ContentCommitment.empty(),
135
+ state: StateReference.empty(),
136
+ globalVariables: GlobalVariables.empty(),
137
+ totalFees: Fr.ZERO,
138
+ totalManaUsed: Fr.ZERO,
139
+ spongeBlobHash: Fr.ZERO,
140
+ ...fields,
141
+ });
142
+ }
143
+
144
+ isEmpty(): boolean {
145
+ return (
146
+ this.lastArchive.isEmpty() &&
147
+ this.contentCommitment.isEmpty() &&
148
+ this.state.isEmpty() &&
149
+ this.globalVariables.isEmpty() &&
150
+ this.totalFees.isZero() &&
151
+ this.totalManaUsed.isZero() &&
152
+ this.spongeBlobHash.isZero()
153
+ );
154
+ }
155
+
156
+ /**
157
+ * Serializes this instance into a string.
158
+ * @returns Encoded string.
159
+ */
160
+ public toString() {
161
+ return bufferToHex(this.toBuffer());
162
+ }
163
+
164
+ static fromString(str: string) {
165
+ return L2BlockHeader.fromBuffer(hexToBuffer(str));
166
+ }
167
+
168
+ toCheckpointHeader() {
169
+ return new CheckpointHeader(
170
+ this.lastArchive.root,
171
+ this.contentCommitment,
172
+ this.globalVariables.slotNumber,
173
+ this.globalVariables.timestamp,
174
+ this.globalVariables.coinbase,
175
+ this.globalVariables.feeRecipient,
176
+ this.globalVariables.gasFees,
177
+ this.totalManaUsed,
178
+ );
179
+ }
180
+
181
+ toBlockHeader() {
182
+ return new BlockHeader(
183
+ this.lastArchive,
184
+ this.state,
185
+ this.spongeBlobHash,
186
+ this.globalVariables,
187
+ this.totalFees,
188
+ this.totalManaUsed,
189
+ );
190
+ }
191
+
192
+ toInspect() {
193
+ return {
194
+ lastArchive: this.lastArchive.root.toString(),
195
+ contentCommitment: this.contentCommitment.toInspect(),
196
+ state: this.state.toInspect(),
197
+ globalVariables: this.globalVariables.toInspect(),
198
+ totalFees: this.totalFees.toBigInt(),
199
+ totalManaUsed: this.totalManaUsed.toBigInt(),
200
+ spongeBlobHash: this.spongeBlobHash.toString(),
201
+ };
202
+ }
203
+
204
+ [inspect.custom]() {
205
+ return `L2BlockHeader {
206
+ lastArchive: ${inspect(this.lastArchive)},
207
+ contentCommitment.blobsHash: ${inspect(this.contentCommitment.blobsHash)},
208
+ contentCommitment.inHash: ${inspect(this.contentCommitment.inHash)},
209
+ contentCommitment.outHash: ${inspect(this.contentCommitment.outHash)},
210
+ state.l1ToL2MessageTree: ${inspect(this.state.l1ToL2MessageTree)},
211
+ state.noteHashTree: ${inspect(this.state.partial.noteHashTree)},
212
+ state.nullifierTree: ${inspect(this.state.partial.nullifierTree)},
213
+ state.publicDataTree: ${inspect(this.state.partial.publicDataTree)},
214
+ globalVariables: ${inspect(this.globalVariables)},
215
+ totalFees: ${this.totalFees},
216
+ totalManaUsed: ${this.totalManaUsed},
217
+ spongeBlobHash: ${this.spongeBlobHash},
218
+ }`;
219
+ }
220
+
221
+ public equals(other: this): boolean {
222
+ return (
223
+ this.contentCommitment.equals(other.contentCommitment) &&
224
+ this.state.equals(other.state) &&
225
+ this.globalVariables.equals(other.globalVariables) &&
226
+ this.totalFees.equals(other.totalFees) &&
227
+ this.totalManaUsed.equals(other.totalManaUsed) &&
228
+ this.lastArchive.equals(other.lastArchive) &&
229
+ this.spongeBlobHash.equals(other.spongeBlobHash)
230
+ );
231
+ }
232
+ }
@@ -70,6 +70,6 @@ export class L2TipsMemoryStore implements L2BlockStreamEventHandler, L2BlockStre
70
70
  }
71
71
 
72
72
  protected computeBlockHash(block: L2Block) {
73
- return block.header.hash().then(hash => hash.toString());
73
+ return block.hash().then(hash => hash.toString());
74
74
  }
75
75
  }
@@ -1,7 +1,6 @@
1
1
  import { times } from '@aztec/foundation/collection';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { type L2Block, type L2BlockId, PublishedL2Block } from '@aztec/stdlib/block';
4
- import type { BlockHeader } from '@aztec/stdlib/tx';
5
4
 
6
5
  import { jestExpect as expect } from '@jest/expect';
7
6
 
@@ -16,7 +15,7 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
16
15
 
17
16
  const makeBlock = (number: number): PublishedL2Block =>
18
17
  PublishedL2Block.fromFields({
19
- block: { number, header: { hash: () => Promise.resolve(new Fr(number)) } as BlockHeader } as L2Block,
18
+ block: { number, hash: () => Promise.resolve(new Fr(number)) } as L2Block,
20
19
  l1: { blockNumber: BigInt(number), blockHash: `0x${number}`, timestamp: BigInt(number) },
21
20
  attestations: [],
22
21
  });
@@ -19,13 +19,8 @@ export interface IBlockFactory extends ProcessedTxHandler {
19
19
  * Prepares to build a new block. Updates the L1 to L2 message tree.
20
20
  * @param globalVariables - The global variables for this block.
21
21
  * @param l1ToL2Messages - The set of L1 to L2 messages to be included in this block.
22
- * @param previousBlockHeader - The header of the previous block.
23
22
  */
24
- startNewBlock(
25
- globalVariables: GlobalVariables,
26
- l1ToL2Messages: Fr[],
27
- previousBlockHeader: BlockHeader,
28
- ): Promise<void>;
23
+ startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[]): Promise<void>;
29
24
 
30
25
  /**
31
26
  * Adds all processed txs to the block. Updates world state with the effects from this tx.
@@ -1,28 +1,55 @@
1
1
  import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { Fr } from '@aztec/foundation/fields';
3
4
 
4
- import type { L2Block } from '../block/l2_block.js';
5
5
  import type { Proof } from '../proofs/proof.js';
6
+ import type { CheckpointConstantData } from '../rollup/checkpoint_constant_data.js';
6
7
  import type { RootRollupPublicInputs } from '../rollup/root_rollup.js';
7
8
  import type { BlockHeader } from '../tx/block_header.js';
8
9
  import type { Tx } from '../tx/tx.js';
10
+ import type { UInt64 } from '../types/index.js';
9
11
  import type { IBlockFactory } from './block-builder.js';
10
12
 
11
13
  /** Coordinates the proving of an entire epoch. */
12
- export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted'> {
14
+ export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted' | 'startNewBlock'> {
13
15
  /**
14
16
  * Starts a new epoch. Must be the first method to be called.
15
17
  * @param epochNumber - The epoch number.
16
- * @param firstBlockNumber - The block number of the first block in the epoch.
17
- * @param totalNumBlocks - The total number of blocks expected in the epoch (must be at least one).
18
+ * @param firstCheckpointNumber - The number of the first checkpoint in the epoch. Used to determine the correct order when checkpoints are added.
19
+ * @param totalNumCheckpoints - The total number of checkpoints expected in the epoch (must be at least one).
20
+ * @param finalBlobBatchingChallenges - The final blob batching challenges for the epoch.
18
21
  **/
19
22
  startNewEpoch(
20
23
  epochNumber: number,
21
- firstBlockNumber: number,
22
- totalNumBlocks: number,
24
+ firstCheckpointNumber: Fr,
25
+ totalNumCheckpoints: number,
23
26
  finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
24
27
  ): void;
25
28
 
29
+ /**
30
+ * Starts a new checkpoint.
31
+ * @param constants - The constants for this checkpoint.
32
+ * @param l1ToL2Messages - The set of L1 to L2 messages to be included in this checkpoint.
33
+ * @param totalNumBlocks - The total number of blocks expected in the checkpoint (must be at least one).
34
+ * @param totalNumBlobFields - The total number of blob fields expected in the checkpoint.
35
+ * @param headerOfLastBlockInPreviousCheckpoint - The header of the last block in the previous checkpoint.
36
+ */
37
+ startNewCheckpoint(
38
+ constants: CheckpointConstantData,
39
+ l1ToL2Messages: Fr[],
40
+ totalNumBlocks: number,
41
+ totalNumBlobFields: number,
42
+ headerOfLastBlockInPreviousCheckpoint: BlockHeader,
43
+ ): Promise<void>;
44
+
45
+ /**
46
+ * Starts a new block.
47
+ * @param blockNumber - The block number.
48
+ * @param timestamp - The timestamp of the block.
49
+ * @param totalNumTxs - The total number of txs in the block.
50
+ */
51
+ startNewBlock(blockNumber: number, timestamp: UInt64, totalNumTxs: number): Promise<void>;
52
+
26
53
  /**
27
54
  * Kickstarts tube circuits for the specified txs. These will be used during epoch proving.
28
55
  * Note that if the tube circuits are not started this way, they will be started nontheless after processing.
@@ -30,7 +57,7 @@ export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted'> {
30
57
  startTubeCircuits(txs: Tx[]): Promise<void>;
31
58
 
32
59
  /** Returns the block. */
33
- setBlockCompleted(blockNumber: number, expectedBlockHeader?: BlockHeader): Promise<L2Block>;
60
+ setBlockCompleted(blockNumber: number, expectedBlockHeader?: BlockHeader): Promise<BlockHeader>;
34
61
 
35
62
  /** Pads the epoch with empty block roots if needed and blocks until proven. Throws if proving has failed. */
36
63
  finalizeEpoch(): Promise<{ publicInputs: RootRollupPublicInputs; proof: Proof; batchedBlobInputs: BatchedBlob }>;
@@ -41,9 +68,6 @@ export interface EpochProver extends Omit<IBlockFactory, 'setBlockCompleted'> {
41
68
  /** Returns an identifier for the prover or zero if not set. */
42
69
  getProverId(): EthAddress;
43
70
 
44
- /** Returns the block assembled at a given index (zero-based) within the epoch. */
45
- getBlock(index: number): L2Block;
46
-
47
71
  /** Called when no longer required, cleans up internal resources */
48
72
  stop(): Promise<void>;
49
73
  }