nimiq / core-rs

Official Rust implementation of the Nimiq protocol
https://nimiq.com
Other
74 stars 10 forks source link

Multiple pBFT processes #34

Closed riptl closed 5 years ago

riptl commented 5 years ago

The current validator network can handle one concurrent pBFT process created after a proposal is received and its parent block is known. This leads to failures building a pBFT majority in some circumstances on high latency networks, specifically in two cases:

  1. Prepare/commit messages referencing an unknown proposal are dropped (if the proposal message gets delayed)
  2. Prepare/commit messages referencing a buffered proposal are dropped. Buffered proposals are intrinsically valid but the micro block chain leading up to them isn't complete yet.

To solve this, the validator network is rewritten to track multiple concurrent pBFT processes for different macro blocks, like so: Map<Blake2bHash, PbftState>.

The PbftState can exist in three settings:

At the end of each epoch, old valid and buffered proposals are pruned. Additionally, their macro block hashes are pushed to a blacklist LimitHashSet to prevent accidental re-creation of a PbftState by pBFT prepares/commits received after committing the macro block.