@aztec/end-to-end 0.0.1-fake-c83136db25 → 0.0.1-fake-ceab37513c
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/benchmark.d.ts +2 -3
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +12 -16
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +58 -54
- package/dest/bench/client_flows/data_extractor.js +3 -3
- package/dest/bench/utils.d.ts +11 -2
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +34 -10
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
- 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 +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +8 -10
- 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 +33 -31
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -9
- package/dest/e2e_epochs/epochs_test.d.ts +1 -3
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +9 -10
- package/dest/e2e_fees/bridging_race.notest.js +9 -12
- package/dest/e2e_fees/fees_test.d.ts +5 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +31 -23
- package/dest/e2e_l1_publisher/write_json.d.ts +1 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -5
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +9 -7
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +2 -2
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +2 -5
- package/dest/e2e_p2p/p2p_network.d.ts +2 -14
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +10 -32
- package/dest/e2e_p2p/shared.d.ts +13 -11
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +45 -49
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +17 -14
- package/dest/fixtures/e2e_prover_test.d.ts +6 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +50 -40
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- 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 +2 -2
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +2 -2
- package/dest/fixtures/setup_p2p_test.d.ts +7 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.d.ts +7 -10
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +32 -42
- package/dest/fixtures/token_utils.d.ts +4 -6
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +15 -11
- package/dest/fixtures/utils.d.ts +27 -23
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +100 -75
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/web3signer.d.ts.map +1 -1
- package/dest/fixtures/web3signer.js +5 -16
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +10 -16
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +15 -13
- package/dest/shared/gas_portal_test_harness.d.ts +6 -9
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +7 -10
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +3 -5
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +7 -8
- package/dest/shared/uniswap_l1_l2.d.ts +6 -9
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +45 -29
- package/dest/simulators/lending_simulator.d.ts +1 -2
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -3
- package/dest/simulators/token_simulator.d.ts +1 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +13 -19
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +84 -107
- package/dest/spartan/utils.d.ts +0 -44
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +20 -212
- package/package.json +36 -37
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +82 -62
- package/src/bench/client_flows/data_extractor.ts +4 -4
- package/src/bench/utils.ts +37 -9
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +63 -46
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -33
- package/src/e2e_deploy_contract/deploy_test.ts +35 -17
- package/src/e2e_epochs/epochs_test.ts +14 -12
- package/src/e2e_fees/bridging_race.notest.ts +9 -14
- package/src/e2e_fees/fees_test.ts +38 -26
- package/src/e2e_l1_publisher/write_json.ts +6 -8
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +10 -11
- package/src/e2e_p2p/inactivity_slash_test.ts +3 -7
- package/src/e2e_p2p/p2p_network.ts +67 -105
- package/src/e2e_p2p/shared.ts +55 -50
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +88 -51
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +2 -3
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +8 -0
- package/src/fixtures/snapshot_manager.ts +59 -59
- package/src/fixtures/token_utils.ts +21 -13
- package/src/fixtures/utils.ts +137 -86
- package/src/fixtures/web3signer.ts +5 -22
- package/src/guides/up_quick_start.sh +10 -2
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +29 -18
- package/src/shared/gas_portal_test_harness.ts +19 -12
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +8 -12
- package/src/shared/uniswap_l1_l2.ts +67 -61
- package/src/simulators/lending_simulator.ts +2 -3
- package/src/simulators/token_simulator.ts +2 -5
- package/src/spartan/DEVELOP.md +3 -8
- package/src/spartan/setup_test_wallets.ts +125 -132
- package/src/spartan/utils.ts +18 -268
package/src/spartan/utils.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/aztec.js
|
|
1
|
+
import { createLogger, sleep } from '@aztec/aztec.js';
|
|
2
2
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
3
3
|
import type { L1ContractAddresses, ViemPublicClient } from '@aztec/ethereum';
|
|
4
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
5
5
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
6
6
|
import { schemas } from '@aztec/foundation/schemas';
|
|
7
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
8
7
|
import {
|
|
9
8
|
type AztecNodeAdmin,
|
|
10
9
|
type AztecNodeAdminConfig,
|
|
@@ -27,9 +26,6 @@ const testConfigSchema = z.object({
|
|
|
27
26
|
REAL_VERIFIER: schemas.Boolean.optional().default(true),
|
|
28
27
|
CREATE_ETH_DEVNET: schemas.Boolean.optional().default(false),
|
|
29
28
|
L1_RPC_URLS_JSON: z.string().optional(),
|
|
30
|
-
L1_ACCOUNT_MNEMONIC: z.string().optional(),
|
|
31
|
-
AZTEC_SLOT_DURATION: z.coerce.number().optional().default(24),
|
|
32
|
-
AZTEC_PROOF_SUBMISSION_WINDOW: z.coerce.number().optional().default(5),
|
|
33
29
|
});
|
|
34
30
|
|
|
35
31
|
export type TestConfig = z.infer<typeof testConfigSchema>;
|
|
@@ -208,16 +204,6 @@ export async function deleteResourceByLabel({
|
|
|
208
204
|
timeout?: string;
|
|
209
205
|
force?: boolean;
|
|
210
206
|
}) {
|
|
211
|
-
// Check if the resource type exists before attempting to delete
|
|
212
|
-
try {
|
|
213
|
-
await execAsync(
|
|
214
|
-
`kubectl api-resources --api-group="" --no-headers -o name | grep -q "^${resource}$" || kubectl api-resources --no-headers -o name | grep -q "^${resource}$"`,
|
|
215
|
-
);
|
|
216
|
-
} catch (error) {
|
|
217
|
-
logger.warn(`Resource type '${resource}' not found in cluster, skipping deletion ${error}`);
|
|
218
|
-
return '';
|
|
219
|
-
}
|
|
220
|
-
|
|
221
207
|
const command = `kubectl delete ${resource} -l ${label} -n ${namespace} --ignore-not-found=true --wait=true --timeout=${timeout} ${
|
|
222
208
|
force ? '--force' : ''
|
|
223
209
|
}`;
|
|
@@ -249,18 +235,9 @@ export function getChartDir(spartanDir: string, chartName: string) {
|
|
|
249
235
|
return path.join(spartanDir.trim(), chartName);
|
|
250
236
|
}
|
|
251
237
|
|
|
252
|
-
function
|
|
253
|
-
// Single-quote safe shell escaping: ' -> '\''
|
|
254
|
-
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function valuesToArgs(values: Record<string, string | number | boolean>) {
|
|
238
|
+
function valuesToArgs(values: Record<string, string | number>) {
|
|
258
239
|
return Object.entries(values)
|
|
259
|
-
.map(([key, value]) =>
|
|
260
|
-
typeof value === 'number' || typeof value === 'boolean'
|
|
261
|
-
? `--set ${key}=${value}`
|
|
262
|
-
: `--set-string ${key}=${shellQuote(String(value))}`,
|
|
263
|
-
)
|
|
240
|
+
.map(([key, value]) => `--set ${key}=${value}`)
|
|
264
241
|
.join(' ');
|
|
265
242
|
}
|
|
266
243
|
|
|
@@ -278,7 +255,7 @@ function createHelmCommand({
|
|
|
278
255
|
namespace: string;
|
|
279
256
|
valuesFile: string | undefined;
|
|
280
257
|
timeout: string;
|
|
281
|
-
values: Record<string, string | number
|
|
258
|
+
values: Record<string, string | number>;
|
|
282
259
|
reuseValues?: boolean;
|
|
283
260
|
}) {
|
|
284
261
|
const valuesFileArgs = valuesFile ? `--values ${helmChartDir}/values/${valuesFile}` : '';
|
|
@@ -318,7 +295,7 @@ export async function installChaosMeshChart({
|
|
|
318
295
|
valuesFile,
|
|
319
296
|
helmChartDir,
|
|
320
297
|
chaosMeshNamespace = 'chaos-mesh',
|
|
321
|
-
timeout = '
|
|
298
|
+
timeout = '5m',
|
|
322
299
|
clean = true,
|
|
323
300
|
values = {},
|
|
324
301
|
logger,
|
|
@@ -337,23 +314,18 @@ export async function installChaosMeshChart({
|
|
|
337
314
|
// uninstall the helm chart if it exists
|
|
338
315
|
logger.info(`Uninstalling helm chart ${instanceName}`);
|
|
339
316
|
await execAsync(`helm uninstall ${instanceName} --namespace ${chaosMeshNamespace} --wait --ignore-not-found`);
|
|
340
|
-
// and delete the
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
label: `app.kubernetes.io/instance=${instanceName}`,
|
|
346
|
-
} as const;
|
|
347
|
-
logger.info(`Deleting ${resource} resources for release ${instanceName}`);
|
|
348
|
-
await deleteResourceByLabel(args).catch(e => {
|
|
349
|
-
logger.error(`Error deleting ${resource}: ${e}`);
|
|
350
|
-
logger.info(`Force deleting ${resource}`);
|
|
351
|
-
return deleteResourceByLabel({ ...args, force: true });
|
|
352
|
-
});
|
|
317
|
+
// and delete the podchaos resource
|
|
318
|
+
const deleteArgs = {
|
|
319
|
+
resource: 'podchaos',
|
|
320
|
+
namespace: chaosMeshNamespace,
|
|
321
|
+
label: `app.kubernetes.io/instance=${instanceName}`,
|
|
353
322
|
};
|
|
354
|
-
|
|
355
|
-
await
|
|
356
|
-
|
|
323
|
+
logger.info(`Deleting podchaos resource`);
|
|
324
|
+
await deleteResourceByLabel(deleteArgs).catch(e => {
|
|
325
|
+
logger.error(`Error deleting podchaos resource: ${e}`);
|
|
326
|
+
logger.info(`Force deleting podchaos resource`);
|
|
327
|
+
return deleteResourceByLabel({ ...deleteArgs, force: true });
|
|
328
|
+
});
|
|
357
329
|
}
|
|
358
330
|
|
|
359
331
|
return execHelmCommand({
|
|
@@ -514,234 +486,12 @@ export async function awaitL2BlockNumber(
|
|
|
514
486
|
|
|
515
487
|
export async function restartBot(namespace: string, logger: Logger) {
|
|
516
488
|
logger.info(`Restarting bot`);
|
|
517
|
-
await deleteResourceByLabel({ resource: 'pods', namespace, label: 'app
|
|
489
|
+
await deleteResourceByLabel({ resource: 'pods', namespace, label: 'app=bot' });
|
|
518
490
|
await sleep(10 * 1000);
|
|
519
|
-
|
|
520
|
-
// Waiting for PodReadyToStartContainers ensures the pod is scheduled and starting without blocking on full readiness.
|
|
521
|
-
await waitForResourceByLabel({
|
|
522
|
-
resource: 'pods',
|
|
523
|
-
namespace,
|
|
524
|
-
label: 'app.kubernetes.io/name=bot',
|
|
525
|
-
condition: 'PodReadyToStartContainers',
|
|
526
|
-
});
|
|
491
|
+
await waitForResourceByLabel({ resource: 'pods', namespace, label: 'app=bot' });
|
|
527
492
|
logger.info(`Bot restarted`);
|
|
528
493
|
}
|
|
529
494
|
|
|
530
|
-
/**
|
|
531
|
-
* Installs or upgrades the transfer bot Helm release for the given namespace.
|
|
532
|
-
* Intended for test setup to enable L2 traffic generation only when needed.
|
|
533
|
-
*/
|
|
534
|
-
export async function installTransferBot({
|
|
535
|
-
namespace,
|
|
536
|
-
spartanDir,
|
|
537
|
-
logger,
|
|
538
|
-
replicas = 1,
|
|
539
|
-
txIntervalSeconds = 10,
|
|
540
|
-
followChain = 'PENDING',
|
|
541
|
-
mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
|
|
542
|
-
mnemonicStartIndex,
|
|
543
|
-
botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
|
|
544
|
-
nodeUrl,
|
|
545
|
-
timeout = '15m',
|
|
546
|
-
reuseValues = true,
|
|
547
|
-
aztecSlotDuration = Number(process.env.AZTEC_SLOT_DURATION ?? 12),
|
|
548
|
-
}: {
|
|
549
|
-
namespace: string;
|
|
550
|
-
spartanDir: string;
|
|
551
|
-
logger: Logger;
|
|
552
|
-
replicas?: number;
|
|
553
|
-
txIntervalSeconds?: number;
|
|
554
|
-
followChain?: string;
|
|
555
|
-
mnemonic?: string;
|
|
556
|
-
mnemonicStartIndex?: number | string;
|
|
557
|
-
botPrivateKey?: string;
|
|
558
|
-
nodeUrl?: string;
|
|
559
|
-
timeout?: string;
|
|
560
|
-
reuseValues?: boolean;
|
|
561
|
-
aztecSlotDuration?: number;
|
|
562
|
-
}) {
|
|
563
|
-
const instanceName = `${namespace}-bot-transfers`;
|
|
564
|
-
const helmChartDir = getChartDir(spartanDir, 'aztec-bot');
|
|
565
|
-
const resolvedNodeUrl = nodeUrl ?? `http://${namespace}-rpc-aztec-node.${namespace}.svc.cluster.local:8080`;
|
|
566
|
-
|
|
567
|
-
logger.info(`Installing/upgrading transfer bot: replicas=${replicas}, followChain=${followChain}`);
|
|
568
|
-
|
|
569
|
-
const values: Record<string, string | number | boolean> = {
|
|
570
|
-
'bot.replicaCount': replicas,
|
|
571
|
-
'bot.txIntervalSeconds': txIntervalSeconds,
|
|
572
|
-
'bot.followChain': followChain,
|
|
573
|
-
'bot.botPrivateKey': botPrivateKey,
|
|
574
|
-
'bot.nodeUrl': resolvedNodeUrl,
|
|
575
|
-
'bot.mnemonic': mnemonic,
|
|
576
|
-
'bot.feePaymentMethod': 'fee_juice',
|
|
577
|
-
'aztec.slotDuration': aztecSlotDuration,
|
|
578
|
-
// Ensure bot can reach its own PXE started in-process (default rpc.port is 8080)
|
|
579
|
-
// Note: since aztec-bot depends on aztec-node with alias `bot`, env vars go under `bot.node.env`.
|
|
580
|
-
'bot.node.env.BOT_PXE_URL': 'http://127.0.0.1:8080',
|
|
581
|
-
// Provide L1 execution RPC for bridging fee juice
|
|
582
|
-
'bot.node.env.ETHEREUM_HOSTS': `http://${namespace}-eth-execution.${namespace}.svc.cluster.local:8545`,
|
|
583
|
-
// Provide L1 mnemonic for bridging (falls back to labs mnemonic)
|
|
584
|
-
'bot.node.env.BOT_L1_MNEMONIC': mnemonic,
|
|
585
|
-
};
|
|
586
|
-
// Ensure we derive a funded L1 key (index 0 is funded on anvil default mnemonic)
|
|
587
|
-
if (mnemonicStartIndex === undefined) {
|
|
588
|
-
values['bot.mnemonicStartIndex'] = 0;
|
|
589
|
-
}
|
|
590
|
-
// Also pass a funded private key directly if available
|
|
591
|
-
if (process.env.FUNDING_PRIVATE_KEY) {
|
|
592
|
-
values['bot.node.env.BOT_L1_PRIVATE_KEY'] = process.env.FUNDING_PRIVATE_KEY;
|
|
593
|
-
}
|
|
594
|
-
// Align bot image with the running network image: prefer env var, else detect from a validator pod
|
|
595
|
-
let repositoryFromEnv: string | undefined;
|
|
596
|
-
let tagFromEnv: string | undefined;
|
|
597
|
-
const aztecDockerImage = process.env.AZTEC_DOCKER_IMAGE;
|
|
598
|
-
if (aztecDockerImage && aztecDockerImage.includes(':')) {
|
|
599
|
-
const lastColon = aztecDockerImage.lastIndexOf(':');
|
|
600
|
-
repositoryFromEnv = aztecDockerImage.slice(0, lastColon);
|
|
601
|
-
tagFromEnv = aztecDockerImage.slice(lastColon + 1);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
let repository = repositoryFromEnv;
|
|
605
|
-
let tag = tagFromEnv;
|
|
606
|
-
if (!repository || !tag) {
|
|
607
|
-
try {
|
|
608
|
-
const { stdout } = await execAsync(
|
|
609
|
-
`kubectl get pods -l app.kubernetes.io/component=validator -n ${namespace} -o jsonpath='{.items[0].spec.containers[?(@.name=="aztec")].image}' | cat`,
|
|
610
|
-
);
|
|
611
|
-
const image = stdout.trim().replace(/^'|'$/g, '');
|
|
612
|
-
if (image && image.includes(':')) {
|
|
613
|
-
const lastColon = image.lastIndexOf(':');
|
|
614
|
-
repository = image.slice(0, lastColon);
|
|
615
|
-
tag = image.slice(lastColon + 1);
|
|
616
|
-
}
|
|
617
|
-
} catch (err) {
|
|
618
|
-
logger.warn(`Could not detect aztec image from validator pod: ${String(err)}`);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
if (repository && tag) {
|
|
622
|
-
values['global.aztecImage.repository'] = repository;
|
|
623
|
-
values['global.aztecImage.tag'] = tag;
|
|
624
|
-
}
|
|
625
|
-
if (mnemonicStartIndex !== undefined) {
|
|
626
|
-
values['bot.mnemonicStartIndex'] =
|
|
627
|
-
typeof mnemonicStartIndex === 'string' ? mnemonicStartIndex : Number(mnemonicStartIndex);
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
await execHelmCommand({
|
|
631
|
-
instanceName,
|
|
632
|
-
helmChartDir,
|
|
633
|
-
namespace,
|
|
634
|
-
valuesFile: undefined,
|
|
635
|
-
timeout,
|
|
636
|
-
values: values as unknown as Record<string, string | number | boolean>,
|
|
637
|
-
reuseValues,
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
if (replicas > 0) {
|
|
641
|
-
await waitForResourceByLabel({
|
|
642
|
-
resource: 'pods',
|
|
643
|
-
namespace,
|
|
644
|
-
label: 'app.kubernetes.io/name=bot',
|
|
645
|
-
condition: 'PodReadyToStartContainers',
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* Uninstalls the transfer bot Helm release from the given namespace.
|
|
652
|
-
* Intended for test teardown to clean up bot resources.
|
|
653
|
-
*/
|
|
654
|
-
export async function uninstallTransferBot(namespace: string, logger: Logger) {
|
|
655
|
-
const instanceName = `${namespace}-bot-transfers`;
|
|
656
|
-
logger.info(`Uninstalling transfer bot release ${instanceName}`);
|
|
657
|
-
await execAsync(`helm uninstall ${instanceName} --namespace ${namespace} --wait --ignore-not-found`);
|
|
658
|
-
// Ensure any leftover pods are removed
|
|
659
|
-
await deleteResourceByLabel({ resource: 'pods', namespace, label: 'app.kubernetes.io/name=bot' }).catch(
|
|
660
|
-
() => undefined,
|
|
661
|
-
);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
/**
|
|
665
|
-
* Enables or disables probabilistic transaction dropping on validators and waits for rollout.
|
|
666
|
-
* Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
|
|
667
|
-
*/
|
|
668
|
-
export async function setValidatorTxDrop({
|
|
669
|
-
namespace,
|
|
670
|
-
enabled,
|
|
671
|
-
probability,
|
|
672
|
-
logger,
|
|
673
|
-
}: {
|
|
674
|
-
namespace: string;
|
|
675
|
-
enabled: boolean;
|
|
676
|
-
probability: number;
|
|
677
|
-
logger: Logger;
|
|
678
|
-
}) {
|
|
679
|
-
const drop = enabled ? 'true' : 'false';
|
|
680
|
-
const prob = String(probability);
|
|
681
|
-
|
|
682
|
-
const selectors = ['app=validator', 'app.kubernetes.io/component=validator'];
|
|
683
|
-
let updated = false;
|
|
684
|
-
for (const selector of selectors) {
|
|
685
|
-
try {
|
|
686
|
-
const list = await execAsync(`kubectl get statefulset -l ${selector} -n ${namespace} --no-headers -o name | cat`);
|
|
687
|
-
const names = list.stdout
|
|
688
|
-
.split('\n')
|
|
689
|
-
.map(s => s.trim())
|
|
690
|
-
.filter(Boolean);
|
|
691
|
-
if (names.length === 0) {
|
|
692
|
-
continue;
|
|
693
|
-
}
|
|
694
|
-
const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
|
|
695
|
-
logger.info(`command: ${cmd}`);
|
|
696
|
-
await execAsync(cmd);
|
|
697
|
-
updated = true;
|
|
698
|
-
} catch (e) {
|
|
699
|
-
logger.warn(`Failed to update validators with selector ${selector}: ${String(e)}`);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
if (!updated) {
|
|
704
|
-
logger.warn(`No validator StatefulSets found in ${namespace}. Skipping tx drop toggle.`);
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// Restart validator pods to ensure env vars take effect and wait for readiness
|
|
709
|
-
await restartValidators(namespace, logger);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
export async function restartValidators(namespace: string, logger: Logger) {
|
|
713
|
-
const selectors = ['app=validator', 'app.kubernetes.io/component=validator'];
|
|
714
|
-
let any = false;
|
|
715
|
-
for (const selector of selectors) {
|
|
716
|
-
try {
|
|
717
|
-
const { stdout } = await execAsync(`kubectl get pods -l ${selector} -n ${namespace} --no-headers -o name | cat`);
|
|
718
|
-
if (!stdout || stdout.trim().length === 0) {
|
|
719
|
-
continue;
|
|
720
|
-
}
|
|
721
|
-
any = true;
|
|
722
|
-
await deleteResourceByLabel({ resource: 'pods', namespace, label: selector });
|
|
723
|
-
} catch (e) {
|
|
724
|
-
logger.warn(`Error restarting validator pods with selector ${selector}: ${String(e)}`);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
if (!any) {
|
|
729
|
-
logger.warn(`No validator pods found to restart in ${namespace}.`);
|
|
730
|
-
return;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
// Wait for either label to be Ready
|
|
734
|
-
for (const selector of selectors) {
|
|
735
|
-
try {
|
|
736
|
-
await waitForResourceByLabel({ resource: 'pods', namespace, label: selector });
|
|
737
|
-
return;
|
|
738
|
-
} catch {
|
|
739
|
-
// try next
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
logger.warn(`Validator pods did not report Ready; continuing.`);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
495
|
export async function enableValidatorDynamicBootNode(
|
|
746
496
|
instanceName: string,
|
|
747
497
|
namespace: string,
|