Use RequestSharing in Native price estimator#4630
Conversation
|
Claude finished @fleupold's task in 3m 32s —— View job PR Review: Use RequestSharing in Native price estimator
Verdict: LGTM ✅ — a clean, well-scoped change that correctly coalesces concurrent native-price requests. Things I checked that hold up well:
One minor, non-blocking observation posted inline: followers inherit the leader's Note: I couldn't run |
| let result = this | ||
| .0 | ||
| .estimator | ||
| .estimate_native_price(approximation.address, request_timeout) |
There was a problem hiding this comment.
Minor / non-blocking: with sharing, request_timeout (and the approximation lookup) is now captured from whichever caller starts the request (the leader). Followers that join an in-flight request inherit the leader's request_timeout rather than their own.
On the multi-token fetch_prices path this is harmless because the whole stream is wrapped in a per-caller time::timeout(timeout, ...). But the single-token estimate_native_price path (line ~438) has no such outer wrapper, so a follower's effective timeout is the leader's, not its own. In practice all callers seem to pass the same configured timeout, so this is likely a non-issue — just flagging in case timeouts ever diverge per call site.
There was a problem hiding this comment.
Valid point. This could be worked around by using a (Address, Timeout) key to store the inflight request with. Given that in practice people use the default timeout this should not increase the number of duplicated requests much but would prevent requests with super short deadlines from messing with honest citizens using reasonable timeouts.
MartinquaXD
left a comment
There was a problem hiding this comment.
Fine to merge as is as the (Address, Timeout) suggestion will likely not have a huge impact either way.
Description
I noticed in the logs that we sometimes send the same native price request within extremely short intervals to our solvers (cf. logs). This is due to us not sharing inflight native price requests.
This leads to us being more annoying that necessary to solver that already have very limited incentive and interest in responding to these requests.
This PR adds our RequestSharing abstraction to this component so we remove unnecessary requests.
Changes
How to test
Added a unit test