filecoin-project / go-f3

Golang implementation of Fast Finality in Filecoin (F3)
Apache License 2.0
8 stars 6 forks source link

Simplify participant locking and expose current GPBFT progress #663

Closed masih closed 6 days ago

masih commented 6 days ago

The host implementation needs to know the progress of the current instance for certificate storage and catch up purposes. As a result the current instance must be safe to read from multiple goroutines. This was achieved by a dedicated mutex that synchronised all access to the current instanceID.

Separately, validation logic requires to know how far the current instance has progressed in order to effectively validate incoming messages.

The changes here simplify the locking by unifying the logic for checking the progress of an instance: both validator and host can now get the latest progress from the participant that is safe for concurrent use. This is achieved by moving the progress observer mechanism out of validator and into the participant, while introducing the concept of gpbft.Progress a function that returns the current instance, round and phase.

As part of this change, Lotus integration can now get the current round and phase as well as current instance, which is useful for self equivocation checking as well as debugging purposes.

Fixes #658 Relates to #599

codecov[bot] commented 6 days ago

Codecov Report

Attention: Patch coverage is 94.73684% with 3 lines in your changes missing coverage. Please review.

Project coverage is 76.19%. Comparing base (12c0356) to head (e30c8aa). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
host.go 50.00% 2 Missing :warning:
gpbft/participant.go 95.65% 0 Missing and 1 partial :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663/graphs/tree.svg?width=650&height=150&src=pr&token=6uD131t7gs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project)](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project) ```diff @@ Coverage Diff @@ ## main #663 +/- ## ========================================== - Coverage 76.43% 76.19% -0.25% ========================================== Files 64 65 +1 Lines 5394 5393 -1 ========================================== - Hits 4123 4109 -14 - Misses 873 881 +8 - Partials 398 403 +5 ``` | [Files with missing lines](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project) | Coverage Δ | | |---|---|---| | [gpbft/gpbft.go](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?src=pr&el=tree&filepath=gpbft%2Fgpbft.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-Z3BiZnQvZ3BiZnQuZ28=) | `88.16% <100.00%> (-0.02%)` | :arrow_down: | | [gpbft/progress.go](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?src=pr&el=tree&filepath=gpbft%2Fprogress.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-Z3BiZnQvcHJvZ3Jlc3MuZ28=) | `100.00% <100.00%> (ø)` | | | [gpbft/validator.go](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?src=pr&el=tree&filepath=gpbft%2Fvalidator.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-Z3BiZnQvdmFsaWRhdG9yLmdv) | `90.72% <100.00%> (-0.53%)` | :arrow_down: | | [gpbft/participant.go](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?src=pr&el=tree&filepath=gpbft%2Fparticipant.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-Z3BiZnQvcGFydGljaXBhbnQuZ28=) | `86.20% <95.65%> (+0.73%)` | :arrow_up: | | [host.go](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663?src=pr&el=tree&filepath=host.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project#diff-aG9zdC5nbw==) | `68.24% <50.00%> (+0.15%)` | :arrow_up: | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/filecoin-project/go-f3/pull/663/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=filecoin-project)