@@ -9,13 +9,14 @@ 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
18- needRegister=false
19+ needRegister=true
1920sleepBeforeStart=10
2021
2122# stop geth client
@@ -48,14 +49,13 @@ function reset_genesis() {
4849 mv genesis-template.json.bk genesis-template.json
4950 fi
5051
51- poetry install --no-root
52+ # poetry install --no-root
5253 npm install
5354 rm -rf lib/forge-std
5455 forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3
5556 cd lib/forge-std/lib
5657 rm -rf ds-test
5758 git clone https://github.com/dapphub/ds-test
58-
5959}
6060
6161function prepare_config() {
@@ -72,6 +72,10 @@ function prepare_config() {
7272 done
7373
7474 mkdir -p ${workspace} /.local/bsc/node${i}
75+ cp ${workspace} /.local/bsc/password.txt ${workspace} /.local/bsc/node${i} /
76+ cp ${workspace} /qa-env-resource/* ${workspace} /.local/bsc/node${i} /
77+ sed -i -e " s/{{validatorAddr}}/${cons_addr} /g" ${workspace} /.local/bsc/node${i} /chaind.sh
78+ cp ${workspace} /.local/bsc/hardforkTime.txt ${workspace} /.local/bsc/node${i} /hardforkTime.txt
7579 bbcfee_addrs=${fee_addr}
7680 powers=" 0x000001d1a94a2000" # 2000000000000
7781 mv ${workspace} /.local/bsc/bls${i} /bls ${workspace} /.local/bsc/node${i} / && rm -rf ${workspace} /.local/bsc/bls${i}
@@ -88,10 +92,10 @@ function prepare_config() {
8892 sed -i -e ' /registeredContractChannelMap\[VALIDATOR_CONTRACT_ADDR\]\[STAKING_CHANNELID\]/d' ${workspace} /genesis/contracts/CrossChain.sol
8993 sed -i -e ' s/public onlyCoinbase onlyZeroGasPrice {/public onlyCoinbase onlyZeroGasPrice {if (block.number < 30) return;/' ${workspace} /genesis/contracts/BSCValidatorSet.sol
9094 fi
91- poetry run python -m scripts.generate generate-validators
92- poetry run python -m scripts.generate generate-init-holders " ${initHolders} "
93- poetry run python -m scripts.generate dev --dev-chain-id ${BSC_CHAIN_ID} --whitelist-1 " ${INIT_HOLDER} " \
94- --epoch ${epoch} --misdemeanor-threshold " 5 " --felony-threshold " 10 " \
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} " \
98+ --epoch ${epoch} \
9599 --init-felony-slash-scope " 60" \
96100 --breathe-block-interval " 1 minutes" \
97101 --block-interval ${blockInterval} \
@@ -110,16 +114,21 @@ function prepare_config() {
110114
111115function initNetwork() {
112116 cd ${workspace}
113- ${workspace} /bin/geth init-network --init.dir ${workspace} /.local/bsc --init.size=${size} --config ${workspace} /config.toml ${workspace} /genesis/genesis.json
117+ ${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
114118 rm -rf ${workspace} /* bsc.log*
115119 for (( i = 0 ; i < size; i++ )) ; do
116120 sed -i -e ' /"<nil>"/d' ${workspace} /.local/bsc/node${i} /config.toml
117121 cp -R ${workspace} /.local/bsc/validator${i} /keystore ${workspace} /.local/bsc/node${i}
118122
119- cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /geth${i}
123+ # cp ${workspace}/bin/geth ${workspace}/.local/bsc/node${i}/geth${i}
124+ cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /bsc
120125 # init genesis
121126 initLog=${workspace} /.local/bsc/node${i} /init.log
122- ${workspace} /bin/geth --datadir ${workspace} /.local/bsc/node${i} init --state.scheme ${stateScheme} --db.engine ${dbEngine} ${workspace} /genesis/genesis.json > " ${initLog} " 2>&1
127+ if [ ` expr $i \* 2` -ge ${size} ] ; then
128+ ${workspace} /bin/geth --datadir ${workspace} /.local/bsc/node${i} init --state.scheme path --db.engine pebble ${workspace} /genesis/genesis.json > " ${initLog} " 2>&1
129+ else
130+ ${workspace} /bin/geth --datadir ${workspace} /.local/bsc/node${i} init --state.scheme ${stateScheme} --db.engine ${dbEngine} ${workspace} /genesis/genesis.json > " ${initLog} " 2>&1
131+ fi
123132 done
124133}
125134
@@ -175,6 +184,25 @@ function register_stakehub(){
175184 fi
176185}
177186
187+ function remote_start() {
188+ rm -rf /mnt/efs/bsc-qa/clusterNetwork
189+ cp -r ${workspace} /.local/bsc /mnt/efs/bsc-qa/clusterNetwork
190+ ips=(${validator_ips_comma// ,/ } )
191+ for (( i= 0 ;i< ${# ips[@]} ;i++ )) ; do
192+ dst_id=${ips2ids[${ips[i]} ]}
193+ 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"
194+ done
195+ }
196+
197+ function remote_upgrade() {
198+ cp ${workspace} /bin/geth /mnt/efs/bsc-qa/clusterNetwork/
199+ cp ${workspace} /qa-env-resource/upgrade-single.sh /mnt/efs/bsc-qa/clusterNetwork/
200+ for dst_id in ${ips2ids[@]} ; do
201+ aws ssm send-command --instance-ids " ${dst_id} " --document-name " AWS-RunShellScript" \
202+ --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"
203+ done
204+ }
205+
178206# # docker relate begin
179207function generate_static_peers() {
180208 tool=${workspace} /bin/bootnode
@@ -283,6 +311,17 @@ restart)
283311 exit_previous $ValidatorIdx
284312 native_start $ValidatorIdx
285313 ;;
314+ remote_reset)
315+ create_validator
316+ reset_genesis
317+ prepare_config
318+ initNetwork
319+ remote_start
320+ register_stakehub
321+ ;;
322+ remote_upgrade)
323+ remote_upgrade
324+ ;;
286325install_k8s)
287326 create_validator
288327 reset_genesis
@@ -295,6 +334,6 @@ uninstall_k8s)
295334 uninstall_k8s
296335 ;;
297336* )
298- echo " Usage: start_cluster.sh | reset | stop | start | restart"
337+ echo " Usage: start_cluster.sh | reset | stop | start | restart | remote_reset | remote_upgrade "
299338 ;;
300339esac
0 commit comments