4
4
# Helper functions
5
5
#
6
6
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
12
11
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'
18
17
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 "
24
23
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
35
34
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
41
40
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
50
49
}
51
50
52
-
53
51
# Default values
54
52
EXEC_TYPE=" docker"
55
53
NETWORK=" mainnet"
@@ -60,69 +58,69 @@ BIN_PATH="./target/release/node-subtensor"
60
58
# Getting arguments from user
61
59
while [[ $# -gt 0 ]]; do
62
60
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
+ ;;
99
97
esac
100
98
done
101
99
102
100
# Verifying arguments values
103
101
if ! [[ " $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
106
104
fi
107
105
108
106
if ! [[ " $NETWORK " =~ ^(mainnet| testnet)$ ]]; then
109
- echo " Network not expected: $NETWORK "
110
- exit 1
107
+ echo " Network not expected: $NETWORK "
108
+ exit 1
111
109
fi
112
110
113
111
if ! [[ " $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
116
114
fi
117
115
118
116
# Running subtensor
119
117
case $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
+ ;;
128
126
esac
0 commit comments