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

[Collection] Compliance engine message queues #1270

Merged
merged 14 commits into from Sep 14, 2021

Conversation

durkmurder
Copy link
Member

https://github.com/dapperlabs/flow-go/issues/5807

Context

This PR implements message queues for collection compliance engine(former proposal engine). Design and implementation is inspired by consensus compliance engine, basically same engine is used with needed modifications for collection clusters.

Previously we named it as proposal engine to follow naming of consensus engines I have renamed it to compliance engine

Copy link
Member

@zhangchiqing zhangchiqing left a comment

Choose a reason for hiding this comment

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

Looks good

@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2021

Codecov Report

Merging #1270 (208c3f0) into master (386f157) will increase coverage by 0.22%.
The diff coverage is 74.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1270      +/-   ##
==========================================
+ Coverage   54.58%   54.81%   +0.22%     
==========================================
  Files         500      501       +1     
  Lines       31659    31721      +62     
==========================================
+ Hits        17281    17387     +106     
+ Misses      12023    11970      -53     
- Partials     2355     2364       +9     
Flag Coverage Δ
unittests 54.81% <74.54%> (+0.22%) ⬆️

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

Impacted Files Coverage Δ
engine/consensus/compliance/core.go 80.86% <ø> (ø)
engine/collection/compliance/engine.go 70.16% <70.16%> (ø)
engine/consensus/compliance/engine.go 72.41% <77.77%> (-0.21%) ⬇️
engine/collection/compliance/core.go 78.62% <78.62%> (ø)
consensus/hotstuff/event_loop.go 37.83% <100.00%> (+5.48%) ⬆️
...sus/approvals/assignment_collector_statemachine.go 45.19% <0.00%> (-6.74%) ⬇️
...ngine/common/synchronization/finalized_snapshot.go 68.75% <0.00%> (-4.17%) ⬇️
engine/collection/synchronization/engine.go 62.90% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 386f157...208c3f0. Read the comment docs.

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.

LGTM.

What really bothers me is the amount of code duplication between the consensus and the collector compliance engine. If golang only had generics ... 😠.
I guess that is technical debt we can address once go 1.18 comes around.

P.S. took the liberty up slightly update some goDoc (commit 26bb30f). No functional changes

@@ -20,6 +21,7 @@ type EventLoop struct {
proposals chan *model.Proposal
votes chan *model.Vote

lm *lifecycle.LifecycleManager
unit *engine.Unit // lock for preventing concurrent state transitions
Copy link
Member

Choose a reason for hiding this comment

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

I feel like LifecycleManager and Unit supply largely redundant functionality here (?)
The only component from unit that we utilize here seems to be the WaitGroup:

wg sync.WaitGroup // tracks in-progress functions

Is there any reason to not replace unit by a WaitGroup. Would remove some of the clutter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really hope to see one day LifecycleManager fused with Unit so that's why I would leave it as it in and just remove unit completely then.

engine/collection/compliance/engine.go Show resolved Hide resolved
@AlexHentschel
Copy link
Member

BTW, I think we can actually have a single implementation of the compliance.Engine and compliance.Core for both collectors and consensus nodes:

  • Engine and Core are agnostic about the payload type
  • The only thing that cares about the payload is the MutableState implementation, which we anyway already inject into Core

My thoughts are that we could:

  • introduce an interface like
    type AbstractBlock interface {
      Header() *flow.Header
    }
    and a similar abstraction for votes
  • introduce a config object that holds all the metric identifiers and such
  • thereby, we would also only need one implementation of PendingBlockBuffer / PendingClusterBlockBuffer

While it seems doable on a high-level, there are probably a lot of details that would need to be aligned. Not sure if it is worth the effort at this time ...

@durkmurder
Copy link
Member Author

BTW, I think we can actually have a single implementation of the compliance.Engine and compliance.Core for both collectors and consensus nodes:

  • Engine and Core are agnostic about the payload type
  • The only thing that cares about the payload is the MutableState implementation, which we anyway already inject into Core

My thoughts are that we could:

  • introduce an interface like

    type AbstractBlock interface {
      Header() *flow.Header
    }

    and a similar abstraction for votes

  • introduce a config object that holds all the metric identifiers and such

  • thereby, we would also only need one implementation of PendingBlockBuffer / PendingClusterBlockBuffer

While it seems doable on a high-level, there are probably a lot of details that would need to be aligned. Not sure if it is worth the effort at this time ...

I was trying to do the same for sync engine and in the end it appears that it's a good idea for later refactoring especially with go 1.18 but for time being it's not a priority. So I would indeed leave it for later.

@durkmurder
Copy link
Member Author

bors merge

bors bot added a commit that referenced this pull request Sep 14, 2021
1270: [Collection] Compliance engine message queues r=durkmurder a=durkmurder

https://github.com/dapperlabs/flow-go/issues/5807

### Context

This PR implements message queues for collection compliance engine(former proposal engine). Design and implementation is inspired by consensus compliance engine, basically same engine is used with needed modifications for collection clusters. 

Previously we named it as _proposal_ engine to follow naming of consensus engines I have renamed it to _compliance_ engine

Co-authored-by: Yurii Oleksyshyn <yuraolex@gmail.com>
Co-authored-by: Yura <yuraolex@gmail.com>
Co-authored-by: Alexander Hentschel <alex.hentschel@axiomzen.co>
@bors
Copy link
Contributor

bors bot commented Sep 14, 2021

Build failed:

@durkmurder
Copy link
Member Author

bors merge

@bors
Copy link
Contributor

bors bot commented Sep 14, 2021

@bors bors bot merged commit affedc8 into master Sep 14, 2021
@bors bors bot deleted the yurii/5807-collection-proposal-engine-refactoring branch September 14, 2021 08:42
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.

None yet

7 participants