@aztec/stdlib 0.80.0 → 0.82.0

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 (201) hide show
  1. package/dest/abi/abi.d.ts +5 -1
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +2 -1
  4. package/dest/abi/contract_artifact.d.ts.map +1 -1
  5. package/dest/abi/contract_artifact.js +11 -0
  6. package/dest/auth_witness/auth_witness.d.ts +21 -0
  7. package/dest/auth_witness/auth_witness.d.ts.map +1 -1
  8. package/dest/auth_witness/auth_witness.js +29 -0
  9. package/dest/avm/avm.d.ts +173 -405
  10. package/dest/avm/avm.d.ts.map +1 -1
  11. package/dest/avm/avm.js +34 -27
  12. package/dest/avm/avm_proving_request.d.ts +84 -186
  13. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  14. package/dest/avm/public_data_write.d.ts +1 -0
  15. package/dest/avm/public_data_write.d.ts.map +1 -1
  16. package/dest/avm/public_data_write.js +3 -0
  17. package/dest/block/body.d.ts +1 -0
  18. package/dest/block/body.d.ts.map +1 -1
  19. package/dest/block/body.js +3 -0
  20. package/dest/block/index.d.ts +1 -1
  21. package/dest/block/index.d.ts.map +1 -1
  22. package/dest/block/index.js +1 -1
  23. package/dest/block/l2_block.d.ts +2 -1
  24. package/dest/block/l2_block.d.ts.map +1 -1
  25. package/dest/block/l2_block.js +3 -0
  26. package/dest/block/l2_block_downloader/l2_block_stream.d.ts +3 -3
  27. package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
  28. package/dest/block/l2_block_downloader/l2_block_stream.js +2 -4
  29. package/dest/block/l2_block_source.d.ts +9 -0
  30. package/dest/block/l2_block_source.d.ts.map +1 -1
  31. package/dest/block/published_l2_block.d.ts +89 -0
  32. package/dest/block/published_l2_block.d.ts.map +1 -0
  33. package/dest/block/published_l2_block.js +32 -0
  34. package/dest/contract/interfaces/contract_data_source.d.ts +3 -14
  35. package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
  36. package/dest/database-version/version_manager.d.ts +5 -0
  37. package/dest/database-version/version_manager.d.ts.map +1 -1
  38. package/dest/database-version/version_manager.js +8 -1
  39. package/dest/interfaces/archiver.d.ts +1 -2
  40. package/dest/interfaces/archiver.d.ts.map +1 -1
  41. package/dest/interfaces/archiver.js +5 -6
  42. package/dest/interfaces/aztec-node-admin.d.ts +20 -0
  43. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -0
  44. package/dest/interfaces/aztec-node-admin.js +16 -0
  45. package/dest/interfaces/aztec-node.d.ts +9 -39
  46. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  47. package/dest/interfaces/aztec-node.js +6 -12
  48. package/dest/interfaces/client.d.ts +1 -0
  49. package/dest/interfaces/client.d.ts.map +1 -1
  50. package/dest/interfaces/client.js +1 -0
  51. package/dest/interfaces/private_kernel_prover.d.ts +2 -3
  52. package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
  53. package/dest/interfaces/prover-node.d.ts +1 -2
  54. package/dest/interfaces/prover-node.d.ts.map +1 -1
  55. package/dest/interfaces/prover-node.js +5 -4
  56. package/dest/interfaces/proving-job.d.ts +106 -208
  57. package/dest/interfaces/proving-job.d.ts.map +1 -1
  58. package/dest/interfaces/pxe.d.ts +21 -39
  59. package/dest/interfaces/pxe.d.ts.map +1 -1
  60. package/dest/interfaces/pxe.js +10 -9
  61. package/dest/kernel/index.d.ts +1 -1
  62. package/dest/kernel/index.d.ts.map +1 -1
  63. package/dest/kernel/index.js +1 -1
  64. package/dest/kernel/private_kernel_prover_output.d.ts +49 -0
  65. package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -0
  66. package/dest/kernel/private_kernel_prover_output.js +8 -0
  67. package/dest/kernel/private_kernel_simulated_output.d.ts +3 -7
  68. package/dest/kernel/private_kernel_simulated_output.d.ts.map +1 -1
  69. package/dest/logs/contract_class_log.d.ts +1 -0
  70. package/dest/logs/contract_class_log.d.ts.map +1 -1
  71. package/dest/logs/contract_class_log.js +3 -0
  72. package/dest/logs/l1_payload/index.d.ts +1 -1
  73. package/dest/logs/l1_payload/index.d.ts.map +1 -1
  74. package/dest/logs/l1_payload/index.js +1 -1
  75. package/dest/logs/log_with_tx_data.js +2 -2
  76. package/dest/logs/private_log.d.ts +2 -1
  77. package/dest/logs/private_log.d.ts.map +1 -1
  78. package/dest/logs/private_log.js +14 -3
  79. package/dest/logs/public_log.d.ts.map +1 -1
  80. package/dest/logs/public_log.js +4 -1
  81. package/dest/logs/tx_scoped_l2_log.d.ts +16 -28
  82. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  83. package/dest/logs/tx_scoped_l2_log.js +28 -19
  84. package/dest/noir/index.d.ts +5 -1
  85. package/dest/noir/index.d.ts.map +1 -1
  86. package/dest/note/extended_note.d.ts +10 -21
  87. package/dest/note/extended_note.d.ts.map +1 -1
  88. package/dest/note/extended_note.js +19 -28
  89. package/dest/note/notes_filter.d.ts +2 -2
  90. package/dest/note/notes_filter.d.ts.map +1 -1
  91. package/dest/note/notes_filter.js +1 -1
  92. package/dest/p2p/consensus_payload.d.ts +3 -1
  93. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  94. package/dest/p2p/consensus_payload.js +3 -0
  95. package/dest/proofs/client_ivc_proof.d.ts +1 -2
  96. package/dest/proofs/client_ivc_proof.d.ts.map +1 -1
  97. package/dest/proofs/client_ivc_proof.js +6 -9
  98. package/dest/proofs/proof.d.ts +0 -1
  99. package/dest/proofs/proof.d.ts.map +1 -1
  100. package/dest/proofs/proof.js +2 -7
  101. package/dest/rollup/block_root_rollup.d.ts +1 -1
  102. package/dest/rollup/tube_inputs.d.ts +7 -2
  103. package/dest/rollup/tube_inputs.d.ts.map +1 -1
  104. package/dest/rollup/tube_inputs.js +10 -4
  105. package/dest/tests/factories.d.ts +3 -2
  106. package/dest/tests/factories.d.ts.map +1 -1
  107. package/dest/tests/factories.js +14 -8
  108. package/dest/tests/mocks.d.ts +2 -2
  109. package/dest/tests/mocks.d.ts.map +1 -1
  110. package/dest/tests/mocks.js +4 -5
  111. package/dest/trees/nullifier_membership_witness.d.ts +11 -7
  112. package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
  113. package/dest/trees/nullifier_membership_witness.js +10 -0
  114. package/dest/trees/public_data_witness.d.ts +12 -12
  115. package/dest/trees/public_data_witness.d.ts.map +1 -1
  116. package/dest/trees/public_data_witness.js +13 -0
  117. package/dest/tx/capsule.d.ts +2 -0
  118. package/dest/tx/capsule.d.ts.map +1 -1
  119. package/dest/tx/capsule.js +2 -0
  120. package/dest/tx/index.d.ts +2 -0
  121. package/dest/tx/index.d.ts.map +1 -1
  122. package/dest/tx/index.js +2 -0
  123. package/dest/tx/private_execution_result.d.ts +4 -0
  124. package/dest/tx/private_execution_result.d.ts.map +1 -1
  125. package/dest/tx/private_execution_result.js +5 -0
  126. package/dest/tx/profiled_tx.d.ts +9 -0
  127. package/dest/tx/profiled_tx.d.ts.map +1 -0
  128. package/dest/tx/profiled_tx.js +27 -0
  129. package/dest/tx/proven_tx.d.ts +33 -0
  130. package/dest/tx/proven_tx.d.ts.map +1 -0
  131. package/dest/tx/proven_tx.js +35 -0
  132. package/dest/tx/simulated_tx.d.ts +8 -44
  133. package/dest/tx/simulated_tx.d.ts.map +1 -1
  134. package/dest/tx/simulated_tx.js +17 -40
  135. package/dest/tx/tx_effect.d.ts +1 -0
  136. package/dest/tx/tx_effect.d.ts.map +1 -1
  137. package/dest/tx/tx_effect.js +4 -1
  138. package/dest/tx/tx_receipt.d.ts +1 -30
  139. package/dest/tx/tx_receipt.d.ts.map +1 -1
  140. package/dest/tx/tx_receipt.js +3 -13
  141. package/package.json +6 -7
  142. package/src/abi/abi.ts +7 -2
  143. package/src/abi/contract_artifact.ts +11 -0
  144. package/src/auth_witness/auth_witness.ts +29 -0
  145. package/src/avm/avm.ts +42 -39
  146. package/src/avm/public_data_write.ts +4 -0
  147. package/src/block/body.ts +6 -0
  148. package/src/block/index.ts +1 -1
  149. package/src/block/l2_block.ts +4 -0
  150. package/src/block/l2_block_downloader/l2_block_stream.ts +5 -7
  151. package/src/block/l2_block_source.ts +11 -0
  152. package/src/block/published_l2_block.ts +45 -0
  153. package/src/contract/interfaces/contract_data_source.ts +3 -16
  154. package/src/database-version/version_manager.ts +11 -1
  155. package/src/interfaces/archiver.ts +11 -14
  156. package/src/interfaces/aztec-node-admin.ts +39 -0
  157. package/src/interfaces/aztec-node.ts +13 -72
  158. package/src/interfaces/client.ts +1 -0
  159. package/src/interfaces/private_kernel_prover.ts +2 -3
  160. package/src/interfaces/prover-node.ts +2 -4
  161. package/src/interfaces/pxe.ts +34 -56
  162. package/src/kernel/index.ts +1 -1
  163. package/src/kernel/private_kernel_prover_output.ts +44 -0
  164. package/src/kernel/private_kernel_simulated_output.ts +4 -13
  165. package/src/logs/contract_class_log.ts +8 -0
  166. package/src/logs/l1_payload/index.ts +1 -1
  167. package/src/logs/log_with_tx_data.ts +2 -2
  168. package/src/logs/private_log.ts +13 -3
  169. package/src/logs/public_log.ts +11 -1
  170. package/src/logs/tx_scoped_l2_log.ts +28 -25
  171. package/src/noir/index.ts +6 -1
  172. package/src/note/extended_note.ts +17 -36
  173. package/src/note/notes_filter.ts +3 -3
  174. package/src/p2p/consensus_payload.ts +9 -0
  175. package/src/proofs/client_ivc_proof.ts +5 -15
  176. package/src/proofs/proof.ts +2 -8
  177. package/src/rollup/tube_inputs.ts +8 -4
  178. package/src/tests/factories.ts +15 -14
  179. package/src/tests/mocks.ts +4 -9
  180. package/src/trees/nullifier_membership_witness.ts +12 -0
  181. package/src/trees/public_data_witness.ts +15 -0
  182. package/src/tx/capsule.ts +2 -0
  183. package/src/tx/index.ts +2 -0
  184. package/src/tx/private_execution_result.ts +7 -0
  185. package/src/tx/profiled_tx.ts +27 -0
  186. package/src/tx/proven_tx.ts +58 -0
  187. package/src/tx/simulated_tx.ts +11 -63
  188. package/src/tx/tx_effect.ts +23 -1
  189. package/src/tx/tx_receipt.ts +0 -36
  190. package/dest/block/nullifier_with_block_source.d.ts +0 -6
  191. package/dest/block/nullifier_with_block_source.d.ts.map +0 -1
  192. package/dest/block/nullifier_with_block_source.js +0 -1
  193. package/dest/kernel/private_kernel_prover_profile_result.d.ts +0 -25
  194. package/dest/kernel/private_kernel_prover_profile_result.d.ts.map +0 -1
  195. package/dest/kernel/private_kernel_prover_profile_result.js +0 -7
  196. package/dest/logs/l1_payload/l1_note_payload.d.ts +0 -82
  197. package/dest/logs/l1_payload/l1_note_payload.d.ts.map +0 -1
  198. package/dest/logs/l1_payload/l1_note_payload.js +0 -129
  199. package/src/block/nullifier_with_block_source.ts +0 -7
  200. package/src/kernel/private_kernel_prover_profile_result.ts +0 -7
  201. package/src/logs/l1_payload/l1_note_payload.ts +0 -182
package/src/block/body.ts CHANGED
@@ -18,6 +18,12 @@ export class Body {
18
18
  });
19
19
  }
20
20
 
21
+ equals(other: Body) {
22
+ return (
23
+ this.txEffects.length === other.txEffects.length && this.txEffects.every((te, i) => te.equals(other.txEffects[i]))
24
+ );
25
+ }
26
+
21
27
  static get schema(): ZodFor<Body> {
22
28
  return z
23
29
  .object({
@@ -1,8 +1,8 @@
1
1
  export * from './l2_block.js';
2
2
  export * from './l2_block_downloader/index.js';
3
- export * from './nullifier_with_block_source.js';
4
3
  export * from './in_block.js';
5
4
  export * from './body.js';
6
5
  export * from './l2_block_number.js';
7
6
  export * from './l2_block_source.js';
8
7
  export * from './block_hash.js';
8
+ export * from './published_l2_block.js';
@@ -202,4 +202,8 @@ export class L2Block {
202
202
  ...logsStats,
203
203
  };
204
204
  }
205
+
206
+ equals(other: L2Block) {
207
+ return this.archive.equals(other.archive) && this.header.equals(other.header) && this.body.equals(other.body);
208
+ }
205
209
  }
@@ -2,8 +2,8 @@ import { AbortError } from '@aztec/foundation/error';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
3
  import { RunningPromise } from '@aztec/foundation/running-promise';
4
4
 
5
- import type { L2Block } from '../l2_block.js';
6
5
  import type { L2BlockId, L2BlockSource, L2Tips } from '../l2_block_source.js';
6
+ import type { PublishedL2Block } from '../published_l2_block.js';
7
7
 
8
8
  /** Creates a stream of events for new blocks, chain tips updates, and reorgs, out of polling an archiver or a node. */
9
9
  export class L2BlockStream {
@@ -11,7 +11,7 @@ export class L2BlockStream {
11
11
  private isSyncing = false;
12
12
 
13
13
  constructor(
14
- private l2BlockSource: Pick<L2BlockSource, 'getBlocks' | 'getBlockHeader' | 'getL2Tips'>,
14
+ private l2BlockSource: Pick<L2BlockSource, 'getPublishedBlocks' | 'getBlockHeader' | 'getL2Tips'>,
15
15
  private localData: L2BlockStreamLocalDataProvider,
16
16
  private handler: L2BlockStreamEventHandler,
17
17
  private readonly log = createLogger('types:block_stream'),
@@ -84,17 +84,15 @@ export class L2BlockStream {
84
84
  const from = latestBlockNumber + 1;
85
85
  const limit = Math.min(this.opts.batchSize ?? 20, sourceTips.latest.number - from + 1);
86
86
  this.log.trace(`Requesting blocks from ${from} limit ${limit} proven=${this.opts.proven}`);
87
- const blocks = await this.l2BlockSource.getBlocks(from, limit, this.opts.proven);
87
+ const blocks = await this.l2BlockSource.getPublishedBlocks(from, limit, this.opts.proven);
88
88
  if (blocks.length === 0) {
89
89
  break;
90
90
  }
91
91
  await this.emitEvent({ type: 'blocks-added', blocks });
92
- latestBlockNumber = blocks.at(-1)!.number;
92
+ latestBlockNumber = blocks.at(-1)!.block.number;
93
93
  }
94
94
 
95
95
  // Update the proven and finalized tips.
96
- // TODO(palla/reorg): Should we emit this before passing the new blocks? This would allow world-state to skip
97
- // building the data structures for the pending chain if it's unneeded.
98
96
  if (localTips.proven !== undefined && sourceTips.proven.number !== localTips.proven.number) {
99
97
  await this.emitEvent({ type: 'chain-proven', blockNumber: sourceTips.proven.number });
100
98
  }
@@ -160,7 +158,7 @@ export type L2BlockStreamEvent =
160
158
  | {
161
159
  type: 'blocks-added';
162
160
  /** New blocks added to the chain. */
163
- blocks: L2Block[];
161
+ blocks: PublishedL2Block[];
164
162
  }
165
163
  | {
166
164
  type: 'chain-pruned';
@@ -10,6 +10,7 @@ import type { TxHash } from '../tx/tx_hash.js';
10
10
  import type { TxReceipt } from '../tx/tx_receipt.js';
11
11
  import type { InBlock } from './in_block.js';
12
12
  import type { L2Block } from './l2_block.js';
13
+ import type { PublishedL2Block } from './published_l2_block.js';
13
14
 
14
15
  /**
15
16
  * Interface of classes allowing for the retrieval of L2 blocks.
@@ -62,6 +63,9 @@ export interface L2BlockSource {
62
63
  */
63
64
  getBlocks(from: number, limit: number, proven?: boolean): Promise<L2Block[]>;
64
65
 
66
+ /** Equivalent to getBlocks but includes publish data. */
67
+ getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
68
+
65
69
  /**
66
70
  * Gets a tx effect.
67
71
  * @param txHash - The hash of a transaction which resulted in the returned tx effect.
@@ -93,6 +97,13 @@ export interface L2BlockSource {
93
97
  */
94
98
  getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]>;
95
99
 
100
+ /**
101
+ * Returns all block headers for a given epoch.
102
+ * @dev Use this method only with recent epochs, since it walks the block list backwards.
103
+ * @param epochNumber - The epoch number to return headers for.
104
+ */
105
+ getBlockHeadersForEpoch(epochNumber: bigint): Promise<BlockHeader[]>;
106
+
96
107
  /**
97
108
  * Returns whether the given epoch is completed on L1, based on the current L1 and L2 block numbers.
98
109
  * @param epochNumber - The epoch number to check.
@@ -0,0 +1,45 @@
1
+ import { Buffer32 } from '@aztec/foundation/buffer';
2
+ import { times } from '@aztec/foundation/collection';
3
+ import { Secp256k1Signer } from '@aztec/foundation/crypto';
4
+ import { Signature } from '@aztec/foundation/eth-signature';
5
+ import { schemas } from '@aztec/foundation/schemas';
6
+ import { L2Block } from '@aztec/stdlib/block';
7
+
8
+ import { z } from 'zod';
9
+
10
+ export type L1PublishedData = {
11
+ blockNumber: bigint;
12
+ timestamp: bigint;
13
+ blockHash: string;
14
+ };
15
+
16
+ export type PublishedL2Block = {
17
+ block: L2Block;
18
+ l1: L1PublishedData;
19
+ signatures: Signature[];
20
+ };
21
+
22
+ export const PublishedL2BlockSchema = z.object({
23
+ block: L2Block.schema,
24
+ l1: z.object({
25
+ blockNumber: schemas.BigInt,
26
+ timestamp: schemas.BigInt,
27
+ blockHash: z.string(),
28
+ }),
29
+ signatures: z.array(Signature.schema),
30
+ });
31
+
32
+ export async function randomPublishedL2Block(l2BlockNumber: number): Promise<PublishedL2Block> {
33
+ const block = await L2Block.random(l2BlockNumber);
34
+ const l1 = {
35
+ blockNumber: BigInt(block.number),
36
+ timestamp: block.header.globalVariables.timestamp.toBigInt(),
37
+ blockHash: Buffer32.random().toString(),
38
+ };
39
+ // Create valid signatures
40
+ const signers = times(3, () => Secp256k1Signer.random());
41
+ const signatures = await Promise.all(
42
+ times(3, async i => signers[i].signMessage(Buffer32.fromField(await block.hash()))),
43
+ );
44
+ return { block, l1, signatures };
45
+ }
@@ -2,18 +2,10 @@ import type { Fr } from '@aztec/foundation/fields';
2
2
 
3
3
  import { FunctionSelector } from '../../abi/index.js';
4
4
  import type { AztecAddress } from '../../aztec-address/index.js';
5
- import type { ContractClassPublic, PublicFunction } from './contract_class.js';
5
+ import type { ContractClassPublic } from './contract_class.js';
6
6
  import type { ContractInstanceWithAddress } from './contract_instance.js';
7
7
 
8
8
  export interface ContractDataSource {
9
- /**
10
- * Returns a contract's encoded public function, given its function selector.
11
- * @param address - The contract aztec address.
12
- * @param selector - The function's selector.
13
- * @returns The function's data.
14
- */
15
- getPublicFunction(address: AztecAddress, selector: FunctionSelector): Promise<PublicFunction | undefined>;
16
-
17
9
  /**
18
10
  * Gets the number of the latest L2 block processed by the implementation.
19
11
  * @returns The number of the latest L2 block processed by the implementation.
@@ -28,17 +20,12 @@ export interface ContractDataSource {
28
20
 
29
21
  getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
30
22
 
31
- /**
32
- * Adds a contract class to the database.
33
- * TODO(#10007): Remove this method
34
- */
35
- addContractClass(contractClass: ContractClassPublic): Promise<void>;
36
-
37
23
  /**
38
24
  * Returns a publicly deployed contract instance given its address.
39
25
  * @param address - Address of the deployed contract.
26
+ * @param blockNumber - Block number at which to retrieve the contract instance. If not provided, the latest block should be used.
40
27
  */
41
- getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
28
+ getContract(address: AztecAddress, blockNumber?: number): Promise<ContractInstanceWithAddress | undefined>;
42
29
 
43
30
  /**
44
31
  * Returns the list of all class ids known.
@@ -3,6 +3,7 @@ import { jsonParseWithSchemaSync, jsonStringify } from '@aztec/foundation/json-r
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
 
5
5
  import fs from 'fs/promises';
6
+ import { inspect } from 'node:util';
6
7
  import { join } from 'path';
7
8
  import { z } from 'zod';
8
9
 
@@ -59,6 +60,15 @@ export class DatabaseVersion {
59
60
  .transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
60
61
  }
61
62
 
63
+ /** Allows for better introspection. */
64
+ public [inspect.custom](): string {
65
+ return this.toString();
66
+ }
67
+
68
+ public toString(): string {
69
+ return this.schemaVersion.toString();
70
+ }
71
+
62
72
  /**
63
73
  * Returns an empty instance
64
74
  */
@@ -148,7 +158,7 @@ export class DatabaseVersionManager<T> {
148
158
  }
149
159
  } else if (cmp !== 0) {
150
160
  this.log.info(
151
- `Can't upgrade from version ${storedVersion.schemaVersion} to ${this.currentVersion}. Resetting database at ${this.dataDirectory}`,
161
+ `Can't upgrade from version ${storedVersion.schemaVersion} to ${this.currentVersion.schemaVersion}. Resetting database at ${this.dataDirectory}`,
152
162
  );
153
163
  needsReset = true;
154
164
  }
@@ -5,12 +5,11 @@ import { z } from 'zod';
5
5
  import { inBlockSchemaFor } from '../block/in_block.js';
6
6
  import { L2Block } from '../block/l2_block.js';
7
7
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
8
- import type { NullifierWithBlockSource } from '../block/nullifier_with_block_source.js';
8
+ import { PublishedL2BlockSchema } from '../block/published_l2_block.js';
9
9
  import {
10
10
  ContractClassPublicSchema,
11
11
  type ContractDataSource,
12
12
  ContractInstanceWithAddressSchema,
13
- PublicFunctionSchema,
14
13
  } from '../contract/index.js';
15
14
  import { L1RollupConstantsSchema } from '../epoch-helpers/index.js';
16
15
  import { LogFilterSchema } from '../logs/log_filter.js';
@@ -26,7 +25,7 @@ import { GetContractClassLogsResponseSchema, GetPublicLogsResponseSchema } from
26
25
  import type { L2LogsSource } from './l2_logs_source.js';
27
26
 
28
27
  export type ArchiverApi = Omit<
29
- L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource & NullifierWithBlockSource,
28
+ L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource,
30
29
  'start' | 'stop'
31
30
  >;
32
31
 
@@ -44,11 +43,16 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
44
43
  .function()
45
44
  .args(schemas.Integer, schemas.Integer, optional(z.boolean()))
46
45
  .returns(z.array(L2Block.schema)),
46
+ getPublishedBlocks: z
47
+ .function()
48
+ .args(schemas.Integer, schemas.Integer, optional(z.boolean()))
49
+ .returns(z.array(PublishedL2BlockSchema)),
47
50
  getTxEffect: z.function().args(TxHash.schema).returns(inBlockSchemaFor(TxEffect.schema).optional()),
48
51
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
49
52
  getL2SlotNumber: z.function().args().returns(schemas.BigInt),
50
53
  getL2EpochNumber: z.function().args().returns(schemas.BigInt),
51
54
  getBlocksForEpoch: z.function().args(schemas.BigInt).returns(z.array(L2Block.schema)),
55
+ getBlockHeadersForEpoch: z.function().args(schemas.BigInt).returns(z.array(BlockHeader.schema)),
52
56
  isEpochComplete: z.function().args(schemas.BigInt).returns(z.boolean()),
53
57
  getL2Tips: z.function().args().returns(L2TipsSchema),
54
58
  getPrivateLogs: z.function().args(z.number(), z.number()).returns(z.array(PrivateLog.schema)),
@@ -56,25 +60,18 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
56
60
  .function()
57
61
  .args(z.array(schemas.Fr))
58
62
  .returns(z.array(z.array(TxScopedL2Log.schema))),
59
- findNullifiersIndexesWithBlock: z
60
- .function()
61
- .args(z.number(), z.array(schemas.Fr))
62
- .returns(z.array(optional(inBlockSchemaFor(schemas.BigInt)))),
63
63
  getPublicLogs: z.function().args(LogFilterSchema).returns(GetPublicLogsResponseSchema),
64
64
  getContractClassLogs: z.function().args(LogFilterSchema).returns(GetContractClassLogsResponseSchema),
65
- getPublicFunction: z
66
- .function()
67
- .args(schemas.AztecAddress, schemas.FunctionSelector)
68
- .returns(PublicFunctionSchema.optional()),
69
65
  getContractClass: z.function().args(schemas.Fr).returns(ContractClassPublicSchema.optional()),
70
66
  getBytecodeCommitment: z.function().args(schemas.Fr).returns(schemas.Fr),
71
- getContract: z.function().args(schemas.AztecAddress).returns(ContractInstanceWithAddressSchema.optional()),
67
+ getContract: z
68
+ .function()
69
+ .args(schemas.AztecAddress, optional(schemas.Integer))
70
+ .returns(ContractInstanceWithAddressSchema.optional()),
72
71
  getContractClassIds: z.function().args().returns(z.array(schemas.Fr)),
73
72
  registerContractFunctionSignatures: z.function().args(schemas.AztecAddress, z.array(z.string())).returns(z.void()),
74
73
  getL1ToL2Messages: z.function().args(schemas.BigInt).returns(z.array(schemas.Fr)),
75
74
  getL1ToL2MessageIndex: z.function().args(schemas.Fr).returns(schemas.BigInt.optional()),
76
- // TODO(#10007): Remove this method
77
- addContractClass: z.function().args(ContractClassPublicSchema).returns(z.void()),
78
75
  getContractFunctionName: z
79
76
  .function()
80
77
  .args(schemas.AztecAddress, schemas.FunctionSelector)
@@ -0,0 +1,39 @@
1
+ import { createSafeJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client';
2
+
3
+ import { z } from 'zod';
4
+
5
+ import type { ApiSchemaFor } from '../schemas/schemas.js';
6
+ import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
7
+ import { type SequencerConfig, SequencerConfigSchema } from './configs.js';
8
+ import { type ProverConfig, ProverConfigSchema } from './prover-client.js';
9
+
10
+ /**
11
+ * Aztec node admin API.
12
+ */
13
+ export interface AztecNodeAdmin {
14
+ /**
15
+ * Updates the configuration of this node.
16
+ * @param config - Updated configuration to be merged with the current one.
17
+ */
18
+ setConfig(config: Partial<SequencerConfig & ProverConfig>): Promise<void>;
19
+
20
+ /** Forces the next block to be built bypassing all time and pending checks. Useful for testing. */
21
+ flushTxs(): Promise<void>;
22
+ }
23
+
24
+ export const AztecNodeAdminApiSchema: ApiSchemaFor<AztecNodeAdmin> = {
25
+ setConfig: z.function().args(SequencerConfigSchema.merge(ProverConfigSchema).partial()).returns(z.void()),
26
+ flushTxs: z.function().returns(z.void()),
27
+ };
28
+
29
+ export function createAztecNodeAdminClient(
30
+ url: string,
31
+ versions: Partial<ComponentsVersions> = {},
32
+ fetch = defaultFetch,
33
+ ): AztecNodeAdmin {
34
+ return createSafeJsonRpcClient<AztecNodeAdmin>(url, AztecNodeAdminApiSchema, {
35
+ namespaceMethods: 'nodeAdmin',
36
+ fetch,
37
+ onResponse: getVersioningResponseHandler(versions),
38
+ });
39
+ }
@@ -17,6 +17,7 @@ import { type InBlock, inBlockSchemaFor } from '../block/in_block.js';
17
17
  import { L2Block } from '../block/l2_block.js';
18
18
  import { type L2BlockNumber, L2BlockNumberSchema } from '../block/l2_block_number.js';
19
19
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
20
+ import { PublishedL2BlockSchema } from '../block/published_l2_block.js';
20
21
  import {
21
22
  type ContractClassPublic,
22
23
  ContractClassPublicSchema,
@@ -46,14 +47,12 @@ import {
46
47
  } from '../tx/index.js';
47
48
  import { TxEffect } from '../tx/tx_effect.js';
48
49
  import { type ComponentsVersions, getVersioningResponseHandler } from '../versioning/index.js';
49
- import { type SequencerConfig, SequencerConfigSchema } from './configs.js';
50
50
  import {
51
51
  type GetContractClassLogsResponse,
52
52
  GetContractClassLogsResponseSchema,
53
53
  type GetPublicLogsResponse,
54
54
  GetPublicLogsResponseSchema,
55
55
  } from './get_logs_response.js';
56
- import { type ProverConfig, ProverConfigSchema } from './prover-client.js';
57
56
  import type { ProverCoordination } from './prover-coordination.js';
58
57
  import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_state.js';
59
58
 
@@ -63,7 +62,7 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
63
62
  */
64
63
  export interface AztecNode
65
64
  extends ProverCoordination,
66
- Pick<L2BlockSource, 'getBlocks' | 'getBlockHeader' | 'getL2Tips'> {
65
+ Pick<L2BlockSource, 'getBlocks' | 'getPublishedBlocks' | 'getBlockHeader' | 'getL2Tips'> {
67
66
  /**
68
67
  * Returns the tips of the L2 chain.
69
68
  */
@@ -75,41 +74,17 @@ export interface AztecNode
75
74
  getWorldStateSyncStatus(): Promise<WorldStateSyncStatus>;
76
75
 
77
76
  /**
78
- * Find the indexes of the given leaves in the given tree.
79
- * @param blockNumber - The block number at which to get the data or 'latest' for latest data
77
+ * Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
78
+ * the leaves were inserted.
79
+ * @param blockNumber - The block number at which to get the data or 'latest' for latest data.
80
80
  * @param treeId - The tree to search in.
81
- * @param leafValues - The values to search for
82
- * @returns The indexes of the given leaves in the given tree or undefined if not found.
81
+ * @param leafValues - The values to search for.
82
+ * @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
83
83
  */
84
84
  findLeavesIndexes(
85
85
  blockNumber: L2BlockNumber,
86
86
  treeId: MerkleTreeId,
87
87
  leafValues: Fr[],
88
- ): Promise<(bigint | undefined)[]>;
89
-
90
- /**
91
- * Find the indexes of the given leaves in the given tree.
92
- * @param blockNumber - The block number at which to get the data or 'latest' for latest data
93
- * @param treeId - The tree to search in.
94
- * @param leafIndices - The values to search for
95
- * @returns The indexes of the given leaves in the given tree or undefined if not found.
96
- */
97
- findBlockNumbersForIndexes(
98
- blockNumber: L2BlockNumber,
99
- treeId: MerkleTreeId,
100
- leafIndices: bigint[],
101
- ): Promise<(bigint | undefined)[]>;
102
-
103
- /**
104
- * Returns the indexes of the given nullifiers in the nullifier tree,
105
- * scoped to the block they were included in.
106
- * @param blockNumber - The block number at which to get the data.
107
- * @param nullifiers - The nullifiers to search for.
108
- * @returns The block scoped indexes of the given nullifiers in the nullifier tree, or undefined if not found.
109
- */
110
- findNullifiersIndexesWithBlock(
111
- blockNumber: L2BlockNumber,
112
- nullifiers: Fr[],
113
88
  ): Promise<(InBlock<bigint> | undefined)[]>;
114
89
 
115
90
  /**
@@ -220,14 +195,14 @@ export interface AztecNode
220
195
  * "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
221
196
  * is contained in the leaf preimage.
222
197
  */
223
- getPublicDataTreeWitness(blockNumber: L2BlockNumber, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
198
+ getPublicDataWitness(blockNumber: L2BlockNumber, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
224
199
 
225
200
  /**
226
201
  * Get a block specified by its number.
227
202
  * @param number - The block number being requested.
228
203
  * @returns The requested block.
229
204
  */
230
- getBlock(number: number): Promise<L2Block | undefined>;
205
+ getBlock(number: L2BlockNumber): Promise<L2Block | undefined>;
231
206
 
232
207
  /**
233
208
  * Fetches the current block number.
@@ -421,12 +396,6 @@ export interface AztecNode
421
396
  */
422
397
  isValidTx(tx: Tx, options?: { isSimulation?: boolean; skipFeeEnforcement?: boolean }): Promise<TxValidationResult>;
423
398
 
424
- /**
425
- * Updates the configuration of this node.
426
- * @param config - Updated configuration to be merged with the current one.
427
- */
428
- setConfig(config: Partial<SequencerConfig & ProverConfig>): Promise<void>;
429
-
430
399
  /**
431
400
  * Returns a registered contract class given its id.
432
401
  * @param id - Id of the contract class.
@@ -439,20 +408,10 @@ export interface AztecNode
439
408
  */
440
409
  getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
441
410
 
442
- /** Forces the next block to be built bypassing all time and pending checks. Useful for testing. */
443
- flushTxs(): Promise<void>;
444
-
445
411
  /**
446
412
  * Returns the ENR of this node for peer discovery, if available.
447
413
  */
448
414
  getEncodedEnr(): Promise<string | undefined>;
449
-
450
- /**
451
- * Adds a contract class bypassing the registerer.
452
- * TODO(#10007): Remove this method.
453
- * @param contractClass - The class to register.
454
- */
455
- addContractClass(contractClass: ContractClassPublic): Promise<void>;
456
415
  }
457
416
 
458
417
  export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
@@ -463,16 +422,6 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
463
422
  findLeavesIndexes: z
464
423
  .function()
465
424
  .args(L2BlockNumberSchema, z.nativeEnum(MerkleTreeId), z.array(schemas.Fr))
466
- .returns(z.array(optional(schemas.BigInt))),
467
-
468
- findBlockNumbersForIndexes: z
469
- .function()
470
- .args(L2BlockNumberSchema, z.nativeEnum(MerkleTreeId), z.array(schemas.BigInt))
471
- .returns(z.array(optional(schemas.BigInt))),
472
-
473
- findNullifiersIndexesWithBlock: z
474
- .function()
475
- .args(L2BlockNumberSchema, z.array(schemas.Fr))
476
425
  .returns(z.array(optional(inBlockSchemaFor(schemas.BigInt)))),
477
426
 
478
427
  getNullifierSiblingPath: z
@@ -517,12 +466,9 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
517
466
  .args(L2BlockNumberSchema, schemas.Fr)
518
467
  .returns(NullifierMembershipWitness.schema.optional()),
519
468
 
520
- getPublicDataTreeWitness: z
521
- .function()
522
- .args(L2BlockNumberSchema, schemas.Fr)
523
- .returns(PublicDataWitness.schema.optional()),
469
+ getPublicDataWitness: z.function().args(L2BlockNumberSchema, schemas.Fr).returns(PublicDataWitness.schema.optional()),
524
470
 
525
- getBlock: z.function().args(z.number()).returns(L2Block.schema.optional()),
471
+ getBlock: z.function().args(L2BlockNumberSchema).returns(L2Block.schema.optional()),
526
472
 
527
473
  getBlockNumber: z.function().returns(z.number()),
528
474
 
@@ -534,6 +480,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
534
480
 
535
481
  getBlocks: z.function().args(z.number(), z.number()).returns(z.array(L2Block.schema)),
536
482
 
483
+ getPublishedBlocks: z.function().args(z.number(), z.number()).returns(z.array(PublishedL2BlockSchema)),
484
+
537
485
  getCurrentBaseFees: z.function().returns(GasFees.schema),
538
486
 
539
487
  getNodeVersion: z.function().returns(z.string()),
@@ -587,18 +535,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
587
535
  )
588
536
  .returns(TxValidationResultSchema),
589
537
 
590
- setConfig: z.function().args(SequencerConfigSchema.merge(ProverConfigSchema).partial()).returns(z.void()),
591
-
592
538
  getContractClass: z.function().args(schemas.Fr).returns(ContractClassPublicSchema.optional()),
593
539
 
594
540
  getContract: z.function().args(schemas.AztecAddress).returns(ContractInstanceWithAddressSchema.optional()),
595
541
 
596
- flushTxs: z.function().returns(z.void()),
597
-
598
542
  getEncodedEnr: z.function().returns(z.string().optional()),
599
-
600
- // TODO(#10007): Remove this method
601
- addContractClass: z.function().args(ContractClassPublicSchema).returns(z.void()),
602
543
  };
603
544
 
604
545
  export function createAztecNodeClient(
@@ -1,4 +1,5 @@
1
1
  export * from './pxe.js';
2
2
  export * from './aztec-node.js';
3
+ export * from './aztec-node-admin.js';
3
4
  export * from './private_kernel_prover.js';
4
5
  export * from './get_logs_response.js';
@@ -1,6 +1,5 @@
1
- import type { WitnessMap } from '@aztec/noir-acvm_js';
2
-
3
1
  import type {
2
+ PrivateExecutionStep,
4
3
  PrivateKernelCircuitPublicInputs,
5
4
  PrivateKernelInitCircuitPrivateInputs,
6
5
  PrivateKernelInnerCircuitPrivateInputs,
@@ -101,7 +100,7 @@ export interface PrivateKernelProver {
101
100
  * @param acirs The program bytecode.
102
101
  * @param witnessStack The witnessses for each program bytecode.
103
102
  */
104
- createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
103
+ createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof>;
105
104
 
106
105
  /**
107
106
  * Compute the gate count for a given circuit.
@@ -11,6 +11,7 @@ const EpochProvingJobState = [
11
11
  'failed',
12
12
  'stopped',
13
13
  'timed-out',
14
+ 'reorg',
14
15
  ] as const;
15
16
 
16
17
  export type EpochProvingJobState = (typeof EpochProvingJobState)[number];
@@ -20,6 +21,7 @@ export const EpochProvingJobTerminalState: EpochProvingJobState[] = [
20
21
  'failed',
21
22
  'stopped',
22
23
  'timed-out',
24
+ 'reorg',
23
25
  ] as const;
24
26
 
25
27
  export type EpochProvingJobTerminalState = (typeof EpochProvingJobTerminalState)[number];
@@ -29,8 +31,6 @@ export interface ProverNodeApi {
29
31
  getJobs(): Promise<{ uuid: string; status: EpochProvingJobState; epochNumber: number }[]>;
30
32
 
31
33
  startProof(epochNumber: number): Promise<void>;
32
-
33
- prove(epochNumber: number): Promise<void>;
34
34
  }
35
35
 
36
36
  /** Schemas for prover node API functions. */
@@ -41,6 +41,4 @@ export const ProverNodeApiSchema: ApiSchemaFor<ProverNodeApi> = {
41
41
  .returns(z.array(z.object({ uuid: z.string(), status: z.enum(EpochProvingJobState), epochNumber: z.number() }))),
42
42
 
43
43
  startProof: z.function().args(schemas.Integer).returns(z.void()),
44
-
45
- prove: z.function().args(schemas.Integer).returns(z.void()),
46
44
  };