@aztec/stdlib 0.0.1-commit.e61ad554 → 0.0.1-commit.ee80a48

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 (120) hide show
  1. package/dest/block/block_hash.d.ts +16 -19
  2. package/dest/block/block_hash.d.ts.map +1 -1
  3. package/dest/block/block_hash.js +21 -34
  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/in_block.d.ts +9 -9
  8. package/dest/block/in_block.d.ts.map +1 -1
  9. package/dest/block/in_block.js +4 -4
  10. package/dest/block/l2_block.d.ts +3 -2
  11. package/dest/block/l2_block.d.ts.map +1 -1
  12. package/dest/block/l2_block.js +2 -3
  13. package/dest/block/l2_block_source.d.ts +5 -4
  14. package/dest/block/l2_block_source.d.ts.map +1 -1
  15. package/dest/contract/contract_address.js +1 -1
  16. package/dest/contract/contract_class_id.d.ts +1 -1
  17. package/dest/contract/contract_class_id.js +1 -1
  18. package/dest/contract/private_function.js +1 -1
  19. package/dest/contract/private_function_membership_proof.d.ts +1 -1
  20. package/dest/contract/private_function_membership_proof.js +1 -1
  21. package/dest/database-version/database_version.d.ts +58 -0
  22. package/dest/database-version/database_version.d.ts.map +1 -0
  23. package/dest/database-version/database_version.js +69 -0
  24. package/dest/database-version/version_manager.d.ts +2 -50
  25. package/dest/database-version/version_manager.d.ts.map +1 -1
  26. package/dest/database-version/version_manager.js +1 -66
  27. package/dest/epoch-helpers/index.d.ts +3 -1
  28. package/dest/epoch-helpers/index.d.ts.map +1 -1
  29. package/dest/epoch-helpers/index.js +4 -0
  30. package/dest/hash/hash.js +2 -2
  31. package/dest/hash/map_slot.d.ts +1 -1
  32. package/dest/hash/map_slot.d.ts.map +1 -1
  33. package/dest/hash/map_slot.js +4 -3
  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 +4 -3
  37. package/dest/interfaces/aztec-node-admin.d.ts +2 -2
  38. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  39. package/dest/interfaces/aztec-node-admin.js +3 -1
  40. package/dest/interfaces/aztec-node.d.ts +33 -54
  41. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  42. package/dest/interfaces/aztec-node.js +6 -10
  43. package/dest/interfaces/block-builder.d.ts +10 -4
  44. package/dest/interfaces/block-builder.d.ts.map +1 -1
  45. package/dest/interfaces/block-builder.js +7 -0
  46. package/dest/interfaces/get_logs_response.d.ts +7 -7
  47. package/dest/interfaces/validator.d.ts +28 -2
  48. package/dest/interfaces/validator.d.ts.map +1 -1
  49. package/dest/keys/derivation.d.ts +3 -3
  50. package/dest/keys/derivation.js +8 -8
  51. package/dest/keys/key_types.d.ts +1 -1
  52. package/dest/keys/utils.d.ts +1 -1
  53. package/dest/keys/utils.d.ts.map +1 -1
  54. package/dest/keys/utils.js +7 -3
  55. package/dest/l1-contracts/slash_factory.d.ts +1 -1
  56. package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
  57. package/dest/l1-contracts/slash_factory.js +1 -0
  58. package/dest/logs/extended_public_log.d.ts +6 -6
  59. package/dest/logs/log_id.d.ts +8 -8
  60. package/dest/logs/log_id.d.ts.map +1 -1
  61. package/dest/logs/log_id.js +6 -5
  62. package/dest/logs/siloed_tag.d.ts +1 -1
  63. package/dest/logs/siloed_tag.d.ts.map +1 -1
  64. package/dest/logs/siloed_tag.js +4 -3
  65. package/dest/p2p/block_proposal.d.ts +10 -3
  66. package/dest/p2p/block_proposal.d.ts.map +1 -1
  67. package/dest/p2p/checkpoint_proposal.d.ts +10 -3
  68. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  69. package/dest/stats/stats.d.ts +1 -3
  70. package/dest/stats/stats.d.ts.map +1 -1
  71. package/dest/tests/mocks.d.ts +6 -2
  72. package/dest/tests/mocks.d.ts.map +1 -1
  73. package/dest/tests/mocks.js +4 -3
  74. package/dest/tx/block_header.d.ts +3 -3
  75. package/dest/tx/block_header.d.ts.map +1 -1
  76. package/dest/tx/block_header.js +3 -3
  77. package/dest/tx/in_tx.d.ts +3 -3
  78. package/dest/tx/indexed_tx_effect.d.ts +5 -5
  79. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  80. package/dest/tx/indexed_tx_effect.js +3 -2
  81. package/dest/tx/tx_receipt.d.ts +5 -5
  82. package/dest/tx/tx_receipt.d.ts.map +1 -1
  83. package/dest/tx/tx_receipt.js +2 -2
  84. package/package.json +11 -10
  85. package/src/block/block_hash.ts +25 -50
  86. package/src/block/block_parameter.ts +3 -3
  87. package/src/block/in_block.ts +5 -5
  88. package/src/block/l2_block.ts +3 -3
  89. package/src/block/l2_block_source.ts +4 -3
  90. package/src/contract/contract_address.ts +1 -1
  91. package/src/contract/contract_class_id.ts +1 -1
  92. package/src/contract/private_function.ts +1 -1
  93. package/src/contract/private_function_membership_proof.ts +1 -1
  94. package/src/database-version/database_version.ts +87 -0
  95. package/src/database-version/version_manager.ts +1 -77
  96. package/src/epoch-helpers/index.ts +9 -0
  97. package/src/hash/hash.ts +2 -2
  98. package/src/hash/map_slot.ts +3 -2
  99. package/src/interfaces/archiver.ts +4 -3
  100. package/src/interfaces/aztec-node-admin.ts +3 -2
  101. package/src/interfaces/aztec-node.ts +42 -93
  102. package/src/interfaces/block-builder.ts +12 -2
  103. package/src/interfaces/validator.ts +1 -2
  104. package/src/keys/derivation.ts +8 -8
  105. package/src/keys/key_types.ts +1 -1
  106. package/src/keys/utils.ts +7 -3
  107. package/src/l1-contracts/slash_factory.ts +1 -0
  108. package/src/logs/log_id.ts +7 -6
  109. package/src/logs/siloed_tag.ts +3 -2
  110. package/src/p2p/block_proposal.ts +9 -2
  111. package/src/p2p/checkpoint_proposal.ts +9 -2
  112. package/src/stats/stats.ts +0 -2
  113. package/src/tests/mocks.ts +6 -4
  114. package/src/tx/block_header.ts +6 -6
  115. package/src/tx/indexed_tx_effect.ts +3 -2
  116. package/src/tx/tx_receipt.ts +4 -4
  117. package/dest/database-version/index.d.ts +0 -2
  118. package/dest/database-version/index.d.ts.map +0 -1
  119. package/dest/database-version/index.js +0 -1
  120. package/src/database-version/index.ts +0 -1
@@ -1,10 +1,4 @@
1
- import {
2
- ARCHIVE_HEIGHT,
3
- L1_TO_L2_MSG_TREE_HEIGHT,
4
- NOTE_HASH_TREE_HEIGHT,
5
- NULLIFIER_TREE_HEIGHT,
6
- PUBLIC_DATA_TREE_HEIGHT,
7
- } from '@aztec/constants';
1
+ import { ARCHIVE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
8
2
  import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum/l1-contract-addresses';
9
3
  import {
10
4
  BlockNumber,
@@ -23,7 +17,7 @@ import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
23
17
  import { z } from 'zod';
24
18
 
25
19
  import type { AztecAddress } from '../aztec-address/index.js';
26
- import { L2BlockHash } from '../block/block_hash.js';
20
+ import { BlockHash } from '../block/block_hash.js';
27
21
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
28
22
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
29
23
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
@@ -93,63 +87,31 @@ export interface AztecNode
93
87
  /**
94
88
  * Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
95
89
  * the leaves were inserted.
96
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
90
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
97
91
  * @param treeId - The tree to search in.
98
92
  * @param leafValues - The values to search for.
99
93
  * @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
100
94
  */
101
95
  findLeavesIndexes(
102
- block: BlockParameter,
96
+ referenceBlock: BlockParameter,
103
97
  treeId: MerkleTreeId,
104
98
  leafValues: Fr[],
105
99
  ): Promise<(DataInBlock<bigint> | undefined)[]>;
106
100
 
107
- /**
108
- * Returns a sibling path for the given index in the nullifier tree.
109
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
110
- * @param leafIndex - The index of the leaf for which the sibling path is required.
111
- * @returns The sibling path for the leaf index.
112
- */
113
- getNullifierSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>>;
114
-
115
- /**
116
- * Returns a sibling path for the given index in the note hash tree.
117
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
118
- * @param leafIndex - The index of the leaf for which the sibling path is required.
119
- * @returns The sibling path for the leaf index.
120
- */
121
- getNoteHashSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>>;
122
-
123
- /**
124
- * Returns a sibling path for a leaf in the committed historic blocks tree.
125
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
126
- * @param leafIndex - Index of the leaf in the tree.
127
- * @returns The sibling path.
128
- */
129
- getArchiveSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>>;
130
-
131
- /**
132
- * Returns a sibling path for a leaf in the committed public data tree.
133
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
134
- * @param leafIndex - Index of the leaf in the tree.
135
- * @returns The sibling path.
136
- */
137
- getPublicDataSiblingPath(
138
- block: BlockParameter,
139
- leafIndex: bigint,
140
- ): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>>;
141
-
142
101
  /**
143
102
  * Returns a nullifier membership witness for a given nullifier at a given block.
144
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
103
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
145
104
  * @param nullifier - Nullifier we try to find witness for.
146
105
  * @returns The nullifier membership witness (if found).
147
106
  */
148
- getNullifierMembershipWitness(block: BlockParameter, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
107
+ getNullifierMembershipWitness(
108
+ referenceBlock: BlockParameter,
109
+ nullifier: Fr,
110
+ ): Promise<NullifierMembershipWitness | undefined>;
149
111
 
150
112
  /**
151
113
  * Returns a low nullifier membership witness for a given nullifier at a given block.
152
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
114
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
153
115
  * @param nullifier - Nullifier we try to find the low nullifier witness for.
154
116
  * @returns The low nullifier membership witness (if found).
155
117
  * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
@@ -157,49 +119,56 @@ export interface AztecNode
157
119
  * we are trying to prove non-inclusion for.
158
120
  */
159
121
  getLowNullifierMembershipWitness(
160
- block: BlockParameter,
122
+ referenceBlock: BlockParameter,
161
123
  nullifier: Fr,
162
124
  ): Promise<NullifierMembershipWitness | undefined>;
163
125
 
164
126
  /**
165
127
  * Returns a public data tree witness for a given leaf slot at a given block.
166
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
128
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
167
129
  * @param leafSlot - The leaf slot we try to find the witness for.
168
130
  * @returns The public data witness (if found).
169
131
  * @remarks The witness can be used to compute the current value of the public data tree leaf. If the low leaf preimage corresponds to an
170
132
  * "in range" slot, means that the slot doesn't exist and the value is 0. If the low leaf preimage corresponds to the exact slot, the current value
171
133
  * is contained in the leaf preimage.
172
134
  */
173
- getPublicDataWitness(block: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
135
+ getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
174
136
 
175
137
  /**
176
- * Returns a membership witness for a given archive leaf at a given block.
177
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
178
- * @param archive - The archive leaf we try to find the witness for.
138
+ * Returns a membership witness for a given block hash in the archive tree.
139
+ *
140
+ * Block hashes are the leaves of the archive tree. Each time a new block is added to the chain,
141
+ * its block hash is appended as a new leaf to the archive tree. This method finds the membership
142
+ * witness (leaf index and sibling path) for a given block hash, which can be used to prove that
143
+ * a specific block exists in the chain's history.
144
+ *
145
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
146
+ * (which contains the root of the archive tree in which we are searching for the block hash).
147
+ * @param blockHash - The block hash to find in the archive tree.
179
148
  */
180
- getArchiveMembershipWitness(
181
- block: BlockParameter,
182
- archive: Fr,
149
+ getBlockHashMembershipWitness(
150
+ referenceBlock: BlockParameter,
151
+ blockHash: BlockHash,
183
152
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
184
153
 
185
154
  /**
186
155
  * Returns a membership witness for a given note hash at a given block.
187
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
156
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
188
157
  * @param noteHash - The note hash we try to find the witness for.
189
158
  */
190
159
  getNoteHashMembershipWitness(
191
- block: BlockParameter,
160
+ referenceBlock: BlockParameter,
192
161
  noteHash: Fr,
193
162
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
194
163
 
195
164
  /**
196
165
  * Returns the index and a sibling path for a leaf in the committed l1 to l2 data tree.
197
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
166
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
198
167
  * @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
199
168
  * @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
200
169
  */
201
170
  getL1ToL2MessageMembershipWitness(
202
- block: BlockParameter,
171
+ referenceBlock: BlockParameter,
203
172
  l1ToL2Message: Fr,
204
173
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
205
174
 
@@ -224,17 +193,17 @@ export interface AztecNode
224
193
 
225
194
  /**
226
195
  * Get a block specified by its block number or 'latest'.
227
- * @param number - The block number or 'latest'.
196
+ * @param blockParameter - The block parameter (block number, block hash, or 'latest').
228
197
  * @returns The requested block.
229
198
  */
230
- getBlock(number: BlockParameter): Promise<L2Block | undefined>;
199
+ getBlock(blockParameter: BlockParameter): Promise<L2Block | undefined>;
231
200
 
232
201
  /**
233
202
  * Get a block specified by its hash.
234
203
  * @param blockHash - The block hash being requested.
235
204
  * @returns The requested block.
236
205
  */
237
- getBlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
206
+ getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
238
207
 
239
208
  /**
240
209
  * Get a block specified by its archive root.
@@ -355,7 +324,7 @@ export interface AztecNode
355
324
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
356
325
  * for a tag, the caller should fetch the next page to check for more logs.
357
326
  */
358
- getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: L2BlockHash): Promise<TxScopedL2Log[][]>;
327
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: BlockHash): Promise<TxScopedL2Log[][]>;
359
328
 
360
329
  /**
361
330
  * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
@@ -374,7 +343,7 @@ export interface AztecNode
374
343
  contractAddress: AztecAddress,
375
344
  tags: Tag[],
376
345
  page?: number,
377
- referenceBlock?: L2BlockHash,
346
+ referenceBlock?: BlockHash,
378
347
  ): Promise<TxScopedL2Log[][]>;
379
348
 
380
349
  /**
@@ -433,12 +402,12 @@ export interface AztecNode
433
402
  * @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
434
403
  * Aztec's version of `eth_getStorageAt`.
435
404
  *
436
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
405
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
437
406
  * @param contract - Address of the contract to query.
438
407
  * @param slot - Slot to query.
439
408
  * @returns Storage value at the given contract slot.
440
409
  */
441
- getPublicStorageAt(block: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
410
+ getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
442
411
 
443
412
  /**
444
413
  * Returns the block header for a given block number, block hash, or 'latest'.
@@ -518,26 +487,6 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
518
487
  .args(BlockParameterSchema, z.nativeEnum(MerkleTreeId), z.array(schemas.Fr).max(MAX_RPC_LEN))
519
488
  .returns(z.array(optional(dataInBlockSchemaFor(schemas.BigInt)))),
520
489
 
521
- getNullifierSiblingPath: z
522
- .function()
523
- .args(BlockParameterSchema, schemas.BigInt)
524
- .returns(SiblingPath.schemaFor(NULLIFIER_TREE_HEIGHT)),
525
-
526
- getNoteHashSiblingPath: z
527
- .function()
528
- .args(BlockParameterSchema, schemas.BigInt)
529
- .returns(SiblingPath.schemaFor(NOTE_HASH_TREE_HEIGHT)),
530
-
531
- getArchiveSiblingPath: z
532
- .function()
533
- .args(BlockParameterSchema, schemas.BigInt)
534
- .returns(SiblingPath.schemaFor(ARCHIVE_HEIGHT)),
535
-
536
- getPublicDataSiblingPath: z
537
- .function()
538
- .args(BlockParameterSchema, schemas.BigInt)
539
- .returns(SiblingPath.schemaFor(PUBLIC_DATA_TREE_HEIGHT)),
540
-
541
490
  getNullifierMembershipWitness: z
542
491
  .function()
543
492
  .args(BlockParameterSchema, schemas.Fr)
@@ -553,9 +502,9 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
553
502
  .args(BlockParameterSchema, schemas.Fr)
554
503
  .returns(PublicDataWitness.schema.optional()),
555
504
 
556
- getArchiveMembershipWitness: z
505
+ getBlockHashMembershipWitness: z
557
506
  .function()
558
- .args(BlockParameterSchema, schemas.Fr)
507
+ .args(BlockParameterSchema, BlockHash.schema)
559
508
  .returns(MembershipWitness.schemaFor(ARCHIVE_HEIGHT).optional()),
560
509
 
561
510
  getNoteHashMembershipWitness: z
@@ -579,7 +528,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
579
528
 
580
529
  getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
581
530
 
582
- getBlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
531
+ getBlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
583
532
 
584
533
  getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
585
534
 
@@ -633,7 +582,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
633
582
 
634
583
  getPrivateLogsByTags: z
635
584
  .function()
636
- .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(L2BlockHash.schema))
585
+ .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(BlockHash.schema))
637
586
  .returns(z.array(z.array(TxScopedL2Log.schema))),
638
587
 
639
588
  getPublicLogsByTagsFromContract: z
@@ -642,7 +591,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
642
591
  schemas.AztecAddress,
643
592
  z.array(Tag.schema).max(MAX_RPC_LEN),
644
593
  optional(z.number().gte(0)),
645
- optional(L2BlockHash.schema),
594
+ optional(BlockHash.schema),
646
595
  )
647
596
  .returns(z.array(z.array(TxScopedL2Log.schema))),
648
597
 
@@ -1,5 +1,6 @@
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
5
  import type { L2Block } from '../block/l2_block.js';
5
6
  import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
@@ -61,8 +62,16 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
61
62
  'fakeThrowAfterProcessingTxCount',
62
63
  ] as const;
63
64
 
65
+ /** Thrown when no valid transactions are available to include in a block after processing, and this is not the first block in a checkpoint. */
66
+ export class NoValidTxsError extends Error {
67
+ constructor(public readonly failedTxs: FailedTx[]) {
68
+ super('No valid transactions to include in block');
69
+ this.name = 'NoValidTxsError';
70
+ }
71
+ }
72
+
64
73
  /** Result of building a block within a checkpoint. */
65
- export interface BuildBlockInCheckpointResult {
74
+ export type BuildBlockInCheckpointResult = {
66
75
  block: L2Block;
67
76
  publicGas: Gas;
68
77
  publicProcessorDuration: number;
@@ -70,7 +79,7 @@ export interface BuildBlockInCheckpointResult {
70
79
  failedTxs: FailedTx[];
71
80
  usedTxs: Tx[];
72
81
  usedTxBlobFields: number;
73
- }
82
+ };
74
83
 
75
84
  /** Interface for building blocks within a checkpoint context. */
76
85
  export interface ICheckpointBlockBuilder {
@@ -92,5 +101,6 @@ export interface ICheckpointsBuilder {
92
101
  l1ToL2Messages: Fr[],
93
102
  previousCheckpointOutHashes: Fr[],
94
103
  fork: MerkleTreeWriteOperations,
104
+ bindings?: LoggerBindings,
95
105
  ): Promise<ICheckpointBlockBuilder>;
96
106
  }
@@ -51,8 +51,7 @@ 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
57
  /** Skip pushing re-executed blocks to archiver (default: false) */
@@ -10,8 +10,8 @@ import type { KeyPrefix } from './key_types.js';
10
10
  import { PublicKeys } from './public_keys.js';
11
11
  import { getKeyGenerator } from './utils.js';
12
12
 
13
- export function computeAppNullifierSecretKey(masterNullifierSecretKey: GrumpkinScalar, app: AztecAddress): Promise<Fr> {
14
- return computeAppSecretKey(masterNullifierSecretKey, app, 'n'); // 'n' is the key prefix for nullifier secret key
13
+ export function computeAppNullifierHidingKey(masterNullifierHidingKey: GrumpkinScalar, app: AztecAddress): Promise<Fr> {
14
+ return computeAppSecretKey(masterNullifierHidingKey, app, 'n'); // 'n' is the key prefix for nullifier hiding key
15
15
  }
16
16
 
17
17
  export function computeAppSecretKey(skM: GrumpkinScalar, app: AztecAddress, keyPrefix: KeyPrefix): Promise<Fr> {
@@ -26,8 +26,8 @@ export async function computeOvskApp(ovsk: GrumpkinScalar, app: AztecAddress): P
26
26
  return GrumpkinScalar.fromBuffer(ovskAppFr.toBuffer());
27
27
  }
28
28
 
29
- export function deriveMasterNullifierSecretKey(secretKey: Fr): GrumpkinScalar {
30
- return sha512ToGrumpkinScalar([secretKey, GeneratorIndex.NSK_M]);
29
+ export function deriveMasterNullifierHidingKey(secretKey: Fr): GrumpkinScalar {
30
+ return sha512ToGrumpkinScalar([secretKey, GeneratorIndex.NHK_M]);
31
31
  }
32
32
 
33
33
  export function deriveMasterIncomingViewingSecretKey(secretKey: Fr): GrumpkinScalar {
@@ -93,15 +93,15 @@ export function derivePublicKeyFromSecretKey(secretKey: Fq) {
93
93
  * @returns The derived keys.
94
94
  */
95
95
  export async function deriveKeys(secretKey: Fr) {
96
- // First we derive master secret keys - we use sha512 here because this derivation will never take place
96
+ // First we derive master secret/hiding keys - we use sha512 here because this derivation will never take place
97
97
  // in a circuit
98
- const masterNullifierSecretKey = deriveMasterNullifierSecretKey(secretKey);
98
+ const masterNullifierHidingKey = deriveMasterNullifierHidingKey(secretKey);
99
99
  const masterIncomingViewingSecretKey = deriveMasterIncomingViewingSecretKey(secretKey);
100
100
  const masterOutgoingViewingSecretKey = deriveMasterOutgoingViewingSecretKey(secretKey);
101
101
  const masterTaggingSecretKey = sha512ToGrumpkinScalar([secretKey, GeneratorIndex.TSK_M]);
102
102
 
103
103
  // Then we derive master public keys
104
- const masterNullifierPublicKey = await derivePublicKeyFromSecretKey(masterNullifierSecretKey);
104
+ const masterNullifierPublicKey = await derivePublicKeyFromSecretKey(masterNullifierHidingKey);
105
105
  const masterIncomingViewingPublicKey = await derivePublicKeyFromSecretKey(masterIncomingViewingSecretKey);
106
106
  const masterOutgoingViewingPublicKey = await derivePublicKeyFromSecretKey(masterOutgoingViewingSecretKey);
107
107
  const masterTaggingPublicKey = await derivePublicKeyFromSecretKey(masterTaggingSecretKey);
@@ -115,7 +115,7 @@ export async function deriveKeys(secretKey: Fr) {
115
115
  );
116
116
 
117
117
  return {
118
- masterNullifierSecretKey,
118
+ masterNullifierHidingKey,
119
119
  masterIncomingViewingSecretKey,
120
120
  masterOutgoingViewingSecretKey,
121
121
  masterTaggingSecretKey,
@@ -1,5 +1,5 @@
1
1
  import type { GeneratorIndex } from '@aztec/constants';
2
2
 
3
- export type KeyGenerator = GeneratorIndex.NSK_M | GeneratorIndex.IVSK_M | GeneratorIndex.OVSK_M | GeneratorIndex.TSK_M;
3
+ export type KeyGenerator = GeneratorIndex.NHK_M | GeneratorIndex.IVSK_M | GeneratorIndex.OVSK_M | GeneratorIndex.TSK_M;
4
4
  export type KeyPrefix = 'n' | 'iv' | 'ov' | 't';
5
5
  export const KEY_PREFIXES: KeyPrefix[] = ['n', 'iv', 'ov', 't'];
package/src/keys/utils.ts CHANGED
@@ -3,7 +3,11 @@ import { GeneratorIndex } from '@aztec/constants';
3
3
  import type { KeyGenerator, KeyPrefix } from './key_types.js';
4
4
 
5
5
  export function getKeyGenerator(prefix: KeyPrefix): KeyGenerator {
6
- // We get enum key by capitalizing key prefix and concatenating it with 'SK_M'
7
- const enumKey = `${prefix.toUpperCase()}SK_M`;
8
- return GeneratorIndex[enumKey as keyof typeof GeneratorIndex] as KeyGenerator;
6
+ const map: Record<KeyPrefix, KeyGenerator> = {
7
+ n: GeneratorIndex.NHK_M,
8
+ iv: GeneratorIndex.IVSK_M,
9
+ ov: GeneratorIndex.OVSK_M,
10
+ t: GeneratorIndex.TSK_M,
11
+ };
12
+ return map[prefix];
9
13
  }
@@ -41,6 +41,7 @@ export class SlashFactoryContract {
41
41
 
42
42
  return {
43
43
  to: this.contract.address,
44
+ abi: SlashFactoryAbi,
44
45
  data: encodeFunctionData({
45
46
  abi: SlashFactoryAbi,
46
47
  functionName: 'createSlashPayload',
@@ -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
 
@@ -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
 
@@ -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
 
@@ -202,8 +202,6 @@ export type L2BlockBuiltStats = {
202
202
  duration: number;
203
203
  /** Time for processing public txs in ms. */
204
204
  publicProcessDuration: number;
205
- /** Time for running rollup circuits in ms. */
206
- rollupCircuitsDuration: number;
207
205
  } & L2BlockStats;
208
206
 
209
207
  /** Stats for an L2 block processed by the world state synchronizer. */
@@ -97,12 +97,14 @@ export const mockTx = async (
97
97
  publicCalldataSize = 2,
98
98
  feePayer,
99
99
  chonkProof = ChonkProof.random(),
100
+ maxFeesPerGas = new GasFees(10, 10),
100
101
  maxPriorityFeesPerGas,
101
102
  gasUsed = Gas.empty(),
102
103
  chainId = Fr.ZERO,
103
104
  version = Fr.ZERO,
104
105
  vkTreeRoot = Fr.ZERO,
105
106
  protocolContractsHash = Fr.ZERO,
107
+ anchorBlockHeader = BlockHeader.empty(),
106
108
  }: {
107
109
  numberOfNonRevertiblePublicCallRequests?: number;
108
110
  numberOfRevertiblePublicCallRequests?: number;
@@ -111,12 +113,14 @@ export const mockTx = async (
111
113
  publicCalldataSize?: number;
112
114
  feePayer?: AztecAddress;
113
115
  chonkProof?: ChonkProof;
116
+ maxFeesPerGas?: GasFees;
114
117
  maxPriorityFeesPerGas?: GasFees;
115
118
  gasUsed?: Gas;
116
119
  chainId?: Fr;
117
120
  version?: Fr;
118
121
  vkTreeRoot?: Fr;
119
122
  protocolContractsHash?: Fr;
123
+ anchorBlockHeader?: BlockHeader;
120
124
  } = {},
121
125
  ) => {
122
126
  const totalPublicCallRequests =
@@ -126,10 +130,8 @@ export const mockTx = async (
126
130
  const isForPublic = totalPublicCallRequests > 0;
127
131
  const data = PrivateKernelTailCircuitPublicInputs.empty();
128
132
  const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
129
- data.constants.txContext.gasSettings = GasSettings.default({
130
- maxFeesPerGas: new GasFees(10, 10),
131
- maxPriorityFeesPerGas,
132
- });
133
+ data.constants.anchorBlockHeader = anchorBlockHeader;
134
+ data.constants.txContext.gasSettings = GasSettings.default({ maxFeesPerGas, maxPriorityFeesPerGas });
133
135
  data.feePayer = feePayer ?? (await AztecAddress.random());
134
136
  data.gasUsed = gasUsed;
135
137
  data.constants.txContext.chainId = chainId;
@@ -11,14 +11,14 @@ import type { FieldsOf } from '@aztec/foundation/types';
11
11
  import { inspect } from 'util';
12
12
  import { z } from 'zod';
13
13
 
14
- import { L2BlockHash } from '../block/block_hash.js';
14
+ import { BlockHash } from '../block/block_hash.js';
15
15
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
16
16
  import { GlobalVariables } from './global_variables.js';
17
17
  import { StateReference } from './state_reference.js';
18
18
 
19
19
  /** A header of an L2 block. */
20
20
  export class BlockHeader {
21
- private _cachedHash?: Promise<L2BlockHash>;
21
+ private _cachedHash?: Promise<BlockHash>;
22
22
 
23
23
  constructor(
24
24
  /** Snapshot of archive before the block is applied. */
@@ -162,10 +162,10 @@ export class BlockHeader {
162
162
  return BlockHeader.fromBuffer(hexToBuffer(str));
163
163
  }
164
164
 
165
- hash(): Promise<L2BlockHash> {
165
+ hash(): Promise<BlockHash> {
166
166
  if (!this._cachedHash) {
167
- this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH).then(fr =>
168
- L2BlockHash.fromField(fr),
167
+ this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HEADER_HASH).then(
168
+ fr => new BlockHash(fr),
169
169
  );
170
170
  }
171
171
  return this._cachedHash;
@@ -173,7 +173,7 @@ export class BlockHeader {
173
173
 
174
174
  /** Manually set the hash for this block header if already computed */
175
175
  setHash(hashed: Fr) {
176
- this._cachedHash = Promise.resolve(L2BlockHash.fromField(hashed));
176
+ this._cachedHash = Promise.resolve(new BlockHash(hashed));
177
177
  }
178
178
 
179
179
  static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
@@ -1,8 +1,9 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { schemas } from '@aztec/foundation/schemas';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
 
5
- import { L2BlockHash } from '../block/block_hash.js';
6
+ import { BlockHash } from '../block/block_hash.js';
6
7
  import { type DataInBlock, dataInBlockSchemaFor, randomDataInBlock } from '../block/in_block.js';
7
8
  import { TxEffect } from './tx_effect.js';
8
9
 
@@ -26,7 +27,7 @@ export function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer {
26
27
  export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
27
28
  const reader = BufferReader.asReader(buffer);
28
29
 
29
- const l2BlockHash = reader.readObject(L2BlockHash);
30
+ const l2BlockHash = new BlockHash(reader.readObject(Fr));
30
31
  const l2BlockNumber = BlockNumber(reader.readNumber());
31
32
  const txIndexInBlock = reader.readNumber();
32
33
  const data = reader.readObject(TxEffect);