commit 99ec9cec324c6bb78ff773e7ee5a2a85a3f667af Author: Gusto Date: Mon Aug 14 22:25:09 2023 +0300 Scripts for building config variations diff --git a/scripts/build_cases.sh b/scripts/build_cases.sh new file mode 100755 index 0000000..bee77dd --- /dev/null +++ b/scripts/build_cases.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Check if the input file is provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + 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 + diff --git a/scripts/build_config.sh b/scripts/build_config.sh new file mode 100755 index 0000000..5fe6cd6 --- /dev/null +++ b/scripts/build_config.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +if [ "$#" -lt 4 ]; then + echo "Usage: $0 [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" diff --git a/scripts/config_builder/network/network_default.json b/scripts/config_builder/network/network_default.json new file mode 100644 index 0000000..acaf917 --- /dev/null +++ b/scripts/config_builder/network/network_default.json @@ -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 + } + } +} diff --git a/scripts/config_builder/network/network_optimistic.json b/scripts/config_builder/network/network_optimistic.json new file mode 100644 index 0000000..b8a5b8a --- /dev/null +++ b/scripts/config_builder/network/network_optimistic.json @@ -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 + } + } +} + diff --git a/scripts/config_builder/network/network_pessimistic.json b/scripts/config_builder/network/network_pessimistic.json new file mode 100644 index 0000000..f6842b1 --- /dev/null +++ b/scripts/config_builder/network/network_pessimistic.json @@ -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 + } + } +} + diff --git a/scripts/config_builder/record.json b/scripts/config_builder/record.json new file mode 100644 index 0000000..01c3304 --- /dev/null +++ b/scripts/config_builder/record.json @@ -0,0 +1,6 @@ +{ + "record_settings": { + "node_id": true, + "current_view": true + } +} diff --git a/scripts/config_builder/template.json b/scripts/config_builder/template.json new file mode 100644 index 0000000..1ed768a --- /dev/null +++ b/scripts/config_builder/template.json @@ -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": {} +} diff --git a/scripts/test_cases.csv b/scripts/test_cases.csv new file mode 100644 index 0000000..6870bb9 --- /dev/null +++ b/scripts/test_cases.csv @@ -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