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

p2p: support zero length request protos #1957

Closed
wants to merge 1 commit into from
Closed

Conversation

corverroos
Copy link
Contributor

Fix regression introduced by length-delimited upgrades which assumed that legacy-stream-delimited protocols handled requests and responses the same while it didn't. It allowed zero length requests while it didn't allow zero-length responses. This aligns the new implementation with that.

category: bug
ticket: #1956

@codecov
Copy link

codecov bot commented Mar 28, 2023

Codecov Report

Patch coverage: 88.88% and project coverage change: +0.36 🎉

Comparison is base (e8931f5) 55.45% compared to head (374c409) 55.82%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1957      +/-   ##
==========================================
+ Coverage   55.45%   55.82%   +0.36%     
==========================================
  Files         174      174              
  Lines       22297    22298       +1     
==========================================
+ Hits        12365    12447      +82     
+ Misses       8361     8272      -89     
- Partials     1571     1579       +8     
Impacted Files Coverage Δ
p2p/sender.go 72.89% <85.71%> (+0.16%) ⬆️
p2p/receive.go 60.34% <100.00%> (ø)

... and 7 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

},
readersByProtocol: map[protocol.ID]func(s network.Stream) pbio.Reader{
pID: func(s network.Stream) pbio.Reader { return legacyReadWriter{s} },
// Request readers are allowed to read zero bytes, this is because the legacy protocol
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Request readers are allowed to read zero bytes, this is because the legacy protocol
// Request readers are allowed to read zero bytes, in order to support the legacy protocol

reqReadersByProtocol: map[protocol.ID]func(s network.Stream) pbio.Reader{
pID: func(s network.Stream) pbio.Reader { return legacyReadWriter{stream: s, allowZeroRead: true} },
},
// Response readers are not allowed to read zero bytes, this is because the legacy protocol
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Response readers are not allowed to read zero bytes, this is because the legacy protocol
// Response readers are not allowed to read zero bytes, in order to support the legacy protocol

@corverroos corverroos closed this Mar 29, 2023
@corverroos corverroos deleted the corver/p2pzerolen branch April 5, 2023 08:05
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