Limit IWANTs sent for a single messageID
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 366
- Forks
- 85
- Avg merge
- 2d 39m
- Merged PRs (30d)
- 6
Description
Summary
The GossipRouter should be smarter when handling IHAVEs from its peers: it should rate limit corresponding IWANT requests across all peers.
In the below test iwantsSent == 100, i.e. the router requested the same message from all peers
@Test
fun `router should limit IWANTs for the same message ID to different peers`() {
val test = ManyRoutersTest(mockRouterCount = 100)
test.connectAll()
test.gossipRouter.subscribe("topic1")
test.routers.forEach { it.router.subscribe("topic1") }
test.fuzz.timeController.addTime(2.seconds)
val unknownMessageId = "0000000000000000000000000000000000000000".toWBytes()
val partsQueue = DefaultGossipRpcPartsQueue(test.gossipRouter.params)
partsQueue.addIHave(unknownMessageId, "topic1")
val rpc = partsQueue.takeMerged().first()
test.mockRouters.forEach { it.sendToSingle(rpc) }
test.fuzz.timeController.addTime(1.seconds)
val iwantsSent = test.mockRouters.sumOf {
val iwants = it.inboundMessages.sumOf {
it.control.iwantList.count {
it.messageIDsList.contains(
unknownMessageId.toProtobuf()
)
}
}
assertTrue(iwants <= 1)
iwants
}
assertTrue(iwantsSent < 10)
}
Expected behavior
The router should request the same message just from few peers, but probably remember others and retry if initial requests fail
Actual behavior
Router just emits IWANT when handling IHAVE if a message ID is not known. Thus it may requests a lot in case when IHAVEs arrived in the same time period. It may have amplification effect with a larger messages: the more router sends IWANTs the slower it may receive the first message
Would you like to work on fixing this bug ?
Maybe
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the included ManyRoutersTest and its router should limit IWANTs for the same message ID to different peers test, then trace the GossipRouter path that handles IHAVE messages. Define and implement the cross-peer request limit and retry behavior, and verify that the test keeps IWANTs bounded while allowing failed requests to be retried.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100