-
Notifications
You must be signed in to change notification settings - Fork 347
/
istanbul-init.sh
executable file
·110 lines (97 loc) · 3.09 KB
/
istanbul-init.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
#!/bin/bash
set -u
set -e
function usage() {
echo ""
echo "Usage:"
echo " $0 [--istanbulTools] [--numNodes numberOfNodes]"
echo ""
echo "Where:"
echo " --istanbulTools will perform initialisation from data generated using"
echo " istanbul-tools (note that permissioned-node.json and istanbul-genesis.json"
echo " files will be overwritten)"
echo " numberOfNodes is the number of nodes to initialise (default = $numNodes)"
echo ""
exit -1
}
istanbulTools="false"
numNodes=7
while (( "$#" )); do
case "$1" in
--istanbulTools)
istanbulTools="true"
shift
;;
--numNodes)
re='^[0-9]+$'
if ! [[ $2 =~ $re ]] ; then
echo "ERROR: numberOfNodes value must be a number"
usage
fi
numNodes=$2
shift 2
;;
--help)
shift
usage
;;
*)
echo "Error: Unsupported command line parameter $1"
usage
;;
esac
done
echo "[*] Cleaning up temporary data directories"
rm -rf qdata
mkdir -p qdata/logs
echo "[*] Configuring for $numNodes node(s)"
echo $numNodes > qdata/numberOfNodes
if [[ "$istanbulTools" == "true" ]]; then
cp static-nodes.json permissioned-nodes.json
cp genesis.json istanbul-genesis.json
fi
permNodesFile=./permissioned-nodes.json
permNodesFile=./permissioned-nodes-${numNodes}.json
./create-permissioned-nodes.sh $numNodes
numPermissionedNodes=`grep "enode" ${permNodesFile} |wc -l`
if [[ $numPermissionedNodes -ne $numNodes ]]; then
echo "ERROR: $numPermissionedNodes nodes are configured in 'permissioned-nodes.json', but expecting configuration for $numNodes nodes"
rm -f $permNodesFile
exit -1
fi
genesisFile=./istanbul-genesis.json
tempGenesisFile=
if [[ "$istanbulTools" == "false" ]] && [[ "$numNodes" -lt 7 ]] ; then
# number of nodes is less than 7, update genesis file
tempGenesisFile="istanbul-genesis-${numNodes}.json"
./create-genesis.sh istanbul $tempGenesisFile $numNodes
genesisFile=$tempGenesisFile
fi
if [[ "${PRIVACY_ENHANCEMENTS:-false}" == "true" ]]; then
echo "adding privacyEnhancementsBlock to genesis.config"
tempGenesisFile="istanbul-genesis-${numNodes}-pe.json"
jq '.config.privacyEnhancementsBlock = 0' $genesisFile > $tempGenesisFile
genesisFile=$tempGenesisFile
fi
for i in `seq 1 ${numNodes}`
do
echo "[*] Configuring node ${i}"
mkdir -p qdata/dd${i}/{keystore,geth}
if [[ "$istanbulTools" == "true" ]]; then
iMinus1=$(($i - 1))
cp ${iMinus1}/nodekey qdata/dd${i}/geth/nodekey
else
cp raft/nodekey${i} qdata/dd${i}/geth/nodekey
fi
cp ${permNodesFile} qdata/dd${i}/static-nodes.json
if ! [[ -z "${STARTPERMISSION+x}" ]] ; then
cp ${permNodesFile} qdata/dd${i}/permissioned-nodes.json
fi
cp keys/key${i} qdata/dd${i}/keystore
geth --datadir qdata/dd${i} init $genesisFile
done
#Initialise Tessera configuration
./tessera-init.sh
#Initialise Cakeshop configuration
./cakeshop-init.sh
rm -f $tempGenesisFile $permNodesFile