@aztec/stdlib 0.0.1-commit.29c6b1a3 → 0.0.1-commit.2eb6648a

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 (140) hide show
  1. package/dest/block/block_hash.d.ts +14 -17
  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 +2 -2
  5. package/dest/block/block_parameter.d.ts.map +1 -1
  6. package/dest/block/in_block.d.ts +5 -5
  7. package/dest/block/in_block.js +2 -2
  8. package/dest/block/l2_block.d.ts +3 -2
  9. package/dest/block/l2_block.d.ts.map +1 -1
  10. package/dest/block/l2_block.js +2 -3
  11. package/dest/block/l2_block_source.d.ts +5 -4
  12. package/dest/block/l2_block_source.d.ts.map +1 -1
  13. package/dest/contract/contract_address.js +1 -1
  14. package/dest/contract/contract_class_id.d.ts +1 -1
  15. package/dest/contract/contract_class_id.js +1 -1
  16. package/dest/contract/private_function.js +1 -1
  17. package/dest/contract/private_function_membership_proof.d.ts +1 -1
  18. package/dest/contract/private_function_membership_proof.js +1 -1
  19. package/dest/database-version/database_version.d.ts +58 -0
  20. package/dest/database-version/database_version.d.ts.map +1 -0
  21. package/dest/database-version/database_version.js +69 -0
  22. package/dest/database-version/version_manager.d.ts +2 -50
  23. package/dest/database-version/version_manager.d.ts.map +1 -1
  24. package/dest/database-version/version_manager.js +1 -66
  25. package/dest/epoch-helpers/index.d.ts +3 -1
  26. package/dest/epoch-helpers/index.d.ts.map +1 -1
  27. package/dest/epoch-helpers/index.js +4 -0
  28. package/dest/hash/hash.js +2 -2
  29. package/dest/hash/map_slot.d.ts +1 -1
  30. package/dest/hash/map_slot.d.ts.map +1 -1
  31. package/dest/hash/map_slot.js +4 -3
  32. package/dest/interfaces/archiver.d.ts +1 -1
  33. package/dest/interfaces/archiver.d.ts.map +1 -1
  34. package/dest/interfaces/archiver.js +4 -3
  35. package/dest/interfaces/aztec-node-admin.d.ts +11 -2
  36. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  37. package/dest/interfaces/aztec-node-admin.js +3 -1
  38. package/dest/interfaces/aztec-node.d.ts +30 -51
  39. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  40. package/dest/interfaces/aztec-node.js +3 -7
  41. package/dest/interfaces/block-builder.d.ts +10 -4
  42. package/dest/interfaces/block-builder.d.ts.map +1 -1
  43. package/dest/interfaces/block-builder.js +7 -0
  44. package/dest/interfaces/get_logs_response.d.ts +14 -7
  45. package/dest/interfaces/get_logs_response.d.ts.map +1 -1
  46. package/dest/interfaces/p2p.d.ts +2 -2
  47. package/dest/interfaces/p2p.d.ts.map +1 -1
  48. package/dest/interfaces/prover-broker.d.ts +16 -1
  49. package/dest/interfaces/prover-broker.d.ts.map +1 -1
  50. package/dest/interfaces/prover-broker.js +4 -1
  51. package/dest/interfaces/prover-client.d.ts +6 -1
  52. package/dest/interfaces/prover-client.d.ts.map +1 -1
  53. package/dest/interfaces/prover-client.js +5 -0
  54. package/dest/interfaces/proving-job.d.ts +34 -34
  55. package/dest/interfaces/slasher.d.ts +5 -1
  56. package/dest/interfaces/slasher.d.ts.map +1 -1
  57. package/dest/interfaces/slasher.js +1 -0
  58. package/dest/interfaces/validator.d.ts +37 -2
  59. package/dest/interfaces/validator.d.ts.map +1 -1
  60. package/dest/interfaces/validator.js +1 -0
  61. package/dest/keys/derivation.d.ts +3 -3
  62. package/dest/keys/derivation.js +8 -8
  63. package/dest/keys/key_types.d.ts +1 -1
  64. package/dest/keys/utils.d.ts +1 -1
  65. package/dest/keys/utils.d.ts.map +1 -1
  66. package/dest/keys/utils.js +7 -3
  67. package/dest/l1-contracts/slash_factory.d.ts +1 -1
  68. package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
  69. package/dest/l1-contracts/slash_factory.js +1 -0
  70. package/dest/logs/extended_public_log.d.ts +12 -6
  71. package/dest/logs/extended_public_log.d.ts.map +1 -1
  72. package/dest/logs/log_id.d.ts +13 -10
  73. package/dest/logs/log_id.d.ts.map +1 -1
  74. package/dest/logs/log_id.js +17 -14
  75. package/dest/logs/siloed_tag.d.ts +1 -1
  76. package/dest/logs/siloed_tag.d.ts.map +1 -1
  77. package/dest/logs/siloed_tag.js +4 -3
  78. package/dest/p2p/checkpoint_proposal.d.ts +8 -1
  79. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  80. package/dest/p2p/checkpoint_proposal.js +9 -0
  81. package/dest/slashing/empire.d.ts +1 -1
  82. package/dest/slashing/empire.d.ts.map +1 -1
  83. package/dest/slashing/empire.js +1 -0
  84. package/dest/slashing/helpers.d.ts +2 -2
  85. package/dest/slashing/helpers.d.ts.map +1 -1
  86. package/dest/slashing/helpers.js +3 -0
  87. package/dest/slashing/tally.d.ts +2 -1
  88. package/dest/slashing/tally.d.ts.map +1 -1
  89. package/dest/slashing/tally.js +6 -2
  90. package/dest/slashing/types.d.ts +5 -3
  91. package/dest/slashing/types.d.ts.map +1 -1
  92. package/dest/slashing/types.js +7 -1
  93. package/dest/stats/stats.d.ts +1 -3
  94. package/dest/stats/stats.d.ts.map +1 -1
  95. package/dest/tx/block_header.js +2 -2
  96. package/dest/tx/in_tx.d.ts +2 -2
  97. package/dest/tx/indexed_tx_effect.d.ts +3 -3
  98. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  99. package/dest/tx/indexed_tx_effect.js +2 -1
  100. package/package.json +22 -11
  101. package/src/block/block_hash.ts +25 -50
  102. package/src/block/in_block.ts +2 -2
  103. package/src/block/l2_block.ts +3 -3
  104. package/src/block/l2_block_source.ts +4 -3
  105. package/src/contract/contract_address.ts +1 -1
  106. package/src/contract/contract_class_id.ts +1 -1
  107. package/src/contract/private_function.ts +1 -1
  108. package/src/contract/private_function_membership_proof.ts +1 -1
  109. package/src/database-version/database_version.ts +87 -0
  110. package/src/database-version/version_manager.ts +1 -77
  111. package/src/epoch-helpers/index.ts +9 -0
  112. package/src/hash/hash.ts +2 -2
  113. package/src/hash/map_slot.ts +3 -2
  114. package/src/interfaces/archiver.ts +4 -3
  115. package/src/interfaces/aztec-node-admin.ts +3 -2
  116. package/src/interfaces/aztec-node.ts +37 -88
  117. package/src/interfaces/block-builder.ts +12 -2
  118. package/src/interfaces/p2p.ts +1 -1
  119. package/src/interfaces/prover-broker.ts +22 -0
  120. package/src/interfaces/prover-client.ts +7 -0
  121. package/src/interfaces/slasher.ts +2 -0
  122. package/src/interfaces/validator.ts +2 -1
  123. package/src/keys/derivation.ts +8 -8
  124. package/src/keys/key_types.ts +1 -1
  125. package/src/keys/utils.ts +7 -3
  126. package/src/l1-contracts/slash_factory.ts +1 -0
  127. package/src/logs/log_id.ts +17 -13
  128. package/src/logs/siloed_tag.ts +3 -2
  129. package/src/p2p/checkpoint_proposal.ts +10 -0
  130. package/src/slashing/empire.ts +2 -1
  131. package/src/slashing/helpers.ts +4 -0
  132. package/src/slashing/tally.ts +8 -2
  133. package/src/slashing/types.ts +7 -0
  134. package/src/stats/stats.ts +0 -2
  135. package/src/tx/block_header.ts +3 -3
  136. package/src/tx/indexed_tx_effect.ts +2 -1
  137. package/dest/database-version/index.d.ts +0 -2
  138. package/dest/database-version/index.d.ts.map +0 -1
  139. package/dest/database-version/index.js +0 -1
  140. 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,
@@ -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.
@@ -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
 
@@ -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
  }
@@ -63,7 +63,7 @@ export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
63
63
 
64
64
  export interface P2PClient extends P2PApiWithAttestations {
65
65
  /** Manually adds checkpoint attestations to the p2p client attestation pool. */
66
- addCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
66
+ addOwnCheckpointAttestations(attestations: CheckpointAttestation[]): Promise<void>;
67
67
  }
68
68
 
69
69
  export type P2PApi<T extends P2PClientType = P2PClientType.Full> = T extends P2PClientType.Full
@@ -1,3 +1,5 @@
1
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
2
+
1
3
  import type { ProvingRequestType } from '../proofs/proving_request_type.js';
2
4
  import type { ProofUri, ProvingJob, ProvingJobId, ProvingJobStatus } from './proving-job.js';
3
5
 
@@ -88,3 +90,23 @@ export interface ProvingJobConsumer {
88
90
  }
89
91
 
90
92
  export interface ProvingJobBroker extends ProvingJobProducer, ProvingJobConsumer {}
93
+
94
+ /**
95
+ * Debug interface for replaying proving jobs from stored inputs.
96
+ * Used for benchmarking different agent configurations against the same workload.
97
+ */
98
+ export interface ProvingJobBrokerDebug {
99
+ /**
100
+ * Replays a proving job by re-enqueuing it with inputs from the configured proof store.
101
+ * The proof type is parsed from the job ID (format: epoch:typeName:hash).
102
+ * @param jobId - The original job ID to replay
103
+ * @param epochNumber - The epoch number to assign
104
+ * @param inputsUri - The proof inputs location
105
+ */
106
+ replayProvingJob(
107
+ jobId: ProvingJobId,
108
+ type: ProvingRequestType,
109
+ epochNumber: EpochNumber,
110
+ inputsUri: ProofUri,
111
+ ): Promise<ProvingJobStatus>;
112
+ }
@@ -35,6 +35,8 @@ export type ProverConfig = ActualProverConfig & {
35
35
  proverId?: EthAddress;
36
36
  /** Number of proving agents to start within the prover. */
37
37
  proverAgentCount: number;
38
+ /** Where to store proving request. Must be accessible to both prover node and agents. If not set will inline-encode the parameters */
39
+ proofStore?: string;
38
40
  /** Store for failed proof inputs. */
39
41
  failedProofStore?: string;
40
42
  };
@@ -48,6 +50,7 @@ export const ProverConfigSchema = zodFor<ProverConfig>()(
48
50
  proverTestDelayMs: z.number(),
49
51
  proverTestDelayFactor: z.number(),
50
52
  proverAgentCount: z.number(),
53
+ proofStore: z.string().optional(),
51
54
  failedProofStore: z.string().optional(),
52
55
  cancelJobsOnStop: z.boolean(),
53
56
  }),
@@ -87,6 +90,10 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
87
90
  description: 'The number of prover agents to start',
88
91
  ...numberConfigHelper(1),
89
92
  },
93
+ proofStore: {
94
+ env: 'PROVER_PROOF_STORE',
95
+ description: 'Optional proof input store for the prover',
96
+ },
90
97
  failedProofStore: {
91
98
  env: 'PROVER_FAILED_PROOF_STORE',
92
99
  description:
@@ -18,6 +18,7 @@ export interface SlasherConfig {
18
18
  slashDataWithholdingPenalty: bigint;
19
19
  slashInactivityPenalty: bigint;
20
20
  slashBroadcastedInvalidBlockPenalty: bigint;
21
+ slashDuplicateProposalPenalty: bigint;
21
22
  slashProposeInvalidAttestationsPenalty: bigint;
22
23
  slashAttestDescendantOfInvalidPenalty: bigint;
23
24
  slashUnknownPenalty: bigint;
@@ -40,6 +41,7 @@ export const SlasherConfigSchema = zodFor<SlasherConfig>()(
40
41
  slashInactivityConsecutiveEpochThreshold: z.number(),
41
42
  slashInactivityPenalty: schemas.BigInt,
42
43
  slashProposeInvalidAttestationsPenalty: schemas.BigInt,
44
+ slashDuplicateProposalPenalty: schemas.BigInt,
43
45
  slashAttestDescendantOfInvalidPenalty: schemas.BigInt,
44
46
  slashUnknownPenalty: schemas.BigInt,
45
47
  slashOffenseExpirationRounds: z.number(),
@@ -60,7 +60,7 @@ export type ValidatorClientConfig = ValidatorHASignerConfig & {
60
60
 
61
61
  export type ValidatorClientFullConfig = ValidatorClientConfig &
62
62
  Pick<SequencerConfig, 'txPublicSetupAllowList' | 'broadcastInvalidBlockProposal'> &
63
- Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty'> & {
63
+ Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty' | 'slashDuplicateProposalPenalty'> & {
64
64
  /**
65
65
  * Whether transactions are disabled for this node
66
66
  * @remarks This should match the property in P2PConfig. It's not picked from there to avoid circular dependencies.
@@ -87,6 +87,7 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
87
87
  txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
88
88
  broadcastInvalidBlockProposal: z.boolean().optional(),
89
89
  slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
90
+ slashDuplicateProposalPenalty: schemas.BigInt,
90
91
  disableTransactions: z.boolean().optional(),
91
92
  }),
92
93
  );
@@ -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,26 +1,24 @@
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
9
  import { BlockHash } from '../block/block_hash.js';
9
10
  import { schemas } from '../schemas/index.js';
11
+ import { TxHash } from '../tx/tx_hash.js';
10
12
 
11
13
  /** A globally unique log id. */
12
14
  export class LogId {
13
- /**
14
- * Parses a log id from a string.
15
- * @param blockNumber - The block number.
16
- * @param txIndex - The transaction index.
17
- * @param logIndex - The log index.
18
- */
19
15
  constructor(
20
16
  /** The block number the log was emitted in. */
21
17
  public readonly blockNumber: BlockNumber,
22
18
  /** The hash of the block the log was emitted in. */
23
19
  public readonly blockHash: BlockHash,
20
+ /** The hash of the transaction the log was emitted in. */
21
+ public readonly txHash: TxHash,
24
22
  /** The index of a tx in a block the log was emitted in. */
25
23
  public readonly txIndex: number,
26
24
  /** The index of a log the tx was emitted in. */
@@ -41,6 +39,7 @@ export class LogId {
41
39
  return new LogId(
42
40
  BlockNumber(Math.floor(Math.random() * 1000) + 1),
43
41
  BlockHash.random(),
42
+ TxHash.random(),
44
43
  Math.floor(Math.random() * 1000),
45
44
  Math.floor(Math.random() * 100),
46
45
  );
@@ -51,11 +50,13 @@ export class LogId {
51
50
  .object({
52
51
  blockNumber: BlockNumberSchema,
53
52
  blockHash: BlockHash.schema,
53
+ txHash: TxHash.schema,
54
54
  txIndex: schemas.Integer,
55
55
  logIndex: schemas.Integer,
56
56
  })
57
57
  .transform(
58
- ({ blockNumber, blockHash, txIndex, logIndex }) => new LogId(blockNumber, blockHash, txIndex, logIndex),
58
+ ({ blockNumber, blockHash, txHash, txIndex, logIndex }) =>
59
+ new LogId(blockNumber, blockHash, txHash, txIndex, logIndex),
59
60
  );
60
61
  }
61
62
 
@@ -67,6 +68,7 @@ export class LogId {
67
68
  return Buffer.concat([
68
69
  toBufferBE(BigInt(this.blockNumber), 4),
69
70
  this.blockHash.toBuffer(),
71
+ this.txHash.toBuffer(),
70
72
  toBufferBE(BigInt(this.txIndex), 4),
71
73
  toBufferBE(BigInt(this.logIndex), 4),
72
74
  ]);
@@ -81,11 +83,12 @@ export class LogId {
81
83
  const reader = BufferReader.asReader(buffer);
82
84
 
83
85
  const blockNumber = BlockNumber(reader.readNumber());
84
- const blockHash = reader.readObject(BlockHash);
86
+ const blockHash = new BlockHash(reader.readObject(Fr));
87
+ const txHash = reader.readObject(TxHash);
85
88
  const txIndex = reader.readNumber();
86
89
  const logIndex = reader.readNumber();
87
90
 
88
- return new LogId(blockNumber, blockHash, txIndex, logIndex);
91
+ return new LogId(blockNumber, blockHash, txHash, txIndex, logIndex);
89
92
  }
90
93
 
91
94
  /**
@@ -93,7 +96,7 @@ export class LogId {
93
96
  * @returns A string representation of the log id.
94
97
  */
95
98
  public toString(): string {
96
- return `${this.blockNumber}-${this.txIndex}-${this.logIndex}-${this.blockHash.toString()}`;
99
+ return `${this.blockNumber}-${this.txIndex}-${this.logIndex}-${this.blockHash.toString()}-${this.txHash.toString()}`;
97
100
  }
98
101
 
99
102
  /**
@@ -102,13 +105,14 @@ export class LogId {
102
105
  * @returns A log id.
103
106
  */
104
107
  static fromString(data: string): LogId {
105
- const [rawBlockNumber, rawTxIndex, rawLogIndex, rawBlockHash] = data.split('-');
108
+ const [rawBlockNumber, rawTxIndex, rawLogIndex, rawBlockHash, rawTxHash] = data.split('-');
106
109
  const blockNumber = BlockNumber(Number(rawBlockNumber));
107
110
  const blockHash = BlockHash.fromString(rawBlockHash);
111
+ const txHash = TxHash.fromString(rawTxHash);
108
112
  const txIndex = Number(rawTxIndex);
109
113
  const logIndex = Number(rawLogIndex);
110
114
 
111
- return new LogId(blockNumber, blockHash, txIndex, logIndex);
115
+ return new LogId(blockNumber, blockHash, txHash, txIndex, logIndex);
112
116
  }
113
117
 
114
118
  /**
@@ -116,6 +120,6 @@ export class LogId {
116
120
  * @returns A human readable representation of the log id.
117
121
  */
118
122
  public toHumanReadable(): string {
119
- return `logId: (blockNumber: ${this.blockNumber}, blockHash: ${this.blockHash.toString()}, txIndex: ${this.txIndex}, logIndex: ${this.logIndex})`;
123
+ return `logId: (blockNumber: ${this.blockNumber}, blockHash: ${this.blockHash.toString()}, txHash: ${this.txHash.toString()}, txIndex: ${this.txIndex}, logIndex: ${this.logIndex})`;
120
124
  }
121
125
  }
@@ -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
 
@@ -148,6 +148,16 @@ export class CheckpointProposal extends Gossipable {
148
148
  };
149
149
  }
150
150
 
151
+ toCheckpointInfo() {
152
+ return {
153
+ slotNumber: this.slotNumber,
154
+ archive: this.archive,
155
+ lastBlockNumber: this.lastBlock?.blockHeader.getBlockNumber(),
156
+ lastBlockIndex: this.lastBlock?.indexWithinCheckpoint,
157
+ blockHeadersHash: this.checkpointHeader.blockHeadersHash,
158
+ };
159
+ }
160
+
151
161
  /**
152
162
  * Get the payload to sign for this checkpoint proposal.
153
163
  * The signature is over the checkpoint header + archive root (for consensus).
@@ -83,7 +83,8 @@ export function getFirstEligibleRoundForOffense(
83
83
  case OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS:
84
84
  case OffenseType.PROPOSED_INCORRECT_ATTESTATIONS:
85
85
  case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
86
- case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL: {
86
+ case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
87
+ case OffenseType.DUPLICATE_PROPOSAL: {
87
88
  const slot = offense.epochOrSlot;
88
89
  const detectedSlot = SlotNumber.fromBigInt(slot + 1n);
89
90
  return getRoundForSlot(detectedSlot, constants).round + 1n;
@@ -50,6 +50,7 @@ export function getPenaltyForOffense(
50
50
  SlasherConfig,
51
51
  | 'slashAttestDescendantOfInvalidPenalty'
52
52
  | 'slashBroadcastedInvalidBlockPenalty'
53
+ | 'slashDuplicateProposalPenalty'
53
54
  | 'slashPrunePenalty'
54
55
  | 'slashDataWithholdingPenalty'
55
56
  | 'slashUnknownPenalty'
@@ -71,6 +72,8 @@ export function getPenaltyForOffense(
71
72
  return config.slashAttestDescendantOfInvalidPenalty;
72
73
  case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
73
74
  return config.slashBroadcastedInvalidBlockPenalty;
75
+ case OffenseType.DUPLICATE_PROPOSAL:
76
+ return config.slashDuplicateProposalPenalty;
74
77
  case OffenseType.UNKNOWN:
75
78
  return config.slashUnknownPenalty;
76
79
  default: {
@@ -85,6 +88,7 @@ export function getTimeUnitForOffense(offense: OffenseType): 'epoch' | 'slot' {
85
88
  switch (offense) {
86
89
  case OffenseType.ATTESTED_DESCENDANT_OF_INVALID:
87
90
  case OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL:
91
+ case OffenseType.DUPLICATE_PROPOSAL:
88
92
  case OffenseType.PROPOSED_INCORRECT_ATTESTATIONS:
89
93
  case OffenseType.PROPOSED_INSUFFICIENT_ATTESTATIONS:
90
94
  return 'slot';