-
Notifications
You must be signed in to change notification settings - Fork 76
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
[GossipSub 1.2] Add IDONTWANT support #374
Conversation
@@ -122,6 +122,7 @@ open class GossipRouter( | |||
private val iAsked = createLRUMap<PeerHandler, AtomicInteger>(MaxIAskedEntries) | |||
private val peerIHave = createLRUMap<PeerHandler, AtomicInteger>(MaxPeerIHaveEntries) | |||
private val iWantRequests = createLRUMap<Pair<PeerHandler, MessageId>, Long>(MaxIWantRequestsEntries) | |||
private val peerIDontWant = createLRUMap<PeerHandler, Pair<AtomicInteger, MutableSet<MessageId>>>(MaxPeerIDontWantEntries) |
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.
May we have an explicit structure for Pair<AtomicInteger, MutableSet<MessageId>>
for clarity?
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.
Added IDontWantCacheEntry
@@ -572,9 +590,14 @@ open class GossipRouter( | |||
enqueueIwant(peer, messageIds) | |||
} | |||
|
|||
private fun iDontWant(peer: PeerHandler, messageIds: List<MessageId>) { | |||
if (messageIds.isEmpty()) return | |||
enqueueIdontwant(peer, messageIds) |
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.
As I understand you are going to add the filtering here yet?
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.
Yes
@@ -572,9 +590,14 @@ open class GossipRouter( | |||
enqueueIwant(peer, messageIds) | |||
} | |||
|
|||
private fun iDontWant(peer: PeerHandler, messageIds: List<MessageId>) { | |||
if (messageIds.isEmpty()) return | |||
enqueueIdontwant(peer, messageIds) |
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 believe it's worth to add self rate limiting here as well ?
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.
Or probably it doesn't make much sense if this is not penalized
@@ -572,9 +590,14 @@ open class GossipRouter( | |||
enqueueIwant(peer, messageIds) | |||
} | |||
|
|||
private fun iDontWant(peer: PeerHandler, messageIds: List<MessageId>) { | |||
if (messageIds.isEmpty()) return | |||
enqueueIdontwant(peer, messageIds) |
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.
The thing of IDONTWANT
is that it needs to be flushed immediately to have the effect
@@ -459,6 +475,8 @@ open class GossipRouter( | |||
.whenTrue { notifyIWantTimeout(key.first, key.second) } | |||
} | |||
|
|||
peerIDontWant.clear() |
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 may clear remote IDONTWANT
which is still in effect here. We probably need some more sophisticated pruning mechanism here
/** | ||
* [maxIDontWantMessages] is the maximum number of IDONTWANT messages per heartbeat per peer | ||
*/ | ||
val maxIDontWantMessages: Int = 10 |
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 believe it's pretty low default which may mitigate the whole purpose of IDONTWANT
.
I would default it to maxIHaveLength * maxIHaveMessages
as proposed here
This one would be pretty high but any client may make it more conservative if needed.
With respect to Ethereum PeerDAS we may legally have up to 128 messages in a single slot for data column subnets
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
Just some neets. Unit tests are very appretiated as well.
01ea9a7
to
b4d6588
Compare
if (!this.protocol.supportsIDontWant()) return | ||
if (msg.protobufMessage.data.size() < params.iDontWantMinMessageSizeThreshold) return | ||
// we need to send IDONTWANT messages to mesh peers immediately in order for them to have an effect | ||
msg.topics.forEach { topic -> |
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.
If there are more than 1 topic wouldn't we send duplicate messageId
to same peers?
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.
Ah that is a good point, fixed in bbe42fa
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
TODO:
fixes #371