Skip to content

fix(yamux): align default window with spec and reject invalid versions#2787

Merged
richard-ramos merged 2 commits into
masterfrom
fix/yamux-interop
Jul 8, 2026
Merged

fix(yamux): align default window with spec and reject invalid versions#2787
richard-ramos merged 2 commits into
masterfrom
fix/yamux-interop

Conversation

@richard-ramos

@richard-ramos richard-ramos commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Align yamux’s default stream window with the spec/reference 256 KiB value (256 * 1024) instead of decimal 256000, and reject headers whose version byte is not 0.

This matches the default initial credit and version handling used by go-yamux and rust-yamux. Existing yamux tests were updated to use YamuxDefaultWindowSize for window exhaustion cases and to expect YamuxError for non-zero-version headers.

Affected Areas

  • Protocol Logic
    Yamux stream-window defaults and header validation.

  • Other
    Yamux muxer/header tests and metrics bucket boundaries.

Impact on Library Users

No API changes.

Behavior changes:

  • fresh yamux streams now start with a 262144-byte default window;
  • malformed/non-zero-version yamux headers now fail as protocol errors instead of being accepted.

Risk Assessment

Low. This brings Nim yamux behavior in line with upstream Go and Rust implementations. The main compatibility impact is that peers sending non-zero yamux versions are now rejected, which is expected for /yamux/1.0.0.

References

@richard-ramos richard-ramos marked this pull request as ready for review July 8, 2026 15:25
@richard-ramos richard-ramos requested review from a team, gmelodie and vladopajic July 8, 2026 15:25
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.31%. Comparing base (057dfb3) to head (412c49c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2787      +/-   ##
==========================================
- Coverage   81.32%   81.31%   -0.02%     
==========================================
  Files         171      171              
  Lines       31013    31014       +1     
  Branches       12       12              
==========================================
- Hits        25221    25218       -3     
- Misses       5792     5796       +4     
Files with missing lines Coverage Δ
libp2p/muxers/yamux/yamux.nim 91.53% <100.00%> (+0.01%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-project-automation github-project-automation Bot moved this from new to In Progress in nim-libp2p Jul 8, 2026
@richard-ramos richard-ramos added this pull request to the merge queue Jul 8, 2026
Merged via the queue into master with commit 27ffb0b Jul 8, 2026
33 checks passed
@richard-ramos richard-ramos deleted the fix/yamux-interop branch July 8, 2026 19:37
@github-project-automation github-project-automation Bot moved this from In Progress to done in nim-libp2p Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: done

Development

Successfully merging this pull request may close these issues.

4 participants