2017-08-28 20:34:36 +04:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
|
2017-12-06 22:51:57 +04:00
|
|
|
set -e
|
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
node_dirs=()
|
|
|
|
node_pids=()
|
|
|
|
|
|
|
|
start_sandboxed_node() {
|
|
|
|
|
|
|
|
id=$1
|
|
|
|
max_peer_id=${max_peer_id:-9}
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
port=$((19730 + id))
|
|
|
|
rpc=$((18730 + id))
|
|
|
|
expected_pow="${expected_pow:-0.0}"
|
|
|
|
expected_connections="${expected_connections:-3}"
|
|
|
|
node_dir="$(mktemp -d -t tezos-node.XXXXXXXX)"
|
|
|
|
peers=("--no-bootstrap-peers")
|
|
|
|
for peer_port in $(seq 19730 $((19730 + max_peer_id))); do
|
|
|
|
peers+=("--peer")
|
|
|
|
peers+=("127.0.0.1:$peer_port")
|
|
|
|
done
|
|
|
|
peers+=("--closed")
|
2018-01-22 12:20:46 +04:00
|
|
|
node="${local_node}"
|
2017-08-28 20:34:36 +04:00
|
|
|
sandbox_param="--sandbox=$sandbox_file"
|
|
|
|
|
2018-01-22 12:20:46 +04:00
|
|
|
if ! [ -f "$sandbox_file" ]; then
|
|
|
|
cat > "$sandbox_file" <<EOF
|
|
|
|
{
|
|
|
|
"genesis_pubkey":
|
2018-04-09 18:28:43 +04:00
|
|
|
"edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"
|
2018-01-22 12:20:46 +04:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
node_dirs+=("$node_dir")
|
|
|
|
|
2018-04-28 12:19:21 +04:00
|
|
|
if [ -n "$USE_TLS" ]; then
|
|
|
|
$node config init \
|
|
|
|
--data-dir "$node_dir" \
|
|
|
|
--net-addr "127.0.0.1:$port" \
|
|
|
|
--rpc-addr "127.0.0.1:$rpc" \
|
|
|
|
--rpc-tls "${node_dir}/tezos.crt,${node_dir}/tezos.key" \
|
|
|
|
--expected-pow "$expected_pow" \
|
|
|
|
--connections "$expected_connections"
|
|
|
|
|
|
|
|
cat > "${node_dir}/tezos.crt" <<EOF
|
|
|
|
Certificate:
|
|
|
|
Data:
|
|
|
|
Version: 3 (0x2)
|
|
|
|
Serial Number: 1 (0x1)
|
|
|
|
Signature Algorithm: sha256WithRSAEncryption
|
|
|
|
Issuer: CN=Easy-RSA CA
|
|
|
|
Validity
|
|
|
|
Not Before: Mar 30 13:07:24 2018 GMT
|
|
|
|
Not After : Mar 27 13:07:24 2028 GMT
|
|
|
|
Subject: CN=tezos
|
|
|
|
Subject Public Key Info:
|
|
|
|
Public Key Algorithm: rsaEncryption
|
|
|
|
Public-Key: (2048 bit)
|
|
|
|
Modulus:
|
|
|
|
00:d3:61:ba:81:6a:0d:8f:0b:6f:84:65:ca:73:b5:
|
|
|
|
c6:2d:89:8e:83:90:9e:2c:e1:16:5f:2c:9d:44:00:
|
|
|
|
25:dd:a2:73:dc:41:06:81:fb:a1:0c:e9:17:db:63:
|
|
|
|
6b:c2:46:63:bc:31:4c:bc:76:50:a0:79:15:de:4a:
|
|
|
|
98:d1:eb:a3:d1:a9:4c:db:32:3e:05:23:be:60:b7:
|
|
|
|
5c:d1:4f:ec:fe:6d:a3:5f:75:0e:8d:e7:c5:d1:48:
|
|
|
|
6f:29:84:0a:cc:52:91:8b:8a:67:65:88:82:1a:a7:
|
|
|
|
31:6c:5c:00:1c:53:0e:fb:98:81:c7:5d:20:e8:72:
|
|
|
|
15:f1:53:e1:a8:e6:45:92:25:6b:a3:f6:67:da:63:
|
|
|
|
9f:fd:35:f6:54:04:c1:10:50:e9:5d:95:e3:12:7f:
|
|
|
|
e1:8f:bc:6c:65:48:f6:0c:eb:9e:d1:cb:30:1f:da:
|
|
|
|
ff:a2:d5:5d:bb:de:e5:df:b8:52:f3:70:6c:2d:8a:
|
|
|
|
e9:bb:85:7f:33:14:bc:fa:1e:c5:c4:b3:9f:f3:10:
|
|
|
|
a3:1c:00:f6:8f:84:ae:a3:a3:08:ae:b8:38:41:0a:
|
|
|
|
a7:84:88:bf:9d:e3:0d:42:51:75:dd:b2:5c:8b:9c:
|
|
|
|
fa:82:ff:0d:bd:6f:f7:c3:b5:e4:49:3a:5c:8c:cc:
|
|
|
|
7f:1c:80:7b:c1:47:ad:2c:fe:44:f1:fc:93:0e:ac:
|
|
|
|
4f:27
|
|
|
|
Exponent: 65537 (0x10001)
|
|
|
|
X509v3 extensions:
|
|
|
|
X509v3 Basic Constraints:
|
|
|
|
CA:FALSE
|
|
|
|
X509v3 Subject Key Identifier:
|
|
|
|
B4:C2:AB:C3:F6:64:80:94:43:46:7F:40:25:E4:D1:CF:01:33:44:DA
|
|
|
|
X509v3 Authority Key Identifier:
|
|
|
|
keyid:5E:27:08:3B:81:1D:FA:05:CC:D3:94:D4:2B:9B:92:5B:3B:F9:EA:A1
|
|
|
|
DirName:/CN=Easy-RSA CA
|
|
|
|
serial:D5:46:5A:8E:8B:18:BD:2B
|
|
|
|
|
|
|
|
X509v3 Extended Key Usage:
|
|
|
|
TLS Web Server Authentication
|
|
|
|
X509v3 Key Usage:
|
|
|
|
Digital Signature, Key Encipherment
|
|
|
|
X509v3 Subject Alternative Name:
|
|
|
|
DNS:tezos
|
|
|
|
Signature Algorithm: sha256WithRSAEncryption
|
|
|
|
2f:23:1a:9e:42:72:2b:57:ec:26:04:a2:a0:22:f3:31:0e:12:
|
|
|
|
c4:46:92:95:b6:c7:44:bf:ab:5b:5b:15:c3:69:a3:48:79:be:
|
|
|
|
f9:09:aa:42:8c:8a:83:6a:55:68:b7:6c:02:b4:1a:d4:98:52:
|
|
|
|
b1:2e:bf:6c:3f:da:ef:93:e0:c8:69:fd:b7:dd:f7:42:65:e1:
|
|
|
|
66:ab:99:c2:d7:81:62:e2:e9:63:98:8a:24:9b:34:da:8a:82:
|
|
|
|
03:00:08:29:00:3f:18:cd:94:00:a7:22:0c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Iorn1A
|
|
|
|
AgrHr8YFn66qHd4bzufBbiRStBkPXUuMsJn5c78WRLqnIpqsoNWZHfpeVQd9GB/Z
|
|
|
|
k+VDfPwHCFJmYUmQpHYpcp2MAnCSAQhFeYZzbn8jVdzxNdwBXE1KMKqjxQKBgDaI
|
|
|
|
tjayFbDFbb+/DIFvZjCROmE2q9QIcgbdqywP6veh3mk8pDGdxuSxaXNXYgbAV42l
|
|
|
|
EikBXodVeRyPk0JjH+U4qUsq/fqmZSClGIUIoazTGxHXXsCDUsHrP/SDTM3/nDjV
|
|
|
|
iztuI+kyDTqEyDfgo77vtXTNPJctV/WROlveBYZvAoGBANCVDb/9bL+Sknwk8UUN
|
|
|
|
qqK1s+/HnLDBZZSGD6e3zfUoBsYtN1PkNmhxrLFsSaRzMEEbIgCCt2bs5vl/DWoi
|
|
|
|
lcQiNhsWRkdUDXpJd0WeqkGK3Gqb4KimoxdGrhhUQ2JmzqanOCuDpmKDDQDGe7Qy
|
|
|
|
XRWBqNomtTmVA25kchhzSMBQ
|
|
|
|
-----END PRIVATE KEY-----
|
|
|
|
EOF
|
|
|
|
|
|
|
|
else
|
|
|
|
$node config init \
|
|
|
|
--data-dir "$node_dir" \
|
|
|
|
--net-addr "127.0.0.1:$port" \
|
|
|
|
--rpc-addr "127.0.0.1:$rpc" \
|
|
|
|
--expected-pow "$expected_pow" \
|
|
|
|
--connections "$expected_connections"
|
|
|
|
fi
|
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
$node identity generate "$expected_pow" --data-dir "$node_dir"
|
|
|
|
$node run --data-dir "$node_dir" "${peers[@]}" "$sandbox_param" "$@" &
|
|
|
|
node_pids+=("$!")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup_nodes() {
|
|
|
|
[ -z "${node_pids[0]}" ] || kill "${node_pids[@]}"
|
2017-09-28 17:40:27 +04:00
|
|
|
for pid in "${node_pids[@]}" ; do wait "$pid" ; done
|
2017-08-28 20:34:36 +04:00
|
|
|
rm -rf "${node_dirs[@]}"
|
|
|
|
}
|
2017-12-06 22:51:57 +04:00
|
|
|
|
|
|
|
|
|
|
|
main() {
|
|
|
|
|
|
|
|
local bin_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")"
|
|
|
|
if [ $(basename "$bin_dir") = "bin_node" ]; then
|
2018-01-18 19:05:06 +04:00
|
|
|
local_node="${local_node:-$bin_dir/../../_build/default/src/bin_node/main.exe}"
|
|
|
|
sandbox_file="${sandbox_file:-$bin_dir/../../scripts/sandbox.json}"
|
2018-01-22 12:20:46 +04:00
|
|
|
else
|
|
|
|
local_node="${local_node:-tezos-node}"
|
|
|
|
sandbox_file="${sandbox_file:-sandbox.json}"
|
2017-12-06 22:51:57 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -lt 1 ] || [ "$1" -le 0 ] || [ 10 -le "$1" ]; then
|
|
|
|
echo "Small script to launch local and closed test network with a maximum of 9 nodes."
|
|
|
|
echo
|
|
|
|
echo "Usage: $0 <id>"
|
|
|
|
echo " where <id> should be an integer between 1 and 9."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
set +e
|
|
|
|
echo Cleaning up...
|
|
|
|
cleanup_nodes
|
|
|
|
}
|
|
|
|
trap cleanup EXIT INT
|
|
|
|
|
|
|
|
start_sandboxed_node "$@"
|
|
|
|
wait $node_pids
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$0" == "$BASH_SOURCE" ]; then
|
|
|
|
main "$@"
|
|
|
|
fi
|