Repository navigation
Conversation
The relay handler kept a single `reservation_request_future` and replaced it when the behaviour sent another accept/deny for the same connection. If an accept was replaced before it completed, the behaviour had already marked the reservation as active but the handler never started the reservation timer or reported `ReservationReqAccepted`, and the client never got its response. Keep all accept/deny futures in a `FuturesUnordered` and report each one.
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
…utures # Conflicts: # Cargo.toml
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
|
Tick the box to add this pull request to the merge queue (same as
|
jxs
left a comment
There was a problem hiding this comment.
Hi, thanks for the PR and sorry for the delay reviewing it.
overall LGTM but It needs two things though:
-
A timeout. Switch the field to
futures_bounded::FuturesSetwithSTREAM_TIMEOUT, exactly asinbound_workersalready does (handler.rs:405-407). Without it, a peer that stalls the response write pins its substream until connection teardown, with no self-healing. -
A max_pending_reservations (per-connection) cap.
FuturesSetgives you capacity + timeout in one construct, so this comes along with 1.
At capacity, don't silently drop, that reintroduces #6141, instead emitReservationReqAcceptFailed.
|
Thanks for the review. Pushed 1df6c41: the reservation futures are now a |
|
This pull request has merge conflicts. Could you please resolve them @0xShadowX? 🙏 |
Related to #6141 (
ReservationReqAcceptednot always emitted, while the relay still routes circuits to the peer).The relay server handler stores the response to an inbound reservation request in a single
Option<ReservationRequestFuture>. WhenAcceptReservationReqorDenyReservationReqarrives while another one is still pending, the old future is replaced and only "Dropping existing deny/accept future in favor of new one" is logged. If the dropped one was an accept:active_reservation, so there is no expiry for it,ReservationReqAcceptedevent is emitted and the client never receives the response, so its listener doesn't come up,max_reservationsand circuits to the peer are routed.That matches what #6141 describes. It happens deterministically when a client sends two reservation requests on the same connection and the second is denied (for example by the per-peer rate limiter), because the connection task handles both commands before polling the handler again.
The handler now keeps accept and deny futures in a
FuturesUnorderedand reports every result, same as it already does for circuit accept/deny.Test:
Two
listen_oncalls to the same relay with a per-peer reservation rate of 1. On master the relay reports the denial but never the acceptance (accepted reservation request was dropped: left 0, right 1).relay 0.22.0 is released, bumped to 0.22.1.
cargo test -p libp2p-relayand-p libp2p-dcutrpass