44# Helper functions
55#
66
7- function run_command()
8- {
9- F_NETWORK=$1
10- F_NODE_TYPE=$2
11- F_BIN_PATH=$3
7+ function run_command() {
8+ F_NETWORK=$1
9+ F_NODE_TYPE=$2
10+ F_BIN_PATH=$3
1211
13- # Different command options by network and node type
14- MAINNET_BOOTNODE=' --bootnodes /dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC'
15- TESTNET_BOOTNODE=' --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/ws/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr'
16- NODE_TYPE_ARCHIVE=' --pruning=archive'
17- NODE_TYPE_LITE=' --sync warp'
12+ # Different command options by network and node type
13+ MAINNET_BOOTNODE=' --bootnodes /dns/bootnode.finney.chain.opentensor.ai/tcp/30333/ws/p2p/12D3KooWRwbMb85RWnT8DSXSYMWQtuDwh4LJzndoRrTDotTR5gDC'
14+ TESTNET_BOOTNODE=' --bootnodes /dns/bootnode.test.finney.opentensor.ai/tcp/30333/ws/p2p/12D3KooWPM4mLcKJGtyVtkggqdG84zWrd7Rij6PGQDoijh1X86Vr'
15+ NODE_TYPE_ARCHIVE=' --pruning=archive'
16+ NODE_TYPE_LITE=' --sync warp'
1817
19- # Options by the type of node we offer
20- MAINNET_ARCHIVE_OPTIONS=" $MAINNET_BOOTNODE $NODE_TYPE_ARCHIVE "
21- MAINNET_LITE_OPTIONS=" $MAINNET_BOOTNODE $NODE_TYPE_LITE "
22- TESTNET_ARCHIVE_OPTIONS=" $TESTNET_BOOTNODE $NODE_TYPE_ARCHIVE "
23- TESTNET_LITE_OPTIONS=" $TESTNET_BOOTNODE $NODE_TYPE_LITE "
18+ # Options by the type of node we offer
19+ MAINNET_ARCHIVE_OPTIONS=" $MAINNET_BOOTNODE $NODE_TYPE_ARCHIVE "
20+ MAINNET_LITE_OPTIONS=" $MAINNET_BOOTNODE $NODE_TYPE_LITE "
21+ TESTNET_ARCHIVE_OPTIONS=" $TESTNET_BOOTNODE $NODE_TYPE_ARCHIVE "
22+ TESTNET_LITE_OPTIONS=" $TESTNET_BOOTNODE $NODE_TYPE_LITE "
2423
25- # Checking options to use
26- if [[ " $F_NETWORK " == " mainnet" ]] && [[ " $F_NODE_TYPE " == " archive" ]]; then
27- SPECIFIC_OPTIONS=$MAINNET_ARCHIVE_OPTIONS
28- elif [[ " $F_NETWORK " == " mainnet" ]] && [[ " $F_NODE_TYPE " == " lite" ]]; then
29- SPECIFIC_OPTIONS=$MAINNET_LITE_OPTIONS
30- elif [[ " $F_NETWORK " == " testnet" ]] && [[ " $F_NODE_TYPE " == " archive" ]]; then
31- SPECIFIC_OPTIONS=$TESTNET_ARCHIVE_OPTIONS
32- elif [[ " $F_NETWORK " == " testnet" ]] && [[ " $F_NODE_TYPE " == " lite" ]]; then
33- SPECIFIC_OPTIONS=$TESTNET_LITE_OPTIONS
34- fi
24+ # Checking options to use
25+ if [[ " $F_NETWORK " == " mainnet" ]] && [[ " $F_NODE_TYPE " == " archive" ]]; then
26+ SPECIFIC_OPTIONS=$MAINNET_ARCHIVE_OPTIONS
27+ elif [[ " $F_NETWORK " == " mainnet" ]] && [[ " $F_NODE_TYPE " == " lite" ]]; then
28+ SPECIFIC_OPTIONS=$MAINNET_LITE_OPTIONS
29+ elif [[ " $F_NETWORK " == " testnet" ]] && [[ " $F_NODE_TYPE " == " archive" ]]; then
30+ SPECIFIC_OPTIONS=$TESTNET_ARCHIVE_OPTIONS
31+ elif [[ " $F_NETWORK " == " testnet" ]] && [[ " $F_NODE_TYPE " == " lite" ]]; then
32+ SPECIFIC_OPTIONS=$TESTNET_LITE_OPTIONS
33+ fi
3534
36- if [ ! -f $F_BIN_PATH ]; then
37- echo " Binary '$F_BIN_PATH ' does not exist. You can use -p or --bin-path to specify a different location."
38- echo " Please ensure you have compiled the binary first."
39- exit 1
40- fi
35+ if [ ! -f $F_BIN_PATH ]; then
36+ echo " Binary '$F_BIN_PATH ' does not exist. You can use -p or --bin-path to specify a different location."
37+ echo " Please ensure you have compiled the binary first."
38+ exit 1
39+ fi
4140
42- # Command to run subtensor
43- $F_BIN_PATH \
44- --base-path /tmp/blockchain \
45- --chain ./raw_spec .json \
46- --rpc-external --rpc-cors all \
47- --no-mdns \
48- --rpc-max-connections 10000 --in-peers 500 --out-peers 500 \
49- $SPECIFIC_OPTIONS
41+ # Command to run subtensor
42+ $F_BIN_PATH \
43+ --base-path /tmp/blockchain \
44+ --chain ./raw_spec_finney .json \
45+ --rpc-external --rpc-cors all \
46+ --no-mdns \
47+ --rpc-max-connections 10000 --in-peers 500 --out-peers 500 \
48+ $SPECIFIC_OPTIONS
5049}
5150
52-
5351# Default values
5452EXEC_TYPE=" docker"
5553NETWORK=" mainnet"
@@ -60,69 +58,69 @@ BIN_PATH="./target/release/node-subtensor"
6058# Getting arguments from user
6159while [[ $# -gt 0 ]]; do
6260 case $1 in
63- -h| --help)
64- help
65- exit 0
66- ;;
67- -e| --execution)
68- EXEC_TYPE=" $2 "
69- shift # past argument
70- shift # past value
71- ;;
72- -b| --build)
73- BUILD=" --build"
74- shift # past argument
75- ;;
76- -n| --network)
77- NETWORK=" $2 "
78- shift
79- shift
80- ;;
81- -t| --node-type)
82- NODE_TYPE=" $2 "
83- shift
84- shift
85- ;;
86- -p| --bin-path)
87- BIN_PATH=" $2 "
88- shift
89- shift
90- ;;
91- - * | --* )
92- echo " Unknown option $1 "
93- exit 1
94- ;;
95- * )
96- POSITIONAL_ARGS+=(" $1 " )
97- shift
98- ;;
61+ -h | --help)
62+ help
63+ exit 0
64+ ;;
65+ -e | --execution)
66+ EXEC_TYPE=" $2 "
67+ shift # past argument
68+ shift # past value
69+ ;;
70+ -b | --build)
71+ BUILD=" --build"
72+ shift # past argument
73+ ;;
74+ -n | --network)
75+ NETWORK=" $2 "
76+ shift
77+ shift
78+ ;;
79+ -t | --node-type)
80+ NODE_TYPE=" $2 "
81+ shift
82+ shift
83+ ;;
84+ -p | --bin-path)
85+ BIN_PATH=" $2 "
86+ shift
87+ shift
88+ ;;
89+ - * | --* )
90+ echo " Unknown option $1 "
91+ exit 1
92+ ;;
93+ * )
94+ POSITIONAL_ARGS+=(" $1 " )
95+ shift
96+ ;;
9997 esac
10098done
10199
102100# Verifying arguments values
103101if ! [[ " $EXEC_TYPE " =~ ^(docker| binary)$ ]]; then
104- echo " Exec type not expected: $EXEC_TYPE "
105- exit 1
102+ echo " Exec type not expected: $EXEC_TYPE "
103+ exit 1
106104fi
107105
108106if ! [[ " $NETWORK " =~ ^(mainnet| testnet)$ ]]; then
109- echo " Network not expected: $NETWORK "
110- exit 1
107+ echo " Network not expected: $NETWORK "
108+ exit 1
111109fi
112110
113111if ! [[ " $NODE_TYPE " =~ ^(lite| archive)$ ]]; then
114- echo " Node type not expected: $NODE_TYPE "
115- exit 1
112+ echo " Node type not expected: $NODE_TYPE "
113+ exit 1
116114fi
117115
118116# Running subtensor
119117case $EXEC_TYPE in
120- docker)
121- docker compose down --remove-orphans
122- echo " Running docker compose up $BUILD --detach $NETWORK -$NODE_TYPE "
123- docker compose up $BUILD --detach $NETWORK -$NODE_TYPE
124- ;;
125- binary)
126- run_command $NETWORK $NODE_TYPE $BIN_PATH
127- ;;
118+ docker)
119+ docker compose down --remove-orphans
120+ echo " Running docker compose up $BUILD --detach $NETWORK -$NODE_TYPE "
121+ docker compose up $BUILD --detach $NETWORK -$NODE_TYPE
122+ ;;
123+ binary)
124+ run_command $NETWORK $NODE_TYPE $BIN_PATH
125+ ;;
128126esac
0 commit comments