Re-resolve the right swarm after a 421 - #126
Open
jagerman wants to merge 1 commit into
Open
Conversation
_handle_421_retry re-resolved the swarm using service_node::swarm_pubkey(), which returns compute_x25519_pubkey(remote_pubkey) -- the failing *node's own* X25519 key, not the account the request was about. So a misdirected request was retried against a swarm chosen by hashing the pubkey of the node that had just rejected it: an unrelated swarm, giving another 421 and then the retry limit. Recovering needs the swarm of the *account*, which may have moved. Request now records the account whose swarm it addresses, and the retry re-resolves that. A request with no swarm recorded -- a snode cache refresh, a clock resync, anything aimed at a node rather than about an account -- is not redirected at all, rather than being sent somewhere arbitrary. session_request_params gains a swarm_pubkey_hex field (appended, so a caller that doesn't set it behaves as before). service_node::swarm_pubkey() is removed rather than corrected: it had a single caller and the name invited exactly this mistake (it reads as "the swarm this node is in" while computing the node's own key). compute_x25519_pubkey() stays. Adapted from pfs commit e5a93a8. On this branch the account-addressed sends originate above libsession and arrive through the C session_network_send_request (hence the swarm_pubkey_hex param); the only internal swarm sends -- the clock resync and snode-pool refreshes -- are node-directed and correctly leave swarm_pubkey unset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
_handle_421_retry re-resolved the swarm using service_node::swarm_pubkey(), which returns compute_x25519_pubkey(remote_pubkey) -- the failing node's own X25519 key, not the account the request was about. So a misdirected request was retried against a swarm chosen by hashing the pubkey of the node that had just rejected it: an unrelated swarm, giving another 421 and then the retry limit. Recovering needs the swarm of the account, which may have moved.
Request now records the account whose swarm it addresses, and the retry re-resolves that. A request with no swarm recorded -- a snode cache refresh, a clock resync, anything aimed at a node rather than about an account -- is not redirected at all, rather than being sent somewhere arbitrary. session_request_params gains a swarm_pubkey_hex field (appended, so a caller that doesn't set it behaves as before).
service_node::swarm_pubkey() is removed rather than corrected: it had a single caller and the name invited exactly this mistake (it reads as "the swarm this node is in" while computing the node's own key). compute_x25519_pubkey() stays.
Adapted from pfs commit e5a93a8. On this branch the account-addressed sends originate above libsession and arrive through the C session_network_send_request (hence the swarm_pubkey_hex param); the only internal swarm sends -- the clock resync and snode-pool refreshes -- are node-directed and correctly leave swarm_pubkey unset.