Skip to content

fix(relay): reopen paths when disabled relays are re-enabled or re-inserted - #23

Merged
CommaBot merged 1 commit into
stillfailfrom
ember/relay-policy-reopen
Nov 20, 2026
Merged

CommaBot merged 1 commit into
stillfailfrom
ember/relay-policy-reopen

Conversation

@CommaBot

@CommaBot CommaBot commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  1. Per-remote disabled relay shelving & automatic reopen (Endpoint::set_disabled_relays, ConnectOptions::with_disabled_relays):
    • Shelves per-remote disabled relay entries inside RemotePathState::shelved_relays instead of permanently deleting them from paths, while keeping allowlist as an immutable ceiling.
    • When set_disabled_relays shrinks a remote's disabled set, restores newly allowed shelved relays into paths, clears their per-relay relay_lost counter (bounded by RELAY_CONN_LOST_MAX = 6), and immediately calls reopen_relay_paths() on client connections without redialing or address lookup.
  2. Serialized Endpoint::remove_relay / Endpoint::insert_relay lifecycle & transport isolation:
    • Moves relay_map.{remove, insert} and relay_policies.set_removed mutations into socket::Actor::handle_actor_message alongside transports_network_change and remote_map, eliminating concurrent insert/remove tombstone races (Astra P1 relay: a packet that waited 200 ms in a client's queue is dropped #1).
    • Fixes TransportsSender::poll_send position index lookup so packets addressed to a removed or unconfigured relay transport never fall back to the default IP/custom transport.
    • Settles one unit of relay_lost and relay_lost_total when State::close_forbidden_paths cancels an unestablished path still in conn_state.relay_opening, preserving MAX_MULTIPATH_PATHS (8) headroom for non-relay (Ip/Custom) paths across repeated blackhole churn (Astra P1 Choose the path again as its RTTs change, not only as paths come and go #2).
    • Tracks explicitly inserted relays in socket::Actor::reopen_on_connect so RelayConnected only clears per-relay relay_lost and reopens client paths for insert_relay (including when the relay is already Connected with zero watch state diff or across back-to-back remove_relay + insert_relay watch coalescing), keeping ordinary home-relay reconnects 100% unchanged.
  3. PR fix(relay): require 10 ms minimum RTT gain before switching relay entrances #24 follow-ups:
    • Clarifies in STILLFAIL.md that ActiveRelayActor::choose_entry switches immediately on the first comparison after startup / update_entries and requires two consecutive rounds thereafter.
    • Adds exact 50 ms -> 40 ms (rejected at exact 20%) and 30 ms -> 20 ms (accepted at exact 10 ms) boundary assertions in choose_entry_requires_both_min_gain_and_relative_margin.

Boundary & station/native/mesh Impact

  • Transport handoff vs wire boundary: Matching socket.rs:1477-1480, Endpoint::relay_datagrams counts datagrams admitted past RelayPolicies::usable into the relay transport channel; ActiveRelayHandle::stop aborts the active relay task immediately on remove_relay, dropping any un-flushed channel items before wire write while closing QUIC paths synchronously in RemoteStateActor.
  • station/native/mesh impact:
    • (a) Ordinary home-relay reconnects: Unchanged — reopen_on_connect is populated exclusively by ActorMessage::RelayInserted, so background ActiveRelayActor reconnects do not trigger on_relay_connected or reset relay_lost.
    • (b) set_disabled_relays: shelved_relays only stores addresses already bounded by RemotePathState (MAX_ADDRS / peer EndpointAddr relays) and removes entries when re-enabled or when the RemoteStateActor idles out (60 s).
    • (c) remove_relay / insert_relay: Actor wait graph is a strict DAG (socket::Actor -> RelayActor -> ActiveRelayActor and socket::Actor -> RemoteStateActor, with zero reverse .await edges).

…ay reinsert

Shelve per-remote disabled relay addresses inside RemotePathState instead of
erasing them so Endpoint::set_disabled_relays re-enables and reopens client
paths immediately without redialing or address lookup.

Serialize RelayMap, RelayPolicies::removed tombstones, RelayActor, and
RemoteMap updates inside socket::Actor for Endpoint::remove_relay and
Endpoint::insert_relay:
- close established and opening paths on remove_relay without falling back to
  another transport in TransportsSender::poll_send;
- settle one unit of relay_lost and relay_lost_total when canceling an
  unestablished opening relay path so RELAY_CONN_LOST_MAX (6) still protects
  MAX_MULTIPATH_PATHS (8) for non-relay transports;
- track inserted relays in socket::Actor::reopen_on_connect so insert_relay
  clears per-relay relay_lost and reopens paths (including when already
  connected or across coalesced watch updates) while leaving ordinary
  home-relay reconnects unchanged;
- clarify first-comparison entrance switch wording in STILLFAIL.md and add
  exact 50->40 ms / 30->20 ms boundary cases in ActiveRelayActor tests.

Co-authored-by: darksky <darksky@cue.surf>
@CommaBot
CommaBot force-pushed the ember/relay-policy-reopen branch from 88e2211 to f02c469 Compare November 20, 2026 19:13
@CommaBot
CommaBot merged commit 4b5d5b9 into stillfail Nov 20, 2026
4 checks passed
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.

1 participant