Scripts for building config variations

This commit is contained in:
Gusto 2023-08-14 22:25:09 +03:00
commit 99ec9cec32
8 changed files with 196 additions and 0 deletions

22
scripts/build_cases.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Check if the input file is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path_to_csv_file>"
exit 1
fi
# Read the CSV file line by line
while IFS=, read -r overlay_type node_count committees; do
if [[ "$overlay_type" == "overlay" ]]; then
continue
fi
CONFIG_NAME="${overlay_type}_${node_count}_${committees}"
./build_config.sh "$overlay_type" "$committees" "$node_count" $CONFIG_NAME"_view_1_default"
./build_config.sh "$overlay_type" "$committees" "$node_count" $CONFIG_NAME"_view_10_default" 10
./build_config.sh "$overlay_type" "$committees" "$node_count" $CONFIG_NAME"_view_10_optimistic" 10 optimistic
./build_config.sh "$overlay_type" "$committees" "$node_count" $CONFIG_NAME"_view_10_pessimistic" 10 pessimistic
mv *.json ../configs/
done < $1

57
scripts/build_config.sh Executable file
View File

@ -0,0 +1,57 @@
#!/bin/bash
if [ "$#" -lt 4 ]; then
echo "Usage: $0 <overlay_type> <number_of_committees> <node_count> <config_name> [max_view] [network_config]"
exit 1
fi
if ! command -v jq &> /dev/null; then
echo "jq is not installed."
exit 1
fi
if ! command -v sponge &> /dev/null; then
echo "moreutils is not installed."
exit 1
fi
OVERLAY_TYPE=$1
NUMBER_OF_COMMITTEES=$2
NODE_COUNT=$3
CONFIG_NAME=$4
MAX_VIEW=${5:-1}
NETWORK_CONFIG=${6:-default}
TEMPLATE_PATH="config_builder/template.json"
TEMPORARY_PATH="config_builder/temp.json"
NETWORK_UPDATE_PATH="config_builder/network/network_$NETWORK_CONFIG.json"
RECORD_UPDATE_PATH="config_builder/record.json"
# Update the template with the network settings
jq --slurpfile networkUpdate $NETWORK_UPDATE_PATH \
'.network_settings = $networkUpdate[0].network_settings' $TEMPLATE_PATH | sponge $TEMPORARY_PATH
# Update the template with the record settings
jq --slurpfile recordUpdate $RECORD_UPDATE_PATH \
'.record_settings = $recordUpdate[0].record_settings' $TEMPORARY_PATH | sponge $TEMPORARY_PATH
# Update new JSON with the command line arguments
jq --arg numCommit "$NUMBER_OF_COMMITTEES" \
--arg nodeCount "$NODE_COUNT" \
--arg confName "$CONFIG_NAME" \
--arg maxView "$MAX_VIEW" \
'.node_count = ($nodeCount | tonumber) | .stream_settings.path = "output/" + $confName + ".json" | .wards[0].max_view = ($maxView | tonumber)' $TEMPORARY_PATH | sponge $TEMPORARY_PATH
if [ "$OVERLAY_TYPE" == "tree" ]; then
jq --arg numCommit "$NUMBER_OF_COMMITTEES" \
'.overlay_settings.number_of_committees = ($numCommit | tonumber)' $TEMPORARY_PATH | sponge $TEMPORARY_PATH
elif [ "$OVERLAY_TYPE" == "branch" ]; then
cat $TEMPORARY_PATH | jq --arg numCommit "$NUMBER_OF_COMMITTEES" \
'.overlay_settings.branch_depth = ($numCommit | tonumber)' $TEMPORARY_PATH | sponge $TEMPORARY_PATH
else
echo "Unknown overlay type. Supported types are 'tree' and 'branch'."
exit 1
fi
mv $TEMPORARY_PATH "$CONFIG_NAME.json"
echo "Configuration built and saved as $CONFIG_NAME.json"

View File

@ -0,0 +1,20 @@
{
"network_settings": {
"network_behaviors": {
"north america:north america": "10ms",
"north america:europe": "150ms",
"north america:asia": "250ms",
"europe:europe": "10ms",
"europe:asia": "200ms",
"europe:north america": "150ms",
"asia:north america": "250ms",
"asia:europe": "200ms",
"asia:asia": "10ms"
},
"regions": {
"north america": 0.4,
"europe": 0.3,
"asia": 0.3
}
}
}

View File

@ -0,0 +1,21 @@
{
"network_settings": {
"network_behaviors": {
"north america:north america": "5ms",
"north america:europe": "80ms",
"north america:asia": "120ms",
"europe:europe": "5ms",
"europe:asia": "90ms",
"europe:north america": "80ms",
"asia:north america": "120ms",
"asia:europe": "90ms",
"asia:asia": "5ms"
},
"regions": {
"north america": 0.3,
"europe": 0.3,
"asia": 0.4
}
}
}

View File

@ -0,0 +1,21 @@
{
"network_settings": {
"network_behaviors": {
"north america:north america": "20ms",
"north america:europe": "250ms",
"north america:asia": "350ms",
"europe:europe": "20ms",
"europe:asia": "300ms",
"europe:north america": "250ms",
"asia:north america": "350ms",
"asia:europe": "300ms",
"asia:asia": "20ms"
},
"regions": {
"north america": 0.4,
"europe": 0.3,
"asia": 0.3
}
}
}

View File

@ -0,0 +1,6 @@
{
"record_settings": {
"node_id": true,
"current_view": true
}
}

View File

@ -0,0 +1,38 @@
{
"network_settings": {
"network_behaviors": {
"north america:north america": "10ms",
"north america:europe": "150ms",
"north america:asia": "250ms",
"europe:europe": "10ms",
"europe:asia": "200ms",
"europe:north america": "150ms",
"asia:north america": "250ms",
"asia:europe": "200ms",
"asia:asia": "10ms"
},
"regions": {
"north america": 0.4,
"europe": 0.4,
"asia": 0.3
}
},
"overlay_settings": {},
"node_settings": {
"network_capacity_kbps": 10000024,
"timeout": "1000ms"
},
"step_time": "100ms",
"runner_settings": "Sync",
"stream_settings": {
"path": "output/100_3_33_1_view_1.json"
},
"node_count": 100,
"views_count": 10,
"leaders_count": 1,
"seed": 0,
"wards": [
{"max_view": 1}
],
"record_settings": {}
}

11
scripts/test_cases.csv Normal file
View File

@ -0,0 +1,11 @@
overlay,nodes,committees_or_depth
tree,100,3
tree,500,7
tree,1000,11
tree,5000,33
tree,10000,57
branch,1764,7
branch,2256,8
branch,2880,9
branch,3590,10
branch,4378,11
1 overlay nodes committees_or_depth
2 tree 100 3
3 tree 500 7
4 tree 1000 11
5 tree 5000 33
6 tree 10000 57
7 branch 1764 7
8 branch 2256 8
9 branch 2880 9
10 branch 3590 10
11 branch 4378 11