hyperledger-labs / Scorex

Scorex 2.0 Core
Apache License 2.0
544 stars 115 forks source link

fixing PeerConnectionHandler #396

Closed pragmaxim closed 3 years ago

pragmaxim commented 3 years ago

Problem: false positive peer bans, ie. peers are getting banned even though they communicate properly.

Explanation: Logic of this whole incoming data deserialization is as follows :

  1. ByteString is received
  2. if BS length is less than message length, keep on reading next BS as we have not enough bytes yet
  3. otherwise try to deserialize it into a message

The bug is caused by the fact that we are testing for magic and grabbing msgCode before checking the length, which means it fails (incorrectly) at time when not enough bytes is read to be able to deserialize it into a message.

Fix outcome: No bans happen now and more peers are connected, tested on Ergo.