Skip to content

fix(payment): enforce single-node proof verification#107

Open
mickvandijke wants to merge 5 commits into
WithAutonomi:mainfrom
mickvandijke:fix/single-node-payment-verification
Open

fix(payment): enforce single-node proof verification#107
mickvandijke wants to merge 5 commits into
WithAutonomi:mainfrom
mickvandijke:fix/single-node-payment-verification

Conversation

@mickvandijke
Copy link
Copy Markdown
Collaborator

@mickvandijke mickvandijke commented May 20, 2026

Summary

  • Enforce the full single-node payment proof validation path before accepting new stores.
  • Validate the quote set against the content address, quoted peer identities, ML-DSA signatures, and this node self-inclusive local close-group view.
  • Replace the generic SingleNodePayment::verify() call with verifier-owned completedPayments(quote.hash()) checks for amount and recipient binding.

SemVer: patch

Requested Checklist Coverage

  • Proof contains exactly CLOSE_GROUP_SIZE quote entries.
  • Quote peer IDs are distinct.
  • Every quote is for the uploaded content address.
  • Every quote is signed by the peer that claims it.
  • Every quoted peer is present in this node valid local close-group view for the content.
  • The paid quote is selected from the already validated quote set, including median-price tie handling.
  • completedPayments(quote.hash()) shows an amount at least 3 * quote.price.
  • completedPayments(quote.hash()) recipient prefix matches the quote rewards address.

Recipient Binding Note

PaymentVaultV2.completedPayments currently stores the recipient as bytes16, not the full 20-byte EVM address. This PR verifies the stored 16-byte prefix against the quote rewards address. Full 20-byte equality would require a contract/ABI change or event-based reconstruction.

Tests

  • cargo fmt --all -- --check
  • cargo test payment::verifier
  • cargo clippy --all-targets --all-features -- -D warnings

Commit

  • 23d15b5 fix(payment): enforce single-node proof verification

Copilot AI review requested due to automatic review settings May 20, 2026 14:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Tightens single-node payment proof verification in PaymentVerifier by ensuring the proof’s quoted peers match the verifier’s local close-group view and by strengthening the on-chain validation (median-priced selection, recipient-prefix binding, and under/overpayment handling) against PaymentVault.completedPayments.

Changes:

  • Adds local close-group membership enforcement for all quoted peers in single-node proofs.
  • Replaces the previous SingleNodePayment::verify(...) path with explicit on-chain completedPayments(quoteHash) checks that handle median-price ties and validate rewards-address prefix + paid amount.
  • Extends unit tests to cover close-group set validation and completed-payment amount/recipient-prefix checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/payment/verifier.rs Outdated
Comment thread src/payment/verifier.rs
Copilot AI review requested due to automatic review settings May 20, 2026 16:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/payment/verifier.rs
Copilot AI review requested due to automatic review settings May 20, 2026 16:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/payment/verifier.rs:501

  • The CPU-heavy ML-DSA signature verification runs before the single-node close-group check (which also fails fast if no P2PNode is attached). To reduce DoS surface and avoid wasting CPU when the proof will be rejected due to close-group / attachment constraints, consider running validate_single_node_close_group(...) (or at least the p2p_node attachment + local peer/rewards checks) before spawning the blocking signature verification task.
        // Verify quote signatures (CPU-bound, run off async runtime)
        let peer_quotes = payment.peer_quotes.clone();
        tokio::task::spawn_blocking(move || {
            for (encoded_peer_id, quote) in &peer_quotes {
                if !verify_quote_signature(quote) {

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