@@ -9,14 +9,16 @@ basedir=$(
99)
1010workspace=${basedir}
1111source ${workspace} /.env
12- size=$(( BSC_CLUSTER_SIZE))
12+ source ${workspace} /qa-env-resource/machines_meta.sh # including machine ips and ids, don't upload!!!
13+ size=${# ips2ids[@]}
1314stateScheme=" hash"
1415dbEngine=" leveldb"
1516gcmode=" full"
1617epoch=200
1718blockInterval=3
18- needRegister=false
19+ needRegister=true
1920sleepBeforeStart=10
21+ copyDir=" bsc-qa"
2022
2123# stop geth client
2224function exit_previous() {
@@ -47,14 +49,13 @@ function reset_genesis() {
4749 mv genesis-template.json.bk genesis-template.json
4850 fi
4951
50- poetry install --no-root
52+ # poetry install --no-root
5153 npm install
5254 rm -rf lib/forge-std
5355 forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3
5456 cd lib/forge-std/lib
5557 rm -rf ds-test
5658 git clone https://github.com/dapphub/ds-test
57-
5859}
5960
6061function prepare_config() {
@@ -73,6 +74,8 @@ function prepare_config() {
7374 mkdir -p ${workspace} /.local/bsc/node${i}
7475 cp ${workspace} /keys/password.txt ${workspace} /.local/bsc/node${i} /
7576 cp ${workspace} /.local/bsc/hardforkTime.txt ${workspace} /.local/bsc/node${i} /
77+ cp ${workspace} /qa-env-resource/* ${workspace} /.local/bsc/node${i} /
78+ sed -i -e " s/{{validatorAddr}}/${cons_addr} /g" ${workspace} /.local/bsc/node${i} /chaind.sh
7679 bbcfee_addrs=${fee_addr}
7780 powers=" 0x000001d1a94a2000" # 2000000000000
7881 mv ${workspace} /.local/bsc/bls${i} /bls ${workspace} /.local/bsc/node${i} / && rm -rf ${workspace} /.local/bsc/bls${i}
@@ -89,9 +92,9 @@ function prepare_config() {
8992 sed -i -e ' /registeredContractChannelMap\[VALIDATOR_CONTRACT_ADDR\]\[STAKING_CHANNELID\]/d' ${workspace} /genesis/contracts/deprecated/CrossChain.sol
9093 sed -i -e ' s/public onlyCoinbase onlyZeroGasPrice {/public onlyCoinbase onlyZeroGasPrice {if (block.number < 30) return;/' ${workspace} /genesis/contracts/BSCValidatorSet.sol
9194 fi
92- poetry run python -m scripts.generate generate-validators
93- poetry run python -m scripts.generate generate-init-holders " ${initHolders} "
94- poetry run python -m scripts.generate dev --dev-chain-id ${BSC_CHAIN_ID} --whitelist-1 " ${INIT_HOLDER} " \
95+ python3 -m scripts.generate generate-validators
96+ python3 -m scripts.generate generate-init-holders " ${initHolders} "
97+ python3 -m scripts.generate dev --dev-chain-id ${BSC_CHAIN_ID} --whitelist-1 " ${INIT_HOLDER} " \
9598 --epoch ${epoch} \
9699 --init-felony-slash-scope " 60" \
97100 --breathe-block-interval " 10 minutes" \
@@ -115,13 +118,14 @@ function initNetwork() {
115118 mkdir ${workspace} /.local/bsc/node${i} /geth
116119 cp ${workspace} /keys/nodekey${i} ${workspace} /.local/bsc/node${i} /geth/nodekey
117120 done
118- ${workspace} /bin/geth init-network --init.dir ${workspace} /.local/bsc --init.size=${size} --config ${workspace} /config.toml ${workspace} /genesis/genesis.json
121+ ${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
119122 rm -rf ${workspace} /* bsc.log*
120123 for (( i = 0 ; i < size; i++ )) ; do
121124 sed -i -e ' /"<nil>"/d' ${workspace} /.local/bsc/node${i} /config.toml
122125 mv ${workspace} /.local/bsc/validator${i} /keystore ${workspace} /.local/bsc/node${i} / && rm -rf ${workspace} /.local/bsc/validator${i}
123126
124- cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /geth${i}
127+ # cp ${workspace}/bin/geth ${workspace}/.local/bsc/node${i}/geth${i}
128+ cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /bsc
125129 # init genesis
126130 initLog=${workspace} /.local/bsc/node${i} /init.log
127131 if [ $i -eq 0 ] ; then
@@ -179,15 +183,34 @@ function native_start() {
179183
180184function register_stakehub(){
181185 if ${needRegister} ; then
182- echo " sleep 45s to wait feynman enable"
183- sleep 45
186+ echo " sleep 100s to wait feynman enable"
187+ sleep 100
184188 for (( i = 0 ; i < size; i++ )) ; do
185189 ${workspace} /create-validator/create-validator --consensus-key-dir ${workspace} /keys/validator${i} --vote-key-dir ${workspace} /keys/bls${i} \
186190 --password-path ${workspace} /keys/password.txt --amount 20001 --validator-desc Val${i} --rpc-url ${RPC_URL}
187191 done
188192 fi
189193}
190194
195+ function remote_start() {
196+ rm -rf /mnt/efs/${copyDir} /clusterNetwork
197+ cp -r ${workspace} /.local/bsc /mnt/efs/${copyDir} /clusterNetwork
198+ ips=(${validator_ips_comma// ,/ } )
199+ for (( i= 0 ;i< ${# ips[@]} ;i++ )) ; do
200+ dst_id=${ips2ids[${ips[i]} ]}
201+ aws ssm send-command --instance-ids " ${dst_id} " --document-name " AWS-RunShellScript" --parameters commands=" sudo bash -x /mnt/efs/${copyDir} /clusterNetwork/node${i} /init.sh"
202+ done
203+ }
204+
205+ function remote_upgrade() {
206+ cp ${workspace} /bin/geth /mnt/efs/${copyDir} /clusterNetwork/
207+ cp ${workspace} /qa-env-resource/upgrade-single.sh /mnt/efs/${copyDir} /clusterNetwork/
208+ for dst_id in ${ips2ids[@]} ; do
209+ aws ssm send-command --instance-ids " ${dst_id} " --document-name " AWS-RunShellScript" \
210+ --parameters commands=" sudo cp /mnt/efs/${copyDir} /clusterNetwork/geth /tmp/bsc && sudo cp /mnt/efs/${copyDir} /clusterNetwork/upgrade-single.sh /tmp/ && sudo bash -x /tmp/upgrade-single.sh"
211+ done
212+ }
213+
191214CMD=$1
192215ValidatorIdx=$2
193216case ${CMD} in
@@ -210,7 +233,18 @@ restart)
210233 exit_previous $ValidatorIdx
211234 native_start $ValidatorIdx
212235 ;;
236+ remote_reset)
237+ create_validator
238+ reset_genesis
239+ prepare_config
240+ initNetwork
241+ remote_start
242+ register_stakehub
243+ ;;
244+ remote_upgrade)
245+ remote_upgrade
246+ ;;
213247* )
214- echo " Usage: bsc_cluster.sh | reset | stop [vidx]| start [vidx]| restart [vidx]"
248+ echo " Usage: bsc_cluster.sh | reset | stop [vidx]| start [vidx]| restart [vidx]| remote_reset | remote_upgrade "
215249 ;;
216250esac
0 commit comments