-
Notifications
You must be signed in to change notification settings - Fork 180
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
Refactor Consensus Matching Engine: engine.Unit
-> ComponentManager
#6916
Open
tim-barry
wants to merge
4
commits into
master
Choose a base branch
from
tim/6854-consensus-matching-engine-componentmanager-refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+56
−98
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2dbeb84
Refactor Consensus Matching Engine: engine.Unit -> ComponentManager
tim-barry a012534
Refactor Consensus Matching Engine: network.Engine -> network.Message…
tim-barry 9398df3
remove duplicated code
tim-barry c7cba34
Refactor consensus matching engine: Log.Fatal -> ctx.Throw
tim-barry 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package matching | ||
|
||
import ( | ||
"context" | ||
"sync" | ||
"testing" | ||
"time" | ||
|
@@ -10,9 +11,9 @@ import ( | |
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/onflow/flow-go/consensus/hotstuff/model" | ||
"github.com/onflow/flow-go/engine" | ||
mockconsensus "github.com/onflow/flow-go/engine/consensus/mock" | ||
"github.com/onflow/flow-go/model/flow" | ||
"github.com/onflow/flow-go/module/irrecoverable" | ||
"github.com/onflow/flow-go/module/metrics" | ||
mockmodule "github.com/onflow/flow-go/module/mock" | ||
"github.com/onflow/flow-go/network/channels" | ||
|
@@ -57,6 +58,8 @@ func (s *MatchingEngineSuite) SetupTest() { | |
s.engine, err = NewEngine(unittest.Logger(), net, me, metrics, metrics, s.state, s.receipts, s.index, s.core) | ||
require.NoError(s.T(), err) | ||
|
||
ctx := irrecoverable.NewMockSignalerContext(s.T(), context.Background()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add teardown logic to make sure we are gracefully stopping the engine?
|
||
s.engine.Start(ctx) | ||
<-s.engine.Ready() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you wrap this in |
||
} | ||
|
||
|
@@ -135,15 +138,12 @@ func (s *MatchingEngineSuite) TestMultipleProcessingItems() { | |
s.core.AssertExpectations(s.T()) | ||
} | ||
|
||
// TestProcessUnsupportedMessageType tests that Process and ProcessLocal correctly handle a case where invalid message type | ||
// was submitted from network layer. | ||
// TestProcessUnsupportedMessageType tests that Process correctly handles a case where invalid message type | ||
// (byzantine message) was submitted from network layer. | ||
func (s *MatchingEngineSuite) TestProcessUnsupportedMessageType() { | ||
invalidEvent := uint64(42) | ||
err := s.engine.Process("ch", unittest.IdentifierFixture(), invalidEvent) | ||
// shouldn't result in error since byzantine inputs are expected | ||
require.NoError(s.T(), err) | ||
// in case of local processing error cannot be consumed since all inputs are trusted | ||
err = s.engine.ProcessLocal(invalidEvent) | ||
require.Error(s.T(), err) | ||
require.True(s.T(), engine.IsIncompatibleInputTypeError(err)) | ||
// Local processing happens only via HandleReceipt, which will log.Fatal on invalid input | ||
} |
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 think that ideally HandleReceipt would also be able to use
ctx.Throw
instead ofLog.Fatal
, but the function type is already dictated by being used as a HandleFunc by the Requester engine. Could be pushed to a future refactor of Requester Engine (since that one also still usesengine.Unit
).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 agree that this could be done as part of updating the requester engine. It would be great to have type-safe handler functions in the requester engine, which we could implement by making the requester engine and its Create/Handle functions generic.