Fix gzip corruption in EVM JSON-RPC responses via seiLegacyHTTPGate#3181
Merged
Conversation
The seiLegacyHTTPGate middleware wraps outside the gzip handler, so for every eth_*/web3_*/net_* request it captures the gzip-compressed response into an httptest.Recorder then replays the already-compressed bytes to the real http.ResponseWriter. This record-and-replay of compressed data breaks gzip framing and causes Z_DATA_ERROR in clients like ethers.js v6. For non-sei_*/sei2_* methods the recorder adds no value — the gate check returns nil immediately and no deprecation header is needed. Skip the recorder for these methods and call serveInnerWithBody so the gzip handler writes directly to the real response writer.
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3181 +/- ##
=======================================
Coverage 58.69% 58.70%
=======================================
Files 2055 2055
Lines 168384 168381 -3
=======================================
+ Hits 98838 98840 +2
+ Misses 60742 60732 -10
- Partials 8804 8809 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
sei-will
approved these changes
Apr 3, 2026
yzang2019
approved these changes
Apr 3, 2026
sei-will
approved these changes
Apr 3, 2026
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 3, 2026
…3181) The seiLegacyHTTPGate middleware wraps outside the gzip handler, so its httptest.Recorder captures gzip-compressed bytes from the inner handler. This causes two problems: 1. For single and all-forwarded batches the gate replays compressed bytes to the real http.ResponseWriter, breaking gzip framing for clients like ethers.js v6 (Z_DATA_ERROR). 2. For mixed/gated batches the gate calls json.Unmarshal on compressed bytes, which fails, causing all results to be replaced with -32603 errors — and then writes plain JSON with a Content-Encoding: gzip header copied from the recorder. Fix both paths: - Non-gated methods (eth_*, web3_*, net_*) now bypass the recorder entirely via serveInnerWithBody, so the gzip handler writes directly to the real response writer. - Recorder paths (gated sei_* singles, mixed batches) strip Accept-Encoding from the cloned request so the inner gzip handler is a no-op. The recorder captures plain JSON, merge logic works, and no stale Content-Encoding: gzip header is propagated. Update two existing batch tests that relied on the recorder/merge path for all-eth batches: add a blocked sei_* element to each so they still exercise mergeSeiLegacyHTTPBatch through the recorder path. (cherry picked from commit b0de857)
|
Successfully created backport PR for |
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.
The seiLegacyHTTPGate middleware wraps outside the gzip handler, so its
httptest.Recorder captures gzip-compressed bytes from the inner handler.
This causes two problems:
For single and all-forwarded batches the gate replays compressed
bytes to the real http.ResponseWriter, breaking gzip framing for
clients like ethers.js v6 (Z_DATA_ERROR).
For mixed/gated batches the gate calls json.Unmarshal on compressed
bytes, which fails, causing all results to be replaced with -32603
errors — and then writes plain JSON with a Content-Encoding: gzip
header copied from the recorder.
Fix both paths:
Non-gated methods (eth_, web3_, net_*) now bypass the recorder
entirely via serveInnerWithBody, so the gzip handler writes directly
to the real response writer.
Recorder paths (gated sei_* singles, mixed batches) strip
Accept-Encoding from the cloned request so the inner gzip handler
is a no-op. The recorder captures plain JSON, merge logic works,
and no stale Content-Encoding: gzip header is propagated.
Update two existing batch tests that relied on the recorder/merge path
for all-eth batches: add a blocked sei_* element to each so they still
exercise mergeSeiLegacyHTTPBatch through the recorder path.