Skip to content

fix: migrate NAT-friendly quote selection and process exit fix#4

Merged
mickvandijke merged 2 commits intoWithAutonomi:mainfrom
jacderida:chore-migrate_saorsa_client_pr_6
Mar 25, 2026
Merged

fix: migrate NAT-friendly quote selection and process exit fix#4
mickvandijke merged 2 commits intoWithAutonomi:mainfrom
jacderida:chore-migrate_saorsa_client_pr_6

Conversation

@jacderida
Copy link
Contributor

@jacderida jacderida commented Mar 25, 2026

Summary

  • XOR distance quote selection: Collect all quote responses instead of racing for the first 5, then sort by XOR distance to chunk address and take the closest REQUIRED_QUOTES peers. This prevents systematic exclusion of nodes behind NAT whose responses arrive slower than cloud nodes.
  • Force process exit: Restructure main() to call std::process::exit() after all work completes, preventing indefinite hangs from open QUIC connections and pending background tasks during tokio runtime shutdown.

Both fixes are migrated from saorsa-client commits a7374ee6 and 45a8c45b.

Test plan

  • cargo check passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • cargo fmt --all -- --check passes
  • Verify quote selection includes NATed nodes in a mixed cloud/NAT testnet
  • Verify ant CLI exits promptly after upload completes

🤖 Generated with Claude Code

jacderida and others added 2 commits March 25, 2026 15:28
The previous quote collection used FuturesUnordered and took the first
5 responses. This systematically excluded nodes behind NAT because
cloud nodes always respond faster, causing the NATed node's quote to
arrive 6th and be dropped — even when it was the 2nd closest peer by
XOR distance.

Now collects all quote responses, sorts by XOR distance to the chunk
address, and takes the closest REQUIRED_QUOTES (5) peers. This ensures
deterministic, distance-based placement where every reachable node gets
a fair chance regardless of network latency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tokio runtime's graceful shutdown blocks indefinitely on open QUIC
connections and pending background tasks (DHT, keep-alive). Restructure
main() to call std::process::exit() after all work completes, for both
success (exit 0) and error (exit 1) paths. All data is persisted/printed
before the exit point, so nothing is lost.

This is essential for continuous upload workflows where the uploader
script needs the ant process to exit promptly so the next upload can
begin.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mickvandijke mickvandijke merged commit 6212882 into WithAutonomi:main Mar 25, 2026
10 of 12 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.

2 participants