@aztec/end-to-end 0.0.1-commit.1bea0213 → 0.0.1-commit.217f559981
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/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 +3 -3
- 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/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +4 -2
- 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 +10 -0
- 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 +15 -7
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +85 -41
- 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 +5 -5
- 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_p2p/p2p_network.d.ts +2 -2
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +16 -2
- 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 +177 -0
- package/dest/e2e_p2p/shared.d.ts +2 -2
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +7 -3
- 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 +10 -0
- 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 +30 -0
- package/dest/fixtures/e2e_prover_test.d.ts +4 -4
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +28 -35
- 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/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 +41 -24
- package/dest/fixtures/setup.d.ts.map +1 -1
- package/dest/fixtures/setup.js +79 -164
- package/dest/fixtures/setup_p2p_test.d.ts +16 -9
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +40 -29
- 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 +3 -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/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/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 +8 -6
- 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 +2 -23
- package/dest/spartan/setup_test_wallets.d.ts +9 -2
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +31 -1
- 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 +150 -0
- 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 +4 -1
- package/dest/spartan/utils/config.d.ts.map +1 -1
- package/dest/spartan/utils/config.js +2 -1
- package/dest/spartan/utils/index.d.ts +4 -4
- package/dest/spartan/utils/index.d.ts.map +1 -1
- package/dest/spartan/utils/index.js +2 -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 +202 -32
- 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 +83 -0
- package/dest/test-wallet/test_wallet.d.ts.map +1 -0
- package/dest/test-wallet/test_wallet.js +214 -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 +40 -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 +103 -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 +43 -39
- package/src/bench/client_flows/client_flows_benchmark.ts +8 -12
- package/src/bench/client_flows/config.ts +9 -1
- package/src/bench/utils.ts +1 -1
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +11 -2
- 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 +103 -72
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +11 -26
- package/src/e2e_l1_publisher/write_json.ts +1 -6
- package/src/e2e_nested_contract/nested_contract_test.ts +1 -1
- package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
- package/src/e2e_p2p/p2p_network.ts +29 -7
- package/src/e2e_p2p/reqresp/utils.ts +235 -0
- package/src/e2e_p2p/shared.ts +13 -3
- 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 +11 -2
- package/src/fixtures/authwit_proxy.ts +50 -0
- package/src/fixtures/dumps/epoch_proof_result.json +1 -1
- package/src/fixtures/e2e_prover_test.ts +29 -39
- package/src/fixtures/fixtures.ts +10 -0
- package/src/fixtures/ha_setup.ts +186 -0
- package/src/fixtures/index.ts +1 -0
- package/src/fixtures/setup.ts +102 -223
- package/src/fixtures/setup_p2p_test.ts +40 -44
- package/src/fixtures/token_utils.ts +2 -1
- package/src/guides/up_quick_start.sh +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/mock_state_view.ts +188 -0
- package/src/shared/submit-transactions.ts +6 -2
- package/src/shared/uniswap_l1_l2.ts +9 -11
- package/src/simulators/token_simulator.ts +1 -29
- package/src/spartan/setup_test_wallets.ts +58 -4
- package/src/spartan/tx_metrics.ts +126 -0
- package/src/spartan/utils/bot.ts +4 -1
- package/src/spartan/utils/config.ts +1 -0
- package/src/spartan/utils/index.ts +4 -1
- package/src/spartan/utils/k8s.ts +160 -0
- package/src/spartan/utils/nodes.ts +242 -30
- package/src/spartan/utils/scripts.ts +43 -7
- package/src/test-wallet/test_wallet.ts +306 -0
- package/src/test-wallet/utils.ts +112 -0
- package/src/test-wallet/wallet_worker_script.ts +43 -0
- package/src/test-wallet/worker_wallet.ts +165 -0
- package/src/test-wallet/worker_wallet_schema.ts +13 -0
|
@@ -4,6 +4,7 @@ import { retryUntil } from '@aztec/foundation/retry';
|
|
|
4
4
|
import { exec, spawn } from 'child_process';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { promisify } from 'util';
|
|
7
|
+
import { AlertTriggeredError, GrafanaClient } from '../../quality_of_service/grafana_client.js';
|
|
7
8
|
const execAsync = promisify(exec);
|
|
8
9
|
const logger = createLogger('e2e:k8s-utils');
|
|
9
10
|
export async function startPortForward({ resource, namespace, containerPort, hostPort }) {
|
|
@@ -252,6 +253,129 @@ export async function waitForResourcesByName({ resource, names, namespace, condi
|
|
|
252
253
|
}
|
|
253
254
|
}));
|
|
254
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Waits for all StatefulSets matching a label to have all their replicas ready.
|
|
258
|
+
*
|
|
259
|
+
* @param namespace - Kubernetes namespace
|
|
260
|
+
* @param label - Label selector for StatefulSets (e.g., "app.kubernetes.io/component=sequencer-node")
|
|
261
|
+
* @param timeoutSeconds - Maximum time to wait in seconds
|
|
262
|
+
* @param pollIntervalSeconds - How often to check status
|
|
263
|
+
*/ export async function waitForStatefulSetsReady({ namespace, label, timeoutSeconds = 600, pollIntervalSeconds = 5 }) {
|
|
264
|
+
logger.info(`Waiting for StatefulSets with label ${label} to have all replicas ready (timeout: ${timeoutSeconds}s)`);
|
|
265
|
+
await retryUntil(async ()=>{
|
|
266
|
+
// Get all StatefulSets matching the label
|
|
267
|
+
const getCmd = `kubectl get statefulset -l ${label} -n ${namespace} -o json`;
|
|
268
|
+
const { stdout } = await execAsync(getCmd);
|
|
269
|
+
const result = JSON.parse(stdout);
|
|
270
|
+
if (!result.items || result.items.length === 0) {
|
|
271
|
+
logger.verbose(`No StatefulSets found with label ${label}`);
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
// Check each StatefulSet
|
|
275
|
+
for (const sts of result.items){
|
|
276
|
+
const name = sts.metadata.name;
|
|
277
|
+
const desired = sts.spec.replicas ?? 0;
|
|
278
|
+
const ready = sts.status.readyReplicas ?? 0;
|
|
279
|
+
const updated = sts.status.updatedReplicas ?? 0;
|
|
280
|
+
if (ready < desired || updated < desired) {
|
|
281
|
+
logger.verbose(`StatefulSet ${name}: ${ready}/${desired} ready, ${updated}/${desired} updated`);
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
logger.info(`All StatefulSets with label ${label} are ready`);
|
|
286
|
+
return true;
|
|
287
|
+
}, `StatefulSets with label ${label} to be ready`, timeoutSeconds, pollIntervalSeconds);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Creates a Prometheus connection that can re-establish port-forward on failure.
|
|
291
|
+
* Returns functions to connect and run alert checks that automatically reconnect if needed.
|
|
292
|
+
*
|
|
293
|
+
* @param namespace - K8s namespace to fall back to if metrics namespace doesn't have Prometheus
|
|
294
|
+
* @param endpoints - Array to track created endpoints for cleanup
|
|
295
|
+
* @param log - Logger instance
|
|
296
|
+
*/ export function createResilientPrometheusConnection(namespace, endpoints, log) {
|
|
297
|
+
let alertChecker;
|
|
298
|
+
let currentEndpoint;
|
|
299
|
+
const connect = async ()=>{
|
|
300
|
+
// Kill existing connection if any
|
|
301
|
+
if (currentEndpoint?.process) {
|
|
302
|
+
currentEndpoint.process.kill();
|
|
303
|
+
}
|
|
304
|
+
// Try metrics namespace first, then network namespace
|
|
305
|
+
let promPort = 0;
|
|
306
|
+
let promUrl = '';
|
|
307
|
+
let promProc;
|
|
308
|
+
try {
|
|
309
|
+
const metricsResult = await startPortForward({
|
|
310
|
+
resource: `svc/metrics-prometheus-server`,
|
|
311
|
+
namespace: 'metrics',
|
|
312
|
+
containerPort: 80
|
|
313
|
+
});
|
|
314
|
+
promProc = metricsResult.process;
|
|
315
|
+
promPort = metricsResult.port;
|
|
316
|
+
promUrl = `http://127.0.0.1:${promPort}/api/v1`;
|
|
317
|
+
} catch {
|
|
318
|
+
// Metrics namespace might not have Prometheus, try network namespace
|
|
319
|
+
log.verbose('Metrics namespace Prometheus not available, trying network namespace');
|
|
320
|
+
}
|
|
321
|
+
if (promPort === 0) {
|
|
322
|
+
const nsResult = await startPortForward({
|
|
323
|
+
resource: `svc/prometheus-server`,
|
|
324
|
+
namespace,
|
|
325
|
+
containerPort: 80
|
|
326
|
+
});
|
|
327
|
+
promProc = nsResult.process;
|
|
328
|
+
promPort = nsResult.port;
|
|
329
|
+
promUrl = `http://127.0.0.1:${promPort}/api/v1`;
|
|
330
|
+
}
|
|
331
|
+
if (!promProc || promPort === 0) {
|
|
332
|
+
throw new Error('Unable to port-forward to Prometheus');
|
|
333
|
+
}
|
|
334
|
+
currentEndpoint = {
|
|
335
|
+
url: promUrl,
|
|
336
|
+
process: promProc
|
|
337
|
+
};
|
|
338
|
+
endpoints.push(currentEndpoint);
|
|
339
|
+
alertChecker = new GrafanaClient(log, {
|
|
340
|
+
grafanaEndpoint: promUrl,
|
|
341
|
+
grafanaCredentials: ''
|
|
342
|
+
});
|
|
343
|
+
log.info(`Established Prometheus connection at ${promUrl}`);
|
|
344
|
+
return alertChecker;
|
|
345
|
+
};
|
|
346
|
+
const runAlertCheck = async (alerts)=>{
|
|
347
|
+
if (!alertChecker) {
|
|
348
|
+
alertChecker = await connect();
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
await alertChecker.runAlertCheck(alerts);
|
|
352
|
+
} catch (err) {
|
|
353
|
+
// If it's an AlertTriggeredError (expected behavior)
|
|
354
|
+
if (err instanceof AlertTriggeredError) {
|
|
355
|
+
throw err;
|
|
356
|
+
}
|
|
357
|
+
// Check if it's a connection error (port-forward died)
|
|
358
|
+
const errorStr = String(err);
|
|
359
|
+
if (errorStr.includes('fetch failed') || errorStr.includes('ECONNREFUSED') || errorStr.includes('ECONNRESET')) {
|
|
360
|
+
log.warn(`Prometheus connection lost, re-establishing port-forward...`);
|
|
361
|
+
alertChecker = await connect();
|
|
362
|
+
await alertChecker.runAlertCheck(alerts);
|
|
363
|
+
} else {
|
|
364
|
+
throw err;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
return {
|
|
369
|
+
connect,
|
|
370
|
+
runAlertCheck
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/** Scales the prover-agent Deployment to the given number of replicas. */ export async function scaleProverAgents(namespace, replicas, log) {
|
|
374
|
+
const label = 'app.kubernetes.io/component=prover-agent';
|
|
375
|
+
const command = `kubectl scale deployment -l ${label} -n ${namespace} --replicas=${replicas} --timeout=2m`;
|
|
376
|
+
log.info(`Scaling prover agents to ${replicas}: ${command}`);
|
|
377
|
+
await execAsync(command);
|
|
378
|
+
}
|
|
255
379
|
export function getChartDir(spartanDir, chartName) {
|
|
256
380
|
return path.join(spartanDir.trim(), chartName);
|
|
257
381
|
}
|
|
@@ -4,17 +4,26 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
4
4
|
import { type AztecNodeAdmin, type AztecNodeAdminConfig } from '@aztec/stdlib/interfaces/client';
|
|
5
5
|
import type { TestConfig } from './config.js';
|
|
6
6
|
export declare function awaitCheckpointNumber(rollupCheatCodes: RollupCheatCodes, checkpointNumber: CheckpointNumber, timeoutSeconds: number, log: Logger): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Waits until the proven block number increases.
|
|
9
|
+
*
|
|
10
|
+
* @param rpcUrl - URL of an Aztec RPC node to query
|
|
11
|
+
* @param log - Logger instance
|
|
12
|
+
* @param timeoutSeconds - Maximum time to wait
|
|
13
|
+
* @param pollIntervalSeconds - How often to check
|
|
14
|
+
*/
|
|
15
|
+
export declare function waitForProvenToAdvance(rpcUrl: string, log: Logger, timeoutSeconds?: number, pollIntervalSeconds?: number): Promise<void>;
|
|
7
16
|
export declare function getSequencers(namespace: string): Promise<string[]>;
|
|
8
17
|
export declare function updateSequencersConfig(env: TestConfig, config: Partial<AztecNodeAdminConfig>): Promise<AztecNodeAdminConfig[]>;
|
|
9
18
|
export declare function getSequencersConfig(env: TestConfig): Promise<AztecNodeAdminConfig[]>;
|
|
10
19
|
export declare function withSequencersAdmin<T>(env: TestConfig, fn: (node: AztecNodeAdmin) => Promise<T>): Promise<T[]>;
|
|
20
|
+
export declare function initHADb(namespace: string): Promise<void>;
|
|
11
21
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Wired to env
|
|
22
|
+
* Sets probabilistic transaction dropping on validators and waits for rollout.
|
|
23
|
+
* Use probability=0 to disable. Wired to env var P2P_DROP_TX_CHANCE via Helm values.
|
|
14
24
|
*/
|
|
15
|
-
export declare function setValidatorTxDrop({ namespace,
|
|
25
|
+
export declare function setValidatorTxDrop({ namespace, probability, logger: log }: {
|
|
16
26
|
namespace: string;
|
|
17
|
-
enabled: boolean;
|
|
18
27
|
probability: number;
|
|
19
28
|
logger: Logger;
|
|
20
29
|
}): Promise<void>;
|
|
@@ -28,4 +37,4 @@ export declare function enableValidatorDynamicBootNode(instanceName: string, nam
|
|
|
28
37
|
* Defaults to false, which preserves the existing storage.
|
|
29
38
|
*/
|
|
30
39
|
export declare function rollAztecPods(namespace: string, clearState?: boolean): Promise<void>;
|
|
31
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zcGFydGFuL3V0aWxzL25vZGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUdwRCxPQUFPLEVBQ0wsS0FBSyxjQUFjLEVBQ25CLEtBQUssb0JBQW9CLEVBRTFCLE1BQU0saUNBQWlDLENBQUM7QUFLekMsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBZTlDLHdCQUFzQixxQkFBcUIsQ0FDekMsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQ2xDLGdCQUFnQixFQUFFLGdCQUFnQixFQUNsQyxjQUFjLEVBQUUsTUFBTSxFQUN0QixHQUFHLEVBQUUsTUFBTSxpQkFlWjtBQUVEOzs7Ozs7O0dBT0c7QUFDSCx3QkFBc0Isc0JBQXNCLENBQzFDLE1BQU0sRUFBRSxNQUFNLEVBQ2QsR0FBRyxFQUFFLE1BQU0sRUFDWCxjQUFjLEdBQUUsTUFBWSxFQUM1QixtQkFBbUIsR0FBRSxNQUFXLEdBQy9CLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0EwQ2Y7QUFFRCx3QkFBc0IsYUFBYSxDQUFDLFNBQVMsRUFBRSxNQUFNLHFCQTRCcEQ7QUFFRCx3QkFBZ0Isc0JBQXNCLENBQUMsR0FBRyxFQUFFLFVBQVUsRUFBRSxNQUFNLEVBQUUsT0FBTyxDQUFDLG9CQUFvQixDQUFDLG1DQUs1RjtBQUVELHdCQUFnQixtQkFBbUIsQ0FBQyxHQUFHLEVBQUUsVUFBVSxtQ0FFbEQ7QUFFRCx3QkFBc0IsbUJBQW1CLENBQUMsQ0FBQyxFQUFFLEdBQUcsRUFBRSxVQUFVLEVBQUUsRUFBRSxFQUFFLENBQUMsSUFBSSxFQUFFLGNBQWMsS0FBSyxPQUFPLENBQUMsQ0FBQyxDQUFDLEdBQUcsT0FBTyxDQUFDLENBQUMsRUFBRSxDQUFDLENBNENwSDtBQWtDRCx3QkFBc0IsUUFBUSxDQUFDLFNBQVMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTBCL0Q7QUFFRDs7O0dBR0c7QUFDSCx3QkFBc0Isa0JBQWtCLENBQUMsRUFDdkMsU0FBUyxFQUNULFdBQVcsRUFDWCxNQUFNLEVBQUUsR0FBRyxFQUNaLEVBQUU7SUFDRCxTQUFTLEVBQUUsTUFBTSxDQUFDO0lBQ2xCLFdBQVcsRUFBRSxNQUFNLENBQUM7SUFDcEIsTUFBTSxFQUFFLE1BQU0sQ0FBQztDQUNoQixpQkErQkE7QUFFRCx3QkFBc0IsaUJBQWlCLENBQUMsU0FBUyxFQUFFLE1BQU0sRUFBRSxHQUFHLEVBQUUsTUFBTSxpQkErQnJFO0FBRUQsd0JBQXNCLDhCQUE4QixDQUNsRCxZQUFZLEVBQUUsTUFBTSxFQUNwQixTQUFTLEVBQUUsTUFBTSxFQUNqQixVQUFVLEVBQUUsTUFBTSxFQUNsQixHQUFHLEVBQUUsTUFBTSxpQkFnQlo7QUFFRDs7Ozs7O0dBTUc7QUFDSCx3QkFBc0IsYUFBYSxDQUFDLFNBQVMsRUFBRSxNQUFNLEVBQUUsVUFBVSxHQUFFLE9BQWUsaUJBMktqRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/nodes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAE1B,MAAM,iCAAiC,CAAC;AAKzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAe9C,wBAAsB,qBAAqB,CACzC,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,MAAM,iBAeZ;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,cAAc,GAAE,MAAY,EAC5B,mBAAmB,GAAE,MAAW,GAC/B,OAAO,CAAC,IAAI,CAAC,CA0Cf;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,qBA4BpD;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,mCAK5F;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,mCAElD;AAED,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CA4CpH;AAkCD,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B/D;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,SAAS,EACT,WAAW,EACX,MAAM,EAAE,GAAG,EACZ,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,iBA+BA;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBA+BrE;AAED,wBAAsB,8BAA8B,CAClD,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,iBAgBZ;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,GAAE,OAAe,iBA2KjF"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/aztec.js/log';
|
|
2
|
-
import {
|
|
2
|
+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
3
|
+
import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
|
|
3
4
|
import { sleep } from '@aztec/foundation/sleep';
|
|
4
5
|
import { createAztecNodeAdminClient } from '@aztec/stdlib/interfaces/client';
|
|
5
6
|
import { exec } from 'child_process';
|
|
6
7
|
import { promisify } from 'util';
|
|
7
8
|
import { execHelmCommand } from './helm.js';
|
|
8
|
-
import { deleteResourceByLabel, getChartDir, startPortForward, waitForResourceByLabel } from './k8s.js';
|
|
9
|
+
import { deleteResourceByLabel, getChartDir, startPortForward, waitForResourceByLabel, waitForResourceByName, waitForStatefulSetsReady } from './k8s.js';
|
|
9
10
|
const execAsync = promisify(exec);
|
|
10
11
|
const logger = createLogger('e2e:k8s-utils');
|
|
11
12
|
export async function awaitCheckpointNumber(rollupCheatCodes, checkpointNumber, timeoutSeconds, log) {
|
|
@@ -23,6 +24,43 @@ export async function awaitCheckpointNumber(rollupCheatCodes, checkpointNumber,
|
|
|
23
24
|
log.info(`Reached checkpoint ${tips.pending}`);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Waits until the proven block number increases.
|
|
29
|
+
*
|
|
30
|
+
* @param rpcUrl - URL of an Aztec RPC node to query
|
|
31
|
+
* @param log - Logger instance
|
|
32
|
+
* @param timeoutSeconds - Maximum time to wait
|
|
33
|
+
* @param pollIntervalSeconds - How often to check
|
|
34
|
+
*/ export async function waitForProvenToAdvance(rpcUrl, log, timeoutSeconds = 300, pollIntervalSeconds = 12) {
|
|
35
|
+
const node = createAztecNodeClient(rpcUrl);
|
|
36
|
+
log.info('Waiting for proven block to advance (indicating epoch proof just submitted)...');
|
|
37
|
+
// Get current proven block number
|
|
38
|
+
let initialProvenBlock;
|
|
39
|
+
try {
|
|
40
|
+
const tips = await node.getL2Tips();
|
|
41
|
+
initialProvenBlock = Number(tips.proven.block.number);
|
|
42
|
+
log.info(`Current proven block: ${initialProvenBlock}. Waiting for it to increase...`);
|
|
43
|
+
} catch (err) {
|
|
44
|
+
log.warn(`Error getting initial tips: ${err}. Will poll until successful.`);
|
|
45
|
+
initialProvenBlock = 0;
|
|
46
|
+
}
|
|
47
|
+
await retryUntil(async ()=>{
|
|
48
|
+
try {
|
|
49
|
+
const tips = await node.getL2Tips();
|
|
50
|
+
const currentProvenBlock = Number(tips.proven.block.number);
|
|
51
|
+
const proposedBlock = Number(tips.proposed.number);
|
|
52
|
+
log.verbose(`Chain state: proposed=${proposedBlock}, proven=${currentProvenBlock} (waiting for > ${initialProvenBlock})`);
|
|
53
|
+
if (currentProvenBlock > initialProvenBlock) {
|
|
54
|
+
log.info(`Proven block advanced from ${initialProvenBlock} to ${currentProvenBlock}.`);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
log.verbose(`Error checking tips: ${err}`);
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}, 'proven block to advance', timeoutSeconds, pollIntervalSeconds);
|
|
63
|
+
}
|
|
26
64
|
export async function getSequencers(namespace) {
|
|
27
65
|
const selectors = [
|
|
28
66
|
'app.kubernetes.io/name=validator',
|
|
@@ -61,9 +99,15 @@ export async function withSequencersAdmin(env, fn) {
|
|
|
61
99
|
const sequencers = await getSequencers(namespace);
|
|
62
100
|
const results = [];
|
|
63
101
|
for (const sequencer of sequencers){
|
|
102
|
+
// Ensure pod is Ready before attempting port-forward.
|
|
103
|
+
await waitForResourceByName({
|
|
104
|
+
resource: 'pods',
|
|
105
|
+
name: sequencer,
|
|
106
|
+
namespace
|
|
107
|
+
});
|
|
64
108
|
// Wrap port-forward + fetch in a retry to handle flaky port-forwards
|
|
65
109
|
const result = await retry(async ()=>{
|
|
66
|
-
const { process, port } = await startPortForward({
|
|
110
|
+
const { process: process1, port } = await startPortForward({
|
|
67
111
|
resource: `pod/${sequencer}`,
|
|
68
112
|
namespace,
|
|
69
113
|
containerPort: adminContainerPort
|
|
@@ -78,11 +122,11 @@ export async function withSequencersAdmin(env, fn) {
|
|
|
78
122
|
const client = createAztecNodeAdminClient(url);
|
|
79
123
|
return {
|
|
80
124
|
result: await fn(client),
|
|
81
|
-
process
|
|
125
|
+
process: process1
|
|
82
126
|
};
|
|
83
127
|
} catch (err) {
|
|
84
128
|
// Kill the port-forward before retrying
|
|
85
|
-
|
|
129
|
+
process1.kill();
|
|
86
130
|
throw err;
|
|
87
131
|
}
|
|
88
132
|
}, 'connect to node admin', makeBackoff([
|
|
@@ -96,11 +140,62 @@ export async function withSequencersAdmin(env, fn) {
|
|
|
96
140
|
}
|
|
97
141
|
return results;
|
|
98
142
|
}
|
|
143
|
+
async function getAztecImageForMigrations(namespace) {
|
|
144
|
+
const aztecDockerImage = process.env.AZTEC_DOCKER_IMAGE;
|
|
145
|
+
if (aztecDockerImage) {
|
|
146
|
+
return aztecDockerImage;
|
|
147
|
+
}
|
|
148
|
+
const { stdout } = await execAsync(`kubectl get pods -l app.kubernetes.io/name=validator -n ${namespace} -o jsonpath='{.items[0].spec.containers[?(@.name=="aztec")].image}' | cat`);
|
|
149
|
+
const image = stdout.trim().replace(/^'|'$/g, '');
|
|
150
|
+
if (!image) {
|
|
151
|
+
throw new Error(`Could not detect aztec image from validator pod in namespace ${namespace}`);
|
|
152
|
+
}
|
|
153
|
+
return image;
|
|
154
|
+
}
|
|
155
|
+
async function getHaDbConnectionUrl(namespace) {
|
|
156
|
+
const secretName = `${namespace}-validator-ha-db-postgres`;
|
|
157
|
+
const { stdout } = await execAsync(`kubectl get secret ${secretName} -n ${namespace} -o json`);
|
|
158
|
+
const secret = JSON.parse(stdout);
|
|
159
|
+
const data = secret?.data ?? {};
|
|
160
|
+
const decode = (value)=>value ? Buffer.from(value, 'base64').toString('utf8') : '';
|
|
161
|
+
const user = decode(data.POSTGRES_USER);
|
|
162
|
+
const password = decode(data.POSTGRES_PASSWORD);
|
|
163
|
+
const database = decode(data.POSTGRES_DB);
|
|
164
|
+
if (!user || !password || !database) {
|
|
165
|
+
throw new Error(`Missing HA DB credentials in secret ${secretName}`);
|
|
166
|
+
}
|
|
167
|
+
const host = `${namespace}-validator-ha-db-postgres.${namespace}.svc.cluster.local`;
|
|
168
|
+
return `postgresql://${encodeURIComponent(user)}:${encodeURIComponent(password)}@${host}:5432/${database}`;
|
|
169
|
+
}
|
|
170
|
+
export async function initHADb(namespace) {
|
|
171
|
+
const databaseUrl = await getHaDbConnectionUrl(namespace);
|
|
172
|
+
const image = await getAztecImageForMigrations(namespace);
|
|
173
|
+
const jobName = `${namespace}-validator-ha-db-migrate`;
|
|
174
|
+
await execAsync(`kubectl delete pod ${jobName} -n ${namespace} --ignore-not-found=true`).catch(()=>undefined);
|
|
175
|
+
const migrateCmd = [
|
|
176
|
+
`kubectl run ${jobName} -n ${namespace}`,
|
|
177
|
+
'--rm -i',
|
|
178
|
+
'--restart=Never',
|
|
179
|
+
`--image=${image}`,
|
|
180
|
+
`--env=DATABASE_URL=${databaseUrl}`,
|
|
181
|
+
'--command -- node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js migrate-ha-db up'
|
|
182
|
+
].join(' ');
|
|
183
|
+
const migrateCmdForLog = migrateCmd.replace(/--env=DATABASE_URL=\S+/, '--env=DATABASE_URL=<redacted>');
|
|
184
|
+
await retry(async ()=>{
|
|
185
|
+
logger.info(`command: ${migrateCmdForLog}`);
|
|
186
|
+
await execAsync(migrateCmd);
|
|
187
|
+
}, 'run HA DB migrations', makeBackoff([
|
|
188
|
+
1,
|
|
189
|
+
2,
|
|
190
|
+
4,
|
|
191
|
+
8,
|
|
192
|
+
16
|
|
193
|
+
]), logger, true);
|
|
194
|
+
}
|
|
99
195
|
/**
|
|
100
|
-
*
|
|
101
|
-
* Wired to env
|
|
102
|
-
*/ export async function setValidatorTxDrop({ namespace,
|
|
103
|
-
const drop = enabled ? 'true' : 'false';
|
|
196
|
+
* Sets probabilistic transaction dropping on validators and waits for rollout.
|
|
197
|
+
* Use probability=0 to disable. Wired to env var P2P_DROP_TX_CHANCE via Helm values.
|
|
198
|
+
*/ export async function setValidatorTxDrop({ namespace, probability, logger: log }) {
|
|
104
199
|
const prob = String(probability);
|
|
105
200
|
const selectors = [
|
|
106
201
|
'app.kubernetes.io/name=validator',
|
|
@@ -115,7 +210,7 @@ export async function withSequencersAdmin(env, fn) {
|
|
|
115
210
|
if (names.length === 0) {
|
|
116
211
|
continue;
|
|
117
212
|
}
|
|
118
|
-
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace}
|
|
213
|
+
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
|
|
119
214
|
log.info(`command: ${cmd}`);
|
|
120
215
|
await execAsync(cmd);
|
|
121
216
|
updated = true;
|
|
@@ -201,14 +296,16 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
|
|
|
201
296
|
'prover-broker',
|
|
202
297
|
'prover-agent',
|
|
203
298
|
'sequencer-node',
|
|
204
|
-
'rpc'
|
|
299
|
+
'rpc',
|
|
300
|
+
'validator-ha-db'
|
|
205
301
|
];
|
|
206
302
|
const pvcComponents = [
|
|
207
303
|
'p2p-bootstrap',
|
|
208
304
|
'prover-node',
|
|
209
305
|
'prover-broker',
|
|
210
306
|
'sequencer-node',
|
|
211
|
-
'rpc'
|
|
307
|
+
'rpc',
|
|
308
|
+
'validator-ha-db'
|
|
212
309
|
];
|
|
213
310
|
// StatefulSet components that need to be scaled down before PVC deletion
|
|
214
311
|
// Note: validators use 'sequencer-node' as component label, not 'validator'
|
|
@@ -217,20 +314,27 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
|
|
|
217
314
|
'prover-node',
|
|
218
315
|
'prover-broker',
|
|
219
316
|
'sequencer-node',
|
|
220
|
-
'rpc'
|
|
317
|
+
'rpc',
|
|
318
|
+
'validator-ha-db'
|
|
221
319
|
];
|
|
222
320
|
if (clearState) {
|
|
223
321
|
// To delete PVCs, we must first scale down StatefulSets so pods release the volumes
|
|
224
322
|
// Otherwise PVC deletion will hang waiting for pods to terminate
|
|
225
|
-
//
|
|
323
|
+
// Save original replica counts for all StatefulSets
|
|
226
324
|
const originalReplicas = new Map();
|
|
227
325
|
for (const component of statefulSetComponents){
|
|
228
326
|
try {
|
|
229
|
-
|
|
327
|
+
// Get all StatefulSets that match the component label
|
|
328
|
+
const getCmd = `kubectl get statefulset -l app.kubernetes.io/component=${component} -n ${namespace} -o json`;
|
|
230
329
|
const { stdout } = await execAsync(getCmd);
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
330
|
+
const result = JSON.parse(stdout);
|
|
331
|
+
for (const sts of result.items || []){
|
|
332
|
+
const name = sts.metadata.name;
|
|
333
|
+
const replicas = sts.spec.replicas ?? 1;
|
|
334
|
+
if (replicas > 0) {
|
|
335
|
+
originalReplicas.set(name, replicas);
|
|
336
|
+
logger.debug(`Saved replica count for StatefulSet ${name}: ${replicas}`);
|
|
337
|
+
}
|
|
234
338
|
}
|
|
235
339
|
} catch {
|
|
236
340
|
// Component might not exist, continue
|
|
@@ -247,25 +351,79 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
|
|
|
247
351
|
logger.verbose(`Scale down ${component} skipped: ${e}`);
|
|
248
352
|
}
|
|
249
353
|
}
|
|
250
|
-
// Wait for pods to terminate
|
|
251
|
-
|
|
354
|
+
// Wait for all pods to fully terminate before deleting PVCs.
|
|
355
|
+
// terminationGracePeriodSeconds default is 30s.
|
|
356
|
+
logger.info('Waiting for pods to fully terminate before deleting PVCs...');
|
|
357
|
+
for (const component of statefulSetComponents){
|
|
358
|
+
try {
|
|
359
|
+
// Wait for all pods with this component label to be deleted
|
|
360
|
+
const waitCmd = `kubectl wait pods -l app.kubernetes.io/component=${component} --for=delete -n ${namespace} --timeout=2m`;
|
|
361
|
+
logger.info(`command: ${waitCmd}`);
|
|
362
|
+
await execAsync(waitCmd);
|
|
363
|
+
} catch (e) {
|
|
364
|
+
logger.verbose(`Wait for pod deletion ${component} skipped: ${e}`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// Extra buffer to ensure PVC protection finalizers are cleared
|
|
368
|
+
await sleep(5 * 1000);
|
|
252
369
|
// Now delete PVCs (they should no longer be in use)
|
|
253
370
|
for (const component of pvcComponents){
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
371
|
+
try {
|
|
372
|
+
await deleteResourceByLabel({
|
|
373
|
+
resource: 'persistentvolumeclaims',
|
|
374
|
+
namespace: namespace,
|
|
375
|
+
label: `app.kubernetes.io/component=${component}`
|
|
376
|
+
});
|
|
377
|
+
} catch (e) {
|
|
378
|
+
logger.warn(`Failed to delete PVCs for ${component}: ${e}`);
|
|
379
|
+
}
|
|
259
380
|
}
|
|
260
|
-
//
|
|
261
|
-
for (const component of
|
|
262
|
-
|
|
381
|
+
// Verify PVCs are deleted
|
|
382
|
+
for (const component of pvcComponents){
|
|
383
|
+
try {
|
|
384
|
+
const waitCmd = `kubectl wait pvc -l app.kubernetes.io/component=${component} --for=delete -n ${namespace} --timeout=2m`;
|
|
385
|
+
logger.info(`command: ${waitCmd}`);
|
|
386
|
+
await execAsync(waitCmd);
|
|
387
|
+
} catch (e) {
|
|
388
|
+
logger.verbose(`Wait for PVC deletion ${component} skipped: ${e}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const haDbStatefulSets = [
|
|
392
|
+
...originalReplicas.entries()
|
|
393
|
+
].filter(([name])=>name.includes('validator-ha-db'));
|
|
394
|
+
const otherStatefulSets = [
|
|
395
|
+
...originalReplicas.entries()
|
|
396
|
+
].filter(([name])=>!name.includes('validator-ha-db'));
|
|
397
|
+
// Bring up HA DB first so we can run migrations before validators start
|
|
398
|
+
for (const [stsName, replicas] of haDbStatefulSets){
|
|
399
|
+
try {
|
|
400
|
+
const scaleCmd = `kubectl scale statefulset ${stsName} -n ${namespace} --replicas=${replicas} --timeout=2m`;
|
|
401
|
+
logger.info(`command: ${scaleCmd}`);
|
|
402
|
+
await execAsync(scaleCmd);
|
|
403
|
+
} catch (e) {
|
|
404
|
+
logger.verbose(`Scale up ${stsName} skipped: ${e}`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (haDbStatefulSets.length > 0) {
|
|
408
|
+
try {
|
|
409
|
+
await waitForStatefulSetsReady({
|
|
410
|
+
namespace,
|
|
411
|
+
label: 'app.kubernetes.io/component=validator-ha-db',
|
|
412
|
+
timeoutSeconds: 600
|
|
413
|
+
});
|
|
414
|
+
await initHADb(namespace);
|
|
415
|
+
} catch (e) {
|
|
416
|
+
logger.warn(`HA DB migration step skipped or failed: ${e}`);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// Scale remaining StatefulSets back up to original replica counts (by name, not label)
|
|
420
|
+
for (const [stsName, replicas] of otherStatefulSets){
|
|
263
421
|
try {
|
|
264
|
-
const scaleCmd = `kubectl scale statefulset
|
|
422
|
+
const scaleCmd = `kubectl scale statefulset ${stsName} -n ${namespace} --replicas=${replicas} --timeout=2m`;
|
|
265
423
|
logger.info(`command: ${scaleCmd}`);
|
|
266
424
|
await execAsync(scaleCmd);
|
|
267
425
|
} catch (e) {
|
|
268
|
-
logger.verbose(`Scale up ${
|
|
426
|
+
logger.verbose(`Scale up ${stsName} skipped: ${e}`);
|
|
269
427
|
}
|
|
270
428
|
}
|
|
271
429
|
} else {
|
|
@@ -279,8 +437,20 @@ export async function enableValidatorDynamicBootNode(instanceName, namespace, sp
|
|
|
279
437
|
}
|
|
280
438
|
}
|
|
281
439
|
await sleep(10 * 1000);
|
|
282
|
-
// Wait for
|
|
283
|
-
for (const component of
|
|
440
|
+
// Wait for StatefulSets to have all replicas ready.
|
|
441
|
+
for (const component of statefulSetComponents){
|
|
442
|
+
try {
|
|
443
|
+
await waitForStatefulSetsReady({
|
|
444
|
+
namespace,
|
|
445
|
+
label: `app.kubernetes.io/component=${component}`,
|
|
446
|
+
timeoutSeconds: 600
|
|
447
|
+
});
|
|
448
|
+
} catch (e) {
|
|
449
|
+
logger.warn(`StatefulSet component ${component} may not be fully ready: ${e}`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const nonStatefulSetComponents = podComponents.filter((c)=>!statefulSetComponents.includes(c));
|
|
453
|
+
for (const component of nonStatefulSetComponents){
|
|
284
454
|
await waitForResourceByLabel({
|
|
285
455
|
resource: 'pods',
|
|
286
456
|
namespace: namespace,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
/** Result from running a script */
|
|
3
|
+
export type ScriptResult = {
|
|
4
|
+
exitCode: number;
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* Returns the absolute path to the git repository root
|
|
4
10
|
*/
|
|
@@ -9,8 +15,16 @@ export declare function getAztecBin(): string;
|
|
|
9
15
|
* @param args - The arguments to pass to the Aztec binary
|
|
10
16
|
* @param logger - The logger to use
|
|
11
17
|
* @param env - Optional environment variables to set for the process
|
|
12
|
-
* @returns The exit code of the Aztec binary
|
|
18
|
+
* @returns The exit code, stdout, and stderr of the Aztec binary
|
|
13
19
|
*/
|
|
14
|
-
export declare function runAztecBin(args: string[], logger: Logger, env?: Record<string, string>): Promise<
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
export declare function runAztecBin(args: string[], logger: Logger, env?: Record<string, string>): Promise<ScriptResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Runs a script from the project root
|
|
23
|
+
* @param script - The path to the script, relative to the project root
|
|
24
|
+
* @param args - The arguments to pass to the script
|
|
25
|
+
* @param logger - The logger to use
|
|
26
|
+
* @param env - Optional environment variables to set for the process
|
|
27
|
+
* @returns The exit code, stdout, and stderr of the script
|
|
28
|
+
*/
|
|
29
|
+
export declare function runProjectScript(script: string, args: string[], logger: Logger, env?: Record<string, string>): Promise<ScriptResult>;
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyaXB0cy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NwYXJ0YW4vdXRpbHMvc2NyaXB0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUtwRCxtQ0FBbUM7QUFDbkMsTUFBTSxNQUFNLFlBQVksR0FBRztJQUN6QixRQUFRLEVBQUUsTUFBTSxDQUFDO0lBQ2pCLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFDZixNQUFNLEVBQUUsTUFBTSxDQUFDO0NBQ2hCLENBQUM7QUF5Q0Y7O0dBRUc7QUFDSCx3QkFBZ0IsaUJBQWlCLElBQUksTUFBTSxDQVcxQztBQUVELHdCQUFnQixXQUFXLFdBRTFCO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsd0JBQWdCLFdBQVcsQ0FBQyxJQUFJLEVBQUUsTUFBTSxFQUFFLEVBQUUsTUFBTSxFQUFFLE1BQU0sRUFBRSxHQUFHLENBQUMsRUFBRSxNQUFNLENBQUMsTUFBTSxFQUFFLE1BQU0sQ0FBQyxHQUFHLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FFL0c7QUFFRDs7Ozs7OztHQU9HO0FBQ0gsd0JBQWdCLGdCQUFnQixDQUM5QixNQUFNLEVBQUUsTUFBTSxFQUNkLElBQUksRUFBRSxNQUFNLEVBQUUsRUFDZCxNQUFNLEVBQUUsTUFBTSxFQUNkLEdBQUcsQ0FBQyxFQUFFLE1BQU0sQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLEdBQzNCLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FHdkIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../../src/spartan/utils/scripts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,mCAAmC;AACnC,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAyCF;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C;AAED,wBAAgB,WAAW,WAE1B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAE/G;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,EACd,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,OAAO,CAAC,YAAY,CAAC,CAGvB"}
|
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
* @param scriptPath - The path to the script, relative to the project root
|
|
5
5
|
* @param args - The arguments to pass to the script
|
|
6
6
|
* @param logger - The logger to use
|
|
7
|
-
* @returns The exit code of the script
|
|
7
|
+
* @returns The exit code, stdout, and stderr of the script
|
|
8
8
|
*/ function runScript(scriptPath, args, logger, env) {
|
|
9
9
|
const childProcess = spawn(scriptPath, args, {
|
|
10
10
|
stdio: [
|
|
@@ -17,13 +17,21 @@ import path from 'path';
|
|
|
17
17
|
...env
|
|
18
18
|
} : process.env
|
|
19
19
|
});
|
|
20
|
+
const stdoutChunks = [];
|
|
21
|
+
const stderrChunks = [];
|
|
20
22
|
return new Promise((resolve, reject)=>{
|
|
21
|
-
childProcess.on('close', (code)=>resolve(
|
|
23
|
+
childProcess.on('close', (code)=>resolve({
|
|
24
|
+
exitCode: code ?? 0,
|
|
25
|
+
stdout: Buffer.concat(stdoutChunks).toString(),
|
|
26
|
+
stderr: Buffer.concat(stderrChunks).toString()
|
|
27
|
+
}));
|
|
22
28
|
childProcess.on('error', reject);
|
|
23
29
|
childProcess.stdout?.on('data', (data)=>{
|
|
30
|
+
stdoutChunks.push(data);
|
|
24
31
|
logger.info(data.toString());
|
|
25
32
|
});
|
|
26
33
|
childProcess.stderr?.on('data', (data)=>{
|
|
34
|
+
stderrChunks.push(data);
|
|
27
35
|
logger.error(data.toString());
|
|
28
36
|
});
|
|
29
37
|
});
|
|
@@ -53,14 +61,21 @@ export function getAztecBin() {
|
|
|
53
61
|
* @param args - The arguments to pass to the Aztec binary
|
|
54
62
|
* @param logger - The logger to use
|
|
55
63
|
* @param env - Optional environment variables to set for the process
|
|
56
|
-
* @returns The exit code of the Aztec binary
|
|
64
|
+
* @returns The exit code, stdout, and stderr of the Aztec binary
|
|
57
65
|
*/ export function runAztecBin(args, logger, env) {
|
|
58
66
|
return runScript('node', [
|
|
59
67
|
getAztecBin(),
|
|
60
68
|
...args
|
|
61
69
|
], logger, env);
|
|
62
70
|
}
|
|
63
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Runs a script from the project root
|
|
73
|
+
* @param script - The path to the script, relative to the project root
|
|
74
|
+
* @param args - The arguments to pass to the script
|
|
75
|
+
* @param logger - The logger to use
|
|
76
|
+
* @param env - Optional environment variables to set for the process
|
|
77
|
+
* @returns The exit code, stdout, and stderr of the script
|
|
78
|
+
*/ export function runProjectScript(script, args, logger, env) {
|
|
64
79
|
const scriptPath = script.startsWith('/') ? script : path.join(getGitProjectRoot(), script);
|
|
65
80
|
return runScript(scriptPath, args, logger, env);
|
|
66
81
|
}
|