Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BFT] Reporting basic consensus protocol violations #4174

Merged
merged 49 commits into from
May 12, 2023

Conversation

durkmurder
Copy link
Member

@durkmurder durkmurder commented Apr 6, 2023

Context

In order to address reporting of protocol violations this PR refactors existing code and introduces new interface for reporting basic consensus protocol violations that can and have to be detected by all node types.

As part of this PR:

  • Updated structuring of our pub-sub consumers. Now protocol violations are moved to a separate interface as well as finalization events, introduced FollowerConsumer which combines separate interfaces usable by consensus follower(FinalizationConsumer and BaseProtocolViolationConsumer).
  • Updated distributors to reflect new changes
  • Updated tests and documentation
  • Connected slashing violations to a specific consumer that for now logs them
  • Updated all of compliance engines(follower, consensus, collection) to report invalid blocks if they were detected during processing

…d structuring of consensus related consumers. Fixed tests and dependant code
@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2023

Codecov Report

Merging #4174 (bbc49b8) into master (18a786a) will decrease coverage by 0.03%.
The diff coverage is 70.29%.

@@            Coverage Diff             @@
##           master    #4174      +/-   ##
==========================================
- Coverage   53.87%   53.84%   -0.03%     
==========================================
  Files         869      869              
  Lines       80465    80453      -12     
==========================================
- Hits        43349    43321      -28     
- Misses      33704    33723      +19     
+ Partials     3412     3409       -3     
Flag Coverage Δ
unittests 53.84% <70.29%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/execution_builder.go 0.00% <0.00%> (ø)
cmd/verification_builder.go 0.00% <0.00%> (ø)
consensus/aggregators.go 0.00% <0.00%> (ø)
consensus/config.go 0.00% <ø> (ø)
consensus/follower.go 35.71% <ø> (ø)
consensus/hotstuff/eventloop/event_loop.go 73.39% <0.00%> (-0.74%) ⬇️
...s/hotstuff/timeoutaggregator/timeout_aggregator.go 70.31% <ø> (-0.24%) ⬇️
consensus/hotstuff/timeoutcollector/factory.go 0.00% <0.00%> (ø)
consensus/hotstuff/votecollector/statemachine.go 77.35% <ø> (ø)
engine/access/ingestion/engine.go 60.23% <ø> (+0.23%) ⬆️
... and 11 more

... and 6 files with indirect coverage changes

consensus/hotstuff/consumer.go Show resolved Hide resolved
consensus/hotstuff/consumer.go Outdated Show resolved Hide resolved
consensus/hotstuff/consumer.go Outdated Show resolved Hide resolved
consensus/hotstuff/notifications/pubsub/distributor.go Outdated Show resolved Hide resolved
consensus/hotstuff/consumer.go Outdated Show resolved Hide resolved
consensus/hotstuff/follower/follower.go Outdated Show resolved Hide resolved
consensus/hotstuff/notifications/noop_consumer.go Outdated Show resolved Hide resolved
state protocol.FollowerState,
follower module.HotStuffFollower,
validator hotstuff.Validator,
sync module.BlockRequester,
tracer module.Tracer,
) (*ComplianceCore, error) {
onEquivocation := func(block, otherBlock *flow.Block) {
finalizationConsumer.OnDoubleProposeDetected(model.BlockFromFlow(block.Header), model.BlockFromFlow(otherBlock.Header))
followerConsumer.OnDoubleProposeDetected(model.BlockFromFlow(block.Header), model.BlockFromFlow(otherBlock.Header))
Copy link
Member

@AlexHentschel AlexHentschel May 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I would appreciate the revision 🙇

The cache here is already very specific to the follower. We can always generalize it should want to use the cache somewhere else ... honestly though, I think the chances of us using the cache elsewhere is reasonably low in my opinion. Therefore, I think specificity to improve the code's clarity is in my opinion the way to go.

Copy link
Member

@AlexHentschel AlexHentschel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an amazing refactoring. It improves modularity and code clarity in sooo many ways. Thank you for your hard work with multiple iterations.

I think it woudl be great to include the two suggestions above still in this PR, as they are tiny changes:

@durkmurder
Copy link
Member Author

bors merge

@bors bors bot merged commit 0ae2b5a into master May 12, 2023
@bors bors bot deleted the yurii/4125-reporting-protocol-violations branch May 12, 2023 11:59
bors bot added a commit that referenced this pull request Jun 19, 2023
4350: [BFT] Reporting compliance engine protocol violations  r=durkmurder a=durkmurder

### Context

This is a follow-up PR which addresses outstanding comments in [previous](#4174) PR.
In compliance engine I have removed usage of `engine.InvalidInputError` since I wanted to consolidate slashing evidence reporting in one place(which works with `model.InvalidProposalError`) and `engine.InvalidInputError` was just adding another level of wrapping without real benefit. I've decided to replace it with `model.InvalidProposalError` which simplified error handling. 

Reference comments: [1](#4174 (comment)), [2](#4174 (comment)), [3](#4174 (comment))

Co-authored-by: Yurii Oleksyshyn <yuraolex@gmail.com>
Co-authored-by: Alexander Hentschel <alex.hentschel@axiomzen.co>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants