@aztec/stdlib 0.0.1-commit.0b941701 → 0.0.1-commit.134ed76

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/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 +16 -19
  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 +4 -4
  8. package/dest/block/block_parameter.d.ts.map +1 -1
  9. package/dest/block/block_parameter.js +2 -2
  10. package/dest/block/in_block.d.ts +9 -9
  11. package/dest/block/in_block.d.ts.map +1 -1
  12. package/dest/block/in_block.js +5 -5
  13. package/dest/block/l2_block.d.ts +3 -2
  14. package/dest/block/l2_block.d.ts.map +1 -1
  15. package/dest/block/l2_block.js +2 -3
  16. package/dest/block/l2_block_source.d.ts +5 -4
  17. package/dest/block/l2_block_source.d.ts.map +1 -1
  18. package/dest/config/index.d.ts +2 -1
  19. package/dest/config/index.d.ts.map +1 -1
  20. package/dest/config/index.js +1 -0
  21. package/dest/config/sequencer-config.d.ts +10 -0
  22. package/dest/config/sequencer-config.d.ts.map +1 -0
  23. package/dest/config/sequencer-config.js +12 -0
  24. package/dest/contract/contract_address.js +1 -1
  25. package/dest/contract/contract_class_id.d.ts +1 -1
  26. package/dest/contract/contract_class_id.js +1 -1
  27. package/dest/contract/private_function.js +1 -1
  28. package/dest/contract/private_function_membership_proof.d.ts +1 -1
  29. package/dest/contract/private_function_membership_proof.js +1 -1
  30. package/dest/database-version/database_version.d.ts +58 -0
  31. package/dest/database-version/database_version.d.ts.map +1 -0
  32. package/dest/database-version/database_version.js +69 -0
  33. package/dest/database-version/version_manager.d.ts +2 -50
  34. package/dest/database-version/version_manager.d.ts.map +1 -1
  35. package/dest/database-version/version_manager.js +1 -66
  36. package/dest/epoch-helpers/index.d.ts +7 -1
  37. package/dest/epoch-helpers/index.d.ts.map +1 -1
  38. package/dest/epoch-helpers/index.js +8 -2
  39. package/dest/hash/hash.js +2 -2
  40. package/dest/hash/map_slot.d.ts +1 -1
  41. package/dest/hash/map_slot.d.ts.map +1 -1
  42. package/dest/hash/map_slot.js +4 -3
  43. package/dest/interfaces/archiver.d.ts +1 -1
  44. package/dest/interfaces/archiver.d.ts.map +1 -1
  45. package/dest/interfaces/archiver.js +4 -3
  46. package/dest/interfaces/aztec-node-admin.d.ts +17 -2
  47. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  48. package/dest/interfaces/aztec-node-admin.js +3 -1
  49. package/dest/interfaces/aztec-node.d.ts +33 -54
  50. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  51. package/dest/interfaces/aztec-node.js +6 -10
  52. package/dest/interfaces/block-builder.d.ts +10 -4
  53. package/dest/interfaces/block-builder.d.ts.map +1 -1
  54. package/dest/interfaces/block-builder.js +7 -0
  55. package/dest/interfaces/get_logs_response.d.ts +15 -8
  56. package/dest/interfaces/get_logs_response.d.ts.map +1 -1
  57. package/dest/interfaces/p2p.d.ts +2 -2
  58. package/dest/interfaces/p2p.d.ts.map +1 -1
  59. package/dest/interfaces/prover-broker.d.ts +16 -1
  60. package/dest/interfaces/prover-broker.d.ts.map +1 -1
  61. package/dest/interfaces/prover-broker.js +4 -1
  62. package/dest/interfaces/prover-client.d.ts +6 -1
  63. package/dest/interfaces/prover-client.d.ts.map +1 -1
  64. package/dest/interfaces/prover-client.js +5 -0
  65. package/dest/interfaces/proving-job.d.ts +200 -200
  66. package/dest/interfaces/slasher.d.ts +9 -1
  67. package/dest/interfaces/slasher.d.ts.map +1 -1
  68. package/dest/interfaces/slasher.js +2 -0
  69. package/dest/interfaces/validator.d.ts +49 -3
  70. package/dest/interfaces/validator.d.ts.map +1 -1
  71. package/dest/interfaces/validator.js +4 -1
  72. package/dest/keys/derivation.d.ts +3 -3
  73. package/dest/keys/derivation.js +8 -8
  74. package/dest/keys/key_types.d.ts +1 -1
  75. package/dest/keys/utils.d.ts +1 -1
  76. package/dest/keys/utils.d.ts.map +1 -1
  77. package/dest/keys/utils.js +7 -3
  78. package/dest/l1-contracts/slash_factory.d.ts +1 -1
  79. package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
  80. package/dest/l1-contracts/slash_factory.js +1 -0
  81. package/dest/logs/extended_public_log.d.ts +13 -7
  82. package/dest/logs/extended_public_log.d.ts.map +1 -1
  83. package/dest/logs/log_id.d.ts +17 -14
  84. package/dest/logs/log_id.d.ts.map +1 -1
  85. package/dest/logs/log_id.js +20 -17
  86. package/dest/logs/siloed_tag.d.ts +1 -1
  87. package/dest/logs/siloed_tag.d.ts.map +1 -1
  88. package/dest/logs/siloed_tag.js +4 -3
  89. package/dest/messaging/l2_to_l1_membership.d.ts +2 -2
  90. package/dest/messaging/l2_to_l1_membership.js +3 -3
  91. package/dest/p2p/block_proposal.d.ts +10 -3
  92. package/dest/p2p/block_proposal.d.ts.map +1 -1
  93. package/dest/p2p/checkpoint_proposal.d.ts +17 -3
  94. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  95. package/dest/p2p/checkpoint_proposal.js +9 -0
  96. package/dest/p2p/constants.d.ts +3 -1
  97. package/dest/p2p/constants.d.ts.map +1 -1
  98. package/dest/p2p/constants.js +1 -0
  99. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +6 -6
  100. package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
  101. package/dest/rollup/checkpoint_rollup_public_inputs.js +2 -2
  102. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +2 -2
  103. package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
  104. package/dest/rollup/root_rollup_public_inputs.d.ts +6 -6
  105. package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
  106. package/dest/rollup/root_rollup_public_inputs.js +3 -3
  107. package/dest/slashing/empire.d.ts +1 -1
  108. package/dest/slashing/empire.d.ts.map +1 -1
  109. package/dest/slashing/empire.js +2 -0
  110. package/dest/slashing/helpers.d.ts +2 -2
  111. package/dest/slashing/helpers.d.ts.map +1 -1
  112. package/dest/slashing/helpers.js +6 -0
  113. package/dest/slashing/tally.d.ts +2 -1
  114. package/dest/slashing/tally.d.ts.map +1 -1
  115. package/dest/slashing/tally.js +6 -2
  116. package/dest/slashing/types.d.ts +7 -3
  117. package/dest/slashing/types.d.ts.map +1 -1
  118. package/dest/slashing/types.js +13 -1
  119. package/dest/stats/stats.d.ts +1 -3
  120. package/dest/stats/stats.d.ts.map +1 -1
  121. package/dest/tests/factories.js +3 -3
  122. package/dest/tests/mocks.d.ts +6 -2
  123. package/dest/tests/mocks.d.ts.map +1 -1
  124. package/dest/tests/mocks.js +4 -3
  125. package/dest/timetable/index.d.ts +37 -0
  126. package/dest/timetable/index.d.ts.map +1 -0
  127. package/dest/timetable/index.js +39 -0
  128. package/dest/trees/public_data_leaf.d.ts +2 -1
  129. package/dest/trees/public_data_leaf.d.ts.map +1 -1
  130. package/dest/trees/public_data_leaf.js +7 -6
  131. package/dest/tx/block_header.d.ts +3 -3
  132. package/dest/tx/block_header.d.ts.map +1 -1
  133. package/dest/tx/block_header.js +3 -3
  134. package/dest/tx/in_tx.d.ts +3 -3
  135. package/dest/tx/indexed_tx_effect.d.ts +5 -5
  136. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  137. package/dest/tx/indexed_tx_effect.js +3 -2
  138. package/dest/tx/tx_receipt.d.ts +5 -5
  139. package/dest/tx/tx_receipt.d.ts.map +1 -1
  140. package/dest/tx/tx_receipt.js +2 -2
  141. package/dest/tx/validator/empty_validator.d.ts +2 -2
  142. package/dest/tx/validator/empty_validator.d.ts.map +1 -1
  143. package/dest/tx/validator/tx_validator.d.ts +2 -2
  144. package/dest/tx/validator/tx_validator.d.ts.map +1 -1
  145. package/package.json +24 -12
  146. package/src/abi/function_call.ts +25 -3
  147. package/src/block/block_hash.ts +25 -50
  148. package/src/block/block_parameter.ts +3 -3
  149. package/src/block/in_block.ts +6 -6
  150. package/src/block/l2_block.ts +3 -3
  151. package/src/block/l2_block_source.ts +4 -3
  152. package/src/config/index.ts +1 -0
  153. package/src/config/sequencer-config.ts +19 -0
  154. package/src/contract/contract_address.ts +1 -1
  155. package/src/contract/contract_class_id.ts +1 -1
  156. package/src/contract/private_function.ts +1 -1
  157. package/src/contract/private_function_membership_proof.ts +1 -1
  158. package/src/database-version/database_version.ts +87 -0
  159. package/src/database-version/version_manager.ts +1 -77
  160. package/src/epoch-helpers/index.ts +12 -0
  161. package/src/hash/hash.ts +2 -2
  162. package/src/hash/map_slot.ts +3 -2
  163. package/src/interfaces/archiver.ts +4 -3
  164. package/src/interfaces/aztec-node-admin.ts +3 -2
  165. package/src/interfaces/aztec-node.ts +42 -93
  166. package/src/interfaces/block-builder.ts +12 -2
  167. package/src/interfaces/p2p.ts +1 -1
  168. package/src/interfaces/prover-broker.ts +22 -0
  169. package/src/interfaces/prover-client.ts +7 -0
  170. package/src/interfaces/slasher.ts +4 -0
  171. package/src/interfaces/validator.ts +11 -3
  172. package/src/keys/derivation.ts +8 -8
  173. package/src/keys/key_types.ts +1 -1
  174. package/src/keys/utils.ts +7 -3
  175. package/src/l1-contracts/slash_factory.ts +1 -0
  176. package/src/logs/log_id.ts +22 -18
  177. package/src/logs/siloed_tag.ts +3 -2
  178. package/src/messaging/l2_to_l1_membership.ts +3 -3
  179. package/src/p2p/block_proposal.ts +9 -2
  180. package/src/p2p/checkpoint_proposal.ts +19 -2
  181. package/src/p2p/constants.ts +3 -0
  182. package/src/rollup/checkpoint_rollup_public_inputs.ts +5 -5
  183. package/src/rollup/root_rollup_public_inputs.ts +7 -7
  184. package/src/slashing/empire.ts +3 -1
  185. package/src/slashing/helpers.ts +8 -0
  186. package/src/slashing/tally.ts +8 -2
  187. package/src/slashing/types.ts +14 -0
  188. package/src/stats/stats.ts +0 -2
  189. package/src/tests/factories.ts +5 -5
  190. package/src/tests/mocks.ts +6 -4
  191. package/src/timetable/index.ts +66 -0
  192. package/src/trees/public_data_leaf.ts +11 -5
  193. package/src/tx/block_header.ts +6 -6
  194. package/src/tx/indexed_tx_effect.ts +3 -2
  195. package/src/tx/tx_receipt.ts +4 -4
  196. package/src/tx/validator/empty_validator.ts +1 -1
  197. package/src/tx/validator/tx_validator.ts +1 -1
  198. package/dest/database-version/index.d.ts +0 -2
  199. package/dest/database-version/index.d.ts.map +0 -1
  200. package/dest/database-version/index.js +0 -1
  201. package/src/database-version/index.ts +0 -1
@@ -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
+ };
@@ -87,5 +87,5 @@ export async function computeInitializationHashFromEncodedArgs(
87
87
  encodedArgs: Fr[],
88
88
  ): Promise<Fr> {
89
89
  const argsHash = await computeVarArgsHash(encodedArgs);
90
- return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.CONSTRUCTOR);
90
+ return poseidon2HashWithSeparator([initFn, argsHash], GeneratorIndex.INITIALIZER);
91
91
  }
@@ -13,7 +13,7 @@ import { computePrivateFunctionsRoot } from './private_function.js';
13
13
  *
14
14
  * ```
15
15
  * version = 1
16
- * private_function_leaves = private_functions.map(fn => pedersen([fn.function_selector as Field, fn.vk_hash], GENERATOR__FUNCTION_LEAF))
16
+ * private_function_leaves = private_functions.map(fn => pedersen([fn.function_selector as Field, fn.vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF))
17
17
  * private_functions_root = merkleize(private_function_leaves)
18
18
  * bytecode_commitment = calculate_commitment(packed_bytecode)
19
19
  * contract_class_id = pedersen([version, artifact_hash, private_functions_root, bytecode_commitment], GENERATOR__CLASS_IDENTIFIER)
@@ -31,7 +31,7 @@ function computePrivateFunctionLeaves(fns: PrivateFunction[]): Promise<Buffer[]>
31
31
 
32
32
  /** Returns the leaf for a given private function. */
33
33
  export async function computePrivateFunctionLeaf(fn: PrivateFunction): Promise<Buffer> {
34
- return (await poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.FUNCTION_LEAF)).toBuffer();
34
+ return (await poseidon2HashWithSeparator([fn.selector, fn.vkHash], GeneratorIndex.PRIVATE_FUNCTION_LEAF)).toBuffer();
35
35
  }
36
36
 
37
37
  async function getPrivateFunctionTreeCalculator(): Promise<MerkleTreeCalculator> {
@@ -99,7 +99,7 @@ export async function createPrivateFunctionMembershipProof(
99
99
  * contract_class = db.get_contract_class(contract_class_id)
100
100
  *
101
101
  * // Compute function leaf and assert it belongs to the private functions tree
102
- * function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__FUNCTION_LEAF)
102
+ * function_leaf = pedersen([selector as Field, vk_hash], GENERATOR__PRIVATE_FUNCTION_LEAF)
103
103
  * computed_private_function_tree_root = compute_root(function_leaf, private_function_tree_sibling_path)
104
104
  * assert computed_private_function_tree_root == contract_class.private_functions_root
105
105
  *
@@ -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
 
@@ -51,6 +54,15 @@ export function getSlotAtTimestamp(
51
54
  : SlotNumber.fromBigInt((ts - constants.l1GenesisTime) / BigInt(constants.slotDuration));
52
55
  }
53
56
 
57
+ /** Returns the L2 slot number at the next L1 block based on the current timestamp. */
58
+ export function getSlotAtNextL1Block(
59
+ currentL1Timestamp: bigint,
60
+ constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'ethereumSlotDuration'>,
61
+ ): SlotNumber {
62
+ const nextL1BlockTimestamp = currentL1Timestamp + BigInt(constants.ethereumSlotDuration);
63
+ return getSlotAtTimestamp(nextL1BlockTimestamp, constants);
64
+ }
65
+
54
66
  /** Returns the epoch number for a given timestamp. */
55
67
  export function getEpochNumberAtTimestamp(
56
68
  ts: bigint,
package/src/hash/hash.ts CHANGED
@@ -55,7 +55,7 @@ export function computeUniqueNoteHash(noteNonce: Fr, siloedNoteHash: Fr): Promis
55
55
  * @returns A siloed nullifier.
56
56
  */
57
57
  export function siloNullifier(contract: AztecAddress, innerNullifier: Fr): Promise<Fr> {
58
- return poseidon2HashWithSeparator([contract, innerNullifier], GeneratorIndex.OUTER_NULLIFIER);
58
+ return poseidon2HashWithSeparator([contract, innerNullifier], GeneratorIndex.SILOED_NULLIFIER);
59
59
  }
60
60
 
61
61
  /**
@@ -87,7 +87,7 @@ export function computePublicDataTreeValue(value: Fr): Fr {
87
87
 
88
88
  */
89
89
  export function computePublicDataTreeLeafSlot(contractAddress: AztecAddress, storageSlot: Fr): Promise<Fr> {
90
- return poseidon2HashWithSeparator([contractAddress, storageSlot], GeneratorIndex.PUBLIC_LEAF_INDEX);
90
+ return poseidon2HashWithSeparator([contractAddress, storageSlot], GeneratorIndex.PUBLIC_LEAF_SLOT);
91
91
  }
92
92
 
93
93
  /**
@@ -1,4 +1,5 @@
1
- import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
1
+ import { GeneratorIndex } from '@aztec/constants';
2
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
2
3
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
4
 
4
5
  /**
@@ -14,5 +15,5 @@ export function deriveStorageSlotInMap(
14
15
  toField: () => Fr;
15
16
  },
16
17
  ): Promise<Fr> {
17
- return poseidon2Hash([mapSlot, key.toField()]);
18
+ return poseidon2HashWithSeparator([mapSlot, key.toField()], GeneratorIndex.PUBLIC_STORAGE_MAP_SLOT);
18
19
  }
@@ -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,
@@ -23,7 +17,7 @@ import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
23
17
  import { z } from 'zod';
24
18
 
25
19
  import type { AztecAddress } from '../aztec-address/index.js';
26
- import { L2BlockHash } from '../block/block_hash.js';
20
+ import { BlockHash } from '../block/block_hash.js';
27
21
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
28
22
  import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
29
23
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
@@ -93,63 +87,31 @@ export interface AztecNode
93
87
  /**
94
88
  * Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
95
89
  * the leaves were inserted.
96
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
90
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
97
91
  * @param treeId - The tree to search in.
98
92
  * @param leafValues - The values to search for.
99
93
  * @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
100
94
  */
101
95
  findLeavesIndexes(
102
- block: BlockParameter,
96
+ referenceBlock: BlockParameter,
103
97
  treeId: MerkleTreeId,
104
98
  leafValues: Fr[],
105
99
  ): Promise<(DataInBlock<bigint> | undefined)[]>;
106
100
 
107
- /**
108
- * Returns a sibling path for the given index in the nullifier tree.
109
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
110
- * @param leafIndex - The index of the leaf for which the sibling path is required.
111
- * @returns The sibling path for the leaf index.
112
- */
113
- getNullifierSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>>;
114
-
115
- /**
116
- * Returns a sibling path for the given index in the note hash tree.
117
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
118
- * @param leafIndex - The index of the leaf for which the sibling path is required.
119
- * @returns The sibling path for the leaf index.
120
- */
121
- getNoteHashSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>>;
122
-
123
- /**
124
- * Returns a sibling path for a leaf in the committed historic blocks tree.
125
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
126
- * @param leafIndex - Index of the leaf in the tree.
127
- * @returns The sibling path.
128
- */
129
- getArchiveSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>>;
130
-
131
- /**
132
- * Returns a sibling path for a leaf in the committed public data tree.
133
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
134
- * @param leafIndex - Index of the leaf in the tree.
135
- * @returns The sibling path.
136
- */
137
- getPublicDataSiblingPath(
138
- block: BlockParameter,
139
- leafIndex: bigint,
140
- ): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>>;
141
-
142
101
  /**
143
102
  * Returns a nullifier membership witness for a given nullifier at a given block.
144
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
103
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
145
104
  * @param nullifier - Nullifier we try to find witness for.
146
105
  * @returns The nullifier membership witness (if found).
147
106
  */
148
- getNullifierMembershipWitness(block: BlockParameter, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
107
+ getNullifierMembershipWitness(
108
+ referenceBlock: BlockParameter,
109
+ nullifier: Fr,
110
+ ): Promise<NullifierMembershipWitness | undefined>;
149
111
 
150
112
  /**
151
113
  * Returns a low nullifier membership witness for a given nullifier at a given block.
152
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
114
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
153
115
  * @param nullifier - Nullifier we try to find the low nullifier witness for.
154
116
  * @returns The low nullifier membership witness (if found).
155
117
  * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
@@ -157,49 +119,56 @@ export interface AztecNode
157
119
  * we are trying to prove non-inclusion for.
158
120
  */
159
121
  getLowNullifierMembershipWitness(
160
- block: BlockParameter,
122
+ referenceBlock: BlockParameter,
161
123
  nullifier: Fr,
162
124
  ): Promise<NullifierMembershipWitness | undefined>;
163
125
 
164
126
  /**
165
127
  * Returns a public data tree witness for a given leaf slot at a given block.
166
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
128
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
167
129
  * @param leafSlot - The leaf slot we try to find the witness for.
168
130
  * @returns The public data witness (if found).
169
131
  * @remarks The witness can be used to compute the current value of the public data tree leaf. If the low leaf preimage corresponds to an
170
132
  * "in range" slot, means that the slot doesn't exist and the value is 0. If the low leaf preimage corresponds to the exact slot, the current value
171
133
  * is contained in the leaf preimage.
172
134
  */
173
- getPublicDataWitness(block: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
135
+ getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
174
136
 
175
137
  /**
176
- * Returns a membership witness for a given archive leaf at a given block.
177
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
178
- * @param archive - The archive leaf we try to find the witness for.
138
+ * Returns a membership witness for a given block hash in the archive tree.
139
+ *
140
+ * Block hashes are the leaves of the archive tree. Each time a new block is added to the chain,
141
+ * its block hash is appended as a new leaf to the archive tree. This method finds the membership
142
+ * witness (leaf index and sibling path) for a given block hash, which can be used to prove that
143
+ * a specific block exists in the chain's history.
144
+ *
145
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
146
+ * (which contains the root of the archive tree in which we are searching for the block hash).
147
+ * @param blockHash - The block hash to find in the archive tree.
179
148
  */
180
- getArchiveMembershipWitness(
181
- block: BlockParameter,
182
- archive: Fr,
149
+ getBlockHashMembershipWitness(
150
+ referenceBlock: BlockParameter,
151
+ blockHash: BlockHash,
183
152
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
184
153
 
185
154
  /**
186
155
  * Returns a membership witness for a given note hash at a given block.
187
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
156
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
188
157
  * @param noteHash - The note hash we try to find the witness for.
189
158
  */
190
159
  getNoteHashMembershipWitness(
191
- block: BlockParameter,
160
+ referenceBlock: BlockParameter,
192
161
  noteHash: Fr,
193
162
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
194
163
 
195
164
  /**
196
165
  * Returns the index and a sibling path for a leaf in the committed l1 to l2 data tree.
197
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
166
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
198
167
  * @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
199
168
  * @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
200
169
  */
201
170
  getL1ToL2MessageMembershipWitness(
202
- block: BlockParameter,
171
+ referenceBlock: BlockParameter,
203
172
  l1ToL2Message: Fr,
204
173
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
205
174
 
@@ -224,17 +193,17 @@ export interface AztecNode
224
193
 
225
194
  /**
226
195
  * Get a block specified by its block number or 'latest'.
227
- * @param number - The block number or 'latest'.
196
+ * @param blockParameter - The block parameter (block number, block hash, or 'latest').
228
197
  * @returns The requested block.
229
198
  */
230
- getBlock(number: BlockParameter): Promise<L2Block | undefined>;
199
+ getBlock(blockParameter: BlockParameter): Promise<L2Block | undefined>;
231
200
 
232
201
  /**
233
202
  * Get a block specified by its hash.
234
203
  * @param blockHash - The block hash being requested.
235
204
  * @returns The requested block.
236
205
  */
237
- getBlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
206
+ getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
238
207
 
239
208
  /**
240
209
  * Get a block specified by its archive root.
@@ -355,7 +324,7 @@ export interface AztecNode
355
324
  * @returns An array of log arrays, one per tag. Returns at most 10 logs per tag per page. If 10 logs are returned
356
325
  * for a tag, the caller should fetch the next page to check for more logs.
357
326
  */
358
- getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: L2BlockHash): Promise<TxScopedL2Log[][]>;
327
+ getPrivateLogsByTags(tags: SiloedTag[], page?: number, referenceBlock?: BlockHash): Promise<TxScopedL2Log[][]>;
359
328
 
360
329
  /**
361
330
  * Gets public logs that match any of the `tags` from the specified contract. For each tag, an array of matching
@@ -374,7 +343,7 @@ export interface AztecNode
374
343
  contractAddress: AztecAddress,
375
344
  tags: Tag[],
376
345
  page?: number,
377
- referenceBlock?: L2BlockHash,
346
+ referenceBlock?: BlockHash,
378
347
  ): Promise<TxScopedL2Log[][]>;
379
348
 
380
349
  /**
@@ -433,12 +402,12 @@ export interface AztecNode
433
402
  * @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
434
403
  * Aztec's version of `eth_getStorageAt`.
435
404
  *
436
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
405
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data.
437
406
  * @param contract - Address of the contract to query.
438
407
  * @param slot - Slot to query.
439
408
  * @returns Storage value at the given contract slot.
440
409
  */
441
- getPublicStorageAt(block: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
410
+ getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
442
411
 
443
412
  /**
444
413
  * Returns the block header for a given block number, block hash, or 'latest'.
@@ -518,26 +487,6 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
518
487
  .args(BlockParameterSchema, z.nativeEnum(MerkleTreeId), z.array(schemas.Fr).max(MAX_RPC_LEN))
519
488
  .returns(z.array(optional(dataInBlockSchemaFor(schemas.BigInt)))),
520
489
 
521
- getNullifierSiblingPath: z
522
- .function()
523
- .args(BlockParameterSchema, schemas.BigInt)
524
- .returns(SiblingPath.schemaFor(NULLIFIER_TREE_HEIGHT)),
525
-
526
- getNoteHashSiblingPath: z
527
- .function()
528
- .args(BlockParameterSchema, schemas.BigInt)
529
- .returns(SiblingPath.schemaFor(NOTE_HASH_TREE_HEIGHT)),
530
-
531
- getArchiveSiblingPath: z
532
- .function()
533
- .args(BlockParameterSchema, schemas.BigInt)
534
- .returns(SiblingPath.schemaFor(ARCHIVE_HEIGHT)),
535
-
536
- getPublicDataSiblingPath: z
537
- .function()
538
- .args(BlockParameterSchema, schemas.BigInt)
539
- .returns(SiblingPath.schemaFor(PUBLIC_DATA_TREE_HEIGHT)),
540
-
541
490
  getNullifierMembershipWitness: z
542
491
  .function()
543
492
  .args(BlockParameterSchema, schemas.Fr)
@@ -553,9 +502,9 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
553
502
  .args(BlockParameterSchema, schemas.Fr)
554
503
  .returns(PublicDataWitness.schema.optional()),
555
504
 
556
- getArchiveMembershipWitness: z
505
+ getBlockHashMembershipWitness: z
557
506
  .function()
558
- .args(BlockParameterSchema, schemas.Fr)
507
+ .args(BlockParameterSchema, BlockHash.schema)
559
508
  .returns(MembershipWitness.schemaFor(ARCHIVE_HEIGHT).optional()),
560
509
 
561
510
  getNoteHashMembershipWitness: z
@@ -579,7 +528,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
579
528
 
580
529
  getBlock: z.function().args(BlockParameterSchema).returns(L2Block.schema.optional()),
581
530
 
582
- getBlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
531
+ getBlockByHash: z.function().args(BlockHash.schema).returns(L2Block.schema.optional()),
583
532
 
584
533
  getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
585
534
 
@@ -633,7 +582,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
633
582
 
634
583
  getPrivateLogsByTags: z
635
584
  .function()
636
- .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(L2BlockHash.schema))
585
+ .args(z.array(SiloedTag.schema).max(MAX_RPC_LEN), optional(z.number().gte(0)), optional(BlockHash.schema))
637
586
  .returns(z.array(z.array(TxScopedL2Log.schema))),
638
587
 
639
588
  getPublicLogsByTagsFromContract: z
@@ -642,7 +591,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
642
591
  schemas.AztecAddress,
643
592
  z.array(Tag.schema).max(MAX_RPC_LEN),
644
593
  optional(z.number().gte(0)),
645
- optional(L2BlockHash.schema),
594
+ optional(BlockHash.schema),
646
595
  )
647
596
  .returns(z.array(z.array(TxScopedL2Log.schema))),
648
597