Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit a0e0373

Browse files
authored
Merge pull request #103 from binance-chain/develop
[R4R] ready for release v0.31.5-binance.1
2 parents 7f89609 + 0b63fbb commit a0e0373

9 files changed

Lines changed: 85 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## v0.31.5-binance.1
4+
*July 17th, 2019*
5+
6+
### IMPROVEMENTS:
7+
- [mempool] [\#100](https://github.com/binance-chain/bnc-tendermint/pull/100) add OnlyPersistent to config of mempool
8+
- [metrics] [\#96](https://github.com/binance-chain/bnc-tendermint/pull/96) monitor: add more metrics about p2p
9+
310
## v0.31.5
411

512
*April 16th, 2019*

CHANGELOG_PENDING.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## v0.31.6
1+
## develop
22

33
**
44

@@ -15,9 +15,7 @@
1515
* P2P Protocol
1616

1717
### FEATURES:
18-
- [node] Support block index by hash, query block by hash through rpc.
1918

2019
### IMPROVEMENTS:
2120

2221
### BUG FIXES:
23-
- [node] \#3186 EventBus and indexerService should be started before first block (for replay last block on handshake) execution

consensus/metrics.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ type Metrics struct {
5151

5252
// Number of blockparts transmitted by peer.
5353
BlockParts metrics.Counter
54+
55+
// Number of proposals transmitted by peer.
56+
Proposals metrics.Counter
57+
58+
// Number of votes transmitted by peer.
59+
Votes metrics.Counter
60+
61+
// Number of voteSetBits transmitted by peer.
62+
VoteSetBits metrics.Counter
5463
}
5564

5665
// PrometheusMetrics returns Metrics build using Prometheus client library.
@@ -154,7 +163,25 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
154163
Subsystem: MetricsSubsystem,
155164
Name: "block_parts",
156165
Help: "Number of blockparts transmitted by peer.",
166+
}, append(labels, "peer_id", "index")).With(labelsAndValues...),
167+
Proposals: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
168+
Namespace: namespace,
169+
Subsystem: MetricsSubsystem,
170+
Name: "proposals",
171+
Help: "Number of proposals transmitted by peer.",
157172
}, append(labels, "peer_id")).With(labelsAndValues...),
173+
Votes: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
174+
Namespace: namespace,
175+
Subsystem: MetricsSubsystem,
176+
Name: "votes",
177+
Help: "Number of votes transmitted by peer.",
178+
}, append(labels, "peer_id", "type")).With(labelsAndValues...),
179+
VoteSetBits: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
180+
Namespace: namespace,
181+
Subsystem: MetricsSubsystem,
182+
Name: "vote_set_bits",
183+
Help: "Number of voteSetBits transmitted by peer.",
184+
}, append(labels, "peer_id", "type")).With(labelsAndValues...),
158185
}
159186
}
160187

@@ -180,5 +207,8 @@ func NopMetrics() *Metrics {
180207
CommittedHeight: discard.NewGauge(),
181208
FastSyncing: discard.NewGauge(),
182209
BlockParts: discard.NewCounter(),
210+
Proposals: discard.NewCounter(),
211+
Votes: discard.NewCounter(),
212+
VoteSetBits: discard.NewCounter(),
183213
}
184214
}

consensus/reactor.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package consensus
33
import (
44
"fmt"
55
"reflect"
6+
"strconv"
67
"sync"
78
"time"
89

@@ -285,12 +286,13 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
285286
switch msg := msg.(type) {
286287
case *ProposalMessage:
287288
ps.SetHasProposal(msg.Proposal)
289+
conR.metrics.Proposals.With("peer_id", string(src.ID())).Add(1)
288290
conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()}
289291
case *ProposalPOLMessage:
290292
ps.ApplyProposalPOLMessage(msg)
291293
case *BlockPartMessage:
292294
ps.SetHasProposalBlockPart(msg.Height, msg.Round, msg.Part.Index)
293-
conR.metrics.BlockParts.With("peer_id", string(src.ID())).Add(1)
295+
conR.metrics.BlockParts.With("peer_id", string(src.ID())).With("index", strconv.Itoa(msg.Part.Index)).Add(1)
294296
conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()}
295297
default:
296298
conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg)))
@@ -310,7 +312,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
310312
ps.EnsureVoteBitArrays(height, valSize)
311313
ps.EnsureVoteBitArrays(height-1, lastCommitSize)
312314
ps.SetHasVote(msg.Vote)
313-
315+
conR.metrics.Votes.With("peer_id", string(src.ID())).With("type", msg.Vote.Type.String()).Add(1)
314316
cs.peerMsgQueue <- msgInfo{msg, src.ID()}
315317

316318
default:
@@ -329,7 +331,7 @@ func (conR *ConsensusReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
329331
cs.mtx.Lock()
330332
height, votes := cs.Height, cs.Votes
331333
cs.mtx.Unlock()
332-
334+
conR.metrics.VoteSetBits.With("peer_id", string(src.ID())).With("type", msg.Type.String()).Add(1)
333335
if height == msg.Height {
334336
var ourVotes *cmn.BitArray
335337
switch msg.Type {

mempool/mempool.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ func txKey(tx types.Tx) [sha256.Size]byte {
161161
type Mempool struct {
162162
config *cfg.MempoolConfig
163163

164-
proxyLowMtx sync.Mutex
165-
proxyNextMtx sync.Mutex
166-
proxyBlockingMtx sync.Mutex
167-
proxyAppConn proxy.AppConnMempool
168-
txs *clist.CList // concurrent linked-list of good txs
169-
preCheck PreCheckFunc
170-
postCheck PostCheckFunc
164+
proxyLowMtx sync.Mutex
165+
proxyNextMtx sync.Mutex
166+
proxyBlockingMtx sync.Mutex
167+
proxyAppConn proxy.AppConnMempool
168+
txs *clist.CList // concurrent linked-list of good txs
169+
preCheck PreCheckFunc
170+
postCheck PostCheckFunc
171171

172172
// Track whether we're rechecking txs.
173173
// These are not protected by a mutex and are expected to be mutated
@@ -417,7 +417,6 @@ func (mem *Mempool) CheckTxWithInfo(tx types.Tx, cb func(*abci.Response), txInfo
417417
// but they can spam the same tx with little cost to them atm.
418418
}
419419
}
420-
421420
return ErrTxInCache
422421
}
423422
// END CACHE

mempool/metrics.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type Metrics struct {
2424
FailedTxs metrics.Counter
2525
// Number of times transactions are rechecked in the mempool.
2626
RecheckTimes metrics.Counter
27+
// Number of tx transmitted by peer.
28+
ReceivedTx metrics.Counter
29+
// Number of duplicated tx transmitted by peer.
30+
DuplicateTx metrics.Counter
2731
}
2832

2933
// PrometheusMetrics returns Metrics build using Prometheus client library.
@@ -60,6 +64,18 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
6064
Name: "recheck_times",
6165
Help: "Number of times transactions are rechecked in the mempool.",
6266
}, labels).With(labelsAndValues...),
67+
ReceivedTx: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
68+
Namespace: namespace,
69+
Subsystem: MetricsSubsystem,
70+
Name: "received_tx",
71+
Help: "Number of tx transmitted by peer.",
72+
}, append(labels, "peer_id")).With(labelsAndValues...),
73+
DuplicateTx: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
74+
Namespace: namespace,
75+
Subsystem: MetricsSubsystem,
76+
Name: "duplicate_tx",
77+
Help: "Number of duplicate tx transmitted by peer.",
78+
}, append(labels, "peer_id")).With(labelsAndValues...),
6379
}
6480
}
6581

@@ -70,5 +86,7 @@ func NopMetrics() *Metrics {
7086
TxSizeBytes: discard.NewHistogram(),
7187
FailedTxs: discard.NewCounter(),
7288
RecheckTimes: discard.NewCounter(),
89+
ReceivedTx: discard.NewCounter(),
90+
DuplicateTx: discard.NewCounter(),
7391
}
7492
}

mempool/reactor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ func (memR *MempoolReactor) receiveImpl(chID byte, src p2p.Peer, msgBytes []byte
193193

194194
switch msg := msg.(type) {
195195
case *TxMessage:
196+
memR.Mempool.metrics.ReceivedTx.With("peer_id", string(src.ID())).Add(1)
196197
peerID := memR.ids.GetForPeer(src)
197198
err := memR.Mempool.CheckTxWithInfo(msg.Tx, nil, TxInfo{PeerID: peerID})
198199
if err != nil {
200+
if err == ErrTxInCache {
201+
memR.Mempool.metrics.DuplicateTx.With("peer_id", string(src.ID())).Add(1)
202+
}
199203
memR.Logger.Info("Could not check tx", "tx", TxID(msg.Tx), "err", err)
200204
}
201205
// broadcasting happens from go routines per peer

p2p/metrics.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ type Metrics struct {
2323
PeerSendBytesTotal metrics.Counter
2424
// Pending bytes to be sent to a given peer.
2525
PeerPendingSendBytes metrics.Gauge
26-
// Number of transactions submitted by each peer.
27-
NumTxs metrics.Gauge
2826
}
2927

3028
// PrometheusMetrics returns Metrics build using Prometheus client library.
@@ -60,12 +58,6 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
6058
Name: "peer_pending_send_bytes",
6159
Help: "Number of pending bytes to be sent to a given peer.",
6260
}, append(labels, "peer_id")).With(labelsAndValues...),
63-
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
64-
Namespace: namespace,
65-
Subsystem: MetricsSubsystem,
66-
Name: "num_txs",
67-
Help: "Number of transactions submitted by each peer.",
68-
}, append(labels, "peer_id")).With(labelsAndValues...),
6961
}
7062
}
7163

@@ -76,6 +68,5 @@ func NopMetrics() *Metrics {
7668
PeerReceiveBytesTotal: discard.NewCounter(),
7769
PeerSendBytesTotal: discard.NewCounter(),
7870
PeerPendingSendBytes: discard.NewGauge(),
79-
NumTxs: discard.NewGauge(),
8071
}
8172
}

types/signed_msg_type.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ func IsVoteTypeValid(t SignedMsgType) bool {
2121
return false
2222
}
2323
}
24+
25+
func (t SignedMsgType) String() string {
26+
switch t {
27+
case PrevoteType:
28+
return "prevote"
29+
case PrecommitType:
30+
return "precommit"
31+
case ProposalType:
32+
return "proposal"
33+
default:
34+
return "unknow"
35+
}
36+
}

0 commit comments

Comments
 (0)