-
Notifications
You must be signed in to change notification settings - Fork 474
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
p2p: refactor gossipsub to validation and handling #5976
p2p: refactor gossipsub to validation and handling #5976
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/p2p #5976 +/- ##
===============================================
- Coverage 55.97% 55.24% -0.74%
===============================================
Files 495 495
Lines 68896 69009 +113
===============================================
- Hits 38562 38121 -441
- Misses 27708 28273 +565
+ Partials 2626 2615 -11 ☔ View full report in Codecov by Sentry. |
This reverts commit 439e89e.
244694f
to
2b4e304
Compare
@@ -24,32 +24,55 @@ import ( | |||
// Multiplexer is a message handler that sorts incoming messages by Tag and passes | |||
// them along to the relevant message handler for that type of message. | |||
type Multiplexer struct { | |||
msgHandlers atomic.Value // stores map[Tag]MessageHandler, an immutable map. | |||
msgHandlers atomic.Value // stores map[Tag]MessageHandler, an immutable map. | |||
msgProcessors atomic.Value // stores map[Tag]MessageProcessor, an immutable map. |
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.
It's probably worth updating network/multiplexer_test.go
as well
tools cross-check fails but this is OK since the entire p2p branch needs updates from |
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.
LGTM! I added a few suggestions for a little additional documentation but I like it, I can't imagine chopping up processor/validator would have any impact on performance for the wsNetwork?
var isDup bool | ||
if handler.msgCache != nil { | ||
// check for duplicate messages | ||
// this helps against relaying duplicates | ||
if msgKey, isDup = handler.msgCache.CheckAndPut(rawmsg.Data); isDup { | ||
if msgKey, isDup = handler.msgCache.CheckAndPut(data); isDup { |
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.
gossipsub has its own duplicate checker too, depending on the message hash function implementation? I wonder how often you will hit this when gossipsub is in front of it
Summary
MessageProcessor
similar toMessageHandler
but working in two stages: validate and handleprocessIncomingTxn
txhandler method into two validate + handleTest Plan