@aztec/stdlib 0.0.1-commit.d1f2d6c → 0.0.1-commit.d431d1c

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 (100) 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.d.ts → l2_block_new.d.ts} +6 -6
  10. package/dest/block/l2_block_new.d.ts.map +1 -0
  11. package/dest/block/{l2_block.js → l2_block_new.js} +9 -5
  12. package/dest/block/l2_block_source.d.ts +29 -37
  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 +3 -2
  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/config/node-rpc-config.js +1 -1
  27. package/dest/contract/private_function.d.ts +1 -1
  28. package/dest/contract/private_function.d.ts.map +1 -1
  29. package/dest/contract/private_function.js +2 -1
  30. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +2 -2
  31. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -1
  32. package/dest/delayed_public_mutable/delayed_public_mutable_values.js +10 -7
  33. package/dest/epoch-helpers/index.js +1 -1
  34. package/dest/interfaces/archiver.d.ts +1 -1
  35. package/dest/interfaces/archiver.d.ts.map +1 -1
  36. package/dest/interfaces/archiver.js +15 -15
  37. package/dest/interfaces/aztec-node-admin.d.ts +1 -4
  38. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  39. package/dest/interfaces/aztec-node.d.ts +9 -23
  40. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  41. package/dest/interfaces/aztec-node.js +11 -11
  42. package/dest/interfaces/block-builder.d.ts +4 -4
  43. package/dest/interfaces/block-builder.d.ts.map +1 -1
  44. package/dest/interfaces/configs.d.ts +2 -2
  45. package/dest/interfaces/configs.d.ts.map +1 -1
  46. package/dest/interfaces/prover-client.d.ts +1 -10
  47. package/dest/interfaces/prover-client.d.ts.map +1 -1
  48. package/dest/interfaces/prover-client.js +1 -7
  49. package/dest/interfaces/tx_provider.d.ts +3 -3
  50. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  51. package/dest/interfaces/validator.d.ts +2 -2
  52. package/dest/interfaces/validator.d.ts.map +1 -1
  53. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
  54. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  55. package/dest/kernel/hints/build_nullifier_read_request_hints.js +6 -4
  56. package/dest/p2p/block_proposal.d.ts +4 -4
  57. package/dest/p2p/block_proposal.d.ts.map +1 -1
  58. package/dest/p2p/block_proposal.js +1 -1
  59. package/dest/p2p/message_validator.d.ts +3 -18
  60. package/dest/p2p/message_validator.d.ts.map +1 -1
  61. package/dest/p2p/message_validator.js +1 -2
  62. package/dest/tests/factories.js +1 -1
  63. package/dest/tests/jest.d.ts +4 -4
  64. package/dest/tests/jest.js +9 -9
  65. package/dest/tests/mocks.d.ts +9 -10
  66. package/dest/tests/mocks.d.ts.map +1 -1
  67. package/dest/tests/mocks.js +10 -15
  68. package/dest/tx/tx_receipt.d.ts +11 -39
  69. package/dest/tx/tx_receipt.d.ts.map +1 -1
  70. package/dest/tx/tx_receipt.js +13 -44
  71. package/package.json +9 -9
  72. package/src/block/checkpointed_l2_block.ts +4 -4
  73. package/src/block/in_block.ts +2 -2
  74. package/src/block/index.ts +1 -1
  75. package/src/block/{l2_block.ts → l2_block_new.ts} +11 -6
  76. package/src/block/l2_block_source.ts +30 -38
  77. package/src/block/l2_block_stream/interfaces.ts +2 -2
  78. package/src/block/l2_block_stream/l2_block_stream.ts +6 -5
  79. package/src/block/l2_block_stream/l2_tips_store_base.ts +2 -2
  80. package/src/block/test/l2_tips_store_test_suite.ts +4 -4
  81. package/src/checkpoint/checkpoint.ts +7 -7
  82. package/src/config/node-rpc-config.ts +1 -1
  83. package/src/contract/private_function.ts +2 -1
  84. package/src/delayed_public_mutable/delayed_public_mutable_values.ts +10 -9
  85. package/src/epoch-helpers/index.ts +1 -1
  86. package/src/interfaces/archiver.ts +24 -15
  87. package/src/interfaces/aztec-node.ts +31 -38
  88. package/src/interfaces/block-builder.ts +3 -3
  89. package/src/interfaces/configs.ts +3 -1
  90. package/src/interfaces/prover-client.ts +0 -15
  91. package/src/interfaces/tx_provider.ts +2 -2
  92. package/src/interfaces/validator.ts +2 -1
  93. package/src/kernel/hints/build_nullifier_read_request_hints.ts +10 -1
  94. package/src/p2p/block_proposal.ts +3 -3
  95. package/src/p2p/message_validator.ts +2 -14
  96. package/src/tests/factories.ts +1 -1
  97. package/src/tests/jest.ts +9 -9
  98. package/src/tests/mocks.ts +13 -20
  99. package/src/tx/tx_receipt.ts +15 -72
  100. package/dest/block/l2_block.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 { L2Block } from './l2_block.js';
24
+ import type { L2BlockNew } from './l2_block_new.js';
25
25
  import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
26
26
 
27
27
  /**
@@ -52,20 +52,6 @@ export interface L2BlockSource {
52
52
  */
53
53
  getProvenBlockNumber(): Promise<BlockNumber>;
54
54
 
55
- /**
56
- * Gets the number of the latest L2 block checkpointed seen by the block source implementation.
57
- * @returns The number of the latest L2 block checkpointed seen by the block source implementation.
58
- */
59
- getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
60
-
61
- /**
62
- * Computes the finalized block number based on the proven block number.
63
- * A block is considered finalized when it's 2 epochs behind the proven block.
64
- * TODO(#13569): Compute proper finalized block number based on L1 finalized block.
65
- * @returns The finalized block number.
66
- */
67
- getFinalizedL2BlockNumber(): Promise<BlockNumber>;
68
-
69
55
  /**
70
56
  * Gets an l2 block header.
71
57
  * @param number - The block number to return or 'latest' for the most recent one.
@@ -81,15 +67,15 @@ export interface L2BlockSource {
81
67
  */
82
68
  getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined>;
83
69
 
84
- getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]>;
70
+ getCheckpointedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
85
71
 
86
72
  /**
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.
73
+ * Retrieves a collection of published checkpoints
74
+ * @param checkpointNumber The first checkpoint to be retrieved
75
+ * @param limit The number of checkpoints to be retrieved
76
+ * @returns The collection of complete checkpoints
91
77
  */
92
- getCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
78
+ getPublishedCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
93
79
 
94
80
  /**
95
81
  * Gets the checkpoints for a given epoch
@@ -116,21 +102,21 @@ export interface L2BlockSource {
116
102
  * @param number - The block number to return.
117
103
  * @returns The requested L2 block (or undefined if not found).
118
104
  */
119
- getL2Block(number: BlockNumber): Promise<L2Block | undefined>;
105
+ getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
120
106
 
121
107
  /**
122
108
  * Gets an L2 block by its hash.
123
109
  * @param blockHash - The block hash to retrieve.
124
110
  * @returns The requested L2 block (or undefined if not found).
125
111
  */
126
- getL2BlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
112
+ getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
127
113
 
128
114
  /**
129
115
  * Gets an L2 block by its archive root.
130
116
  * @param archive - The archive root to retrieve.
131
117
  * @returns The requested L2 block (or undefined if not found).
132
118
  */
133
- getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined>;
119
+ getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
134
120
 
135
121
  /**
136
122
  * Gets a tx effect.
@@ -157,11 +143,11 @@ export interface L2BlockSource {
157
143
  getL2EpochNumber(): Promise<EpochNumber | undefined>;
158
144
 
159
145
  /**
160
- * Returns all checkpointed block headers for a given epoch.
146
+ * Returns all block headers for a given epoch.
161
147
  * @dev Use this method only with recent epochs, since it walks the block list backwards.
162
148
  * @param epochNumber - The epoch number to return headers for.
163
149
  */
164
- getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]>;
150
+ getBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]>;
165
151
 
166
152
  /**
167
153
  * Returns whether the given epoch is completed on L1, based on the current L1 and L2 block numbers.
@@ -207,43 +193,49 @@ export interface L2BlockSource {
207
193
  * @param number - The block number to return (inclusive).
208
194
  * @returns The requested L2 block.
209
195
  */
210
- getBlock(number: BlockNumber): Promise<L2Block | undefined>;
196
+ getBlock(number: BlockNumber): Promise<L2BlockNew | undefined>;
197
+
198
+ getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
211
199
 
212
200
  /**
213
- * Returns all checkpointed blocks for a given epoch.
201
+ * Returns all blocks for a given epoch.
214
202
  * @dev Use this method only with recent epochs, since it walks the block list backwards.
215
203
  * @param epochNumber - The epoch number to return blocks for.
216
204
  */
217
- getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]>;
205
+ getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]>;
218
206
 
219
207
  /**
220
208
  * Returns all blocks for a given slot.
221
209
  * @dev Use this method only with recent slots, since it walks the block list backwards.
222
210
  * @param slotNumber - The slot number to return blocks for.
223
211
  */
224
- getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]>;
212
+ getBlocksForSlot(slotNumber: SlotNumber): Promise<L2BlockNew[]>;
225
213
 
226
214
  /**
227
- * Gets a checkpointed block by its block hash.
215
+ * Gets a published block by its block hash.
228
216
  * @param blockHash - The block hash to retrieve.
229
217
  * @returns The requested block (or undefined if not found).
230
218
  */
231
- getCheckpointedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
219
+ getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
232
220
 
233
221
  /**
234
- * Gets a checkpointed block by its archive root.
222
+ * Gets a published block by its archive root.
235
223
  * @param archive - The archive root to retrieve.
236
224
  * @returns The requested block (or undefined if not found).
237
225
  */
238
- getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
226
+ getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
239
227
 
240
228
  /**
241
229
  * Gets up to `limit` amount of L2 blocks starting from `from`.
242
230
  * @param from - Number of the first block to return (inclusive).
243
231
  * @param limit - The maximum number of blocks to return.
232
+ * @param proven - If true, only return blocks that have been proven.
244
233
  * @returns The requested L2 blocks.
245
234
  */
246
- getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
235
+ getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
236
+
237
+ /** Equivalent to getBlocks but includes publish data. */
238
+ getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
247
239
  }
248
240
 
249
241
  /**
@@ -255,7 +247,7 @@ export interface L2BlockSink {
255
247
  * @param block - The L2 block to add.
256
248
  * @throws If block number is not incremental (i.e., not exactly one more than the last stored block).
257
249
  */
258
- addBlock(block: L2Block): Promise<void>;
250
+ addBlock(block: L2BlockNew): Promise<void>;
259
251
  }
260
252
 
261
253
  /**
@@ -352,13 +344,13 @@ export type L2BlockProvenEvent = {
352
344
  export type L2PruneUnprovenEvent = {
353
345
  type: 'l2PruneUnproven';
354
346
  epochNumber: EpochNumber;
355
- blocks: L2Block[];
347
+ blocks: L2BlockNew[];
356
348
  };
357
349
 
358
350
  export type L2PruneUncheckpointedEvent = {
359
351
  type: 'l2PruneUncheckpointed';
360
352
  slotNumber: SlotNumber;
361
- blocks: L2Block[];
353
+ blocks: L2BlockNew[];
362
354
  };
363
355
 
364
356
  export type L2CheckpointEvent = {
@@ -1,5 +1,5 @@
1
1
  import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
2
- import type { L2Block } from '../l2_block.js';
2
+ import type { L2BlockNew } from '../l2_block_new.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: L2Block[];
19
+ blocks: L2BlockNew[];
20
20
  }
21
21
  | /** Emits checkpoints published to L1. */ {
22
22
  type: 'chain-checkpointed';
@@ -19,12 +19,13 @@ export class L2BlockStream {
19
19
  constructor(
20
20
  private l2BlockSource: Pick<
21
21
  L2BlockSource,
22
- 'getBlocks' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpoints' | 'getCheckpointedBlocks'
22
+ 'getL2BlocksNew' | 'getBlockHeader' | 'getL2Tips' | 'getPublishedCheckpoints' | '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;
28
29
  pollIntervalMS?: number;
29
30
  batchSize?: number;
30
31
  startingBlock?: number;
@@ -128,7 +129,7 @@ export class L2BlockStream {
128
129
  if (!this.opts.ignoreCheckpoints) {
129
130
  let loop1Iterations = 0;
130
131
  while (nextCheckpointToEmit <= sourceTips.checkpointed.checkpoint.number) {
131
- const checkpoints = await this.l2BlockSource.getCheckpoints(nextCheckpointToEmit, 1);
132
+ const checkpoints = await this.l2BlockSource.getPublishedCheckpoints(nextCheckpointToEmit, 1);
132
133
  if (checkpoints.length === 0) {
133
134
  break;
134
135
  }
@@ -173,7 +174,7 @@ export class L2BlockStream {
173
174
  // Refill the prefetch buffer when exhausted
174
175
  if (prefetchIdx >= prefetchedCheckpoints.length) {
175
176
  const prefetchLimit = this.opts.checkpointPrefetchLimit ?? CHECKPOINT_PREFETCH_LIMIT;
176
- prefetchedCheckpoints = await this.l2BlockSource.getCheckpoints(nextCheckpointNumber, prefetchLimit);
177
+ prefetchedCheckpoints = await this.l2BlockSource.getPublishedCheckpoints(nextCheckpointNumber, prefetchLimit);
177
178
  prefetchIdx = 0;
178
179
  if (prefetchedCheckpoints.length === 0) {
179
180
  break;
@@ -212,8 +213,8 @@ export class L2BlockStream {
212
213
  // Loop 3: Fetch any remaining uncheckpointed (proposed) blocks.
213
214
  while (nextBlockNumber <= sourceTips.proposed.number) {
214
215
  const limit = Math.min(this.opts.batchSize ?? 50, sourceTips.proposed.number - nextBlockNumber + 1);
215
- this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit}`);
216
- const blocks = await this.l2BlockSource.getBlocks(BlockNumber(nextBlockNumber), BlockNumber(limit));
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);
217
218
  if (blocks.length === 0) {
218
219
  break;
219
220
  }
@@ -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 { L2Block } from '../l2_block.js';
5
+ import type { L2BlockNew } from '../l2_block_new.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: L2Block): Promise<string> {
112
+ protected computeBlockHash(block: L2BlockNew): 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,
9
8
  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<L2Block> => {
35
- const block = await L2Block.random(BlockNumber(number));
34
+ const makeBlock = async (number: number): Promise<L2BlockNew> => {
35
+ const block = await L2BlockNew.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: L2Block[]): Promise<PublishedCheckpoint> => {
77
+ const makeCheckpoint = async (checkpointNumber: number, blocks: L2BlockNew[]): 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 { L2Block } from '../block/l2_block.js';
16
+ import { L2BlockNew } from '../block/l2_block_new.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: L2Block[],
32
+ public blocks: L2BlockNew[],
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(L2Block.schema),
46
+ blocks: z.array(L2BlockNew.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(L2Block, MAX_BLOCKS_PER_CHECKPOINT),
65
+ reader.readVector(L2BlockNew, 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 L2Block.random>[1]> = {},
138
+ Partial<Parameters<typeof L2BlockNew.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: L2Block[] = [];
144
+ const blocks: L2BlockNew[] = [];
145
145
  let lastArchive = previousArchive;
146
146
  for (let i = 0; i < numBlocks; i++) {
147
- const block = await L2Block.random(BlockNumber(startBlockNumber + i), {
147
+ const block = await L2BlockNew.random(BlockNumber(startBlockNumber + i), {
148
148
  indexWithinCheckpoint: IndexWithinCheckpoint(i),
149
149
  ...options,
150
150
  ...(lastArchive ? { lastArchive } : {}),
@@ -21,7 +21,7 @@ export const nodeRpcConfigMappings: ConfigMappingsType<NodeRPCConfig> = {
21
21
  rpcMaxBodySize: {
22
22
  env: 'RPC_MAX_BODY_SIZE',
23
23
  description: 'Maximum allowed batch size for JSON RPC batch requests.',
24
- defaultValue: '1mb',
24
+ defaultValue: '50mb',
25
25
  },
26
26
  };
27
27
 
@@ -1,4 +1,5 @@
1
1
  import { FUNCTION_TREE_HEIGHT, GeneratorIndex } from '@aztec/constants';
2
+ import { pedersenHash } from '@aztec/foundation/crypto/pedersen';
2
3
  import { poseidon2Hash, poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import { type MerkleTree, MerkleTreeCalculator } from '@aztec/foundation/trees';
@@ -37,7 +38,7 @@ export async function computePrivateFunctionLeaf(fn: PrivateFunction): Promise<B
37
38
  async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator> {
38
39
  if (!privateFunctionTreeCalculator) {
39
40
  const functionTreeZeroLeaf = (
40
- await poseidon2Hash(new Array(PRIVATE_FUNCTION_SIZE).fill(0))
41
+ await pedersenHash(new Array(PRIVATE_FUNCTION_SIZE).fill(0))
41
42
  ).toBuffer() as Buffer<ArrayBuffer>;
42
43
  privateFunctionTreeCalculator = await MerkleTreeCalculator.create(
43
44
  FUNCTION_TREE_HEIGHT,
@@ -68,22 +68,23 @@ export class DelayedPublicMutableValues {
68
68
  }
69
69
 
70
70
  static async readFromTree(delayedPublicMutableSlot: Fr, readStorage: (storageSlot: Fr) => Promise<Fr>) {
71
- const fieldPromises = Array.from({ length: DELAYED_PUBLIC_MUTABLE_VALUES_LEN }).map((_, i) =>
72
- readStorage(delayedPublicMutableSlot.add(new Fr(i))),
73
- );
74
- return DelayedPublicMutableValues.fromFields(await Promise.all(fieldPromises));
71
+ const fields = [];
72
+ for (let i = 0; i < DELAYED_PUBLIC_MUTABLE_VALUES_LEN; i++) {
73
+ fields.push(await readStorage(delayedPublicMutableSlot.add(new Fr(i))));
74
+ }
75
+ return DelayedPublicMutableValues.fromFields(fields);
75
76
  }
76
77
 
77
78
  isEmpty(): boolean {
78
79
  return this.svc.isEmpty() && this.sdc.isEmpty();
79
80
  }
80
81
 
81
- writeToTree(delayedPublicMutableSlot: Fr, storageWrite: (storageSlot: Fr, value: Fr) => Promise<void>) {
82
- const fieldPromises = this.toFields().map((field, i) =>
83
- storageWrite(delayedPublicMutableSlot.add(new Fr(i)), field),
84
- );
82
+ async writeToTree(delayedPublicMutableSlot: Fr, storageWrite: (storageSlot: Fr, value: Fr) => Promise<void>) {
83
+ const fields = this.toFields();
85
84
 
86
- return Promise.all(fieldPromises);
85
+ for (let i = 0; i < fields.length; i++) {
86
+ await storageWrite(delayedPublicMutableSlot.add(new Fr(i)), fields[i]);
87
+ }
87
88
  }
88
89
 
89
90
  async hash(): Promise<Fr> {
@@ -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(Number(epochNumber) * constants.epochDuration);
72
+ const startSlot = SlotNumber(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 { L2Block } from '../block/l2_block.js';
8
+ import { L2BlockNew } from '../block/l2_block_new.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';
@@ -82,9 +82,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
82
82
  getRegistryAddress: z.function().args().returns(schemas.EthAddress),
83
83
  getBlockNumber: z.function().args().returns(BlockNumberSchema),
84
84
  getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
85
- getCheckpointedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
86
- getFinalizedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
87
- getBlock: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
85
+ getBlock: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
88
86
  getBlockHeader: z
89
87
  .function()
90
88
  .args(z.union([BlockNumberSchema, z.literal('latest')]))
@@ -92,28 +90,39 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
92
90
  getCheckpointedBlock: z.function().args(BlockNumberSchema).returns(CheckpointedL2Block.schema.optional()),
93
91
  getCheckpointedBlocks: z
94
92
  .function()
95
- .args(BlockNumberSchema, schemas.Integer)
93
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
96
94
  .returns(z.array(CheckpointedL2Block.schema)),
97
- getBlocks: z.function().args(BlockNumberSchema, schemas.Integer).returns(z.array(L2Block.schema)),
98
- getCheckpoints: z
95
+ getBlocks: z
96
+ .function()
97
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
98
+ .returns(z.array(L2BlockNew.schema)),
99
+ getPublishedCheckpoints: z
99
100
  .function()
100
101
  .args(CheckpointNumberSchema, schemas.Integer)
101
102
  .returns(z.array(PublishedCheckpoint.schema)),
102
- getCheckpointedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
103
- getCheckpointedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
103
+ getPublishedBlocks: z
104
+ .function()
105
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
106
+ .returns(z.array(CheckpointedL2Block.schema)),
107
+ getL2BlocksNew: z
108
+ .function()
109
+ .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
110
+ .returns(z.array(L2BlockNew.schema)),
111
+ getPublishedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
112
+ getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
104
113
  getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
105
114
  getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.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()),
115
+ getL2BlockNew: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
116
+ getL2BlockNewByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
117
+ getL2BlockNewByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
109
118
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
110
119
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
111
120
  getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
112
121
  getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
113
122
  getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.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)),
123
+ getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(L2BlockNew.schema)),
124
+ getBlocksForSlot: z.function().args(schemas.SlotNumber).returns(z.array(L2BlockNew.schema)),
125
+ getBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
117
126
  isEpochComplete: z.function().args(EpochNumberSchema).returns(z.boolean()),
118
127
  getL2Tips: z.function().args().returns(L2TipsSchema),
119
128
  getPrivateLogsByTags: z
@@ -23,11 +23,10 @@ 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';
27
26
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
28
27
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
29
28
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
30
- import { L2Block } from '../block/l2_block.js';
29
+ import { L2BlockNew } from '../block/l2_block_new.js';
31
30
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
32
31
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
33
32
  import {
@@ -78,7 +77,13 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
78
77
  export interface AztecNode
79
78
  extends Pick<
80
79
  L2BlockSource,
81
- 'getBlocks' | 'getCheckpoints' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpointedBlocks'
80
+ | 'getBlocks'
81
+ | 'getL2BlocksNew'
82
+ | 'getPublishedBlocks'
83
+ | 'getPublishedCheckpoints'
84
+ | 'getBlockHeader'
85
+ | 'getL2Tips'
86
+ | 'getCheckpointedBlocks'
82
87
  > {
83
88
  /**
84
89
  * Returns the tips of the L2 chain.
@@ -227,21 +232,21 @@ export interface AztecNode
227
232
  * @param number - The block number or 'latest'.
228
233
  * @returns The requested block.
229
234
  */
230
- getBlock(number: BlockParameter): Promise<L2Block | undefined>;
235
+ getBlock(number: BlockParameter): Promise<L2BlockNew | undefined>;
231
236
 
232
237
  /**
233
238
  * Get a block specified by its hash.
234
239
  * @param blockHash - The block hash being requested.
235
240
  * @returns The requested block.
236
241
  */
237
- getBlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
242
+ getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
238
243
 
239
244
  /**
240
245
  * Get a block specified by its archive root.
241
246
  * @param archive - The archive root being requested.
242
247
  * @returns The requested block.
243
248
  */
244
- getBlockByArchive(archive: Fr): Promise<L2Block | undefined>;
249
+ getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
245
250
 
246
251
  /**
247
252
  * Method to fetch the latest block number synchronized by the node.
@@ -255,12 +260,6 @@ export interface AztecNode
255
260
  */
256
261
  getProvenBlockNumber(): Promise<BlockNumber>;
257
262
 
258
- /**
259
- * Fetches the latest checkpointed block number.
260
- * @returns The block number.
261
- */
262
- getCheckpointedBlockNumber(): Promise<BlockNumber>;
263
-
264
263
  /**
265
264
  * Method to determine if the node is ready to accept transactions.
266
265
  * @returns - Flag indicating the readiness for tx submission.
@@ -280,7 +279,7 @@ export interface AztecNode
280
279
  * @param limit - The maximum number of blocks to return.
281
280
  * @returns The blocks requested.
282
281
  */
283
- getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
282
+ getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]>;
284
283
 
285
284
  /**
286
285
  * Method to fetch the current min fees.
@@ -348,14 +347,10 @@ export interface AztecNode
348
347
  * array implies no logs match that tag.
349
348
  * @param tags - The tags to search for.
350
349
  * @param page - The page number (0-indexed) for pagination.
351
- * @param referenceBlock - Optional block hash used to ensure the block still exists before logs are retrieved.
352
- * This block is expected to represent the latest block to which the client has synced (called anchor block in PXE).
353
- * If specified and the block is not found, an error is thrown. This helps detect reorgs, which could result in
354
- * undefined behavior in the client's code.
355
350
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
356
351
  * for a tag, the caller should fetch the next page to check for more logs.
357
352
  */
358
- getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: L2BlockHash): Promise<TxScopedL2Log[][]>;
353
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]>;
359
354
 
360
355
  /**
361
356
  * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
@@ -363,10 +358,6 @@ export interface AztecNode
363
358
  * @param contractAddress - The contract address to search logs for.
364
359
  * @param tags - The tags to search for.
365
360
  * @param page - The page number (0-indexed) for pagination.
366
- * @param referenceBlock - Optional block hash used to ensure the block still exists before logs are retrieved.
367
- * This block is expected to represent the latest block to which the client has synced (called anchor block in PXE).
368
- * If specified and the block is not found, an error is thrown. This helps detect reorgs, which could result in
369
- * undefined behavior in the client's code.
370
361
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
371
362
  * for a tag, the caller should fetch the next page to check for more logs.
372
363
  */
@@ -374,7 +365,6 @@ export interface AztecNode
374
365
  contractAddress: AztecAddress,
375
366
  tags: Tag[],
376
367
  page?: number,
377
- referenceBlock?: L2BlockHash,
378
368
  ): Promise<TxScopedL2Log[][]>;
379
369
 
380
370
  /**
@@ -577,18 +567,16 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
577
567
  .args(EpochNumberSchema)
578
568
  .returns(z.array(z.array(z.array(z.array(schemas.Fr))))),
579
569
 
580
- getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
570
+ getBlock: z.function().args(BlockParameterSchema).returns(L2BlockNew.schema.optional()),
581
571
 
582
- getBlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
572
+ getBlockByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
583
573
 
584
- getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
574
+ getBlockByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
585
575
 
586
576
  getBlockNumber: z.function().returns(BlockNumberSchema),
587
577
 
588
578
  getProvenBlockNumber: z.function().returns(BlockNumberSchema),
589
579
 
590
- getCheckpointedBlockNumber: z.function().returns(BlockNumberSchema),
591
-
592
580
  isReady: z.function().returns(z.boolean()),
593
581
 
594
582
  getNodeInfo: z.function().returns(NodeInfoSchema),
@@ -596,16 +584,26 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
596
584
  getBlocks: z
597
585
  .function()
598
586
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
599
- .returns(z.array(L2Block.schema)),
587
+ .returns(z.array(L2BlockNew.schema)),
600
588
 
601
- getCheckpoints: z
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
602
595
  .function()
603
596
  .args(CheckpointNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_CHECKPOINTS_LEN))
604
597
  .returns(z.array(PublishedCheckpoint.schema)),
605
598
 
606
- getCheckpointedBlocks: z
599
+ getL2BlocksNew: z
607
600
  .function()
608
601
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
602
+ .returns(z.array(L2BlockNew.schema)),
603
+
604
+ getCheckpointedBlocks: z
605
+ .function()
606
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN), optional(z.boolean()))
609
607
  .returns(z.array(CheckpointedL2Block.schema)),
610
608
 
611
609
  getCurrentMinFees: z.function().returns(GasFees.schema),
@@ -633,17 +631,12 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
633
631
 
634
632
  getPrivateLogsByTags: z
635
633
  .function()
636
- .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(L2BlockHash.schema))
634
+ .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)))
637
635
  .returns(z.array(z.array(TxScopedL2Log.schema))),
638
636
 
639
637
  getPublicLogsByTagsFromContract: z
640
638
  .function()
641
- .args(
642
- schemas.AztecAddress,
643
- z.array(Tag.schema).max(MAX_RPC_LEN),
644
- optional(z.number().gte(0)),
645
- optional(L2BlockHash.schema),
646
- )
639
+ .args(schemas.AztecAddress, z.array(Tag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)))
647
640
  .returns(z.array(z.array(TxScopedL2Log.schema))),
648
641
 
649
642
  sendTx: z.function().args(Tx.schema).returns(z.void()),