@@ -9,13 +9,15 @@ 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
1819sleepBeforeStart=10
20+ copyDir=" bsc-qa"
1921
2022# stop geth client
2123function exit_previous() {
@@ -48,14 +50,13 @@ function reset_genesis() {
4850 mv genesis-template.json.bk genesis-template.json
4951 fi
5052
51- poetry install --no-root
53+ # poetry install --no-root
5254 npm install
5355 rm -rf lib/forge-std
5456 forge install --no-git --no-commit foundry-rs/forge-std@v1.7.3
5557 cd lib/forge-std/lib
5658 rm -rf ds-test
5759 git clone https://github.com/dapphub/ds-test
58-
5960}
6061
6162function prepare_config() {
@@ -74,6 +75,9 @@ function prepare_config() {
7475 mkdir -p ${workspace} /.local/bsc/node${i}
7576 cp ${workspace} /keys/password.txt ${workspace} /.local/bsc/node${i} /
7677 cp ${workspace} /.local/bsc/hardforkTime.txt ${workspace} /.local/bsc/node${i} /
78+ cp ${workspace} /qa-env-resource/* ${workspace} /.local/bsc/node${i} /
79+ sed -i -e " s/{{validatorAddr}}/${cons_addr} /g" ${workspace} /.local/bsc/node${i} /chaind.sh
80+ rm -f ${workspace} /.local/bsc/node${i} /chaind.sh.bak
7781 bbcfee_addrs=${fee_addr}
7882 powers=" 0x000001d1a94a2000" # 2000000000000
7983 mv ${workspace} /.local/bsc/bls${i} /bls ${workspace} /.local/bsc/node${i} / && rm -rf ${workspace} /.local/bsc/bls${i}
@@ -88,13 +92,14 @@ function prepare_config() {
8892 cd ${workspace} /genesis/
8993 git checkout HEAD contracts
9094
91- sed -i -e ' /registeredContractChannelMap\[VALIDATOR_CONTRACT_ADDR\]\[STAKING_CHANNELID\]/d' ${workspace} /genesis/contracts/deprecated/CrossChain.sol
92- sed -i -e ' s/alreadyInit = true;/turnLength = 4;alreadyInit = true;/' ${workspace} /genesis/contracts/BSCValidatorSet.sol
95+ # to test unregister relayer
96+ # sed -i -e 's/currentRelayers\[addr\] = true;/currentRelayers\[addr\] = true; relayersExistMap\[addr\] = true;/' ${workspace}/genesis/contracts/deprecated/RelayerHub.sol
97+ sed -i -e ' s/alreadyInit = true;/turnLength = 8;alreadyInit = true;/' ${workspace} /genesis/contracts/BSCValidatorSet.sol
9398 sed -i -e ' s/public onlyCoinbase onlyZeroGasPrice {/public onlyCoinbase onlyZeroGasPrice {if (block.number < 30) return;/' ${workspace} /genesis/contracts/BSCValidatorSet.sol
94-
95- poetry run python -m scripts.generate generate-validators
96- poetry run python -m scripts.generate generate-init-holders " ${initHolders} "
97- poetry run python -m scripts.generate dev \
99+
100+ python3 -m scripts.generate generate-validators
101+ python3 -m scripts.generate generate-init-holders " ${initHolders} "
102+ python3 -m scripts.generate dev \
98103 --epoch ${epoch} \
99104 --init-felony-slash-scope " 60" \
100105 --breathe-block-interval " 10 minutes" \
@@ -116,13 +121,14 @@ function initNetwork() {
116121 mkdir ${workspace} /.local/bsc/node${i} /geth
117122 cp ${workspace} /keys/nodekey${i} ${workspace} /.local/bsc/node${i} /geth/nodekey
118123 done
119- ${workspace} /bin/geth init-network --init.dir ${workspace} /.local/bsc --init.size=${size} --config ${workspace} /config.toml ${workspace} /genesis/genesis.json
124+ ${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
120125 rm -f ${workspace} /* bsc.log*
121126 for (( i = 0 ; i < size; i++ )) ; do
122127 sed -i -e ' /"<nil>"/d' ${workspace} /.local/bsc/node${i} /config.toml
123128 mv ${workspace} /.local/bsc/validator${i} /keystore ${workspace} /.local/bsc/node${i} / && rm -rf ${workspace} /.local/bsc/validator${i}
124129
125- cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /geth${i}
130+ # cp ${workspace}/bin/geth ${workspace}/.local/bsc/node${i}/geth${i}
131+ cp ${workspace} /bin/geth ${workspace} /.local/bsc/node${i} /bsc
126132 # init genesis
127133 initLog=${workspace} /.local/bsc/node${i} /init.log
128134 if [ $i -eq 0 ] ; then
@@ -174,7 +180,7 @@ function native_start() {
174180 --ws.addr 0.0.0.0 --ws.port ${WSPort} --http.addr 0.0.0.0 --http.port ${HTTPPort} --http.corsdomain " *" \
175181 --metrics --metrics.addr localhost --metrics.port ${MetricsPort} --metrics.expensive \
176182 --gcmode ${gcmode} --syncmode full --mine --vote --monitor.maliciousvote \
177- --rialtohash ${rialtoHash} --override.passedforktime ${PassedForkTime} --override.lorentz ${LastHardforkTime} \
183+ --rialtohash ${rialtoHash} --override.passedforktime ${PassedForkTime} --override.lorentz ${PassedForkTime} --override.maxwell ${ LastHardforkTime} \
178184 --override.immutabilitythreshold ${FullImmutabilityThreshold} --override.breatheblockinterval ${BreatheBlockInterval} \
179185 --override.minforblobrequest ${MinBlocksForBlobRequests} --override.defaultextrareserve ${DefaultExtraReserveForBlobRequests} \
180186 > ${workspace} /.local/bsc/node${i} /bsc-node.log 2>&1 &
@@ -183,15 +189,34 @@ function native_start() {
183189
184190function register_stakehub(){
185191 if ${needRegister} ; then
186- echo " sleep 45s to wait feynman enable"
187- sleep 45
192+ echo " sleep 100s to wait feynman enable"
193+ sleep 100
188194 for (( i = 0 ; i < size; i++ )) ; do
189195 ${workspace} /create-validator/create-validator --consensus-key-dir ${workspace} /keys/validator${i} --vote-key-dir ${workspace} /keys/bls${i} \
190196 --password-path ${workspace} /keys/password.txt --amount 20001 --validator-desc Val${i} --rpc-url ${RPC_URL}
191197 done
192198 fi
193199}
194200
201+ function remote_start() {
202+ rm -rf /mnt/efs/${copyDir} /clusterNetwork
203+ cp -r ${workspace} /.local/bsc /mnt/efs/${copyDir} /clusterNetwork
204+ ips=(${validator_ips_comma// ,/ } )
205+ for (( i= 0 ;i< ${# ips[@]} ;i++ )) ; do
206+ dst_id=${ips2ids[${ips[i]} ]}
207+ 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"
208+ done
209+ }
210+
211+ function remote_upgrade() {
212+ cp ${workspace} /bin/geth /mnt/efs/${copyDir} /clusterNetwork/
213+ cp ${workspace} /qa-env-resource/upgrade-single.sh /mnt/efs/${copyDir} /clusterNetwork/
214+ for dst_id in ${ips2ids[@]} ; do
215+ aws ssm send-command --instance-ids " ${dst_id} " --document-name " AWS-RunShellScript" \
216+ --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"
217+ done
218+ }
219+
195220CMD=$1
196221ValidatorIdx=$2
197222case ${CMD} in
@@ -214,7 +239,18 @@ restart)
214239 exit_previous $ValidatorIdx
215240 native_start $ValidatorIdx
216241 ;;
242+ remote_reset)
243+ create_validator
244+ reset_genesis
245+ prepare_config
246+ initNetwork
247+ remote_start
248+ register_stakehub
249+ ;;
250+ remote_upgrade)
251+ remote_upgrade
252+ ;;
217253* )
218- echo " Usage: bsc_cluster.sh | reset | stop [vidx]| start [vidx]| restart [vidx]"
254+ echo " Usage: bsc_cluster.sh | reset | stop [vidx]| start [vidx]| restart [vidx]| remote_reset | remote_upgrade "
219255 ;;
220256esac
0 commit comments