@aztec/stdlib 0.0.1-commit.18ccd8f0 → 0.0.1-commit.1bb068fb5

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 (214) hide show
  1. package/dest/abi/function_call.d.ts +39 -9
  2. package/dest/abi/function_call.d.ts.map +1 -1
  3. package/dest/abi/function_call.js +20 -3
  4. package/dest/block/block_hash.d.ts +14 -17
  5. package/dest/block/block_hash.d.ts.map +1 -1
  6. package/dest/block/block_hash.js +21 -34
  7. package/dest/block/block_parameter.d.ts +2 -2
  8. package/dest/block/block_parameter.d.ts.map +1 -1
  9. package/dest/block/in_block.d.ts +5 -5
  10. package/dest/block/in_block.js +2 -2
  11. package/dest/block/l2_block.d.ts +3 -2
  12. package/dest/block/l2_block.d.ts.map +1 -1
  13. package/dest/block/l2_block.js +2 -3
  14. package/dest/block/l2_block_source.d.ts +5 -4
  15. package/dest/block/l2_block_source.d.ts.map +1 -1
  16. package/dest/checkpoint/checkpoint.d.ts +16 -7
  17. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  18. package/dest/checkpoint/checkpoint.js +19 -9
  19. package/dest/checkpoint/published_checkpoint.d.ts +7 -1
  20. package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
  21. package/dest/config/index.d.ts +2 -1
  22. package/dest/config/index.d.ts.map +1 -1
  23. package/dest/config/index.js +1 -0
  24. package/dest/config/sequencer-config.d.ts +10 -0
  25. package/dest/config/sequencer-config.d.ts.map +1 -0
  26. package/dest/config/sequencer-config.js +12 -0
  27. package/dest/contract/contract_class_id.d.ts +1 -1
  28. package/dest/contract/contract_class_id.d.ts.map +1 -1
  29. package/dest/contract/contract_class_id.js +3 -2
  30. package/dest/contract/interfaces/node-info.d.ts +3 -1
  31. package/dest/contract/interfaces/node-info.d.ts.map +1 -1
  32. package/dest/contract/interfaces/node-info.js +2 -1
  33. package/dest/database-version/database_version.d.ts +58 -0
  34. package/dest/database-version/database_version.d.ts.map +1 -0
  35. package/dest/database-version/database_version.js +69 -0
  36. package/dest/database-version/version_manager.d.ts +2 -50
  37. package/dest/database-version/version_manager.d.ts.map +1 -1
  38. package/dest/database-version/version_manager.js +1 -66
  39. package/dest/epoch-helpers/index.d.ts +5 -1
  40. package/dest/epoch-helpers/index.d.ts.map +1 -1
  41. package/dest/epoch-helpers/index.js +4 -2
  42. package/dest/hash/hash.d.ts +2 -1
  43. package/dest/hash/hash.d.ts.map +1 -1
  44. package/dest/hash/hash.js +6 -0
  45. package/dest/interfaces/archiver.d.ts +1 -1
  46. package/dest/interfaces/archiver.d.ts.map +1 -1
  47. package/dest/interfaces/archiver.js +4 -3
  48. package/dest/interfaces/aztec-node-admin.d.ts +17 -2
  49. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  50. package/dest/interfaces/aztec-node-admin.js +3 -1
  51. package/dest/interfaces/aztec-node.d.ts +30 -51
  52. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  53. package/dest/interfaces/aztec-node.js +3 -7
  54. package/dest/interfaces/block-builder.d.ts +9 -4
  55. package/dest/interfaces/block-builder.d.ts.map +1 -1
  56. package/dest/interfaces/block-builder.js +7 -0
  57. package/dest/interfaces/get_logs_response.d.ts +14 -7
  58. package/dest/interfaces/get_logs_response.d.ts.map +1 -1
  59. package/dest/interfaces/p2p.d.ts +2 -2
  60. package/dest/interfaces/p2p.d.ts.map +1 -1
  61. package/dest/interfaces/prover-broker.d.ts +16 -1
  62. package/dest/interfaces/prover-broker.d.ts.map +1 -1
  63. package/dest/interfaces/prover-broker.js +4 -1
  64. package/dest/interfaces/prover-client.d.ts +6 -1
  65. package/dest/interfaces/prover-client.d.ts.map +1 -1
  66. package/dest/interfaces/prover-client.js +5 -0
  67. package/dest/interfaces/proving-job.d.ts +202 -202
  68. package/dest/interfaces/slasher.d.ts +9 -1
  69. package/dest/interfaces/slasher.d.ts.map +1 -1
  70. package/dest/interfaces/slasher.js +2 -0
  71. package/dest/interfaces/validator.d.ts +49 -3
  72. package/dest/interfaces/validator.d.ts.map +1 -1
  73. package/dest/interfaces/validator.js +4 -1
  74. package/dest/keys/derivation.d.ts +3 -3
  75. package/dest/keys/derivation.js +8 -8
  76. package/dest/keys/key_types.d.ts +1 -1
  77. package/dest/keys/utils.d.ts +1 -1
  78. package/dest/keys/utils.d.ts.map +1 -1
  79. package/dest/keys/utils.js +7 -3
  80. package/dest/l1-contracts/slash_factory.d.ts +1 -1
  81. package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
  82. package/dest/l1-contracts/slash_factory.js +1 -0
  83. package/dest/logs/extended_public_log.d.ts +12 -6
  84. package/dest/logs/extended_public_log.d.ts.map +1 -1
  85. package/dest/logs/log_id.d.ts +13 -10
  86. package/dest/logs/log_id.d.ts.map +1 -1
  87. package/dest/logs/log_id.js +17 -14
  88. package/dest/logs/siloed_tag.d.ts +1 -1
  89. package/dest/logs/siloed_tag.d.ts.map +1 -1
  90. package/dest/logs/siloed_tag.js +2 -6
  91. package/dest/messaging/l2_to_l1_membership.d.ts +2 -2
  92. package/dest/messaging/l2_to_l1_membership.js +3 -3
  93. package/dest/note/index.d.ts +1 -2
  94. package/dest/note/index.d.ts.map +1 -1
  95. package/dest/note/index.js +0 -1
  96. package/dest/p2p/checkpoint_attestation.d.ts +2 -1
  97. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  98. package/dest/p2p/checkpoint_attestation.js +1 -1
  99. package/dest/p2p/checkpoint_proposal.d.ts +17 -5
  100. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  101. package/dest/p2p/checkpoint_proposal.js +29 -15
  102. package/dest/p2p/consensus_payload.d.ts +12 -3
  103. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  104. package/dest/p2p/consensus_payload.js +22 -15
  105. package/dest/p2p/constants.d.ts +3 -1
  106. package/dest/p2p/constants.d.ts.map +1 -1
  107. package/dest/p2p/constants.js +1 -0
  108. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +6 -6
  109. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
  110. package/dest/rollup/checkpoint_rollup_public_inputs.js +2 -2
  111. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +2 -2
  112. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
  113. package/dest/rollup/root_rollup_public_inputs.d.ts +6 -6
  114. package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
  115. package/dest/rollup/root_rollup_public_inputs.js +3 -3
  116. package/dest/slashing/empire.d.ts +1 -1
  117. package/dest/slashing/empire.d.ts.map +1 -1
  118. package/dest/slashing/empire.js +2 -0
  119. package/dest/slashing/helpers.d.ts +2 -2
  120. package/dest/slashing/helpers.d.ts.map +1 -1
  121. package/dest/slashing/helpers.js +6 -0
  122. package/dest/slashing/tally.d.ts +2 -1
  123. package/dest/slashing/tally.d.ts.map +1 -1
  124. package/dest/slashing/tally.js +6 -2
  125. package/dest/slashing/types.d.ts +7 -3
  126. package/dest/slashing/types.d.ts.map +1 -1
  127. package/dest/slashing/types.js +13 -1
  128. package/dest/stats/stats.d.ts +1 -3
  129. package/dest/stats/stats.d.ts.map +1 -1
  130. package/dest/tests/factories.js +3 -3
  131. package/dest/tests/mocks.d.ts +4 -1
  132. package/dest/tests/mocks.d.ts.map +1 -1
  133. package/dest/tests/mocks.js +11 -6
  134. package/dest/timetable/index.d.ts +37 -0
  135. package/dest/timetable/index.d.ts.map +1 -0
  136. package/dest/timetable/index.js +39 -0
  137. package/dest/trees/public_data_leaf.d.ts +2 -1
  138. package/dest/trees/public_data_leaf.d.ts.map +1 -1
  139. package/dest/trees/public_data_leaf.js +7 -6
  140. package/dest/tx/block_header.js +2 -2
  141. package/dest/tx/in_tx.d.ts +2 -2
  142. package/dest/tx/indexed_tx_effect.d.ts +3 -3
  143. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  144. package/dest/tx/indexed_tx_effect.js +2 -1
  145. package/dest/tx/validator/empty_validator.d.ts +2 -2
  146. package/dest/tx/validator/empty_validator.d.ts.map +1 -1
  147. package/dest/tx/validator/tx_validator.d.ts +2 -2
  148. package/dest/tx/validator/tx_validator.d.ts.map +1 -1
  149. package/dest/validators/schemas.d.ts +30 -30
  150. package/dest/validators/schemas.d.ts.map +1 -1
  151. package/dest/validators/schemas.js +4 -3
  152. package/dest/validators/types.d.ts +3 -3
  153. package/dest/validators/types.d.ts.map +1 -1
  154. package/package.json +24 -12
  155. package/src/abi/function_call.ts +25 -3
  156. package/src/block/block_hash.ts +25 -50
  157. package/src/block/in_block.ts +2 -2
  158. package/src/block/l2_block.ts +3 -3
  159. package/src/block/l2_block_source.ts +4 -3
  160. package/src/checkpoint/checkpoint.ts +27 -11
  161. package/src/config/index.ts +1 -0
  162. package/src/config/sequencer-config.ts +19 -0
  163. package/src/contract/contract_class_id.ts +3 -2
  164. package/src/contract/interfaces/node-info.ts +3 -0
  165. package/src/database-version/database_version.ts +87 -0
  166. package/src/database-version/version_manager.ts +1 -77
  167. package/src/epoch-helpers/index.ts +3 -0
  168. package/src/hash/hash.ts +4 -0
  169. package/src/interfaces/archiver.ts +4 -3
  170. package/src/interfaces/aztec-node-admin.ts +3 -2
  171. package/src/interfaces/aztec-node.ts +37 -88
  172. package/src/interfaces/block-builder.ts +11 -2
  173. package/src/interfaces/p2p.ts +1 -1
  174. package/src/interfaces/prover-broker.ts +22 -0
  175. package/src/interfaces/prover-client.ts +7 -0
  176. package/src/interfaces/slasher.ts +4 -0
  177. package/src/interfaces/validator.ts +11 -1
  178. package/src/keys/derivation.ts +8 -8
  179. package/src/keys/key_types.ts +1 -1
  180. package/src/keys/utils.ts +7 -3
  181. package/src/l1-contracts/slash_factory.ts +1 -0
  182. package/src/logs/log_id.ts +17 -13
  183. package/src/logs/siloed_tag.ts +2 -3
  184. package/src/messaging/l2_to_l1_membership.ts +3 -3
  185. package/src/note/index.ts +0 -1
  186. package/src/p2p/checkpoint_attestation.ts +6 -1
  187. package/src/p2p/checkpoint_proposal.ts +45 -13
  188. package/src/p2p/consensus_payload.ts +25 -12
  189. package/src/p2p/constants.ts +3 -0
  190. package/src/rollup/checkpoint_rollup_public_inputs.ts +5 -5
  191. package/src/rollup/root_rollup_public_inputs.ts +7 -7
  192. package/src/slashing/empire.ts +3 -1
  193. package/src/slashing/helpers.ts +8 -0
  194. package/src/slashing/tally.ts +8 -2
  195. package/src/slashing/types.ts +14 -0
  196. package/src/stats/stats.ts +0 -2
  197. package/src/tests/factories.ts +5 -5
  198. package/src/tests/mocks.ts +18 -7
  199. package/src/timetable/index.ts +66 -0
  200. package/src/trees/public_data_leaf.ts +11 -5
  201. package/src/tx/block_header.ts +3 -3
  202. package/src/tx/indexed_tx_effect.ts +2 -1
  203. package/src/tx/validator/empty_validator.ts +1 -1
  204. package/src/tx/validator/tx_validator.ts +1 -1
  205. package/src/validators/schemas.ts +8 -1
  206. package/src/validators/types.ts +5 -4
  207. package/dest/database-version/index.d.ts +0 -2
  208. package/dest/database-version/index.d.ts.map +0 -1
  209. package/dest/database-version/index.js +0 -1
  210. package/dest/note/notes_filter.d.ts +0 -27
  211. package/dest/note/notes_filter.d.ts.map +0 -1
  212. package/dest/note/notes_filter.js +0 -11
  213. package/src/database-version/index.ts +0 -1
  214. package/src/note/notes_filter.ts +0 -38
@@ -8,7 +8,7 @@ import {
8
8
  } from '@aztec/foundation/branded-types';
9
9
  import { sum } from '@aztec/foundation/collection';
10
10
  import { Fr } from '@aztec/foundation/curves/bn254';
11
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
11
+ import { BufferReader, serializeSignedBigInt, serializeToBuffer } from '@aztec/foundation/serialize';
12
12
  import type { FieldsOf } from '@aztec/foundation/types';
13
13
 
14
14
  import { z } from 'zod';
@@ -17,6 +17,7 @@ import { L2Block } from '../block/l2_block.js';
17
17
  import { MAX_BLOCKS_PER_CHECKPOINT } from '../deserialization/index.js';
18
18
  import { computeCheckpointOutHash } from '../messaging/out_hash.js';
19
19
  import { CheckpointHeader } from '../rollup/checkpoint_header.js';
20
+ import { schemas } from '../schemas/schemas.js';
20
21
  import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
21
22
  import type { CheckpointInfo } from './checkpoint_info.js';
22
23
 
@@ -32,6 +33,8 @@ export class Checkpoint {
32
33
  public blocks: L2Block[],
33
34
  /** Number of the checkpoint. */
34
35
  public number: CheckpointNumber,
36
+ /** Fee asset price modifier in basis points (from oracle). Defaults to 0 (no change). */
37
+ public feeAssetPriceModifier: bigint = 0n,
35
38
  ) {}
36
39
 
37
40
  get slot(): SlotNumber {
@@ -45,8 +48,12 @@ export class Checkpoint {
45
48
  header: CheckpointHeader.schema,
46
49
  blocks: z.array(L2Block.schema),
47
50
  number: CheckpointNumberSchema,
51
+ feeAssetPriceModifier: schemas.BigInt,
48
52
  })
49
- .transform(({ archive, header, blocks, number }) => new Checkpoint(archive, header, blocks, number));
53
+ .transform(
54
+ ({ archive, header, blocks, number, feeAssetPriceModifier }) =>
55
+ new Checkpoint(archive, header, blocks, number, feeAssetPriceModifier),
56
+ );
50
57
  }
51
58
 
52
59
  static from(fields: FieldsOfCheckpoint) {
@@ -54,21 +61,28 @@ export class Checkpoint {
54
61
  }
55
62
 
56
63
  static getFields(fields: FieldsOfCheckpoint) {
57
- return [fields.archive, fields.header, fields.blocks, fields.number] as const;
64
+ return [fields.archive, fields.header, fields.blocks, fields.number, fields.feeAssetPriceModifier] as const;
58
65
  }
59
66
 
60
67
  static fromBuffer(buf: Buffer | BufferReader) {
61
68
  const reader = BufferReader.asReader(buf);
62
- return new Checkpoint(
63
- reader.readObject(AppendOnlyTreeSnapshot),
64
- reader.readObject(CheckpointHeader),
65
- reader.readVector(L2Block, MAX_BLOCKS_PER_CHECKPOINT),
66
- CheckpointNumber(reader.readNumber()),
67
- );
69
+ const archive = reader.readObject(AppendOnlyTreeSnapshot);
70
+ const header = reader.readObject(CheckpointHeader);
71
+ const blocks = reader.readVector(L2Block, MAX_BLOCKS_PER_CHECKPOINT);
72
+ const number = CheckpointNumber(reader.readNumber());
73
+ const feeAssetPriceModifier = reader.readInt256();
74
+ return new Checkpoint(archive, header, blocks, number, feeAssetPriceModifier);
68
75
  }
69
76
 
70
77
  public toBuffer() {
71
- return serializeToBuffer(this.archive, this.header, this.blocks.length, this.blocks, this.number);
78
+ return serializeToBuffer(
79
+ this.archive,
80
+ this.header,
81
+ this.blocks.length,
82
+ this.blocks,
83
+ this.number,
84
+ serializeSignedBigInt(this.feeAssetPriceModifier),
85
+ );
72
86
  }
73
87
 
74
88
  public toBlobFields(): Fr[] {
@@ -129,11 +143,13 @@ export class Checkpoint {
129
143
  numBlocks = 1,
130
144
  startBlockNumber = 1,
131
145
  previousArchive,
146
+ feeAssetPriceModifier = 0n,
132
147
  ...options
133
148
  }: {
134
149
  numBlocks?: number;
135
150
  startBlockNumber?: number;
136
151
  previousArchive?: AppendOnlyTreeSnapshot;
152
+ feeAssetPriceModifier?: bigint;
137
153
  } & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
138
154
  Partial<Parameters<typeof L2Block.random>[1]> = {},
139
155
  ) {
@@ -153,6 +169,6 @@ export class Checkpoint {
153
169
  blocks.push(block);
154
170
  }
155
171
 
156
- return new Checkpoint(AppendOnlyTreeSnapshot.random(), header, blocks, checkpointNumber);
172
+ return new Checkpoint(AppendOnlyTreeSnapshot.random(), header, blocks, checkpointNumber, feeAssetPriceModifier);
157
173
  }
158
174
  }
@@ -1,2 +1,3 @@
1
1
  export * from './chain-config.js';
2
2
  export * from './node-rpc-config.js';
3
+ export * from './sequencer-config.js';
@@ -0,0 +1,19 @@
1
+ import type { ConfigMappingsType } from '@aztec/foundation/config';
2
+
3
+ import type { SequencerConfig } from '../interfaces/configs.js';
4
+
5
+ /**
6
+ * Partial sequencer config mappings for fields that need to be shared across packages.
7
+ * The full sequencer config mappings remain in sequencer-client, but shared fields
8
+ * (like blockDurationMs needed by both p2p and sequencer-client) are defined here
9
+ * to avoid duplication.
10
+ */
11
+ export const sharedSequencerConfigMappings: ConfigMappingsType<Pick<SequencerConfig, 'blockDurationMs'>> = {
12
+ blockDurationMs: {
13
+ env: 'SEQ_BLOCK_DURATION_MS',
14
+ description:
15
+ 'Duration per block in milliseconds when building multiple blocks per slot. ' +
16
+ 'If undefined (default), builds a single block per slot using the full slot duration.',
17
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
18
+ },
19
+ };
@@ -60,7 +60,7 @@ export type ContractClassIdPreimage = {
60
60
  };
61
61
 
62
62
  export async function computePublicBytecodeCommitment(packedBytecode: Buffer) {
63
- // Encode the buffer into field elements (chunked into 32 bytes each)
63
+ // Encode the buffer into field elements (chunked into 31 bytes each)
64
64
  // The first element is the length of the bytecode (in bytes)
65
65
  const [bytecodeLengthAsField, ...bytecodeAsFields] = bufferAsFields(
66
66
  packedBytecode,
@@ -72,5 +72,6 @@ export async function computePublicBytecodeCommitment(packedBytecode: Buffer) {
72
72
 
73
73
  // NOTE: hash the bytecode here only up to the actual length of the bytecode.
74
74
  // We do not hash the entire max bytecode length!
75
- return await poseidon2HashWithSeparator(bytecodeAsFields.slice(0, bytecodeLength), GeneratorIndex.PUBLIC_BYTECODE);
75
+ const sep = BigInt(GeneratorIndex.PUBLIC_BYTECODE) + (bytecodeLengthAsField.toBigInt() << 32n);
76
+ return await poseidon2HashWithSeparator(bytecodeAsFields.slice(0, bytecodeLength), new Fr(sep).toNumber());
76
77
  }
@@ -19,6 +19,8 @@ export interface NodeInfo {
19
19
  l1ContractAddresses: L1ContractAddresses;
20
20
  /** Protocol contract addresses */
21
21
  protocolContractAddresses: ProtocolContractAddresses;
22
+ /** Whether the node requires real proofs for transaction submission. */
23
+ realProofs: boolean;
22
24
  }
23
25
 
24
26
  export const NodeInfoSchema: ZodFor<NodeInfo> = z
@@ -29,5 +31,6 @@ export const NodeInfoSchema: ZodFor<NodeInfo> = z
29
31
  enr: z.string().optional(),
30
32
  l1ContractAddresses: L1ContractAddressesSchema,
31
33
  protocolContractAddresses: ProtocolContractAddressesSchema,
34
+ realProofs: z.boolean(),
32
35
  })
33
36
  .transform(obj => ({ enr: undefined, ...obj }));
@@ -0,0 +1,87 @@
1
+ import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
3
+
4
+ import { z } from 'zod';
5
+
6
+ /**
7
+ * Symbol for Node.js custom inspect. Using Symbol.for() is the documented way to
8
+ * reference this without importing node:util. In browsers, objects with this symbol
9
+ * simply won't have custom inspect behavior (which is fine).
10
+ * @see https://nodejs.org/api/util.html#utilinspectcustom
11
+ */
12
+ const inspectCustomSymbol = Symbol.for('nodejs.util.inspect.custom');
13
+
14
+ /**
15
+ * Represents a version record for storing in a version file.
16
+ */
17
+ export class DatabaseVersion {
18
+ constructor(
19
+ /** The version of the data on disk. Used to perform upgrades */
20
+ public readonly schemaVersion: number,
21
+ /** The rollup the data pertains to */
22
+ public readonly rollupAddress: EthAddress,
23
+ ) {}
24
+
25
+ public toBuffer(): Buffer {
26
+ return Buffer.from(jsonStringify(this));
27
+ }
28
+
29
+ public static fromBuffer(buf: Buffer): DatabaseVersion {
30
+ try {
31
+ return jsonParseWithSchema(buf.toString('utf-8'), DatabaseVersion.schema);
32
+ } catch (err) {
33
+ throw new Error(`Failed to deserialize version information: ${err}`, { cause: err });
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Compares two versions. If the rollups addresses are different then it returns undefined
39
+ */
40
+ public cmp(other: DatabaseVersion): undefined | -1 | 0 | 1 {
41
+ if (this.rollupAddress.equals(other.rollupAddress)) {
42
+ if (this.schemaVersion < other.schemaVersion) {
43
+ return -1;
44
+ } else if (this.schemaVersion > other.schemaVersion) {
45
+ return 1;
46
+ } else {
47
+ return 0;
48
+ }
49
+ }
50
+ return undefined;
51
+ }
52
+
53
+ /**
54
+ * Checks if two versions exactly match
55
+ */
56
+ public equals(other: DatabaseVersion): boolean {
57
+ return this.cmp(other) === 0;
58
+ }
59
+
60
+ /**
61
+ * Returns the schema for this class
62
+ */
63
+ static get schema() {
64
+ return z
65
+ .object({
66
+ schemaVersion: z.number(),
67
+ rollupAddress: EthAddress.schema,
68
+ })
69
+ .transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
70
+ }
71
+
72
+ /** Allows for better introspection in Node.js console. Ignored in browser envs. */
73
+ public [inspectCustomSymbol](): string {
74
+ return this.toString();
75
+ }
76
+
77
+ public toString(): string {
78
+ return `DatabaseVersion{schemaVersion=${this.schemaVersion},rollupAddress=${this.rollupAddress}"}`;
79
+ }
80
+
81
+ /**
82
+ * Returns an empty instance
83
+ */
84
+ static empty() {
85
+ return new DatabaseVersion(0, EthAddress.ZERO);
86
+ }
87
+ }
@@ -1,86 +1,10 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
3
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
3
 
5
4
  import fs from 'fs/promises';
6
- import { inspect } from 'node:util';
7
5
  import { join } from 'path';
8
- import { z } from 'zod';
9
6
 
10
- /**
11
- * Represents a version record for storing in a version file.
12
- */
13
- export class DatabaseVersion {
14
- constructor(
15
- /** The version of the data on disk. Used to perform upgrades */
16
- public readonly schemaVersion: number,
17
- /** The rollup the data pertains to */
18
- public readonly rollupAddress: EthAddress,
19
- ) {}
20
-
21
- public toBuffer(): Buffer {
22
- return Buffer.from(jsonStringify(this));
23
- }
24
-
25
- public static fromBuffer(buf: Buffer): DatabaseVersion {
26
- try {
27
- return jsonParseWithSchema(buf.toString('utf-8'), DatabaseVersion.schema);
28
- } catch (err) {
29
- throw new Error(`Failed to deserialize version information: ${err}`, { cause: err });
30
- }
31
- }
32
-
33
- /**
34
- * Compares two versions. If the rollups addresses are different then it returns undefined
35
- */
36
- public cmp(other: DatabaseVersion): undefined | -1 | 0 | 1 {
37
- if (this.rollupAddress.equals(other.rollupAddress)) {
38
- if (this.schemaVersion < other.schemaVersion) {
39
- return -1;
40
- } else if (this.schemaVersion > other.schemaVersion) {
41
- return 1;
42
- } else {
43
- return 0;
44
- }
45
- }
46
- return undefined;
47
- }
48
-
49
- /**
50
- * Checks if two versions exactly match
51
- */
52
- public equals(other: DatabaseVersion): boolean {
53
- return this.cmp(other) === 0;
54
- }
55
-
56
- /**
57
- * Returns the schema for this class
58
- */
59
- static get schema() {
60
- return z
61
- .object({
62
- schemaVersion: z.number(),
63
- rollupAddress: EthAddress.schema,
64
- })
65
- .transform(({ schemaVersion, rollupAddress }) => new DatabaseVersion(schemaVersion, rollupAddress));
66
- }
67
-
68
- /** Allows for better introspection. */
69
- public [inspect.custom](): string {
70
- return this.toString();
71
- }
72
-
73
- public toString(): string {
74
- return `DatabaseVersion{schemaVersion=${this.schemaVersion},rollupAddress=${this.rollupAddress}"}`;
75
- }
76
-
77
- /**
78
- * Returns an empty instance
79
- */
80
- static empty() {
81
- return new DatabaseVersion(0, EthAddress.ZERO);
82
- }
83
- }
7
+ import { DatabaseVersion } from './database_version.js';
84
8
 
85
9
  export type DatabaseVersionManagerFs = Pick<typeof fs, 'readFile' | 'writeFile' | 'rm' | 'mkdir'>;
86
10
 
@@ -11,6 +11,7 @@ export type L1RollupConstants = {
11
11
  epochDuration: number;
12
12
  ethereumSlotDuration: number;
13
13
  proofSubmissionEpochs: number;
14
+ targetCommitteeSize: number;
14
15
  };
15
16
 
16
17
  export const EmptyL1RollupConstants: L1RollupConstants = {
@@ -20,6 +21,7 @@ export const EmptyL1RollupConstants: L1RollupConstants = {
20
21
  slotDuration: 1,
21
22
  ethereumSlotDuration: 1,
22
23
  proofSubmissionEpochs: 1,
24
+ targetCommitteeSize: 48,
23
25
  };
24
26
 
25
27
  export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
@@ -30,6 +32,7 @@ export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
30
32
  epochDuration: z.number(),
31
33
  ethereumSlotDuration: z.number(),
32
34
  proofSubmissionEpochs: z.number(),
35
+ targetCommitteeSize: z.number(),
33
36
  }),
34
37
  );
35
38
 
package/src/hash/hash.ts CHANGED
@@ -69,6 +69,10 @@ export function computeProtocolNullifier(txRequestHash: Fr): Promise<Fr> {
69
69
  return siloNullifier(AztecAddress.fromBigInt(NULL_MSG_SENDER_CONTRACT_ADDRESS), txRequestHash);
70
70
  }
71
71
 
72
+ export function computeSiloedPrivateLogFirstField(contract: AztecAddress, field: Fr): Promise<Fr> {
73
+ return poseidon2HashWithSeparator([contract, field], GeneratorIndex.PRIVATE_LOG_FIRST_FIELD);
74
+ }
75
+
72
76
  /**
73
77
  * Computes a public data tree value ready for insertion.
74
78
  * @param value - Raw public data tree value to hash into a tree-insertion-ready value.
@@ -4,6 +4,7 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import { z } from 'zod';
6
6
 
7
+ import { BlockHash } from '../block/block_hash.js';
7
8
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
8
9
  import { L2Block } from '../block/l2_block.js';
9
10
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
@@ -99,12 +100,12 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
99
100
  .function()
100
101
  .args(CheckpointNumberSchema, schemas.Integer)
101
102
  .returns(z.array(PublishedCheckpoint.schema)),
102
- getCheckpointedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
103
+ getCheckpointedBlockByHash: z.function().args(BlockHash.schema).returns(CheckpointedL2Block.schema.optional()),
103
104
  getCheckpointedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
104
- getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
105
+ getBlockHeaderByHash: z.function().args(BlockHash.schema).returns(BlockHeader.schema.optional()),
105
106
  getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
106
107
  getL2Block: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
107
- getL2BlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
108
+ getL2BlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
108
109
  getL2BlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
109
110
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
110
111
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
@@ -52,7 +52,8 @@ export interface AztecNodeAdmin {
52
52
  getSlashOffenses(round: bigint | 'all' | 'current'): Promise<Offense[]>;
53
53
  }
54
54
 
55
- export type AztecNodeAdminConfig = ValidatorClientFullConfig &
55
+ // L1 contracts are not mutable via admin updates.
56
+ export type AztecNodeAdminConfig = Omit<ValidatorClientFullConfig, 'l1Contracts'> &
56
57
  SequencerConfig &
57
58
  ProverConfig &
58
59
  SlasherConfig &
@@ -65,7 +66,7 @@ export type AztecNodeAdminConfig = ValidatorClientFullConfig &
65
66
 
66
67
  export const AztecNodeAdminConfigSchema = SequencerConfigSchema.merge(ProverConfigSchema)
67
68
  .merge(SlasherConfigSchema)
68
- .merge(ValidatorClientFullConfigSchema)
69
+ .merge(ValidatorClientFullConfigSchema.omit({ l1Contracts: true }))
69
70
  .merge(
70
71
  ArchiverSpecificConfigSchema.pick({
71
72
  archiverPollingIntervalMS: true,
@@ -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