Skip to content

fix(dht): let runtime re-bootstrap recover isolated and client-starved routing tables - #153

Open
Nic-dorman wants to merge 1 commit into
mainfrom
nic/v2-1036-client-rebootstrap-recovery
Open

fix(dht): let runtime re-bootstrap recover isolated and client-starved routing tables#153
Nic-dorman wants to merge 1 commit into
mainfrom
nic/v2-1036-client-rebootstrap-recovery

Conversation

@Nic-dorman

@Nic-dorman Nic-dorman commented Aug 20, 2026

Copy link
Copy Markdown
Member

Linear issue

V2-1036

Risk tier

  • T0 — docs / tooling / CI / pure UX-output. Repo CI only.
  • T1 — client-only, no network-facing behavior change. CI + prod compat smoke.
  • T2 — node/client logic with behavioral surface, no protocol/format/economics change. Dev testnet + ADR.
  • T3 — protocol / storage format / payments / routing. T2 evidence + adversarial testing.

Compatibility

  • Wire: none — no message or format changes; only when existing dials are issued changes, and only for nodes already below the re-bootstrap threshold.
  • Storage: none.
  • API: additive — AUTO_REBOOTSTRAP_THRESHOLD and DhtNetworkManager::maybe_rebootstrap become public.

Semver impact

  • breaking
  • feature
  • fix

Test evidence

  • New tests/client_rebootstrap.rs covers both dead ends (isolated-node fallback, client-mode starvation dials). Both tests were run against the unfixed code and fail there; they pass with the fix (0.97s).
  • Full cargo test green locally (Windows, exit 0); cargo fmt and the strict clippy gate (-D warnings -D clippy::unwrap_used -D clippy::expect_used) clean.
  • Field reproduction of the bug documented in V2-1036: a client held 10 identity-verified connections with its routing table pinned at 2 for 10+ hours across 98 repair cycles, each logging Auto re-bootstrap discovered 10 peers; and the downstream mainnet incident antd: /health reports ok when the node has no peers and cannot write (no peer-count or write-readiness signal) ant-sdk#232 (~34h at rt=0, restart-only recovery).

New dependency

none

ADR

ADR-018: Runtime Re-bootstrap Must Be Able to Recover (added in this PR)

Mitigation / rollback

Revert the commit; the new behavior only activates below the re-bootstrap threshold after the 5-minute cooldown, so the blast radius is limited to nodes that are already degraded.

🤖 Generated with Claude Code

Two dead ends in the routing-table repair path (V2-1036):

- maybe_rebootstrap gave up when no peers were connected; only process
  startup re-dials the configured bootstrap peers, so a fully isolated
  node could never recover at runtime (WithAutonomi/ant-sdk#232: ~34h at
  rt=0, restart-only recovery). It now falls back to re-dialing the
  configured bootstrap peers before giving up.

- bootstrap_from_peers skipped every gossiped-peer dial in client mode,
  but admission is connection-driven (handle_peer_connected), so a
  starved client rediscovered the same peers every cycle and stayed
  starved forever (observed: 98 cycles / 10h of 'discovered 10 peers'
  with the table pinned at 2). Starved clients now dial gossiped peers
  until the table clears the threshold; non-starved clients keep the
  skip.

Also: the completion log reports post-repair table size, and
maybe_rebootstrap + AUTO_REBOOTSTRAP_THRESHOLD are now public (manual
recovery hook and health reporting). Regression tests cover both dead
ends and were verified to fail against the previous behavior. ADR-018
records the decision.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dirvine

dirvine commented Aug 21, 2026

Copy link
Copy Markdown
Member

Review verdict: APPROVE (code) at 4fe03ab28faa504999527cf1ddc5b5a9b0937aa6.

The recovery path is bounded by the existing cooldown, falls back to configured bootstrap peers only when isolated, and only adds client-mode gossip dials while the routing table is below the threshold. The two regression scenarios passed locally: cargo test --test client_rebootstrap2 passed. I found no diff-specific async/network blocker.

Before merge: ADR-018 is still Proposed and needs the repository's human acceptance/sign-off; pr-template is currently red. The Security Audit failure is the h2 advisory fixed by #154, so merge/update from #154 and rerun CI. The claude-review failure appears infrastructural rather than a code finding.

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