@@ -9,9 +9,10 @@ basedir=$(
99)
1010workspace=${basedir}
1111source ${workspace} /.env
12- size=$(( BSC_CLUSTER_SIZE))
13- stateScheme=" path"
14- dbEngine=" pebble"
12+ source ${workspace} /qa-env-resource/machines_meta.sh # including machine ips and ids, don't upload!!!
13+ size=${# ips2ids[@]}
14+ stateScheme=" hash"
15+ dbEngine=" leveldb"
1516gcmode=" full"
1617epoch=200
1718blockInterval=3
@@ -46,14 +47,13 @@ function reset_genesis() {
4647 mv genesis-template.json.bk genesis-template.json
4748 fi
4849
49- poetry install --no-root
50+ # poetry install --no-root
5051 npm install
5152 rm -rf lib/forge-std
5253 forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3
5354 cd lib/forge-std/lib
5455 rm -rf ds-test
5556 git clone https://github.com/dapphub/ds-test
56-
5757}
5858
5959function prepare_config() {
@@ -70,6 +70,10 @@ function prepare_config() {
7070 done
7171
7272 mkdir -p ${workspace} /.local/bsc/node${i}
73+ cp ${workspace} /.local/bsc/password.txt ${workspace} /.local/bsc/node${i} /
74+ cp ${workspace} /qa-env-resource/* ${workspace} /.local/bsc/node${i} /
75+ sed -i -e " s/{{validatorAddr}}/${cons_addr} /g" ${workspace} /.local/bsc/node${i} /chaind.sh
76+ cp ${workspace} /.local/bsc/hardforkTime.txt ${workspace} /.local/bsc/node${i} /hardforkTime.txt
7377 bbcfee_addrs=${fee_addr}
7478 powers=" 0x000001d1a94a2000" # 2000000000000
7579 mv ${workspace} /.local/bsc/bls${i} /bls ${workspace} /.local/bsc/node${i} / && rm -rf ${workspace} /.local/bsc/bls${i}
@@ -86,10 +90,10 @@ function prepare_config() {
8690 sed -i -e ' /registeredContractChannelMap\[VALIDATOR_CONTRACT_ADDR\]\[STAKING_CHANNELID\]/d' ${workspace} /genesis/contracts/CrossChain.sol
8791 sed -i -e ' s/public onlyCoinbase onlyZeroGasPrice {/public onlyCoinbase onlyZeroGasPrice {if (block.number < 30) return;/' ${workspace} /genesis/contracts/BSCValidatorSet.sol
8892 fi
89- poetry run python -m scripts.generate generate-validators
90- poetry run python -m scripts.generate generate-init-holders " ${initHolders} "
91- poetry run python -m scripts.generate dev --dev-chain-id ${BSC_CHAIN_ID} --whitelist-1 " ${INIT_HOLDER} " \
92- --epoch ${epoch} --misdemeanor-threshold " 5 " --felony-threshold " 10 " \
93+ python3 -m scripts.generate generate-validators
94+ python3 -m scripts.generate generate-init-holders " ${initHolders} "
95+ python3 -m scripts.generate dev --dev-chain-id ${BSC_CHAIN_ID} --whitelist-1 " ${INIT_HOLDER} " \
96+ --epoch ${epoch} \
9397 --init-felony-slash-scope " 60" \
9498 --breathe-block-interval " 1 minutes" \
9599 --block-interval ${blockInterval} \
@@ -108,16 +112,21 @@ function prepare_config() {
108112
109113function initNetwork() {
110114 cd ${workspace}
111- ${workspace} /bin/geth init-network --init.dir ${workspace} /.local/bsc --init.size=${size} --config ${workspace} /config.toml ${workspace} /genesis/genesis.json
115+ ${workspace} /bin/geth init-network --init.dir ${workspace} /.local/bsc --init.size=${size} --init.ips " ${validator_ips_comma} " -- config ${workspace} /qa-env-resource /config.toml ${workspace} /genesis/genesis.json
112116 rm -rf ${workspace} /* bsc.log*
113117 for (( i = 0 ; i < size; i++ )) ; do
114118 sed -i -e ' /"<nil>"/d' ${workspace} /.local/bsc/node${i} /config.toml
115119 cp -R ${workspace} /.local/bsc/validator${i} /keystore ${workspace} /.local/bsc/node${i}
116120
117- cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /geth${i}
121+ # cp ${workspace}/bin/geth ${workspace}/.local/bsc/node${i}/geth${i}
122+ cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /bsc
118123 # init genesis
119124 initLog=${workspace} /.local/bsc/node${i} /init.log
120- ${workspace} /bin/geth --datadir ${workspace} /.local/bsc/node${i} init --state.scheme ${stateScheme} --db.engine ${dbEngine} ${workspace} /genesis/genesis.json > " ${initLog} " 2>&1
125+ if [ ` expr $i \* 2` -ge ${size} ] ; then
126+ ${workspace} /bin/geth --datadir ${workspace} /.local/bsc/node${i} init --state.scheme path --db.engine pebble ${workspace} /genesis/genesis.json > " ${initLog} " 2>&1
127+ else
128+ ${workspace} /bin/geth --datadir ${workspace} /.local/bsc/node${i} init --state.scheme ${stateScheme} --db.engine ${dbEngine} ${workspace} /genesis/genesis.json > " ${initLog} " 2>&1
129+ fi
121130 done
122131}
123132
@@ -168,6 +177,25 @@ function register_stakehub(){
168177 fi
169178}
170179
180+ function remote_start() {
181+ rm -rf /mnt/efs/bsc-qa/clusterNetwork
182+ cp -r ${workspace} /.local/bsc /mnt/efs/bsc-qa/clusterNetwork
183+ ips=(${validator_ips_comma// ,/ } )
184+ for (( i= 0 ;i< ${# ips[@]} ;i++ )) ; do
185+ dst_id=${ips2ids[${ips[i]} ]}
186+ aws ssm send-command --instance-ids " ${dst_id} " --document-name " AWS-RunShellScript" --parameters commands=" sudo bash -x /mnt/efs/bsc-qa/clusterNetwork/node${i} /init.sh"
187+ done
188+ }
189+
190+ function remote_upgrade() {
191+ cp ${workspace} /bin/geth /mnt/efs/bsc-qa/clusterNetwork/
192+ cp ${workspace} /qa-env-resource/upgrade-single.sh /mnt/efs/bsc-qa/clusterNetwork/
193+ for dst_id in ${ips2ids[@]} ; do
194+ aws ssm send-command --instance-ids " ${dst_id} " --document-name " AWS-RunShellScript" \
195+ --parameters commands=" sudo cp /mnt/efs/bsc-qa/clusterNetwork/geth /tmp/bsc && sudo cp /mnt/efs/bsc-qa/clusterNetwork/upgrade-single.sh /tmp/ && sudo bash -x /tmp/upgrade-single.sh"
196+ done
197+ }
198+
171199# # docker relate begin
172200function generate_static_peers() {
173201 tool=${workspace} /bin/bootnode
@@ -275,6 +303,17 @@ restart)
275303 exit_previous
276304 native_start
277305 ;;
306+ remote_reset)
307+ create_validator
308+ reset_genesis
309+ prepare_config
310+ initNetwork
311+ remote_start
312+ register_stakehub
313+ ;;
314+ remote_upgrade)
315+ remote_upgrade
316+ ;;
278317install_k8s)
279318 create_validator
280319 reset_genesis
@@ -287,6 +326,6 @@ uninstall_k8s)
287326 uninstall_k8s
288327 ;;
289328* )
290- echo " Usage: start_cluster.sh | reset | stop | start | restart"
329+ echo " Usage: start_cluster.sh | reset | stop | start | restart | remote_reset | remote_upgrade "
291330 ;;
292331esac
0 commit comments