@aztec/foundation 0.0.1-commit.9ef841308 → 0.0.1-commit.a4600f49

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 (237) 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 -1
  23. package/dest/buffer/buffer16.d.ts.map +1 -1
  24. package/dest/buffer/buffer32.d.ts +28 -61
  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/aes128/index.d.ts +2 -1
  50. package/dest/crypto/aes128/index.d.ts.map +1 -1
  51. package/dest/crypto/aes128/index.js +11 -2
  52. package/dest/crypto/bls/bn254_keystore.d.ts +10 -177
  53. package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
  54. package/dest/crypto/bls/bn254_keystore.js +22 -34
  55. package/dest/crypto/keys/index.d.ts +3 -2
  56. package/dest/crypto/keys/index.d.ts.map +1 -1
  57. package/dest/crypto/keys/index.js +30 -6
  58. package/dest/crypto/schnorr/index.d.ts +8 -7
  59. package/dest/crypto/schnorr/index.d.ts.map +1 -1
  60. package/dest/crypto/schnorr/index.js +6 -6
  61. package/dest/crypto/schnorr/signature.d.ts +9 -29
  62. package/dest/crypto/schnorr/signature.d.ts.map +1 -1
  63. package/dest/crypto/schnorr/signature.js +20 -36
  64. package/dest/curves/bls12/field.d.ts +3 -3
  65. package/dest/curves/bls12/field.d.ts.map +1 -1
  66. package/dest/curves/bls12/field.js +0 -5
  67. package/dest/curves/bls12/point.d.ts +2 -2
  68. package/dest/curves/bls12/point.d.ts.map +1 -1
  69. package/dest/curves/bn254/field.d.ts +23 -19
  70. package/dest/curves/bn254/field.d.ts.map +1 -1
  71. package/dest/curves/bn254/field.js +23 -17
  72. package/dest/curves/grumpkin/point.d.ts +14 -28
  73. package/dest/curves/grumpkin/point.d.ts.map +1 -1
  74. package/dest/curves/grumpkin/point.js +29 -43
  75. package/dest/eth-address/index.d.ts +2 -2
  76. package/dest/eth-address/index.d.ts.map +1 -1
  77. package/dest/eth-address/index.js +0 -3
  78. package/dest/eth-signature/eth_signature.d.ts +2 -2
  79. package/dest/eth-signature/eth_signature.d.ts.map +1 -1
  80. package/dest/fifo/fifo_frame_reader.d.ts +2 -2
  81. package/dest/fifo/fifo_frame_reader.d.ts.map +1 -1
  82. package/dest/fifo/fifo_frame_reader.js +21 -4
  83. package/dest/fifo_set/fifo_set.d.ts +15 -0
  84. package/dest/fifo_set/fifo_set.d.ts.map +1 -0
  85. package/dest/fifo_set/fifo_set.js +39 -0
  86. package/dest/fifo_set/index.d.ts +2 -0
  87. package/dest/fifo_set/index.d.ts.map +1 -0
  88. package/dest/fifo_set/index.js +1 -0
  89. package/dest/json-rpc/client/fetch.d.ts +1 -1
  90. package/dest/json-rpc/client/fetch.d.ts.map +1 -1
  91. package/dest/json-rpc/client/fetch.js +4 -3
  92. package/dest/json-rpc/client/safe_json_rpc_client.d.ts +1 -1
  93. package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
  94. package/dest/json-rpc/client/safe_json_rpc_client.js +2 -2
  95. package/dest/json-rpc/client/undici.d.ts +1 -1
  96. package/dest/json-rpc/client/undici.d.ts.map +1 -1
  97. package/dest/json-rpc/client/undici.js +5 -3
  98. package/dest/json-rpc/fixtures/test_state.d.ts +4 -8
  99. package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
  100. package/dest/json-rpc/fixtures/test_state.js +57 -17
  101. package/dest/json-rpc/server/safe_json_rpc_server.d.ts +8 -3
  102. package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
  103. package/dest/json-rpc/server/safe_json_rpc_server.js +27 -13
  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 +17 -2
  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 +5 -4
  111. package/dest/promise/running-promise.d.ts.map +1 -1
  112. package/dest/promise/running-promise.js +7 -3
  113. package/dest/queue/batch_queue.d.ts +1 -1
  114. package/dest/queue/batch_queue.d.ts.map +1 -1
  115. package/dest/queue/batch_queue.js +1 -0
  116. package/dest/retry/index.d.ts +31 -3
  117. package/dest/retry/index.d.ts.map +1 -1
  118. package/dest/retry/index.js +44 -2
  119. package/dest/schemas/api.d.ts +11 -9
  120. package/dest/schemas/api.d.ts.map +1 -1
  121. package/dest/schemas/api.js +7 -1
  122. package/dest/schemas/parse.d.ts +4 -4
  123. package/dest/schemas/parse.d.ts.map +1 -1
  124. package/dest/schemas/parse.js +6 -5
  125. package/dest/schemas/schemas.d.ts +15 -15
  126. package/dest/schemas/types.d.ts +3 -3
  127. package/dest/schemas/types.d.ts.map +1 -1
  128. package/dest/schemas/utils.d.ts +7 -11
  129. package/dest/schemas/utils.d.ts.map +1 -1
  130. package/dest/schemas/utils.js +2 -18
  131. package/dest/serialize/buffer_sink.d.ts +134 -0
  132. package/dest/serialize/buffer_sink.d.ts.map +1 -0
  133. package/dest/serialize/buffer_sink.js +297 -0
  134. package/dest/serialize/index.d.ts +2 -1
  135. package/dest/serialize/index.d.ts.map +1 -1
  136. package/dest/serialize/index.js +1 -0
  137. package/dest/string/index.js +1 -1
  138. package/dest/testing/files/index.d.ts +2 -3
  139. package/dest/testing/files/index.d.ts.map +1 -1
  140. package/dest/testing/files/index.js +1 -2
  141. package/dest/timer/index.d.ts +2 -2
  142. package/dest/timer/index.d.ts.map +1 -1
  143. package/dest/timer/index.js +1 -1
  144. package/dest/timer/timeout.d.ts +3 -1
  145. package/dest/timer/timeout.d.ts.map +1 -1
  146. package/dest/timer/timeout.js +26 -0
  147. package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
  148. package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
  149. package/dest/transport/index.d.ts +1 -2
  150. package/dest/transport/index.d.ts.map +1 -1
  151. package/dest/transport/index.js +0 -1
  152. package/dest/trees/balanced_merkle_tree_root.d.ts +2 -3
  153. package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
  154. package/dest/trees/balanced_merkle_tree_root.js +2 -3
  155. package/dest/trees/hasher.d.ts +3 -2
  156. package/dest/trees/hasher.d.ts.map +1 -1
  157. package/dest/trees/hasher.js +5 -5
  158. package/dest/trees/membership_witness.d.ts +2 -6
  159. package/dest/trees/membership_witness.d.ts.map +1 -1
  160. package/dest/trees/membership_witness.js +0 -9
  161. package/dest/trees/merkle_tree_calculator.d.ts +4 -2
  162. package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
  163. package/dest/trees/merkle_tree_calculator.js +1 -5
  164. package/dest/trees/sibling_path.d.ts +5 -4
  165. package/dest/trees/sibling_path.d.ts.map +1 -1
  166. package/dest/trees/sibling_path.js +10 -8
  167. package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
  168. package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
  169. package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
  170. package/dest/types/index.d.ts +23 -1
  171. package/dest/types/index.d.ts.map +1 -1
  172. package/dest/types/index.js +15 -0
  173. package/package.json +5 -4
  174. package/src/bigint-buffer/index.ts +6 -1
  175. package/src/branded-types/block_number.ts +20 -2
  176. package/src/branded-types/buffer32_hash.ts +38 -0
  177. package/src/branded-types/checkpoint_number.ts +16 -1
  178. package/src/branded-types/epoch.ts +1 -1
  179. package/src/branded-types/index.ts +1 -0
  180. package/src/branded-types/index_within_checkpoint.ts +1 -1
  181. package/src/branded-types/slot.ts +1 -1
  182. package/src/buffer/buffer16.ts +3 -0
  183. package/src/buffer/buffer32.ts +39 -68
  184. package/src/collection/array.ts +20 -0
  185. package/src/collection/index.ts +1 -0
  186. package/src/collection/lru_map.ts +143 -0
  187. package/src/committable/committable.ts +1 -1
  188. package/src/config/env_var.ts +42 -22
  189. package/src/config/index.ts +143 -122
  190. package/src/config/network_name.ts +2 -5
  191. package/src/config/secret_value.ts +1 -1
  192. package/src/crypto/aes128/index.ts +11 -2
  193. package/src/crypto/bls/bn254_keystore.ts +33 -43
  194. package/src/crypto/keys/index.ts +20 -4
  195. package/src/crypto/schnorr/index.ts +9 -8
  196. package/src/crypto/schnorr/signature.ts +17 -46
  197. package/src/curves/bls12/field.ts +0 -7
  198. package/src/curves/bn254/field.ts +35 -34
  199. package/src/curves/grumpkin/point.ts +23 -40
  200. package/src/eth-address/index.ts +0 -4
  201. package/src/fifo/fifo_frame_reader.ts +17 -2
  202. package/src/fifo_set/fifo_set.ts +52 -0
  203. package/src/fifo_set/index.ts +1 -0
  204. package/src/json-rpc/client/fetch.ts +4 -3
  205. package/src/json-rpc/client/safe_json_rpc_client.ts +2 -2
  206. package/src/json-rpc/client/undici.ts +5 -3
  207. package/src/json-rpc/fixtures/test_state.ts +10 -10
  208. package/src/json-rpc/server/safe_json_rpc_server.ts +31 -13
  209. package/src/log/pino-logger.ts +19 -2
  210. package/src/noir/noir_package_config.ts +32 -20
  211. package/src/promise/running-promise.ts +8 -5
  212. package/src/queue/batch_queue.ts +1 -0
  213. package/src/retry/index.ts +66 -4
  214. package/src/schemas/api.ts +21 -24
  215. package/src/schemas/parse.ts +9 -6
  216. package/src/schemas/schemas.ts +4 -4
  217. package/src/schemas/types.ts +2 -2
  218. package/src/schemas/utils.ts +4 -38
  219. package/src/serialize/buffer_sink.ts +350 -0
  220. package/src/serialize/index.ts +1 -0
  221. package/src/string/index.ts +1 -1
  222. package/src/testing/files/index.ts +1 -2
  223. package/src/timer/index.ts +1 -1
  224. package/src/timer/timeout.ts +31 -0
  225. package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
  226. package/src/transport/index.ts +0 -1
  227. package/src/trees/balanced_merkle_tree_root.ts +2 -5
  228. package/src/trees/hasher.ts +6 -3
  229. package/src/trees/membership_witness.ts +0 -8
  230. package/src/trees/merkle_tree_calculator.ts +4 -10
  231. package/src/trees/sibling_path.ts +11 -6
  232. package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
  233. package/src/types/index.ts +47 -0
  234. package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
  235. package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
  236. package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
  237. package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
@@ -89,5 +89,5 @@ SlotNumber.ZERO = SlotNumber(0);
89
89
  */
90
90
  export const SlotNumberSchema = z
91
91
  .union([z.number(), z.bigint(), z.string()])
92
- .pipe(z.coerce.number().int().min(0))
92
+ .pipe(z.coerce.number<string | number | bigint>().int().min(0))
93
93
  .transform(value => SlotNumber(value));
@@ -10,6 +10,9 @@ import { bufferToHex } from '../string/index.js';
10
10
  * A class representing a 16 byte Buffer.
11
11
  */
12
12
  export class Buffer16 {
13
+ /** Branding for nominal typing. */
14
+ declare private readonly _branding: 'Buffer16';
15
+
13
16
  /**
14
17
  * The size of the hash in bytes.
15
18
  */
@@ -7,69 +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
- /**
14
- * The size of the hash in bytes.
15
- */
14
+ export abstract class BaseBuffer32 {
15
+ /** The size of the buffer in bytes. */
16
16
  public static SIZE = 32;
17
17
 
18
- /**
19
- * Buffer32 with value zero.
20
- */
21
- public static ZERO = new Buffer32(Buffer.alloc(Buffer32.SIZE));
22
-
23
18
  constructor(
24
- /**
25
- * The buffer containing the hash.
26
- */
19
+ /** The buffer containing the data. */
27
20
  public buffer: Buffer,
28
21
  ) {
29
- if (buffer.length !== Buffer32.SIZE) {
30
- 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}`);
31
24
  }
32
25
  }
33
26
 
34
- /**
35
- * Returns the raw buffer of the hash.
36
- * @returns The buffer containing the hash.
37
- */
27
+ /** Returns the raw buffer. */
38
28
  public toBuffer() {
39
29
  return this.buffer;
40
30
  }
41
31
 
42
- /**
43
- * Creates a Buffer32 from a buffer.
44
- * @param buffer - The buffer to create from.
45
- * @returns A new Buffer32 object.
46
- */
47
- public static fromBuffer(buffer: Buffer | BufferReader) {
48
- const reader = BufferReader.asReader(buffer);
49
- return new Buffer32(reader.readBytes(Buffer32.SIZE));
50
- }
51
-
52
- /**
53
- * Checks if this hash and another hash are equal.
54
- * @param hash - A hash to compare with.
55
- * @returns True if the hashes are equal, false otherwise.
56
- */
57
- public equals(hash: Buffer32): boolean {
32
+ /** Checks if this and another buffer are equal. */
33
+ public equals(hash: BaseBuffer32): boolean {
58
34
  return this.buffer.equals(hash.buffer);
59
35
  }
60
36
 
61
- /**
62
- * Returns true if this hash is zero.
63
- * @returns True if this hash is zero.
64
- */
37
+ /** Returns true if all bytes are zero. */
65
38
  public isZero(): boolean {
66
39
  return this.buffer.equals(Buffer.alloc(32, 0));
67
40
  }
68
41
 
69
- /**
70
- * Convert this hash to a hex string.
71
- * @returns The hex string.
72
- */
42
+ /** Convert to a hex string. */
73
43
  public toString() {
74
44
  return bufferToHex(this.buffer);
75
45
  }
@@ -82,16 +52,27 @@ export class Buffer32 {
82
52
  return this.toString();
83
53
  }
84
54
 
85
- /**
86
- * Convert this hash to a big int.
87
- * @returns The big int.
88
- */
55
+ /** Convert to a big int. */
89
56
  public toBigInt() {
90
- return deserializeBigInt(this.buffer, 0, Buffer32.SIZE).elem;
57
+ return deserializeBigInt(this.buffer, 0, BaseBuffer32.SIZE).elem;
91
58
  }
92
- /**
93
- * Creates a Buffer32 from a bigint.
94
- */
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. */
95
76
  public static fromBigInt(hash: bigint) {
96
77
  return new Buffer32(serializeBigInt(hash, Buffer32.SIZE));
97
78
  }
@@ -101,8 +82,7 @@ export class Buffer32 {
101
82
  }
102
83
 
103
84
  /**
104
- * Converts this hash from a buffer of 28 bytes.
105
- * Verifies the input is 28 bytes.
85
+ * Converts from a buffer of 28 bytes.
106
86
  * @param buffer - The 28 byte buffer to construct from.
107
87
  * @returns A Buffer32 created from the input buffer with 4 bytes 0 padding at the front.
108
88
  */
@@ -110,36 +90,27 @@ export class Buffer32 {
110
90
  if (buffer.length != 28) {
111
91
  throw new Error(`Expected Buffer32 input buffer to be 28 bytes`);
112
92
  }
113
- const padded = Buffer.concat([Buffer.alloc(this.SIZE - 28), buffer]);
93
+ const padded = Buffer.concat([Buffer.alloc(Buffer32.SIZE - 28), buffer]);
114
94
  return new Buffer32(padded);
115
95
  }
116
96
 
117
- /**
118
- * Converts a string into a Buffer32 object.
119
- */
97
+ /** Converts a string into a Buffer32 object. */
120
98
  public static fromString(str: string): Buffer32 {
121
99
  if (str.startsWith('0x')) {
122
100
  str = str.slice(2);
123
101
  }
124
- if (str.length !== this.SIZE * 2) {
125
- 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}`);
126
104
  }
127
105
  return new Buffer32(Buffer.from(str, 'hex'));
128
106
  }
129
107
 
130
- /**
131
- * Converts a number into a Buffer32 object.
132
- * @param num - The number to convert.
133
- * @returns A new Buffer32 object.
134
- */
108
+ /** Converts a number into a Buffer32 object. */
135
109
  public static fromNumber(num: number): Buffer32 {
136
110
  return new Buffer32(serializeBigInt(BigInt(num), Buffer32.SIZE));
137
111
  }
138
112
 
139
- /**
140
- * Generates a random Buffer32.
141
- * @returns A new Buffer32 object.
142
- */
113
+ /** Generates a random Buffer32. */
143
114
  public static random(): Buffer32 {
144
115
  return new Buffer32(Buffer.from(randomBytes(Buffer32.SIZE)));
145
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,6 +77,8 @@ 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'
@@ -94,14 +99,16 @@ export type EnvVar =
94
99
  | 'MNEMONIC'
95
100
  | 'NETWORK'
96
101
  | 'NETWORK_CONFIG_LOCATION'
97
- | 'NO_PXE'
102
+ | 'ALLOW_OVERRIDING_NETWORK_CONFIG'
98
103
  | 'USE_GCLOUD_LOGGING'
99
104
  | 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
100
105
  | 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'
101
106
  | 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT'
102
107
  | 'OTEL_COLLECT_INTERVAL_MS'
108
+ | 'OTEL_BSP_MAX_QUEUE_SIZE'
103
109
  | 'OTEL_EXCLUDE_METRICS'
104
110
  | 'OTEL_INCLUDE_METRICS'
111
+ | 'OTEL_MIN_TRACE_DURATION_MS'
105
112
  | 'OTEL_EXPORT_TIMEOUT_MS'
106
113
  | 'PUBLIC_OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
107
114
  | 'PUBLIC_OTEL_INCLUDE_METRICS'
@@ -112,7 +119,6 @@ export type EnvVar =
112
119
  | 'P2P_BATCH_TX_REQUESTER_TX_BATCH_SIZE'
113
120
  | 'P2P_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD'
114
121
  | 'P2P_BLOCK_CHECK_INTERVAL_MS'
115
- | 'P2P_SLOT_CHECK_INTERVAL_MS'
116
122
  | 'P2P_BLOCK_REQUEST_BATCH_SIZE'
117
123
  | 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK'
118
124
  | 'P2P_BOOTSTRAP_NODES_AS_FULL_PEERS'
@@ -131,11 +137,14 @@ export type EnvVar =
131
137
  | 'P2P_GOSSIPSUB_TX_INVALID_MESSAGE_DELIVERIES_WEIGHT'
132
138
  | 'P2P_GOSSIPSUB_TX_TOPIC_WEIGHT'
133
139
  | 'P2P_L2_QUEUE_SIZE'
140
+ | 'P2P_MAX_GOSSIP_CLOCK_DISPARITY_MS'
134
141
  | 'P2P_MAX_PEERS'
142
+ | 'P2P_PEER_BAN_DURATION_SECONDS'
135
143
  | 'P2P_PEER_CHECK_INTERVAL_MS'
136
144
  | 'P2P_PEER_FAILED_BAN_TIME_MS'
137
145
  | 'P2P_PEER_PENALTY_VALUES'
138
146
  | 'P2P_QUERY_FOR_IP'
147
+ | 'P2P_PUBLIC_IP_SERVICES'
139
148
  | 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS'
140
149
  | 'P2P_REQRESP_DIAL_TIMEOUT_MS'
141
150
  | 'P2P_REQRESP_OVERALL_REQUEST_TIMEOUT_MS'
@@ -157,7 +166,10 @@ export type EnvVar =
157
166
  | 'P2P_DROP_TX_CHANCE'
158
167
  | 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG'
159
168
  | 'P2P_MIN_TX_POOL_AGE_MS'
169
+ | 'P2P_MISSING_TX_COLLECTION_DEADLINE_SLOTS'
160
170
  | 'P2P_RPC_PRICE_BUMP_PERCENTAGE'
171
+ | 'P2P_KEEP_FINALIZED_TXS_FOR_SLOTS'
172
+ | 'P2P_TX_VALIDATION_CACHE_SIZE'
161
173
  | 'DEBUG_P2P_INSTRUMENT_MESSAGES'
162
174
  | 'PEER_ID_PRIVATE_KEY'
163
175
  | 'PEER_ID_PRIVATE_KEY_PATH'
@@ -179,6 +191,7 @@ export type EnvVar =
179
191
  | 'PROVER_FAILED_PROOF_STORE'
180
192
  | 'PROVER_NODE_FAILED_EPOCH_STORE'
181
193
  | 'PROVER_NODE_DISABLE_PROOF_PUBLISH'
194
+ | 'PROVER_NODE_PROOF_SUBMISSION_TARGET_ADDRESS'
182
195
  | 'PROVER_ID'
183
196
  | 'PROVER_NODE_POLLING_INTERVAL_MS'
184
197
  | 'PROVER_NODE_MAX_PENDING_JOBS'
@@ -197,6 +210,7 @@ export type EnvVar =
197
210
  | 'PROVER_TEST_DELAY_MS'
198
211
  | 'PROVER_TEST_DELAY_TYPE'
199
212
  | 'PROVER_TEST_VERIFICATION_DELAY_MS'
213
+ | 'PXE_AUTO_SYNC'
200
214
  | 'PXE_L2_BLOCK_BATCH_SIZE'
201
215
  | 'PXE_PROVER_ENABLED'
202
216
  | 'PXE_SYNC_CHAIN_TIP'
@@ -204,10 +218,11 @@ export type EnvVar =
204
218
  | 'RPC_MAX_BODY_SIZE'
205
219
  | 'RPC_SIMULATE_PUBLIC_MAX_GAS_LIMIT'
206
220
  | 'RPC_SIMULATE_PUBLIC_MAX_DEBUG_LOG_MEMORY_READS'
221
+ | 'OFFENSE_COLLECTION_ENABLED'
207
222
  | 'SENTINEL_ENABLED'
208
223
  | 'SENTINEL_HISTORY_LENGTH_IN_EPOCHS'
209
- | 'SENTINEL_HISTORIC_PROVEN_PERFORMANCE_LENGTH_IN_EPOCHS'
210
- | 'SEQ_ENABLE_PROPOSER_PIPELINING'
224
+ | 'SENTINEL_HISTORIC_EPOCH_PERFORMANCE_LENGTH_IN_EPOCHS'
225
+ | 'SENTINEL_EPOCH_END_BUFFER_SLOTS'
211
226
  | 'SEQ_MAX_TX_PER_BLOCK'
212
227
  | 'SEQ_MAX_TX_PER_CHECKPOINT'
213
228
  | 'SEQ_MIN_TX_PER_BLOCK'
@@ -215,39 +230,45 @@ export type EnvVar =
215
230
  | 'SEQ_MAX_DA_BLOCK_GAS'
216
231
  | 'SEQ_MAX_L2_BLOCK_GAS'
217
232
  | 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER'
233
+ | 'SEQ_PER_BLOCK_DA_ALLOCATION_MULTIPLIER'
218
234
  | 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET'
219
235
  | 'SEQ_PUBLISHER_PRIVATE_KEY'
220
236
  | 'SEQ_PUBLISHER_PRIVATE_KEYS'
221
237
  | 'SEQ_PUBLISHER_ADDRESSES'
222
238
  | 'SEQ_PUBLISHER_ALLOW_INVALID_STATES'
223
239
  | 'SEQ_PUBLISHER_FORWARDER_ADDRESS'
240
+ | 'SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_TIMEOUT_MS'
241
+ | 'SEQ_PUBLISHER_PREVIOUS_L1_BLOCK_WAIT_POLL_INTERVAL_MS'
224
242
  | 'PUBLISHER_FUNDING_THRESHOLD'
225
243
  | 'PUBLISHER_FUNDING_AMOUNT'
226
244
  | 'SEQ_POLLING_INTERVAL_MS'
227
- | 'SEQ_ENFORCE_TIME_TABLE'
228
245
  | 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
229
246
  | 'SEQ_ATTESTATION_PROPAGATION_TIME'
247
+ | 'SEQ_CHECKPOINT_PROPOSAL_PREPARE_TIME'
248
+ | 'CHECKPOINT_PROPOSAL_SYNC_GRACE_SECONDS'
249
+ | 'SEQ_MIN_BLOCK_DURATION'
230
250
  | 'SEQ_BLOCK_DURATION_MS'
251
+ | 'SEQ_LAST_BLOCK_DURATION_MS'
231
252
  | 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT'
232
253
  | 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
233
254
  | 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
234
255
  | 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
235
256
  | 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT'
236
- | 'SLASH_MIN_PENALTY_PERCENTAGE'
237
- | 'SLASH_MAX_PENALTY_PERCENTAGE'
238
257
  | 'SLASH_VALIDATORS_ALWAYS'
239
258
  | 'SLASH_VALIDATORS_NEVER'
240
- | 'SLASH_PRUNE_PENALTY'
241
259
  | 'SLASH_DATA_WITHHOLDING_PENALTY'
260
+ | 'SLASH_DATA_WITHHOLDING_TOLERANCE_SLOTS'
242
261
  | 'SLASH_INACTIVITY_PENALTY'
243
262
  | 'SLASH_INACTIVITY_TARGET_PERCENTAGE'
244
263
  | 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD'
245
264
  | 'SLASH_INVALID_BLOCK_PENALTY'
265
+ | 'SLASH_INVALID_CHECKPOINT_PROPOSAL_PENALTY'
246
266
  | 'SLASH_DUPLICATE_PROPOSAL_PENALTY'
247
267
  | 'SLASH_DUPLICATE_ATTESTATION_PENALTY'
248
268
  | 'SLASH_OVERRIDE_PAYLOAD'
249
269
  | 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY'
250
- | 'SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY'
270
+ | 'SLASH_PROPOSE_DESCENDANT_OF_CHECKPOINT_WITH_INVALID_ATTESTATIONS_PENALTY'
271
+ | 'SLASH_ATTEST_INVALID_CHECKPOINT_PROPOSAL_PENALTY'
251
272
  | 'SLASH_UNKNOWN_PENALTY'
252
273
  | 'SLASH_GRACE_PERIOD_L2_SLOTS'
253
274
  | 'SLASH_OFFENSE_EXPIRATION_ROUNDS'
@@ -261,25 +282,16 @@ export type EnvVar =
261
282
  | 'SPONSORED_FPC'
262
283
  | 'PREFUND_ADDRESSES'
263
284
  | '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
285
  | 'TX_COLLECTION_FAST_NODE_INTERVAL_MS'
270
286
  | 'TX_COLLECTION_FAST_MAX_PARALLEL_REQUESTS_PER_NODE'
271
287
  | 'TX_COLLECTION_NODE_RPC_MAX_BATCH_SIZE'
272
288
  | 'TX_COLLECTION_NODE_RPC_URLS'
273
289
  | 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE'
274
290
  | 'TX_COLLECTION_FILE_STORE_URLS'
275
- | 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS'
276
291
  | 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS'
277
292
  | 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT'
278
- | 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT'
279
293
  | 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS'
280
- | 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS'
281
294
  | 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS'
282
- | 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS'
283
295
  | 'TX_FILE_STORE_URL'
284
296
  | 'TX_FILE_STORE_UPLOAD_CONCURRENCY'
285
297
  | 'TX_FILE_STORE_MAX_QUEUE_SIZE'
@@ -327,11 +339,16 @@ export type EnvVar =
327
339
  | 'AZTEC_SLASH_AMOUNT_SMALL'
328
340
  | 'AZTEC_SLASH_AMOUNT_MEDIUM'
329
341
  | 'AZTEC_SLASH_AMOUNT_LARGE'
330
- | 'AZTEC_SLASHER_FLAVOR'
342
+ | 'AZTEC_SLASHER_ENABLED'
331
343
  | 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
332
344
  | 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
333
345
  | 'AZTEC_GOVERNANCE_VOTING_DURATION'
334
346
  | 'AZTEC_EXIT_DELAY_SECONDS'
347
+ | 'AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE'
348
+ | 'AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE'
349
+ | 'AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN'
350
+ | 'AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT'
351
+ | 'AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE'
335
352
  | 'L1_GAS_LIMIT_BUFFER_PERCENTAGE'
336
353
  | 'L1_GAS_PRICE_MAX'
337
354
  | 'L1_FEE_PER_GAS_GWEI_MAX'
@@ -356,7 +373,7 @@ export type EnvVar =
356
373
  | 'K8S_POD_NAME'
357
374
  | 'K8S_POD_UID'
358
375
  | 'K8S_NAMESPACE_NAME'
359
- | 'ENABLE_VERSION_CHECK'
376
+ | 'ENABLE_AUTO_SHUTDOWN'
360
377
  | 'WEB3_SIGNER_URL'
361
378
  | 'SKIP_ARCHIVER_INITIAL_SYNC'
362
379
  | 'BLOB_ALLOW_EMPTY_SOURCES'
@@ -364,12 +381,15 @@ export type EnvVar =
364
381
  | 'BLOB_FILE_STORE_TIMEOUT_MS'
365
382
  | 'FISHERMAN_MODE'
366
383
  | 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
384
+ | 'MAX_BLOCKS_PER_CHECKPOINT'
367
385
  | 'LEGACY_BLS_CLI'
368
386
  | 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
387
+ | 'VALIDATOR_ALLOW_EPHEMERAL_SIGNING_PROTECTION'
369
388
  | 'VALIDATOR_HA_SIGNING_ENABLED'
370
389
  | 'VALIDATOR_HA_NODE_ID'
371
390
  | 'VALIDATOR_HA_POLLING_INTERVAL_MS'
372
391
  | 'VALIDATOR_HA_SIGNING_TIMEOUT_MS'
392
+ | 'VALIDATOR_SIGNER_CALL_TIMEOUT_MS'
373
393
  | 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS'
374
394
  | 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H'
375
395
  | 'VALIDATOR_HA_DATABASE_URL'