Skip to content
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

Limit IWANTs sent for a single messageID #402

Open
Nashatyrev opened this issue Dec 30, 2024 · 0 comments
Open

Limit IWANTs sent for a single messageID #402

Nashatyrev opened this issue Dec 30, 2024 · 0 comments

Comments

@Nashatyrev
Copy link
Collaborator

Nashatyrev commented Dec 30, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant