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
531 stars 176 forks source link

Optimize consensus follower to avoid lagging 1 view when observing finality #4154

Closed AlexHentschel closed 1 year ago

AlexHentschel commented 1 year ago

As part of updating the consensus follower to Jolteon, we front-loaded the all validity checks into the compliance layer. The consensus follower now only stores valid blocks on disk. Furthermore, it only forwards blocks to its local HotStuff follower, whose validity has been confirmed. The follower does not validate blocks in full. Instead, it mainly validates QCs (and a few other details of the block header) and considers blocks B valid only if there is a QC for B known. This means that the consensus follower waits for a child block, before it processes B.

Details:

Definition of done:

On the happy path, we desire:

AlexHentschel commented 1 year ago

Furthermore, I would suggest to remove the FollowerLogic interface and implementation and have the FollowerLoop directly interact with Forks.

Thereby, we would be removing the validation step from the HotStuffFollower, which I think is fine, as correctness of the proposals is already guaranteed by the follower's compliance layer.

jordanschalm commented 1 year ago

The follower's compliance layer forwards certified blocks to Forks

Forks is not thread-safe. Currently only the single-threaded event loop forwards data to Forks for processing. If the compliance layer also forwards certified blocks to Forks, then we will need data synchronization. Alternatively the compliance layer could forward to the event loop first, which in turn would forward to Forks.

Flagging in case this hasn't come up yet -- did you have a preference for how to approach this?

AlexHentschel commented 1 year ago

Re Jordan's comment: Basically, my intention is that Forks can work within the consensus follower as well as the consensus participant.

[Update] issue description to reduce ambiguity

AlexHentschel commented 1 year ago

last part implemented by https://github.com/onflow/flow-go/pull/4234