網(wǎng)絡(luò)上很少有全面詳細(xì)的區(qū)塊鏈系統(tǒng)仿真的代碼和講解,從頭開始真的很難。
現(xiàn)在先把葉之秋大神分享的BFT-SMaRt 性能測試實(shí)驗(yàn)給復(fù)現(xiàn)一下,遇到的困難...不計(jì)其數(shù)。鏈接如下:共識(shí)和區(qū)塊鏈實(shí)驗(yàn)-以 BFT-SMaRt 和 Fabric 為例 - 知乎
Ubuntu和docker部分省略。
初始化環(huán)境
拉取Ubuntu18.04鏡像
docker run -it --rm ubuntu:18.04 bash
安裝git和ant
apt update
apt install git -y
apt install ant -y
git clone https://github.com/bft-smart/library.git
cd library
git checkout 0f2d407
ant
重要步驟:注釋掉 /usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security 中的下面這3行,不然會(huì)報(bào)錯(cuò)。(Java調(diào)用ssl異常,javax.net.ssl.SSLHandshakeException: No appropriate protocol)
apt update
apt install vim
vim /usr/lib/jvm/java-11-openjdk-amd64/conf/security/java.security
#注釋下面這三行,記得看清楚內(nèi)容,行數(shù)不一定準(zhǔn)確
# 704 # jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
# 705 # DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
# 706 # include jdk.disabled.namedCurves
此時(shí)網(wǎng)絡(luò)環(huán)境初始化步驟已經(jīng)結(jié)束,筆者建議此時(shí)的容器可以保存成鏡像,后續(xù)使用避免重來。
之后在ubuntu中打開四個(gè)終端,進(jìn)入同一個(gè)docker容器的終端作為四個(gè)節(jié)點(diǎn)。
docker exec -it 7e9117c6bbb2 /bin/bash
#容器id自擬
之后在新打開的四個(gè)終端內(nèi)單獨(dú)配置組網(wǎng)設(shè)置:
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 0
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 1
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 2
./runscripts/smartrun.sh bftsmart.demo.counter.CounterServer 3
# 等四個(gè)節(jié)點(diǎn)都輸出 Ready to process operations 后,運(yùn)行 client
./runscripts/smartrun.sh bftsmart.demo.counter.CounterClient 1001 2 100
注:四個(gè)終端都配置好后才顯示-- Ready to process operations成功頁面
client正常運(yùn)行:
測試 BFT-SmaRt 的 throughput 和 latency
根據(jù)葉之秋大神筆記做


更改節(jié)點(diǎn)數(shù)量
在config/hosts.config文件中增加一個(gè)節(jié)點(diǎn)。
4 127.0.0.1 11040 11041
修改config/hosts.config:? ?文章來源:http://www.zghlxwxcb.cn/news/detail-854935.html
############################################
### Replication Algorithm Configurations ###
############################################
#Number of servers in the group
system.servers.num = 5
############################################
###### Reconfiguration Configurations ######
############################################
#Replicas ID for the initial view, separated by a comma.
# The number of replicas in this parameter should be equal to that specified in 'system.servers.num'
system.initial.view = 0,1,2,3,4
##163行
后續(xù)未實(shí)現(xiàn)文章來源地址http://www.zghlxwxcb.cn/news/detail-854935.html
到了這里,關(guān)于小白學(xué)習(xí)區(qū)塊鏈-共識(shí)算法測試(1)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!