Skip to content

All sessions in resume share the same relay instead of randomizing independently #1391

@bc1cindy

Description

@bc1cindy

Which crate is this feature request for (if any)?

payjoin-cli

Question

while investigating #1385, I found that selected_relay in RelayManager is scoped to the entire process, not per-session or per-request. In resume_payjoins, all sessions share the same Arc<Mutex<RelayManager>> via self.clone(). The first session writes to the cache via set_selected_relay and every subsequent session finds Some(relay) and skips randomization entirely

git show origin/master:payjoin-cli/src/app/v2/ohttp.rs | grep -n "set_selected_relay\|get_selected_relay"
git show origin/master:payjoin-cli/src/app/v2/mod.rs | grep -n "get_selected_relay"
16:    pub fn set_selected_relay(&mut self, relay: url::Url) { self.selected_relay = Some(relay); }
18:    pub fn get_selected_relay(&self) -> Option<url::Url> { self.selected_relay.clone() }
78:            .set_selected_relay(selected_relay.clone());
// mod.rs:820
let selected_relay = self.relay_manager.lock()...get_selected_relay();
match selected_relay {
    Some(relay) => relay, // sessions 2, 3... never randomize
    None => unwrap_ohttp_keys_or_else_fetch(...).await?.relay_url, // only session 1 gets here
}

I understand the cache is for reliability, holding onto a working relay instead of retrying. But with multiple sessions in resume, this means all sessions use the same relay, which comes back to the fingerprinting concern

would it make sense to remove the relay cache entirely, ensuring each session randomizes relay selection independently and resulting in per-request selection? If the choice becomes per-session we could update later, but as is stands, the cache scope seems inconsistent with the randomization intent

I've reported it in #1380 and #1385 but decided to open this issue to be more specific

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions