diff --git a/.env b/.env index 24645f3..9e9c793 100644 --- a/.env +++ b/.env @@ -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 diff --git a/config.toml b/config.toml index 7b7d7ac..d00f273 100644 --- a/config.toml +++ b/config.toml @@ -19,7 +19,7 @@ GasPrice = 10000000000 Recommit = 10000000000 [Eth.Miner.Mev] -Enabled = false +Enabled = true GreedyMergeTx = true BuilderFeeCeil= "0" ValidatorCommission = 1000 diff --git a/genesis b/genesis index 04bc57c..398c936 160000 --- a/genesis +++ b/genesis @@ -1 +1 @@ -Subproject commit 04bc57c1876dd543dd3133b2755ba87cc5f1796a +Subproject commit 398c9364aad5261c1ecd90ac3ab2df89b65c45e3 diff --git a/keys/nodekey0 b/keys/nodekey0 new file mode 100644 index 0000000..5f775f0 --- /dev/null +++ b/keys/nodekey0 @@ -0,0 +1 @@ +4e53fc003749b87a8e1a1bfdf1c2688ef0f8ea7301e49de3ee766e34dc41b7a4 \ No newline at end of file diff --git a/keys/nodekey1 b/keys/nodekey1 new file mode 100644 index 0000000..8e05674 --- /dev/null +++ b/keys/nodekey1 @@ -0,0 +1 @@ +a70322a0f89a73e7648577659eaa9185de61897697e05471b8aabd119f301703 \ No newline at end of file diff --git a/keys/nodekey10 b/keys/nodekey10 new file mode 100644 index 0000000..eb7254f --- /dev/null +++ b/keys/nodekey10 @@ -0,0 +1 @@ +4a6963661cb4bca8185c3209c33a6d16e6fdcf7ad2204f65353b23ecef183981 \ No newline at end of file diff --git a/keys/nodekey11 b/keys/nodekey11 new file mode 100644 index 0000000..84573b3 --- /dev/null +++ b/keys/nodekey11 @@ -0,0 +1 @@ +54c4495c0d17fe33013c202bfe6493d1cfa415f9ff94e5378c94015d766c7266 \ No newline at end of file diff --git a/keys/nodekey12 b/keys/nodekey12 new file mode 100644 index 0000000..509bd8c --- /dev/null +++ b/keys/nodekey12 @@ -0,0 +1 @@ +14174f27b73f25bb34eefa206a30ab37cc6f41bc7c93e4746ae173ff86415eae \ No newline at end of file diff --git a/keys/nodekey13 b/keys/nodekey13 new file mode 100644 index 0000000..f2d0154 --- /dev/null +++ b/keys/nodekey13 @@ -0,0 +1 @@ +9a9eb3dd23b839e870fdef1ab318acaf3308d18186dcda1330f9c20b547495fc \ No newline at end of file diff --git a/keys/nodekey14 b/keys/nodekey14 new file mode 100644 index 0000000..c2c109a --- /dev/null +++ b/keys/nodekey14 @@ -0,0 +1 @@ +6e9f908dd76d9166299439c70845466c7cef2093c0ce7dc2193c677ebe566369 \ No newline at end of file diff --git a/keys/nodekey15 b/keys/nodekey15 new file mode 100644 index 0000000..6750626 --- /dev/null +++ b/keys/nodekey15 @@ -0,0 +1 @@ +368885deebe33e020bffac57f19f36a5712073b4b7ce097a343da9770690c568 \ No newline at end of file diff --git a/keys/nodekey16 b/keys/nodekey16 new file mode 100644 index 0000000..06b987b --- /dev/null +++ b/keys/nodekey16 @@ -0,0 +1 @@ +9e6494e7c485296cd84783b8aec6426577f3ccc56245f5bac58e7349fc48f4fa \ No newline at end of file diff --git a/keys/nodekey17 b/keys/nodekey17 new file mode 100644 index 0000000..6852b71 --- /dev/null +++ b/keys/nodekey17 @@ -0,0 +1 @@ +7c52c7fdb24886fd65669cb4214cb1bec3e3f98262b33e142a158e5fba178708 \ No newline at end of file diff --git a/keys/nodekey18 b/keys/nodekey18 new file mode 100644 index 0000000..ac33598 --- /dev/null +++ b/keys/nodekey18 @@ -0,0 +1 @@ +2a6334a29611c6ffb845038884d430706235a9c37910ceadf04fef9c3d543ccf \ No newline at end of file diff --git a/keys/nodekey19 b/keys/nodekey19 new file mode 100644 index 0000000..5c65ca8 --- /dev/null +++ b/keys/nodekey19 @@ -0,0 +1 @@ +e841bf5f4669270172bb5f8fb42fe4ba9a8c1ae6cb91c3e983f3bf69d9bebe5a \ No newline at end of file diff --git a/keys/nodekey2 b/keys/nodekey2 new file mode 100644 index 0000000..e74a7b5 --- /dev/null +++ b/keys/nodekey2 @@ -0,0 +1 @@ +a97ba2b4fcba715ce70e5edae07c472bd13dc10a7648237c9ae93e9ba9da8a6f \ No newline at end of file diff --git a/keys/nodekey20 b/keys/nodekey20 new file mode 100644 index 0000000..4128210 --- /dev/null +++ b/keys/nodekey20 @@ -0,0 +1 @@ +4dcbab3e7c97ba11b7a3ab37dc7a3a59806df941cca5a2a8c26c8dc8fd917e90 \ No newline at end of file diff --git a/keys/nodekey3 b/keys/nodekey3 new file mode 100644 index 0000000..55faf08 --- /dev/null +++ b/keys/nodekey3 @@ -0,0 +1 @@ +714594b74b8f8ba91a5ec9ea740e789330bd9a26a3140f1278806ae4475228d2 \ No newline at end of file diff --git a/keys/nodekey4 b/keys/nodekey4 new file mode 100644 index 0000000..eeee714 --- /dev/null +++ b/keys/nodekey4 @@ -0,0 +1 @@ +2147c90c49d560ce92f81245787e7a49f21552ba4dc7bd2383ef66bb5fa4719a \ No newline at end of file diff --git a/keys/nodekey5 b/keys/nodekey5 new file mode 100644 index 0000000..c8ac496 --- /dev/null +++ b/keys/nodekey5 @@ -0,0 +1 @@ +a8a055bffe8b6f4d223dc9ce2407cf717500a8969f545cbb6ed058af2ea8714c \ No newline at end of file diff --git a/keys/nodekey6 b/keys/nodekey6 new file mode 100644 index 0000000..fe85fce --- /dev/null +++ b/keys/nodekey6 @@ -0,0 +1 @@ +54bccba78142c774cdd12966866cc7677921955e1f56f66012af990a79826c34 \ No newline at end of file diff --git a/keys/nodekey7 b/keys/nodekey7 new file mode 100644 index 0000000..1bd3b70 --- /dev/null +++ b/keys/nodekey7 @@ -0,0 +1 @@ +2effb85f159d28ee3e76765a3ae0b5daee6fe907274df0f54a30378b1b559b37 \ No newline at end of file diff --git a/keys/nodekey8 b/keys/nodekey8 new file mode 100644 index 0000000..bf7c10a --- /dev/null +++ b/keys/nodekey8 @@ -0,0 +1 @@ +e7b5b870f999ce5ece45cc87c11303da938d3ed27945541ef9dc039d23a26bf5 \ No newline at end of file diff --git a/keys/nodekey9 b/keys/nodekey9 new file mode 100644 index 0000000..2911981 --- /dev/null +++ b/keys/nodekey9 @@ -0,0 +1 @@ +0303b120dc0d8ffb2e8d071f6501b5381c8fddb81d8fd01cb6dab394889e1b05 \ No newline at end of file diff --git a/start_cluster.sh b/start_cluster.sh index 52f1466..00f40e8 100644 --- a/start_cluster.sh +++ b/start_cluster.sh @@ -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 @@ -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/ @@ -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 @@ -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} @@ -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"' \ @@ -110,21 +111,32 @@ 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 '/""/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 @@ -132,7 +144,7 @@ function native_start() { 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 @@ -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 } @@ -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 \