-
Notifications
You must be signed in to change notification settings - Fork 186
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
Abstracts GossipSubRouter interface #505
Abstracts GossipSubRouter interface #505
Conversation
* Enables non-atomic validation for peer scoring parameters (libp2p#499) * decouples topic scoring parameters * adds skiping atomic validation for topic parameters * cleans up * adds skip atomic validation to peer score threshold * adds skip atomic validation for peer parameters * adds test for non-atomic validation * adds tests for peer score * adds tests for peer score thresholds * refactors tests * chore: Update .github/workflows/stale.yml [skip ci] * adds with gossipsub tracker Co-authored-by: libp2p-mgmt-read-write[bot] <104492852+libp2p-mgmt-read-write[bot]@users.noreply.github.com>
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.
Well, day of reckoning.... sigh.
I am really not fond of reifying and exposing the internal types like that, but i can accept it if there is no other way around it.
Are you sure this isnt the case?
Cant we just reify the router type and offer an interface you can use, without changing the internal plumbing?
These abstractions are not public proof and thre is cost associated with having to go through the interface potentially (hundreds of) thousands times per second.
rt, err := DefaultGossipSubRouter(h) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create default gossipsub router: %w", err) | ||
} | ||
opts = append(opts, WithRawTracer(rt.tagTracer)) |
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.
We need to find a way to absorb this (the tag tracer) into the defaults, it is very error prone to require it to be explicitly instantaited.
|
||
gs.gossipTracer = newGossipTracer() | ||
gs.SetGossipTracer(newGossipTracer()) |
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 very ugly.
Problem Statement
Although in #503 we introduced injectible
PubSubRouter
into theGossipSub
, there are several places in the code that initializing aGossipSub
instance with a customizedPubSubRouter
is failing due to the strict type assertions, e.g., example-1, example-2, and example-3.Although the
rt
(router) attribute of theGossipSub
is deemed as aPubSubRouter
interface type, nevertheless through the initialization phase of theGossipSub
thert
attribute is strictly asserted as aGossipSubRouter
value type. This is a blocker for initializingGossipSub
with customized wrappers aroundGossipSubRouter
as it no longer is going to be aGossipSubRouter
strict value type. Hence the initialization fails with anpubsub router is not gossipsub
error.Contributions
In order to resolve the initialization failure due to the strict type assertions with
GossipSubRouter
this PR introduces the following changes:GossipPubSubRouter
interface type, and replaced strict type assertions with interface type assertions.GossipSubRouter
struct
type from those deal with thePubSub
.