Skip to content

Commit

Permalink
make nodekey fixed (#70)
Browse files Browse the repository at this point in the history
support passedforktime
update genesis
  • Loading branch information
buddh0 authored Aug 13, 2024
1 parent f6693d2 commit 59b5692
Show file tree
Hide file tree
Showing 25 changed files with 54 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ KEYPASS="0123456789"
INIT_HOLDER="0x04d63aBCd2b9b1baa327f2Dda0f873F197ccd186"
INIT_HOLDER_PRV="59ba8068eb256d520179e903f43dacf6d8d57d72bd306e1bd603fdb8c8da10e8"
RPC_URL="http://127.0.0.1:8545"
HARD_FORK_DELAY=40
PASSED_FORK_DELAY=40
LAST_FORK_MORE_DELAY=10
FullImmutabilityThreshold=512
MinBlocksForBlobRequests=576
DefaultExtraReserveForBlobRequests=32
BreatheBlockInterval=600
FixedTurnLength=4
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GasPrice = 10000000000
Recommit = 10000000000

[Eth.Miner.Mev]
Enabled = false
Enabled = true
GreedyMergeTx = true
BuilderFeeCeil= "0"
ValidatorCommission = 1000
Expand Down
2 changes: 1 addition & 1 deletion genesis
1 change: 1 addition & 0 deletions keys/nodekey0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4e53fc003749b87a8e1a1bfdf1c2688ef0f8ea7301e49de3ee766e34dc41b7a4
1 change: 1 addition & 0 deletions keys/nodekey1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a70322a0f89a73e7648577659eaa9185de61897697e05471b8aabd119f301703
1 change: 1 addition & 0 deletions keys/nodekey10
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4a6963661cb4bca8185c3209c33a6d16e6fdcf7ad2204f65353b23ecef183981
1 change: 1 addition & 0 deletions keys/nodekey11
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
54c4495c0d17fe33013c202bfe6493d1cfa415f9ff94e5378c94015d766c7266
1 change: 1 addition & 0 deletions keys/nodekey12
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14174f27b73f25bb34eefa206a30ab37cc6f41bc7c93e4746ae173ff86415eae
1 change: 1 addition & 0 deletions keys/nodekey13
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9a9eb3dd23b839e870fdef1ab318acaf3308d18186dcda1330f9c20b547495fc
1 change: 1 addition & 0 deletions keys/nodekey14
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6e9f908dd76d9166299439c70845466c7cef2093c0ce7dc2193c677ebe566369
1 change: 1 addition & 0 deletions keys/nodekey15
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
368885deebe33e020bffac57f19f36a5712073b4b7ce097a343da9770690c568
1 change: 1 addition & 0 deletions keys/nodekey16
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9e6494e7c485296cd84783b8aec6426577f3ccc56245f5bac58e7349fc48f4fa
1 change: 1 addition & 0 deletions keys/nodekey17
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7c52c7fdb24886fd65669cb4214cb1bec3e3f98262b33e142a158e5fba178708
1 change: 1 addition & 0 deletions keys/nodekey18
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2a6334a29611c6ffb845038884d430706235a9c37910ceadf04fef9c3d543ccf
1 change: 1 addition & 0 deletions keys/nodekey19
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e841bf5f4669270172bb5f8fb42fe4ba9a8c1ae6cb91c3e983f3bf69d9bebe5a
1 change: 1 addition & 0 deletions keys/nodekey2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a97ba2b4fcba715ce70e5edae07c472bd13dc10a7648237c9ae93e9ba9da8a6f
1 change: 1 addition & 0 deletions keys/nodekey20
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4dcbab3e7c97ba11b7a3ab37dc7a3a59806df941cca5a2a8c26c8dc8fd917e90
1 change: 1 addition & 0 deletions keys/nodekey3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
714594b74b8f8ba91a5ec9ea740e789330bd9a26a3140f1278806ae4475228d2
1 change: 1 addition & 0 deletions keys/nodekey4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2147c90c49d560ce92f81245787e7a49f21552ba4dc7bd2383ef66bb5fa4719a
1 change: 1 addition & 0 deletions keys/nodekey5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a8a055bffe8b6f4d223dc9ce2407cf717500a8969f545cbb6ed058af2ea8714c
1 change: 1 addition & 0 deletions keys/nodekey6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
54bccba78142c774cdd12966866cc7677921955e1f56f66012af990a79826c34
1 change: 1 addition & 0 deletions keys/nodekey7
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2effb85f159d28ee3e76765a3ae0b5daee6fe907274df0f54a30378b1b559b37
1 change: 1 addition & 0 deletions keys/nodekey8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e7b5b870f999ce5ece45cc87c11303da938d3ed27945541ef9dc039d23a26bf5
1 change: 1 addition & 0 deletions keys/nodekey9
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0303b120dc0d8ffb2e8d071f6501b5381c8fddb81d8fd01cb6dab394889e1b05
43 changes: 28 additions & 15 deletions start_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ basedir=$(
workspace=${basedir}
source ${workspace}/.env
size=$((BSC_CLUSTER_SIZE))
stateScheme="path"
dbEngine="pebble"
stateScheme="hash"
dbEngine="leveldb"
gcmode="full"
epoch=200
blockInterval=3
Expand All @@ -28,7 +28,6 @@ function exit_previous() {
function create_validator() {
rm -rf ${workspace}/.local
mkdir -p ${workspace}/.local/bsc
cp ${workspace}/keys/password.txt ${workspace}/.local/bsc/

for ((i = 0; i < size; i++)); do
cp -r ${workspace}/keys/validator${i} ${workspace}/.local/bsc/
Expand Down Expand Up @@ -61,8 +60,8 @@ function reset_genesis() {
function prepare_config() {
rm -f ${workspace}/genesis/validators.conf

hardforkTime=$(expr $(date +%s) + ${HARD_FORK_DELAY})
echo "hardforkTime "${hardforkTime} > ${workspace}/.local/bsc/hardforkTime.txt
passedHardforkTime=$(expr $(date +%s) + ${PASSED_FORK_DELAY})
echo "passedHardforkTime "${passedHardforkTime} > ${workspace}/.local/bsc/hardforkTime.txt
initHolders=${INIT_HOLDER}
for ((i = 0; i < size; i++)); do
for f in ${workspace}/.local/bsc/validator${i}/keystore/*; do
Expand All @@ -72,6 +71,8 @@ function prepare_config() {
done

mkdir -p ${workspace}/.local/bsc/node${i}
cp ${workspace}/keys/password.txt ${workspace}/.local/bsc/node${i}/
cp ${workspace}/.local/bsc/hardforkTime.txt ${workspace}/.local/bsc/node${i}/
bbcfee_addrs=${fee_addr}
powers="0x000001d1a94a2000" #2000000000000
mv ${workspace}/.local/bsc/bls${i}/bls ${workspace}/.local/bsc/node${i}/ && rm -rf ${workspace}/.local/bsc/bls${i}
Expand All @@ -91,9 +92,9 @@ function prepare_config() {
poetry run python -m scripts.generate generate-validators
poetry run python -m scripts.generate generate-init-holders "${initHolders}"
poetry run python -m scripts.generate dev --dev-chain-id ${BSC_CHAIN_ID} --whitelist-1 "${INIT_HOLDER}" \
--epoch ${epoch} --misdemeanor-threshold "5" --felony-threshold "10" \
--epoch ${epoch} \
--init-felony-slash-scope "60" \
--breathe-block-interval "1 minutes" \
--breathe-block-interval "10 minutes" \
--block-interval ${blockInterval} \
--init-bc-consensus-addresses 'hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc"' \
--init-bc-vote-addresses 'hex"00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000030b86b3146bdd2200b1dbdb1cea5e40d3451c028cbb4fb03b1826f7f2d82bee76bbd5cd68a74a16a7eceea093fd5826b9200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003087ce273bb9b51fd69e50de7a8d9a99cfb3b1a5c6a7b85f6673d137a5a2ce7df3d6ee4e6d579a142d58b0606c4a7a1c27000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030a33ac14980d85c0d154c5909ebf7a11d455f54beb4d5d0dc1d8b3670b9c4a6b6c450ee3d623ecc48026f09ed1f0b5c1200000000000000000000000000000000"' \
Expand All @@ -110,29 +111,40 @@ function prepare_config() {

function initNetwork() {
cd ${workspace}
for ((i = 0; i < size; i++)); do
mkdir ${workspace}/.local/bsc/node${i}/geth
cp ${workspace}/keys/nodekey${i} ${workspace}/.local/bsc/node${i}/geth/nodekey
done
${workspace}/bin/geth init-network --init.dir ${workspace}/.local/bsc --init.size=${size} --config ${workspace}/config.toml ${workspace}/genesis/genesis.json
rm -rf ${workspace}/*bsc.log*
for ((i = 0; i < size; i++)); do
sed -i -e '/"<nil>"/d' ${workspace}/.local/bsc/node${i}/config.toml
cp -R ${workspace}/.local/bsc/validator${i}/keystore ${workspace}/.local/bsc/node${i}
mv ${workspace}/.local/bsc/validator${i}/keystore ${workspace}/.local/bsc/node${i}/ && rm -rf ${workspace}/.local/bsc/validator${i}

cp ${workspace}/bin/geth ${workspace}/.local/bsc/node${i}/geth${i}
# init genesis
initLog=${workspace}/.local/bsc/node${i}/init.log
${workspace}/bin/geth --datadir ${workspace}/.local/bsc/node${i} init --state.scheme ${stateScheme} --db.engine ${dbEngine} ${workspace}/genesis/genesis.json > "${initLog}" 2>&1
if [ $i -eq 0 ] ; then
${workspace}/bin/geth --datadir ${workspace}/.local/bsc/node${i} init --state.scheme ${stateScheme} --db.engine ${dbEngine} ${workspace}/genesis/genesis.json > "${initLog}" 2>&1
elif [ $i -eq 1 ] ; then
${workspace}/bin/geth --datadir ${workspace}/.local/bsc/node${i} init --state.scheme path --db.engine pebble --multidatabase ${workspace}/genesis/genesis.json > "${initLog}" 2>&1
else
${workspace}/bin/geth --datadir ${workspace}/.local/bsc/node${i} init --state.scheme path --db.engine pebble ${workspace}/genesis/genesis.json > "${initLog}" 2>&1
fi
done
}

function native_start() {
BohrHardforkTime=`cat ${workspace}/.local/bsc/hardforkTime.txt|grep hardforkTime|awk -F" " '{print $NF}'`
PassedForkTime=`cat ${workspace}/.local/bsc/hardforkTime.txt|grep passedHardforkTime|awk -F" " '{print $NF}'`
LastHardforkTime=$(expr ${PassedForkTime} + ${LAST_FORK_MORE_DELAY})

ValIdx=$1
for ((i = 0; i < size; i++));do
if [ ! -z $ValIdx ] && [ $i -ne $ValIdx ]; then
continue
fi

for j in ${workspace}/.local/bsc/validator${i}/keystore/*;do
for j in ${workspace}/.local/bsc/node${i}/keystore/*;do
cons_addr="0x$(cat ${j} | jq -r .address)"
done

Expand All @@ -150,16 +162,17 @@ function native_start() {
# run BSC node
nohup ${workspace}/.local/bsc/node${i}/geth${i} --config ${workspace}/.local/bsc/node${i}/config.toml \
--datadir ${workspace}/.local/bsc/node${i} \
--password ${workspace}/.local/bsc/password.txt \
--blspassword ${workspace}/.local/bsc/password.txt \
--password ${workspace}/.local/bsc/node${i}/password.txt \
--blspassword ${workspace}/.local/bsc/node${i}/password.txt \
--nodekey ${workspace}/.local/bsc/node${i}/geth/nodekey \
--unlock ${cons_addr} --miner.etherbase ${cons_addr} --rpc.allow-unprotected-txs --allow-insecure-unlock \
--ws.addr 0.0.0.0 --ws.port ${WSPort} --http.addr 0.0.0.0 --http.port ${HTTPPort} --http.corsdomain "*" \
--metrics --metrics.addr localhost --metrics.port ${MetricsPort} --metrics.expensive \
--gcmode ${gcmode} --syncmode full --mine --vote --monitor.maliciousvote \
--rialtohash ${rialtoHash} --override.bohr ${BohrHardforkTime} \
--rialtohash ${rialtoHash} --override.passedforktime ${PassedForkTime} --override.bohr ${LastHardforkTime} \
--override.immutabilitythreshold ${FullImmutabilityThreshold} --override.breatheblockinterval ${BreatheBlockInterval} \
--override.minforblobrequest ${MinBlocksForBlobRequests} --override.defaultextrareserve ${DefaultExtraReserveForBlobRequests} \
`# --override.fixedturnlength ${FixedTurnLength}` \
> ${workspace}/.local/bsc/node${i}/bsc-node.log 2>&1 &
done
}
Expand Down Expand Up @@ -214,7 +227,7 @@ function prepare_k8s_config() {

kubectl delete secret password -n bsc
kubectl create secret generic password -n bsc \
--from-file ${workspace}/.local/bsc/password.txt
--from-file ${workspace}/keys/password.txt

kubectl delete configmap config${i} -n bsc
kubectl create configmap config${i} -n bsc \
Expand Down

0 comments on commit 59b5692

Please sign in to comment.