@aztec/stdlib 4.0.0-nightly.20260122 → 4.0.0-nightly.20260123

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 (70) hide show
  1. package/dest/block/checkpointed_l2_block.d.ts +6 -6
  2. package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
  3. package/dest/block/checkpointed_l2_block.js +3 -3
  4. package/dest/block/in_block.d.ts +3 -3
  5. package/dest/block/in_block.d.ts.map +1 -1
  6. package/dest/block/index.d.ts +2 -2
  7. package/dest/block/index.d.ts.map +1 -1
  8. package/dest/block/index.js +1 -1
  9. package/dest/block/{l2_block_new.d.ts → l2_block.d.ts} +6 -6
  10. package/dest/block/l2_block.d.ts.map +1 -0
  11. package/dest/block/{l2_block_new.js → l2_block.js} +5 -9
  12. package/dest/block/l2_block_source.d.ts +25 -29
  13. package/dest/block/l2_block_source.d.ts.map +1 -1
  14. package/dest/block/l2_block_stream/interfaces.d.ts +3 -3
  15. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  16. package/dest/block/l2_block_stream/l2_block_stream.d.ts +2 -3
  17. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  18. package/dest/block/l2_block_stream/l2_block_stream.js +4 -4
  19. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +3 -3
  20. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  21. package/dest/block/test/l2_tips_store_test_suite.js +2 -2
  22. package/dest/checkpoint/checkpoint.d.ts +8 -8
  23. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  24. package/dest/checkpoint/checkpoint.js +4 -4
  25. package/dest/checkpoint/published_checkpoint.d.ts +2 -2
  26. package/dest/contract/private_function.d.ts +1 -1
  27. package/dest/contract/private_function.d.ts.map +1 -1
  28. package/dest/contract/private_function.js +1 -2
  29. package/dest/epoch-helpers/index.js +1 -1
  30. package/dest/interfaces/archiver.d.ts +1 -1
  31. package/dest/interfaces/archiver.d.ts.map +1 -1
  32. package/dest/interfaces/archiver.js +13 -15
  33. package/dest/interfaces/aztec-node.d.ts +18 -9
  34. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  35. package/dest/interfaces/aztec-node.js +10 -11
  36. package/dest/interfaces/block-builder.d.ts +4 -4
  37. package/dest/interfaces/block-builder.d.ts.map +1 -1
  38. package/dest/interfaces/tx_provider.d.ts +3 -3
  39. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  40. package/dest/p2p/block_proposal.d.ts +4 -4
  41. package/dest/p2p/block_proposal.d.ts.map +1 -1
  42. package/dest/p2p/block_proposal.js +1 -1
  43. package/dest/tests/factories.js +1 -1
  44. package/dest/tests/jest.d.ts +4 -4
  45. package/dest/tests/jest.js +9 -9
  46. package/dest/tests/mocks.d.ts +10 -9
  47. package/dest/tests/mocks.d.ts.map +1 -1
  48. package/dest/tests/mocks.js +15 -10
  49. package/package.json +9 -9
  50. package/src/block/checkpointed_l2_block.ts +4 -4
  51. package/src/block/in_block.ts +2 -2
  52. package/src/block/index.ts +1 -1
  53. package/src/block/{l2_block_new.ts → l2_block.ts} +6 -11
  54. package/src/block/l2_block_source.ts +24 -30
  55. package/src/block/l2_block_stream/interfaces.ts +2 -2
  56. package/src/block/l2_block_stream/l2_block_stream.ts +5 -6
  57. package/src/block/l2_block_stream/l2_tips_store_base.ts +2 -2
  58. package/src/block/test/l2_tips_store_test_suite.ts +4 -4
  59. package/src/checkpoint/checkpoint.ts +7 -7
  60. package/src/contract/private_function.ts +1 -2
  61. package/src/epoch-helpers/index.ts +1 -1
  62. package/src/interfaces/archiver.ts +13 -24
  63. package/src/interfaces/aztec-node.ts +30 -31
  64. package/src/interfaces/block-builder.ts +3 -3
  65. package/src/interfaces/tx_provider.ts +2 -2
  66. package/src/p2p/block_proposal.ts +3 -3
  67. package/src/tests/factories.ts +1 -1
  68. package/src/tests/jest.ts +9 -9
  69. package/src/tests/mocks.ts +20 -13
  70. package/dest/block/l2_block_new.d.ts.map +0 -1
@@ -21,7 +21,7 @@ import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
21
21
  import type { TxHash } from '../tx/tx_hash.js';
22
22
  import type { TxReceipt } from '../tx/tx_receipt.js';
23
23
  import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
24
- import type { L2BlockNew } from './l2_block_new.js';
24
+ import type { L2Block } from './l2_block.js';
25
25
  import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
26
26
 
27
27
  /**
@@ -81,15 +81,15 @@ export interface L2BlockSource {
81
81
  */
82
82
  getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined>;
83
83
 
84
- getCheckpointedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
84
+ getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]>;
85
85
 
86
86
  /**
87
- * Retrieves a collection of published checkpoints
88
- * @param checkpointNumber The first checkpoint to be retrieved
89
- * @param limit The number of checkpoints to be retrieved
90
- * @returns The collection of complete checkpoints
87
+ * Retrieves a collection of checkpoints.
88
+ * @param checkpointNumber The first checkpoint to be retrieved.
89
+ * @param limit The number of checkpoints to be retrieved.
90
+ * @returns The collection of complete checkpoints.
91
91
  */
92
- getPublishedCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
92
+ getCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
93
93
 
94
94
  /**
95
95
  * Gets the checkpoints for a given epoch
@@ -116,21 +116,21 @@ export interface L2BlockSource {
116
116
  * @param number - The block number to return.
117
117
  * @returns The requested L2 block (or undefined if not found).
118
118
  */
119
- getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
119
+ getL2Block(number: BlockNumber): Promise<L2Block | undefined>;
120
120
 
121
121
  /**
122
122
  * Gets an L2 block by its hash.
123
123
  * @param blockHash - The block hash to retrieve.
124
124
  * @returns The requested L2 block (or undefined if not found).
125
125
  */
126
- getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
126
+ getL2BlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
127
127
 
128
128
  /**
129
129
  * Gets an L2 block by its archive root.
130
130
  * @param archive - The archive root to retrieve.
131
131
  * @returns The requested L2 block (or undefined if not found).
132
132
  */
133
- getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
133
+ getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined>;
134
134
 
135
135
  /**
136
136
  * Gets a tx effect.
@@ -157,11 +157,11 @@ export interface L2BlockSource {
157
157
  getL2EpochNumber(): Promise<EpochNumber | undefined>;
158
158
 
159
159
  /**
160
- * Returns all block headers for a given epoch.
160
+ * Returns all checkpointed block headers for a given epoch.
161
161
  * @dev Use this method only with recent epochs, since it walks the block list backwards.
162
162
  * @param epochNumber - The epoch number to return headers for.
163
163
  */
164
- getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]>;
164
+ getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]>;
165
165
 
166
166
  /**
167
167
  * Returns whether the given epoch is completed on L1, based on the current L1 and L2 block numbers.
@@ -207,49 +207,43 @@ export interface L2BlockSource {
207
207
  * @param number - The block number to return (inclusive).
208
208
  * @returns The requested L2 block.
209
209
  */
210
- getBlock(number: BlockNumber): Promise<L2BlockNew | undefined>;
211
-
212
- getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
210
+ getBlock(number: BlockNumber): Promise<L2Block | undefined>;
213
211
 
214
212
  /**
215
- * Returns all blocks for a given epoch.
213
+ * Returns all checkpointed blocks for a given epoch.
216
214
  * @dev Use this method only with recent epochs, since it walks the block list backwards.
217
215
  * @param epochNumber - The epoch number to return blocks for.
218
216
  */
219
- getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]>;
217
+ getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]>;
220
218
 
221
219
  /**
222
220
  * Returns all blocks for a given slot.
223
221
  * @dev Use this method only with recent slots, since it walks the block list backwards.
224
222
  * @param slotNumber - The slot number to return blocks for.
225
223
  */
226
- getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]>;
224
+ getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]>;
227
225
 
228
226
  /**
229
- * Gets a published block by its block hash.
227
+ * Gets a checkpointed block by its block hash.
230
228
  * @param blockHash - The block hash to retrieve.
231
229
  * @returns The requested block (or undefined if not found).
232
230
  */
233
- getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
231
+ getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
234
232
 
235
233
  /**
236
- * Gets a published block by its archive root.
234
+ * Gets a checkpointed block by its archive root.
237
235
  * @param archive - The archive root to retrieve.
238
236
  * @returns The requested block (or undefined if not found).
239
237
  */
240
- getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
238
+ getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
241
239
 
242
240
  /**
243
241
  * Gets up to `limit` amount of L2 blocks starting from `from`.
244
242
  * @param from - Number of the first block to return (inclusive).
245
243
  * @param limit - The maximum number of blocks to return.
246
- * @param proven - If true, only return blocks that have been proven.
247
244
  * @returns The requested L2 blocks.
248
245
  */
249
- getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
250
-
251
- /** Equivalent to getBlocks but includes publish data. */
252
- getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
246
+ getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
253
247
  }
254
248
 
255
249
  /**
@@ -261,7 +255,7 @@ export interface L2BlockSink {
261
255
  * @param block - The L2 block to add.
262
256
  * @throws If block number is not incremental (i.e., not exactly one more than the last stored block).
263
257
  */
264
- addBlock(block: L2BlockNew): Promise<void>;
258
+ addBlock(block: L2Block): Promise<void>;
265
259
  }
266
260
 
267
261
  /**
@@ -358,13 +352,13 @@ export type L2BlockProvenEvent = {
358
352
  export type L2PruneUnprovenEvent = {
359
353
  type: 'l2PruneUnproven';
360
354
  epochNumber: EpochNumber;
361
- blocks: L2BlockNew[];
355
+ blocks: L2Block[];
362
356
  };
363
357
 
364
358
  export type L2PruneUncheckpointedEvent = {
365
359
  type: 'l2PruneUncheckpointed';
366
360
  slotNumber: SlotNumber;
367
- blocks: L2BlockNew[];
361
+ blocks: L2Block[];
368
362
  };
369
363
 
370
364
  export type L2CheckpointEvent = {
@@ -1,5 +1,5 @@
1
1
  import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
2
- import type { L2BlockNew } from '../l2_block_new.js';
2
+ import type { L2Block } from '../l2_block.js';
3
3
  import type { CheckpointId, L2BlockId, L2Tips } from '../l2_block_source.js';
4
4
 
5
5
  /** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
@@ -16,7 +16,7 @@ export interface L2BlockStreamEventHandler {
16
16
  export type L2BlockStreamEvent =
17
17
  | /** Emits blocks added to the chain. */ {
18
18
  type: 'blocks-added';
19
- blocks: L2BlockNew[];
19
+ blocks: L2Block[];
20
20
  }
21
21
  | /** Emits checkpoints published to L1. */ {
22
22
  type: 'chain-checkpointed';
@@ -19,13 +19,12 @@ export class L2BlockStream {
19
19
  constructor(
20
20
  private l2BlockSource: Pick<
21
21
  L2BlockSource,
22
- 'getL2BlocksNew' | 'getBlockHeader' | 'getL2Tips' | 'getPublishedCheckpoints' | 'getCheckpointedBlocks'
22
+ 'getBlocks' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpoints' | 'getCheckpointedBlocks'
23
23
  >,
24
24
  private localData: L2BlockStreamLocalDataProvider,
25
25
  private handler: L2BlockStreamEventHandler,
26
26
  private readonly log = createLogger('types:block_stream'),
27
27
  private opts: {
28
- proven?: boolean;
29
28
  pollIntervalMS?: number;
30
29
  batchSize?: number;
31
30
  startingBlock?: number;
@@ -129,7 +128,7 @@ export class L2BlockStream {
129
128
  if (!this.opts.ignoreCheckpoints) {
130
129
  let loop1Iterations = 0;
131
130
  while (nextCheckpointToEmit <= sourceTips.checkpointed.checkpoint.number) {
132
- const checkpoints = await this.l2BlockSource.getPublishedCheckpoints(nextCheckpointToEmit, 1);
131
+ const checkpoints = await this.l2BlockSource.getCheckpoints(nextCheckpointToEmit, 1);
133
132
  if (checkpoints.length === 0) {
134
133
  break;
135
134
  }
@@ -174,7 +173,7 @@ export class L2BlockStream {
174
173
  // Refill the prefetch buffer when exhausted
175
174
  if (prefetchIdx >= prefetchedCheckpoints.length) {
176
175
  const prefetchLimit = this.opts.checkpointPrefetchLimit ?? CHECKPOINT_PREFETCH_LIMIT;
177
- prefetchedCheckpoints = await this.l2BlockSource.getPublishedCheckpoints(nextCheckpointNumber, prefetchLimit);
176
+ prefetchedCheckpoints = await this.l2BlockSource.getCheckpoints(nextCheckpointNumber, prefetchLimit);
178
177
  prefetchIdx = 0;
179
178
  if (prefetchedCheckpoints.length === 0) {
180
179
  break;
@@ -213,8 +212,8 @@ export class L2BlockStream {
213
212
  // Loop 3: Fetch any remaining uncheckpointed (proposed) blocks.
214
213
  while (nextBlockNumber <= sourceTips.proposed.number) {
215
214
  const limit = Math.min(this.opts.batchSize ?? 50, sourceTips.proposed.number - nextBlockNumber + 1);
216
- this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit} proven=${this.opts.proven}`);
217
- const blocks = await this.l2BlockSource.getL2BlocksNew(BlockNumber(nextBlockNumber), limit, this.opts.proven);
215
+ this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit}`);
216
+ const blocks = await this.l2BlockSource.getBlocks(BlockNumber(nextBlockNumber), BlockNumber(limit));
218
217
  if (blocks.length === 0) {
219
218
  break;
220
219
  }
@@ -2,7 +2,7 @@ import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
2
2
  import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
3
3
 
4
4
  import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
5
- import type { L2BlockNew } from '../l2_block_new.js';
5
+ import type { L2Block } from '../l2_block.js';
6
6
  import {
7
7
  type CheckpointId,
8
8
  GENESIS_CHECKPOINT_HEADER_HASH,
@@ -109,7 +109,7 @@ export abstract class L2TipsStoreBase implements L2BlockStreamEventHandler, L2Bl
109
109
  }
110
110
 
111
111
  // Protected helper that subclasses can override for block hash computation
112
- protected computeBlockHash(block: L2BlockNew): Promise<string> {
112
+ protected computeBlockHash(block: L2Block): Promise<string> {
113
113
  return block.hash().then(hash => hash.toString());
114
114
  }
115
115
 
@@ -5,8 +5,8 @@ import { Fr } from '@aztec/foundation/curves/bn254';
5
5
  import {
6
6
  type CheckpointId,
7
7
  GENESIS_CHECKPOINT_HEADER_HASH,
8
+ L2Block,
8
9
  type L2BlockId,
9
- L2BlockNew,
10
10
  type L2TipId,
11
11
  } from '@aztec/stdlib/block';
12
12
  import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
@@ -31,8 +31,8 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
31
31
  blockToCheckpoint.clear();
32
32
  });
33
33
 
34
- const makeBlock = async (number: number): Promise<L2BlockNew> => {
35
- const block = await L2BlockNew.random(BlockNumber(number));
34
+ const makeBlock = async (number: number): Promise<L2Block> => {
35
+ const block = await L2Block.random(BlockNumber(number));
36
36
  blockHashes.set(number, (await block.hash()).toString());
37
37
  return block;
38
38
  };
@@ -74,7 +74,7 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
74
74
  checkpointed: makeTipId(checkpointed),
75
75
  });
76
76
 
77
- const makeCheckpoint = async (checkpointNumber: number, blocks: L2BlockNew[]): Promise<PublishedCheckpoint> => {
77
+ const makeCheckpoint = async (checkpointNumber: number, blocks: L2Block[]): Promise<PublishedCheckpoint> => {
78
78
  const checkpoint = await Checkpoint.random(CheckpointNumber(checkpointNumber), {
79
79
  numBlocks: blocks.length,
80
80
  startBlockNumber: blocks[0].number,
@@ -13,7 +13,7 @@ import type { FieldsOf } from '@aztec/foundation/types';
13
13
 
14
14
  import { z } from 'zod';
15
15
 
16
- import { L2BlockNew } from '../block/l2_block_new.js';
16
+ import { L2Block } from '../block/l2_block.js';
17
17
  import { MAX_BLOCKS_PER_CHECKPOINT } from '../deserialization/index.js';
18
18
  import { computeCheckpointOutHash } from '../messaging/out_hash.js';
19
19
  import { CheckpointHeader } from '../rollup/checkpoint_header.js';
@@ -29,7 +29,7 @@ export class Checkpoint {
29
29
  /** Header of the checkpoint. */
30
30
  public header: CheckpointHeader,
31
31
  /** L2 blocks in the checkpoint. */
32
- public blocks: L2BlockNew[],
32
+ public blocks: L2Block[],
33
33
  /** Number of the checkpoint. */
34
34
  public number: CheckpointNumber,
35
35
  ) {}
@@ -43,7 +43,7 @@ export class Checkpoint {
43
43
  .object({
44
44
  archive: AppendOnlyTreeSnapshot.schema,
45
45
  header: CheckpointHeader.schema,
46
- blocks: z.array(L2BlockNew.schema),
46
+ blocks: z.array(L2Block.schema),
47
47
  number: CheckpointNumberSchema,
48
48
  })
49
49
  .transform(({ archive, header, blocks, number }) => new Checkpoint(archive, header, blocks, number));
@@ -62,7 +62,7 @@ export class Checkpoint {
62
62
  return new Checkpoint(
63
63
  reader.readObject(AppendOnlyTreeSnapshot),
64
64
  reader.readObject(CheckpointHeader),
65
- reader.readVector(L2BlockNew, MAX_BLOCKS_PER_CHECKPOINT),
65
+ reader.readVector(L2Block, MAX_BLOCKS_PER_CHECKPOINT),
66
66
  CheckpointNumber(reader.readNumber()),
67
67
  );
68
68
  }
@@ -135,16 +135,16 @@ export class Checkpoint {
135
135
  startBlockNumber?: number;
136
136
  previousArchive?: AppendOnlyTreeSnapshot;
137
137
  } & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
138
- Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
138
+ Partial<Parameters<typeof L2Block.random>[1]> = {},
139
139
  ) {
140
140
  const header = CheckpointHeader.random(options);
141
141
 
142
142
  // Create blocks sequentially to chain archive roots properly.
143
143
  // Each block's header.lastArchive must equal the previous block's archive.
144
- const blocks: L2BlockNew[] = [];
144
+ const blocks: L2Block[] = [];
145
145
  let lastArchive = previousArchive;
146
146
  for (let i = 0; i < numBlocks; i++) {
147
- const block = await L2BlockNew.random(BlockNumber(startBlockNumber + i), {
147
+ const block = await L2Block.random(BlockNumber(startBlockNumber + i), {
148
148
  indexWithinCheckpoint: IndexWithinCheckpoint(i),
149
149
  ...options,
150
150
  ...(lastArchive ? { lastArchive } : {}),
@@ -1,5 +1,4 @@
1
1
  import { FUNCTION_TREE_HEIGHT, GeneratorIndex } from '@aztec/constants';
2
- import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
3
2
  import { poseidon2Hash, poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
4
3
  import { Fr } from '@aztec/foundation/curves/bn254';
5
4
  import { type MerkleTree, MerkleTreeCalculator } from '@aztec/foundation/trees';
@@ -38,7 +37,7 @@ export async function computePrivateFunctionLeaf(fn: PrivateFunction): Promise<B
38
37
  async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator> {
39
38
  if (!privateFunctionTreeCalculator) {
40
39
  const functionTreeZeroLeaf = (
41
- await pedersenHash(new Array(PRIVATE_FUNCTION_SIZE).fill(0))
40
+ await poseidon2Hash(new Array(PRIVATE_FUNCTION_SIZE).fill(0))
42
41
  ).toBuffer() as Buffer<ArrayBuffer>;
43
42
  privateFunctionTreeCalculator = await MerkleTreeCalculator.create(
44
43
  FUNCTION_TREE_HEIGHT,
@@ -69,7 +69,7 @@ export function getSlotRangeForEpoch(
69
69
  epochNumber: EpochNumber,
70
70
  constants: Pick<L1RollupConstants, 'epochDuration'>,
71
71
  ): [SlotNumber, SlotNumber] {
72
- const startSlot = SlotNumber(epochNumber * constants.epochDuration);
72
+ const startSlot = SlotNumber(Number(epochNumber) * constants.epochDuration);
73
73
  return [startSlot, SlotNumber(startSlot + constants.epochDuration - 1)];
74
74
  }
75
75
 
@@ -5,7 +5,7 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
5
5
  import { z } from 'zod';
6
6
 
7
7
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
8
- import { L2BlockNew } from '../block/l2_block_new.js';
8
+ import { L2Block } from '../block/l2_block.js';
9
9
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
10
10
  import { ValidateCheckpointResultSchema } from '../block/validate_block_result.js';
11
11
  import { Checkpoint } from '../checkpoint/checkpoint.js';
@@ -84,7 +84,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
84
84
  getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
85
85
  getCheckpointedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
86
86
  getFinalizedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
87
- getBlock: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
87
+ getBlock: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
88
88
  getBlockHeader: z
89
89
  .function()
90
90
  .args(z.union([BlockNumberSchema, z.literal('latest')]))
@@ -92,39 +92,28 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
92
92
  getCheckpointedBlock: z.function().args(BlockNumberSchema).returns(CheckpointedL2Block.schema.optional()),
93
93
  getCheckpointedBlocks: z
94
94
  .function()
95
- .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
95
+ .args(BlockNumberSchema, schemas.Integer)
96
96
  .returns(z.array(CheckpointedL2Block.schema)),
97
- getBlocks: z
98
- .function()
99
- .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
100
- .returns(z.array(L2BlockNew.schema)),
101
- getPublishedCheckpoints: z
97
+ getBlocks: z.function().args(BlockNumberSchema, schemas.Integer).returns(z.array(L2Block.schema)),
98
+ getCheckpoints: z
102
99
  .function()
103
100
  .args(CheckpointNumberSchema, schemas.Integer)
104
101
  .returns(z.array(PublishedCheckpoint.schema)),
105
- getPublishedBlocks: z
106
- .function()
107
- .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
108
- .returns(z.array(CheckpointedL2Block.schema)),
109
- getL2BlocksNew: z
110
- .function()
111
- .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
112
- .returns(z.array(L2BlockNew.schema)),
113
- getPublishedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
114
- getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
102
+ getCheckpointedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
103
+ getCheckpointedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
115
104
  getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
116
105
  getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
117
- getL2BlockNew: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
118
- getL2BlockNewByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
119
- getL2BlockNewByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
106
+ getL2Block: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
107
+ getL2BlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
108
+ getL2BlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
120
109
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
121
110
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
122
111
  getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
123
112
  getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
124
113
  getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.schema)),
125
- getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(L2BlockNew.schema)),
126
- getBlocksForSlot: z.function().args(schemas.SlotNumber).returns(z.array(L2BlockNew.schema)),
127
- getBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
114
+ getCheckpointedBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(CheckpointedL2Block.schema)),
115
+ getBlocksForSlot: z.function().args(schemas.SlotNumber).returns(z.array(L2Block.schema)),
116
+ getCheckpointedBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
128
117
  isEpochComplete: z.function().args(EpochNumberSchema).returns(z.boolean()),
129
118
  getL2Tips: z.function().args().returns(L2TipsSchema),
130
119
  getPrivateLogsByTags: z
@@ -23,10 +23,11 @@ import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
23
23
  import { z } from 'zod';
24
24
 
25
25
  import type { AztecAddress } from '../aztec-address/index.js';
26
+ import { L2BlockHash } from '../block/block_hash.js';
26
27
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
27
28
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
28
29
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
29
- import { L2BlockNew } from '../block/l2_block_new.js';
30
+ import { L2Block } from '../block/l2_block.js';
30
31
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
31
32
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
32
33
  import {
@@ -77,13 +78,7 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
77
78
  export interface AztecNode
78
79
  extends Pick<
79
80
  L2BlockSource,
80
- | 'getBlocks'
81
- | 'getL2BlocksNew'
82
- | 'getPublishedBlocks'
83
- | 'getPublishedCheckpoints'
84
- | 'getBlockHeader'
85
- | 'getL2Tips'
86
- | 'getCheckpointedBlocks'
81
+ 'getBlocks' | 'getCheckpoints' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpointedBlocks'
87
82
  > {
88
83
  /**
89
84
  * Returns the tips of the L2 chain.
@@ -232,21 +227,21 @@ export interface AztecNode
232
227
  * @param number - The block number or 'latest'.
233
228
  * @returns The requested block.
234
229
  */
235
- getBlock(number: BlockParameter): Promise<L2BlockNew | undefined>;
230
+ getBlock(number: BlockParameter): Promise<L2Block | undefined>;
236
231
 
237
232
  /**
238
233
  * Get a block specified by its hash.
239
234
  * @param blockHash - The block hash being requested.
240
235
  * @returns The requested block.
241
236
  */
242
- getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
237
+ getBlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
243
238
 
244
239
  /**
245
240
  * Get a block specified by its archive root.
246
241
  * @param archive - The archive root being requested.
247
242
  * @returns The requested block.
248
243
  */
249
- getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
244
+ getBlockByArchive(archive: Fr): Promise<L2Block | undefined>;
250
245
 
251
246
  /**
252
247
  * Method to fetch the latest block number synchronized by the node.
@@ -279,7 +274,7 @@ export interface AztecNode
279
274
  * @param limit - The maximum number of blocks to return.
280
275
  * @returns The blocks requested.
281
276
  */
282
- getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]>;
277
+ getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
283
278
 
284
279
  /**
285
280
  * Method to fetch the current min fees.
@@ -347,10 +342,14 @@ export interface AztecNode
347
342
  * array implies no logs match that tag.
348
343
  * @param tags - The tags to search for.
349
344
  * @param page - The page number (0-indexed) for pagination.
345
+ * @param referenceBlock - Optional block hash used to ensure the block still exists before logs are retrieved.
346
+ * This block is expected to represent the latest block to which the client has synced (called anchor block in PXE).
347
+ * If specified and the block is not found, an error is thrown. This helps detect reorgs, which could result in
348
+ * undefined behavior in the client's code.
350
349
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
351
350
  * for a tag, the caller should fetch the next page to check for more logs.
352
351
  */
353
- getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]>;
352
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: L2BlockHash): Promise<TxScopedL2Log[][]>;
354
353
 
355
354
  /**
356
355
  * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
@@ -358,6 +357,10 @@ export interface AztecNode
358
357
  * @param contractAddress - The contract address to search logs for.
359
358
  * @param tags - The tags to search for.
360
359
  * @param page - The page number (0-indexed) for pagination.
360
+ * @param referenceBlock - Optional block hash used to ensure the block still exists before logs are retrieved.
361
+ * This block is expected to represent the latest block to which the client has synced (called anchor block in PXE).
362
+ * If specified and the block is not found, an error is thrown. This helps detect reorgs, which could result in
363
+ * undefined behavior in the client's code.
361
364
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
362
365
  * for a tag, the caller should fetch the next page to check for more logs.
363
366
  */
@@ -365,6 +368,7 @@ export interface AztecNode
365
368
  contractAddress: AztecAddress,
366
369
  tags: Tag[],
367
370
  page?: number,
371
+ referenceBlock?: L2BlockHash,
368
372
  ): Promise<TxScopedL2Log[][]>;
369
373
 
370
374
  /**
@@ -567,11 +571,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
567
571
  .args(EpochNumberSchema)
568
572
  .returns(z.array(z.array(z.array(z.array(schemas.Fr))))),
569
573
 
570
- getBlock: z.function().args(BlockParameterSchema).returns(L2BlockNew.schema.optional()),
574
+ getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
571
575
 
572
- getBlockByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
576
+ getBlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
573
577
 
574
- getBlockByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
578
+ getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
575
579
 
576
580
  getBlockNumber: z.function().returns(BlockNumberSchema),
577
581
 
@@ -584,26 +588,16 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
584
588
  getBlocks: z
585
589
  .function()
586
590
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
587
- .returns(z.array(L2BlockNew.schema)),
591
+ .returns(z.array(L2Block.schema)),
588
592
 
589
- getPublishedBlocks: z
590
- .function()
591
- .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
592
- .returns(z.array(CheckpointedL2Block.schema)),
593
-
594
- getPublishedCheckpoints: z
593
+ getCheckpoints: z
595
594
  .function()
596
595
  .args(CheckpointNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_CHECKPOINTS_LEN))
597
596
  .returns(z.array(PublishedCheckpoint.schema)),
598
597
 
599
- getL2BlocksNew: z
600
- .function()
601
- .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
602
- .returns(z.array(L2BlockNew.schema)),
603
-
604
598
  getCheckpointedBlocks: z
605
599
  .function()
606
- .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN), optional(z.boolean()))
600
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
607
601
  .returns(z.array(CheckpointedL2Block.schema)),
608
602
 
609
603
  getCurrentMinFees: z.function().returns(GasFees.schema),
@@ -631,12 +625,17 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
631
625
 
632
626
  getPrivateLogsByTags: z
633
627
  .function()
634
- .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)))
628
+ .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(L2BlockHash.schema))
635
629
  .returns(z.array(z.array(TxScopedL2Log.schema))),
636
630
 
637
631
  getPublicLogsByTagsFromContract: z
638
632
  .function()
639
- .args(schemas.AztecAddress, z.array(Tag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)))
633
+ .args(
634
+ schemas.AztecAddress,
635
+ z.array(Tag.schema).max(MAX_RPC_LEN),
636
+ optional(z.number().gte(0)),
637
+ optional(L2BlockHash.schema),
638
+ )
640
639
  .returns(z.array(z.array(TxScopedL2Log.schema))),
641
640
 
642
641
  sendTx: z.function().args(Tx.schema).returns(z.void()),
@@ -1,7 +1,7 @@
1
1
  import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
2
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
 
4
- import type { L2BlockNew } from '../block/l2_block_new.js';
4
+ import type { L2Block } from '../block/l2_block.js';
5
5
  import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
6
6
  import type { L1RollupConstants } from '../epoch-helpers/index.js';
7
7
  import type { Gas } from '../gas/gas.js';
@@ -31,7 +31,7 @@ export interface IBlockFactory extends ProcessedTxHandler {
31
31
  /**
32
32
  * Assembles the block and updates the archive tree.
33
33
  */
34
- setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2BlockNew>;
34
+ setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2Block>;
35
35
  }
36
36
 
37
37
  export interface PublicProcessorLimits {
@@ -63,7 +63,7 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
63
63
 
64
64
  /** Result of building a block within a checkpoint. */
65
65
  export interface BuildBlockInCheckpointResult {
66
- block: L2BlockNew;
66
+ block: L2Block;
67
67
  publicGas: Gas;
68
68
  publicProcessorDuration: number;
69
69
  numTxs: number;
@@ -1,4 +1,4 @@
1
- import type { L2BlockNew } from '@aztec/stdlib/block';
1
+ import type { L2Block } from '@aztec/stdlib/block';
2
2
  import type { BlockProposal } from '@aztec/stdlib/p2p';
3
3
  import { type Tx, TxHash } from '@aztec/stdlib/tx';
4
4
 
@@ -13,5 +13,5 @@ export interface ITxProvider {
13
13
  opts: { pinnedPeer: PeerId | undefined; deadline: Date },
14
14
  ): Promise<{ txs: Tx[]; missingTxs: TxHash[] }>;
15
15
 
16
- getTxsForBlock(block: L2BlockNew, opts: { deadline: Date }): Promise<{ txs: Tx[]; missingTxs: TxHash[] }>;
16
+ getTxsForBlock(block: L2Block, opts: { deadline: Date }): Promise<{ txs: Tx[]; missingTxs: TxHash[] }>;
17
17
  }
@@ -8,8 +8,8 @@ import { Signature } from '@aztec/foundation/eth-signature';
8
8
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
9
9
  import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
10
10
 
11
+ import type { L2Block } from '../block/l2_block.js';
11
12
  import type { L2BlockInfo } from '../block/l2_block_info.js';
12
- import type { L2BlockNew } from '../block/l2_block_new.js';
13
13
  import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
14
14
  import { BlockHeader } from '../tx/block_header.js';
15
15
  import { TxHash } from '../tx/index.js';
@@ -284,10 +284,10 @@ export class BlockProposal extends Gossipable {
284
284
  /**
285
285
  * Check if this proposal matches the given block.
286
286
  * Compares the archive root and block header.
287
- * @param block - The L2BlockNew to compare against
287
+ * @param block - The L2Block to compare against
288
288
  * @returns True if the proposal matches the block
289
289
  */
290
- matchesBlock(block: L2BlockNew): boolean {
290
+ matchesBlock(block: L2Block): boolean {
291
291
  return this.archiveRoot.equals(block.archive.root) && this.blockHeader.equals(block.header);
292
292
  }
293
293
 
@@ -1739,7 +1739,7 @@ export function makeL2Tips(
1739
1739
  ? typeof checkpointNumber === 'number'
1740
1740
  ? CheckpointNumber(checkpointNumber)
1741
1741
  : checkpointNumber
1742
- : CheckpointNumber(bn);
1742
+ : CheckpointNumber.fromBlockNumber(bn);
1743
1743
  const cph = checkpointHash ?? hash;
1744
1744
  return {
1745
1745
  proposed: { number: bn, hash },