如何阅读Tendermint的日志
如何閱讀Tendermint的日志
TM的完整日志可以在這里獲取。本文用的日志文件來自TM v0.16。
案例走起(walk through example)
I[03-25|04:40:48.219] Starting multiAppConn module=proxy impl=multiAppConn I[03-25|04:40:48.219] Starting localClient module=abci-client connection=query impl=localClient I[03-25|04:40:48.219] Starting localClient module=abci-client connection=mempool impl=localClient I[03-25|04:40:48.219] Starting localClient module=abci-client connection=consensus impl=localClient首先,創建了多個應用連接(multiAppConn),具體是三個連接(query,mempool和consensu)。注意:這里的應用是指在本地以dummy運行。
接著Tendermint Core和應用完成了一次握手。
之后,開啟了一系列的服務(為正式啟動node做準備),例如事件開關(event switch),reactor以及為了檢測IP地址,完成了UPNP發現。
I[03-25|04:40:48.219] This node is a validator module=consensus addr=BD8F0160796AEC1E6454C55CCA6AF15EACF94A2D pubKey={PubKeyInner:PubKeyEd25519{7A4BCE42785BF1B008E2B2B9117FB617153597E9E3BBE00BB93889DFA7885461}} I[03-25|04:40:48.243] Starting Node module=main impl=Node I[03-25|04:40:48.243] Starting EventBus module=events impl=EventBus I[03-25|04:40:48.243] Starting RPC HTTP server on tcp socket 0.0.0.0:46657 module=rpc-server I[03-25|04:40:48.244] Local listener module=p2p ip=:: port=46656 I[03-25|04:40:48.244] Getting UPNP external address module=p2p I[03-25|04:40:51.244] Could not perform UPNP discover module=p2p err="read udp4 0.0.0.0:50863: i/o timeout" I[03-25|04:40:51.244] Starting DefaultListener module=p2p impl=Listener(@172.31.22.212:46656) I[03-25|04:40:51.244] P2P Node ID module=main ID=6082741e5b3494908078fe5f473563f1c483d79e file=/opt/datadir/tendermint/config/node_key.json I[03-25|04:40:51.244] Starting P2P Switch module=p2p impl="P2P Switch" I[03-25|04:40:51.244] Starting EvidenceReactor module=evidence impl=EvidenceReactor I[03-25|04:40:51.245] Starting PEXReactor module=p2p impl=PEXReactor I[03-25|04:40:51.245] Starting AddrBook module=p2p book=/opt/datadir/tendermint/config/addrbook.json impl=AddrBook I[03-25|04:40:51.245] Starting MempoolReactor module=mempool impl=MempoolReactor I[03-25|04:40:51.245] Starting BlockchainReactor module=blockchain impl=BlockchainReactor I[03-25|04:40:51.245] Starting ConsensusReactor module=consensus impl=ConsensusReactor I[03-25|04:40:51.245] ConsensusReactor module=consensus fastSync=false I[03-25|04:40:51.245] Starting ConsensusState module=consensus impl=ConsensusState I[03-25|04:40:51.245] Starting baseWAL module=consensus wal=/opt/datadir/tendermint/data/cs.wal/wal impl=baseWAL I[03-25|04:40:51.247] Starting TimeoutTicker module=consensus impl=TimeoutTicker注意第一行,Tendermint Core報告,“此節點是驗證人”。這里也可以只是觀察人(正規節點)。第二行報告,Starting Node,這預示系統正式進入啟動node的處理邏輯中。
接著,我們中繼了來自WAL的所有消息。
“Started node”消息預示著node啟動完畢,隨時準備區塊創建。
I[03-25|04:40:51.248] Started node module=main nodeInfo="NodeInfo{pk: {PubKeyEd25519{54E665EFA8EF7AD5763C421129F66FBD367B253788543C0E1B9CF047C45771D3}}, moniker: bootnode-hongkong, network: test-chain-MErM3n [listen 172.31.22.212:46656], version: 0.16.0 ([wire_version=0.7.2 p2p_version=0.5.0 consensus_version=v1/0.2.2 rpc_version=0.7.0/3 tx_index=on rpc_addr=tcp://0.0.0.0:46657])}"接著是一個標準的區塊創建過程,即進入到新的一輪中,提案一個區塊,接收超過2/3的預投票(prevote),接著預提交(precommit)并且最終提交一個區塊(finalise)。其中的細節,可以參閱介紹Tendermint共識的其他文章。
I[03-25|04:40:51.250] enterNewRound(1/0). Current: 1/0/RoundStepNewHeight module=consensus I[03-25|04:40:51.250] enterPropose(1/0). Current: 1/0/RoundStepNewRound module=consensus I[03-25|04:40:51.250] enterPropose: Our turn to propose module=consensus proposer=BD8F0160796AEC1E6454C55CCA6AF15EACF94A2D privValidator="PrivValidator{BD8F0160796AEC1E6454C55CCA6AF15EACF94A2D LH:0, LR:0, LS:0}" I[03-25|04:40:51.253] Signed proposal module=consensus height=1 round=0 proposal="Proposal{1/0 1:57D9BC19067F (-1,:0:000000000000) {/3FB2AD239E88.../} @ 2018-03-25T04:40:51.250Z}" I[03-25|04:40:51.259] Received complete proposal block module=consensus height=1 hash=2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49 I[03-25|04:40:51.259] enterPrevote(1/0). Current: 1/0/RoundStepPropose module=consensus I[03-25|04:40:51.259] enterPrevote: ProposalBlock is valid module=consensus height=1 round=0 I[03-25|04:40:51.261] Signed and pushed vote module=consensus height=1 round=0 vote="Vote{0:BD8F0160796A 1/00/1(Prevote) 2CFA5BC56A2E {/347B4DC16274.../} @ 2018-03-25T04:40:51.259Z}" err=null I[03-25|04:40:51.265] Added to prevote module=consensus vote="Vote{0:BD8F0160796A 1/00/1(Prevote) 2CFA5BC56A2E {/347B4DC16274.../} @ 2018-03-25T04:40:51.259Z}" prevotes="VoteSet{H:1 R:0 T:1 +2/3:2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49:1:57D9BC19067F BA{1:X} map[]}" I[03-25|04:40:51.265] enterPrecommit(1/0). Current: 1/0/RoundStepPrevote module=consensus I[03-25|04:40:51.265] enterPrecommit: +2/3 prevoted proposal block. Locking module=consensus hash=2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49 I[03-25|04:40:51.267] Signed and pushed vote module=consensus height=1 round=0 vote="Vote{0:BD8F0160796A 1/00/2(Precommit) 2CFA5BC56A2E {/1AB356C41018.../} @ 2018-03-25T04:40:51.265Z}" err=null I[03-25|04:40:51.271] Added to precommit module=consensus vote="Vote{0:BD8F0160796A 1/00/2(Precommit) 2CFA5BC56A2E {/1AB356C41018.../} @ 2018-03-25T04:40:51.265Z}" precommits="VoteSet{H:1 R:0 T:2 +2/3:2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49:1:57D9BC19067F BA{1:X} map[]}" I[03-25|04:40:51.271] enterCommit(1/0). Current: 1/0/RoundStepPrecommit module=consensus I[03-25|04:40:51.274] Finalizing commit of block with 0 txs module=consensus height=1 hash=2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49 root= I[03-25|04:40:51.274] Block{Header{ChainID: test-chain-MErM3nHeight: 1Time: 2018-03-25 12:40:51.25 +0800 CSTNumTxs: 0TotalTxs: 0LastBlockID: :0:000000000000LastCommit:Data:Validators: 7DBC0AC152D72CA2DA37CAB8D6D5A73B8DA9DC43App:Conensus: 0B8CEF95EC57AC2D96038FD0AE3901C14FAE8E73Results:Evidence:}#2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49Data{}#Data{}#Commit{BlockID: :0:000000000000Precommits:}# }#2CFA5BC56A2E5D0BB94B84EB35AD05CC8F47CC49 module=consensus I[03-25|04:40:51.279] Executed block module=state height=1 validTxs=0 invalidTxs=0 I[03-25|04:40:51.281] Committed state module=state height=1 txs=0 appHash=0000000000000000 I[03-25|04:40:51.281] Recheck txs module=mempool numtxs=0 height=1模塊列表
你可能在Tendermint的日志中看到下面這些模塊。這里簡單綜述一下它們是做什么的。
abci-client:Tendermint充當有關一個應用的ABCI客戶端,并且維護3個連接:mempool,consensu和query。
blockchain:提供存儲,pool(一組peers)以及在peers之間存儲以及交換區塊的reactor。
consensus:Tendermint core的核心,實現了共識算法。包括兩個“子模塊”:wal(write-ahead logging,預寫式日志)用于保證數據完整性和replay:宕機恢復后replay區塊和消息。
events:簡單的事件通知系統。你可以用過調用subscribe RPC方法來訂閱。
mempool:內存池模塊會處理所有流入系統的交易,不論它們是來自peers(即peers也可以產生交易)還是應用(應用也可以產生交易,當然主要是應用產生)。
p2p:圍繞點對點通信提供了抽象。
rpc:Tendermint的RPC服務。
rpc-server:RPC服務器。
state:表示最近的狀態和執行子模塊(根據應用執行區塊)。
types:一組公開暴露的類型和方法。
總結
區塊鏈的日志體系很強大,通過日志我們可以知道很多技術細節。我想日志體系可能是構建基礎服務類軟件的重器之一吧。本文翻譯了官方文檔之“如何閱讀日志”,在尊重原文的基礎上,略做了少許注釋。有關TM的更多細節可以參考我們的文章。它們是:
1、安裝Tendermint
2、Windows下編譯Tendermint源碼遇到的坑
3、TM白皮書
4、Tendermint源碼分析—協議參數部分
5、Tendermint的初始化流程分析
6、Tendermint源碼分析之peer建立連接
總結
以上是生活随笔為你收集整理的如何阅读Tendermint的日志的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 跨阻放大器振荡
- 下一篇: express+mongoDB项目创建及