@aztec/foundation 0.0.1-commit.1142ef1 → 0.0.1-commit.125b3452
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/sorted_array.d.ts +6 -1
- package/dest/array/sorted_array.d.ts.map +1 -1
- package/dest/array/sorted_array.js +18 -15
- 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/index.d.ts +2 -1
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +1 -0
- 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/buffer32.d.ts +4 -1
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/index.d.ts +2 -1
- package/dest/buffer/index.d.ts.map +1 -1
- package/dest/buffer/index.js +1 -0
- package/dest/buffer/utils.d.ts +3 -0
- package/dest/buffer/utils.d.ts.map +1 -0
- package/dest/buffer/utils.js +7 -0
- 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 +5 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +29 -0
- package/dest/config/network_config.d.ts +19 -1
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_config.js +4 -1
- package/dest/config/network_name.d.ts +2 -2
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +2 -0
- 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 +13 -22
- 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 +4 -4
- package/dest/crypto/secp256k1-signer/utils.d.ts +12 -1
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +26 -0
- 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/point.d.ts +10 -1
- package/dest/curves/bls12/point.d.ts.map +1 -1
- package/dest/curves/bn254/field.d.ts +2 -1
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +5 -2
- 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-signature/eth_signature.d.ts +5 -1
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +7 -2
- package/dest/jest/setup.js +28 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +2 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +1 -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/api_key_auth.d.ts +19 -0
- package/dest/json-rpc/server/api_key_auth.d.ts.map +1 -0
- package/dest/json-rpc/server/api_key_auth.js +57 -0
- package/dest/json-rpc/server/index.d.ts +2 -1
- package/dest/json-rpc/server/index.d.ts.map +1 -1
- package/dest/json-rpc/server/index.js +1 -0
- package/dest/json-rpc/server/safe_json_rpc_server.js +1 -1
- package/dest/log/bigint-utils.d.ts +5 -0
- package/dest/log/bigint-utils.d.ts.map +1 -0
- package/dest/log/bigint-utils.js +21 -0
- package/dest/log/gcloud-logger-config.d.ts +1 -1
- package/dest/log/gcloud-logger-config.d.ts.map +1 -1
- package/dest/log/gcloud-logger-config.js +3 -0
- 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 +121 -28
- 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/serialize/buffer_reader.d.ts +14 -4
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +26 -4
- package/dest/serialize/serialize.d.ts +19 -1
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/serialize/serialize.js +31 -0
- package/dest/sleep/index.d.ts +2 -1
- package/dest/sleep/index.d.ts.map +1 -1
- package/dest/sleep/index.js +10 -1
- package/dest/timer/date.d.ts +25 -1
- package/dest/timer/date.d.ts.map +1 -1
- package/dest/timer/date.js +33 -0
- package/dest/transport/transport_client.js +2 -2
- 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 -2
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.js +1 -1
- package/dest/trees/{unbalanced_merkle_tree.d.ts → unbalanced_merkle_tree_root.d.ts} +3 -7
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{unbalanced_merkle_tree.js → unbalanced_merkle_tree_root.js} +8 -52
- 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 +4 -2
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +3 -0
- package/package.json +25 -4
- package/src/array/sorted_array.ts +22 -17
- package/src/branded-types/block_number.ts +5 -0
- package/src/branded-types/index.ts +1 -0
- package/src/branded-types/index_within_checkpoint.ts +88 -0
- package/src/buffer/index.ts +1 -0
- package/src/buffer/utils.ts +8 -0
- package/src/collection/array.ts +52 -0
- package/src/config/env_var.ts +60 -12
- package/src/config/index.ts +32 -0
- package/src/config/network_config.ts +3 -0
- package/src/config/network_name.ts +4 -1
- package/src/crypto/poseidon/index.ts +13 -23
- package/src/crypto/random/randomness_singleton.ts +9 -5
- package/src/crypto/secp256k1-signer/utils.ts +32 -0
- package/src/crypto/sync/poseidon/index.ts +0 -9
- package/src/curves/bn254/field.ts +6 -2
- package/src/eth-signature/eth_signature.ts +7 -1
- package/src/jest/setup.mjs +31 -1
- package/src/json-rpc/client/safe_json_rpc_client.ts +2 -0
- package/src/json-rpc/client/undici.ts +21 -3
- package/src/json-rpc/server/api_key_auth.ts +63 -0
- package/src/json-rpc/server/index.ts +1 -0
- package/src/json-rpc/server/safe_json_rpc_server.ts +1 -1
- package/src/log/bigint-utils.ts +25 -0
- package/src/log/gcloud-logger-config.ts +5 -0
- 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 +142 -38
- 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/serialize/buffer_reader.ts +36 -9
- package/src/serialize/serialize.ts +32 -0
- package/src/sleep/index.ts +10 -1
- package/src/timer/date.ts +48 -0
- package/src/transport/transport_client.ts +2 -2
- 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 -2
- package/src/trees/{unbalanced_merkle_tree.ts → unbalanced_merkle_tree_root.ts} +8 -66
- package/src/trees/unbalanced_tree_store.ts +57 -2
- package/src/types/index.ts +6 -1
- 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/config/env_var.ts
CHANGED
|
@@ -12,6 +12,9 @@ export type EnvVar =
|
|
|
12
12
|
| 'ARCHIVER_VIEM_POLLING_INTERVAL_MS'
|
|
13
13
|
| 'ARCHIVER_BATCH_SIZE'
|
|
14
14
|
| 'AZTEC_ADMIN_PORT'
|
|
15
|
+
| 'AZTEC_ADMIN_API_KEY_HASH'
|
|
16
|
+
| 'AZTEC_DISABLE_ADMIN_API_KEY'
|
|
17
|
+
| 'AZTEC_RESET_ADMIN_API_KEY'
|
|
15
18
|
| 'AZTEC_NODE_ADMIN_URL'
|
|
16
19
|
| 'AZTEC_NODE_URL'
|
|
17
20
|
| 'AZTEC_PORT'
|
|
@@ -47,7 +50,10 @@ export type EnvVar =
|
|
|
47
50
|
| 'BOT_TX_MINED_WAIT_SECONDS'
|
|
48
51
|
| 'BOT_MAX_CONSECUTIVE_ERRORS'
|
|
49
52
|
| 'BOT_STOP_WHEN_UNHEALTHY'
|
|
50
|
-
| '
|
|
53
|
+
| 'BOT_MODE'
|
|
54
|
+
| 'BOT_L2_TO_L1_MESSAGES_PER_TX'
|
|
55
|
+
| 'BOT_L1_TO_L2_SEED_COUNT'
|
|
56
|
+
| 'BOT_L1_TO_L2_SEED_INTERVAL'
|
|
51
57
|
| 'COINBASE'
|
|
52
58
|
| 'CRS_PATH'
|
|
53
59
|
| 'DATA_DIRECTORY'
|
|
@@ -56,6 +62,7 @@ export type EnvVar =
|
|
|
56
62
|
| 'BLOB_SINK_MAP_SIZE_KB'
|
|
57
63
|
| 'P2P_STORE_MAP_SIZE_KB'
|
|
58
64
|
| 'PROVER_BROKER_STORE_MAP_SIZE_KB'
|
|
65
|
+
| 'SIGNING_PROTECTION_MAP_SIZE_KB'
|
|
59
66
|
| 'WS_DB_MAP_SIZE_KB'
|
|
60
67
|
| 'ARCHIVE_TREE_MAP_SIZE_KB'
|
|
61
68
|
| 'NULLIFIER_TREE_MAP_SIZE_KB'
|
|
@@ -64,6 +71,7 @@ export type EnvVar =
|
|
|
64
71
|
| 'PUBLIC_DATA_TREE_MAP_SIZE_KB'
|
|
65
72
|
| 'DEBUG'
|
|
66
73
|
| 'DEBUG_P2P_DISABLE_COLOCATION_PENALTY'
|
|
74
|
+
| 'ENABLE_PROVER_NODE'
|
|
67
75
|
| 'ETHEREUM_HOSTS'
|
|
68
76
|
| 'ETHEREUM_DEBUG_HOSTS'
|
|
69
77
|
| 'ETHEREUM_ALLOW_NO_DEBUG_HOSTS'
|
|
@@ -73,10 +81,13 @@ export type EnvVar =
|
|
|
73
81
|
| 'KEY_STORE_DIRECTORY'
|
|
74
82
|
| 'L1_CHAIN_ID'
|
|
75
83
|
| 'L1_CONSENSUS_HOST_URLS'
|
|
84
|
+
| 'ETHEREUM_HTTP_TIMEOUT_MS'
|
|
76
85
|
| 'L1_CONSENSUS_HOST_API_KEYS'
|
|
77
86
|
| 'L1_CONSENSUS_HOST_API_KEY_HEADERS'
|
|
87
|
+
| 'L1_TX_FAILED_STORE'
|
|
78
88
|
| 'LOG_JSON'
|
|
79
89
|
| 'LOG_MULTILINE'
|
|
90
|
+
| 'LOG_NO_COLOR_PER_ACTOR'
|
|
80
91
|
| 'LOG_LEVEL'
|
|
81
92
|
| 'MNEMONIC'
|
|
82
93
|
| 'NETWORK'
|
|
@@ -94,7 +105,12 @@ export type EnvVar =
|
|
|
94
105
|
| 'PUBLIC_OTEL_INCLUDE_METRICS'
|
|
95
106
|
| 'PUBLIC_OTEL_COLLECT_FROM'
|
|
96
107
|
| 'PUBLIC_OTEL_OPT_OUT'
|
|
108
|
+
| 'P2P_BATCH_TX_REQUESTER_SMART_PARALLEL_WORKER_COUNT'
|
|
109
|
+
| 'P2P_BATCH_TX_REQUESTER_DUMB_PARALLEL_WORKER_COUNT'
|
|
110
|
+
| 'P2P_BATCH_TX_REQUESTER_TX_BATCH_SIZE'
|
|
111
|
+
| 'P2P_BATCH_TX_REQUESTER_BAD_PEER_THRESHOLD'
|
|
97
112
|
| 'P2P_BLOCK_CHECK_INTERVAL_MS'
|
|
113
|
+
| 'P2P_SLOT_CHECK_INTERVAL_MS'
|
|
98
114
|
| 'P2P_BLOCK_REQUEST_BATCH_SIZE'
|
|
99
115
|
| 'P2P_BOOTSTRAP_NODE_ENR_VERSION_CHECK'
|
|
100
116
|
| 'P2P_BOOTSTRAP_NODES_AS_FULL_PEERS'
|
|
@@ -135,9 +151,10 @@ export type EnvVar =
|
|
|
135
151
|
| 'P2P_PREFERRED_PEERS'
|
|
136
152
|
| 'P2P_MAX_PENDING_TX_COUNT'
|
|
137
153
|
| 'P2P_SEEN_MSG_CACHE_SIZE'
|
|
138
|
-
| 'P2P_DROP_TX'
|
|
139
154
|
| 'P2P_DROP_TX_CHANCE'
|
|
140
155
|
| 'P2P_TX_POOL_DELETE_TXS_AFTER_REORG'
|
|
156
|
+
| 'P2P_MIN_TX_POOL_AGE_MS'
|
|
157
|
+
| 'P2P_RPC_PRICE_BUMP_PERCENTAGE'
|
|
141
158
|
| 'DEBUG_P2P_INSTRUMENT_MESSAGES'
|
|
142
159
|
| 'PEER_ID_PRIVATE_KEY'
|
|
143
160
|
| 'PEER_ID_PRIVATE_KEY_PATH'
|
|
@@ -151,7 +168,11 @@ export type EnvVar =
|
|
|
151
168
|
| 'PROVER_BROKER_BATCH_INTERVAL_MS'
|
|
152
169
|
| 'PROVER_BROKER_BATCH_SIZE'
|
|
153
170
|
| 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR'
|
|
171
|
+
| 'PROVER_BROKER_DEBUG_REPLAY_ENABLED'
|
|
172
|
+
| 'PROVER_CANCEL_JOBS_ON_STOP'
|
|
173
|
+
| 'PROVER_ENQUEUE_CONCURRENCY'
|
|
154
174
|
| 'PROVER_COORDINATION_NODE_URLS'
|
|
175
|
+
| 'PROVER_PROOF_STORE'
|
|
155
176
|
| 'PROVER_FAILED_PROOF_STORE'
|
|
156
177
|
| 'PROVER_NODE_FAILED_EPOCH_STORE'
|
|
157
178
|
| 'PROVER_NODE_DISABLE_PROOF_PUBLISH'
|
|
@@ -175,6 +196,7 @@ export type EnvVar =
|
|
|
175
196
|
| 'PROVER_TEST_VERIFICATION_DELAY_MS'
|
|
176
197
|
| 'PXE_L2_BLOCK_BATCH_SIZE'
|
|
177
198
|
| 'PXE_PROVER_ENABLED'
|
|
199
|
+
| 'PXE_SYNC_CHAIN_TIP'
|
|
178
200
|
| 'RPC_MAX_BATCH_SIZE'
|
|
179
201
|
| 'RPC_MAX_BODY_SIZE'
|
|
180
202
|
| 'RPC_SIMULATE_PUBLIC_MAX_GAS_LIMIT'
|
|
@@ -182,12 +204,14 @@ export type EnvVar =
|
|
|
182
204
|
| 'SENTINEL_ENABLED'
|
|
183
205
|
| 'SENTINEL_HISTORY_LENGTH_IN_EPOCHS'
|
|
184
206
|
| 'SENTINEL_HISTORIC_PROVEN_PERFORMANCE_LENGTH_IN_EPOCHS'
|
|
185
|
-
| 'SEQ_MAX_BLOCK_SIZE_IN_BYTES'
|
|
186
207
|
| 'SEQ_MAX_TX_PER_BLOCK'
|
|
208
|
+
| 'SEQ_MAX_TX_PER_CHECKPOINT'
|
|
187
209
|
| 'SEQ_MIN_TX_PER_BLOCK'
|
|
188
210
|
| 'SEQ_PUBLISH_TXS_WITH_PROPOSALS'
|
|
189
211
|
| 'SEQ_MAX_DA_BLOCK_GAS'
|
|
190
212
|
| 'SEQ_MAX_L2_BLOCK_GAS'
|
|
213
|
+
| 'SEQ_PER_BLOCK_ALLOCATION_MULTIPLIER'
|
|
214
|
+
| 'SEQ_REDISTRIBUTE_CHECKPOINT_BUDGET'
|
|
191
215
|
| 'SEQ_PUBLISHER_PRIVATE_KEY'
|
|
192
216
|
| 'SEQ_PUBLISHER_PRIVATE_KEYS'
|
|
193
217
|
| 'SEQ_PUBLISHER_ADDRESSES'
|
|
@@ -198,9 +222,11 @@ export type EnvVar =
|
|
|
198
222
|
| 'SEQ_L1_PUBLISHING_TIME_ALLOWANCE_IN_SLOT'
|
|
199
223
|
| 'SEQ_ATTESTATION_PROPAGATION_TIME'
|
|
200
224
|
| 'SEQ_BLOCK_DURATION_MS'
|
|
225
|
+
| 'SEQ_EXPECTED_BLOCK_PROPOSALS_PER_SLOT'
|
|
201
226
|
| 'SEQ_BUILD_CHECKPOINT_IF_EMPTY'
|
|
202
227
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_COMMITTEE_MEMBER'
|
|
203
228
|
| 'SEQ_SECONDS_BEFORE_INVALIDATING_BLOCK_AS_NON_COMMITTEE_MEMBER'
|
|
229
|
+
| 'SEQ_SKIP_CHECKPOINT_PUBLISH_PERCENT'
|
|
204
230
|
| 'SLASH_MIN_PENALTY_PERCENTAGE'
|
|
205
231
|
| 'SLASH_MAX_PENALTY_PERCENTAGE'
|
|
206
232
|
| 'SLASH_VALIDATORS_ALWAYS'
|
|
@@ -211,6 +237,8 @@ export type EnvVar =
|
|
|
211
237
|
| 'SLASH_INACTIVITY_TARGET_PERCENTAGE'
|
|
212
238
|
| 'SLASH_INACTIVITY_CONSECUTIVE_EPOCH_THRESHOLD'
|
|
213
239
|
| 'SLASH_INVALID_BLOCK_PENALTY'
|
|
240
|
+
| 'SLASH_DUPLICATE_PROPOSAL_PENALTY'
|
|
241
|
+
| 'SLASH_DUPLICATE_ATTESTATION_PENALTY'
|
|
214
242
|
| 'SLASH_OVERRIDE_PAYLOAD'
|
|
215
243
|
| 'SLASH_PROPOSE_INVALID_ATTESTATIONS_PENALTY'
|
|
216
244
|
| 'SLASH_ATTEST_DESCENDANT_OF_INVALID_PENALTY'
|
|
@@ -225,6 +253,7 @@ export type EnvVar =
|
|
|
225
253
|
| 'TELEMETRY'
|
|
226
254
|
| 'TEST_ACCOUNTS'
|
|
227
255
|
| 'SPONSORED_FPC'
|
|
256
|
+
| 'PREFUND_ADDRESSES'
|
|
228
257
|
| 'TX_COLLECTION_FAST_NODES_TIMEOUT_BEFORE_REQ_RESP_MS'
|
|
229
258
|
| 'TX_COLLECTION_SLOW_NODES_INTERVAL_MS'
|
|
230
259
|
| 'TX_COLLECTION_SLOW_REQ_RESP_INTERVAL_MS'
|
|
@@ -235,21 +264,39 @@ export type EnvVar =
|
|
|
235
264
|
| 'TX_COLLECTION_FAST_MAX_PARALLEL_REQUESTS_PER_NODE'
|
|
236
265
|
| 'TX_COLLECTION_NODE_RPC_MAX_BATCH_SIZE'
|
|
237
266
|
| 'TX_COLLECTION_NODE_RPC_URLS'
|
|
267
|
+
| 'TX_COLLECTION_MISSING_TXS_COLLECTOR_TYPE'
|
|
268
|
+
| 'TX_COLLECTION_FILE_STORE_URLS'
|
|
269
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_DELAY_MS'
|
|
270
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_DELAY_MS'
|
|
271
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_WORKER_COUNT'
|
|
272
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_WORKER_COUNT'
|
|
273
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_BASE_MS'
|
|
274
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_BASE_MS'
|
|
275
|
+
| 'TX_COLLECTION_FILE_STORE_FAST_BACKOFF_MAX_MS'
|
|
276
|
+
| 'TX_COLLECTION_FILE_STORE_SLOW_BACKOFF_MAX_MS'
|
|
277
|
+
| 'TX_FILE_STORE_URL'
|
|
278
|
+
| 'TX_FILE_STORE_UPLOAD_CONCURRENCY'
|
|
279
|
+
| 'TX_FILE_STORE_MAX_QUEUE_SIZE'
|
|
280
|
+
| 'TX_FILE_STORE_ENABLED'
|
|
238
281
|
| 'TX_PUBLIC_SETUP_ALLOWLIST'
|
|
239
282
|
| 'TXE_PORT'
|
|
240
283
|
| 'TRANSACTIONS_DISABLED'
|
|
241
284
|
| 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS'
|
|
242
285
|
| 'VALIDATOR_DISABLED'
|
|
286
|
+
| 'VALIDATOR_MAX_DA_BLOCK_GAS'
|
|
287
|
+
| 'VALIDATOR_MAX_L2_BLOCK_GAS'
|
|
288
|
+
| 'VALIDATOR_MAX_TX_PER_BLOCK'
|
|
289
|
+
| 'VALIDATOR_MAX_TX_PER_CHECKPOINT'
|
|
243
290
|
| 'VALIDATOR_PRIVATE_KEYS'
|
|
244
291
|
| 'VALIDATOR_PRIVATE_KEY'
|
|
245
292
|
| 'VALIDATOR_REEXECUTE'
|
|
246
293
|
| 'VALIDATOR_ADDRESSES'
|
|
247
294
|
| 'ROLLUP_VERSION'
|
|
248
295
|
| 'WS_BLOCK_CHECK_INTERVAL_MS'
|
|
249
|
-
| 'WS_PROVEN_BLOCKS_ONLY'
|
|
250
296
|
| 'WS_BLOCK_REQUEST_BATCH_SIZE'
|
|
251
297
|
| 'L1_READER_VIEM_POLLING_INTERVAL_MS'
|
|
252
298
|
| 'WS_DATA_DIRECTORY'
|
|
299
|
+
| 'WS_NUM_HISTORIC_CHECKPOINTS'
|
|
253
300
|
| 'WS_NUM_HISTORIC_BLOCKS'
|
|
254
301
|
| 'ETHEREUM_SLOT_DURATION'
|
|
255
302
|
| 'AZTEC_SLOT_DURATION'
|
|
@@ -264,6 +311,7 @@ export type EnvVar =
|
|
|
264
311
|
| 'AZTEC_LOCAL_EJECTION_THRESHOLD'
|
|
265
312
|
| 'AZTEC_MANA_TARGET'
|
|
266
313
|
| 'AZTEC_PROVING_COST_PER_MANA'
|
|
314
|
+
| 'AZTEC_INITIAL_ETH_PER_FEE_ASSET'
|
|
267
315
|
| 'AZTEC_SLASHING_QUORUM'
|
|
268
316
|
| 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS'
|
|
269
317
|
| 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS'
|
|
@@ -277,6 +325,7 @@ export type EnvVar =
|
|
|
277
325
|
| 'AZTEC_SLASHER_FLAVOR'
|
|
278
326
|
| 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
|
|
279
327
|
| 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
|
|
328
|
+
| 'AZTEC_GOVERNANCE_VOTING_DURATION'
|
|
280
329
|
| 'AZTEC_EXIT_DELAY_SECONDS'
|
|
281
330
|
| 'L1_GAS_LIMIT_BUFFER_PERCENTAGE'
|
|
282
331
|
| 'L1_GAS_PRICE_MAX'
|
|
@@ -302,10 +351,8 @@ export type EnvVar =
|
|
|
302
351
|
| 'K8S_POD_NAME'
|
|
303
352
|
| 'K8S_POD_UID'
|
|
304
353
|
| 'K8S_NAMESPACE_NAME'
|
|
354
|
+
| 'ENABLE_VERSION_CHECK'
|
|
305
355
|
| 'VALIDATOR_REEXECUTE_DEADLINE_MS'
|
|
306
|
-
| 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS'
|
|
307
|
-
| 'AUTO_UPDATE'
|
|
308
|
-
| 'AUTO_UPDATE_URL'
|
|
309
356
|
| 'WEB3_SIGNER_URL'
|
|
310
357
|
| 'SKIP_ARCHIVER_INITIAL_SYNC'
|
|
311
358
|
| 'BLOB_ALLOW_EMPTY_SOURCES'
|
|
@@ -313,11 +360,12 @@ export type EnvVar =
|
|
|
313
360
|
| 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
|
|
314
361
|
| 'LEGACY_BLS_CLI'
|
|
315
362
|
| 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
|
|
316
|
-
| '
|
|
317
|
-
| '
|
|
318
|
-
| '
|
|
319
|
-
| '
|
|
320
|
-
| '
|
|
363
|
+
| 'VALIDATOR_HA_SIGNING_ENABLED'
|
|
364
|
+
| 'VALIDATOR_HA_NODE_ID'
|
|
365
|
+
| 'VALIDATOR_HA_POLLING_INTERVAL_MS'
|
|
366
|
+
| 'VALIDATOR_HA_SIGNING_TIMEOUT_MS'
|
|
367
|
+
| 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS'
|
|
368
|
+
| 'VALIDATOR_HA_OLD_DUTIES_MAX_AGE_H'
|
|
321
369
|
| 'VALIDATOR_HA_DATABASE_URL'
|
|
322
370
|
| 'VALIDATOR_HA_RUN_MIGRATIONS'
|
|
323
371
|
| 'VALIDATOR_HA_POOL_MAX'
|
package/src/config/index.ts
CHANGED
|
@@ -149,6 +149,23 @@ export function floatConfigHelper(
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
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
|
+
|
|
152
169
|
/**
|
|
153
170
|
* Generates parseEnv and default values for a numerical config value.
|
|
154
171
|
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
@@ -160,6 +177,21 @@ export function bigintConfigHelper(defaultVal?: bigint): Pick<ConfigMapping, 'pa
|
|
|
160
177
|
if (val === '') {
|
|
161
178
|
return defaultVal;
|
|
162
179
|
}
|
|
180
|
+
// Handle scientific notation (e.g. "1e+23", "2E23") which BigInt() doesn't accept directly.
|
|
181
|
+
// We parse it losslessly using bigint arithmetic instead of going through float64.
|
|
182
|
+
if (/[eE]/.test(val)) {
|
|
183
|
+
const match = val.match(/^(-?\d+(?:\.(\d+))?)[eE]([+-]?\d+)$/);
|
|
184
|
+
if (!match) {
|
|
185
|
+
throw new Error(`Cannot convert '${val}' to a BigInt`);
|
|
186
|
+
}
|
|
187
|
+
const digits = match[1].replace('.', '');
|
|
188
|
+
const decimalPlaces = match[2]?.length ?? 0;
|
|
189
|
+
const exponent = parseInt(match[3], 10) - decimalPlaces;
|
|
190
|
+
if (exponent < 0) {
|
|
191
|
+
throw new Error(`Cannot convert '${val}' to a BigInt: result is not an integer`);
|
|
192
|
+
}
|
|
193
|
+
return BigInt(digits) * 10n ** BigInt(exponent);
|
|
194
|
+
}
|
|
163
195
|
return BigInt(val);
|
|
164
196
|
},
|
|
165
197
|
defaultValue: defaultVal,
|
|
@@ -5,10 +5,13 @@ 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(),
|
|
14
|
+
nodeVersion: z.string().optional(),
|
|
12
15
|
})
|
|
13
16
|
.passthrough(); // Allow additional unknown fields to pass through
|
|
14
17
|
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Barretenberg } from '@aztec/bb.js';
|
|
2
2
|
|
|
3
3
|
import { Fr } from '../../curves/bn254/field.js';
|
|
4
4
|
import { type Fieldable, serializeToFields } from '../../serialize/serialize.js';
|
|
@@ -10,9 +10,9 @@ import { type Fieldable, serializeToFields } from '../../serialize/serialize.js'
|
|
|
10
10
|
*/
|
|
11
11
|
export async function poseidon2Hash(input: Fieldable[]): Promise<Fr> {
|
|
12
12
|
const inputFields = serializeToFields(input);
|
|
13
|
-
await
|
|
14
|
-
const api =
|
|
15
|
-
const response = api.poseidon2Hash({
|
|
13
|
+
await Barretenberg.initSingleton();
|
|
14
|
+
const api = Barretenberg.getSingleton();
|
|
15
|
+
const response = await api.poseidon2Hash({
|
|
16
16
|
inputs: inputFields.map(i => i.toBuffer()),
|
|
17
17
|
});
|
|
18
18
|
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
@@ -27,19 +27,9 @@ export async function poseidon2Hash(input: Fieldable[]): Promise<Fr> {
|
|
|
27
27
|
export async function poseidon2HashWithSeparator(input: Fieldable[], separator: number): Promise<Fr> {
|
|
28
28
|
const inputFields = serializeToFields(input);
|
|
29
29
|
inputFields.unshift(new Fr(separator));
|
|
30
|
-
await
|
|
31
|
-
const api =
|
|
32
|
-
const response = api.poseidon2Hash({
|
|
33
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
34
|
-
});
|
|
35
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
36
|
-
}
|
|
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({
|
|
30
|
+
await Barretenberg.initSingleton();
|
|
31
|
+
const api = Barretenberg.getSingleton();
|
|
32
|
+
const response = await api.poseidon2Hash({
|
|
43
33
|
inputs: inputFields.map(i => i.toBuffer()),
|
|
44
34
|
});
|
|
45
35
|
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
@@ -54,9 +44,9 @@ export async function poseidon2Permutation(input: Fieldable[]): Promise<Fr[]> {
|
|
|
54
44
|
const inputFields = serializeToFields(input);
|
|
55
45
|
// We'd like this assertion but it's not possible to use it in the browser.
|
|
56
46
|
// assert(input.length === 4, 'Input state must be of size 4');
|
|
57
|
-
await
|
|
58
|
-
const api =
|
|
59
|
-
const response = api.poseidon2Permutation({
|
|
47
|
+
await Barretenberg.initSingleton();
|
|
48
|
+
const api = Barretenberg.getSingleton();
|
|
49
|
+
const response = await api.poseidon2Permutation({
|
|
60
50
|
inputs: inputFields.map(i => i.toBuffer()),
|
|
61
51
|
});
|
|
62
52
|
// We'd like this assertion but it's not possible to use it in the browser.
|
|
@@ -75,9 +65,9 @@ export async function poseidon2HashBytes(input: Buffer): Promise<Fr> {
|
|
|
75
65
|
inputFields.push(Fr.fromBuffer(fieldBytes));
|
|
76
66
|
}
|
|
77
67
|
|
|
78
|
-
await
|
|
79
|
-
const api =
|
|
80
|
-
const response = api.poseidon2Hash({
|
|
68
|
+
await Barretenberg.initSingleton();
|
|
69
|
+
const api = Barretenberg.getSingleton();
|
|
70
|
+
const response = await api.poseidon2Hash({
|
|
81
71
|
inputs: inputFields.map(i => i.toBuffer()),
|
|
82
72
|
});
|
|
83
73
|
|
|
@@ -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,9 +12,13 @@ export class RandomnessSingleton {
|
|
|
12
12
|
private static instance: RandomnessSingleton;
|
|
13
13
|
|
|
14
14
|
private counter = 0;
|
|
15
|
-
private
|
|
15
|
+
private log: Logger;
|
|
16
16
|
|
|
17
|
-
private constructor(
|
|
17
|
+
private constructor(
|
|
18
|
+
private readonly seed?: number,
|
|
19
|
+
bindings?: LoggerBindings,
|
|
20
|
+
) {
|
|
21
|
+
this.log = createLogger('foundation:randomness_singleton', bindings);
|
|
18
22
|
if (seed !== undefined) {
|
|
19
23
|
this.log.debug(`Using pseudo-randomness with seed: ${seed}`);
|
|
20
24
|
this.counter = seed;
|
|
@@ -23,10 +27,10 @@ export class RandomnessSingleton {
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
|
|
26
|
-
public static getInstance(): RandomnessSingleton {
|
|
30
|
+
public static getInstance(bindings?: LoggerBindings): RandomnessSingleton {
|
|
27
31
|
if (!RandomnessSingleton.instance) {
|
|
28
32
|
const seed = process.env.SEED ? Number(process.env.SEED) : undefined;
|
|
29
|
-
RandomnessSingleton.instance = new RandomnessSingleton(seed);
|
|
33
|
+
RandomnessSingleton.instance = new RandomnessSingleton(seed, bindings);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
return RandomnessSingleton.instance;
|
|
@@ -210,3 +210,35 @@ export function recoverPublicKey(hash: Buffer32, signature: Signature, opts: Rec
|
|
|
210
210
|
const publicKey = sig.recoverPublicKey(hash.buffer).toHex(false);
|
|
211
211
|
return Buffer.from(publicKey, 'hex');
|
|
212
212
|
}
|
|
213
|
+
|
|
214
|
+
/** Arbitrary hash used for testing signature recoverability. */
|
|
215
|
+
const PROBE_HASH = Buffer32.fromBuffer(keccak256(Buffer.from('signature-recoverability-probe')));
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Generates a random valid ECDSA signature that is recoverable to some address.
|
|
219
|
+
* Since Signature.random() produces real signatures via secp256k1 signing, the result is always
|
|
220
|
+
* recoverable, but we verify defensively by checking tryRecoverAddress.
|
|
221
|
+
*/
|
|
222
|
+
export function generateRecoverableSignature(): Signature {
|
|
223
|
+
for (let i = 0; i < 100; i++) {
|
|
224
|
+
const sig = Signature.random();
|
|
225
|
+
if (tryRecoverAddress(PROBE_HASH, sig) !== undefined) {
|
|
226
|
+
return sig;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
throw new Secp256k1Error('Failed to generate a recoverable signature after 100 attempts');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Generates a random signature where ECDSA address recovery fails.
|
|
234
|
+
* Uses random r/s values (not from real signing) so that r is unlikely to be a valid secp256k1 x-coordinate.
|
|
235
|
+
*/
|
|
236
|
+
export function generateUnrecoverableSignature(): Signature {
|
|
237
|
+
for (let i = 0; i < 100; i++) {
|
|
238
|
+
const sig = new Signature(Buffer32.random(), Buffer32.random(), 27);
|
|
239
|
+
if (tryRecoverAddress(PROBE_HASH, sig) === undefined) {
|
|
240
|
+
return sig;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
throw new Secp256k1Error('Failed to generate an unrecoverable signature after 100 attempts');
|
|
244
|
+
}
|
|
@@ -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.
|
|
@@ -118,14 +118,18 @@ abstract class BaseField {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
cmp(rhs: BaseField): -1 | 0 | 1 {
|
|
121
|
-
|
|
122
|
-
return this.asBigInt === rhsBigInt ? 0 : this.asBigInt < rhsBigInt ? -1 : 1;
|
|
121
|
+
return BaseField.cmpAsBigInt(this.asBigInt, rhs.asBigInt);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
static cmp(lhs: BaseField, rhs: BaseField): -1 | 0 | 1 {
|
|
126
125
|
return lhs.cmp(rhs);
|
|
127
126
|
}
|
|
128
127
|
|
|
128
|
+
// Actual bigint comparison. Arguments must have been validated previously.
|
|
129
|
+
static cmpAsBigInt(lhs: bigint, rhs: bigint): -1 | 0 | 1 {
|
|
130
|
+
return lhs === rhs ? 0 : lhs < rhs ? -1 : 1;
|
|
131
|
+
}
|
|
132
|
+
|
|
129
133
|
isZero(): boolean {
|
|
130
134
|
return this.asBigInt === 0n;
|
|
131
135
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
3
|
|
|
4
|
+
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
|
|
7
|
+
import { randomBytes } from '../crypto/random/index.js';
|
|
6
8
|
import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -77,8 +79,12 @@ export class Signature {
|
|
|
77
79
|
return new Signature(Buffer32.fromBuffer(hexToBuffer(sig.r)), Buffer32.fromBuffer(hexToBuffer(sig.s)), sig.yParity);
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
/** Generates a random valid ECDSA signature with a low s-value by signing a random message with a random key. */
|
|
80
83
|
static random(): Signature {
|
|
81
|
-
|
|
84
|
+
const privateKey = randomBytes(32);
|
|
85
|
+
const message = randomBytes(32);
|
|
86
|
+
const { r, s, recovery } = secp256k1.sign(message, privateKey);
|
|
87
|
+
return new Signature(Buffer32.fromBigInt(r), Buffer32.fromBigInt(s), recovery ? 28 : 27);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
static empty(): Signature {
|
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,33 @@ 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
|
+
}
|
|
13
|
+
|
|
14
|
+
// Prevent timers from keeping the process alive after tests complete.
|
|
15
|
+
// Libraries like viem create internal polling loops (via setTimeout) that
|
|
16
|
+
// reschedule themselves indefinitely. In test environments we never want a
|
|
17
|
+
// timer to be the reason the process can't exit. We also unref stdout/stderr
|
|
18
|
+
// which, when they are pipes (as in Jest workers), remain ref'd by default.
|
|
19
|
+
{
|
|
20
|
+
const origSetTimeout = globalThis.setTimeout;
|
|
21
|
+
const origSetInterval = globalThis.setInterval;
|
|
22
|
+
globalThis.setTimeout = function unrefSetTimeout(...args) {
|
|
23
|
+
const id = origSetTimeout.apply(this, args);
|
|
24
|
+
id?.unref?.();
|
|
25
|
+
return id;
|
|
26
|
+
};
|
|
27
|
+
// Preserve .unref, .__promisify__ etc. that may exist on the original
|
|
28
|
+
Object.setPrototypeOf(globalThis.setTimeout, origSetTimeout);
|
|
29
|
+
|
|
30
|
+
globalThis.setInterval = function unrefSetInterval(...args) {
|
|
31
|
+
const id = origSetInterval.apply(this, args);
|
|
32
|
+
id?.unref?.();
|
|
33
|
+
return id;
|
|
34
|
+
};
|
|
35
|
+
Object.setPrototypeOf(globalThis.setInterval, origSetInterval);
|
|
36
|
+
|
|
37
|
+
if (process.stdout?._handle?.unref) process.stdout._handle.unref();
|
|
38
|
+
if (process.stderr?._handle?.unref) process.stderr._handle.unref();
|
|
39
|
+
}
|
|
@@ -24,6 +24,7 @@ export type SafeJsonRpcClientOptions = {
|
|
|
24
24
|
batchWindowMS?: number;
|
|
25
25
|
maxBatchSize?: number;
|
|
26
26
|
maxRequestBodySize?: number;
|
|
27
|
+
extraHeaders?: Record<string, string>;
|
|
27
28
|
onResponse?: (res: {
|
|
28
29
|
response: any;
|
|
29
30
|
headers: { get: (header: string) => string | null | undefined };
|
|
@@ -129,6 +130,7 @@ export function createSafeJsonRpcClient<T extends object>(
|
|
|
129
130
|
const { response, headers } = await fetch(
|
|
130
131
|
host,
|
|
131
132
|
rpcCalls.map(({ request }) => request),
|
|
133
|
+
config.extraHeaders,
|
|
132
134
|
);
|
|
133
135
|
|
|
134
136
|
if (config.onResponse) {
|
|
@@ -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) {
|