poanetwork / hbbft

An implementation of the paper "Honey Badger of BFT Protocols" in Rust. This is a modular library of consensus.
Other
357 stars 96 forks source link

Remove peers from sender queue after validator change. #341

Closed afck closed 5 years ago

afck commented 6 years ago

The sender queue already automatically adds peers based on StateChange::InProgress, so that joining nodes are guaranteed to receive their messages. It should also remove peers that have left the network:

SenderQueue probably needs a map that assigns to each peer the epoch after which they left, which would be updated in update_epoch. Then defer_messages would drop all messages from later epochs. When all outgoing messages to a removed peer have been sent, the peer can be removed from both maps.

vkomenda commented 6 years ago

Adding some more detail to this, I think removing peers can be done on ChangeState::Complete(Change::NodeChange(pub_keys)):

  1. by first adding those existing validators not in pub_keys to this new map, call it last_epochs;

  2. for each such validator, sending all messages to it up to its last epoch (this implies that the sending node has advanced past the last epoch), then removing that validator from both peer_epochs and last_epochs.