-
Notifications
You must be signed in to change notification settings - Fork 177
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
[Consensus] Approval Processing Core -> Sealing Core #736
Merged
Merged
Changes from 56 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
40dc39a
Added basic engine implementation for approvals engine
durkmurder 6c16fef
Updated test conditions
durkmurder 19b60c5
Replacing sealing core with new implementation
durkmurder 442a1ec
Fixed approval processing tests. Partially fixed old tests
durkmurder 9e1c565
Removed receipt processing from sealing engine
durkmurder 93e9355
Updated initialization
durkmurder d5839db
Updated tests
durkmurder ff3105a
Updated tests. Cleanup
durkmurder c80cfa6
Merge branch 'master' of https://github.com/onflow/flow-go into yurii…
durkmurder a3bf7b9
Refactored of consensus engines. Added skeleton for matching engine
durkmurder 7039b25
Added logs. Updated godoc
durkmurder ea9b290
Implemented matching engine and core
durkmurder 4a0d08f
Updated defualt config
durkmurder 881adff
Removed modules that aren't used anymore
durkmurder 4d12dd0
Added matching engine tests. Updated mocks. Tests refactoring
durkmurder 87cfd3b
Added finalization distributor for consensus node engines. Updated te…
durkmurder 397ffe3
Merge branch 'master' of https://github.com/onflow/flow-go into yurii…
durkmurder 003f921
Fixed tests. Removed leftovers
durkmurder 0a5a7c5
Linted
durkmurder c4c43d3
Removed more legacy files
durkmurder b799719
• separated Notifier as a separate component from MessageHandler;
cab8ce5
consistent naming for callback `OnFinalizedBlock`
e8bbea8
• also named implementation of callback `OnFinalizedBlock` accordingl…
58fcbfa
minor code-compactification
747ef63
• cleanup of all mentions of ResultApprovalProcessor (as it was previ…
f18aee1
micro godoc revision
1e579e5
extended goDoc
a7ca45d
removed field `requiredApprovalsForSealConstruction` from `ApprovalCo…
ab0ebbe
Merge pull request #740 from onflow/alex/5417-approval-processing-eng…
durkmurder 04ba8dc
Apply suggestions from PR
durkmurder 65a1d36
Added back sealing tracker
durkmurder 688a1bf
Added tracker of sealing state when requesting missing approvals
durkmurder b9024c7
Fixed sealing engine initialization
durkmurder a1eb253
Fixed unittests
durkmurder d828bc8
Updated tracing for matching & sealing engines
durkmurder 9ccd70e
Updated how results are feed to sealing engine. Updated hotstuff even…
durkmurder 691e1cd
Updated sealing engine with new implementation of message handler
durkmurder 056eddd
Updated godoc
durkmurder a1208aa
Added workaround for handling genesis block. Updated tests
durkmurder e929872
Apply suggestions from PR comments
durkmurder c619f79
Added logic for repopulating collectors tree. Added tests
durkmurder 21eaaf7
Apply suggestions from PR review
durkmurder 4796d6f
Implemented monotonous counter for sealing.Core. Replaced atomic oper…
durkmurder 23019b0
Update core.go
durkmurder 71b6ea4
Updated assignment collector tree to finalize forks over multiple blocks
durkmurder 715005c
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 4abd541
Updated how processable incorporated results are handled
durkmurder dae4cc7
Apply suggestions from PR review
durkmurder 5f0e650
Merge branch 'master' of https://github.com/onflow/flow-go into yurii…
durkmurder f087e3d
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 0320624
Implemented traversing of valid descendants when repopulating results…
durkmurder 3eb8166
updated goDoc of notifier.
63d0eac
moved `SignatureCollector` from package flow to package `approvals`
49d3c2f
updated imports for tests after moving SignatureCollector
dc31871
removed originID from matching.Core.ProcessReceipt
275f047
minor revision of sealing.Core
b62f6fd
Merge pull request #769 from onflow/alex/5417-approval-processing-eng…
durkmurder db2bb4e
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 64aae7f
Fixed tests
durkmurder 997b9ff
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 7e5f2ed
Added back check for originID
durkmurder d6a3f7e
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 684d630
Apply comments from PR review
durkmurder ccba22c
• minor goDoc revisions
bc3e532
• minor revisions for code comments
40edcae
AssignmentCollector now checks _first_ the cache before doing expensi…
ccb19d3
• ApprovalCollector: added logic for sealing right away if no approva…
2d5f120
Merge pull request #774 from onflow/alex/5417-approval-processing-eng…
durkmurder b6066d2
Added extra logs
durkmurder 4f0ee34
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 8b26d8e
Merge branch 'master' of https://github.com/onflow/flow-go into yurii…
durkmurder db2a08c
Updated logs
durkmurder 5f9808e
Merge branch 'yurii/5417-approval-processing-engine' of https://githu…
durkmurder 102d919
attempt 1 to fix test
0c3bf01
updated integration test to only seal if two receipts are known
0c808a5
updated imports
c5a6b09
removed sleep in test to see, if waiting for two receipts before seal…
1a7da01
Merge pull request #780 from onflow/alex/attempting_integration_test_fix
durkmurder 7efd30b
Apply suggestions from code review
durkmurder e39ec83
Merge pull request #765 from onflow/yurii/5216-repopulate-assignment-…
durkmurder 1c8a645
Linted. Added check for 2 receipts before sealing
durkmurder 64914fa
Added fallback solution for sealing recovery. Updated tests
durkmurder 498c741
Merge branch 'master' of https://github.com/onflow/flow-go into yurii…
durkmurder 70cd038
Updated godoc
durkmurder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
consensus/hotstuff/notifications/pubsub/finalization_distributor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package pubsub | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/onflow/flow-go/consensus/hotstuff/model" | ||
"github.com/onflow/flow-go/model/flow" | ||
) | ||
|
||
type OnBlockFinalizedConsumer = func(finalizedBlockID flow.Identifier) | ||
type OnBlockIncorporatedConsumer = func(incorporatedBlockID flow.Identifier) | ||
|
||
// FinalizationDistributor subscribes for finalization events from hotstuff and distributes it to subscribers | ||
type FinalizationDistributor struct { | ||
blockFinalizedConsumers []OnBlockFinalizedConsumer | ||
blockIncorporatedConsumers []OnBlockIncorporatedConsumer | ||
lock sync.RWMutex | ||
} | ||
|
||
func NewFinalizationDistributor() *FinalizationDistributor { | ||
return &FinalizationDistributor{ | ||
blockFinalizedConsumers: make([]OnBlockFinalizedConsumer, 0), | ||
blockIncorporatedConsumers: make([]OnBlockIncorporatedConsumer, 0), | ||
lock: sync.RWMutex{}, | ||
} | ||
} | ||
|
||
func (p *FinalizationDistributor) AddOnBlockFinalizedConsumer(consumer OnBlockFinalizedConsumer) { | ||
p.lock.Lock() | ||
defer p.lock.Unlock() | ||
p.blockFinalizedConsumers = append(p.blockFinalizedConsumers, consumer) | ||
} | ||
func (p *FinalizationDistributor) AddOnBlockIncorporatedConsumer(consumer OnBlockIncorporatedConsumer) { | ||
p.lock.Lock() | ||
defer p.lock.Unlock() | ||
p.blockIncorporatedConsumers = append(p.blockIncorporatedConsumers, consumer) | ||
} | ||
|
||
func (p *FinalizationDistributor) OnEventProcessed() {} | ||
|
||
func (p *FinalizationDistributor) OnBlockIncorporated(block *model.Block) { | ||
p.lock.RLock() | ||
defer p.lock.RUnlock() | ||
for _, consumer := range p.blockIncorporatedConsumers { | ||
consumer(block.BlockID) | ||
} | ||
} | ||
|
||
func (p *FinalizationDistributor) OnFinalizedBlock(block *model.Block) { | ||
p.lock.RLock() | ||
defer p.lock.RUnlock() | ||
for _, consumer := range p.blockFinalizedConsumers { | ||
consumer(block.BlockID) | ||
} | ||
} | ||
|
||
func (p *FinalizationDistributor) OnDoubleProposeDetected(*model.Block, *model.Block) {} | ||
|
||
func (p *FinalizationDistributor) OnReceiveVote(uint64, *model.Vote) {} | ||
|
||
func (p *FinalizationDistributor) OnReceiveProposal(uint64, *model.Proposal) {} | ||
|
||
func (p *FinalizationDistributor) OnEnteringView(uint64, flow.Identifier) {} | ||
|
||
func (p *FinalizationDistributor) OnQcTriggeredViewChange(*flow.QuorumCertificate, uint64) {} | ||
|
||
func (p *FinalizationDistributor) OnProposingBlock(*model.Proposal) {} | ||
|
||
func (p *FinalizationDistributor) OnVoting(*model.Vote) {} | ||
|
||
func (p *FinalizationDistributor) OnQcConstructedFromVotes(*flow.QuorumCertificate) {} | ||
|
||
func (p *FinalizationDistributor) OnStartingTimeout(*model.TimerInfo) {} | ||
|
||
func (p *FinalizationDistributor) OnReachedTimeout(*model.TimerInfo) {} | ||
|
||
func (p *FinalizationDistributor) OnQcIncorporated(*flow.QuorumCertificate) {} | ||
|
||
func (p *FinalizationDistributor) OnForkChoiceGenerated(uint64, *flow.QuorumCertificate) {} | ||
|
||
func (p *FinalizationDistributor) OnDoubleVotingDetected(*model.Vote, *model.Vote) {} | ||
|
||
func (p *FinalizationDistributor) OnInvalidVoteDetected(*model.Vote) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering how this code will behave, when
requiredApprovalsForSealConstruction = 0
. In this case, sealing should proceed, even if all verifiers are offline.My theory on how the current implementation will behave is:
the only code paths reaching
ApprovalCollector.SealResult()
are:flow-go/engine/consensus/approvals/assignment_collector.go
Lines 139 to 143 in 7e5f2ed
flow-go/engine/consensus/approvals/approval_collector.go
Lines 89 to 110 in 7e5f2ed
Hence, if all verifiers are offline, we will not generate seals until the result is emergency sealed, even if
requiredApprovalsForSealConstruction = 0
.I think the better behaviour would be produce a candidate seal right away, as soon as we construct the
ApprovalCollector
This is already implemented in PR #774