fix(p2p): add per-peer timeout to performRequest#376
Merged
walldiss merged 1 commit intocelestiaorg:mainfrom Mar 6, 2026
Merged
fix(p2p): add per-peer timeout to performRequest#376walldiss merged 1 commit intocelestiaorg:mainfrom
walldiss merged 1 commit intocelestiaorg:mainfrom
Conversation
performRequest iterates trusted peers sequentially but previously inherited the full parent context deadline for each request. A single slow or unresponsive peer could consume the entire remaining deadline, causing GetByHeight (and Get) to time out even when other trusted peers are healthy. Wrap each ex.request() call with context.WithTimeout using the existing Params.RequestTimeout (default 8s), matching how session.doRequest() already applies per-peer timeouts for range requests. This ensures a slow peer is skipped after RequestTimeout and the next peer is tried immediately.
017efa6 to
cce003f
Compare
Wondertan
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
performRequest()iterates trusted peers sequentially but previously inherited the full parent context deadline for eachex.request()call. A single slow or unresponsive peer could consume the entire remaining deadline, causingGetByHeight/Getto time out even when other trusted peers are healthy.ex.request()call withcontext.WithTimeout(ctx, ex.Params.RequestTimeout)(default 8s), matching howsession.doRequest()already applies per-peer timeouts for range requests.TestExchange_PerformRequest_PeerTimeoutto verify a slow first peer is skipped and the request succeeds via the second peer.Context
Mocha light nodes fail to start within the 20s
StartupTimeoutwhen a bootstrap peer is slow (e.g., returns "not found" after 14s).Head()returns quickly, but the subsequentGetByHeight()call blocks on the slow peer for the full remaining context deadline sinceperformRequesthad no per-peer timeout.With this fix, a slow peer is abandoned after
RequestTimeout(8s) and the next trusted peer is tried immediately.