@aztec/foundation 3.0.3 → 4.0.0-devnet.1-patch.0
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.
- package/dest/array/index.d.ts +2 -1
- package/dest/array/index.d.ts.map +1 -1
- package/dest/array/index.js +1 -0
- package/dest/array/sorted_array.d.ts +15 -0
- package/dest/array/sorted_array.d.ts.map +1 -0
- package/dest/array/sorted_array.js +109 -0
- package/dest/branded-types/block_number.d.ts +4 -1
- package/dest/branded-types/block_number.d.ts.map +1 -1
- package/dest/branded-types/block_number.js +3 -0
- package/dest/branded-types/checkpoint_number.d.ts +10 -2
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +17 -8
- package/dest/branded-types/index.d.ts +3 -2
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +2 -1
- package/dest/branded-types/index_within_checkpoint.d.ts +42 -0
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -0
- package/dest/branded-types/index_within_checkpoint.js +59 -0
- package/dest/buffer/buffer16.d.ts +4 -1
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer16.js +3 -1
- package/dest/buffer/buffer32.d.ts +4 -1
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +3 -1
- package/dest/collection/array.d.ts +12 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +51 -0
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +6 -3
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +16 -7
- package/dest/config/network_config.d.ts +13 -1
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +3 -1
- package/dest/config/parse-env.d.ts +3 -0
- package/dest/config/parse-env.d.ts.map +1 -0
- package/dest/config/parse-env.js +7 -0
- package/dest/config/secret_value.js +3 -1
- package/dest/crypto/ecdsa/signature.d.ts +10 -1
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.d.ts +1 -2
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +0 -9
- package/dest/crypto/random/randomness_singleton.d.ts +4 -3
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
- package/dest/crypto/random/randomness_singleton.js +5 -5
- package/dest/crypto/sync/poseidon/index.d.ts +1 -2
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +0 -8
- package/dest/curves/bls12/field.js +6 -3
- package/dest/curves/bls12/point.d.ts +10 -1
- package/dest/curves/bls12/point.d.ts.map +1 -1
- package/dest/curves/bls12/point.js +3 -1
- package/dest/curves/bn254/field.d.ts +6 -7
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +30 -43
- package/dest/curves/grumpkin/point.d.ts +11 -2
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/error/index.d.ts +4 -4
- package/dest/error/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +4 -2
- package/dest/eth-signature/eth_signature.d.ts +4 -1
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/iterator/filter.d.ts +3 -0
- package/dest/iterator/filter.d.ts.map +1 -0
- package/dest/iterator/filter.js +7 -0
- package/dest/iterator/index.d.ts +2 -0
- package/dest/iterator/index.d.ts.map +1 -0
- package/dest/iterator/index.js +1 -0
- package/dest/jest/setup.js +4 -1
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +21 -4
- package/dest/json-rpc/fixtures/class_a.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/class_b.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +1 -1
- package/dest/log/libp2p_logger.d.ts +5 -2
- package/dest/log/libp2p_logger.d.ts.map +1 -1
- package/dest/log/libp2p_logger.js +14 -4
- package/dest/log/log-filters.d.ts +17 -4
- package/dest/log/log-filters.d.ts.map +1 -1
- package/dest/log/log-filters.js +26 -12
- package/dest/log/pino-logger-server.d.ts +9 -0
- package/dest/log/pino-logger-server.d.ts.map +1 -0
- package/dest/log/pino-logger-server.js +18 -0
- package/dest/log/pino-logger.d.ts +37 -8
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +118 -29
- package/dest/queue/base_memory_queue.d.ts +2 -2
- package/dest/queue/base_memory_queue.d.ts.map +1 -1
- package/dest/queue/semaphore.d.ts +5 -1
- package/dest/queue/semaphore.d.ts.map +1 -1
- package/dest/retry/index.d.ts +11 -1
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +11 -0
- package/dest/schemas/schemas.d.ts +3 -1
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +5 -0
- package/dest/schemas/types.d.ts +31 -1
- package/dest/schemas/types.d.ts.map +1 -1
- package/dest/schemas/types.js +25 -1
- package/dest/serialize/buffer_reader.d.ts +7 -4
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +13 -4
- package/dest/sleep/index.d.ts +3 -1
- package/dest/sleep/index.d.ts.map +1 -1
- package/dest/sleep/index.js +4 -0
- package/dest/timer/date.d.ts +24 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +32 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts +17 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{balanced_merkle_tree.js → balanced_merkle_tree_root.js} +2 -17
- package/dest/trees/hasher.d.ts +3 -1
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +10 -5
- package/dest/trees/index.d.ts +4 -4
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +3 -3
- package/dest/trees/membership_witness.d.ts +11 -1
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/membership_witness.js +9 -0
- package/dest/trees/merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +2 -2
- package/dest/trees/sibling_path.d.ts +2 -1
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +2 -2
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.js +1 -5
- package/dest/trees/{unbalanced_merkle_tree.d.ts → unbalanced_merkle_tree_root.d.ts} +3 -5
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{unbalanced_merkle_tree.js → unbalanced_merkle_tree_root.js} +11 -49
- package/dest/trees/unbalanced_tree_store.d.ts +5 -1
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
- package/dest/trees/unbalanced_tree_store.js +49 -1
- package/dest/types/index.d.ts +6 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +6 -0
- package/package.json +26 -4
- package/src/array/index.ts +1 -0
- package/src/array/sorted_array.ts +138 -0
- package/src/branded-types/block_number.ts +5 -0
- package/src/branded-types/checkpoint_number.ts +22 -7
- package/src/branded-types/index.ts +2 -1
- package/src/branded-types/index_within_checkpoint.ts +88 -0
- package/src/collection/array.ts +52 -0
- package/src/config/env_var.ts +46 -11
- package/src/config/index.ts +19 -4
- package/src/config/network_config.ts +2 -0
- package/src/config/parse-env.ts +4 -0
- package/src/crypto/poseidon/index.ts +0 -10
- package/src/crypto/random/randomness_singleton.ts +6 -4
- package/src/crypto/sync/poseidon/index.ts +0 -9
- package/src/curves/bn254/field.ts +28 -43
- package/src/eth-address/index.ts +1 -1
- package/src/iterator/filter.ts +11 -0
- package/src/iterator/index.ts +1 -0
- package/src/jest/setup.mjs +4 -1
- package/src/json-rpc/client/undici.ts +21 -3
- package/src/json-rpc/server/safe_json_rpc_server.ts +1 -1
- package/src/log/libp2p_logger.ts +12 -5
- package/src/log/log-filters.ts +29 -11
- package/src/log/pino-logger-server.ts +25 -0
- package/src/log/pino-logger.ts +140 -39
- package/src/queue/base_memory_queue.ts +1 -1
- package/src/queue/semaphore.ts +5 -0
- package/src/retry/index.ts +18 -0
- package/src/schemas/schemas.ts +8 -0
- package/src/schemas/types.ts +33 -0
- package/src/serialize/buffer_reader.ts +21 -9
- package/src/sleep/index.ts +6 -0
- package/src/timer/date.ts +46 -0
- package/src/trees/{balanced_merkle_tree.ts → balanced_merkle_tree_root.ts} +2 -18
- package/src/trees/hasher.ts +9 -0
- package/src/trees/index.ts +3 -3
- package/src/trees/membership_witness.ts +8 -0
- package/src/trees/merkle_tree_calculator.ts +2 -2
- package/src/trees/sibling_path.ts +2 -2
- package/src/trees/unbalanced_merkle_tree_calculator.ts +1 -12
- package/src/trees/{unbalanced_merkle_tree.ts → unbalanced_merkle_tree_root.ts} +17 -61
- package/src/trees/unbalanced_tree_store.ts +57 -2
- package/src/types/index.ts +11 -1
- package/dest/json-rpc/server/telemetry.d.ts +0 -2
- package/dest/json-rpc/server/telemetry.d.ts.map +0 -1
- package/dest/json-rpc/server/telemetry.js +0 -0
- package/dest/trees/balanced_merkle_tree.d.ts +0 -22
- package/dest/trees/balanced_merkle_tree.d.ts.map +0 -1
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +0 -1
- package/src/json-rpc/server/telemetry.ts +0 -0
package/src/config/env_var.ts
CHANGED
|
@@ -21,12 +21,13 @@ export type EnvVar =
|
|
|
21
21
|
| 'BB_NUM_IVC_VERIFIERS'
|
|
22
22
|
| 'BB_IVC_CONCURRENCY'
|
|
23
23
|
| 'BOOTSTRAP_NODES'
|
|
24
|
-
| '
|
|
25
|
-
| '
|
|
26
|
-
| '
|
|
24
|
+
| 'BLOB_ARCHIVE_API_URL'
|
|
25
|
+
| 'BLOB_FILE_STORE_URLS'
|
|
26
|
+
| 'BLOB_FILE_STORE_UPLOAD_URL'
|
|
27
|
+
| 'BLOB_HEALTHCHECK_UPLOAD_INTERVAL_MINUTES'
|
|
27
28
|
| 'BOT_DA_GAS_LIMIT'
|
|
28
29
|
| 'BOT_FEE_PAYMENT_METHOD'
|
|
29
|
-
| '
|
|
30
|
+
| 'BOT_MIN_FEE_PADDING'
|
|
30
31
|
| 'BOT_FLUSH_SETUP_TRANSACTIONS'
|
|
31
32
|
| 'BOT_FOLLOW_CHAIN'
|
|
32
33
|
| 'BOT_L2_GAS_LIMIT'
|
|
@@ -76,6 +77,7 @@ export type EnvVar =
|
|
|
76
77
|
| 'L1_CONSENSUS_HOST_API_KEY_HEADERS'
|
|
77
78
|
| 'LOG_JSON'
|
|
78
79
|
| 'LOG_MULTILINE'
|
|
80
|
+
| 'LOG_NO_COLOR_PER_ACTOR'
|
|
79
81
|
| 'LOG_LEVEL'
|
|
80
82
|
| 'MNEMONIC'
|
|
81
83
|
| 'NETWORK'
|
|
@@ -93,7 +95,12 @@ export type EnvVar =
|
|
|
93
95
|
| 'PUBLIC_OTEL_INCLUDE_METRICS'
|
|
94
96
|
| 'PUBLIC_OTEL_COLLECT_FROM'
|
|
95
97
|
| 'PUBLIC_OTEL_OPT_OUT'
|
|
98
|
+
| 'P2P_BATCH_TX_REQUESTER_SMART_PARALLEL_WORKER_COUNT'
|
|
99
|
+
| 'P2P_BATCH_TX_REQUESTER_DUMB_PARALLEL_WORKER_COUNT'
|
|
100
|
+
| 'P2P_BATCH_TX_REQUESTER_TX_BATCH_SIZE'
|
|
101
|
+
| 'P2P_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD'
|
|
96
102
|
| 'P2P_BLOCK_CHECK_INTERVAL_MS'
|
|
103
|
+
| 'P2P_SLOT_CHECK_INTERVAL_MS'
|
|
97
104
|
| 'P2P_BLOCK_REQUEST_BATCH_SIZE'
|
|
98
105
|
| 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK'
|
|
99
106
|
| 'P2P_BOOTSTRAP_NODES_AS_FULL_PEERS'
|
|
@@ -132,8 +139,7 @@ export type EnvVar =
|
|
|
132
139
|
| 'P2P_TRUSTED_PEERS'
|
|
133
140
|
| 'P2P_PRIVATE_PEERS'
|
|
134
141
|
| 'P2P_PREFERRED_PEERS'
|
|
135
|
-
| '
|
|
136
|
-
| 'P2P_TX_POOL_OVERFLOW_FACTOR'
|
|
142
|
+
| 'P2P_MAX_PENDING_TX_COUNT'
|
|
137
143
|
| 'P2P_SEEN_MSG_CACHE_SIZE'
|
|
138
144
|
| 'P2P_DROP_TX'
|
|
139
145
|
| 'P2P_DROP_TX_CHANCE'
|
|
@@ -151,7 +157,10 @@ export type EnvVar =
|
|
|
151
157
|
| 'PROVER_BROKER_BATCH_INTERVAL_MS'
|
|
152
158
|
| 'PROVER_BROKER_BATCH_SIZE'
|
|
153
159
|
| 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR'
|
|
160
|
+
| 'PROVER_BROKER_DEBUG_REPLAY_ENABLED'
|
|
161
|
+
| 'PROVER_CANCEL_JOBS_ON_STOP'
|
|
154
162
|
| 'PROVER_COORDINATION_NODE_URLS'
|
|
163
|
+
| 'PROVER_PROOF_STORE'
|
|
155
164
|
| 'PROVER_FAILED_PROOF_STORE'
|
|
156
165
|
| 'PROVER_NODE_FAILED_EPOCH_STORE'
|
|
157
166
|
| 'PROVER_NODE_DISABLE_PROOF_PUBLISH'
|
|
@@ -175,6 +184,7 @@ export type EnvVar =
|
|
|
175
184
|
| 'PROVER_TEST_VERIFICATION_DELAY_MS'
|
|
176
185
|
| 'PXE_L2_BLOCK_BATCH_SIZE'
|
|
177
186
|
| 'PXE_PROVER_ENABLED'
|
|
187
|
+
| 'PXE_SYNC_CHAIN_TIP'
|
|
178
188
|
| 'RPC_MAX_BATCH_SIZE'
|
|
179
189
|
| 'RPC_MAX_BODY_SIZE'
|
|
180
190
|
| 'RPC_SIMULATE_PUBLIC_MAX_GAS_LIMIT'
|
|
@@ -193,10 +203,12 @@ export type EnvVar =
|
|
|
193
203
|
| 'SEQ_PUBLISHER_ADDRESSES'
|
|
194
204
|
| 'SEQ_PUBLISHER_ALLOW_INVALID_STATES'
|
|
195
205
|
| 'SEQ_PUBLISHER_FORWARDER_ADDRESS'
|
|
196
|
-
| '
|
|
206
|
+
| 'SEQ_POLLING_INTERVAL_MS'
|
|
197
207
|
| 'SEQ_ENFORCE_TIME_TABLE'
|
|
198
|
-
| '
|
|
208
|
+
| 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
|
|
199
209
|
| 'SEQ_ATTESTATION_PROPAGATION_TIME'
|
|
210
|
+
| 'SEQ_BLOCK_DURATION_MS'
|
|
211
|
+
| 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
|
|
200
212
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
|
|
201
213
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
|
|
202
214
|
| 'SLASH_MIN_PENALTY_PERCENTAGE'
|
|
@@ -209,6 +221,8 @@ export type EnvVar =
|
|
|
209
221
|
| 'SLASH_INACTIVITY_TARGET_PERCENTAGE'
|
|
210
222
|
| 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD'
|
|
211
223
|
| 'SLASH_INVALID_BLOCK_PENALTY'
|
|
224
|
+
| 'SLASH_DUPLICATE_PROPOSAL_PENALTY'
|
|
225
|
+
| 'SLASH_DUPLICATE_ATTESTATION_PENALTY'
|
|
212
226
|
| 'SLASH_OVERRIDE_PAYLOAD'
|
|
213
227
|
| 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY'
|
|
214
228
|
| 'SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY'
|
|
@@ -233,6 +247,14 @@ export type EnvVar =
|
|
|
233
247
|
| 'TX_COLLECTION_FAST_MAX_PARALLEL_REQUESTS_PER_NODE'
|
|
234
248
|
| 'TX_COLLECTION_NODE_RPC_MAX_BATCH_SIZE'
|
|
235
249
|
| 'TX_COLLECTION_NODE_RPC_URLS'
|
|
250
|
+
| 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE'
|
|
251
|
+
| 'TX_COLLECTION_FILE_STORE_URLS'
|
|
252
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS'
|
|
253
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS'
|
|
254
|
+
| 'TX_FILE_STORE_URL'
|
|
255
|
+
| 'TX_FILE_STORE_UPLOAD_CONCURRENCY'
|
|
256
|
+
| 'TX_FILE_STORE_MAX_QUEUE_SIZE'
|
|
257
|
+
| 'TX_FILE_STORE_ENABLED'
|
|
236
258
|
| 'TX_PUBLIC_SETUP_ALLOWLIST'
|
|
237
259
|
| 'TXE_PORT'
|
|
238
260
|
| 'TRANSACTIONS_DISABLED'
|
|
@@ -244,7 +266,6 @@ export type EnvVar =
|
|
|
244
266
|
| 'VALIDATOR_ADDRESSES'
|
|
245
267
|
| 'ROLLUP_VERSION'
|
|
246
268
|
| 'WS_BLOCK_CHECK_INTERVAL_MS'
|
|
247
|
-
| 'WS_PROVEN_BLOCKS_ONLY'
|
|
248
269
|
| 'WS_BLOCK_REQUEST_BATCH_SIZE'
|
|
249
270
|
| 'L1_READER_VIEM_POLLING_INTERVAL_MS'
|
|
250
271
|
| 'WS_DATA_DIRECTORY'
|
|
@@ -255,12 +276,14 @@ export type EnvVar =
|
|
|
255
276
|
| 'AZTEC_TARGET_COMMITTEE_SIZE'
|
|
256
277
|
| 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET'
|
|
257
278
|
| 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO'
|
|
279
|
+
| 'AZTEC_INBOX_LAG'
|
|
258
280
|
| 'AZTEC_PROOF_SUBMISSION_EPOCHS'
|
|
259
281
|
| 'AZTEC_ACTIVATION_THRESHOLD'
|
|
260
282
|
| 'AZTEC_EJECTION_THRESHOLD'
|
|
261
283
|
| 'AZTEC_LOCAL_EJECTION_THRESHOLD'
|
|
262
284
|
| 'AZTEC_MANA_TARGET'
|
|
263
285
|
| 'AZTEC_PROVING_COST_PER_MANA'
|
|
286
|
+
| 'AZTEC_INITIAL_ETH_PER_FEE_ASSET'
|
|
264
287
|
| 'AZTEC_SLASHING_QUORUM'
|
|
265
288
|
| 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS'
|
|
266
289
|
| 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS'
|
|
@@ -274,6 +297,7 @@ export type EnvVar =
|
|
|
274
297
|
| 'AZTEC_SLASHER_FLAVOR'
|
|
275
298
|
| 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
|
|
276
299
|
| 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
|
|
300
|
+
| 'AZTEC_GOVERNANCE_VOTING_DURATION'
|
|
277
301
|
| 'AZTEC_EXIT_DELAY_SECONDS'
|
|
278
302
|
| 'L1_GAS_LIMIT_BUFFER_PERCENTAGE'
|
|
279
303
|
| 'L1_GAS_PRICE_MAX'
|
|
@@ -300,7 +324,6 @@ export type EnvVar =
|
|
|
300
324
|
| 'K8S_POD_UID'
|
|
301
325
|
| 'K8S_NAMESPACE_NAME'
|
|
302
326
|
| 'VALIDATOR_REEXECUTE_DEADLINE_MS'
|
|
303
|
-
| 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS'
|
|
304
327
|
| 'AUTO_UPDATE'
|
|
305
328
|
| 'AUTO_UPDATE_URL'
|
|
306
329
|
| 'WEB3_SIGNER_URL'
|
|
@@ -309,4 +332,16 @@ export type EnvVar =
|
|
|
309
332
|
| 'FISHERMAN_MODE'
|
|
310
333
|
| 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
|
|
311
334
|
| 'LEGACY_BLS_CLI'
|
|
312
|
-
| 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
|
|
335
|
+
| 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
|
|
336
|
+
| 'VALIDATOR_HA_SIGNING_ENABLED'
|
|
337
|
+
| 'VALIDATOR_HA_NODE_ID'
|
|
338
|
+
| 'VALIDATOR_HA_POLLING_INTERVAL_MS'
|
|
339
|
+
| 'VALIDATOR_HA_SIGNING_TIMEOUT_MS'
|
|
340
|
+
| 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS'
|
|
341
|
+
| 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H'
|
|
342
|
+
| 'VALIDATOR_HA_DATABASE_URL'
|
|
343
|
+
| 'VALIDATOR_HA_RUN_MIGRATIONS'
|
|
344
|
+
| 'VALIDATOR_HA_POOL_MAX'
|
|
345
|
+
| 'VALIDATOR_HA_POOL_MIN'
|
|
346
|
+
| 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS'
|
|
347
|
+
| 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS';
|
package/src/config/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Fq, Fr } from '../curves/bn254/field.js';
|
|
|
2
2
|
import { createConsoleLogger } from '../log/console.js';
|
|
3
3
|
import type { EnvVar } from './env_var.js';
|
|
4
4
|
import { type NetworkNames, getActiveNetworkName } from './network_name.js';
|
|
5
|
+
import { parseBooleanEnv } from './parse-env.js';
|
|
5
6
|
import { SecretValue } from './secret_value.js';
|
|
6
7
|
|
|
7
8
|
export { SecretValue, getActiveNetworkName };
|
|
@@ -148,6 +149,23 @@ export function floatConfigHelper(
|
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Parses an environment variable to a 0-1 percentage value
|
|
154
|
+
*/
|
|
155
|
+
export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
|
|
156
|
+
return {
|
|
157
|
+
parseEnv: (val: string): number => {
|
|
158
|
+
const parsed = safeParseFloat(val, defaultVal);
|
|
159
|
+
if (parsed < 0 || parsed > 1) {
|
|
160
|
+
throw new TypeError(`Invalid percentage value: ${parsed} should be between 0 and 1`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return parsed;
|
|
164
|
+
},
|
|
165
|
+
defaultValue: defaultVal,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
151
169
|
/**
|
|
152
170
|
* Generates parseEnv and default values for a numerical config value.
|
|
153
171
|
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
@@ -231,10 +249,7 @@ export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T
|
|
|
231
249
|
};
|
|
232
250
|
}
|
|
233
251
|
|
|
234
|
-
|
|
235
|
-
export function parseBooleanEnv(val: string | undefined): boolean {
|
|
236
|
-
return val !== undefined && ['1', 'true', 'TRUE'].includes(val);
|
|
237
|
-
}
|
|
252
|
+
export { parseBooleanEnv } from './parse-env.js';
|
|
238
253
|
|
|
239
254
|
export function secretStringConfigHelper(): Required<
|
|
240
255
|
Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
|
|
@@ -4,9 +4,11 @@ export const NetworkConfigSchema = z
|
|
|
4
4
|
.object({
|
|
5
5
|
bootnodes: z.array(z.string()),
|
|
6
6
|
snapshots: z.array(z.string()),
|
|
7
|
+
blobFileStoreUrls: z.array(z.string()).optional(),
|
|
7
8
|
registryAddress: z.string(),
|
|
8
9
|
feeAssetHandlerAddress: z.string().optional(),
|
|
9
10
|
l1ChainId: z.number(),
|
|
11
|
+
blockDurationMs: z.number().positive().optional(),
|
|
10
12
|
})
|
|
11
13
|
.passthrough(); // Allow additional unknown fields to pass through
|
|
12
14
|
|
|
@@ -35,16 +35,6 @@ export async function poseidon2HashWithSeparator(input: Fieldable[], separator:
|
|
|
35
35
|
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export async function poseidon2HashAccumulate(input: Fieldable[]): Promise<Fr> {
|
|
39
|
-
const inputFields = serializeToFields(input);
|
|
40
|
-
await BarretenbergSync.initSingleton();
|
|
41
|
-
const api = BarretenbergSync.getSingleton();
|
|
42
|
-
const response = api.poseidon2HashAccumulate({
|
|
43
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
44
|
-
});
|
|
45
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
38
|
/**
|
|
49
39
|
* Runs a Poseidon2 permutation.
|
|
50
40
|
* @param input the input state. Expected to be of size 4.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger } from '../../log/pino-logger.js';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '../../log/pino-logger.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A number generator which is used as a source of randomness in the system. If the SEED env variable is set, the
|
|
@@ -12,11 +12,13 @@ export class RandomnessSingleton {
|
|
|
12
12
|
private static instance: RandomnessSingleton;
|
|
13
13
|
|
|
14
14
|
private counter = 0;
|
|
15
|
+
private log: Logger;
|
|
15
16
|
|
|
16
17
|
private constructor(
|
|
17
18
|
private readonly seed?: number,
|
|
18
|
-
|
|
19
|
+
bindings?: LoggerBindings,
|
|
19
20
|
) {
|
|
21
|
+
this.log = createLogger('foundation:randomness_singleton', bindings);
|
|
20
22
|
if (seed !== undefined) {
|
|
21
23
|
this.log.debug(`Using pseudo-randomness with seed: ${seed}`);
|
|
22
24
|
this.counter = seed;
|
|
@@ -25,10 +27,10 @@ export class RandomnessSingleton {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
public static getInstance(): RandomnessSingleton {
|
|
30
|
+
public static getInstance(bindings?: LoggerBindings): RandomnessSingleton {
|
|
29
31
|
if (!RandomnessSingleton.instance) {
|
|
30
32
|
const seed = process.env.SEED ? Number(process.env.SEED) : undefined;
|
|
31
|
-
RandomnessSingleton.instance = new RandomnessSingleton(seed);
|
|
33
|
+
RandomnessSingleton.instance = new RandomnessSingleton(seed, bindings);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
return RandomnessSingleton.instance;
|
|
@@ -34,15 +34,6 @@ export function poseidon2HashWithSeparator(input: Fieldable[], separator: number
|
|
|
34
34
|
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function poseidon2HashAccumulate(input: Fieldable[]): Fr {
|
|
38
|
-
const inputFields = serializeToFields(input);
|
|
39
|
-
const api = BarretenbergSync.getSingleton();
|
|
40
|
-
const response = api.poseidon2HashAccumulate({
|
|
41
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
42
|
-
});
|
|
43
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
37
|
/**
|
|
47
38
|
* Runs a Poseidon2 permutation.
|
|
48
39
|
* @param input the input state. Expected to be of size 4.
|
|
@@ -8,8 +8,6 @@ import { hexSchemaFor } from '../../schemas/utils.js';
|
|
|
8
8
|
import { BufferReader } from '../../serialize/buffer_reader.js';
|
|
9
9
|
import { TypeRegistry } from '../../serialize/type_registry.js';
|
|
10
10
|
|
|
11
|
-
const ZERO_BUFFER = Buffer.alloc(32);
|
|
12
|
-
|
|
13
11
|
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
14
12
|
|
|
15
13
|
/**
|
|
@@ -25,14 +23,12 @@ type DerivedField<T extends BaseField> = {
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* Base field class.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* We only check we are within the field modulus when initializing with bigint.
|
|
26
|
+
* Uses bigint as the internal representation.
|
|
27
|
+
* Buffers are generated on demand from the bigint value.
|
|
31
28
|
*/
|
|
32
29
|
abstract class BaseField {
|
|
33
30
|
static SIZE_IN_BYTES = 32;
|
|
34
|
-
private
|
|
35
|
-
private asBigInt?: bigint;
|
|
31
|
+
private readonly asBigInt: bigint;
|
|
36
32
|
|
|
37
33
|
/**
|
|
38
34
|
* Return bigint representation.
|
|
@@ -52,53 +48,41 @@ abstract class BaseField {
|
|
|
52
48
|
if (value.length > BaseField.SIZE_IN_BYTES) {
|
|
53
49
|
throw new Error(`Value length ${value.length} exceeds ${BaseField.SIZE_IN_BYTES}`);
|
|
54
50
|
}
|
|
55
|
-
this.
|
|
56
|
-
value.length === BaseField.SIZE_IN_BYTES
|
|
57
|
-
? value
|
|
58
|
-
: Buffer.concat([Buffer.alloc(BaseField.SIZE_IN_BYTES - value.length), value]);
|
|
51
|
+
this.asBigInt = toBigIntBE(value);
|
|
59
52
|
} else if (typeof value === 'bigint' || typeof value === 'number' || typeof value === 'boolean') {
|
|
60
53
|
this.asBigInt = BigInt(value);
|
|
61
|
-
if (this.asBigInt >= this.modulus()) {
|
|
62
|
-
throw new Error(`Value 0x${this.asBigInt.toString(16)} is greater or equal to field modulus.`);
|
|
63
|
-
} else if (this.asBigInt < 0n) {
|
|
64
|
-
throw new Error(`Value 0x${this.asBigInt.toString(16)} is negative.`);
|
|
65
|
-
}
|
|
66
54
|
} else if (value instanceof BaseField) {
|
|
67
|
-
this.asBuffer = value.asBuffer;
|
|
68
55
|
this.asBigInt = value.asBigInt;
|
|
69
56
|
} else {
|
|
70
57
|
throw new Error(`Type '${typeof value}' with value '${value}' passed to BaseField ctor.`);
|
|
71
58
|
}
|
|
59
|
+
|
|
60
|
+
if (this.asBigInt < 0n) {
|
|
61
|
+
throw new Error(`Value 0x${this.asBigInt.toString(16)} is negative.`);
|
|
62
|
+
} else if (this.asBigInt >= this.modulus()) {
|
|
63
|
+
throw new Error(`Value 0x${this.asBigInt.toString(16)} is greater or equal to field modulus.`);
|
|
64
|
+
}
|
|
72
65
|
}
|
|
73
66
|
|
|
74
67
|
protected abstract modulus(): bigint;
|
|
75
68
|
|
|
76
69
|
/**
|
|
77
|
-
*
|
|
70
|
+
* Converts the bigint to a Buffer.
|
|
78
71
|
*/
|
|
79
72
|
toBuffer(): Buffer {
|
|
80
|
-
|
|
81
|
-
this.asBuffer = toBufferBE(this.asBigInt!, 32);
|
|
82
|
-
}
|
|
83
|
-
return Buffer.from(this.asBuffer);
|
|
73
|
+
return toBufferBE(this.asBigInt, 32);
|
|
84
74
|
}
|
|
85
75
|
|
|
86
76
|
toString(): `0x${string}` {
|
|
87
|
-
return `0x${this.
|
|
77
|
+
return `0x${this.asBigInt.toString(16).padStart(64, '0')}`;
|
|
88
78
|
}
|
|
89
79
|
|
|
90
80
|
toBigInt(): bigint {
|
|
91
|
-
if (this.asBigInt === undefined) {
|
|
92
|
-
this.asBigInt = toBigIntBE(this.asBuffer!);
|
|
93
|
-
if (this.asBigInt >= this.modulus()) {
|
|
94
|
-
throw new Error(`Value 0x${this.asBigInt.toString(16)} is greater or equal to field modulus.`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
81
|
return this.asBigInt;
|
|
98
82
|
}
|
|
99
83
|
|
|
100
84
|
toBool(): boolean {
|
|
101
|
-
return
|
|
85
|
+
return this.asBigInt !== 0n;
|
|
102
86
|
}
|
|
103
87
|
|
|
104
88
|
/**
|
|
@@ -106,11 +90,10 @@ abstract class BaseField {
|
|
|
106
90
|
* Throws if the underlying value is greater than MAX_SAFE_INTEGER.
|
|
107
91
|
*/
|
|
108
92
|
toNumber(): number {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
throw new Error(`Value ${value.toString(16)} greater than than max safe integer`);
|
|
93
|
+
if (this.asBigInt > Number.MAX_SAFE_INTEGER) {
|
|
94
|
+
throw new Error(`Value ${this.asBigInt.toString(16)} greater than than max safe integer`);
|
|
112
95
|
}
|
|
113
|
-
return Number(
|
|
96
|
+
return Number(this.asBigInt);
|
|
114
97
|
}
|
|
115
98
|
|
|
116
99
|
/**
|
|
@@ -118,8 +101,7 @@ abstract class BaseField {
|
|
|
118
101
|
* May cause loss of precision if the underlying value is greater than MAX_SAFE_INTEGER.
|
|
119
102
|
*/
|
|
120
103
|
toNumberUnsafe(): number {
|
|
121
|
-
|
|
122
|
-
return Number(value);
|
|
104
|
+
return Number(this.asBigInt);
|
|
123
105
|
}
|
|
124
106
|
|
|
125
107
|
toShortString(): string {
|
|
@@ -128,21 +110,24 @@ abstract class BaseField {
|
|
|
128
110
|
}
|
|
129
111
|
|
|
130
112
|
equals(rhs: BaseField): boolean {
|
|
131
|
-
return this.
|
|
113
|
+
return this.asBigInt === rhs.asBigInt;
|
|
132
114
|
}
|
|
133
115
|
|
|
134
116
|
lt(rhs: BaseField): boolean {
|
|
135
|
-
return this.
|
|
117
|
+
return this.asBigInt < rhs.asBigInt;
|
|
136
118
|
}
|
|
137
119
|
|
|
138
120
|
cmp(rhs: BaseField): -1 | 0 | 1 {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
121
|
+
const rhsBigInt = rhs.asBigInt;
|
|
122
|
+
return this.asBigInt === rhsBigInt ? 0 : this.asBigInt < rhsBigInt ? -1 : 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static cmp(lhs: BaseField, rhs: BaseField): -1 | 0 | 1 {
|
|
126
|
+
return lhs.cmp(rhs);
|
|
142
127
|
}
|
|
143
128
|
|
|
144
129
|
isZero(): boolean {
|
|
145
|
-
return this.
|
|
130
|
+
return this.asBigInt === 0n;
|
|
146
131
|
}
|
|
147
132
|
|
|
148
133
|
isEmpty(): boolean {
|
|
@@ -195,7 +180,7 @@ function fromHexString<T extends BaseField>(buf: string, f: DerivedField<T>) {
|
|
|
195
180
|
|
|
196
181
|
const buffer = Buffer.from(checked.length % 2 === 1 ? '0' + checked : checked, 'hex');
|
|
197
182
|
|
|
198
|
-
return new f(buffer);
|
|
183
|
+
return new f(toBigIntBE(buffer));
|
|
199
184
|
}
|
|
200
185
|
|
|
201
186
|
/** Branding to ensure fields are not interchangeable types. */
|
package/src/eth-address/index.ts
CHANGED
|
@@ -249,7 +249,7 @@ export class EthAddress {
|
|
|
249
249
|
/** Converts a number into an address. Useful for testing. */
|
|
250
250
|
static fromNumber(num: bigint | number): EthAddress {
|
|
251
251
|
const buffer = Buffer.alloc(EthAddress.SIZE_IN_BYTES);
|
|
252
|
-
buffer.writeBigUInt64BE(BigInt(num),
|
|
252
|
+
buffer.writeBigUInt64BE(BigInt(num), EthAddress.SIZE_IN_BYTES - 8);
|
|
253
253
|
return new EthAddress(buffer);
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Wraps an async iterable iterator such that it filters values based on a predicate. */
|
|
2
|
+
export async function* filter<T>(
|
|
3
|
+
iterator: AsyncIterableIterator<T>,
|
|
4
|
+
predicate: (item: T) => boolean | Promise<boolean>,
|
|
5
|
+
): AsyncIterableIterator<T> {
|
|
6
|
+
for await (const item of iterator) {
|
|
7
|
+
if (await predicate(item)) {
|
|
8
|
+
yield item;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { filter } from './filter.js';
|
package/src/jest/setup.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseBooleanEnv } from '@aztec/foundation/config';
|
|
1
2
|
import { overwriteLoggingStream, pinoPrettyOpts } from '@aztec/foundation/log';
|
|
2
3
|
|
|
3
4
|
import pretty from 'pino-pretty';
|
|
@@ -6,4 +7,6 @@ import pretty from 'pino-pretty';
|
|
|
6
7
|
// file so we don't mess up with dependencies in non-testing environments,
|
|
7
8
|
// since pino-pretty messes up with browser bundles.
|
|
8
9
|
// See also https://www.npmjs.com/package/pino-pretty?activeTab=readme#user-content-usage-with-jest
|
|
9
|
-
|
|
10
|
+
if (!parseBooleanEnv(process.env.LOG_JSON)) {
|
|
11
|
+
overwriteLoggingStream(pretty(pinoPrettyOpts));
|
|
12
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { promisify } from 'node:util';
|
|
2
|
+
import { gunzip as gunzipCb, gzip as gzipCb } from 'node:zlib';
|
|
1
3
|
import { Agent, type Dispatcher } from 'undici';
|
|
2
4
|
|
|
3
5
|
import { createLogger } from '../../log/pino-logger.js';
|
|
@@ -5,8 +7,14 @@ import { NoRetryError } from '../../retry/index.js';
|
|
|
5
7
|
import { jsonStringify } from '../convert.js';
|
|
6
8
|
import type { JsonRpcFetch } from './fetch.js';
|
|
7
9
|
|
|
10
|
+
const gzip = promisify(gzipCb);
|
|
11
|
+
const gunzip = promisify(gunzipCb);
|
|
12
|
+
|
|
8
13
|
const log = createLogger('json-rpc:json_rpc_client:undici');
|
|
9
14
|
|
|
15
|
+
/** Minimum request size in bytes to trigger compression. */
|
|
16
|
+
const COMPRESSION_THRESHOLD = 1024;
|
|
17
|
+
|
|
10
18
|
export { Agent };
|
|
11
19
|
|
|
12
20
|
export function makeUndiciFetch(client = new Agent()): JsonRpcFetch {
|
|
@@ -14,14 +22,18 @@ export function makeUndiciFetch(client = new Agent()): JsonRpcFetch {
|
|
|
14
22
|
log.trace(`JsonRpcClient.fetch: ${host}`, { host, body });
|
|
15
23
|
let resp: Dispatcher.ResponseData;
|
|
16
24
|
try {
|
|
25
|
+
const jsonBody = Buffer.from(jsonStringify(body));
|
|
26
|
+
const shouldCompress = jsonBody.length >= COMPRESSION_THRESHOLD;
|
|
17
27
|
resp = await client.request({
|
|
18
28
|
method: 'POST',
|
|
19
29
|
origin: new URL(host),
|
|
20
30
|
path: '/',
|
|
21
|
-
body:
|
|
31
|
+
body: shouldCompress ? await gzip(jsonBody) : jsonBody,
|
|
22
32
|
headers: {
|
|
23
33
|
...extraHeaders,
|
|
24
34
|
'content-type': 'application/json',
|
|
35
|
+
...(shouldCompress && { 'content-encoding': 'gzip' }),
|
|
36
|
+
'accept-encoding': 'gzip',
|
|
25
37
|
},
|
|
26
38
|
});
|
|
27
39
|
} catch (err) {
|
|
@@ -31,13 +43,19 @@ export function makeUndiciFetch(client = new Agent()): JsonRpcFetch {
|
|
|
31
43
|
|
|
32
44
|
let responseJson: any;
|
|
33
45
|
const responseOk = resp.statusCode >= 200 && resp.statusCode <= 299;
|
|
46
|
+
const contentEncoding = resp.headers['content-encoding'];
|
|
34
47
|
try {
|
|
35
|
-
|
|
48
|
+
if (contentEncoding === 'gzip') {
|
|
49
|
+
const jsonBuffer = await gunzip(await resp.body.arrayBuffer());
|
|
50
|
+
responseJson = JSON.parse(jsonBuffer.toString('utf-8'));
|
|
51
|
+
} else {
|
|
52
|
+
responseJson = await resp.body.json();
|
|
53
|
+
}
|
|
36
54
|
} catch {
|
|
37
55
|
if (!responseOk) {
|
|
38
56
|
throw new Error('HTTP ' + resp.statusCode);
|
|
39
57
|
}
|
|
40
|
-
throw new Error(`Failed to parse body as JSON: ${await resp.body.text()}`);
|
|
58
|
+
throw new Error(`Failed to parse body as JSON. encoding: ${contentEncoding}, body: ${await resp.body.text()}`);
|
|
41
59
|
}
|
|
42
60
|
|
|
43
61
|
if (!responseOk) {
|
package/src/log/libp2p_logger.ts
CHANGED
|
@@ -2,15 +2,17 @@ import type { ComponentLogger, Logger } from '@libp2p/interface';
|
|
|
2
2
|
|
|
3
3
|
import { getLogLevelFromFilters } from './log-filters.js';
|
|
4
4
|
import type { LogLevel } from './log-levels.js';
|
|
5
|
-
import { logFilters, logger } from './pino-logger.js';
|
|
5
|
+
import { type LoggerBindings, logFilters, logger } from './pino-logger.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Creates a libp2p compatible logger that wraps our pino logger.
|
|
9
9
|
* This adapter implements the ComponentLogger interface required by libp2p.
|
|
10
|
+
* @param namespace - Base namespace for the logger
|
|
11
|
+
* @param bindings - Optional bindings to pass to the logger (actor, instanceId)
|
|
10
12
|
*/
|
|
11
|
-
export function createLibp2pComponentLogger(namespace: string): ComponentLogger {
|
|
13
|
+
export function createLibp2pComponentLogger(namespace: string, bindings?: LoggerBindings): ComponentLogger {
|
|
12
14
|
return {
|
|
13
|
-
forComponent: (component: string) => createLibp2pLogger(`${namespace}:${component}
|
|
15
|
+
forComponent: (component: string) => createLibp2pLogger(`${namespace}:${component}`, bindings),
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -24,9 +26,14 @@ function replaceFormatting(message: string) {
|
|
|
24
26
|
return message.replace(/(%p|%a)/g, '%s');
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
function createLibp2pLogger(component: string): Logger {
|
|
29
|
+
function createLibp2pLogger(component: string, bindings?: LoggerBindings): Logger {
|
|
28
30
|
// Create a direct pino logger instance for libp2p that supports string interpolation
|
|
29
|
-
const
|
|
31
|
+
const actor = bindings?.actor;
|
|
32
|
+
const instanceId = bindings?.instanceId;
|
|
33
|
+
const log = logger.child(
|
|
34
|
+
{ module: component, ...(actor && { actor }), ...(instanceId && { instanceId }) },
|
|
35
|
+
{ level: getLogLevelFromFilters(logFilters, component) },
|
|
36
|
+
);
|
|
30
37
|
|
|
31
38
|
const logIfEnabled = (level: LogLevel, message: string, ...args: unknown[]) => {
|
|
32
39
|
if (!log.isLevelEnabled(level)) {
|
package/src/log/log-filters.ts
CHANGED
|
@@ -19,22 +19,40 @@ export function getLogLevelFromFilters(filters: LogFilters, module: string): Log
|
|
|
19
19
|
return undefined;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Parses the LOG_LEVEL env string into a default level and per-module filter overrides.
|
|
24
|
+
*
|
|
25
|
+
* Format: `<default_level>;<level>:<module1>,<module2>;<level>:<module3>;...`
|
|
26
|
+
* - First segment (before the first `;`) is the default log level for all modules.
|
|
27
|
+
* - Remaining segments are `level:module` pairs: apply the given level to the listed modules (comma-separated).
|
|
28
|
+
* - Later filters override earlier ones for overlapping module matches.
|
|
29
|
+
* - The `aztec:` prefix is stripped from module names; spaces are trimmed.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* parseLogLevel('debug;warn:module1,module2;error:module3', 'info')
|
|
34
|
+
* // => ['debug', [['module3', 'error'], ['module2', 'warn'], ['module1', 'warn']]]
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function parseLogLevelEnvVar(
|
|
38
|
+
logLevelEnvVar: string | undefined,
|
|
39
|
+
defaultLevel: LogLevel,
|
|
40
|
+
): [LogLevel, LogFilters] {
|
|
41
|
+
if (!logLevelEnvVar) {
|
|
42
|
+
return [defaultLevel, []];
|
|
25
43
|
}
|
|
44
|
+
const [level] = logLevelEnvVar.split(';', 1);
|
|
45
|
+
assertValidLogLevel(level);
|
|
46
|
+
return [level, parseFilters(logLevelEnvVar.slice(level.length + 1))];
|
|
26
47
|
}
|
|
27
48
|
|
|
28
|
-
|
|
29
|
-
if (!
|
|
30
|
-
|
|
49
|
+
function assertValidLogLevel(level: string): asserts level is LogLevel {
|
|
50
|
+
if (!LogLevels.includes(level as LogLevel)) {
|
|
51
|
+
throw new Error(`Invalid log level: ${level}`);
|
|
31
52
|
}
|
|
32
|
-
const [level] = env.split(';', 1);
|
|
33
|
-
assertLogLevel(level);
|
|
34
|
-
return [level, parseFilters(env.slice(level.length + 1))];
|
|
35
53
|
}
|
|
36
54
|
|
|
37
|
-
|
|
55
|
+
function parseFilters(definition: string | undefined): LogFilters {
|
|
38
56
|
if (!definition) {
|
|
39
57
|
return [];
|
|
40
58
|
}
|
|
@@ -48,7 +66,7 @@ export function parseFilters(definition: string | undefined): LogFilters {
|
|
|
48
66
|
throw new Error(`Invalid log filter statement: ${statement}`);
|
|
49
67
|
}
|
|
50
68
|
const sanitizedLevel = level.trim().toLowerCase();
|
|
51
|
-
|
|
69
|
+
assertValidLogLevel(sanitizedLevel);
|
|
52
70
|
for (const module of modules.split(',')) {
|
|
53
71
|
filters.push([
|
|
54
72
|
module
|