Skip to content

feat(client): use witnessed SNP quote selection#118

Merged
jacderida merged 4 commits into
rc-2026.6.2from
snp-witnessed-close-group
Jun 14, 2026
Merged

feat(client): use witnessed SNP quote selection#118
jacderida merged 4 commits into
rc-2026.6.2from
snp-witnessed-close-group

Conversation

@mickvandijke

@mickvandijke mickvandijke commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Updates SNP quote collection to use a quorum-witnessed close group instead of relying only on the client's local strict-K view.

The client now asks saorsa-core for a witnessed close group, fetches store quotes only from that final quorum-recognised set, and builds the SNP median payment from those witnessed quotes. If the client cannot construct a full K-sized witnessed group, it fails before payment with diagnostic context.

Problem

PR #117 fixed SNP quote collection to query exactly CLOSE_GROUP_SIZE peers instead of over-querying. The saorsa-core pure-XOR revert fixes the reachability re-ranking disagreement, but honest nodes can still have slightly divergent routing-table views because of trust filtering, IP-diversity limits, churn, or missing addresses.

In that case, a client-selected median paid quote issuer can be outside a receiver's local strict K, producing failures like:

Median quote payment verification failed, including Paid quote issuer <peer> is not among this node's local 7 closest peers.

The fix here is to select SNP quote peers from a set recognised by a quorum of the closest responders, rather than from a single client-local view.

Client Behavior

For single-node payment quote collection, the client now:

  1. Computes a 5-of-7 witnessed quorum for the current CLOSE_GROUP_SIZE = 7.
  2. Calls Network::find_witnessed_close_group(target, K, quorum).
  3. Requires the returned consensus set to contain at least K quorum-recognised peers.
  4. Uses the quorum-recognised consensus peers, already ordered by pure XOR, as the SNP quote set.
  5. Fetches store quotes from that witnessed set.
  6. Builds the SingleNodePayment from those witnessed quotes.
  7. Logs the selected median paid quote issuer and median price before payment submission.

If fewer than K peers pass quorum, the client returns Error::InsufficientPeers before payment. The error includes the target, initial closest responders, per-responder self-inclusive views, vote counts, quorum threshold, and final witnessed set.

Important Boundaries

  • This changes only the SNP quote path.
  • Merkle / fault-tolerant quote collection remains separate and keeps its existing candidate-pool behavior.
  • The client does not silently top up from non-quorum peers.
  • Vote count is not used for final ordering; quorum decides eligibility, then pure XOR decides ordering/truncation.
  • Receiver-side verification is not relaxed by this PR. Receivers still enforce their local verifier policy; this change reduces the chance of paying an issuer that only the client recognises.

Dependency Stack

This PR is stacked on the witnessed close-group API and branch pins while the stack is open:

Tests

Added/updated coverage for:

  • typed pre-payment failure when the witnessed consensus has fewer than K peers
  • preservation of the single-node quote query count behavior
  • full ant-core lib suite against the witnessed dependency stack
  • test support compatibility with the current node verifier config

Validation

  • cargo check --all-targets --all-features
  • cargo fmt --all -- --check
  • cargo test -p ant-core --lib
  • cargo clippy --all-targets --all-features -- -D warnings

@jacderida jacderida merged commit 363b5ae into rc-2026.6.2 Jun 14, 2026
8 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