@aztec/stdlib 0.0.1-commit.3469e52 → 0.0.1-commit.54489865

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 (147) hide show
  1. package/dest/block/block_hash.d.ts +16 -18
  2. package/dest/block/block_hash.d.ts.map +1 -1
  3. package/dest/block/block_hash.js +21 -31
  4. package/dest/block/block_parameter.d.ts +4 -4
  5. package/dest/block/block_parameter.d.ts.map +1 -1
  6. package/dest/block/block_parameter.js +2 -2
  7. package/dest/block/checkpointed_l2_block.d.ts +6 -6
  8. package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
  9. package/dest/block/checkpointed_l2_block.js +3 -3
  10. package/dest/block/in_block.d.ts +11 -11
  11. package/dest/block/in_block.d.ts.map +1 -1
  12. package/dest/block/in_block.js +4 -4
  13. package/dest/block/index.d.ts +2 -2
  14. package/dest/block/index.d.ts.map +1 -1
  15. package/dest/block/index.js +1 -1
  16. package/dest/block/{l2_block_new.d.ts → l2_block.d.ts} +8 -7
  17. package/dest/block/l2_block.d.ts.map +1 -0
  18. package/dest/block/{l2_block_new.js → l2_block.js} +5 -9
  19. package/dest/block/l2_block_source.d.ts +39 -30
  20. package/dest/block/l2_block_source.d.ts.map +1 -1
  21. package/dest/block/l2_block_stream/interfaces.d.ts +3 -3
  22. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  23. package/dest/block/l2_block_stream/l2_block_stream.d.ts +2 -3
  24. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  25. package/dest/block/l2_block_stream/l2_block_stream.js +4 -4
  26. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +3 -3
  27. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  28. package/dest/block/test/l2_tips_store_test_suite.js +2 -2
  29. package/dest/checkpoint/checkpoint.d.ts +8 -8
  30. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  31. package/dest/checkpoint/checkpoint.js +4 -4
  32. package/dest/checkpoint/published_checkpoint.d.ts +2 -2
  33. package/dest/config/node-rpc-config.js +1 -1
  34. package/dest/contract/contract_address.js +1 -1
  35. package/dest/contract/contract_class_id.d.ts +1 -1
  36. package/dest/contract/contract_class_id.js +1 -1
  37. package/dest/contract/private_function.d.ts +1 -1
  38. package/dest/contract/private_function.d.ts.map +1 -1
  39. package/dest/contract/private_function.js +2 -3
  40. package/dest/contract/private_function_membership_proof.d.ts +1 -1
  41. package/dest/contract/private_function_membership_proof.js +1 -1
  42. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +2 -2
  43. package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -1
  44. package/dest/delayed_public_mutable/delayed_public_mutable_values.js +7 -10
  45. package/dest/epoch-helpers/index.d.ts +3 -1
  46. package/dest/epoch-helpers/index.d.ts.map +1 -1
  47. package/dest/epoch-helpers/index.js +5 -1
  48. package/dest/hash/hash.js +2 -2
  49. package/dest/hash/map_slot.d.ts +1 -1
  50. package/dest/hash/map_slot.d.ts.map +1 -1
  51. package/dest/hash/map_slot.js +4 -3
  52. package/dest/interfaces/archiver.d.ts +1 -1
  53. package/dest/interfaces/archiver.d.ts.map +1 -1
  54. package/dest/interfaces/archiver.js +17 -16
  55. package/dest/interfaces/aztec-node-admin.d.ts +4 -1
  56. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  57. package/dest/interfaces/aztec-node.d.ts +23 -9
  58. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  59. package/dest/interfaces/aztec-node.js +11 -11
  60. package/dest/interfaces/block-builder.d.ts +6 -5
  61. package/dest/interfaces/block-builder.d.ts.map +1 -1
  62. package/dest/interfaces/configs.d.ts +2 -2
  63. package/dest/interfaces/configs.d.ts.map +1 -1
  64. package/dest/interfaces/get_logs_response.d.ts +7 -7
  65. package/dest/interfaces/prover-client.d.ts +10 -1
  66. package/dest/interfaces/prover-client.d.ts.map +1 -1
  67. package/dest/interfaces/prover-client.js +7 -1
  68. package/dest/interfaces/tx_provider.d.ts +3 -3
  69. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  70. package/dest/interfaces/validator.d.ts +3 -3
  71. package/dest/interfaces/validator.d.ts.map +1 -1
  72. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
  73. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  74. package/dest/kernel/hints/build_nullifier_read_request_hints.js +4 -6
  75. package/dest/logs/extended_public_log.d.ts +6 -6
  76. package/dest/logs/log_id.d.ts +8 -8
  77. package/dest/logs/log_id.d.ts.map +1 -1
  78. package/dest/logs/log_id.js +6 -5
  79. package/dest/logs/siloed_tag.d.ts +1 -1
  80. package/dest/logs/siloed_tag.d.ts.map +1 -1
  81. package/dest/logs/siloed_tag.js +4 -3
  82. package/dest/p2p/block_proposal.d.ts +13 -6
  83. package/dest/p2p/block_proposal.d.ts.map +1 -1
  84. package/dest/p2p/block_proposal.js +1 -1
  85. package/dest/p2p/checkpoint_proposal.d.ts +10 -3
  86. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  87. package/dest/p2p/message_validator.d.ts +18 -3
  88. package/dest/p2p/message_validator.d.ts.map +1 -1
  89. package/dest/p2p/message_validator.js +2 -1
  90. package/dest/tests/factories.js +1 -1
  91. package/dest/tests/jest.d.ts +4 -4
  92. package/dest/tests/jest.js +9 -9
  93. package/dest/tests/mocks.d.ts +15 -10
  94. package/dest/tests/mocks.d.ts.map +1 -1
  95. package/dest/tests/mocks.js +19 -13
  96. package/dest/tx/block_header.d.ts +3 -2
  97. package/dest/tx/block_header.d.ts.map +1 -1
  98. package/dest/tx/block_header.js +3 -2
  99. package/dest/tx/in_tx.d.ts +3 -3
  100. package/dest/tx/indexed_tx_effect.d.ts +5 -5
  101. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  102. package/dest/tx/indexed_tx_effect.js +3 -2
  103. package/dest/tx/tx_receipt.d.ts +42 -14
  104. package/dest/tx/tx_receipt.d.ts.map +1 -1
  105. package/dest/tx/tx_receipt.js +46 -15
  106. package/package.json +9 -9
  107. package/src/block/block_hash.ts +26 -47
  108. package/src/block/block_parameter.ts +3 -3
  109. package/src/block/checkpointed_l2_block.ts +4 -4
  110. package/src/block/in_block.ts +7 -7
  111. package/src/block/index.ts +1 -1
  112. package/src/block/{l2_block_new.ts → l2_block.ts} +8 -12
  113. package/src/block/l2_block_source.ts +40 -31
  114. package/src/block/l2_block_stream/interfaces.ts +2 -2
  115. package/src/block/l2_block_stream/l2_block_stream.ts +5 -6
  116. package/src/block/l2_block_stream/l2_tips_store_base.ts +2 -2
  117. package/src/block/test/l2_tips_store_test_suite.ts +4 -4
  118. package/src/checkpoint/checkpoint.ts +7 -7
  119. package/src/config/node-rpc-config.ts +1 -1
  120. package/src/contract/contract_address.ts +1 -1
  121. package/src/contract/contract_class_id.ts +1 -1
  122. package/src/contract/private_function.ts +2 -3
  123. package/src/contract/private_function_membership_proof.ts +1 -1
  124. package/src/delayed_public_mutable/delayed_public_mutable_values.ts +9 -10
  125. package/src/epoch-helpers/index.ts +10 -1
  126. package/src/hash/hash.ts +2 -2
  127. package/src/hash/map_slot.ts +3 -2
  128. package/src/interfaces/archiver.ts +17 -25
  129. package/src/interfaces/aztec-node.ts +38 -31
  130. package/src/interfaces/block-builder.ts +5 -3
  131. package/src/interfaces/configs.ts +1 -3
  132. package/src/interfaces/prover-client.ts +15 -0
  133. package/src/interfaces/tx_provider.ts +2 -2
  134. package/src/interfaces/validator.ts +2 -4
  135. package/src/kernel/hints/build_nullifier_read_request_hints.ts +1 -10
  136. package/src/logs/log_id.ts +7 -6
  137. package/src/logs/siloed_tag.ts +3 -2
  138. package/src/p2p/block_proposal.ts +12 -5
  139. package/src/p2p/checkpoint_proposal.ts +9 -2
  140. package/src/p2p/message_validator.ts +14 -2
  141. package/src/tests/factories.ts +1 -1
  142. package/src/tests/jest.ts +9 -9
  143. package/src/tests/mocks.ts +26 -17
  144. package/src/tx/block_header.ts +7 -4
  145. package/src/tx/indexed_tx_effect.ts +3 -2
  146. package/src/tx/tx_receipt.ts +75 -18
  147. 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 { BlockHash } 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: BlockHash): 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.
@@ -260,6 +255,12 @@ export interface AztecNode
260
255
  */
261
256
  getProvenBlockNumber(): Promise<BlockNumber>;
262
257
 
258
+ /**
259
+ * Fetches the latest checkpointed block number.
260
+ * @returns The block number.
261
+ */
262
+ getCheckpointedBlockNumber(): Promise<BlockNumber>;
263
+
263
264
  /**
264
265
  * Method to determine if the node is ready to accept transactions.
265
266
  * @returns - Flag indicating the readiness for tx submission.
@@ -279,7 +280,7 @@ export interface AztecNode
279
280
  * @param limit - The maximum number of blocks to return.
280
281
  * @returns The blocks requested.
281
282
  */
282
- getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]>;
283
+ getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
283
284
 
284
285
  /**
285
286
  * Method to fetch the current min fees.
@@ -347,10 +348,14 @@ export interface AztecNode
347
348
  * array implies no logs match that tag.
348
349
  * @param tags - The tags to search for.
349
350
  * @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.
350
355
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
351
356
  * for a tag, the caller should fetch the next page to check for more logs.
352
357
  */
353
- getPrivateLogsByTags(tags: SiloedTag[], page?: number): Promise<TxScopedL2Log[][]>;
358
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: BlockHash): Promise<TxScopedL2Log[][]>;
354
359
 
355
360
  /**
356
361
  * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
@@ -358,6 +363,10 @@ export interface AztecNode
358
363
  * @param contractAddress - The contract address to search logs for.
359
364
  * @param tags - The tags to search for.
360
365
  * @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.
361
370
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
362
371
  * for a tag, the caller should fetch the next page to check for more logs.
363
372
  */
@@ -365,6 +374,7 @@ export interface AztecNode
365
374
  contractAddress: AztecAddress,
366
375
  tags: Tag[],
367
376
  page?: number,
377
+ referenceBlock?: BlockHash,
368
378
  ): Promise<TxScopedL2Log[][]>;
369
379
 
370
380
  /**
@@ -567,16 +577,18 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
567
577
  .args(EpochNumberSchema)
568
578
  .returns(z.array(z.array(z.array(z.array(schemas.Fr))))),
569
579
 
570
- getBlock: z.function().args(BlockParameterSchema).returns(L2BlockNew.schema.optional()),
580
+ getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
571
581
 
572
- getBlockByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
582
+ getBlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
573
583
 
574
- getBlockByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
584
+ getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
575
585
 
576
586
  getBlockNumber: z.function().returns(BlockNumberSchema),
577
587
 
578
588
  getProvenBlockNumber: z.function().returns(BlockNumberSchema),
579
589
 
590
+ getCheckpointedBlockNumber: z.function().returns(BlockNumberSchema),
591
+
580
592
  isReady: z.function().returns(z.boolean()),
581
593
 
582
594
  getNodeInfo: z.function().returns(NodeInfoSchema),
@@ -584,26 +596,16 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
584
596
  getBlocks: z
585
597
  .function()
586
598
  .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
587
- .returns(z.array(L2BlockNew.schema)),
599
+ .returns(z.array(L2Block.schema)),
588
600
 
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
601
+ getCheckpoints: z
595
602
  .function()
596
603
  .args(CheckpointNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_CHECKPOINTS_LEN))
597
604
  .returns(z.array(PublishedCheckpoint.schema)),
598
605
 
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
606
  getCheckpointedBlocks: z
605
607
  .function()
606
- .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN), optional(z.boolean()))
608
+ .args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
607
609
  .returns(z.array(CheckpointedL2Block.schema)),
608
610
 
609
611
  getCurrentMinFees: z.function().returns(GasFees.schema),
@@ -631,12 +633,17 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
631
633
 
632
634
  getPrivateLogsByTags: z
633
635
  .function()
634
- .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)))
636
+ .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(BlockHash.schema))
635
637
  .returns(z.array(z.array(TxScopedL2Log.schema))),
636
638
 
637
639
  getPublicLogsByTagsFromContract: z
638
640
  .function()
639
- .args(schemas.AztecAddress, z.array(Tag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)))
641
+ .args(
642
+ schemas.AztecAddress,
643
+ z.array(Tag.schema).max(MAX_RPC_LEN),
644
+ optional(z.number().gte(0)),
645
+ optional(BlockHash.schema),
646
+ )
640
647
  .returns(z.array(z.array(TxScopedL2Log.schema))),
641
648
 
642
649
  sendTx: z.function().args(Tx.schema).returns(z.void()),
@@ -1,7 +1,8 @@
1
1
  import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
2
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { LoggerBindings } from '@aztec/foundation/log';
3
4
 
4
- import type { L2BlockNew } from '../block/l2_block_new.js';
5
+ import type { L2Block } from '../block/l2_block.js';
5
6
  import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
6
7
  import type { L1RollupConstants } from '../epoch-helpers/index.js';
7
8
  import type { Gas } from '../gas/gas.js';
@@ -31,7 +32,7 @@ export interface IBlockFactory extends ProcessedTxHandler {
31
32
  /**
32
33
  * Assembles the block and updates the archive tree.
33
34
  */
34
- setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2BlockNew>;
35
+ setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2Block>;
35
36
  }
36
37
 
37
38
  export interface PublicProcessorLimits {
@@ -63,7 +64,7 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
63
64
 
64
65
  /** Result of building a block within a checkpoint. */
65
66
  export interface BuildBlockInCheckpointResult {
66
- block: L2BlockNew;
67
+ block: L2Block;
67
68
  publicGas: Gas;
68
69
  publicProcessorDuration: number;
69
70
  numTxs: number;
@@ -92,5 +93,6 @@ export interface ICheckpointsBuilder {
92
93
  l1ToL2Messages: Fr[],
93
94
  previousCheckpointOutHashes: Fr[],
94
95
  fork: MerkleTreeWriteOperations,
96
+ bindings?: LoggerBindings,
95
97
  ): Promise<ICheckpointBlockBuilder>;
96
98
  }
@@ -67,9 +67,7 @@ export interface SequencerConfig {
67
67
  blockDurationMs?: number;
68
68
  /** Have sequencer build and publish an empty checkpoint if there are no txs */
69
69
  buildCheckpointIfEmpty?: boolean;
70
-
71
- // TODO(palla/mbps): Change default to false once block sync is stable
72
- /** Skip pushing proposed blocks to archiver (default: true) */
70
+ /** Skip pushing proposed blocks to archiver (default: false) */
73
71
  skipPushProposedBlocksToArchiver?: boolean;
74
72
  }
75
73
 
@@ -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
  }
@@ -51,12 +51,10 @@ export type ValidatorClientConfig = ValidatorHASignerConfig & {
51
51
  /** Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus */
52
52
  fishermanMode?: boolean;
53
53
 
54
- // TODO(palla/mbps): Change default to false once checkpoint validation is stable
55
- /** Skip checkpoint proposal validation and always attest (default: true) */
54
+ /** Skip checkpoint proposal validation and always attest (default: false) */
56
55
  skipCheckpointProposalValidation?: boolean;
57
56
 
58
- // TODO(palla/mbps): Change default to false once block sync is stable
59
- /** Skip pushing re-executed blocks to archiver (default: true) */
57
+ /** Skip pushing re-executed blocks to archiver (default: false) */
60
58
  skipPushProposedBlocksToArchiver?: boolean;
61
59
  };
62
60
 
@@ -6,7 +6,6 @@ import {
6
6
  import type { Fr } from '@aztec/foundation/curves/bn254';
7
7
  import { MembershipWitness } from '@aztec/foundation/trees';
8
8
 
9
- import { siloNullifier } from '../../hash/hash.js';
10
9
  import type { NullifierLeafPreimage } from '../../trees/nullifier_leaf.js';
11
10
  import type { ClaimedLengthArray } from '../claimed_length_array.js';
12
11
  import type { ScopedNullifier } from '../nullifier.js';
@@ -74,7 +73,6 @@ export async function buildNullifierReadRequestHintsFromResetActions<PENDING ext
74
73
  resetActions: ReadRequestResetActions<typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
75
74
  maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
76
75
  maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
77
- siloed = false,
78
76
  ) {
79
77
  const builder = new NullifierReadRequestHintsBuilder(maxPending, maxSettled);
80
78
 
@@ -90,12 +88,7 @@ export async function buildNullifierReadRequestHintsFromResetActions<PENDING ext
90
88
  }
91
89
  }
92
90
 
93
- // Compute siloed values in parallel (if not already siloed)
94
- const siloedValues = siloed
95
- ? settledRequests.map(({ readRequest }) => readRequest.value)
96
- : await Promise.all(
97
- settledRequests.map(({ readRequest }) => siloNullifier(readRequest.contractAddress, readRequest.value)),
98
- );
91
+ const siloedValues = settledRequests.map(({ readRequest }) => readRequest.value);
99
92
 
100
93
  // Fetch all membership witnesses in parallel
101
94
  const membershipWitnesses = await Promise.all(siloedValues.map(value => oracle.getNullifierMembershipWitness(value)));
@@ -121,7 +114,6 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
121
114
  futureNullifiers: ScopedNullifier[],
122
115
  maxPending: PENDING = MAX_NULLIFIER_READ_REQUESTS_PER_TX as PENDING,
123
116
  maxSettled: SETTLED = MAX_NULLIFIER_READ_REQUESTS_PER_TX as SETTLED,
124
- siloed = false,
125
117
  ) {
126
118
  const resetActions = getNullifierReadRequestResetActions(nullifierReadRequests, nullifiers, futureNullifiers);
127
119
  return await buildNullifierReadRequestHintsFromResetActions(
@@ -130,6 +122,5 @@ export async function buildNullifierReadRequestHints<PENDING extends number, SET
130
122
  resetActions,
131
123
  maxPending,
132
124
  maxSettled,
133
- siloed,
134
125
  );
135
126
  }
@@ -1,11 +1,12 @@
1
1
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
2
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
3
3
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import { BufferReader } from '@aztec/foundation/serialize';
5
6
 
6
7
  import { z } from 'zod';
7
8
 
8
- import { L2BlockHash } from '../block/block_hash.js';
9
+ import { BlockHash } from '../block/block_hash.js';
9
10
  import { schemas } from '../schemas/index.js';
10
11
 
11
12
  /** A globally unique log id. */
@@ -20,7 +21,7 @@ export class LogId {
20
21
  /** The block number the log was emitted in. */
21
22
  public readonly blockNumber: BlockNumber,
22
23
  /** The hash of the block the log was emitted in. */
23
- public readonly blockHash: L2BlockHash,
24
+ public readonly blockHash: BlockHash,
24
25
  /** The index of a tx in a block the log was emitted in. */
25
26
  public readonly txIndex: number,
26
27
  /** The index of a log the tx was emitted in. */
@@ -40,7 +41,7 @@ export class LogId {
40
41
  static random() {
41
42
  return new LogId(
42
43
  BlockNumber(Math.floor(Math.random() * 1000) + 1),
43
- L2BlockHash.random(),
44
+ BlockHash.random(),
44
45
  Math.floor(Math.random() * 1000),
45
46
  Math.floor(Math.random() * 100),
46
47
  );
@@ -50,7 +51,7 @@ export class LogId {
50
51
  return z
51
52
  .object({
52
53
  blockNumber: BlockNumberSchema,
53
- blockHash: L2BlockHash.schema,
54
+ blockHash: BlockHash.schema,
54
55
  txIndex: schemas.Integer,
55
56
  logIndex: schemas.Integer,
56
57
  })
@@ -81,7 +82,7 @@ export class LogId {
81
82
  const reader = BufferReader.asReader(buffer);
82
83
 
83
84
  const blockNumber = BlockNumber(reader.readNumber());
84
- const blockHash = reader.readObject(L2BlockHash);
85
+ const blockHash = new BlockHash(reader.readObject(Fr));
85
86
  const txIndex = reader.readNumber();
86
87
  const logIndex = reader.readNumber();
87
88
 
@@ -104,7 +105,7 @@ export class LogId {
104
105
  static fromString(data: string): LogId {
105
106
  const [rawBlockNumber, rawTxIndex, rawLogIndex, rawBlockHash] = data.split('-');
106
107
  const blockNumber = BlockNumber(Number(rawBlockNumber));
107
- const blockHash = L2BlockHash.fromString(rawBlockHash);
108
+ const blockHash = BlockHash.fromString(rawBlockHash);
108
109
  const txIndex = Number(rawTxIndex);
109
110
  const logIndex = Number(rawLogIndex);
110
111
 
@@ -1,4 +1,5 @@
1
- import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
1
+ import { GeneratorIndex } from '@aztec/constants';
2
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
2
3
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
4
  import type { ZodFor } from '@aztec/foundation/schemas';
4
5
 
@@ -22,7 +23,7 @@ export class SiloedTag {
22
23
  constructor(public readonly value: Fr) {}
23
24
 
24
25
  static async compute(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
25
- const siloedTag = await poseidon2Hash([app, tag.value]);
26
+ const siloedTag = await poseidon2HashWithSeparator([app, tag.value], GeneratorIndex.PRIVATE_LOG_FIRST_FIELD);
26
27
  return new SiloedTag(siloedTag);
27
28
  }
28
29
 
@@ -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';
@@ -30,8 +30,15 @@ export class BlockProposalHash extends Buffer32 {
30
30
  }
31
31
 
32
32
  export type BlockProposalOptions = {
33
- publishFullTxs: boolean;
34
- /** Whether to generate an invalid block proposal for broadcasting. Use only for testing. */
33
+ /**
34
+ * Whether to include the tx objects along with the block proposal.
35
+ * Dramatically increases size of the payload but eliminates failed reexecutions due to missing txs.
36
+ */
37
+ publishFullTxs?: boolean;
38
+ /**
39
+ * Whether to generate an invalid block proposal for broadcasting.
40
+ * Use only for testing.
41
+ */
35
42
  broadcastInvalidBlockProposal?: boolean;
36
43
  };
37
44
 
@@ -284,10 +291,10 @@ export class BlockProposal extends Gossipable {
284
291
  /**
285
292
  * Check if this proposal matches the given block.
286
293
  * Compares the archive root and block header.
287
- * @param block - The L2BlockNew to compare against
294
+ * @param block - The L2Block to compare against
288
295
  * @returns True if the proposal matches the block
289
296
  */
290
- matchesBlock(block: L2BlockNew): boolean {
297
+ matchesBlock(block: L2Block): boolean {
291
298
  return this.archiveRoot.equals(block.archive.root) && this.blockHeader.equals(block.header);
292
299
  }
293
300
 
@@ -32,8 +32,15 @@ export class CheckpointProposalHash extends Buffer32 {
32
32
  }
33
33
 
34
34
  export type CheckpointProposalOptions = {
35
- publishFullTxs: boolean;
36
- /** Whether to generate an invalid checkpoint proposal for broadcasting. Use only for testing. */
35
+ /**
36
+ * Whether to include the tx objects along with the block proposal.
37
+ * Dramatically increases size of the payload but eliminates failed reexecutions due to missing txs.
38
+ */
39
+ publishFullTxs?: boolean;
40
+ /**
41
+ * Whether to generate an invalid checkpoint proposal for broadcasting.
42
+ * Use only for testing.
43
+ */
37
44
  broadcastInvalidCheckpointProposal?: boolean;
38
45
  };
39
46
 
@@ -1,10 +1,22 @@
1
1
  import type { PeerErrorSeverity } from './peer_error.js';
2
2
 
3
+ /**
4
+ * Result of validating a P2P message.
5
+ * - 'accept': Message is valid and should be accepted and processed
6
+ * - 'ignore': Message should be ignored (not propagated or processed, but sender not penalized)
7
+ * - 'reject': Message is invalid (rejected and sender penalized)
8
+ */
9
+ export type ValidationResult =
10
+ | { result: 'accept' }
11
+ | { result: 'ignore' }
12
+ | { result: 'reject'; severity: PeerErrorSeverity };
13
+
3
14
  /**
4
15
  * P2PValidator
5
16
  *
6
- * A validator for P2P messages, which returns a severity of error to be applied to the peer
17
+ * A validator for P2P messages, which returns a ValidationResult indicating
18
+ * whether to accept, ignore, or reject the message
7
19
  */
8
20
  export interface P2PValidator<T> {
9
- validate(message: T): Promise<PeerErrorSeverity | undefined>;
21
+ validate(message: T): Promise<ValidationResult>;
10
22
  }
@@ -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