Browse Source

Merge branch 'master' into blocksync-avoid-redundant-channel

pull/8140/head
Sam Kleinman 2 years ago
committed by GitHub
parent
commit
8579c8e848
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions
  1. +5
    -5
      internal/p2p/peermanager.go
  2. +16
    -0
      internal/p2p/peermanager_scoring_test.go
  3. +1
    -1
      spec/abci++/abci++_methods_002_draft.md

+ 5
- 5
internal/p2p/peermanager.go View File

@ -42,7 +42,8 @@ const (
type PeerScore uint8
const (
PeerScorePersistent PeerScore = math.MaxUint8 // persistent peers
PeerScorePersistent PeerScore = math.MaxUint8 // persistent peers
MaxPeerScoreNotPersistent PeerScore = PeerScorePersistent - 1
)
// PeerUpdate is a peer update event sent via PeerUpdates.
@ -1283,6 +1284,9 @@ func (p *peerInfo) Score() PeerScore {
}
score := p.MutableScore
if score > int64(MaxPeerScoreNotPersistent) {
score = int64(MaxPeerScoreNotPersistent)
}
for _, addr := range p.AddressInfo {
// DialFailures is reset when dials succeed, so this
@ -1294,10 +1298,6 @@ func (p *peerInfo) Score() PeerScore {
return 0
}
if score >= math.MaxUint8 {
return PeerScore(math.MaxUint8)
}
return PeerScore(score)
}


+ 16
- 0
internal/p2p/peermanager_scoring_test.go View File

@ -80,4 +80,20 @@ func TestPeerScoring(t *testing.T) {
time.Millisecond,
"startAt=%d score=%d", start, peerManager.Scores()[id])
})
t.Run("TestNonPersistantPeerUpperBound", func(t *testing.T) {
start := int64(peerManager.Scores()[id] + 1)
for i := start; i <= int64(PeerScorePersistent); i++ {
peerManager.processPeerEvent(ctx, PeerUpdate{
NodeID: id,
Status: PeerStatusGood,
})
if i == int64(PeerScorePersistent) {
require.EqualValues(t, MaxPeerScoreNotPersistent, peerManager.Scores()[id])
} else {
require.EqualValues(t, i, peerManager.Scores()[id])
}
}
})
}

+ 1
- 1
spec/abci++/abci++_methods_002_draft.md View File

@ -422,7 +422,7 @@ Note that, if _p_ has a non-`nil` _validValue_, Tendermint will use it as propos
* The parameters and types of `RequestProcessProposal` are the same as `RequestPrepareProposal`
and `RequestFinalizeBlock`.
* The Application may fully execute the block as though it was handling `RequestFinalizeBlock`.
However, any resulting state changes must be kept as _canditade state_,
However, any resulting state changes must be kept as _candidate state_,
and the Application should be ready to backtrack/discard it in case the decided block is different.
* The header exactly matches the Tendermint header of the proposed block.
* In next-block execution mode, the header hashes _AppHash_, _LastResultHash_, _ValidatorHash_,


Loading…
Cancel
Save