Skip to content

Commit

Permalink
support QA deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBSC committed Apr 28, 2024
1 parent 592cf11 commit 017b526
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ KEYPASS="0123456789"
#private key 59ba8068eb256d520179e903f43dacf6d8d57d72bd306e1bd603fdb8c8da10e8
INIT_HOLDER="0x04d63aBCd2b9b1baa327f2Dda0f873F197ccd186"
INIT_HOLDER_PRV="59ba8068eb256d520179e903f43dacf6d8d57d72bd306e1bd603fdb8c8da10e8"
HARD_FORK_DELAY=40
HARD_FORK_DELAY=200
FullImmutabilityThreshold=512
MinBlocksForBlobRequests=576
DefaultExtraReserveForBlobRequests=32
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

.local/

.idea/
.idea/

/qa-env-resource/machines_meta.sh
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "genesis"]
path = genesis
url = ../bsc-genesis-contract.git
url = https://github.com/bnb-chain/bsc-genesis-contract.git
branch = master
ignore = dirty
3 changes: 3 additions & 0 deletions bin/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore everything in this directory
*
# Except geth
9 changes: 0 additions & 9 deletions bin/getInitConsensusState

This file was deleted.

Binary file removed bin/getInitConsensusState_linux
Binary file not shown.
Binary file removed bin/getInitConsensusState_macos
Binary file not shown.
19 changes: 19 additions & 0 deletions qa-env-resource/bsc.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=bsc
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/server/validator/chaind.sh -start
ExecReload=/server/validator/chaind.sh -restart
ExecStop=/server/validator/chaind.sh -stop
PrivateTmp=true
Restart=always
LimitNOFILE=10000
RestartSec=5
StartLimitInterval=0

[Install]
WantedBy=multi-user.target
71 changes: 71 additions & 0 deletions qa-env-resource/chaind.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

export GOGC=200
# default values
FullImmutabilityThreshold=90000
MinBlocksForBlobRequests=524288
DefaultExtraReserveForBlobRequests=28800

function startChaind() {
workspace=/server/validator

FeynmanHardforkTime=`cat ${workspace}/hardforkTime.txt|grep hardforkTime|awk -F" " '{print $NF}'`
CancunHardforkTime=`expr ${FeynmanHardforkTime} + 10`
initLog=${workspace}/init.log
rialtoHash=`cat ${initLog}|grep "database=lightchaindata"|awk -F"=" '{print $NF}'|awk -F'"' '{print $1}'`

ip=`ifconfig eth0|grep inet|grep -v inet6 |awk '{ print $2 }'`
sed -i -e "s?FileRoot = \"\"?FileRoot = \"/mnt/efs/validator/${ip}/\"?g" /server/validator/config.toml
mkdir -p /mnt/efs/validator/${ip}
${workspace}/bsc --config ${workspace}/config.toml \
--datadir ${workspace} \
--password ${workspace}/password.txt \
--blspassword ${workspace}/password.txt \
--unlock {{validatorAddr}} --miner.etherbase {{validatorAddr}} --rpc.allow-unprotected-txs --allow-insecure-unlock \
--ws --ws.port 8545 --ws.addr ${ip} --http.addr 0.0.0.0 --http.corsdomain "*" \
--metrics --metrics.addr 0.0.0.0 \
--pprof --pprof.port 6061 \
--syncmode snap --state.scheme {{stateScheme}} --db.engine {{dbEngine}} --mine --vote --monitor.maliciousvote \
--cache 10480 --light.serve 50 \
--rialtohash ${rialtoHash} --override.feynman ${FeynmanHardforkTime} --override.feynmanfix ${FeynmanHardforkTime} --override.cancun ${CancunHardforkTime} \
--override.immutabilitythreshold ${FullImmutabilityThreshold} --override.minforblobrequest ${MinBlocksForBlobRequests} --override.defaultextrareserve ${DefaultExtraReserveForBlobRequests} \
>> /mnt/efs/validator/${ip}/bscnode.log 2>&1
}

function stopChaind() {
pid=`ps -ef | grep /server/validator/bsc | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]; then
for((i=1;i<=4;i++));
do
kill $pid
sleep 5
pid=`ps -ef | grep /server/validator/bsc | grep -v grep | awk '{print $2}'`
if [ -z "$pid" ]; then
break
elif [ $i -eq 4 ]; then
kill -9 $kid
fi
done
fi
}

CMD=$1

case $CMD in
-start)
echo "start"
startChaind
;;
-stop)
echo "stop"
stopChaind
;;
-restart)
stopChaind
sleep 3
startChaind
;;
*)
echo "Usage: chaind.sh -start | -stop | -restart .Or use systemctl start | stop | restart bsc.service "
;;
esac
65 changes: 65 additions & 0 deletions qa-env-resource/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[Eth]
NetworkId = 714
SyncMode = "full"
NoPruning = false
NoPrefetch = false
LightPeers = 100
TrieTimeout = 100000000000
DatabaseCache = 512
DatabaseFreezer = ""
TriesInMemory = 128
TrieCleanCache = 256
TrieDirtyCache = 256
EnablePreimageRecording = false

[Eth.Miner]
GasFloor = 500000000
GasCeil = 500000000
GasPrice = 1000000000
Recommit = 10000000000

[Eth.TxPool]
Locals = []
NoLocals = true
Journal = "transactions.rlp"
Rejournal = 3600000000000
PriceLimit = 1000000000
PriceBump = 10
AccountSlots = 512
GlobalSlots = 10000
AccountQueue = 256
GlobalQueue = 5000
Lifetime = 10800000000000

[Eth.GPO]
Blocks = 20
Percentile = 60
OracleThreshold = 1000

[Node]
IPCPath = "geth.ipc"
HTTPHost = "localhost"
NoUSB = true
InsecureUnlockAllowed = false
HTTPPort = 8545
HTTPVirtualHosts = ["localhost"]
HTTPModules = ["eth", "net", "web3", "txpool", "parlia", "miner"]
WSPort = 8546
WSModules = ["net", "web3", "eth"]

[Node.P2P]
MaxPeers = 30
NoDiscovery = false
ListenAddr = ":30311"
EnableMsgEvents = false

[Node.HTTPTimeouts]
ReadTimeout = 30000000000
WriteTimeout = 30000000000
IdleTimeout = 120000000000

[Node.LogConfig]
FilePath = "bsc.log"
MaxBytesSize = 10485760
Level = "info"
FileRoot = ""
12 changes: 12 additions & 0 deletions qa-env-resource/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

workspace=$(cd `dirname $0`; pwd)

cp ${workspace}/bsc.service /usr/lib/systemd/system/
chmod +x ${workspace}/start.sh ${workspace}/chaind.sh ${workspace}/bsc

service bsc stop
rm -rf /server/validator
mv ${workspace} /server/validator

/server/validator/start.sh
4 changes: 4 additions & 0 deletions qa-env-resource/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
systemctl daemon-reload
chkconfig bsc on
service bsc restart
15 changes: 15 additions & 0 deletions qa-env-resource/upgrade-single.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

service bsc stop
cp /tmp/bsc /server/validator/bsc

#cd /server/validator/geth/
#rm -rf chaindata les.server nodes triecache

#sed -i -e 's/sleep 5/sleep 40/' /server/validator/chaind.sh

#/server/validator/bsc init --datadir /server/validator/ /server/validator/genesis.json

#sed -i -e 's/HTTPModules = \[/HTTPModules = \["debug",/g' /server/validator/config.toml

service bsc start
Loading

0 comments on commit 017b526

Please sign in to comment.