datahaven/test/cli/handlers/deploy/parameters.ts
Ahmad Kaouk 9344e243cf
perf: Batch runtime parameter updates to speed up E2E setup (#368)
## Summary
Optimizes the DataHaven parameter configuration during E2E test
infrastructure setup by batching multiple extrinsics into a single
transaction, reducing setup time.
## Problem
Setting runtime parameters required 5 separate
`Parameters.set_parameter` calls, each waiting for block finality. This
created unnecessary delays during infrastructure setup since each call
blocked sequentially.
## Solution
- **Batch parameter updates:** Combine all `Parameters.set_parameter
`calls into a single `Utility.batch_all` transaction wrapped in
`Sudo.sudo`.
- **~5× faster parameter setup:** Only wait for finality once instead of
5 separate times
- **Code simplification:** Refactored parameter handling code, removing
~190 lines of unnecessary abstractions and complexity
2025-12-22 15:57:32 +01:00

37 lines
1.2 KiB
TypeScript

import { setDataHavenParameters } from "scripts/set-datahaven-parameters";
import { logger, printDivider, printHeader } from "utils";
import { DEFAULT_SUBSTRATE_WS_PORT } from "utils/constants";
import type { ParameterCollection } from "utils/parameters";
/**
* A helper function to set DataHaven parameters from a ParameterCollection
*
* @param options Options for setting parameters
* @param options.launchedNetwork The launched network instance
* @param options.collection The parameter collection
* @returns Promise resolving to true if parameters were set successfully
*/
export const setParametersFromCollection = async ({
collection,
skipSetParameters
}: {
collection: ParameterCollection;
skipSetParameters: boolean;
}): Promise<boolean> => {
printHeader("Setting DataHaven Runtime Parameters");
if (skipSetParameters) {
logger.info("🏳️ Skipping parameter setting");
printDivider();
return false;
}
const parametersFilePath = await collection.generateParametersFile();
const rpcUrl = `ws://127.0.0.1:${DEFAULT_SUBSTRATE_WS_PORT}`;
const parametersSet = await setDataHavenParameters(rpcUrl, parametersFilePath);
printDivider();
return parametersSet;
};