@aztec/stdlib 5.0.0-rc.2 → 5.0.1

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 (197) hide show
  1. package/dest/block/attestation_info.d.ts +1 -1
  2. package/dest/block/attestation_info.d.ts.map +1 -1
  3. package/dest/block/attestation_info.js +7 -4
  4. package/dest/block/l2_block_source.d.ts +34 -3
  5. package/dest/block/l2_block_source.d.ts.map +1 -1
  6. package/dest/block/l2_block_source.js +15 -0
  7. package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts +39 -0
  8. package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts.map +1 -0
  9. package/dest/block/l2_block_stream/event_driven_l2_block_stream.js +165 -0
  10. package/dest/block/l2_block_stream/index.d.ts +2 -1
  11. package/dest/block/l2_block_stream/index.d.ts.map +1 -1
  12. package/dest/block/l2_block_stream/index.js +1 -0
  13. package/dest/block/l2_block_stream/interfaces.d.ts +16 -2
  14. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  15. package/dest/block/l2_block_stream/interfaces.js +25 -1
  16. package/dest/block/l2_block_stream/l2_block_stream.d.ts +21 -35
  17. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  18. package/dest/block/l2_block_stream/l2_block_stream.js +5 -30
  19. package/dest/block/proposal/attestations_and_signers.d.ts +19 -1
  20. package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -1
  21. package/dest/block/proposal/attestations_and_signers.js +47 -7
  22. package/dest/block/validate_block_result.d.ts +16 -1
  23. package/dest/block/validate_block_result.d.ts.map +1 -1
  24. package/dest/block/validate_block_result.js +18 -3
  25. package/dest/config/network-consensus-config.d.ts +1 -1
  26. package/dest/config/network-consensus-config.d.ts.map +1 -1
  27. package/dest/config/network-consensus-config.js +2 -10
  28. package/dest/contract/contract_address.d.ts +5 -4
  29. package/dest/contract/contract_address.d.ts.map +1 -1
  30. package/dest/contract/contract_instance.d.ts +16 -2
  31. package/dest/contract/contract_instance.d.ts.map +1 -1
  32. package/dest/contract/contract_instance.js +45 -0
  33. package/dest/contract/interfaces/contract_instance.d.ts +71 -10
  34. package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
  35. package/dest/contract/interfaces/contract_instance.js +7 -2
  36. package/dest/contract/partial_address.d.ts +9 -3
  37. package/dest/contract/partial_address.d.ts.map +1 -1
  38. package/dest/contract/partial_address.js +8 -2
  39. package/dest/database-version/version_manager.d.ts +18 -4
  40. package/dest/database-version/version_manager.d.ts.map +1 -1
  41. package/dest/database-version/version_manager.js +76 -6
  42. package/dest/ha-signing/config.d.ts +19 -5
  43. package/dest/ha-signing/config.d.ts.map +1 -1
  44. package/dest/ha-signing/config.js +9 -3
  45. package/dest/ha-signing/local_config.d.ts +10 -2
  46. package/dest/ha-signing/local_config.d.ts.map +1 -1
  47. package/dest/ha-signing/local_config.js +8 -2
  48. package/dest/hash/hash.d.ts +1 -2
  49. package/dest/hash/hash.d.ts.map +1 -1
  50. package/dest/hash/hash.js +0 -7
  51. package/dest/interfaces/archiver.d.ts +8 -1
  52. package/dest/interfaces/archiver.d.ts.map +1 -1
  53. package/dest/interfaces/archiver.js +2 -1
  54. package/dest/interfaces/aztec-node-admin.d.ts +5 -2
  55. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  56. package/dest/interfaces/configs.d.ts +4 -1
  57. package/dest/interfaces/configs.d.ts.map +1 -1
  58. package/dest/interfaces/configs.js +1 -0
  59. package/dest/interfaces/private_kernel_prover.d.ts +9 -11
  60. package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
  61. package/dest/interfaces/proving-job.d.ts +87 -74
  62. package/dest/interfaces/proving-job.d.ts.map +1 -1
  63. package/dest/interfaces/proving-job.js +13 -4
  64. package/dest/interfaces/server_circuit_prover.d.ts +3 -3
  65. package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
  66. package/dest/interfaces/validator.d.ts +7 -3
  67. package/dest/interfaces/validator.d.ts.map +1 -1
  68. package/dest/interfaces/world_state.d.ts +14 -1
  69. package/dest/interfaces/world_state.d.ts.map +1 -1
  70. package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +8 -2
  71. package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
  72. package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +12 -74
  73. package/dest/kernel/index.d.ts +2 -2
  74. package/dest/kernel/index.d.ts.map +1 -1
  75. package/dest/kernel/index.js +1 -1
  76. package/dest/kernel/private_circuit_public_inputs.d.ts +13 -3
  77. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  78. package/dest/kernel/private_circuit_public_inputs.js +14 -7
  79. package/dest/kernel/private_context_inputs.d.ts +4 -3
  80. package/dest/kernel/private_context_inputs.d.ts.map +1 -1
  81. package/dest/kernel/private_context_inputs.js +7 -3
  82. package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +7 -1
  83. package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
  84. package/dest/kernel/private_kernel_circuit_public_inputs.js +7 -0
  85. package/dest/kernel/private_kernel_init_2_circuit_private_inputs.d.ts +2 -3
  86. package/dest/kernel/private_kernel_init_2_circuit_private_inputs.d.ts.map +1 -1
  87. package/dest/kernel/private_kernel_init_2_circuit_private_inputs.js +3 -5
  88. package/dest/kernel/private_kernel_init_3_circuit_private_inputs.d.ts +2 -3
  89. package/dest/kernel/private_kernel_init_3_circuit_private_inputs.d.ts.map +1 -1
  90. package/dest/kernel/private_kernel_init_3_circuit_private_inputs.js +3 -5
  91. package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts +1 -9
  92. package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts.map +1 -1
  93. package/dest/kernel/private_kernel_init_circuit_private_inputs.js +2 -6
  94. package/dest/kernel/private_kernel_reset_dimensions.d.ts +7 -8
  95. package/dest/kernel/private_kernel_reset_dimensions.d.ts.map +1 -1
  96. package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.d.ts +29 -0
  97. package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.d.ts.map +1 -0
  98. package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.js +36 -0
  99. package/dest/keys/derivation.d.ts +41 -6
  100. package/dest/keys/derivation.d.ts.map +1 -1
  101. package/dest/keys/derivation.js +49 -26
  102. package/dest/logs/app_tagging_secret.d.ts +16 -8
  103. package/dest/logs/app_tagging_secret.d.ts.map +1 -1
  104. package/dest/logs/app_tagging_secret.js +24 -27
  105. package/dest/logs/index.d.ts +1 -3
  106. package/dest/logs/index.d.ts.map +1 -1
  107. package/dest/logs/index.js +0 -2
  108. package/dest/logs/shared_secret_derivation.d.ts +29 -6
  109. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  110. package/dest/logs/shared_secret_derivation.js +44 -11
  111. package/dest/messaging/l1_to_l2_message.d.ts +23 -2
  112. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  113. package/dest/messaging/l1_to_l2_message.js +36 -11
  114. package/dest/p2p/attestation_utils.d.ts +1 -1
  115. package/dest/p2p/attestation_utils.d.ts.map +1 -1
  116. package/dest/p2p/attestation_utils.js +8 -1
  117. package/dest/p2p/checkpoint_attestation.d.ts +9 -1
  118. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  119. package/dest/p2p/checkpoint_attestation.js +10 -0
  120. package/dest/p2p/signature_utils.d.ts +10 -1
  121. package/dest/p2p/signature_utils.d.ts.map +1 -1
  122. package/dest/p2p/signature_utils.js +9 -1
  123. package/dest/rollup/avm_proof_data.d.ts +3 -3
  124. package/dest/rollup/avm_proof_data.d.ts.map +1 -1
  125. package/dest/stats/stats.d.ts +2 -2
  126. package/dest/stats/stats.d.ts.map +1 -1
  127. package/dest/tests/factories.d.ts +1 -1
  128. package/dest/tests/factories.d.ts.map +1 -1
  129. package/dest/tests/factories.js +4 -3
  130. package/dest/tx/private_tx_constant_data.d.ts +18 -2
  131. package/dest/tx/private_tx_constant_data.d.ts.map +1 -1
  132. package/dest/tx/private_tx_constant_data.js +13 -4
  133. package/dest/tx/simulated_tx.d.ts +10 -6
  134. package/dest/tx/simulated_tx.d.ts.map +1 -1
  135. package/dest/world-state/genesis_data.d.ts +9 -1
  136. package/dest/world-state/genesis_data.d.ts.map +1 -1
  137. package/dest/world-state/genesis_data.js +1 -0
  138. package/package.json +8 -8
  139. package/src/block/attestation_info.ts +7 -2
  140. package/src/block/l2_block_source.ts +54 -2
  141. package/src/block/l2_block_stream/event_driven_l2_block_stream.ts +207 -0
  142. package/src/block/l2_block_stream/index.ts +1 -0
  143. package/src/block/l2_block_stream/interfaces.ts +35 -1
  144. package/src/block/l2_block_stream/l2_block_stream.ts +35 -62
  145. package/src/block/proposal/attestations_and_signers.ts +53 -7
  146. package/src/block/validate_block_result.ts +48 -2
  147. package/src/config/network-consensus-config.ts +2 -13
  148. package/src/contract/contract_address.ts +4 -3
  149. package/src/contract/contract_instance.ts +62 -1
  150. package/src/contract/interfaces/contract_instance.ts +26 -8
  151. package/src/contract/partial_address.ts +8 -2
  152. package/src/database-version/version_manager.ts +96 -6
  153. package/src/gas/README.md +108 -36
  154. package/src/ha-signing/config.ts +23 -5
  155. package/src/ha-signing/local_config.ts +20 -1
  156. package/src/hash/hash.ts +0 -8
  157. package/src/interfaces/archiver.ts +8 -0
  158. package/src/interfaces/configs.ts +3 -0
  159. package/src/interfaces/private_kernel_prover.ts +10 -12
  160. package/src/interfaces/proving-job.ts +15 -3
  161. package/src/interfaces/server_circuit_prover.ts +2 -2
  162. package/src/interfaces/world_state.ts +14 -0
  163. package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +22 -112
  164. package/src/kernel/index.ts +1 -1
  165. package/src/kernel/private_circuit_public_inputs.ts +12 -1
  166. package/src/kernel/private_context_inputs.ts +10 -3
  167. package/src/kernel/private_kernel_circuit_public_inputs.ts +9 -0
  168. package/src/kernel/private_kernel_init_2_circuit_private_inputs.ts +0 -3
  169. package/src/kernel/private_kernel_init_3_circuit_private_inputs.ts +0 -3
  170. package/src/kernel/private_kernel_init_circuit_private_inputs.ts +0 -6
  171. package/src/kernel/private_kernel_reset_dimensions.ts +15 -5
  172. package/src/kernel/private_kernel_reset_tail_circuit_private_inputs.ts +69 -0
  173. package/src/keys/derivation.ts +69 -24
  174. package/src/logs/app_tagging_secret.ts +34 -27
  175. package/src/logs/index.ts +0 -2
  176. package/src/logs/shared_secret_derivation.ts +47 -14
  177. package/src/messaging/l1_to_l2_message.ts +51 -13
  178. package/src/p2p/attestation_utils.ts +8 -1
  179. package/src/p2p/checkpoint_attestation.ts +12 -0
  180. package/src/p2p/signature_utils.ts +9 -0
  181. package/src/rollup/avm_proof_data.ts +2 -2
  182. package/src/stats/stats.ts +2 -2
  183. package/src/tests/factories.ts +3 -6
  184. package/src/tx/private_tx_constant_data.ts +25 -2
  185. package/src/world-state/genesis_data.ts +10 -0
  186. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +0 -47
  187. package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +0 -1
  188. package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +0 -38
  189. package/dest/logs/message_context.d.ts +0 -17
  190. package/dest/logs/message_context.d.ts.map +0 -1
  191. package/dest/logs/message_context.js +0 -9
  192. package/dest/logs/pending_tagged_log.d.ts +0 -11
  193. package/dest/logs/pending_tagged_log.d.ts.map +0 -1
  194. package/dest/logs/pending_tagged_log.js +0 -4
  195. package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +0 -58
  196. package/src/logs/message_context.ts +0 -18
  197. package/src/logs/pending_tagged_log.ts +0 -12
@@ -1,4 +1,9 @@
1
- import { type ConfigMappingsType, getConfigFromMappings, optionalNumberConfigHelper } from '@aztec/foundation/config';
1
+ import {
2
+ type ConfigMappingsType,
3
+ booleanConfigHelper,
4
+ getConfigFromMappings,
5
+ optionalNumberConfigHelper,
6
+ } from '@aztec/foundation/config';
2
7
  import { zodFor } from '@aztec/foundation/schemas';
3
8
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
4
9
 
@@ -17,6 +22,12 @@ export type LocalSignerConfig = BaseSignerConfig &
17
22
  DataStoreConfig & {
18
23
  /** Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb. */
19
24
  signingProtectionMapSizeKb?: number;
25
+ /**
26
+ * Allow local signing protection to run against an ephemeral store when no data directory is set.
27
+ * Without this, a missing data directory fails startup, since ephemeral protection does not survive
28
+ * restarts. Intended for dev/test networks only; production validators must persist to disk.
29
+ */
30
+ allowEphemeralSigningProtection?: boolean;
20
31
  };
21
32
 
22
33
  export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> = {
@@ -28,6 +39,13 @@ export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> =
28
39
  'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
29
40
  ...optionalNumberConfigHelper(),
30
41
  },
42
+ allowEphemeralSigningProtection: {
43
+ env: 'VALIDATOR_ALLOW_EPHEMERAL_SIGNING_PROTECTION',
44
+ description:
45
+ 'Allow local signing protection to run against an ephemeral store when no data directory is set (dev/test only). ' +
46
+ 'Ephemeral protection does not survive restarts, so this is unsafe for production validators.',
47
+ ...booleanConfigHelper(false),
48
+ },
31
49
  };
32
50
 
33
51
  export const LocalSignerConfigSchema = zodFor<LocalSignerConfig>()(
@@ -35,6 +53,7 @@ export const LocalSignerConfigSchema = zodFor<LocalSignerConfig>()(
35
53
  dataDirectory: z.string().optional(),
36
54
  dataStoreMapSizeKb: z.number(),
37
55
  signingProtectionMapSizeKb: z.number().optional(),
56
+ allowEphemeralSigningProtection: z.boolean().optional(),
38
57
  }),
39
58
  );
40
59
 
package/src/hash/hash.ts CHANGED
@@ -188,14 +188,6 @@ export function computeSecretHash(secret: Fr): Promise<Fr> {
188
188
  return poseidon2HashWithSeparator([secret], DomainSeparator.SECRET_HASH);
189
189
  }
190
190
 
191
- export async function computeL1ToL2MessageNullifier(contract: AztecAddress, messageHash: Fr, secret: Fr) {
192
- const innerMessageNullifier = await poseidon2HashWithSeparator(
193
- [messageHash, secret],
194
- DomainSeparator.MESSAGE_NULLIFIER,
195
- );
196
- return siloNullifier(contract, innerMessageNullifier);
197
- }
198
-
199
191
  /**
200
192
  * Calculates a siloed hash of a scoped l2 to l1 message.
201
193
  * @returns Fr containing 248 bits of information of sha256 hash.
@@ -68,6 +68,13 @@ export type ArchiverSpecificConfig = {
68
68
 
69
69
  /** Skip pruning orphan proposed blocks that have no matching proposed checkpoint. */
70
70
  skipOrphanProposedBlockPruning?: boolean;
71
+
72
+ /**
73
+ * Preload the standard contracts (AuthRegistry, PublicChecks, HandshakeRegistry) into the contract store at block 0.
74
+ * For test environments only: it must only be set when genesis also seeds the matching registration/deployment
75
+ * nullifiers, otherwise a later on-chain publish of a preloaded class would collide with the block-0 preload.
76
+ */
77
+ testPreloadStandardContracts?: boolean;
71
78
  };
72
79
 
73
80
  export const ArchiverSpecificConfigSchema = z.object({
@@ -82,6 +89,7 @@ export const ArchiverSpecificConfigSchema = z.object({
82
89
  skipPromoteProposedCheckpointDuringL1Sync: z.boolean().optional(),
83
90
  orphanPruneNoProposalTolerance: schemas.Integer.optional(),
84
91
  skipOrphanProposedBlockPruning: z.boolean().optional(),
92
+ testPreloadStandardContracts: z.boolean().optional(),
85
93
  });
86
94
 
87
95
  export type ArchiverApi = Omit<
@@ -96,6 +96,8 @@ export interface SequencerConfig {
96
96
  injectHighSValueAttestation?: boolean;
97
97
  /** Inject an attestation with an unrecoverable signature (for testing only) */
98
98
  injectUnrecoverableSignatureAttestation?: boolean;
99
+ /** Inject a non-proposer attestation slot in yParity (v ∈ {0, 1}) form in the packed L1 tuple (for testing only) */
100
+ injectYParityAttestation?: boolean;
99
101
  /** Whether to run in fisherman mode: builds blocks on every slot for validation without publishing */
100
102
  fishermanMode?: boolean;
101
103
  /** Shuffle attestation ordering to create invalid ordering (for testing only) */
@@ -165,6 +167,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
165
167
  injectFakeAttestation: z.boolean().optional(),
166
168
  injectHighSValueAttestation: z.boolean().optional(),
167
169
  injectUnrecoverableSignatureAttestation: z.boolean().optional(),
170
+ injectYParityAttestation: z.boolean().optional(),
168
171
  fishermanMode: z.boolean().optional(),
169
172
  shuffleAttestationOrdering: z.boolean().optional(),
170
173
  blockDurationMs: z.number().positive().optional(),
@@ -10,8 +10,8 @@ import type {
10
10
  PrivateKernelInner3CircuitPrivateInputs,
11
11
  PrivateKernelInnerCircuitPrivateInputs,
12
12
  PrivateKernelResetCircuitPrivateInputs,
13
+ PrivateKernelResetTailCircuitPrivateInputs,
13
14
  PrivateKernelSimulateOutput,
14
- PrivateKernelTailCircuitPrivateInputs,
15
15
  PrivateKernelTailCircuitPublicInputs,
16
16
  } from '../kernel/index.js';
17
17
  import type { ChonkProofWithPublicInputs } from '../proofs/chonk_proof.js';
@@ -166,23 +166,21 @@ export interface PrivateKernelProver {
166
166
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
167
167
 
168
168
  /**
169
- * Creates a proof output based on the last inner kernel iteration kernel data for the final ordering iteration.
169
+ * Creates a proof output for the terminal reset+tail step. Dispatches to the rollup-bound or
170
+ * public-bound family based on `inputs.isForPublic()`.
170
171
  *
171
- * @param privateKernelInputsTail - The private input data structure for the final ordering iteration.
172
- * @returns A Promise resolving to a ProofOutput object containing public inputs and the kernel proof.
172
+ * @param privateKernelInputs - Reset hints, dimensions, and tail params.
173
+ * @returns A Promise resolving to a ProofOutput containing the tail-shaped public inputs.
173
174
  */
174
- generateTailOutput(
175
- privateKernelInputsTail: PrivateKernelTailCircuitPrivateInputs,
175
+ generateResetTailOutput(
176
+ privateKernelInputs: PrivateKernelResetTailCircuitPrivateInputs,
176
177
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
177
178
 
178
179
  /**
179
- * Executes the final ordering iteration circuit.
180
- *
181
- * @param privateKernelInputsTail - The private input data structure for the final ordering iteration.
182
- * @returns A Promise resolving to a ProofOutput object containing public inputs an empty kernel proof.
180
+ * Simulates the terminal reset+tail step without generating a proof.
183
181
  */
184
- simulateTail(
185
- privateKernelInputsTail: PrivateKernelTailCircuitPrivateInputs,
182
+ simulateResetTail(
183
+ privateKernelInputs: PrivateKernelResetTailCircuitPrivateInputs,
186
184
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
187
185
 
188
186
  generateHidingToRollupOutput(
@@ -1,5 +1,5 @@
1
1
  import {
2
- AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
2
+ AVM_V2_PROOF_LENGTH_IN_FIELDS,
3
3
  NESTED_RECURSIVE_PROOF_LENGTH,
4
4
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
5
5
  RECURSIVE_PROOF_LENGTH,
@@ -204,7 +204,7 @@ export type ProvingJobInputsMap = {
204
204
  export const ProvingJobResult = z.discriminatedUnion('type', [
205
205
  z.object({
206
206
  type: z.literal(ProvingRequestType.PUBLIC_VM),
207
- result: RecursiveProof.schemaFor(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
207
+ result: RecursiveProof.schemaFor(AVM_V2_PROOF_LENGTH_IN_FIELDS),
208
208
  }),
209
209
  z.object({
210
210
  type: z.literal(ProvingRequestType.PUBLIC_CHONK_VERIFIER),
@@ -319,7 +319,7 @@ export const ProvingJobResult = z.discriminatedUnion('type', [
319
319
  ]);
320
320
  export type ProvingJobResult = z.infer<typeof ProvingJobResult>;
321
321
  export type ProvingJobResultsMap = {
322
- [ProvingRequestType.PUBLIC_VM]: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>;
322
+ [ProvingRequestType.PUBLIC_VM]: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS>;
323
323
  [ProvingRequestType.PUBLIC_CHONK_VERIFIER]: PublicInputsAndRecursiveProof<
324
324
  PublicChonkVerifierPublicInputs,
325
325
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
@@ -441,9 +441,20 @@ export const ProvingJobRejectedResult = z.object({
441
441
  });
442
442
  export type ProvingJobRejectedResult = z.infer<typeof ProvingJobRejectedResult>;
443
443
 
444
+ /**
445
+ * The result of a job that was cancelled by its producer. Unlike a fulfilled or rejected result it
446
+ * is not truly terminal: re-enqueuing the same job id revives it, so an abort never permanently
447
+ * blocks a proof from being produced.
448
+ */
449
+ export const ProvingJobAbortedResult = z.object({
450
+ status: z.literal('aborted'),
451
+ });
452
+ export type ProvingJobAbortedResult = z.infer<typeof ProvingJobAbortedResult>;
453
+
444
454
  export const ProvingJobSettledResult = z.discriminatedUnion('status', [
445
455
  ProvingJobFulfilledResult,
446
456
  ProvingJobRejectedResult,
457
+ ProvingJobAbortedResult,
447
458
  ]);
448
459
  export type ProvingJobSettledResult = z.infer<typeof ProvingJobSettledResult>;
449
460
 
@@ -453,5 +464,6 @@ export const ProvingJobStatus = z.discriminatedUnion('status', [
453
464
  z.object({ status: z.literal('not-found') }),
454
465
  ProvingJobFulfilledResult,
455
466
  ProvingJobRejectedResult,
467
+ ProvingJobAbortedResult,
456
468
  ]);
457
469
  export type ProvingJobStatus = z.infer<typeof ProvingJobStatus>;
@@ -1,5 +1,5 @@
1
1
  import type {
2
- AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
2
+ AVM_V2_PROOF_LENGTH_IN_FIELDS,
3
3
  NESTED_RECURSIVE_PROOF_LENGTH,
4
4
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
5
5
  RECURSIVE_PROOF_LENGTH,
@@ -189,7 +189,7 @@ export interface ServerCircuitProver {
189
189
  inputs: AvmCircuitInputs,
190
190
  signal?: AbortSignal,
191
191
  epochNumber?: number,
192
- ): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>>;
192
+ ): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS>>;
193
193
  }
194
194
 
195
195
  export type IVCProofVerificationResult = {
@@ -65,6 +65,20 @@ export interface ReadonlyWorldStateAccess {
65
65
 
66
66
  /** Defines the interface for a world state synchronizer. */
67
67
  export interface WorldStateSynchronizer extends ReadonlyWorldStateAccess, ForkMerkleTreeOperations {
68
+ /**
69
+ * Returns a read handle to the world state at `blockNumber`, but only after verifying that the block at that
70
+ * height is on the fork identified by `blockHash`. This pins the returned view to a specific fork so a reorg
71
+ * that replaced the block at `blockNumber` cannot be served silently, closing the gap between resolving a query
72
+ * and reading its snapshot.
73
+ *
74
+ * Rejects if the block at `blockNumber` does not match `blockHash` (a reorg), or if the block's hash cannot be
75
+ * read from the requested view. Both are transient from a caller's perspective: re-resolving the query against
76
+ * the current chain and retrying may succeed or produce a more precise error. However, if the block's history
77
+ * has been pruned away (it predates the oldest historical block kept by world state), the rejection is terminal:
78
+ * retrying cannot bring the data back.
79
+ */
80
+ getVerifiedSnapshot(blockNumber: BlockNumber, blockHash: BlockHash): Promise<MerkleTreeReadOperations>;
81
+
68
82
  /** Starts the synchronizer. */
69
83
  start(): Promise<void | PromiseWithResolvers<void>>;
70
84
 
@@ -1,8 +1,7 @@
1
- import { isDefined } from '@aztec/foundation/types';
2
-
3
1
  import {
4
2
  PrivateKernelResetDimensions,
5
3
  type PrivateKernelResetDimensionsConfig,
4
+ type ResetCatalogEntry,
6
5
  privateKernelResetDimensionNames,
7
6
  } from '../private_kernel_reset_dimensions.js';
8
7
 
@@ -12,13 +11,6 @@ interface DimensionOption {
12
11
  remainder?: PrivateKernelResetDimensions;
13
12
  }
14
13
 
15
- function computeCost(dimensions: PrivateKernelResetDimensions, config: PrivateKernelResetDimensionsConfig) {
16
- return privateKernelResetDimensionNames.reduce(
17
- (accum, name) => accum + dimensions[name] * config.dimensions[name].cost,
18
- 0,
19
- );
20
- }
21
-
22
14
  function getSize(dimensions: PrivateKernelResetDimensions) {
23
15
  return privateKernelResetDimensionNames.reduce((accum, name) => accum + dimensions[name], 0);
24
16
  }
@@ -38,124 +30,42 @@ function getRemainder(
38
30
  return remainingDimensions ? remainder : undefined;
39
31
  }
40
32
 
41
- function pickFromValues(targetValue: number, values: number[]) {
42
- // Find the min value in `values` that's greater than or equal to `targetValue`.
43
- const minGte = values.reduce(
44
- (prev: number | undefined, curr) => (curr >= targetValue && (prev === undefined || curr < prev) ? curr : prev),
45
- undefined,
46
- );
47
-
48
- // If no such value is found, returns the max value.
49
- return minGte ?? Math.max(...values);
50
- }
51
-
52
- function pickCheapest(options: DimensionOption[]) {
53
- return options.reduce((prev, curr) => (curr.cost < prev.cost ? curr : prev), options[0]);
54
- }
55
-
56
- function pickSmallestRemainder(options: DimensionOption[]) {
57
- const optionsWithSize = options
58
- .filter(o => o.remainder)
59
- .map(option => ({ option, size: getSize(option.remainder!) }));
60
- return optionsWithSize.reduce((prev, curr) => (curr.size < prev.size ? curr : prev), optionsWithSize[0])?.option;
61
- }
62
-
63
- function pickBestOption(options: DimensionOption[]) {
64
- const optionsResetAll = options.filter(opt => !opt.remainder);
65
- const optionsResetPartial = options.filter(opt => opt.remainder);
66
- // The best option is the cheapest one that can reset all dimensions.
67
- // If no such option exists, find one that can reset the most data.
68
- return pickCheapest(optionsResetAll) || pickSmallestRemainder(optionsResetPartial);
69
- }
70
-
71
- function findVariant(
72
- requestedDimensions: PrivateKernelResetDimensions,
73
- config: PrivateKernelResetDimensionsConfig,
74
- isQualified: (dimensions: PrivateKernelResetDimensions) => boolean,
75
- ): DimensionOption | undefined {
76
- const variant = PrivateKernelResetDimensions.empty();
77
- privateKernelResetDimensionNames.forEach(name => {
78
- variant[name] = pickFromValues(requestedDimensions[name], config.dimensions[name].variants);
79
- });
80
- if (!isQualified(variant)) {
81
- return;
33
+ // Returns the cheapest option that fully covers the request, or the option with the smallest
34
+ // remainder if none do. Caller must pass a non-empty list.
35
+ function pickBestOption(options: DimensionOption[]): DimensionOption {
36
+ const fullCoverage = options.filter(opt => !opt.remainder);
37
+ if (fullCoverage.length) {
38
+ return fullCoverage.reduce((prev, curr) => (curr.cost < prev.cost ? curr : prev));
82
39
  }
83
-
84
- return {
85
- dimensions: variant,
86
- cost: computeCost(variant, config),
87
- remainder: getRemainder(requestedDimensions, variant),
88
- };
40
+ return options.reduce((prev, curr) => (getSize(curr.remainder!) < getSize(prev.remainder!) ? curr : prev));
89
41
  }
90
42
 
91
- function findStandalone(
92
- requestedDimensions: PrivateKernelResetDimensions,
93
- config: PrivateKernelResetDimensionsConfig,
94
- isQualified: (dimensions: PrivateKernelResetDimensions) => boolean,
95
- ): DimensionOption | undefined {
96
- const needsReset = privateKernelResetDimensionNames.filter(name => requestedDimensions[name] > 0);
97
- if (needsReset.length !== 1) {
98
- // At the moment, we only use standalone to reset one dimension when it's about to overflow.
99
- return;
100
- }
101
-
102
- const name = needsReset[0];
103
- const value = pickFromValues(requestedDimensions[name], config.dimensions[name].standalone);
104
- if (!value) {
105
- return;
106
- }
107
-
108
- const dimensions = PrivateKernelResetDimensions.from({ [name]: value });
109
- if (!isQualified(dimensions)) {
110
- return;
111
- }
112
-
43
+ function buildOption(entry: ResetCatalogEntry, requestedDimensions: PrivateKernelResetDimensions): DimensionOption {
44
+ const dimensions = PrivateKernelResetDimensions.fromValues(entry.dimensions);
113
45
  return {
114
46
  dimensions,
115
- cost: computeCost(dimensions, config),
47
+ cost: entry.cost,
116
48
  remainder: getRemainder(requestedDimensions, dimensions),
117
49
  };
118
50
  }
119
51
 
120
- function findSpecialCase(
121
- requestedDimensions: PrivateKernelResetDimensions,
122
- config: PrivateKernelResetDimensionsConfig,
123
- isQualified: (dimensions: PrivateKernelResetDimensions) => boolean,
124
- ): DimensionOption | undefined {
125
- const specialCases = config.specialCases.map(PrivateKernelResetDimensions.fromValues);
126
- const options = specialCases.filter(isQualified).map(dimensions => ({
127
- dimensions,
128
- cost: computeCost(dimensions, config),
129
- remainder: getRemainder(requestedDimensions, dimensions),
130
- }));
131
- return pickBestOption(options);
132
- }
52
+ /**
53
+ * Picks which catalog group the selector should search. Mid-tx resets go to `inner` (no
54
+ * siloing); terminal kernels go to `finalTail` or `finalTailToPublic`, depending on whether
55
+ * the tx has public function calls.
56
+ */
57
+ export type ResetDimensionsMode = 'inner' | 'finalTail' | 'finalTailToPublic';
133
58
 
134
59
  export function findPrivateKernelResetDimensions(
135
60
  requestedDimensions: PrivateKernelResetDimensions,
136
61
  config: PrivateKernelResetDimensionsConfig,
137
- isInner = false,
62
+ mode: ResetDimensionsMode,
138
63
  allowRemainder = false,
139
64
  ) {
140
- const requestedValues = requestedDimensions.toValues();
141
- const isEnough = allowRemainder
142
- ? () => true
143
- : (dimensions: PrivateKernelResetDimensions) => dimensions.toValues().every((v, i) => v >= requestedValues[i]);
144
-
145
- const isQualified = !isInner
146
- ? isEnough
147
- : // If isInner is true, it's a reset to prevent overflow. The following must be zero because siloing can't be done at the moment.
148
- (dimensions: PrivateKernelResetDimensions) =>
149
- dimensions.NOTE_HASH_SILOING === 0 &&
150
- dimensions.NULLIFIER_SILOING === 0 &&
151
- dimensions.PRIVATE_LOG_SILOING === 0 &&
152
- isEnough(dimensions);
153
-
154
- const options = [
155
- findVariant(requestedDimensions, config, isQualified),
156
- findStandalone(requestedDimensions, config, isQualified),
157
- findSpecialCase(requestedDimensions, config, isQualified),
158
- ].filter(isDefined);
65
+ const catalog = config[mode];
66
+ const options = catalog
67
+ .map(entry => buildOption(entry, requestedDimensions))
68
+ .filter(option => allowRemainder || !option.remainder);
159
69
 
160
70
  if (!options.length) {
161
71
  throw new Error(`Cannot find an option for dimension: ${requestedDimensions.toValues()}`);
@@ -14,7 +14,7 @@ export * from './private_kernel_inner_2_circuit_private_inputs.js';
14
14
  export * from './private_kernel_inner_3_circuit_private_inputs.js';
15
15
  export * from './private_kernel_reset_circuit_private_inputs.js';
16
16
  export * from './private_kernel_reset_dimensions.js';
17
- export * from './private_kernel_tail_circuit_private_inputs.js';
17
+ export * from './private_kernel_reset_tail_circuit_private_inputs.js';
18
18
  export * from './private_kernel_tail_circuit_public_inputs.js';
19
19
  export * from './private_to_avm_accumulated_data.js';
20
20
  export * from './private_to_public_accumulated_data.js';
@@ -144,6 +144,11 @@ export class PrivateCircuitPublicInputs {
144
144
  * Hash of the contract class logs emitted in this function call.
145
145
  */
146
146
  public contractClassLogsHashes: ClaimedLengthArray<CountedLogHash, typeof MAX_CONTRACT_CLASS_LOGS_PER_CALL>,
147
+ /**
148
+ * The tx request's salt. Keeps `tx_request.hash()` (the protocol nullifier) unpredictable, and lets the init
149
+ * kernel bind this proof to a specific tx request (it asserts this equals `tx_request.salt`).
150
+ */
151
+ public txRequestSalt: Fr,
147
152
  ) {}
148
153
 
149
154
  /**
@@ -188,6 +193,7 @@ export class PrivateCircuitPublicInputs {
188
193
  reader.readObject(ClaimedLengthArrayFromBuffer(CountedL2ToL1Message, MAX_L2_TO_L1_MSGS_PER_CALL)),
189
194
  reader.readObject(ClaimedLengthArrayFromBuffer(PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL)),
190
195
  reader.readObject(ClaimedLengthArrayFromBuffer(CountedLogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL)),
196
+ reader.readObject(Fr),
191
197
  );
192
198
  }
193
199
 
@@ -219,6 +225,7 @@ export class PrivateCircuitPublicInputs {
219
225
  reader.readObject(ClaimedLengthArrayFromFields(CountedL2ToL1Message, MAX_L2_TO_L1_MSGS_PER_CALL)),
220
226
  reader.readObject(ClaimedLengthArrayFromFields(PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL)),
221
227
  reader.readObject(ClaimedLengthArrayFromFields(CountedLogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL)),
228
+ reader.readField(),
222
229
  );
223
230
  }
224
231
 
@@ -251,6 +258,7 @@ export class PrivateCircuitPublicInputs {
251
258
  ClaimedLengthArray.empty(CountedL2ToL1Message, MAX_L2_TO_L1_MSGS_PER_CALL),
252
259
  ClaimedLengthArray.empty(PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL),
253
260
  ClaimedLengthArray.empty(CountedLogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL),
261
+ Fr.ZERO,
254
262
  );
255
263
  }
256
264
 
@@ -278,7 +286,8 @@ export class PrivateCircuitPublicInputs {
278
286
  this.nullifiers.isEmpty() &&
279
287
  this.l2ToL1Msgs.isEmpty() &&
280
288
  this.privateLogs.isEmpty() &&
281
- this.contractClassLogsHashes.isEmpty()
289
+ this.contractClassLogsHashes.isEmpty() &&
290
+ this.txRequestSalt.isZero()
282
291
  );
283
292
  }
284
293
 
@@ -312,6 +321,7 @@ export class PrivateCircuitPublicInputs {
312
321
  fields.l2ToL1Msgs,
313
322
  fields.privateLogs,
314
323
  fields.contractClassLogsHashes,
324
+ fields.txRequestSalt,
315
325
  ] as const;
316
326
  }
317
327
 
@@ -346,6 +356,7 @@ export class PrivateCircuitPublicInputs {
346
356
  this.l2ToL1Msgs,
347
357
  this.privateLogs,
348
358
  this.contractClassLogsHashes,
359
+ this.txRequestSalt,
349
360
  ]);
350
361
  }
351
362
 
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/curves/bn254';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { serializeToFields } from '@aztec/foundation/serialize';
3
3
 
4
4
  import { BlockHeader } from '../tx/block_header.js';
@@ -11,13 +11,20 @@ export class PrivateContextInputs {
11
11
  public anchorBlockHeader: BlockHeader,
12
12
  public txContext: TxContext,
13
13
  public startSideEffectCounter: number,
14
+ public txRequestSalt: Fr,
14
15
  ) {}
15
16
 
16
17
  public static empty(): PrivateContextInputs {
17
- return new PrivateContextInputs(CallContext.empty(), BlockHeader.empty(), TxContext.empty(), 0);
18
+ return new PrivateContextInputs(CallContext.empty(), BlockHeader.empty(), TxContext.empty(), 0, Fr.ZERO);
18
19
  }
19
20
 
20
21
  public toFields(): Fr[] {
21
- return serializeToFields([this.callContext, this.anchorBlockHeader, this.txContext, this.startSideEffectCounter]);
22
+ return serializeToFields([
23
+ this.callContext,
24
+ this.anchorBlockHeader,
25
+ this.txContext,
26
+ this.startSideEffectCounter,
27
+ this.txRequestSalt,
28
+ ]);
22
29
  }
23
30
  }
@@ -115,3 +115,12 @@ export class PrivateKernelCircuitPublicInputs {
115
115
  );
116
116
  }
117
117
  }
118
+
119
+ /**
120
+ * Returns true iff the tx requires the public-bound terminal path: it has either un-processed
121
+ * public-call requests in the side-effect stream or a pending public-teardown call request. Every
122
+ * site picking between the rollup-bound and public-bound terminal artifact must route through this.
123
+ */
124
+ export function kernelStateIsForPublic(publicInputs: PrivateKernelCircuitPublicInputs): boolean {
125
+ return publicInputs.end.publicCallRequests.claimedLength > 0 || !publicInputs.publicTeardownCallRequest.isEmpty();
126
+ }
@@ -17,7 +17,6 @@ export class PrivateKernelInit2CircuitPrivateInputs {
17
17
  public privateCall0: PrivateCallData,
18
18
  public privateCall1: PrivateCallData,
19
19
  public isPrivateOnly: boolean,
20
- public firstNullifierHint: Fr,
21
20
  public revertibleCounterHint: number,
22
21
  ) {}
23
22
 
@@ -28,7 +27,6 @@ export class PrivateKernelInit2CircuitPrivateInputs {
28
27
  this.protocolContracts,
29
28
  this.privateCall0,
30
29
  this.privateCall1,
31
- this.firstNullifierHint,
32
30
  this.revertibleCounterHint,
33
31
  );
34
32
  }
@@ -42,7 +40,6 @@ export class PrivateKernelInit2CircuitPrivateInputs {
42
40
  reader.readObject(PrivateCallData),
43
41
  reader.readObject(PrivateCallData),
44
42
  reader.readBoolean(),
45
- Fr.fromBuffer(reader),
46
43
  reader.readNumber(),
47
44
  );
48
45
  }
@@ -18,7 +18,6 @@ export class PrivateKernelInit3CircuitPrivateInputs {
18
18
  public privateCall1: PrivateCallData,
19
19
  public privateCall2: PrivateCallData,
20
20
  public isPrivateOnly: boolean,
21
- public firstNullifierHint: Fr,
22
21
  public revertibleCounterHint: number,
23
22
  ) {}
24
23
 
@@ -30,7 +29,6 @@ export class PrivateKernelInit3CircuitPrivateInputs {
30
29
  this.privateCall0,
31
30
  this.privateCall1,
32
31
  this.privateCall2,
33
- this.firstNullifierHint,
34
32
  this.revertibleCounterHint,
35
33
  );
36
34
  }
@@ -45,7 +43,6 @@ export class PrivateKernelInit3CircuitPrivateInputs {
45
43
  reader.readObject(PrivateCallData),
46
44
  reader.readObject(PrivateCallData),
47
45
  reader.readBoolean(),
48
- Fr.fromBuffer(reader),
49
46
  reader.readNumber(),
50
47
  );
51
48
  }
@@ -30,10 +30,6 @@ export class PrivateKernelInitCircuitPrivateInputs {
30
30
  * Wether this tx will make public calls or not.
31
31
  */
32
32
  public isPrivateOnly: boolean,
33
- /**
34
- * A hint to what will be the first nullifier of the transaction, used for nonce generation.
35
- */
36
- public firstNullifierHint: Fr,
37
33
  /**
38
34
  * A claim to the final min revertible side effect counter of a tx.
39
35
  */
@@ -50,7 +46,6 @@ export class PrivateKernelInitCircuitPrivateInputs {
50
46
  this.vkTreeRoot,
51
47
  this.protocolContracts,
52
48
  this.privateCall,
53
- this.firstNullifierHint,
54
49
  this.revertibleCounterHint,
55
50
  );
56
51
  }
@@ -68,7 +63,6 @@ export class PrivateKernelInitCircuitPrivateInputs {
68
63
  reader.readObject(ProtocolContracts),
69
64
  reader.readObject(PrivateCallData),
70
65
  reader.readBoolean(),
71
- Fr.fromBuffer(reader),
72
66
  reader.readNumber(),
73
67
  );
74
68
  }
@@ -68,14 +68,24 @@ export const privateKernelResetDimensionNames: DimensionName[] = [
68
68
  'PRIVATE_LOG_SILOING',
69
69
  ];
70
70
 
71
- export interface DimensionConfig {
72
- variants: number[];
73
- standalone: number[];
71
+ export interface ResetCatalogEntry {
72
+ name: string;
73
+ dimensions: number[];
74
+ // Measured gate count (circuit_size) of the compiled variant. Used by the selector to pick the
75
+ // cheapest variant that covers the requested dimensions, e.g. if the required dimensions are
76
+ // `6 - 2 - 2` then a variant with capacity `8 - 2 - 2` might be cheaper than one with capacity
77
+ // `6 - 4 - 4`.
74
78
  cost: number;
75
79
  }
76
80
 
77
81
  // Must match the config in noir-projects/noir-protocol-circuits/private_kernel_reset_config.json
78
82
  export interface PrivateKernelResetDimensionsConfig {
79
- dimensions: { [K in DimensionName]: DimensionConfig };
80
- specialCases: number[][];
83
+ // Variants used for mid-tx resets that prevent overflow. Never the last kernel in the chain.
84
+ inner: ResetCatalogEntry[];
85
+ // Variants used as the terminal kernel for the rollup-bound private-only path. Each runs
86
+ // final-reset siloing and tail finalisation in one proof.
87
+ finalTail: ResetCatalogEntry[];
88
+ // Terminal variants for the public-bound path (transactions with public function calls). Runs
89
+ // final-reset siloing and tail-to-public partitioning by revertibility in one proof.
90
+ finalTailToPublic: ResetCatalogEntry[];
81
91
  }