onflow / flow-go

A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps, and the digital assets that power them.
GNU Affero General Public License v3.0
534 stars 179 forks source link

Use Safety Rules for signing block proposals #6389

Open AlexHentschel opened 3 months ago

AlexHentschel commented 3 months ago

Copied issue from proprietary repo: https://github.com/dapperlabs/flow-go/issues/6900


Context

HotStuff's EventHandler uses the BlockProducer.MakeBlockProposal to generate block proposals. At the moment, the BlockProducer has its own independent logic for signing the proposals it produces. This is problematic for the following reasons:

ToDo

With a little more work, we can utilize the EventHandler's SafetyRules to generate the block signature. There is a bit of subtly around protecting SafetyRules from potentially concurrent access, because we are handing it to external code.

Suggestion

AlexHentschel commented 3 months ago

This tech debt is now creating additional complexity and need to resort to formal arguments to cover additional edge cases, as we want to optimize the consensus code for Cruise Control (👉 PR #6379).

importance

The following is a foundational theorem to prove the safety of HotStuff. Beyond HotStuff, we utilize this Theorem in various places outside of consensus to simplify our implementation (e.g. queuing pending blocks for execution, verification, sealing, etc).

Theorem: For each view, there can be at most 1 certified block.

The overall safety argument for the current implementation (already quite involved with [1], [2], [3] ) now becomes even longer as we need to add Cruise Control into the consideration (PR #6379)