Skip to content

fix snappy frame multi chunks and refactor#521

Merged
g11tech merged 3 commits intomainfrom
gr/snappy_frame_multi_chunks
Jan 26, 2026
Merged

fix snappy frame multi chunks and refactor#521
g11tech merged 3 commits intomainfrom
gr/snappy_frame_multi_chunks

Conversation

@GrapeBaBa
Copy link
Copy Markdown
Member

@GrapeBaBa GrapeBaBa commented Jan 25, 2026

  • Improve req/resp snappy framing to compute total frame size from chunk headers, validate chunk types/lengths, and handle multi‑chunk frames based on the declared uncompressed
    length.
  • Thread the declared uncompressed length through inbound/outbound codecs and Zig RPC handling to verify decoded payload size matches the declaration and reject mismatches.
  • Remove the heuristic compressed‑size overhead check in favor of strict framing validation; minor lint cleanup.

Copilot AI review requested due to automatic review settings January 25, 2026 14:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes snappy frame handling to properly support multi-chunk frames and refactors the validation logic for improved precision and security.

Changes:

  • Implemented multi-chunk snappy frame parsing with proper accumulation of uncompressed lengths across chunks
  • Replaced heuristic frame size validation with precise calculation using snap::raw::max_compress_len
  • Added defense-in-depth validation by checking decompressed length matches declared length on the Zig side

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
rust/libp2p-glue/src/req_resp/varint.rs Refactored calculate_snappy_frame_size to handle multi-chunk frames, added max_framed_len helper, improved validation with overflow checks
rust/libp2p-glue/src/req_resp/outbound_protocol.rs Updated calls to calculate_snappy_frame_size with new parameter, removed heuristic validation
rust/libp2p-glue/src/req_resp/inbound_protocol.rs Updated calls to calculate_snappy_frame_size with new parameter, removed heuristic validation
pkgs/network/src/ethlibp2p.zig Enhanced frame parsing to return declared length, added validation that decompressed length matches declared length

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

grapebaba added 2 commits January 26, 2026 11:27
Signed-off-by: grapebaba <grapebaba@grapebabadeMacBook-Pro.local>
@GrapeBaBa GrapeBaBa marked this pull request as ready for review January 26, 2026 04:06
Copilot AI review requested due to automatic review settings January 26, 2026 04:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

seems already tested against ream interop

@g11tech g11tech changed the title fix: fix snappy frame multi chunks and refactor fix snappy frame multi chunks and refactor Jan 26, 2026
@g11tech g11tech merged commit 278bbaf into main Jan 26, 2026
18 checks passed
@g11tech g11tech deleted the gr/snappy_frame_multi_chunks branch January 26, 2026 11:50
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.

3 participants