@aztec/stdlib 4.0.0-nightly.20260121 → 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 (105) 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 +37 -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 +6 -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 +37 -25
  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 +1 -2
  30. package/dest/epoch-helpers/index.js +1 -1
  31. package/dest/interfaces/api_limit.d.ts +2 -1
  32. package/dest/interfaces/api_limit.d.ts.map +1 -1
  33. package/dest/interfaces/api_limit.js +1 -0
  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 +17 -17
  37. package/dest/interfaces/aztec-node-admin.d.ts +4 -1
  38. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  39. package/dest/interfaces/aztec-node.d.ts +32 -14
  40. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  41. package/dest/interfaces/aztec-node.js +10 -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/l2_logs_source.d.ts +14 -5
  45. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  46. package/dest/interfaces/prover-client.d.ts +10 -1
  47. package/dest/interfaces/prover-client.d.ts.map +1 -1
  48. package/dest/interfaces/prover-client.js +7 -1
  49. package/dest/interfaces/tx_provider.d.ts +3 -3
  50. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  51. package/dest/p2p/block_proposal.d.ts +4 -4
  52. package/dest/p2p/block_proposal.d.ts.map +1 -1
  53. package/dest/p2p/block_proposal.js +1 -1
  54. package/dest/p2p/constants.d.ts +3 -0
  55. package/dest/p2p/constants.d.ts.map +1 -0
  56. package/dest/p2p/constants.js +2 -0
  57. package/dest/p2p/index.d.ts +2 -1
  58. package/dest/p2p/index.d.ts.map +1 -1
  59. package/dest/p2p/index.js +1 -0
  60. package/dest/tests/factories.js +1 -1
  61. package/dest/tests/jest.d.ts +4 -4
  62. package/dest/tests/jest.js +9 -9
  63. package/dest/tests/mocks.d.ts +10 -9
  64. package/dest/tests/mocks.d.ts.map +1 -1
  65. package/dest/tests/mocks.js +15 -10
  66. package/dest/tx/tx.d.ts +2 -1
  67. package/dest/tx/tx.d.ts.map +1 -1
  68. package/dest/tx/tx.js +6 -3
  69. package/dest/tx/tx_receipt.d.ts +39 -11
  70. package/dest/tx/tx_receipt.d.ts.map +1 -1
  71. package/dest/tx/tx_receipt.js +44 -13
  72. package/dest/tx/validator/error_texts.d.ts +2 -1
  73. package/dest/tx/validator/error_texts.d.ts.map +1 -1
  74. package/dest/tx/validator/error_texts.js +2 -0
  75. package/package.json +9 -9
  76. package/src/block/checkpointed_l2_block.ts +4 -4
  77. package/src/block/in_block.ts +2 -2
  78. package/src/block/index.ts +1 -1
  79. package/src/block/{l2_block_new.ts → l2_block.ts} +6 -11
  80. package/src/block/l2_block_source.ts +38 -30
  81. package/src/block/l2_block_stream/interfaces.ts +2 -2
  82. package/src/block/l2_block_stream/l2_block_stream.ts +44 -27
  83. package/src/block/l2_block_stream/l2_tips_store_base.ts +2 -2
  84. package/src/block/test/l2_tips_store_test_suite.ts +4 -4
  85. package/src/checkpoint/checkpoint.ts +7 -7
  86. package/src/config/node-rpc-config.ts +1 -1
  87. package/src/contract/private_function.ts +1 -2
  88. package/src/epoch-helpers/index.ts +1 -1
  89. package/src/interfaces/api_limit.ts +1 -0
  90. package/src/interfaces/archiver.ts +17 -26
  91. package/src/interfaces/aztec-node.ts +47 -35
  92. package/src/interfaces/block-builder.ts +3 -3
  93. package/src/interfaces/l2_logs_source.ts +17 -4
  94. package/src/interfaces/prover-client.ts +15 -0
  95. package/src/interfaces/tx_provider.ts +2 -2
  96. package/src/p2p/block_proposal.ts +3 -3
  97. package/src/p2p/constants.ts +3 -0
  98. package/src/p2p/index.ts +1 -0
  99. package/src/tests/factories.ts +1 -1
  100. package/src/tests/jest.ts +9 -9
  101. package/src/tests/mocks.ts +20 -13
  102. package/src/tx/tx.ts +8 -9
  103. package/src/tx/tx_receipt.ts +72 -15
  104. package/src/tx/validator/error_texts.ts +3 -0
  105. package/dest/block/l2_block_new.d.ts.map +0 -1
@@ -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.
@@ -343,16 +338,38 @@ export interface AztecNode
343
338
  getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse>;
344
339
 
345
340
  /**
346
- * Gets all private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
341
+ * Gets private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
347
342
  * array implies no logs match that tag.
343
+ * @param tags - The tags to search for.
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.
349
+ * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
350
+ * for a tag, the caller should fetch the next page to check for more logs.
348
351
  */
349
- getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
352
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: L2BlockHash): Promise<TxScopedL2Log[][]>;
350
353
 
351
354
  /**
352
- * Gets all public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
355
+ * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
353
356
  * logs is returned. An empty array implies no logs match that tag.
354
- */
355
- getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]>;
357
+ * @param contractAddress - The contract address to search logs for.
358
+ * @param tags - The tags to search for.
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.
364
+ * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
365
+ * for a tag, the caller should fetch the next page to check for more logs.
366
+ */
367
+ getPublicLogsByTagsFromContract(
368
+ contractAddress: AztecAddress,
369
+ tags: Tag[],
370
+ page?: number,
371
+ referenceBlock?: L2BlockHash,
372
+ ): Promise<TxScopedL2Log[][]>;
356
373
 
357
374
  /**
358
375
  * Method to submit a transaction to the p2p pool.
@@ -554,11 +571,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
554
571
  .args(EpochNumberSchema)
555
572
  .returns(z.array(z.array(z.array(z.array(schemas.Fr))))),
556
573
 
557
- getBlock: z.function().args(BlockParameterSchema).returns(L2BlockNew.schema.optional()),
574
+ getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
558
575
 
559
- getBlockByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
576
+ getBlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
560
577
 
561
- getBlockByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
578
+ getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
562
579
 
563
580
  getBlockNumber: z.function().returns(BlockNumberSchema),
564
581
 
@@ -571,26 +588,16 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
571
588
  getBlocks: z
572
589
  .function()
573
590
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
574
- .returns(z.array(L2BlockNew.schema)),
575
-
576
- getPublishedBlocks: z
577
- .function()
578
- .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
579
- .returns(z.array(CheckpointedL2Block.schema)),
591
+ .returns(z.array(L2Block.schema)),
580
592
 
581
- getPublishedCheckpoints: z
593
+ getCheckpoints: z
582
594
  .function()
583
595
  .args(CheckpointNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_CHECKPOINTS_LEN))
584
596
  .returns(z.array(PublishedCheckpoint.schema)),
585
597
 
586
- getL2BlocksNew: z
587
- .function()
588
- .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
589
- .returns(z.array(L2BlockNew.schema)),
590
-
591
598
  getCheckpointedBlocks: z
592
599
  .function()
593
- .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))
594
601
  .returns(z.array(CheckpointedL2Block.schema)),
595
602
 
596
603
  getCurrentMinFees: z.function().returns(GasFees.schema),
@@ -618,12 +625,17 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
618
625
 
619
626
  getPrivateLogsByTags: z
620
627
  .function()
621
- .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN))
628
+ .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(L2BlockHash.schema))
622
629
  .returns(z.array(z.array(TxScopedL2Log.schema))),
623
630
 
624
631
  getPublicLogsByTagsFromContract: z
625
632
  .function()
626
- .args(schemas.AztecAddress, z.array(Tag.schema).max(MAX_RPC_LEN))
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
+ )
627
639
  .returns(z.array(z.array(TxScopedL2Log.schema))),
628
640
 
629
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;
@@ -12,16 +12,29 @@ import type { GetContractClassLogsResponse, GetPublicLogsResponse } from './get_
12
12
  */
13
13
  export interface L2LogsSource {
14
14
  /**
15
- * Gets all private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
15
+ * Gets private logs that match any of the `tags`. For each tag, an array of matching logs is returned. An empty
16
16
  * array implies no logs match that tag.
17
+ * @param tags - The tags to search for.
18
+ * @param page - The page number (0-indexed) for pagination.
19
+ * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
20
+ * for a tag, the caller should fetch the next page to check for more logs.
17
21
  */
18
- getPrivateLogsByTags(tags: SiloedTag[]): Promise<TxScopedL2Log[][]>;
22
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]>;
19
23
 
20
24
  /**
21
- * Gets all public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
25
+ * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
22
26
  * logs is returned. An empty array implies no logs match that tag.
27
+ * @param contractAddress - The contract address to search logs for.
28
+ * @param tags - The tags to search for.
29
+ * @param page - The page number (0-indexed) for pagination.
30
+ * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
31
+ * for a tag, the caller should fetch the next page to check for more logs.
23
32
  */
24
- getPublicLogsByTagsFromContract(contractAddress: AztecAddress, tags: Tag[]): Promise<TxScopedL2Log[][]>;
33
+ getPublicLogsByTagsFromContract(
34
+ contractAddress: AztecAddress,
35
+ tags: Tag[],
36
+ page?: number,
37
+ ): Promise<TxScopedL2Log[][]>;
25
38
 
26
39
  /**
27
40
  * Gets public logs based on the provided filter.
@@ -17,6 +17,12 @@ export type ActualProverConfig = {
17
17
  proverTestDelayMs: number;
18
18
  /** If using realistic delays, what percentage of realistic times to apply. */
19
19
  proverTestDelayFactor: number;
20
+ /**
21
+ * Whether to abort pending proving jobs when the orchestrator is cancelled.
22
+ * When false (default), jobs remain in the broker queue and can be reused on restart/reorg.
23
+ * When true, jobs are explicitly cancelled with the broker, which prevents reuse.
24
+ */
25
+ cancelJobsOnStop: boolean;
20
26
  };
21
27
 
22
28
  /**
@@ -43,6 +49,7 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
43
49
  proverTestDelayFactor: z.number(),
44
50
  proverAgentCount: z.number(),
45
51
  failedProofStore: z.string().optional(),
52
+ cancelJobsOnStop: z.boolean(),
46
53
  }),
47
54
  );
48
55
 
@@ -85,6 +92,14 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
85
92
  description:
86
93
  'Store for failed proof inputs. Google cloud storage is only supported at the moment. Set this value as gs://bucket-name/path/to/store.',
87
94
  },
95
+ cancelJobsOnStop: {
96
+ env: 'PROVER_CANCEL_JOBS_ON_STOP',
97
+ description:
98
+ 'Whether to abort pending proving jobs when the orchestrator is cancelled. ' +
99
+ 'When false (default), jobs remain in the broker queue and can be reused on restart/reorg. ' +
100
+ 'When true, jobs are explicitly cancelled with the broker, which prevents reuse.',
101
+ ...booleanConfigHelper(false),
102
+ },
88
103
  };
89
104
 
90
105
  function parseProverId(str?: string) {
@@ -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
 
@@ -0,0 +1,3 @@
1
+ export const MAX_TX_SIZE_KB: number = 512;
2
+
3
+ export const MAX_MESSAGE_SIZE_KB: number = 10 * 1024;
package/src/p2p/index.ts CHANGED
@@ -11,3 +11,4 @@ export * from './topic_type.js';
11
11
  export * from './client_type.js';
12
12
  export * from './message_validator.js';
13
13
  export * from './peer_error.js';
14
+ export * from './constants.js';
@@ -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 },
package/src/tests/jest.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { L2BlockNew } from '../block/l2_block_new.js';
1
+ import { L2Block } from '../block/l2_block.js';
2
2
 
3
3
  /**
4
- * Checks if two objects are the same L2BlockNew.
4
+ * Checks if two objects are the same L2Block.
5
5
  *
6
- * Sometimes we might be comparing two L2BlockNew instances that represent the same block but one of them might not have
6
+ * Sometimes we might be comparing two L2Block instances that represent the same block but one of them might not have
7
7
  * calculated and filled its `blockHash` property (which is computed on demand). This function ensures both objects
8
- * are really the same L2BlockNew.
8
+ * are really the same L2Block.
9
9
  *
10
10
  * @param a - An object
11
11
  * @param b - Another object
12
- * @returns True if both a and b are the same L2BlockNew
12
+ * @returns True if both a and b are the same L2Block
13
13
  */
14
14
  export function equalL2Blocks(a: any, b: any) {
15
- const aAsL2Block = a && a instanceof L2BlockNew ? a : undefined;
16
- const bAsL2Block = b && b instanceof L2BlockNew ? b : undefined;
15
+ const aAsL2Block = a && a instanceof L2Block ? a : undefined;
16
+ const bAsL2Block = b && b instanceof L2Block ? b : undefined;
17
17
 
18
18
  if (aAsL2Block && bAsL2Block) {
19
- // we got two L2BlockNew instances, so we can compare them
19
+ // we got two L2Block instances, so we can compare them
20
20
  // use a custom comparator because the blockHash property is lazily computed and one instance might not have it
21
21
  return aAsL2Block.toBuffer().equals(bAsL2Block.toBuffer());
22
22
  } else if (aAsL2Block || bAsL2Block) {
23
- // one value is an L2BlockNew and the other isn't. Definitely not equal.
23
+ // one value is an L2Block and the other isn't. Definitely not equal.
24
24
  return false;
25
25
  } else {
26
26
  // we don't know what they are, tell Jest to keep looking
@@ -22,7 +22,7 @@ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
22
22
  import { PublicDataWrite } from '../avm/public_data_write.js';
23
23
  import { RevertCode } from '../avm/revert_code.js';
24
24
  import { AztecAddress } from '../aztec-address/index.js';
25
- import { CheckpointedL2Block, CommitteeAttestation, L2BlockNew } from '../block/index.js';
25
+ import { CheckpointedL2Block, CommitteeAttestation, L2Block } from '../block/index.js';
26
26
  import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
27
27
  import { Checkpoint } from '../checkpoint/checkpoint.js';
28
28
  import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
@@ -404,32 +404,37 @@ export async function mockCheckpointAndMessages(
404
404
  numL1ToL2Messages = 1,
405
405
  makeBlockOptions = () => ({}),
406
406
  previousArchive,
407
+ maxEffects,
407
408
  ...options
408
409
  }: {
409
410
  startBlockNumber?: BlockNumber;
410
411
  numBlocks?: number;
411
412
  numTxsPerBlock?: number;
412
413
  numL1ToL2Messages?: number;
413
- makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof L2BlockNew.random>[1]>;
414
+ makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof L2Block.random>[1]>;
414
415
  previousArchive?: AppendOnlyTreeSnapshot;
415
- blocks?: L2BlockNew[];
416
+ blocks?: L2Block[];
417
+ maxEffects?: number;
416
418
  } & Partial<Parameters<typeof Checkpoint.random>[1]> &
417
- Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
419
+ Partial<Parameters<typeof L2Block.random>[1]> = {},
418
420
  ) {
419
- const slotNumber = options.slotNumber ?? SlotNumber(checkpointNumber * 10);
421
+ const slotNumber = options.slotNumber ?? SlotNumber(Number(checkpointNumber) * 10);
420
422
  const blocksAndMessages = [];
421
423
  // Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
422
424
  // The current block's header.lastArchive must equal the previous block's archive.
423
425
  let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
426
+ // Pass maxEffects via txOptions so it reaches TxEffect.random
427
+ const txOptions = maxEffects !== undefined ? { maxEffects } : {};
424
428
  for (let i = 0; i < (blocks?.length ?? numBlocks); i++) {
425
429
  const blockNumber = BlockNumber(startBlockNumber + i);
426
430
  const { block, messages } = {
427
431
  block:
428
432
  blocks?.[i] ??
429
- (await L2BlockNew.random(blockNumber, {
433
+ (await L2Block.random(blockNumber, {
430
434
  checkpointNumber,
431
435
  indexWithinCheckpoint: IndexWithinCheckpoint(i),
432
436
  txsPerBlock: numTxsPerBlock,
437
+ txOptions,
433
438
  slotNumber,
434
439
  ...options,
435
440
  ...makeBlockOptions(blockNumber),
@@ -670,15 +675,15 @@ export const makeCheckpointAttestationFromCheckpoint = (
670
675
  };
671
676
 
672
677
  /**
673
- * Create a checkpoint attestation from an L2BlockNew
674
- * Note: This is a compatibility function for tests. L2BlockNew doesn't have a checkpoint header directly.
678
+ * Create a checkpoint attestation from an L2Block
679
+ * Note: This is a compatibility function for tests. L2Block doesn't have a checkpoint header directly.
675
680
  */
676
681
  export const makeCheckpointAttestationFromBlock = (
677
- block: L2BlockNew,
682
+ block: L2Block,
678
683
  attesterSigner?: Secp256k1Signer,
679
684
  proposerSigner?: Secp256k1Signer,
680
685
  ): CheckpointAttestation => {
681
- // For L2BlockNew, we create a minimal checkpoint header for testing purposes
686
+ // For L2Block, we create a minimal checkpoint header for testing purposes
682
687
  const header = CheckpointHeader.empty({
683
688
  lastArchiveRoot: block.header.lastArchive.root,
684
689
  slotNumber: block.slot,
@@ -694,7 +699,7 @@ export async function randomPublishedL2Block(
694
699
  l2BlockNumber: number,
695
700
  opts: { signers?: Secp256k1Signer[] } = {},
696
701
  ): Promise<CheckpointedL2Block> {
697
- const block = await L2BlockNew.random(BlockNumber(l2BlockNumber));
702
+ const block = await L2Block.random(BlockNumber(l2BlockNumber));
698
703
  const l1 = L1PublishedData.fromFields({
699
704
  blockNumber: BigInt(block.number),
700
705
  timestamp: block.header.globalVariables.timestamp,
@@ -702,7 +707,9 @@ export async function randomPublishedL2Block(
702
707
  });
703
708
 
704
709
  const signers = opts.signers ?? times(3, () => Secp256k1Signer.random());
705
- const checkpoint = await Checkpoint.random(CheckpointNumber(l2BlockNumber), { numBlocks: 0 });
710
+ const checkpoint = await Checkpoint.random(CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)), {
711
+ numBlocks: 0,
712
+ });
706
713
  checkpoint.blocks = [block];
707
714
  const atts = signers.map(signer =>
708
715
  makeCheckpointAttestation({
@@ -714,5 +721,5 @@ export async function randomPublishedL2Block(
714
721
  const attestations = atts.map(
715
722
  (attestation, i) => new CommitteeAttestation(signers[i].address, attestation.signature),
716
723
  );
717
- return new CheckpointedL2Block(CheckpointNumber(l2BlockNumber), block, l1, attestations);
724
+ return new CheckpointedL2Block(CheckpointNumber.fromBlockNumber(BlockNumber(l2BlockNumber)), block, l1, attestations);
718
725
  }
package/src/tx/tx.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
- import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection';
3
2
  import { Fr } from '@aztec/foundation/curves/bn254';
4
3
  import type { ZodFor } from '@aztec/foundation/schemas';
5
4
  import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
@@ -247,7 +246,7 @@ export class Tx extends Gossipable {
247
246
  contractClassLogSize: this.data.getEmittedContractClassLogsLength(),
248
247
 
249
248
  proofSize: this.chonkProof.fields.length,
250
- size: this.toBuffer().length,
249
+ size: this.getSize(),
251
250
 
252
251
  feePaymentMethod:
253
252
  // needsSetup? then we pay through a fee payment contract
@@ -255,13 +254,13 @@ export class Tx extends Gossipable {
255
254
  };
256
255
  }
257
256
 
258
- getSize() {
259
- return (
260
- this.data.getSize() +
261
- this.chonkProof.fields.length * Fr.SIZE_IN_BYTES +
262
- arraySerializedSizeOfNonEmpty(this.contractClassLogFields) +
263
- this.publicFunctionCalldata.reduce((accum, cd) => accum + cd.getSize(), 0)
264
- );
257
+ private sizeCache: number | undefined;
258
+
259
+ getSize(): number {
260
+ if (this.sizeCache == undefined) {
261
+ this.sizeCache = this.toBuffer().length;
262
+ }
263
+ return this.sizeCache;
265
264
  }
266
265
 
267
266
  /**
@@ -1,5 +1,4 @@
1
1
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
2
- import type { FieldsOf } from '@aztec/foundation/types';
3
2
 
4
3
  import { z } from 'zod';
5
4
 
@@ -8,12 +7,28 @@ import { L2BlockHash } from '../block/block_hash.js';
8
7
  import { type ZodFor, schemas } from '../schemas/schemas.js';
9
8
  import { TxHash } from './tx_hash.js';
10
9
 
11
- /**
12
- * Possible status of a transaction.
13
- */
10
+ /** Block inclusion/finalization status. */
14
11
  export enum TxStatus {
15
12
  DROPPED = 'dropped',
16
13
  PENDING = 'pending',
14
+ PROPOSED = 'proposed',
15
+ CHECKPOINTED = 'checkpointed',
16
+ PROVEN = 'proven',
17
+ FINALIZED = 'finalized', // TODO(#13569): Implement finalized status properly
18
+ }
19
+
20
+ /** Tx status sorted by finalization progress. */
21
+ export const SortedTxStatuses: TxStatus[] = [
22
+ TxStatus.DROPPED,
23
+ TxStatus.PENDING,
24
+ TxStatus.PROPOSED,
25
+ TxStatus.CHECKPOINTED,
26
+ TxStatus.PROVEN,
27
+ TxStatus.FINALIZED,
28
+ ];
29
+
30
+ /** Execution result - only set when tx is in a block. */
31
+ export enum TxExecutionResult {
17
32
  SUCCESS = 'success',
18
33
  APP_LOGIC_REVERTED = 'app_logic_reverted',
19
34
  TEARDOWN_REVERTED = 'teardown_reverted',
@@ -30,10 +45,12 @@ export class TxReceipt {
30
45
  constructor(
31
46
  /** A unique identifier for a transaction. */
32
47
  public txHash: TxHash,
33
- /** The transaction's status. */
48
+ /** The transaction's block finalization status. */
34
49
  public status: TxStatus,
50
+ /** The execution result of the transaction, only set when tx is in a block. */
51
+ public executionResult: TxExecutionResult | undefined,
35
52
  /** Description of transaction error, if any. */
36
- public error: string,
53
+ public error: string | undefined,
37
54
  /** The transaction fee paid for the transaction. */
38
55
  public transactionFee?: bigint,
39
56
  /** The hash of the block containing the transaction. */
@@ -42,8 +59,38 @@ export class TxReceipt {
42
59
  public blockNumber?: BlockNumber,
43
60
  ) {}
44
61
 
62
+ /** Returns true if the transaction was executed successfully. */
63
+ hasExecutionSucceeded(): boolean {
64
+ return this.executionResult === TxExecutionResult.SUCCESS;
65
+ }
66
+
67
+ /** Returns true if the transaction execution reverted. */
68
+ hasExecutionReverted(): boolean {
69
+ return this.executionResult !== undefined && this.executionResult !== TxExecutionResult.SUCCESS;
70
+ }
71
+
72
+ /** Returns true if the transaction has been included in a block (proposed, checkpointed, proven, or finalized). */
73
+ isMined(): boolean {
74
+ return (
75
+ this.status === TxStatus.PROPOSED ||
76
+ this.status === TxStatus.CHECKPOINTED ||
77
+ this.status === TxStatus.PROVEN ||
78
+ this.status === TxStatus.FINALIZED
79
+ );
80
+ }
81
+
82
+ /** Returns true if the transaction is pending. */
83
+ isPending(): boolean {
84
+ return this.status === TxStatus.PENDING;
85
+ }
86
+
87
+ /** Returns true if the transaction was dropped. */
88
+ isDropped(): boolean {
89
+ return this.status === TxStatus.DROPPED;
90
+ }
91
+
45
92
  static empty() {
46
- return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, '');
93
+ return new TxReceipt(TxHash.zero(), TxStatus.DROPPED, undefined, undefined);
47
94
  }
48
95
 
49
96
  static get schema(): ZodFor<TxReceipt> {
@@ -51,18 +98,28 @@ export class TxReceipt {
51
98
  .object({
52
99
  txHash: TxHash.schema,
53
100
  status: z.nativeEnum(TxStatus),
54
- error: z.string(),
101
+ executionResult: z.nativeEnum(TxExecutionResult).optional(),
102
+ error: z.string().optional(),
55
103
  blockHash: L2BlockHash.schema.optional(),
56
104
  blockNumber: BlockNumberSchema.optional(),
57
105
  transactionFee: schemas.BigInt.optional(),
58
106
  })
59
- .transform(TxReceipt.from);
107
+ .transform(fields => TxReceipt.from(fields));
60
108
  }
61
109
 
62
- static from(fields: FieldsOf<TxReceipt>) {
110
+ static from(fields: {
111
+ txHash: TxHash;
112
+ status: TxStatus;
113
+ executionResult?: TxExecutionResult;
114
+ error?: string;
115
+ transactionFee?: bigint;
116
+ blockHash?: L2BlockHash;
117
+ blockNumber?: BlockNumber;
118
+ }) {
63
119
  return new TxReceipt(
64
120
  fields.txHash,
65
121
  fields.status,
122
+ fields.executionResult,
66
123
  fields.error,
67
124
  fields.transactionFee,
68
125
  fields.blockHash,
@@ -70,15 +127,15 @@ export class TxReceipt {
70
127
  );
71
128
  }
72
129
 
73
- public static statusFromRevertCode(revertCode: RevertCode) {
130
+ public static executionResultFromRevertCode(revertCode: RevertCode): TxExecutionResult {
74
131
  if (revertCode.equals(RevertCode.OK)) {
75
- return TxStatus.SUCCESS;
132
+ return TxExecutionResult.SUCCESS;
76
133
  } else if (revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
77
- return TxStatus.APP_LOGIC_REVERTED;
134
+ return TxExecutionResult.APP_LOGIC_REVERTED;
78
135
  } else if (revertCode.equals(RevertCode.TEARDOWN_REVERTED)) {
79
- return TxStatus.TEARDOWN_REVERTED;
136
+ return TxExecutionResult.TEARDOWN_REVERTED;
80
137
  } else if (revertCode.equals(RevertCode.BOTH_REVERTED)) {
81
- return TxStatus.BOTH_REVERTED;
138
+ return TxExecutionResult.BOTH_REVERTED;
82
139
  } else {
83
140
  throw new Error(`Unknown revert code: ${revertCode.getCode()}`);
84
141
  }
@@ -31,6 +31,9 @@ export const TX_ERROR_CONTRACT_CLASS_LOGS = 'Mismatched contract class logs';
31
31
  export const TX_ERROR_CONTRACT_CLASS_LOG_SORTING = 'Incorrectly sorted contract class logs';
32
32
  export const TX_ERROR_INCORRECT_HASH = 'Incorrect tx hash';
33
33
 
34
+ // Size
35
+ export const TX_ERROR_SIZE_ABOVE_LIMIT = 'Transaction size above size limit';
36
+
34
37
  // Block header
35
38
  export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
36
39
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"l2_block_new.d.ts","sourceRoot":"","sources":["../../src/block/l2_block_new.ts"],"names":[],"mappings":"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"}