@aztec/foundation 0.0.1-commit.993d52e → 0.0.1-commit.9badcec54

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 (169) hide show
  1. package/dest/branded-types/buffer32_hash.d.ts +24 -0
  2. package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
  3. package/dest/branded-types/buffer32_hash.js +19 -0
  4. package/dest/branded-types/checkpoint_number.d.ts +4 -1
  5. package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
  6. package/dest/branded-types/checkpoint_number.js +3 -0
  7. package/dest/branded-types/index.d.ts +2 -1
  8. package/dest/branded-types/index.d.ts.map +1 -1
  9. package/dest/branded-types/index.js +1 -0
  10. package/dest/branded-types/slot.d.ts +4 -1
  11. package/dest/branded-types/slot.d.ts.map +1 -1
  12. package/dest/branded-types/slot.js +3 -0
  13. package/dest/buffer/buffer16.d.ts +3 -1
  14. package/dest/buffer/buffer16.d.ts.map +1 -1
  15. package/dest/buffer/buffer32.d.ts +28 -61
  16. package/dest/buffer/buffer32.d.ts.map +1 -1
  17. package/dest/buffer/buffer32.js +26 -60
  18. package/dest/buffer/index.d.ts +2 -1
  19. package/dest/buffer/index.d.ts.map +1 -1
  20. package/dest/buffer/index.js +1 -0
  21. package/dest/buffer/utils.d.ts +3 -0
  22. package/dest/buffer/utils.d.ts.map +1 -0
  23. package/dest/buffer/utils.js +7 -0
  24. package/dest/collection/array.d.ts +3 -1
  25. package/dest/collection/array.d.ts.map +1 -1
  26. package/dest/collection/array.js +15 -0
  27. package/dest/collection/index.d.ts +2 -1
  28. package/dest/collection/index.d.ts.map +1 -1
  29. package/dest/collection/index.js +1 -0
  30. package/dest/collection/lru_set.d.ts +35 -0
  31. package/dest/collection/lru_set.d.ts.map +1 -0
  32. package/dest/collection/lru_set.js +95 -0
  33. package/dest/config/env_var.d.ts +2 -2
  34. package/dest/config/env_var.d.ts.map +1 -1
  35. package/dest/config/index.d.ts +48 -30
  36. package/dest/config/index.d.ts.map +1 -1
  37. package/dest/config/index.js +21 -30
  38. package/dest/config/network_config.d.ts +13 -1
  39. package/dest/config/network_config.d.ts.map +1 -1
  40. package/dest/config/network_config.js +2 -0
  41. package/dest/config/network_name.d.ts +2 -2
  42. package/dest/config/network_name.d.ts.map +1 -1
  43. package/dest/config/network_name.js +2 -0
  44. package/dest/crypto/aes128/index.d.ts +2 -1
  45. package/dest/crypto/aes128/index.d.ts.map +1 -1
  46. package/dest/crypto/aes128/index.js +11 -2
  47. package/dest/crypto/bls/bn254_keystore.d.ts +1 -10
  48. package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
  49. package/dest/crypto/bls/bn254_keystore.js +0 -17
  50. package/dest/crypto/poseidon/index.d.ts +1 -1
  51. package/dest/crypto/poseidon/index.d.ts.map +1 -1
  52. package/dest/crypto/poseidon/index.js +40 -33
  53. package/dest/curves/bls12/field.d.ts +1 -1
  54. package/dest/curves/bls12/field.d.ts.map +1 -1
  55. package/dest/curves/bls12/field.js +0 -5
  56. package/dest/curves/bn254/field.d.ts +17 -16
  57. package/dest/curves/bn254/field.d.ts.map +1 -1
  58. package/dest/curves/bn254/field.js +18 -13
  59. package/dest/curves/grumpkin/point.d.ts +4 -4
  60. package/dest/curves/grumpkin/point.d.ts.map +1 -1
  61. package/dest/curves/grumpkin/point.js +7 -4
  62. package/dest/eth-address/index.d.ts +1 -1
  63. package/dest/eth-address/index.d.ts.map +1 -1
  64. package/dest/eth-address/index.js +0 -3
  65. package/dest/fifo/fifo_frame_reader.d.ts +41 -0
  66. package/dest/fifo/fifo_frame_reader.d.ts.map +1 -0
  67. package/dest/fifo/fifo_frame_reader.js +74 -0
  68. package/dest/fifo/index.d.ts +2 -0
  69. package/dest/fifo/index.d.ts.map +1 -0
  70. package/dest/fifo/index.js +1 -0
  71. package/dest/jest/setup.js +24 -0
  72. package/dest/json-rpc/client/fetch.d.ts +1 -1
  73. package/dest/json-rpc/client/fetch.d.ts.map +1 -1
  74. package/dest/json-rpc/client/fetch.js +4 -3
  75. package/dest/json-rpc/client/undici.d.ts +1 -1
  76. package/dest/json-rpc/client/undici.d.ts.map +1 -1
  77. package/dest/json-rpc/client/undici.js +5 -3
  78. package/dest/log/pino-logger.d.ts +1 -1
  79. package/dest/log/pino-logger.d.ts.map +1 -1
  80. package/dest/log/pino-logger.js +17 -2
  81. package/dest/queue/batch_queue.d.ts +1 -1
  82. package/dest/queue/batch_queue.d.ts.map +1 -1
  83. package/dest/queue/batch_queue.js +1 -0
  84. package/dest/retry/index.d.ts +12 -1
  85. package/dest/retry/index.d.ts.map +1 -1
  86. package/dest/retry/index.js +21 -0
  87. package/dest/schemas/api.d.ts +2 -2
  88. package/dest/schemas/api.d.ts.map +1 -1
  89. package/dest/sleep/index.d.ts +2 -1
  90. package/dest/sleep/index.d.ts.map +1 -1
  91. package/dest/sleep/index.js +10 -1
  92. package/dest/string/index.js +1 -1
  93. package/dest/timer/date.d.ts +3 -1
  94. package/dest/timer/date.d.ts.map +1 -1
  95. package/dest/timer/date.js +4 -0
  96. package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
  97. package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
  98. package/dest/transport/index.d.ts +1 -2
  99. package/dest/transport/index.d.ts.map +1 -1
  100. package/dest/transport/index.js +0 -1
  101. package/dest/trees/balanced_merkle_tree_root.d.ts +2 -3
  102. package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
  103. package/dest/trees/balanced_merkle_tree_root.js +2 -3
  104. package/dest/trees/hasher.d.ts +3 -2
  105. package/dest/trees/hasher.d.ts.map +1 -1
  106. package/dest/trees/hasher.js +5 -5
  107. package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
  108. package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
  109. package/dest/trees/indexed_merkle_tree_calculator.js +5 -1
  110. package/dest/trees/merkle_tree_calculator.d.ts +4 -2
  111. package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
  112. package/dest/trees/merkle_tree_calculator.js +1 -5
  113. package/dest/trees/sibling_path.d.ts +2 -2
  114. package/dest/trees/sibling_path.d.ts.map +1 -1
  115. package/dest/trees/sibling_path.js +1 -5
  116. package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
  117. package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
  118. package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
  119. package/package.json +3 -2
  120. package/src/branded-types/buffer32_hash.ts +42 -0
  121. package/src/branded-types/checkpoint_number.ts +5 -0
  122. package/src/branded-types/index.ts +1 -0
  123. package/src/branded-types/slot.ts +5 -0
  124. package/src/buffer/buffer16.ts +3 -0
  125. package/src/buffer/buffer32.ts +36 -65
  126. package/src/buffer/index.ts +1 -0
  127. package/src/buffer/utils.ts +8 -0
  128. package/src/collection/array.ts +14 -0
  129. package/src/collection/index.ts +1 -0
  130. package/src/collection/lru_set.ts +115 -0
  131. package/src/config/env_var.ts +22 -9
  132. package/src/config/index.ts +96 -84
  133. package/src/config/network_config.ts +2 -0
  134. package/src/config/network_name.ts +4 -1
  135. package/src/crypto/aes128/index.ts +11 -2
  136. package/src/crypto/bls/bn254_keystore.ts +0 -23
  137. package/src/crypto/poseidon/index.ts +42 -34
  138. package/src/curves/bls12/field.ts +0 -7
  139. package/src/curves/bn254/field.ts +25 -31
  140. package/src/curves/grumpkin/point.ts +6 -3
  141. package/src/eth-address/index.ts +0 -4
  142. package/src/fifo/fifo_frame_reader.ts +98 -0
  143. package/src/fifo/index.ts +1 -0
  144. package/src/jest/setup.mjs +27 -0
  145. package/src/json-rpc/client/fetch.ts +4 -3
  146. package/src/json-rpc/client/undici.ts +5 -3
  147. package/src/log/pino-logger.ts +19 -2
  148. package/src/queue/batch_queue.ts +1 -0
  149. package/src/retry/index.ts +30 -0
  150. package/src/schemas/api.ts +4 -1
  151. package/src/sleep/index.ts +10 -1
  152. package/src/string/index.ts +1 -1
  153. package/src/timer/date.ts +6 -0
  154. package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
  155. package/src/transport/index.ts +0 -1
  156. package/src/trees/balanced_merkle_tree_root.ts +2 -5
  157. package/src/trees/hasher.ts +6 -3
  158. package/src/trees/indexed_merkle_tree_calculator.ts +5 -1
  159. package/src/trees/merkle_tree_calculator.ts +4 -10
  160. package/src/trees/sibling_path.ts +1 -2
  161. package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
  162. package/dest/crypto/serialize.d.ts +0 -51
  163. package/dest/crypto/serialize.d.ts.map +0 -1
  164. package/dest/crypto/serialize.js +0 -68
  165. package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
  166. package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
  167. package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
  168. package/src/crypto/serialize.ts +0 -85
  169. package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
@@ -0,0 +1,115 @@
1
+ /** Node in a doubly-linked list used by {@link LruSet}. */
2
+ type LruNode<T> = {
3
+ value: T;
4
+ prev: LruNode<T> | undefined;
5
+ next: LruNode<T> | undefined;
6
+ };
7
+
8
+ /**
9
+ * A bounded set with Least Recently Used (LRU) eviction.
10
+ * Both {@link has} and {@link add} count as an access and refresh the entry's
11
+ * recency, so items that are actively checked stay in the set longest.
12
+ *
13
+ * Uses a doubly-linked list for O(1) ordering and a Map for O(1) lookup.
14
+ * Head = least recent, tail = most recent.
15
+ */
16
+ export class LruSet<T> {
17
+ /** Map from value to its linked-list node for O(1) lookup. */
18
+ private readonly map = new Map<T, LruNode<T>>();
19
+ private head: LruNode<T> | undefined;
20
+ private tail: LruNode<T> | undefined;
21
+
22
+ constructor(private readonly maxSize: number) {
23
+ if (maxSize < 1) {
24
+ throw new Error('LruSet maxSize must be at least 1');
25
+ }
26
+ }
27
+
28
+ /** Number of entries in the set. */
29
+ get size(): number {
30
+ return this.map.size;
31
+ }
32
+
33
+ /**
34
+ * Returns true if the item is in the set.
35
+ * Refreshes the item's recency so it becomes the most recently used.
36
+ */
37
+ has(item: T): boolean {
38
+ const node = this.map.get(item);
39
+ if (!node) {
40
+ return false;
41
+ }
42
+ this.moveToTail(node);
43
+ return true;
44
+ }
45
+
46
+ /**
47
+ * Adds an item to the set. If the item already exists, refreshes its recency.
48
+ * If the set is at capacity, evicts the least recently used item.
49
+ */
50
+ add(item: T): void {
51
+ const existing = this.map.get(item);
52
+ if (existing) {
53
+ this.moveToTail(existing);
54
+ return;
55
+ }
56
+
57
+ if (this.map.size >= this.maxSize) {
58
+ this.evictHead();
59
+ }
60
+
61
+ const node: LruNode<T> = { value: item, prev: this.tail, next: undefined };
62
+ if (this.tail) {
63
+ this.tail.next = node;
64
+ } else {
65
+ this.head = node;
66
+ }
67
+ this.tail = node;
68
+ this.map.set(item, node);
69
+ }
70
+
71
+ /** Removes all entries from the set. */
72
+ clear(): void {
73
+ this.map.clear();
74
+ this.head = undefined;
75
+ this.tail = undefined;
76
+ }
77
+
78
+ /** Unlinks a node from its current position and relinks it at the tail. */
79
+ private moveToTail(node: LruNode<T>): void {
80
+ if (node === this.tail) {
81
+ return;
82
+ }
83
+
84
+ // Unlink
85
+ if (node.prev) {
86
+ node.prev.next = node.next;
87
+ } else {
88
+ this.head = node.next;
89
+ }
90
+ if (node.next) {
91
+ node.next.prev = node.prev;
92
+ }
93
+
94
+ // Relink at tail
95
+ node.prev = this.tail;
96
+ node.next = undefined;
97
+ if (this.tail) {
98
+ this.tail.next = node;
99
+ }
100
+ this.tail = node;
101
+ }
102
+
103
+ /** Evicts the head (least recently used) node. */
104
+ private evictHead(): void {
105
+ const oldHead = this.head!;
106
+ this.map.delete(oldHead.value);
107
+
108
+ this.head = oldHead.next;
109
+ if (this.head) {
110
+ this.head.prev = undefined;
111
+ } else {
112
+ this.tail = undefined;
113
+ }
114
+ }
115
+ }
@@ -1,7 +1,6 @@
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'
@@ -12,6 +11,7 @@ export type EnvVar =
12
11
  | 'ARCHIVER_VIEM_POLLING_INTERVAL_MS'
13
12
  | 'ARCHIVER_BATCH_SIZE'
14
13
  | 'AZTEC_ADMIN_PORT'
14
+ | 'AZTEC_NODE_DEBUG'
15
15
  | 'AZTEC_ADMIN_API_KEY_HASH'
16
16
  | 'AZTEC_DISABLE_ADMIN_API_KEY'
17
17
  | 'AZTEC_RESET_ADMIN_API_KEY'
@@ -23,6 +23,8 @@ export type EnvVar =
23
23
  | 'BB_WORKING_DIRECTORY'
24
24
  | 'BB_NUM_IVC_VERIFIERS'
25
25
  | 'BB_IVC_CONCURRENCY'
26
+ | 'BB_CHONK_VERIFY_MAX_BATCH'
27
+ | 'BB_CHONK_VERIFY_BATCH_CONCURRENCY'
26
28
  | 'BOOTSTRAP_NODES'
27
29
  | 'BLOB_ARCHIVE_API_URL'
28
30
  | 'BLOB_FILE_STORE_URLS'
@@ -62,6 +64,7 @@ export type EnvVar =
62
64
  | 'BLOB_SINK_MAP_SIZE_KB'
63
65
  | 'P2P_STORE_MAP_SIZE_KB'
64
66
  | 'PROVER_BROKER_STORE_MAP_SIZE_KB'
67
+ | 'SIGNING_PROTECTION_MAP_SIZE_KB'
65
68
  | 'WS_DB_MAP_SIZE_KB'
66
69
  | 'ARCHIVE_TREE_MAP_SIZE_KB'
67
70
  | 'NULLIFIER_TREE_MAP_SIZE_KB'
@@ -80,8 +83,10 @@ export type EnvVar =
80
83
  | 'KEY_STORE_DIRECTORY'
81
84
  | 'L1_CHAIN_ID'
82
85
  | 'L1_CONSENSUS_HOST_URLS'
86
+ | 'ETHEREUM_HTTP_TIMEOUT_MS'
83
87
  | 'L1_CONSENSUS_HOST_API_KEYS'
84
88
  | 'L1_CONSENSUS_HOST_API_KEY_HEADERS'
89
+ | 'L1_TX_FAILED_STORE'
85
90
  | 'LOG_JSON'
86
91
  | 'LOG_MULTILINE'
87
92
  | 'LOG_NO_COLOR_PER_ACTOR'
@@ -89,7 +94,6 @@ export type EnvVar =
89
94
  | 'MNEMONIC'
90
95
  | 'NETWORK'
91
96
  | 'NETWORK_CONFIG_LOCATION'
92
- | 'NO_PXE'
93
97
  | 'USE_GCLOUD_LOGGING'
94
98
  | 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
95
99
  | 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'
@@ -128,6 +132,7 @@ export type EnvVar =
128
132
  | 'P2P_L2_QUEUE_SIZE'
129
133
  | 'P2P_MAX_PEERS'
130
134
  | 'P2P_PEER_CHECK_INTERVAL_MS'
135
+ | 'P2P_PEER_FAILED_BAN_TIME_MS'
131
136
  | 'P2P_PEER_PENALTY_VALUES'
132
137
  | 'P2P_QUERY_FOR_IP'
133
138
  | 'P2P_REQRESP_INDIVIDUAL_REQUEST_TIMEOUT_MS'
@@ -148,7 +153,6 @@ export type EnvVar =
148
153
  | 'P2P_PREFERRED_PEERS'
149
154
  | 'P2P_MAX_PENDING_TX_COUNT'
150
155
  | 'P2P_SEEN_MSG_CACHE_SIZE'
151
- | 'P2P_DROP_TX'
152
156
  | 'P2P_DROP_TX_CHANCE'
153
157
  | 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG'
154
158
  | 'P2P_MIN_TX_POOL_AGE_MS'
@@ -168,6 +172,7 @@ export type EnvVar =
168
172
  | 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR'
169
173
  | 'PROVER_BROKER_DEBUG_REPLAY_ENABLED'
170
174
  | 'PROVER_CANCEL_JOBS_ON_STOP'
175
+ | 'PROVER_ENQUEUE_CONCURRENCY'
171
176
  | 'PROVER_COORDINATION_NODE_URLS'
172
177
  | 'PROVER_PROOF_STORE'
173
178
  | 'PROVER_FAILED_PROOF_STORE'
@@ -201,29 +206,33 @@ export type EnvVar =
201
206
  | 'SENTINEL_ENABLED'
202
207
  | 'SENTINEL_HISTORY_LENGTH_IN_EPOCHS'
203
208
  | 'SENTINEL_HISTORIC_PROVEN_PERFORMANCE_LENGTH_IN_EPOCHS'
204
- | 'SEQ_MAX_BLOCK_SIZE_IN_BYTES'
209
+ | 'SEQ_ENABLE_PROPOSER_PIPELINING'
205
210
  | 'SEQ_MAX_TX_PER_BLOCK'
211
+ | 'SEQ_MAX_TX_PER_CHECKPOINT'
206
212
  | 'SEQ_MIN_TX_PER_BLOCK'
207
213
  | 'SEQ_PUBLISH_TXS_WITH_PROPOSALS'
208
214
  | 'SEQ_MAX_DA_BLOCK_GAS'
209
215
  | 'SEQ_MAX_L2_BLOCK_GAS'
216
+ | 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER'
217
+ | 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET'
210
218
  | 'SEQ_PUBLISHER_PRIVATE_KEY'
211
219
  | 'SEQ_PUBLISHER_PRIVATE_KEYS'
212
220
  | 'SEQ_PUBLISHER_ADDRESSES'
213
221
  | 'SEQ_PUBLISHER_ALLOW_INVALID_STATES'
214
222
  | 'SEQ_PUBLISHER_FORWARDER_ADDRESS'
223
+ | 'PUBLISHER_FUNDING_THRESHOLD'
224
+ | 'PUBLISHER_FUNDING_AMOUNT'
215
225
  | 'SEQ_POLLING_INTERVAL_MS'
216
226
  | 'SEQ_ENFORCE_TIME_TABLE'
217
227
  | 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
218
228
  | 'SEQ_ATTESTATION_PROPAGATION_TIME'
219
229
  | 'SEQ_BLOCK_DURATION_MS'
230
+ | 'SEQ_LAST_BLOCK_DURATION_MS'
220
231
  | 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT'
221
232
  | 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
222
233
  | 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
223
234
  | 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
224
235
  | 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT'
225
- | 'SLASH_MIN_PENALTY_PERCENTAGE'
226
- | 'SLASH_MAX_PENALTY_PERCENTAGE'
227
236
  | 'SLASH_VALIDATORS_ALWAYS'
228
237
  | 'SLASH_VALIDATORS_NEVER'
229
238
  | 'SLASH_PRUNE_PENALTY'
@@ -278,9 +287,12 @@ export type EnvVar =
278
287
  | 'TRANSACTIONS_DISABLED'
279
288
  | 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS'
280
289
  | 'VALIDATOR_DISABLED'
290
+ | 'VALIDATOR_MAX_DA_BLOCK_GAS'
291
+ | 'VALIDATOR_MAX_L2_BLOCK_GAS'
292
+ | 'VALIDATOR_MAX_TX_PER_BLOCK'
293
+ | 'VALIDATOR_MAX_TX_PER_CHECKPOINT'
281
294
  | 'VALIDATOR_PRIVATE_KEYS'
282
295
  | 'VALIDATOR_PRIVATE_KEY'
283
- | 'VALIDATOR_REEXECUTE'
284
296
  | 'VALIDATOR_ADDRESSES'
285
297
  | 'ROLLUP_VERSION'
286
298
  | 'WS_BLOCK_CHECK_INTERVAL_MS'
@@ -313,7 +325,7 @@ export type EnvVar =
313
325
  | 'AZTEC_SLASH_AMOUNT_SMALL'
314
326
  | 'AZTEC_SLASH_AMOUNT_MEDIUM'
315
327
  | 'AZTEC_SLASH_AMOUNT_LARGE'
316
- | 'AZTEC_SLASHER_FLAVOR'
328
+ | 'AZTEC_SLASHER_ENABLED'
317
329
  | 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
318
330
  | 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
319
331
  | 'AZTEC_GOVERNANCE_VOTING_DURATION'
@@ -343,10 +355,11 @@ export type EnvVar =
343
355
  | 'K8S_POD_UID'
344
356
  | 'K8S_NAMESPACE_NAME'
345
357
  | 'ENABLE_VERSION_CHECK'
346
- | 'VALIDATOR_REEXECUTE_DEADLINE_MS'
347
358
  | 'WEB3_SIGNER_URL'
348
359
  | 'SKIP_ARCHIVER_INITIAL_SYNC'
349
360
  | 'BLOB_ALLOW_EMPTY_SOURCES'
361
+ | 'BLOB_PREFER_FILESTORES'
362
+ | 'BLOB_FILE_STORE_TIMEOUT_MS'
350
363
  | 'FISHERMAN_MODE'
351
364
  | 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
352
365
  | 'LEGACY_BLS_CLI'
@@ -10,14 +10,15 @@ export type { EnvVar, NetworkNames };
10
10
  export type { NetworkConfig, NetworkConfigMap } from './network_config.js';
11
11
  export { NetworkConfigMapSchema, NetworkConfigSchema } from './network_config.js';
12
12
 
13
- export interface ConfigMapping {
13
+ export interface ConfigMapping<T> {
14
14
  env?: EnvVar;
15
- parseEnv?: (val: string) => any;
16
- defaultValue?: any;
15
+ /** Parse an env-var string into `T`. Throws on invalid input. */
16
+ parseEnv?: (val: string) => T;
17
+ defaultValue?: T;
17
18
  printDefault?: (val: any) => string;
18
19
  description: string;
19
20
  isBoolean?: boolean;
20
- nested?: Record<string, ConfigMapping>;
21
+ nested?: Record<string, ConfigMapping<any>>;
21
22
  fallback?: EnvVar[];
22
23
  /**
23
24
  * List of deprecated env vars that are still supported but will log a warning.
@@ -30,7 +31,9 @@ export function isBooleanConfigValue<T>(obj: T, key: keyof T): boolean {
30
31
  return typeof obj[key] === 'boolean';
31
32
  }
32
33
 
33
- export type ConfigMappingsType<T> = Record<keyof T, ConfigMapping>;
34
+ export type ConfigMappingsType<T> = {
35
+ [K in keyof T]-?: ConfigMapping<Required<T>[K]>;
36
+ };
34
37
 
35
38
  /**
36
39
  * Shared utility function to get a value from environment variables with fallback support.
@@ -66,8 +69,8 @@ export function getValueFromEnvWithFallback<T>(
66
69
  }
67
70
  }
68
71
 
69
- // Parse the value if needed
70
- if (value !== undefined) {
72
+ // Parse the value if needed. Empty strings are treated as "not set".
73
+ if (value !== undefined && value !== '') {
71
74
  return parseFunc ? parseFunc(value) : (value as unknown as T);
72
75
  }
73
76
 
@@ -84,7 +87,11 @@ export function getConfigFromMappings<T>(configMappings: ConfigMappingsType<T>):
84
87
  (config as any)[key] = getConfigFromMappings(nested);
85
88
  } else {
86
89
  // Use the shared utility function
87
- (config as any)[key] = getValueFromEnvWithFallback(env, parseEnv, defaultValue, fallback);
90
+ try {
91
+ (config as any)[key] = getValueFromEnvWithFallback(env, parseEnv, defaultValue, fallback);
92
+ } catch (e: any) {
93
+ throw new Error(`Failed to parse config '${key}' (env: ${env ?? 'none'}): ${e.message}`);
94
+ }
88
95
 
89
96
  // Check for deprecated env vars and warn if logger is set
90
97
  if (deprecatedFallback?.length) {
@@ -123,7 +130,7 @@ export function omitConfigMappings<T, K extends keyof T>(
123
130
  * @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
124
131
  * @returns Object with parseEnv and default values for a numerical config value
125
132
  */
126
- export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
133
+ export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
127
134
  return {
128
135
  parseEnv: (val: string) => safeParseNumber(val, defaultVal),
129
136
  defaultValue: defaultVal,
@@ -138,7 +145,7 @@ export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'par
138
145
  export function floatConfigHelper(
139
146
  defaultVal: number,
140
147
  validationFn?: (val: number) => void,
141
- ): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
148
+ ): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
142
149
  return {
143
150
  parseEnv: (val: string): number => {
144
151
  const parsed = safeParseFloat(val, defaultVal);
@@ -152,7 +159,7 @@ export function floatConfigHelper(
152
159
  /**
153
160
  * Parses an environment variable to a 0-1 percentage value
154
161
  */
155
- export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
162
+ export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping<number>, 'parseEnv' | 'defaultValue'> {
156
163
  return {
157
164
  parseEnv: (val: string): number => {
158
165
  const parsed = safeParseFloat(val, defaultVal);
@@ -171,12 +178,13 @@ export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping,
171
178
  * @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
172
179
  * @returns Object with parseEnv and default values for a numerical config value
173
180
  */
174
- export function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
181
+ export function bigintConfigHelper(defaultVal: bigint): Pick<ConfigMapping<bigint>, 'parseEnv' | 'defaultValue'>;
182
+ export function bigintConfigHelper(): Pick<ConfigMapping<bigint | undefined>, 'parseEnv' | 'defaultValue'>;
183
+ export function bigintConfigHelper(
184
+ defaultVal?: bigint,
185
+ ): Pick<ConfigMapping<bigint | undefined>, 'parseEnv' | 'defaultValue'> {
175
186
  return {
176
187
  parseEnv: (val: string) => {
177
- if (val === '') {
178
- return defaultVal;
179
- }
180
188
  // Handle scientific notation (e.g. "1e+23", "2E23") which BigInt() doesn't accept directly.
181
189
  // We parse it losslessly using bigint arithmetic instead of going through float64.
182
190
  if (/[eE]/.test(val)) {
@@ -200,32 +208,37 @@ export function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'pa
200
208
 
201
209
  /**
202
210
  * Generates parseEnv for an optional numerical config value.
211
+ * Empty strings are already handled by getValueFromEnvWithFallback.
203
212
  */
204
- export function optionalNumberConfigHelper(): Pick<ConfigMapping, 'parseEnv'> {
213
+ export function optionalNumberConfigHelper(): Pick<ConfigMapping<number>, 'parseEnv'> {
205
214
  return {
206
- parseEnv: (val: string | undefined) => {
207
- if (val !== undefined && val.length > 0) {
208
- const parsedValue = parseInt(val);
209
- return Number.isSafeInteger(parsedValue) ? parsedValue : undefined;
215
+ parseEnv: (val: string) => {
216
+ const parsedValue = parseInt(val);
217
+ if (!Number.isSafeInteger(parsedValue)) {
218
+ throw new Error(`Invalid number: ${val}`);
210
219
  }
211
- return undefined;
220
+ return parsedValue;
212
221
  },
213
222
  };
214
223
  }
215
224
 
216
225
  /** Generates parseEnv for an enum-like config value. */
226
+ export function enumConfigHelper<T extends string>(
227
+ values: T[],
228
+ defaultValue: NoInfer<T>,
229
+ ): Pick<ConfigMapping<T>, 'parseEnv' | 'defaultValue'>;
230
+ export function enumConfigHelper<T extends string>(
231
+ values: T[],
232
+ ): Pick<ConfigMapping<T | undefined>, 'parseEnv' | 'defaultValue'>;
217
233
  export function enumConfigHelper<T extends string>(
218
234
  values: T[],
219
235
  defaultValue?: NoInfer<T>,
220
- ): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
236
+ ): Pick<ConfigMapping<T | undefined>, 'parseEnv' | 'defaultValue'> {
221
237
  return {
222
238
  parseEnv: (val: string) => {
223
- const sanitizedVal = (val ?? '').trim().toLowerCase();
224
- if (values.includes(sanitizedVal as T)) {
225
- return sanitizedVal as T;
226
- }
227
- if (!val && defaultValue) {
228
- return defaultValue;
239
+ const sanitizedVal = val.trim().toLowerCase();
240
+ if (values.some(v => v.toLowerCase() === sanitizedVal)) {
241
+ return values.find(v => v.toLowerCase() === sanitizedVal)!;
229
242
  }
230
243
  throw new Error(`Invalid config value '${val}' (must be one of ${values.join(', ')})`);
231
244
  },
@@ -240,7 +253,9 @@ export function enumConfigHelper<T extends string>(
240
253
  */
241
254
  export function booleanConfigHelper(
242
255
  defaultVal = false,
243
- ): Required<Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & { parseVal: (val: string) => boolean }> {
256
+ ): Required<
257
+ Pick<ConfigMapping<boolean>, 'parseEnv' | 'defaultValue' | 'isBoolean'> & { parseVal: (val: string) => boolean }
258
+ > {
244
259
  const parse = (val: string | boolean) => (typeof val === 'boolean' ? val : parseBooleanEnv(val));
245
260
  return {
246
261
  parseEnv: parse,
@@ -250,91 +265,88 @@ export function booleanConfigHelper(
250
265
  };
251
266
  }
252
267
 
253
- export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T): Required<
254
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
255
- parseVal: (val: string) => SecretValue<T>;
256
- }
257
- > {
268
+ export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T): Pick<
269
+ ConfigMapping<SecretValue<T>>,
270
+ 'parseEnv' | 'defaultValue'
271
+ > & {
272
+ parseVal: (val: string) => SecretValue<T>;
273
+ } {
258
274
  const wrap = (val: string) => new SecretValue(parse(val));
259
275
  return {
260
276
  parseEnv: wrap,
261
277
  parseVal: wrap,
262
278
  defaultValue: new SecretValue(parse(undefined)),
263
- isBoolean: true,
264
279
  };
265
280
  }
266
281
 
267
282
  export { parseBooleanEnv } from './parse-env.js';
268
283
 
269
- export function secretStringConfigHelper(): Required<
270
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
271
- parseVal: (val: string) => SecretValue<string | undefined>;
272
- }
273
- >;
274
- export function secretStringConfigHelper(defaultValue: string): Required<
275
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
276
- parseVal: (val: string) => SecretValue<string>;
277
- }
278
- >;
279
- export function secretStringConfigHelper(defaultValue?: string): Required<
280
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
281
- parseVal: (val: string) => SecretValue<string | typeof defaultValue>;
282
- }
283
- > {
284
+ export function secretStringConfigHelper(): {
285
+ parseEnv: (val: string) => SecretValue<string>;
286
+ parseVal: (val: string) => SecretValue<string>;
287
+ defaultValue: undefined;
288
+ };
289
+ export function secretStringConfigHelper(defaultValue: string): {
290
+ parseEnv: (val: string) => SecretValue<string>;
291
+ parseVal: (val: string) => SecretValue<string>;
292
+ defaultValue: SecretValue<string>;
293
+ };
294
+ export function secretStringConfigHelper(defaultValue?: string): {
295
+ parseEnv: (val: string) => SecretValue<string>;
296
+ parseVal: (val: string) => SecretValue<string>;
297
+ defaultValue: SecretValue<string> | undefined;
298
+ } {
284
299
  const parse = (val: string) => new SecretValue(val);
285
300
  return {
286
301
  parseEnv: parse,
287
302
  parseVal: parse,
288
303
  defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
289
- isBoolean: true,
290
304
  };
291
305
  }
292
306
 
293
- export function secretFrConfigHelper(): Required<
294
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
295
- parseVal: (val: string) => SecretValue<Fr | undefined>;
296
- }
297
- >;
298
- export function secretFrConfigHelper(defaultValue: Fr): Required<
299
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
300
- parseVal: (val: string) => SecretValue<Fr>;
301
- }
302
- >;
303
- export function secretFrConfigHelper(defaultValue?: Fr): Required<
304
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
305
- parseVal: (val: string) => SecretValue<Fr | typeof defaultValue>;
306
- }
307
- > {
307
+ export function secretFrConfigHelper(): {
308
+ parseEnv: (val: string) => SecretValue<Fr>;
309
+ parseVal: (val: string) => SecretValue<Fr>;
310
+ defaultValue: undefined;
311
+ };
312
+ export function secretFrConfigHelper(defaultValue: Fr): {
313
+ parseEnv: (val: string) => SecretValue<Fr>;
314
+ parseVal: (val: string) => SecretValue<Fr>;
315
+ defaultValue: SecretValue<Fr>;
316
+ };
317
+ export function secretFrConfigHelper(defaultValue?: Fr): {
318
+ parseEnv: (val: string) => SecretValue<Fr>;
319
+ parseVal: (val: string) => SecretValue<Fr>;
320
+ defaultValue: SecretValue<Fr> | undefined;
321
+ } {
308
322
  const parse = (val: string) => new SecretValue(Fr.fromHexString(val));
309
323
  return {
310
324
  parseEnv: parse,
311
325
  parseVal: parse,
312
326
  defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
313
- isBoolean: true,
314
327
  };
315
328
  }
316
329
 
317
- export function secretFqConfigHelper(defaultValue: Fq): Required<
318
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
319
- parseVal: (val: string) => SecretValue<Fq>;
320
- }
321
- >;
322
- export function secretFqConfigHelper(): Required<
323
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
324
- parseVal: (val: string) => SecretValue<Fq | undefined>;
325
- }
326
- >;
327
- export function secretFqConfigHelper(defaultValue?: Fq): Required<
328
- Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
329
- parseVal: (val: string) => SecretValue<Fq | typeof defaultValue>;
330
- }
331
- > {
330
+ export function secretFqConfigHelper(): {
331
+ parseEnv: (val: string) => SecretValue<Fq>;
332
+ parseVal: (val: string) => SecretValue<Fq>;
333
+ defaultValue: undefined;
334
+ };
335
+ export function secretFqConfigHelper(defaultValue: Fq): {
336
+ parseEnv: (val: string) => SecretValue<Fq>;
337
+ parseVal: (val: string) => SecretValue<Fq>;
338
+ defaultValue: SecretValue<Fq>;
339
+ };
340
+ export function secretFqConfigHelper(defaultValue?: Fq): {
341
+ parseEnv: (val: string) => SecretValue<Fq>;
342
+ parseVal: (val: string) => SecretValue<Fq>;
343
+ defaultValue: SecretValue<Fq> | undefined;
344
+ } {
332
345
  const parse = (val: string) => new SecretValue(Fq.fromHexString(val));
333
346
  return {
334
347
  parseEnv: parse,
335
348
  parseVal: parse,
336
- defaultValue: typeof defaultValue !== 'undefined' ? new SecretValue(defaultValue) : undefined,
337
- isBoolean: true,
349
+ defaultValue: defaultValue !== undefined ? new SecretValue(defaultValue) : undefined,
338
350
  };
339
351
  }
340
352
 
@@ -5,10 +5,12 @@ export const NetworkConfigSchema = z
5
5
  bootnodes: z.array(z.string()),
6
6
  snapshots: z.array(z.string()),
7
7
  blobFileStoreUrls: z.array(z.string()).optional(),
8
+ txCollectionFileStoreUrls: z.array(z.string()).optional(),
8
9
  registryAddress: z.string(),
9
10
  feeAssetHandlerAddress: z.string().optional(),
10
11
  l1ChainId: z.number(),
11
12
  blockDurationMs: z.number().positive().optional(),
13
+ txPublicSetupAllowListExtend: z.string().optional(),
12
14
  nodeVersion: z.string().optional(),
13
15
  })
14
16
  .passthrough(); // Allow additional unknown fields to pass through
@@ -5,7 +5,8 @@ export type NetworkNames =
5
5
  | 'testnet'
6
6
  | 'mainnet'
7
7
  | 'next-net'
8
- | 'devnet';
8
+ | 'devnet'
9
+ | `v${number}-devnet-${number}`;
9
10
 
10
11
  export function getActiveNetworkName(name?: string): NetworkNames {
11
12
  const network = name || process.env.NETWORK;
@@ -23,6 +24,8 @@ export function getActiveNetworkName(name?: string): NetworkNames {
23
24
  return 'next-net';
24
25
  } else if (network === 'devnet') {
25
26
  return 'devnet';
27
+ } else if (/^v\d+-devnet-\d+$/.test(network)) {
28
+ return network as `v${number}-devnet-${number}`;
26
29
  }
27
30
  throw new Error(`Unknown network: ${network}`);
28
31
  }
@@ -59,10 +59,19 @@ export class Aes128 {
59
59
  * @param iv - AES initialization vector.
60
60
  * @param key - Key to decrypt with.
61
61
  * @returns Decrypted data.
62
+ * @throws If the decrypted buffer has invalid PKCS#7 padding.
62
63
  */
63
64
  public async decryptBufferCBC(data: Uint8Array, iv: Uint8Array, key: Uint8Array) {
64
65
  const paddedBuffer = await this.decryptBufferCBCKeepPadding(data, iv, key);
65
- const paddingToRemove = paddedBuffer[paddedBuffer.length - 1];
66
- return paddedBuffer.subarray(0, paddedBuffer.length - paddingToRemove);
66
+ const paddingLen = paddedBuffer[paddedBuffer.length - 1];
67
+ if (paddingLen === 0 || paddingLen > 16) {
68
+ throw new Error(`Invalid PKCS#7 padding length: ${paddingLen}`);
69
+ }
70
+ for (let i = paddedBuffer.length - paddingLen; i < paddedBuffer.length; i++) {
71
+ if (paddedBuffer[i] !== paddingLen) {
72
+ throw new Error('Invalid PKCS#7 padding');
73
+ }
74
+ }
75
+ return paddedBuffer.subarray(0, paddedBuffer.length - paddingLen);
67
76
  }
68
77
  }
@@ -262,26 +262,3 @@ export function decryptBn254KeystoreFromObject(keystore: Bn254Keystore, password
262
262
  throw new Bn254KeystoreError(`Failed to decrypt keystore: ${String(error)}`, error as Error);
263
263
  }
264
264
  }
265
-
266
- /**
267
- * Validates that a decrypted private key matches the public key in the keystore.
268
- *
269
- * @param privateKeyHex - Decrypted private key (0x-prefixed)
270
- * @param expectedPubkey - Expected public key from keystore
271
- * @param computePublicKey - Function to compute public key from private key
272
- * @returns true if keys match, false otherwise
273
- */
274
- export function verifyBn254Keypair(
275
- privateKeyHex: string,
276
- expectedPubkey: string,
277
- computePublicKey: (privateKey: string) => string,
278
- ): boolean {
279
- try {
280
- const computedPubkey = computePublicKey(privateKeyHex);
281
- const normalizedExpected = expectedPubkey.toLowerCase().replace(/^0x/i, '');
282
- const normalizedComputed = computedPubkey.toLowerCase().replace(/^0x/i, '');
283
- return normalizedExpected === normalizedComputed;
284
- } catch {
285
- return false;
286
- }
287
- }