mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## 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
37 lines
1.2 KiB
TypeScript
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;
|
|
};
|