fix: restore method/params in WS send-caching dummy request (#3823)#3825
Open
saheersk wants to merge 2 commits intoethereum:mainfrom
Open
fix: restore method/params in WS send-caching dummy request (#3823)#3825saheersk wants to merge 2 commits intoethereum:mainfrom
saheersk wants to merge 2 commits intoethereum:mainfrom
Conversation
…#3823) When async_handle_send_caching detects a cache hit it returns a dummy RPCRequest (id=-1) to skip the network send. Previously the dummy used method="" and params=[], so async_handle_recv_caching could not compute the correct cache key and fell through to _get_response_for_request_id(-1), causing a TimeExhausted error on every cached WS request. Fix: preserve the original method and params in the dummy request so the recv-caching decorator can look up and return the cached response. Also move `import threading` in cache_request_information to module level. Add three tests covering the persistent-connection (WebSocket) caching path: end-to-end socket_request caching, dummy request preservation, and recv-caching round-trip.
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.
Title:
fix: restore method/params in WS send-caching dummy request (#3823)
Body:
When async_handle_send_caching detects a cache hit it returns a dummy
RPCRequest (id=-1) to skip the network send. Previously the dummy used
method="" and params=[], so async_handle_recv_caching could not compute
the correct cache key and fell through to _get_response_for_request_id(-1),
causing a TimeExhausted error on every cached WS request.
Fix: preserve the original method and params in the dummy request so the
recv-caching decorator can look up and return the cached response.
Also move
import threadingin cache_request_information to module level.Add three tests covering the persistent-connection (WebSocket) caching
path: end-to-end socket_request caching, dummy request preservation,
and recv-caching round-trip.
What was wrong?
Related to Issue #3823
Closes #3823
For PersistentConnectionProvider (WebSocket/AsyncIPC), cacheable RPC
requests (e.g. eth_chainId) were never served from cache — every call
hit the network.
Root cause: async_handle_send_caching returns a dummy RPCRequest
(id=-1) when it detects a cache hit, to prevent the request from being
sent over the wire. The dummy used method="" and params=[], so when
async_handle_recv_caching received it, is_cacheable_request returned
False (empty method is not on the allowlist). The decorator then called
_get_response_for_request_id(-1), which polled until TimeExhausted.
A secondary contributing bug: the cache key in cache_request_information
used a different format from the one used by the caching decorators
(missing the thread-ID prefix), so the early-exit guard that prevents
duplicate request-info entries never fired.
How was it fixed?
in the dummy request ({"id": -1, "method": method, "params": params}),
so async_handle_recv_caching can compute the correct cache key and
return the cached response without touching the network.
level in request_processor.py.
end-to-end socket_request cache hit, dummy request field preservation,
and full send->recv cached round-trip.
Todo:
Cute Animal Picture