Browse Source

blockchain/v1: add noBlockResponse handling (#5401)

## Description

Add simple `NoBlockResponse` handling to blockchain reactor v1. I tested before and after with erik's e2e testing and was not able to reproduce the inability to sync after the changes were applied

Closes: #5394
pull/5534/head
Marko 4 years ago
committed by Erik Grinaker
parent
commit
41ab199378
3 changed files with 20 additions and 1 deletions
  1. +10
    -0
      blockchain/v1/reactor.go
  2. +9
    -0
      blockchain/v1/reactor_fsm.go
  3. +1
    -1
      blockchain/v1/reactor_fsm_test.go

+ 10
- 0
blockchain/v1/reactor.go View File

@ -298,6 +298,16 @@ func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
} }
bcR.Logger.Info("Received", "src", src, "height", bi.Height) bcR.Logger.Info("Received", "src", src, "height", bi.Height)
bcR.messagesForFSMCh <- msgForFSM bcR.messagesForFSMCh <- msgForFSM
case *bcproto.NoBlockResponse:
msgForFSM := bcReactorMessage{
event: noBlockResponseEv,
data: bReactorEventData{
peerID: src.ID(),
height: msg.Height,
},
}
bcR.Logger.Debug("Peer does not have requested block", "peer", src, "height", msg.Height)
bcR.messagesForFSMCh <- msgForFSM
case *bcproto.StatusResponse: case *bcproto.StatusResponse:
// Got a peer status. Unverified. // Got a peer status. Unverified.


+ 9
- 0
blockchain/v1/reactor_fsm.go View File

@ -74,6 +74,7 @@ const (
startFSMEv = iota + 1 startFSMEv = iota + 1
statusResponseEv statusResponseEv
blockResponseEv blockResponseEv
noBlockResponseEv
processedBlockEv processedBlockEv
makeRequestsEv makeRequestsEv
stopFSMEv stopFSMEv
@ -94,6 +95,9 @@ func (msg *bcReactorMessage) String() string {
case blockResponseEv: case blockResponseEv:
dataStr = fmt.Sprintf("peer=%v block.height=%v length=%v", dataStr = fmt.Sprintf("peer=%v block.height=%v length=%v",
msg.data.peerID, msg.data.block.Height, msg.data.length) msg.data.peerID, msg.data.block.Height, msg.data.length)
case noBlockResponseEv:
dataStr = fmt.Sprintf("peer=%v requested height=%v",
msg.data.peerID, msg.data.height)
case processedBlockEv: case processedBlockEv:
dataStr = fmt.Sprintf("error=%v", msg.data.err) dataStr = fmt.Sprintf("error=%v", msg.data.err)
case makeRequestsEv: case makeRequestsEv:
@ -119,6 +123,8 @@ func (ev bReactorEvent) String() string {
return "statusResponseEv" return "statusResponseEv"
case blockResponseEv: case blockResponseEv:
return "blockResponseEv" return "blockResponseEv"
case noBlockResponseEv:
return "noBlockResponseEv"
case processedBlockEv: case processedBlockEv:
return "processedBlockEv" return "processedBlockEv"
case makeRequestsEv: case makeRequestsEv:
@ -269,7 +275,10 @@ func init() {
return waitForPeer, err return waitForPeer, err
} }
return waitForBlock, err return waitForBlock, err
case noBlockResponseEv:
fsm.logger.Error("peer does not have requested block", "peer", data.peerID)
return waitForBlock, nil
case processedBlockEv: case processedBlockEv:
if data.err != nil { if data.err != nil {
first, second, _ := fsm.pool.FirstTwoBlocksAndPeers() first, second, _ := fsm.pool.FirstTwoBlocksAndPeers()


+ 1
- 1
blockchain/v1/reactor_fsm_test.go View File

@ -822,7 +822,7 @@ const (
maxRequestsPerPeerTest = 20 maxRequestsPerPeerTest = 20
maxTotalPendingRequestsTest = 600 maxTotalPendingRequestsTest = 600
maxNumPeersTest = 1000 maxNumPeersTest = 1000
maxNumBlocksInChainTest = 10000 //should be smaller than 9999999
maxNumBlocksInChainTest = 10000 // should be smaller than 9999999
) )
func makeCorrectTransitionSequenceWithRandomParameters() testFields { func makeCorrectTransitionSequenceWithRandomParameters() testFields {


Loading…
Cancel
Save