-
Notifications
You must be signed in to change notification settings - Fork 179
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 Pusher Engine with updated interface #6780
Changes from 5 commits
1fc3a19
9e37f14
d157f48
eacc992
f9e16bf
42b2331
f58ccaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package collection | ||
|
||
import ( | ||
"github.com/onflow/flow-go/model/flow" | ||
) | ||
|
||
// GuaranteedCollectionPublisher defines the interface to send collection guarantees | ||
// from a collection node to consensus nodes. Collection guarantees are broadcast on a best-effort basis, | ||
// and it is acceptable to discard some guarantees (especially those that are out of date). | ||
// Implementation is non-blocking and concurrency safe. | ||
type GuaranteedCollectionPublisher interface { | ||
// SubmitCollectionGuarantee adds a guarantee to an internal queue | ||
// to be published to consensus nodes. | ||
SubmitCollectionGuarantee(guarantee *flow.CollectionGuarantee) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,7 +13,6 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||
"github.com/onflow/flow-go/engine/collection/pusher" | ||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/onflow/flow-go/model/flow" | ||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/onflow/flow-go/model/flow/filter" | ||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/onflow/flow-go/model/messages" | ||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/onflow/flow-go/module/irrecoverable" | ||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/onflow/flow-go/module/metrics" | ||||||||||||||||||||||||||||||||||||||||||||||||
module "github.com/onflow/flow-go/module/mock" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -97,11 +96,7 @@ func (suite *Suite) TestSubmitCollectionGuarantee() { | |||||||||||||||||||||||||||||||||||||||||||||||
suite.conduit.On("Publish", guarantee, consensus[0].NodeID). | ||||||||||||||||||||||||||||||||||||||||||||||||
Run(func(_ mock.Arguments) { close(done) }).Return(nil).Once() | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
msg := &messages.SubmitCollectionGuarantee{ | ||||||||||||||||||||||||||||||||||||||||||||||||
Guarantee: *guarantee, | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
err := suite.engine.ProcessLocal(msg) | ||||||||||||||||||||||||||||||||||||||||||||||||
suite.Require().Nil(err) | ||||||||||||||||||||||||||||||||||||||||||||||||
suite.engine.SubmitCollectionGuarantee(guarantee) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
unittest.RequireCloseBefore(suite.T(), done, time.Second, "message not sent") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -116,10 +111,7 @@ func (suite *Suite) TestSubmitCollectionGuaranteeNonLocal() { | |||||||||||||||||||||||||||||||||||||||||||||||
// send from a non-allowed role | ||||||||||||||||||||||||||||||||||||||||||||||||
sender := suite.identities.Filter(filter.HasRole[flow.Identity](flow.RoleVerification))[0] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
msg := &messages.SubmitCollectionGuarantee{ | ||||||||||||||||||||||||||||||||||||||||||||||||
Guarantee: *guarantee, | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
err := suite.engine.Process(channels.PushGuarantees, sender.NodeID, msg) | ||||||||||||||||||||||||||||||||||||||||||||||||
err := suite.engine.Process(channels.PushGuarantees, sender.NodeID, guarantee) | ||||||||||||||||||||||||||||||||||||||||||||||||
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. unfortunately, with the change I suggested above, we would hide the case where Lines 52 to 58 in 42b2331
Trying to adjust the test so we verify that
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
suite.Require().Error(err) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
suite.conduit.AssertNumberOfCalls(suite.T(), "Multicast", 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
This suggestion is largely about mildly adjusting the framing of
Process
to align with the protocol. Jordan had a helpful explanation in his comment on the prior PR, which might be a useful reference here.Here’s how I’d frame the context:
flow-go/engine/collection/pusher/engine.go
Line 173 in 42b2331
pusher.Engine
(only running within honest Collector nodes), we would receive such messages via thechannels.PushGuarantees
networking channel. It’s important to note that the networking layer operates as a low-level tool and doesn’t understand the higher-level protocol logic. Its role is simply to relay messages, even if they’re outside the protocol rules (there are only very very basic checks in the networking layer, as briefly explained in this notion doc).However, there’s an opportunity to refine this behavior. Returning an error here informs the networking layer of an issue, but since the networking layer doesn’t understand the meaning of those errors, it’s essentially acting as a "glorified logger." Instead, I think it would be cleaner and more maintainable for the
pusher.Engine
, which has the detailed protocol knowledge, to handle this edge case directly. For example:flow-go/utils/logging/consts.go
Lines 4 to 6 in 42b2331