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

fix(bitswap): increase timeout to ensure hole punching completes #651

Merged
merged 4 commits into from
Aug 6, 2024

Conversation

2color
Copy link
Member

@2color 2color commented Aug 5, 2024

What's in this PR

This PR increases the Bitswap connection timeout from 5 seconds to 10 seconds. This is based on testing that shows that when one of the peers is behind NAT and holepunching is necessary, it can take a little bit over 5 seconds only for hole punching to succeed.

Hole punching slowness will be handled independently in libp2p/go-libp2p#2898.

This issue aims to prevent bitswap connection timeouts that would otherwise succeed, if given a higher connection timeout. Increasing the timeout appears to be an effective workaround based on some testing.

Based on https://github.com/ipfs/go-bitswap/pull/477/files, it appears that the 5 second timeout was an arbitrary starting that was picked in 2021, prior to which there was no time out. Here's the source of the suggestion of a 5 second timeout.

@2color 2color requested a review from a team as a code owner August 5, 2024 13:57

This comment was marked as off-topic.

@ipfs ipfs deleted a comment from welcome bot Aug 5, 2024
bitswap/network/ipfs_impl.go Outdated Show resolved Hide resolved
@lidel
Copy link
Member

lidel commented Aug 6, 2024

Triage note:

@lidel lidel self-assigned this Aug 6, 2024
connectionTimeout here is not necessary since defaultNewStreamTimeout
was introduced upstream in libp2p/go-libp2p#2907
@lidel lidel changed the title fix: increase bitswap connection timeout fix(bitswap): increase connection timeout Aug 6, 2024
@lidel lidel changed the title fix(bitswap): increase connection timeout fix(bitswap): increase timeout to ensure hole punching completes Aug 6, 2024
@lidel lidel mentioned this pull request Aug 6, 2024
32 tasks
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some spelunking we realized this timeout is no longer necessary, refactored this PR to reflect that. LGTM.

go-libp2p now has implicit ones for both Dial and NewStream:
https://github.com/libp2p/go-libp2p/blob/v0.36.1/p2p/net/swarm/swarm.go#L28-L36

(With libp2p/go-libp2p#2907 being the default in go-libp2p 0.36, we have implicit timeout of 15s on stream as well)

@lidel lidel merged commit 831b83e into main Aug 6, 2024
17 checks passed
@lidel lidel deleted the increase-timeout branch August 6, 2024 19:20
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

Successfully merging this pull request may close these issues.

2 participants