-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions_net_host.sh
232 lines (216 loc) · 9.41 KB
/
functions_net_host.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
chain_image=$1
chain_type=$2
node_name=$3
base_path_=$4
address=$5
port=$6
rpc_port=$7
node_key=$8
telemetry_url=$9
password=${10}
secret_phrase=${11}
boot_nodes=${12}
base_path="$base_path_/$node_name"
chain_spec="$base_path_/$chain_type"_spec.json
chain_spec_raw="${chain_spec%.*}"_raw.json
log_max_size="10m"
log_max_file=10
# docker run -p "$port":"$port" -p "$rpc_port":"$rpc_port" -v "$base_path_":"$base_path_" "$chain_image"
# docker run -v "$base_path_":"$base_path_" "$chain_image"
mkdir -p "$base_path_"
export_spec() {
docker run -v "$base_path_":"$base_path_" "$chain_image" \
build-spec \
--disable-default-bootnode \
--chain "$chain_type" \
> "$chain_spec"
}
spec_to_raw() {
docker run -v "$base_path_":"$base_path_" "$chain_image" \
build-spec \
--chain "$chain_spec" \
--raw \
--disable-default-bootnode \
> "$chain_spec_raw"
}
export_raw_spec() {
export_spec
spec_to_raw
}
add_keys_to_keystore() {
docker run -v "$base_path_":"$base_path_" "$chain_image" \
key insert \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--scheme Sr25519 \
--suri "$secret_phrase" \
--password "$password" \
--key-type aura
docker run -v "$base_path_":"$base_path_" "$chain_image" \
key insert \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--scheme Ed25519 \
--suri "$secret_phrase" \
--password "$password" \
--key-type gran
}
# Reference:
# https://docs.substrate.io/deploy/prepare-to-deploy/#common-deployment-targets
# validator, rpc, archive
run_node01_() {
docker run \
--network host \
-v "$base_path_:$base_path_" \
--log-driver json-file \
--log-opt max-size="$log_max_size" \
--log-opt max-file="$log_max_file" \
-d \
"$chain_image" \
\
--validator \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--name "$node_name" \
--node-key "$node_key" \
--public-addr /ip4/"$address"/tcp/"$port" \
--port "$port" \
--rpc-port "$rpc_port" \
--rpc-methods Safe \
--unsafe-rpc-external \
--rpc-cors all \
--rpc-max-connections 5000 \
--state-pruning archive \
--telemetry-url "$telemetry_url" \
--password "$password"
}
# validator, rpc
run_node02_() {
docker run \
--network host \
-v "$base_path_:$base_path_" \
--log-driver json-file \
--log-opt max-size="$log_max_size" \
--log-opt max-file="$log_max_file" \
-d \
"$chain_image" \
\
--validator \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--name "$node_name" \
--node-key "$node_key" \
--public-addr /ip4/"$address"/tcp/"$port" \
--port "$port" \
--rpc-port "$rpc_port" \
--rpc-methods Safe \
--unsafe-rpc-external \
--rpc-cors all \
--rpc-max-connections 5000 \
--bootnodes "$boot_nodes" \
--password "$password"
}
# validator, rpc
run_node03_() {
docker run \
--network host \
-v "$base_path_:$base_path_" \
--log-driver json-file \
--log-opt max-size="$log_max_size" \
--log-opt max-file="$log_max_file" \
-d \
"$chain_image" \
\
--validator \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--name "$node_name" \
--node-key "$node_key" \
--public-addr /ip4/"$address"/tcp/"$port" \
--port "$port" \
--rpc-port "$rpc_port" \
--rpc-methods Safe \
--unsafe-rpc-external \
--rpc-cors all \
--rpc-max-connections 5000 \
--bootnodes "$boot_nodes" \
--password "$password"
}
# validator, rpc
run_node04_() {
docker run \
--network host \
-v "$base_path_:$base_path_" \
--log-driver json-file \
--log-opt max-size="$log_max_size" \
--log-opt max-file="$log_max_file" \
-d \
"$chain_image" \
\
--validator \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--name "$node_name" \
--node-key "$node_key" \
--public-addr /ip4/"$address"/tcp/"$port" \
--port "$port" \
--rpc-port "$rpc_port" \
--rpc-methods Safe \
--unsafe-rpc-external \
--rpc-cors all \
--rpc-max-connections 5000 \
--bootnodes "$boot_nodes" \
--password "$password"
}
# validator, rpc, archive
run_node05_() {
docker run \
--network host \
-v "$base_path_:$base_path_" \
--log-driver json-file \
--log-opt max-size="$log_max_size" \
--log-opt max-file="$log_max_file" \
-d \
"$chain_image" \
\
--validator \
--base-path "$base_path" \
--chain "$chain_spec_raw" \
--name "$node_name" \
--node-key "$node_key" \
--public-addr /ip4/"$address"/tcp/"$port" \
--port "$port" \
--rpc-port "$rpc_port" \
--rpc-methods Safe \
--unsafe-rpc-external \
--rpc-cors all \
--rpc-max-connections 5000 \
--state-pruning archive \
--bootnodes "$boot_nodes" \
--password "$password"
}
run_node01() {
export_raw_spec
add_keys_to_keystore
run_node01_
}
run_node02() {
export_raw_spec
add_keys_to_keystore
run_node02_
}
run_node03() {
export_raw_spec
add_keys_to_keystore
run_node03_
}
run_node04() {
export_raw_spec
add_keys_to_keystore
run_node04_
}
run_node05() {
export_raw_spec
add_keys_to_keystore
run_node05_
}