fix(payment): enforce single-node proof verification#107
Open
mickvandijke wants to merge 5 commits into
Open
Conversation
SemVer: patch
There was a problem hiding this comment.
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-chaincompletedPayments(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.
SemVer: patch
SemVer: patch
There was a problem hiding this comment.
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 thep2p_nodeattachment + 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) {
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.
Summary
SingleNodePayment::verify()call with verifier-ownedcompletedPayments(quote.hash())checks for amount and recipient binding.SemVer: patch
Requested Checklist Coverage
CLOSE_GROUP_SIZEquote entries.completedPayments(quote.hash())shows an amount at least3 * quote.price.completedPayments(quote.hash())recipient prefix matches the quote rewards address.Recipient Binding Note
PaymentVaultV2.completedPaymentscurrently stores the recipient asbytes16, 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 -- --checkcargo test payment::verifiercargo clippy --all-targets --all-features -- -D warningsCommit
23d15b5 fix(payment): enforce single-node proof verification