@aztec/foundation 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d

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 (238) hide show
  1. package/dest/bigint-buffer/index.d.ts +1 -1
  2. package/dest/bigint-buffer/index.d.ts.map +1 -1
  3. package/dest/bigint-buffer/index.js +6 -1
  4. package/dest/branded-types/block_number.d.ts +3 -3
  5. package/dest/branded-types/block_number.d.ts.map +1 -1
  6. package/dest/branded-types/block_number.js +15 -4
  7. package/dest/branded-types/buffer32_hash.d.ts +27 -0
  8. package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
  9. package/dest/branded-types/buffer32_hash.js +12 -0
  10. package/dest/branded-types/checkpoint_number.d.ts +9 -3
  11. package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
  12. package/dest/branded-types/checkpoint_number.js +11 -0
  13. package/dest/branded-types/epoch.d.ts +2 -2
  14. package/dest/branded-types/epoch.d.ts.map +1 -1
  15. package/dest/branded-types/index.d.ts +2 -1
  16. package/dest/branded-types/index.d.ts.map +1 -1
  17. package/dest/branded-types/index.js +1 -0
  18. package/dest/branded-types/index_within_checkpoint.d.ts +2 -2
  19. package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -1
  20. package/dest/branded-types/slot.d.ts +2 -2
  21. package/dest/branded-types/slot.d.ts.map +1 -1
  22. package/dest/buffer/buffer16.d.ts +3 -3
  23. package/dest/buffer/buffer16.d.ts.map +1 -1
  24. package/dest/buffer/buffer32.d.ts +28 -63
  25. package/dest/buffer/buffer32.d.ts.map +1 -1
  26. package/dest/buffer/buffer32.js +29 -63
  27. package/dest/collection/array.d.ts +9 -1
  28. package/dest/collection/array.d.ts.map +1 -1
  29. package/dest/collection/array.js +18 -0
  30. package/dest/collection/index.d.ts +2 -1
  31. package/dest/collection/index.d.ts.map +1 -1
  32. package/dest/collection/index.js +1 -0
  33. package/dest/collection/lru_map.d.ts +41 -0
  34. package/dest/collection/lru_map.d.ts.map +1 -0
  35. package/dest/collection/lru_map.js +119 -0
  36. package/dest/committable/committable.js +1 -1
  37. package/dest/config/env_var.d.ts +2 -2
  38. package/dest/config/env_var.d.ts.map +1 -1
  39. package/dest/config/index.d.ts +67 -37
  40. package/dest/config/index.d.ts.map +1 -1
  41. package/dest/config/index.js +72 -71
  42. package/dest/config/network_config.d.ts +11 -55
  43. package/dest/config/network_config.d.ts.map +1 -1
  44. package/dest/config/network_name.d.ts +2 -2
  45. package/dest/config/network_name.d.ts.map +1 -1
  46. package/dest/config/network_name.js +1 -3
  47. package/dest/config/secret_value.d.ts +2 -2
  48. package/dest/config/secret_value.d.ts.map +1 -1
  49. package/dest/crypto/bls/bn254_keystore.d.ts +10 -168
  50. package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
  51. package/dest/crypto/bls/bn254_keystore.js +22 -17
  52. package/dest/crypto/schnorr/index.d.ts +8 -7
  53. package/dest/crypto/schnorr/index.d.ts.map +1 -1
  54. package/dest/crypto/schnorr/index.js +6 -6
  55. package/dest/crypto/schnorr/signature.d.ts +9 -29
  56. package/dest/crypto/schnorr/signature.d.ts.map +1 -1
  57. package/dest/crypto/schnorr/signature.js +20 -36
  58. package/dest/curves/bls12/field.d.ts +3 -3
  59. package/dest/curves/bls12/field.d.ts.map +1 -1
  60. package/dest/curves/bls12/field.js +0 -5
  61. package/dest/curves/bls12/point.d.ts +2 -2
  62. package/dest/curves/bls12/point.d.ts.map +1 -1
  63. package/dest/curves/bn254/field.d.ts +23 -19
  64. package/dest/curves/bn254/field.d.ts.map +1 -1
  65. package/dest/curves/bn254/field.js +23 -17
  66. package/dest/curves/grumpkin/point.d.ts +13 -27
  67. package/dest/curves/grumpkin/point.d.ts.map +1 -1
  68. package/dest/curves/grumpkin/point.js +28 -42
  69. package/dest/eth-address/index.d.ts +2 -2
  70. package/dest/eth-address/index.d.ts.map +1 -1
  71. package/dest/eth-address/index.js +0 -3
  72. package/dest/eth-signature/eth_signature.d.ts +2 -2
  73. package/dest/eth-signature/eth_signature.d.ts.map +1 -1
  74. package/dest/fifo_set/fifo_set.d.ts +15 -0
  75. package/dest/fifo_set/fifo_set.d.ts.map +1 -0
  76. package/dest/fifo_set/fifo_set.js +39 -0
  77. package/dest/fifo_set/index.d.ts +2 -0
  78. package/dest/fifo_set/index.d.ts.map +1 -0
  79. package/dest/fifo_set/index.js +1 -0
  80. package/dest/iterable/first.d.ts +8 -0
  81. package/dest/iterable/first.d.ts.map +1 -0
  82. package/dest/iterable/first.js +11 -0
  83. package/dest/iterable/index.d.ts +2 -1
  84. package/dest/iterable/index.d.ts.map +1 -1
  85. package/dest/iterable/index.js +1 -0
  86. package/dest/json-rpc/client/fetch.d.ts +8 -3
  87. package/dest/json-rpc/client/fetch.d.ts.map +1 -1
  88. package/dest/json-rpc/client/fetch.js +8 -5
  89. package/dest/json-rpc/client/safe_json_rpc_client.d.ts +1 -1
  90. package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
  91. package/dest/json-rpc/client/safe_json_rpc_client.js +2 -2
  92. package/dest/json-rpc/client/undici.d.ts +14 -3
  93. package/dest/json-rpc/client/undici.d.ts.map +1 -1
  94. package/dest/json-rpc/client/undici.js +47 -14
  95. package/dest/json-rpc/fixtures/test_state.d.ts +4 -8
  96. package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
  97. package/dest/json-rpc/fixtures/test_state.js +57 -17
  98. package/dest/json-rpc/server/safe_json_rpc_server.d.ts +49 -11
  99. package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
  100. package/dest/json-rpc/server/safe_json_rpc_server.js +159 -40
  101. package/dest/log/aws-logger-config.d.ts +8 -0
  102. package/dest/log/aws-logger-config.d.ts.map +1 -0
  103. package/dest/log/aws-logger-config.js +55 -0
  104. package/dest/log/pino-logger.d.ts +1 -1
  105. package/dest/log/pino-logger.d.ts.map +1 -1
  106. package/dest/log/pino-logger.js +27 -7
  107. package/dest/noir/noir_package_config.d.ts +19 -104
  108. package/dest/noir/noir_package_config.d.ts.map +1 -1
  109. package/dest/noir/noir_package_config.js +1 -1
  110. package/dest/promise/running-promise.d.ts +8 -2
  111. package/dest/promise/running-promise.d.ts.map +1 -1
  112. package/dest/promise/running-promise.js +17 -5
  113. package/dest/promise/utils.d.ts +14 -1
  114. package/dest/promise/utils.d.ts.map +1 -1
  115. package/dest/promise/utils.js +20 -0
  116. package/dest/queue/batch_queue.d.ts +1 -1
  117. package/dest/queue/batch_queue.d.ts.map +1 -1
  118. package/dest/queue/batch_queue.js +1 -0
  119. package/dest/retry/index.d.ts +20 -3
  120. package/dest/retry/index.d.ts.map +1 -1
  121. package/dest/retry/index.js +23 -2
  122. package/dest/schemas/api.d.ts +11 -9
  123. package/dest/schemas/api.d.ts.map +1 -1
  124. package/dest/schemas/api.js +7 -1
  125. package/dest/schemas/parse.d.ts +4 -4
  126. package/dest/schemas/parse.d.ts.map +1 -1
  127. package/dest/schemas/parse.js +6 -5
  128. package/dest/schemas/schemas.d.ts +15 -15
  129. package/dest/schemas/types.d.ts +3 -3
  130. package/dest/schemas/types.d.ts.map +1 -1
  131. package/dest/schemas/utils.d.ts +7 -11
  132. package/dest/schemas/utils.d.ts.map +1 -1
  133. package/dest/schemas/utils.js +2 -18
  134. package/dest/serialize/buffer_reader.d.ts +1 -1
  135. package/dest/serialize/buffer_reader.d.ts.map +1 -1
  136. package/dest/serialize/buffer_reader.js +5 -0
  137. package/dest/serialize/buffer_sink.d.ts +134 -0
  138. package/dest/serialize/buffer_sink.d.ts.map +1 -0
  139. package/dest/serialize/buffer_sink.js +297 -0
  140. package/dest/serialize/index.d.ts +2 -1
  141. package/dest/serialize/index.d.ts.map +1 -1
  142. package/dest/serialize/index.js +1 -0
  143. package/dest/serialize/serialize.d.ts +1 -32
  144. package/dest/serialize/serialize.d.ts.map +1 -1
  145. package/dest/serialize/serialize.js +0 -21
  146. package/dest/string/index.js +1 -1
  147. package/dest/testing/files/index.d.ts +2 -3
  148. package/dest/testing/files/index.d.ts.map +1 -1
  149. package/dest/testing/files/index.js +1 -2
  150. package/dest/timer/index.d.ts +2 -2
  151. package/dest/timer/index.d.ts.map +1 -1
  152. package/dest/timer/index.js +1 -1
  153. package/dest/timer/timeout.d.ts +3 -1
  154. package/dest/timer/timeout.d.ts.map +1 -1
  155. package/dest/timer/timeout.js +26 -0
  156. package/dest/trees/balanced_merkle_tree_root.d.ts +2 -3
  157. package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
  158. package/dest/trees/balanced_merkle_tree_root.js +2 -3
  159. package/dest/trees/hasher.d.ts +3 -2
  160. package/dest/trees/hasher.d.ts.map +1 -1
  161. package/dest/trees/hasher.js +5 -5
  162. package/dest/trees/membership_witness.d.ts +2 -6
  163. package/dest/trees/membership_witness.d.ts.map +1 -1
  164. package/dest/trees/membership_witness.js +0 -9
  165. package/dest/trees/merkle_tree_calculator.d.ts +4 -2
  166. package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
  167. package/dest/trees/merkle_tree_calculator.js +1 -5
  168. package/dest/trees/sibling_path.d.ts +13 -14
  169. package/dest/trees/sibling_path.d.ts.map +1 -1
  170. package/dest/trees/sibling_path.js +23 -28
  171. package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
  172. package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
  173. package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
  174. package/dest/types/index.d.ts +23 -1
  175. package/dest/types/index.d.ts.map +1 -1
  176. package/dest/types/index.js +15 -0
  177. package/package.json +5 -4
  178. package/src/bigint-buffer/index.ts +6 -1
  179. package/src/branded-types/block_number.ts +20 -2
  180. package/src/branded-types/buffer32_hash.ts +38 -0
  181. package/src/branded-types/checkpoint_number.ts +16 -1
  182. package/src/branded-types/epoch.ts +1 -1
  183. package/src/branded-types/index.ts +1 -0
  184. package/src/branded-types/index_within_checkpoint.ts +1 -1
  185. package/src/branded-types/slot.ts +1 -1
  186. package/src/buffer/buffer16.ts +2 -2
  187. package/src/buffer/buffer32.ts +39 -71
  188. package/src/collection/array.ts +20 -0
  189. package/src/collection/index.ts +1 -0
  190. package/src/collection/lru_map.ts +143 -0
  191. package/src/committable/committable.ts +1 -1
  192. package/src/config/env_var.ts +50 -22
  193. package/src/config/index.ts +143 -122
  194. package/src/config/network_name.ts +2 -5
  195. package/src/config/secret_value.ts +1 -1
  196. package/src/crypto/bls/bn254_keystore.ts +33 -20
  197. package/src/crypto/schnorr/index.ts +9 -8
  198. package/src/crypto/schnorr/signature.ts +17 -46
  199. package/src/curves/bls12/field.ts +0 -7
  200. package/src/curves/bn254/field.ts +35 -34
  201. package/src/curves/grumpkin/point.ts +22 -39
  202. package/src/eth-address/index.ts +0 -4
  203. package/src/fifo_set/fifo_set.ts +52 -0
  204. package/src/fifo_set/index.ts +1 -0
  205. package/src/iterable/first.ts +14 -0
  206. package/src/iterable/index.ts +1 -0
  207. package/src/json-rpc/client/fetch.ts +16 -3
  208. package/src/json-rpc/client/safe_json_rpc_client.ts +2 -2
  209. package/src/json-rpc/client/undici.ts +54 -12
  210. package/src/json-rpc/fixtures/test_state.ts +10 -10
  211. package/src/json-rpc/server/safe_json_rpc_server.ts +204 -47
  212. package/src/log/aws-logger-config.ts +32 -0
  213. package/src/log/pino-logger.ts +30 -5
  214. package/src/noir/noir_package_config.ts +32 -20
  215. package/src/promise/running-promise.ts +20 -7
  216. package/src/promise/utils.ts +31 -0
  217. package/src/queue/batch_queue.ts +1 -0
  218. package/src/retry/index.ts +36 -4
  219. package/src/schemas/api.ts +21 -24
  220. package/src/schemas/parse.ts +9 -6
  221. package/src/schemas/schemas.ts +4 -4
  222. package/src/schemas/types.ts +2 -2
  223. package/src/schemas/utils.ts +4 -38
  224. package/src/serialize/buffer_reader.ts +5 -0
  225. package/src/serialize/buffer_sink.ts +350 -0
  226. package/src/serialize/index.ts +1 -0
  227. package/src/serialize/serialize.ts +0 -50
  228. package/src/string/index.ts +1 -1
  229. package/src/testing/files/index.ts +1 -2
  230. package/src/timer/index.ts +1 -1
  231. package/src/timer/timeout.ts +31 -0
  232. package/src/trees/balanced_merkle_tree_root.ts +2 -5
  233. package/src/trees/hasher.ts +6 -3
  234. package/src/trees/membership_witness.ts +0 -8
  235. package/src/trees/merkle_tree_calculator.ts +4 -10
  236. package/src/trees/sibling_path.ts +24 -30
  237. package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
  238. package/src/types/index.ts +47 -0
@@ -7,72 +7,39 @@ import { inspect } from 'util';
7
7
  import { bufferToHex } from '../string/index.js';
8
8
 
9
9
  /**
10
- * A class representing a 32 byte Buffer.
10
+ * Abstract unbranded base class for 32-byte buffers.
11
+ * Extend this instead of Buffer32 when defining a branded subtype
12
+ * to avoid inheriting Buffer32's `_branding`.
11
13
  */
12
- export class Buffer32 {
13
- /** Branding to prevent structural compatibility with Buffer16. */
14
- declare readonly __brand: 'Buffer32';
15
-
16
- /**
17
- * The size of the hash in bytes.
18
- */
14
+ export abstract class BaseBuffer32 {
15
+ /** The size of the buffer in bytes. */
19
16
  public static SIZE = 32;
20
17
 
21
- /**
22
- * Buffer32 with value zero.
23
- */
24
- public static ZERO = new Buffer32(Buffer.alloc(Buffer32.SIZE));
25
-
26
18
  constructor(
27
- /**
28
- * The buffer containing the hash.
29
- */
19
+ /** The buffer containing the data. */
30
20
  public buffer: Buffer,
31
21
  ) {
32
- if (buffer.length !== Buffer32.SIZE) {
33
- throw new Error(`Expected buffer to have length ${Buffer32.SIZE} but was ${buffer.length}`);
22
+ if (buffer.length !== BaseBuffer32.SIZE) {
23
+ throw new Error(`Expected buffer to have length ${BaseBuffer32.SIZE} but was ${buffer.length}`);
34
24
  }
35
25
  }
36
26
 
37
- /**
38
- * Returns the raw buffer of the hash.
39
- * @returns The buffer containing the hash.
40
- */
27
+ /** Returns the raw buffer. */
41
28
  public toBuffer() {
42
29
  return this.buffer;
43
30
  }
44
31
 
45
- /**
46
- * Creates a Buffer32 from a buffer.
47
- * @param buffer - The buffer to create from.
48
- * @returns A new Buffer32 object.
49
- */
50
- public static fromBuffer(buffer: Buffer | BufferReader) {
51
- const reader = BufferReader.asReader(buffer);
52
- return new Buffer32(reader.readBytes(Buffer32.SIZE));
53
- }
54
-
55
- /**
56
- * Checks if this hash and another hash are equal.
57
- * @param hash - A hash to compare with.
58
- * @returns True if the hashes are equal, false otherwise.
59
- */
60
- public equals(hash: Buffer32): boolean {
32
+ /** Checks if this and another buffer are equal. */
33
+ public equals(hash: BaseBuffer32): boolean {
61
34
  return this.buffer.equals(hash.buffer);
62
35
  }
63
36
 
64
- /**
65
- * Returns true if this hash is zero.
66
- * @returns True if this hash is zero.
67
- */
37
+ /** Returns true if all bytes are zero. */
68
38
  public isZero(): boolean {
69
39
  return this.buffer.equals(Buffer.alloc(32, 0));
70
40
  }
71
41
 
72
- /**
73
- * Convert this hash to a hex string.
74
- * @returns The hex string.
75
- */
42
+ /** Convert to a hex string. */
76
43
  public toString() {
77
44
  return bufferToHex(this.buffer);
78
45
  }
@@ -85,16 +52,27 @@ export class Buffer32 {
85
52
  return this.toString();
86
53
  }
87
54
 
88
- /**
89
- * Convert this hash to a big int.
90
- * @returns The big int.
91
- */
55
+ /** Convert to a big int. */
92
56
  public toBigInt() {
93
- return deserializeBigInt(this.buffer, 0, Buffer32.SIZE).elem;
57
+ return deserializeBigInt(this.buffer, 0, BaseBuffer32.SIZE).elem;
94
58
  }
95
- /**
96
- * Creates a Buffer32 from a bigint.
97
- */
59
+ }
60
+
61
+ /** A branded 32-byte buffer. */
62
+ export class Buffer32 extends BaseBuffer32 {
63
+ /** Branding for nominal typing. */
64
+ declare private readonly _branding: 'Buffer32';
65
+
66
+ /** Buffer32 with value zero. */
67
+ public static ZERO = new Buffer32(Buffer.alloc(Buffer32.SIZE));
68
+
69
+ /** Creates a Buffer32 from a buffer. */
70
+ public static fromBuffer(buffer: Buffer | BufferReader) {
71
+ const reader = BufferReader.asReader(buffer);
72
+ return new Buffer32(reader.readBytes(Buffer32.SIZE));
73
+ }
74
+
75
+ /** Creates a Buffer32 from a bigint. */
98
76
  public static fromBigInt(hash: bigint) {
99
77
  return new Buffer32(serializeBigInt(hash, Buffer32.SIZE));
100
78
  }
@@ -104,8 +82,7 @@ export class Buffer32 {
104
82
  }
105
83
 
106
84
  /**
107
- * Converts this hash from a buffer of 28 bytes.
108
- * Verifies the input is 28 bytes.
85
+ * Converts from a buffer of 28 bytes.
109
86
  * @param buffer - The 28 byte buffer to construct from.
110
87
  * @returns A Buffer32 created from the input buffer with 4 bytes 0 padding at the front.
111
88
  */
@@ -113,36 +90,27 @@ export class Buffer32 {
113
90
  if (buffer.length != 28) {
114
91
  throw new Error(`Expected Buffer32 input buffer to be 28 bytes`);
115
92
  }
116
- const padded = Buffer.concat([Buffer.alloc(this.SIZE - 28), buffer]);
93
+ const padded = Buffer.concat([Buffer.alloc(Buffer32.SIZE - 28), buffer]);
117
94
  return new Buffer32(padded);
118
95
  }
119
96
 
120
- /**
121
- * Converts a string into a Buffer32 object.
122
- */
97
+ /** Converts a string into a Buffer32 object. */
123
98
  public static fromString(str: string): Buffer32 {
124
99
  if (str.startsWith('0x')) {
125
100
  str = str.slice(2);
126
101
  }
127
- if (str.length !== this.SIZE * 2) {
128
- throw new Error(`Expected string to be ${this.SIZE * 2} characters long, but was ${str.length}`);
102
+ if (str.length !== Buffer32.SIZE * 2) {
103
+ throw new Error(`Expected string to be ${Buffer32.SIZE * 2} characters long, but was ${str.length}`);
129
104
  }
130
105
  return new Buffer32(Buffer.from(str, 'hex'));
131
106
  }
132
107
 
133
- /**
134
- * Converts a number into a Buffer32 object.
135
- * @param num - The number to convert.
136
- * @returns A new Buffer32 object.
137
- */
108
+ /** Converts a number into a Buffer32 object. */
138
109
  public static fromNumber(num: number): Buffer32 {
139
110
  return new Buffer32(serializeBigInt(BigInt(num), Buffer32.SIZE));
140
111
  }
141
112
 
142
- /**
143
- * Generates a random Buffer32.
144
- * @returns A new Buffer32 object.
145
- */
113
+ /** Generates a random Buffer32. */
146
114
  public static random(): Buffer32 {
147
115
  return new Buffer32(Buffer.from(randomBytes(Buffer32.SIZE)));
148
116
  }
@@ -138,6 +138,26 @@ export function unique<T>(arr: T[]): T[] {
138
138
  return [...new Set(arr)];
139
139
  }
140
140
 
141
+ /**
142
+ * Removes duplicates from the given array using a key function. The first occurrence of each key is kept.
143
+ * @param arr - The array.
144
+ * @param keyFn - A function that returns a primitive key for each element. Elements with the same key are
145
+ * considered duplicates.
146
+ * @returns A new array.
147
+ */
148
+ export function uniqueBy<T, K extends string | number | bigint>(arr: T[], keyFn: (item: T) => K): T[] {
149
+ const seen = new Set<K>();
150
+ const result: T[] = [];
151
+ for (const item of arr) {
152
+ const key = keyFn(item);
153
+ if (!seen.has(key)) {
154
+ seen.add(key);
155
+ result.push(item);
156
+ }
157
+ }
158
+ return result;
159
+ }
160
+
141
161
  /**
142
162
  * Removes all undefined elements from the array.
143
163
  * @param arr - The array.
@@ -1,3 +1,4 @@
1
1
  export * from './array.js';
2
+ export * from './lru_map.js';
2
3
  export * from './lru_set.js';
3
4
  export * from './object.js';
@@ -0,0 +1,143 @@
1
+ /** Node in a doubly-linked list used by {@link LruMap}. */
2
+ type LruNode<K, V> = {
3
+ key: K;
4
+ value: V;
5
+ prev: LruNode<K, V> | undefined;
6
+ next: LruNode<K, V> | undefined;
7
+ };
8
+
9
+ /**
10
+ * A bounded key-value map with Least Recently Used (LRU) eviction.
11
+ * Both {@link get} and {@link set} count as an access and refresh the entry's
12
+ * recency, so entries that are actively used stay in the map longest.
13
+ *
14
+ * Uses a doubly-linked list for O(1) ordering and a Map for O(1) lookup.
15
+ * Head = least recent, tail = most recent.
16
+ */
17
+ export class LruMap<K, V> {
18
+ /** Map from key to its linked-list node for O(1) lookup. */
19
+ private readonly map = new Map<K, LruNode<K, V>>();
20
+ private head: LruNode<K, V> | undefined;
21
+ private tail: LruNode<K, V> | undefined;
22
+
23
+ constructor(private readonly maxSize: number) {
24
+ if (maxSize < 1) {
25
+ throw new Error('LruMap maxSize must be at least 1');
26
+ }
27
+ }
28
+
29
+ /** Number of entries in the map. */
30
+ get size(): number {
31
+ return this.map.size;
32
+ }
33
+
34
+ /** Returns true if the key is present, without refreshing its recency. */
35
+ has(key: K): boolean {
36
+ return this.map.has(key);
37
+ }
38
+
39
+ /**
40
+ * Returns the value for the key, or undefined if absent.
41
+ * Refreshes the entry's recency so it becomes the most recently used.
42
+ */
43
+ get(key: K): V | undefined {
44
+ const node = this.map.get(key);
45
+ if (!node) {
46
+ return undefined;
47
+ }
48
+ this.moveToTail(node);
49
+ return node.value;
50
+ }
51
+
52
+ /**
53
+ * Stores a value for the key, refreshing its recency. If the key already exists, overwrites the value.
54
+ * If the map is at capacity, evicts the least recently used entry.
55
+ */
56
+ set(key: K, value: V): void {
57
+ const existing = this.map.get(key);
58
+ if (existing) {
59
+ existing.value = value;
60
+ this.moveToTail(existing);
61
+ return;
62
+ }
63
+
64
+ if (this.map.size >= this.maxSize) {
65
+ this.evictHead();
66
+ }
67
+
68
+ const node: LruNode<K, V> = { key, value, prev: this.tail, next: undefined };
69
+ if (this.tail) {
70
+ this.tail.next = node;
71
+ } else {
72
+ this.head = node;
73
+ }
74
+ this.tail = node;
75
+ this.map.set(key, node);
76
+ }
77
+
78
+ /** Removes the entry for the key, returning true if it was present. */
79
+ delete(key: K): boolean {
80
+ const node = this.map.get(key);
81
+ if (!node) {
82
+ return false;
83
+ }
84
+ this.unlink(node);
85
+ this.map.delete(key);
86
+ return true;
87
+ }
88
+
89
+ /** Removes all entries from the map. */
90
+ clear(): void {
91
+ this.map.clear();
92
+ this.head = undefined;
93
+ this.tail = undefined;
94
+ }
95
+
96
+ /** Unlinks a node from its current position and relinks it at the tail. */
97
+ private moveToTail(node: LruNode<K, V>): void {
98
+ if (node === this.tail) {
99
+ return;
100
+ }
101
+ this.unlink(node);
102
+
103
+ node.prev = this.tail;
104
+ node.next = undefined;
105
+ if (this.tail) {
106
+ this.tail.next = node;
107
+ } else {
108
+ this.head = node;
109
+ }
110
+ this.tail = node;
111
+ }
112
+
113
+ /** Detaches a node from the linked list, fixing up its neighbours and the head/tail pointers. */
114
+ private unlink(node: LruNode<K, V>): void {
115
+ if (node.prev) {
116
+ node.prev.next = node.next;
117
+ } else {
118
+ this.head = node.next;
119
+ }
120
+ if (node.next) {
121
+ node.next.prev = node.prev;
122
+ } else {
123
+ this.tail = node.prev;
124
+ }
125
+ node.prev = undefined;
126
+ node.next = undefined;
127
+ }
128
+
129
+ /** Evicts the head (least recently used) node. */
130
+ private evictHead(): void {
131
+ const oldHead = this.head;
132
+ if (!oldHead) {
133
+ return;
134
+ }
135
+ this.head = oldHead.next;
136
+ if (this.head) {
137
+ this.head.prev = undefined;
138
+ } else {
139
+ this.tail = undefined;
140
+ }
141
+ this.map.delete(oldHead.key);
142
+ }
143
+ }
@@ -24,7 +24,7 @@ export class Committable<T> {
24
24
  * Rolls back the uncommitted value.
25
25
  */
26
26
  public rollback() {
27
- this.nextValue === undefined;
27
+ this.nextValue = undefined;
28
28
  }
29
29
 
30
30
  /**
@@ -1,17 +1,19 @@
1
1
  export type EnvVar =
2
2
  | 'REGISTRY_CONTRACT_ADDRESS'
3
3
  | 'FEE_ASSET_HANDLER_CONTRACT_ADDRESS'
4
- | 'SLASH_FACTORY_CONTRACT_ADDRESS'
5
4
  | 'ACVM_BINARY_PATH'
6
5
  | 'ACVM_WORKING_DIRECTORY'
7
6
  | 'API_KEY'
8
7
  | 'API_PREFIX'
9
- | 'ARCHIVER_MAX_LOGS'
10
8
  | 'ARCHIVER_POLLING_INTERVAL_MS'
9
+ | 'ARCHIVER_SKIP_HISTORICAL_LOGS_CHECK'
11
10
  | 'ARCHIVER_URL'
12
11
  | 'ARCHIVER_VIEM_POLLING_INTERVAL_MS'
13
12
  | 'ARCHIVER_BATCH_SIZE'
13
+ | 'ARCHIVER_ORPHAN_PRUNE_NO_PROPOSAL_TOLERANCE'
14
+ | 'ARCHIVER_SKIP_ORPHAN_PROPOSED_BLOCK_PRUNING'
14
15
  | 'AZTEC_ADMIN_PORT'
16
+ | 'AZTEC_NODE_DEBUG'
15
17
  | 'AZTEC_ADMIN_API_KEY_HASH'
16
18
  | 'AZTEC_DISABLE_ADMIN_API_KEY'
17
19
  | 'AZTEC_RESET_ADMIN_API_KEY'
@@ -25,6 +27,7 @@ export type EnvVar =
25
27
  | 'BB_IVC_CONCURRENCY'
26
28
  | 'BB_CHONK_VERIFY_MAX_BATCH'
27
29
  | 'BB_CHONK_VERIFY_BATCH_CONCURRENCY'
30
+ | 'BB_DEBUG_OUTPUT_DIR'
28
31
  | 'BOOTSTRAP_NODES'
29
32
  | 'BLOB_ARCHIVE_API_URL'
30
33
  | 'BLOB_FILE_STORE_URLS'
@@ -74,11 +77,14 @@ export type EnvVar =
74
77
  | 'DEBUG'
75
78
  | 'DEBUG_P2P_DISABLE_COLOCATION_PENALTY'
76
79
  | 'ENABLE_PROVER_NODE'
80
+ | 'USE_AUTOMINE_SEQUENCER'
81
+ | 'AUTOMINE_ENABLE_PROVE_EPOCH'
77
82
  | 'ETHEREUM_HOSTS'
78
83
  | 'ETHEREUM_DEBUG_HOSTS'
79
84
  | 'ETHEREUM_ALLOW_NO_DEBUG_HOSTS'
80
85
  | 'FEE_RECIPIENT'
81
86
  | 'FORCE_COLOR'
87
+ | 'GOVERNANCE_PROPOSER_FORCE_PAYLOAD_VOTE'
82
88
  | 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS'
83
89
  | 'KEY_STORE_DIRECTORY'
84
90
  | 'L1_CHAIN_ID'
@@ -94,14 +100,17 @@ export type EnvVar =
94
100
  | 'MNEMONIC'
95
101
  | 'NETWORK'
96
102
  | 'NETWORK_CONFIG_LOCATION'
97
- | 'NO_PXE'
103
+ | 'ALLOW_OVERRIDING_NETWORK_CONFIG'
104
+ | 'USE_AWS_LOGGING'
98
105
  | 'USE_GCLOUD_LOGGING'
99
106
  | 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
100
107
  | 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'
101
108
  | 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT'
102
109
  | 'OTEL_COLLECT_INTERVAL_MS'
110
+ | 'OTEL_BSP_MAX_QUEUE_SIZE'
103
111
  | 'OTEL_EXCLUDE_METRICS'
104
112
  | 'OTEL_INCLUDE_METRICS'
113
+ | 'OTEL_MIN_TRACE_DURATION_MS'
105
114
  | 'OTEL_EXPORT_TIMEOUT_MS'
106
115
  | 'PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
107
116
  | 'PUBLIC_OTEL_INCLUDE_METRICS'
@@ -112,7 +121,6 @@ export type EnvVar =
112
121
  | 'P2P_BATCH_TX_REQUESTER_TX_BATCH_SIZE'
113
122
  | 'P2P_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD'
114
123
  | 'P2P_BLOCK_CHECK_INTERVAL_MS'
115
- | 'P2P_SLOT_CHECK_INTERVAL_MS'
116
124
  | 'P2P_BLOCK_REQUEST_BATCH_SIZE'
117
125
  | 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK'
118
126
  | 'P2P_BOOTSTRAP_NODES_AS_FULL_PEERS'
@@ -130,12 +138,16 @@ export type EnvVar =
130
138
  | 'P2P_GOSSIPSUB_TX_INVALID_MESSAGE_DELIVERIES_DECAY'
131
139
  | 'P2P_GOSSIPSUB_TX_INVALID_MESSAGE_DELIVERIES_WEIGHT'
132
140
  | 'P2P_GOSSIPSUB_TX_TOPIC_WEIGHT'
141
+ | 'P2P_HEALTH_MIN_PEERS'
133
142
  | 'P2P_L2_QUEUE_SIZE'
143
+ | 'P2P_MAX_GOSSIP_CLOCK_DISPARITY_MS'
134
144
  | 'P2P_MAX_PEERS'
145
+ | 'P2P_PEER_BAN_DURATION_SECONDS'
135
146
  | 'P2P_PEER_CHECK_INTERVAL_MS'
136
147
  | 'P2P_PEER_FAILED_BAN_TIME_MS'
137
148
  | 'P2P_PEER_PENALTY_VALUES'
138
149
  | 'P2P_QUERY_FOR_IP'
150
+ | 'P2P_PUBLIC_IP_SERVICES'
139
151
  | 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS'
140
152
  | 'P2P_REQRESP_DIAL_TIMEOUT_MS'
141
153
  | 'P2P_REQRESP_OVERALL_REQUEST_TIMEOUT_MS'
@@ -157,7 +169,10 @@ export type EnvVar =
157
169
  | 'P2P_DROP_TX_CHANCE'
158
170
  | 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG'
159
171
  | 'P2P_MIN_TX_POOL_AGE_MS'
172
+ | 'P2P_MISSING_TX_COLLECTION_DEADLINE_SLOTS'
160
173
  | 'P2P_RPC_PRICE_BUMP_PERCENTAGE'
174
+ | 'P2P_KEEP_FINALIZED_TXS_FOR_SLOTS'
175
+ | 'P2P_TX_VALIDATION_CACHE_SIZE'
161
176
  | 'DEBUG_P2P_INSTRUMENT_MESSAGES'
162
177
  | 'PEER_ID_PRIVATE_KEY'
163
178
  | 'PEER_ID_PRIVATE_KEY_PATH'
@@ -179,6 +194,7 @@ export type EnvVar =
179
194
  | 'PROVER_FAILED_PROOF_STORE'
180
195
  | 'PROVER_NODE_FAILED_EPOCH_STORE'
181
196
  | 'PROVER_NODE_DISABLE_PROOF_PUBLISH'
197
+ | 'PROVER_NODE_PROOF_SUBMISSION_TARGET_ADDRESS'
182
198
  | 'PROVER_ID'
183
199
  | 'PROVER_NODE_POLLING_INTERVAL_MS'
184
200
  | 'PROVER_NODE_MAX_PENDING_JOBS'
@@ -197,17 +213,27 @@ export type EnvVar =
197
213
  | 'PROVER_TEST_DELAY_MS'
198
214
  | 'PROVER_TEST_DELAY_TYPE'
199
215
  | 'PROVER_TEST_VERIFICATION_DELAY_MS'
216
+ | 'PXE_AUTO_SYNC'
217
+ | 'PXE_CONCURRENT_CONTRACT_SYNC_ENABLED'
200
218
  | 'PXE_L2_BLOCK_BATCH_SIZE'
201
219
  | 'PXE_PROVER_ENABLED'
202
220
  | 'PXE_SYNC_CHAIN_TIP'
203
221
  | 'RPC_MAX_BATCH_SIZE'
204
222
  | 'RPC_MAX_BODY_SIZE'
223
+ | 'RPC_HTTP_HEADERS_TIMEOUT_MS'
224
+ | 'RPC_HTTP_KEEP_ALIVE_TIMEOUT_MS'
225
+ | 'RPC_CORS_ALLOW_ANY_ORIGIN'
226
+ | 'RPC_CORS_ALLOWED_HEADERS'
227
+ | 'RPC_CORS_ALLOWED_ORIGINS'
205
228
  | 'RPC_SIMULATE_PUBLIC_MAX_GAS_LIMIT'
206
229
  | 'RPC_SIMULATE_PUBLIC_MAX_DEBUG_LOG_MEMORY_READS'
230
+ | 'RPC_UNSEEN_BLOCK_BY_NUMBER_WAIT_MS'
231
+ | 'RPC_UNSEEN_BLOCK_BY_HASH_WAIT_MS'
232
+ | 'OFFENSE_COLLECTION_ENABLED'
207
233
  | 'SENTINEL_ENABLED'
208
234
  | 'SENTINEL_HISTORY_LENGTH_IN_EPOCHS'
209
- | 'SENTINEL_HISTORIC_PROVEN_PERFORMANCE_LENGTH_IN_EPOCHS'
210
- | 'SEQ_ENABLE_PROPOSER_PIPELINING'
235
+ | 'SENTINEL_HISTORIC_EPOCH_PERFORMANCE_LENGTH_IN_EPOCHS'
236
+ | 'SENTINEL_EPOCH_END_BUFFER_SLOTS'
211
237
  | 'SEQ_MAX_TX_PER_BLOCK'
212
238
  | 'SEQ_MAX_TX_PER_CHECKPOINT'
213
239
  | 'SEQ_MIN_TX_PER_BLOCK'
@@ -215,39 +241,46 @@ export type EnvVar =
215
241
  | 'SEQ_MAX_DA_BLOCK_GAS'
216
242
  | 'SEQ_MAX_L2_BLOCK_GAS'
217
243
  | 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER'
244
+ | 'SEQ_PER_BLOCK_DA_ALLOCATION_MULTIPLIER'
218
245
  | 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET'
219
246
  | 'SEQ_PUBLISHER_PRIVATE_KEY'
220
247
  | 'SEQ_PUBLISHER_PRIVATE_KEYS'
221
248
  | 'SEQ_PUBLISHER_ADDRESSES'
222
249
  | 'SEQ_PUBLISHER_ALLOW_INVALID_STATES'
223
250
  | 'SEQ_PUBLISHER_FORWARDER_ADDRESS'
251
+ | 'SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_TIMEOUT_MS'
252
+ | 'SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_POLL_INTERVAL_MS'
224
253
  | 'PUBLISHER_FUNDING_THRESHOLD'
225
254
  | 'PUBLISHER_FUNDING_AMOUNT'
226
255
  | 'SEQ_POLLING_INTERVAL_MS'
227
- | 'SEQ_ENFORCE_TIME_TABLE'
228
256
  | 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
229
257
  | 'SEQ_ATTESTATION_PROPAGATION_TIME'
258
+ | 'SEQ_CHECKPOINT_PROPOSAL_PREPARE_TIME'
259
+ | 'CHECKPOINT_PROPOSAL_SYNC_GRACE_SECONDS'
260
+ | 'SEQ_MIN_BLOCK_DURATION'
230
261
  | 'SEQ_BLOCK_DURATION_MS'
262
+ | 'SEQ_LAST_BLOCK_DURATION_MS'
231
263
  | 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT'
232
264
  | 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
233
265
  | 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
234
266
  | 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
235
267
  | 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT'
236
- | 'SLASH_MIN_PENALTY_PERCENTAGE'
237
- | 'SLASH_MAX_PENALTY_PERCENTAGE'
268
+ | 'SEQ_MIN_PEERS_TO_PROPOSE'
238
269
  | 'SLASH_VALIDATORS_ALWAYS'
239
270
  | 'SLASH_VALIDATORS_NEVER'
240
- | 'SLASH_PRUNE_PENALTY'
241
271
  | 'SLASH_DATA_WITHHOLDING_PENALTY'
272
+ | 'SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS'
242
273
  | 'SLASH_INACTIVITY_PENALTY'
243
274
  | 'SLASH_INACTIVITY_TARGET_PERCENTAGE'
244
275
  | 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD'
245
276
  | 'SLASH_INVALID_BLOCK_PENALTY'
277
+ | 'SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY'
246
278
  | 'SLASH_DUPLICATE_PROPOSAL_PENALTY'
247
279
  | 'SLASH_DUPLICATE_ATTESTATION_PENALTY'
248
280
  | 'SLASH_OVERRIDE_PAYLOAD'
249
281
  | 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY'
250
- | 'SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY'
282
+ | 'SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY'
283
+ | 'SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY'
251
284
  | 'SLASH_UNKNOWN_PENALTY'
252
285
  | 'SLASH_GRACE_PERIOD_L2_SLOTS'
253
286
  | 'SLASH_OFFENSE_EXPIRATION_ROUNDS'
@@ -258,28 +291,20 @@ export type EnvVar =
258
291
  | 'SYNC_SNAPSHOTS_URL'
259
292
  | 'TELEMETRY'
260
293
  | 'TEST_ACCOUNTS'
294
+ | 'TEST_PRELOAD_STANDARD_CONTRACTS'
261
295
  | 'SPONSORED_FPC'
262
296
  | 'PREFUND_ADDRESSES'
263
297
  | 'TX_COLLECTION_FAST_NODES_TIMEOUT_BEFORE_REQ_RESP_MS'
264
- | 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS'
265
- | 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS'
266
- | 'TX_COLLECTION_SLOW_REQ_RESP_TIMEOUT_MS'
267
- | 'TX_COLLECTION_RECONCILE_INTERVAL_MS'
268
- | 'TX_COLLECTION_DISABLE_SLOW_DURING_FAST_REQUESTS'
269
298
  | 'TX_COLLECTION_FAST_NODE_INTERVAL_MS'
270
299
  | 'TX_COLLECTION_FAST_MAX_PARALLEL_REQUESTS_PER_NODE'
271
300
  | 'TX_COLLECTION_NODE_RPC_MAX_BATCH_SIZE'
272
301
  | 'TX_COLLECTION_NODE_RPC_URLS'
273
302
  | 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE'
274
303
  | 'TX_COLLECTION_FILE_STORE_URLS'
275
- | 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS'
276
304
  | 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS'
277
305
  | 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT'
278
- | 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT'
279
306
  | 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS'
280
- | 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS'
281
307
  | 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS'
282
- | 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS'
283
308
  | 'TX_FILE_STORE_URL'
284
309
  | 'TX_FILE_STORE_UPLOAD_CONCURRENCY'
285
310
  | 'TX_FILE_STORE_MAX_QUEUE_SIZE'
@@ -327,7 +352,7 @@ export type EnvVar =
327
352
  | 'AZTEC_SLASH_AMOUNT_SMALL'
328
353
  | 'AZTEC_SLASH_AMOUNT_MEDIUM'
329
354
  | 'AZTEC_SLASH_AMOUNT_LARGE'
330
- | 'AZTEC_SLASHER_FLAVOR'
355
+ | 'AZTEC_SLASHER_ENABLED'
331
356
  | 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
332
357
  | 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
333
358
  | 'AZTEC_GOVERNANCE_VOTING_DURATION'
@@ -356,7 +381,7 @@ export type EnvVar =
356
381
  | 'K8S_POD_NAME'
357
382
  | 'K8S_POD_UID'
358
383
  | 'K8S_NAMESPACE_NAME'
359
- | 'ENABLE_VERSION_CHECK'
384
+ | 'ENABLE_AUTO_SHUTDOWN'
360
385
  | 'WEB3_SIGNER_URL'
361
386
  | 'SKIP_ARCHIVER_INITIAL_SYNC'
362
387
  | 'BLOB_ALLOW_EMPTY_SOURCES'
@@ -364,12 +389,15 @@ export type EnvVar =
364
389
  | 'BLOB_FILE_STORE_TIMEOUT_MS'
365
390
  | 'FISHERMAN_MODE'
366
391
  | 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
392
+ | 'MAX_BLOCKS_PER_CHECKPOINT'
367
393
  | 'LEGACY_BLS_CLI'
368
394
  | 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
395
+ | 'VALIDATOR_ALLOW_EPHEMERAL_SIGNING_PROTECTION'
369
396
  | 'VALIDATOR_HA_SIGNING_ENABLED'
370
397
  | 'VALIDATOR_HA_NODE_ID'
371
398
  | 'VALIDATOR_HA_POLLING_INTERVAL_MS'
372
399
  | 'VALIDATOR_HA_SIGNING_TIMEOUT_MS'
400
+ | 'VALIDATOR_SIGNER_CALL_TIMEOUT_MS'
373
401
  | 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS'
374
402
  | 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H'
375
403
  | 'VALIDATOR_HA_DATABASE_URL'