@aztec/end-to-end 0.0.1-commit.e6bd8901 → 0.0.1-commit.ec7ac5448
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/README.md +27 -0
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +22 -29
- package/dest/bench/client_flows/config.d.ts +2 -2
- package/dest/bench/client_flows/config.d.ts.map +1 -1
- package/dest/bench/client_flows/config.js +18 -0
- package/dest/bench/utils.d.ts +1 -1
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +6 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +6 -3
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +23 -13
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +3 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.d.ts +17 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +91 -44
- package/dest/e2e_fees/fees_test.d.ts +2 -2
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +19 -12
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -2
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -7
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
- package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
- package/dest/e2e_p2p/p2p_network.d.ts +9 -10
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +38 -20
- package/dest/e2e_p2p/reqresp/utils.d.ts +22 -0
- package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -0
- package/dest/e2e_p2p/reqresp/utils.js +190 -0
- package/dest/e2e_p2p/shared.d.ts +26 -8
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +56 -47
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
- package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -2
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +19 -9
- package/dest/fixtures/authwit_proxy.d.ts +15 -0
- package/dest/fixtures/authwit_proxy.d.ts.map +1 -0
- package/dest/fixtures/authwit_proxy.js +34 -0
- package/dest/fixtures/e2e_prover_test.d.ts +7 -6
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +38 -50
- package/dest/fixtures/elu_monitor.d.ts +21 -0
- package/dest/fixtures/elu_monitor.d.ts.map +1 -0
- package/dest/fixtures/elu_monitor.js +102 -0
- package/dest/fixtures/fixtures.d.ts +5 -1
- package/dest/fixtures/fixtures.d.ts.map +1 -1
- package/dest/fixtures/fixtures.js +6 -0
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +5 -5
- package/dest/fixtures/ha_setup.d.ts +71 -0
- package/dest/fixtures/ha_setup.d.ts.map +1 -0
- package/dest/fixtures/ha_setup.js +116 -0
- package/dest/fixtures/index.d.ts +2 -1
- package/dest/fixtures/index.d.ts.map +1 -1
- package/dest/fixtures/index.js +1 -0
- package/dest/fixtures/setup.d.ts +55 -31
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +97 -176
- package/dest/fixtures/setup_p2p_test.d.ts +18 -11
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +43 -32
- package/dest/fixtures/token_utils.d.ts +2 -2
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +5 -7
- package/dest/legacy-jest-resolver.d.cts +3 -0
- package/dest/legacy-jest-resolver.d.cts.map +1 -0
- package/dest/shared/cross_chain_test_harness.d.ts +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -13
- package/dest/shared/gas_portal_test_harness.js +2 -2
- package/dest/shared/index.d.ts +2 -1
- package/dest/shared/index.d.ts.map +1 -1
- package/dest/shared/index.js +1 -0
- package/dest/shared/jest_setup.js +41 -1
- package/dest/shared/mock_state_view.d.ts +86 -0
- package/dest/shared/mock_state_view.d.ts.map +1 -0
- package/dest/shared/mock_state_view.js +186 -0
- package/dest/shared/submit-transactions.d.ts +2 -2
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +16 -17
- package/dest/simulators/lending_simulator.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +4 -4
- package/dest/simulators/token_simulator.d.ts +1 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +3 -24
- package/dest/spartan/setup_test_wallets.d.ts +12 -3
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +100 -39
- package/dest/spartan/tx_metrics.d.ts +35 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +151 -1
- package/dest/spartan/utils/bot.d.ts +3 -2
- package/dest/spartan/utils/bot.d.ts.map +1 -1
- package/dest/spartan/utils/bot.js +2 -1
- package/dest/spartan/utils/config.d.ts +10 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +4 -1
- package/dest/spartan/utils/index.d.ts +6 -4
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +6 -2
- package/dest/spartan/utils/k8s.d.ts +31 -1
- package/dest/spartan/utils/k8s.d.ts.map +1 -1
- package/dest/spartan/utils/k8s.js +124 -0
- package/dest/spartan/utils/nodes.d.ts +14 -5
- package/dest/spartan/utils/nodes.d.ts.map +1 -1
- package/dest/spartan/utils/nodes.js +204 -33
- package/dest/spartan/utils/pod_logs.d.ts +25 -0
- package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
- package/dest/spartan/utils/pod_logs.js +74 -0
- package/dest/spartan/utils/scripts.d.ts +18 -4
- package/dest/spartan/utils/scripts.d.ts.map +1 -1
- package/dest/spartan/utils/scripts.js +19 -4
- package/dest/test-wallet/test_wallet.d.ts +84 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +249 -0
- package/dest/test-wallet/utils.d.ts +41 -0
- package/dest/test-wallet/utils.d.ts.map +1 -0
- package/dest/test-wallet/utils.js +71 -0
- package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
- package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
- package/dest/test-wallet/wallet_worker_script.js +48 -0
- package/dest/test-wallet/worker_wallet.d.ts +52 -0
- package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet.js +151 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
- package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
- package/dest/test-wallet/worker_wallet_schema.js +10 -0
- package/package.json +46 -43
- package/src/bench/client_flows/client_flows_benchmark.ts +31 -18
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +8 -3
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +31 -21
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +7 -8
- package/src/e2e_deploy_contract/deploy_test.ts +3 -3
- package/src/e2e_epochs/epochs_test.ts +115 -72
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +21 -29
- package/src/e2e_l1_publisher/write_json.ts +1 -6
- package/src/e2e_nested_contract/nested_contract_test.ts +7 -5
- package/src/e2e_p2p/inactivity_slash_test.ts +7 -7
- package/src/e2e_p2p/p2p_network.ts +58 -37
- package/src/e2e_p2p/reqresp/utils.ts +256 -0
- package/src/e2e_p2p/shared.ts +84 -62
- package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
- package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
- package/src/e2e_token_contract/token_contract_test.ts +26 -9
- package/src/fixtures/authwit_proxy.ts +54 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +47 -56
- package/src/fixtures/elu_monitor.ts +126 -0
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/get_bb_config.ts +7 -6
- package/src/fixtures/ha_setup.ts +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +132 -239
- package/src/fixtures/setup_p2p_test.ts +48 -52
- package/src/fixtures/token_utils.ts +3 -3
- package/src/guides/up_quick_start.sh +3 -3
- package/src/legacy-jest-resolver.cjs +135 -0
- package/src/shared/cross_chain_test_harness.ts +13 -9
- package/src/shared/gas_portal_test_harness.ts +1 -1
- package/src/shared/index.ts +1 -0
- package/src/shared/jest_setup.ts +51 -1
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +3 -2
- package/src/shared/uniswap_l1_l2.ts +38 -33
- package/src/simulators/lending_simulator.ts +8 -4
- package/src/simulators/token_simulator.ts +6 -30
- package/src/spartan/setup_test_wallets.ts +141 -32
- package/src/spartan/tx_metrics.ts +127 -1
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/config.ts +3 -0
- package/src/spartan/utils/index.ts +10 -1
- package/src/spartan/utils/k8s.ts +160 -0
- package/src/spartan/utils/nodes.ts +251 -31
- package/src/spartan/utils/pod_logs.ts +99 -0
- package/src/spartan/utils/scripts.ts +43 -7
- package/src/test-wallet/test_wallet.ts +351 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +60 -0
- package/src/test-wallet/worker_wallet.ts +214 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { NO_FROM } from '@aztec/aztec.js/account';
|
|
2
3
|
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
3
4
|
import { NO_WAIT } from '@aztec/aztec.js/contracts';
|
|
4
5
|
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
@@ -10,14 +11,17 @@ import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
|
10
11
|
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
11
12
|
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
12
13
|
import type { Logger } from '@aztec/foundation/log';
|
|
13
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
14
|
+
import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
|
|
14
15
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
15
16
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
16
|
-
import {
|
|
17
|
+
import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
|
|
17
18
|
|
|
18
19
|
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
|
|
19
20
|
import { getBBConfig } from '../fixtures/get_bb_config.js';
|
|
20
21
|
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
|
|
22
|
+
import { TestWallet } from '../test-wallet/test_wallet.js';
|
|
23
|
+
import { proveInteraction } from '../test-wallet/utils.js';
|
|
24
|
+
import { WorkerWallet } from '../test-wallet/worker_wallet.js';
|
|
21
25
|
|
|
22
26
|
export interface TestAccounts {
|
|
23
27
|
aztecNode: AztecNode;
|
|
@@ -85,11 +89,19 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
85
89
|
|
|
86
90
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
87
91
|
const recipientDeployMethod = await recipientAccount.getDeployMethod();
|
|
88
|
-
await recipientDeployMethod.send({
|
|
92
|
+
await recipientDeployMethod.send({
|
|
93
|
+
from: NO_FROM,
|
|
94
|
+
fee: { paymentMethod },
|
|
95
|
+
wait: { timeout: 2400 },
|
|
96
|
+
});
|
|
89
97
|
await Promise.all(
|
|
90
98
|
fundedAccounts.map(async a => {
|
|
91
99
|
const deployMethod = await a.getDeployMethod();
|
|
92
|
-
await deployMethod.send({
|
|
100
|
+
await deployMethod.send({
|
|
101
|
+
from: NO_FROM,
|
|
102
|
+
fee: { paymentMethod },
|
|
103
|
+
wait: { timeout: 2400 },
|
|
104
|
+
}); // increase timeout on purpose in order to account for two empty epochs
|
|
93
105
|
logger.info(`Account deployed at ${a.address}`);
|
|
94
106
|
}),
|
|
95
107
|
);
|
|
@@ -118,49 +130,91 @@ export async function deploySponsoredTestAccountsWithTokens(
|
|
|
118
130
|
}
|
|
119
131
|
|
|
120
132
|
async function deployAccountWithDiagnostics(
|
|
121
|
-
account: { getDeployMethod: () => Promise<{ send: (opts: any) => any }>; address: any },
|
|
133
|
+
account: { getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>; address: any },
|
|
122
134
|
paymentMethod: SponsoredFeePaymentMethod,
|
|
123
135
|
aztecNode: AztecNode,
|
|
124
136
|
logger: Logger,
|
|
125
137
|
accountLabel: string,
|
|
138
|
+
estimateGas?: boolean,
|
|
126
139
|
): Promise<void> {
|
|
127
140
|
const deployMethod = await account.getDeployMethod();
|
|
128
|
-
let
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
logger.info(`${accountLabel}
|
|
133
|
-
} catch (error) {
|
|
134
|
-
const blockNumber = await aztecNode.getBlockNumber();
|
|
135
|
-
let receipt;
|
|
136
|
-
try {
|
|
137
|
-
receipt = await aztecNode.getTxReceipt(txHash);
|
|
138
|
-
} catch {
|
|
139
|
-
receipt = 'unavailable';
|
|
140
|
-
}
|
|
141
|
-
logger.error(`${accountLabel} deployment failed`, {
|
|
142
|
-
txHash: txHash.toString(),
|
|
143
|
-
receipt: JSON.stringify(receipt),
|
|
144
|
-
currentBlockNumber: blockNumber,
|
|
145
|
-
error: String(error),
|
|
146
|
-
});
|
|
147
|
-
throw error;
|
|
141
|
+
let gasSettings: any;
|
|
142
|
+
if (estimateGas) {
|
|
143
|
+
const sim = await deployMethod.simulate({ from: NO_FROM, fee: { paymentMethod } });
|
|
144
|
+
gasSettings = sim.estimatedGas;
|
|
145
|
+
logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
|
|
148
146
|
}
|
|
147
|
+
|
|
148
|
+
// Track the tx hash across retries so we don't re-send when the previous tx is still pending.
|
|
149
|
+
let sentTxHash: { txHash: any } | undefined;
|
|
150
|
+
|
|
151
|
+
await retry(
|
|
152
|
+
async () => {
|
|
153
|
+
// Check if already deployed (handles case where previous attempt succeeded but waitForTx timed out)
|
|
154
|
+
const existing = await aztecNode.getContract(account.address);
|
|
155
|
+
if (existing) {
|
|
156
|
+
logger.info(`${accountLabel} already deployed at ${account.address}, skipping`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// If we already sent a tx, check if it was dropped before deciding to re-send.
|
|
161
|
+
if (sentTxHash) {
|
|
162
|
+
const prevReceipt = await aztecNode.getTxReceipt(sentTxHash.txHash);
|
|
163
|
+
if (prevReceipt.isDropped()) {
|
|
164
|
+
logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} was dropped, re-sending`);
|
|
165
|
+
sentTxHash = undefined;
|
|
166
|
+
} else {
|
|
167
|
+
logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} still pending, waiting again...`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!sentTxHash) {
|
|
172
|
+
const deployResult = await deployMethod.send({
|
|
173
|
+
from: NO_FROM,
|
|
174
|
+
fee: { paymentMethod, gasSettings },
|
|
175
|
+
wait: NO_WAIT,
|
|
176
|
+
});
|
|
177
|
+
sentTxHash = { txHash: deployResult.txHash };
|
|
178
|
+
logger.info(`${accountLabel} tx sent`, { txHash: sentTxHash.txHash.toString() });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const receipt = await waitForTx(aztecNode, sentTxHash.txHash, { timeout: 600 });
|
|
182
|
+
if (receipt.isDropped()) {
|
|
183
|
+
sentTxHash = undefined;
|
|
184
|
+
throw new Error(`${accountLabel} tx was dropped, retrying...`);
|
|
185
|
+
}
|
|
186
|
+
logger.info(`${accountLabel} deployed at ${account.address}`);
|
|
187
|
+
},
|
|
188
|
+
`deploy ${accountLabel}`,
|
|
189
|
+
makeBackoff([1, 2, 4, 8, 16]),
|
|
190
|
+
logger,
|
|
191
|
+
);
|
|
149
192
|
}
|
|
150
193
|
|
|
151
194
|
async function deployAccountsInBatches(
|
|
152
|
-
accounts: {
|
|
195
|
+
accounts: {
|
|
196
|
+
getDeployMethod: () => Promise<{ simulate: (opts: any) => any; send: (opts: any) => any }>;
|
|
197
|
+
address: any;
|
|
198
|
+
}[],
|
|
153
199
|
paymentMethod: SponsoredFeePaymentMethod,
|
|
154
200
|
aztecNode: AztecNode,
|
|
155
201
|
logger: Logger,
|
|
156
202
|
labelPrefix: string,
|
|
157
203
|
batchSize = 2,
|
|
204
|
+
estimateGas?: boolean,
|
|
158
205
|
): Promise<void> {
|
|
159
206
|
for (let i = 0; i < accounts.length; i += batchSize) {
|
|
160
207
|
const batch = accounts.slice(i, i + batchSize);
|
|
161
208
|
await Promise.all(
|
|
162
209
|
batch.map((account, idx) =>
|
|
163
|
-
deployAccountWithDiagnostics(
|
|
210
|
+
deployAccountWithDiagnostics(
|
|
211
|
+
account,
|
|
212
|
+
paymentMethod,
|
|
213
|
+
aztecNode,
|
|
214
|
+
logger,
|
|
215
|
+
`${labelPrefix}${i + idx + 1}`,
|
|
216
|
+
estimateGas,
|
|
217
|
+
),
|
|
164
218
|
),
|
|
165
219
|
);
|
|
166
220
|
}
|
|
@@ -171,6 +225,7 @@ export async function deploySponsoredTestAccounts(
|
|
|
171
225
|
aztecNode: AztecNode,
|
|
172
226
|
logger: Logger,
|
|
173
227
|
numberOfFundedWallets = 1,
|
|
228
|
+
opts?: { estimateGas?: boolean },
|
|
174
229
|
): Promise<TestAccountsWithoutTokens> {
|
|
175
230
|
const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
|
|
176
231
|
const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
|
|
@@ -180,8 +235,23 @@ export async function deploySponsoredTestAccounts(
|
|
|
180
235
|
|
|
181
236
|
const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
|
|
182
237
|
|
|
183
|
-
await deployAccountWithDiagnostics(
|
|
184
|
-
|
|
238
|
+
await deployAccountWithDiagnostics(
|
|
239
|
+
recipientAccount,
|
|
240
|
+
paymentMethod,
|
|
241
|
+
aztecNode,
|
|
242
|
+
logger,
|
|
243
|
+
'Recipient account',
|
|
244
|
+
opts?.estimateGas,
|
|
245
|
+
);
|
|
246
|
+
await deployAccountsInBatches(
|
|
247
|
+
fundedAccounts,
|
|
248
|
+
paymentMethod,
|
|
249
|
+
aztecNode,
|
|
250
|
+
logger,
|
|
251
|
+
'Funded account ',
|
|
252
|
+
2,
|
|
253
|
+
opts?.estimateGas,
|
|
254
|
+
);
|
|
185
255
|
|
|
186
256
|
return {
|
|
187
257
|
aztecNode,
|
|
@@ -219,7 +289,7 @@ export async function deployTestAccountsWithTokens(
|
|
|
219
289
|
fundedAccounts.map(async (a, i) => {
|
|
220
290
|
const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
|
|
221
291
|
const deployMethod = await a.getDeployMethod();
|
|
222
|
-
await deployMethod.send({ from:
|
|
292
|
+
await deployMethod.send({ from: NO_FROM, fee: { paymentMethod } });
|
|
223
293
|
logger.info(`Account deployed at ${a.address}`);
|
|
224
294
|
}),
|
|
225
295
|
);
|
|
@@ -263,7 +333,7 @@ async function bridgeL1FeeJuice(
|
|
|
263
333
|
const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
|
|
264
334
|
|
|
265
335
|
const isSynced = async () =>
|
|
266
|
-
(await aztecNode.
|
|
336
|
+
(await aztecNode.getL1ToL2MessageCheckpoint(Fr.fromHexString(claim.messageHash))) !== undefined;
|
|
267
337
|
await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
|
|
268
338
|
|
|
269
339
|
log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
|
|
@@ -306,7 +376,7 @@ async function deployTokenAndMint(
|
|
|
306
376
|
fee: {
|
|
307
377
|
paymentMethod,
|
|
308
378
|
},
|
|
309
|
-
wait: { timeout: 600
|
|
379
|
+
wait: { timeout: 600 },
|
|
310
380
|
});
|
|
311
381
|
|
|
312
382
|
const tokenAddress = tokenContract.address;
|
|
@@ -395,3 +465,42 @@ export async function createWalletAndAztecNodeClient(
|
|
|
395
465
|
},
|
|
396
466
|
};
|
|
397
467
|
}
|
|
468
|
+
|
|
469
|
+
export type WorkerWalletWrapper = {
|
|
470
|
+
wallet: WorkerWallet;
|
|
471
|
+
aztecNode: AztecNode;
|
|
472
|
+
cleanup: () => Promise<void>;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
export async function createWorkerWalletClient(
|
|
476
|
+
nodeUrl: string,
|
|
477
|
+
proverEnabled: boolean,
|
|
478
|
+
logger: Logger,
|
|
479
|
+
): Promise<WorkerWalletWrapper> {
|
|
480
|
+
const aztecNode = createAztecNodeClient(nodeUrl);
|
|
481
|
+
const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
|
|
482
|
+
|
|
483
|
+
// Strip cleanup functions — they can't be structured-cloned for worker transfer
|
|
484
|
+
const { cleanup: bbCleanup, ...bbPaths } = bbConfig ?? {};
|
|
485
|
+
const { cleanup: acvmCleanup, ...acvmPaths } = acvmConfig ?? {};
|
|
486
|
+
|
|
487
|
+
const pxeConfig = {
|
|
488
|
+
dataDirectory: undefined,
|
|
489
|
+
dataStoreMapSizeKb: 1024 * 1024,
|
|
490
|
+
...bbPaths,
|
|
491
|
+
...acvmPaths,
|
|
492
|
+
proverEnabled,
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
const wallet = await WorkerWallet.create(nodeUrl, pxeConfig);
|
|
496
|
+
|
|
497
|
+
return {
|
|
498
|
+
wallet,
|
|
499
|
+
aztecNode,
|
|
500
|
+
async cleanup() {
|
|
501
|
+
await wallet.stop();
|
|
502
|
+
await bbCleanup?.();
|
|
503
|
+
await acvmCleanup?.();
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
}
|
|
@@ -6,6 +6,132 @@ import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
|
|
|
6
6
|
|
|
7
7
|
import { createHistogram } from 'perf_hooks';
|
|
8
8
|
|
|
9
|
+
/** Metrics class for proving-related benchmarks. */
|
|
10
|
+
export class ProvingMetrics {
|
|
11
|
+
private successfulTxs: number | undefined;
|
|
12
|
+
private proofDuration: number | undefined;
|
|
13
|
+
private activeAgents: number | undefined;
|
|
14
|
+
private avgQueueTime: number | undefined;
|
|
15
|
+
private jobRetries: number | undefined;
|
|
16
|
+
private jobDuration: number | undefined;
|
|
17
|
+
private timedOutJobs: number | undefined;
|
|
18
|
+
private resolvedJobs: number | undefined;
|
|
19
|
+
private rejectedJobs: number | undefined;
|
|
20
|
+
private epochProvingDuration: number | undefined;
|
|
21
|
+
private provenTransactions: number | undefined;
|
|
22
|
+
private provenBlocks: number | undefined;
|
|
23
|
+
|
|
24
|
+
constructor(private prefix: string) {}
|
|
25
|
+
|
|
26
|
+
recordSuccessfulTxs(count: number): void {
|
|
27
|
+
this.successfulTxs = count;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
recordProofDuration(seconds: number): void {
|
|
31
|
+
this.proofDuration = seconds;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
recordActiveAgents(count: number): void {
|
|
35
|
+
this.activeAgents = count;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
recordAvgQueueTime(ms: number): void {
|
|
39
|
+
this.avgQueueTime = ms;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
recordJobRetries(count: number): void {
|
|
43
|
+
this.jobRetries = count;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
recordJobDuration(ms: number): void {
|
|
47
|
+
this.jobDuration = ms;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
recordTimedOutJobs(count: number): void {
|
|
51
|
+
this.timedOutJobs = count;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
recordResolvedJobs(count: number): void {
|
|
55
|
+
this.resolvedJobs = count;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
recordRejectedJobs(count: number): void {
|
|
59
|
+
this.rejectedJobs = count;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
recordEpochProvingDuration(seconds: number): void {
|
|
63
|
+
this.epochProvingDuration = seconds;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
recordProvenTransactions(count: number): void {
|
|
67
|
+
this.provenTransactions = count;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
recordProvenBlocks(count: number): void {
|
|
71
|
+
this.provenBlocks = count;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
toGithubActionBenchmarkJSON(): Array<{ name: string; unit: string; value: number }> {
|
|
75
|
+
const data: Array<{ name: string; unit: string; value: number }> = [];
|
|
76
|
+
|
|
77
|
+
if (this.successfulTxs !== undefined) {
|
|
78
|
+
data.push({ name: `${this.prefix}/successful_txs`, unit: 'count', value: this.successfulTxs });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (this.proofDuration !== undefined) {
|
|
82
|
+
data.push({ name: `${this.prefix}/proof_duration`, unit: 's', value: this.proofDuration });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this.activeAgents !== undefined) {
|
|
86
|
+
data.push({ name: `${this.prefix}/active_agents`, unit: 'count', value: this.activeAgents });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.avgQueueTime !== undefined) {
|
|
90
|
+
data.push({ name: `${this.prefix}/avg_queue_time`, unit: 'ms', value: this.avgQueueTime });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.jobRetries !== undefined) {
|
|
94
|
+
data.push({ name: `${this.prefix}/job_retries`, unit: 'count', value: this.jobRetries });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.jobDuration !== undefined) {
|
|
98
|
+
data.push({ name: `${this.prefix}/job_duration`, unit: 'ms', value: this.jobDuration });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (this.timedOutJobs !== undefined) {
|
|
102
|
+
data.push({ name: `${this.prefix}/timed_out_jobs`, unit: 'count', value: this.timedOutJobs });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.resolvedJobs !== undefined) {
|
|
106
|
+
data.push({ name: `${this.prefix}/resolved_jobs`, unit: 'count', value: this.resolvedJobs });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (this.rejectedJobs !== undefined) {
|
|
110
|
+
data.push({ name: `${this.prefix}/rejected_jobs`, unit: 'count', value: this.rejectedJobs });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (this.epochProvingDuration !== undefined) {
|
|
114
|
+
data.push({ name: `${this.prefix}/epoch_proving_duration`, unit: 's', value: this.epochProvingDuration });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (this.provenTransactions !== undefined) {
|
|
118
|
+
data.push({ name: `${this.prefix}/proven_transactions`, unit: 'count', value: this.provenTransactions });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.provenBlocks !== undefined) {
|
|
122
|
+
data.push({ name: `${this.prefix}/proven_blocks`, unit: 'count', value: this.provenBlocks });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const scenario = process.env.BENCH_SCENARIO?.trim();
|
|
126
|
+
if (!scenario) {
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const scenarioPrefix = `scenario/${scenario}/`;
|
|
131
|
+
return data.map(entry => ({ ...entry, name: `${scenarioPrefix}${entry.name}` }));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
9
135
|
export type TxInclusionData = {
|
|
10
136
|
txHash: string;
|
|
11
137
|
sentAt: number;
|
|
@@ -170,7 +296,7 @@ export class TxInclusionMetrics {
|
|
|
170
296
|
value: stats.mean,
|
|
171
297
|
},
|
|
172
298
|
{
|
|
173
|
-
name: `${group}/
|
|
299
|
+
name: `${group}/p50_inclusion`,
|
|
174
300
|
unit: 's',
|
|
175
301
|
value: stats.median,
|
|
176
302
|
},
|
package/src/spartan/utils/bot.ts
CHANGED
|
@@ -34,7 +34,8 @@ export async function installTransferBot({
|
|
|
34
34
|
logger: log,
|
|
35
35
|
replicas = 1,
|
|
36
36
|
txIntervalSeconds = 10,
|
|
37
|
-
followChain = '
|
|
37
|
+
followChain = 'CHECKPOINTED',
|
|
38
|
+
pxeSyncChainTip = 'proposed',
|
|
38
39
|
mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
|
|
39
40
|
mnemonicStartIndex,
|
|
40
41
|
botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
|
|
@@ -49,6 +50,7 @@ export async function installTransferBot({
|
|
|
49
50
|
replicas?: number;
|
|
50
51
|
txIntervalSeconds?: number;
|
|
51
52
|
followChain?: string;
|
|
53
|
+
pxeSyncChainTip?: string;
|
|
52
54
|
mnemonic?: string;
|
|
53
55
|
mnemonicStartIndex?: number | string;
|
|
54
56
|
botPrivateKey?: string;
|
|
@@ -67,6 +69,7 @@ export async function installTransferBot({
|
|
|
67
69
|
'bot.replicaCount': replicas,
|
|
68
70
|
'bot.txIntervalSeconds': txIntervalSeconds,
|
|
69
71
|
'bot.followChain': followChain,
|
|
72
|
+
'bot.pxeSyncChainTip': pxeSyncChainTip,
|
|
70
73
|
'bot.botPrivateKey': botPrivateKey,
|
|
71
74
|
'bot.nodeUrl': resolvedNodeUrl,
|
|
72
75
|
'bot.mnemonic': mnemonic,
|
|
@@ -8,6 +8,7 @@ const logger = createLogger('e2e:k8s-utils');
|
|
|
8
8
|
const testConfigSchema = z.object({
|
|
9
9
|
NAMESPACE: z.string().default('scenario'),
|
|
10
10
|
REAL_VERIFIER: schemas.Boolean.optional().default(true),
|
|
11
|
+
DEBUG_FORCE_TX_PROOF_VERIFICATION: schemas.Boolean.optional().default(true),
|
|
11
12
|
CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
|
|
12
13
|
L1_RPC_URLS_JSON: z.string().optional(),
|
|
13
14
|
L1_ACCOUNT_MNEMONIC: z.string().optional(),
|
|
@@ -15,6 +16,8 @@ const testConfigSchema = z.object({
|
|
|
15
16
|
AZTEC_EPOCH_DURATION: z.coerce.number().optional().default(32),
|
|
16
17
|
AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
|
|
17
18
|
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: z.coerce.number().optional().default(2),
|
|
19
|
+
FUNDING_PRIVATE_KEY: z.string().optional(),
|
|
20
|
+
AZTEC_ADMIN_API_KEY: z.string().optional(),
|
|
18
21
|
});
|
|
19
22
|
|
|
20
23
|
export type TestConfig = z.infer<typeof testConfigSchema>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
export { type TestConfig, setupEnvironment } from './config.js';
|
|
6
6
|
|
|
7
7
|
// Scripts
|
|
8
|
-
export { getGitProjectRoot, getAztecBin, runAztecBin, runProjectScript } from './scripts.js';
|
|
8
|
+
export { type ScriptResult, getGitProjectRoot, getAztecBin, runAztecBin, runProjectScript } from './scripts.js';
|
|
9
9
|
|
|
10
10
|
// K8s operations
|
|
11
11
|
export {
|
|
@@ -24,6 +24,8 @@ export {
|
|
|
24
24
|
getServiceEndpoint,
|
|
25
25
|
getRPCEndpoint,
|
|
26
26
|
getEthereumEndpoint,
|
|
27
|
+
createResilientPrometheusConnection,
|
|
28
|
+
scaleProverAgents,
|
|
27
29
|
} from './k8s.js';
|
|
28
30
|
|
|
29
31
|
// Chaos Mesh
|
|
@@ -39,12 +41,16 @@ export {
|
|
|
39
41
|
applyNetworkShaping,
|
|
40
42
|
} from './chaos.js';
|
|
41
43
|
|
|
44
|
+
// Helm
|
|
45
|
+
export { hasDeployedHelmRelease } from './helm.js';
|
|
46
|
+
|
|
42
47
|
// Bot management
|
|
43
48
|
export { restartBot, installTransferBot, uninstallTransferBot } from './bot.js';
|
|
44
49
|
|
|
45
50
|
// Node operations (sequencers, validators, pods)
|
|
46
51
|
export {
|
|
47
52
|
awaitCheckpointNumber,
|
|
53
|
+
waitForProvenToAdvance,
|
|
48
54
|
getSequencers,
|
|
49
55
|
updateSequencersConfig,
|
|
50
56
|
getSequencersConfig,
|
|
@@ -60,3 +66,6 @@ export { getPublicViemClient, getL1DeploymentAddresses, getNodeClient } from './
|
|
|
60
66
|
|
|
61
67
|
// Health checks
|
|
62
68
|
export { ChainHealth, type ChainHealthSnapshot } from './health.js';
|
|
69
|
+
|
|
70
|
+
// Pod log extraction
|
|
71
|
+
export { type BlockBuiltLogEntry, fetchBlockBuiltLogs } from './pod_logs.js';
|
package/src/spartan/utils/k8s.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
3
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
3
4
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
5
|
|
|
@@ -6,6 +7,8 @@ import { type ChildProcess, exec, spawn } from 'child_process';
|
|
|
6
7
|
import path from 'path';
|
|
7
8
|
import { promisify } from 'util';
|
|
8
9
|
|
|
10
|
+
import { AlertTriggeredError, GrafanaClient } from '../../quality_of_service/grafana_client.js';
|
|
11
|
+
|
|
9
12
|
const execAsync = promisify(exec);
|
|
10
13
|
|
|
11
14
|
const logger = createLogger('e2e:k8s-utils');
|
|
@@ -370,6 +373,163 @@ export async function waitForResourcesByName({
|
|
|
370
373
|
);
|
|
371
374
|
}
|
|
372
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Waits for all StatefulSets matching a label to have all their replicas ready.
|
|
378
|
+
*
|
|
379
|
+
* @param namespace - Kubernetes namespace
|
|
380
|
+
* @param label - Label selector for StatefulSets (e.g., "app.kubernetes.io/component=sequencer-node")
|
|
381
|
+
* @param timeoutSeconds - Maximum time to wait in seconds
|
|
382
|
+
* @param pollIntervalSeconds - How often to check status
|
|
383
|
+
*/
|
|
384
|
+
export async function waitForStatefulSetsReady({
|
|
385
|
+
namespace,
|
|
386
|
+
label,
|
|
387
|
+
timeoutSeconds = 600,
|
|
388
|
+
pollIntervalSeconds = 5,
|
|
389
|
+
}: {
|
|
390
|
+
namespace: string;
|
|
391
|
+
label: string;
|
|
392
|
+
timeoutSeconds?: number;
|
|
393
|
+
pollIntervalSeconds?: number;
|
|
394
|
+
}): Promise<void> {
|
|
395
|
+
logger.info(`Waiting for StatefulSets with label ${label} to have all replicas ready (timeout: ${timeoutSeconds}s)`);
|
|
396
|
+
|
|
397
|
+
await retryUntil(
|
|
398
|
+
async () => {
|
|
399
|
+
// Get all StatefulSets matching the label
|
|
400
|
+
const getCmd = `kubectl get statefulset -l ${label} -n ${namespace} -o json`;
|
|
401
|
+
const { stdout } = await execAsync(getCmd);
|
|
402
|
+
const result = JSON.parse(stdout);
|
|
403
|
+
|
|
404
|
+
if (!result.items || result.items.length === 0) {
|
|
405
|
+
logger.verbose(`No StatefulSets found with label ${label}`);
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Check each StatefulSet
|
|
410
|
+
for (const sts of result.items) {
|
|
411
|
+
const name = sts.metadata.name;
|
|
412
|
+
const desired = sts.spec.replicas ?? 0;
|
|
413
|
+
const ready = sts.status.readyReplicas ?? 0;
|
|
414
|
+
const updated = sts.status.updatedReplicas ?? 0;
|
|
415
|
+
|
|
416
|
+
if (ready < desired || updated < desired) {
|
|
417
|
+
logger.verbose(`StatefulSet ${name}: ${ready}/${desired} ready, ${updated}/${desired} updated`);
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
logger.info(`All StatefulSets with label ${label} are ready`);
|
|
423
|
+
return true;
|
|
424
|
+
},
|
|
425
|
+
`StatefulSets with label ${label} to be ready`,
|
|
426
|
+
timeoutSeconds,
|
|
427
|
+
pollIntervalSeconds,
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Creates a Prometheus connection that can re-establish port-forward on failure.
|
|
433
|
+
* Returns functions to connect and run alert checks that automatically reconnect if needed.
|
|
434
|
+
*
|
|
435
|
+
* @param namespace - K8s namespace to fall back to if metrics namespace doesn't have Prometheus
|
|
436
|
+
* @param endpoints - Array to track created endpoints for cleanup
|
|
437
|
+
* @param log - Logger instance
|
|
438
|
+
*/
|
|
439
|
+
export function createResilientPrometheusConnection(
|
|
440
|
+
namespace: string,
|
|
441
|
+
endpoints: ServiceEndpoint[],
|
|
442
|
+
log: Logger,
|
|
443
|
+
): {
|
|
444
|
+
connect: () => Promise<GrafanaClient>;
|
|
445
|
+
runAlertCheck: (alerts: Parameters<GrafanaClient['runAlertCheck']>[0]) => Promise<void>;
|
|
446
|
+
} {
|
|
447
|
+
let alertChecker: GrafanaClient | undefined;
|
|
448
|
+
let currentEndpoint: ServiceEndpoint | undefined;
|
|
449
|
+
|
|
450
|
+
const connect = async (): Promise<GrafanaClient> => {
|
|
451
|
+
// Kill existing connection if any
|
|
452
|
+
if (currentEndpoint?.process) {
|
|
453
|
+
currentEndpoint.process.kill();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Try metrics namespace first, then network namespace
|
|
457
|
+
let promPort = 0;
|
|
458
|
+
let promUrl = '';
|
|
459
|
+
let promProc: ChildProcess | undefined;
|
|
460
|
+
|
|
461
|
+
try {
|
|
462
|
+
const metricsResult = await startPortForward({
|
|
463
|
+
resource: `svc/metrics-prometheus-server`,
|
|
464
|
+
namespace: 'metrics',
|
|
465
|
+
containerPort: 80,
|
|
466
|
+
});
|
|
467
|
+
promProc = metricsResult.process;
|
|
468
|
+
promPort = metricsResult.port;
|
|
469
|
+
promUrl = `http://127.0.0.1:${promPort}/api/v1`;
|
|
470
|
+
} catch {
|
|
471
|
+
// Metrics namespace might not have Prometheus, try network namespace
|
|
472
|
+
log.verbose('Metrics namespace Prometheus not available, trying network namespace');
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (promPort === 0) {
|
|
476
|
+
const nsResult = await startPortForward({
|
|
477
|
+
resource: `svc/prometheus-server`,
|
|
478
|
+
namespace,
|
|
479
|
+
containerPort: 80,
|
|
480
|
+
});
|
|
481
|
+
promProc = nsResult.process;
|
|
482
|
+
promPort = nsResult.port;
|
|
483
|
+
promUrl = `http://127.0.0.1:${promPort}/api/v1`;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (!promProc || promPort === 0) {
|
|
487
|
+
throw new Error('Unable to port-forward to Prometheus');
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
currentEndpoint = { url: promUrl, process: promProc };
|
|
491
|
+
endpoints.push(currentEndpoint);
|
|
492
|
+
alertChecker = new GrafanaClient(log, { grafanaEndpoint: promUrl, grafanaCredentials: '' });
|
|
493
|
+
log.info(`Established Prometheus connection at ${promUrl}`);
|
|
494
|
+
return alertChecker;
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
const runAlertCheck = async (alerts: Parameters<GrafanaClient['runAlertCheck']>[0]): Promise<void> => {
|
|
498
|
+
if (!alertChecker) {
|
|
499
|
+
alertChecker = await connect();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
try {
|
|
503
|
+
await alertChecker.runAlertCheck(alerts);
|
|
504
|
+
} catch (err) {
|
|
505
|
+
// If it's an AlertTriggeredError (expected behavior)
|
|
506
|
+
if (err instanceof AlertTriggeredError) {
|
|
507
|
+
throw err;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Check if it's a connection error (port-forward died)
|
|
511
|
+
const errorStr = String(err);
|
|
512
|
+
if (errorStr.includes('fetch failed') || errorStr.includes('ECONNREFUSED') || errorStr.includes('ECONNRESET')) {
|
|
513
|
+
log.warn(`Prometheus connection lost, re-establishing port-forward...`);
|
|
514
|
+
alertChecker = await connect();
|
|
515
|
+
await alertChecker.runAlertCheck(alerts);
|
|
516
|
+
} else {
|
|
517
|
+
throw err;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
return { connect, runAlertCheck };
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** Scales the prover-agent Deployment to the given number of replicas. */
|
|
526
|
+
export async function scaleProverAgents(namespace: string, replicas: number, log: Logger): Promise<void> {
|
|
527
|
+
const label = 'app.kubernetes.io/component=prover-agent';
|
|
528
|
+
const command = `kubectl scale deployment -l ${label} -n ${namespace} --replicas=${replicas} --timeout=2m`;
|
|
529
|
+
log.info(`Scaling prover agents to ${replicas}: ${command}`);
|
|
530
|
+
await execAsync(command);
|
|
531
|
+
}
|
|
532
|
+
|
|
373
533
|
export function getChartDir(spartanDir: string, chartName: string) {
|
|
374
534
|
return path.join(spartanDir.trim(), chartName);
|
|
375
535
|
}
|