feat: payment amount verification tests + unified vault migration#23
Open
mickvandijke wants to merge 8 commits intomainfrom
Open
feat: payment amount verification tests + unified vault migration#23mickvandijke wants to merge 8 commits intomainfrom
mickvandijke wants to merge 8 commits intomainfrom
Conversation
…yment vault Add E2E security tests verifying that nodes reject underpayment for both single-node and merkle payment modes: - test_attack_underpayment_single_node: pays 1 atto instead of 3x median - test_attack_underpayment_half_price: pays ~1.5x instead of 3x median - test_attack_merkle_proof_for_wrong_chunk: uses proof for wrong chunk - test_attack_merkle_proof_swap_within_batch: swaps proofs between chunks Also migrates client payment code to the unified payment vault contract, replacing separate data_payments/merkle_payments approvals with a single payment_vault approval, and using node-reported prices directly instead of fetching from the on-chain contract. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a09c731 to
9cf4cb5
Compare
The verifier was calling verifyPayment with original quote prices from ProofOfPayment::digest(), but the SingleNode model pays 3x to the median and 0 to others. The contract does exact amount matching, so all 5 quotes failed verification. The updated ant-node reconstructs actual paid amounts via SingleNodePayment::from_quotes() before calling verifyPayment. - ant-node: 08bb16f5 -> f283b9ac - evmlib: f4cdd45e -> 56148ce8 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both underpayment tests were sending the PUT to quotes.first() (arbitrary peer) instead of the median peer. Since verify() only checks the target node's own payment, non-median nodes see expected=0, on-chain=0 and pass verification regardless of median tampering. Now we resolve the median peer via rewards_address after from_quotes() sorts internally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Updated `ant-node` and `evmlib` to newer commits and adjusted dependency versions in `Cargo.lock` for compatibility. Removed redundant `windows` package versions for cleanup.
…o.lock Removed `TEST_INITIAL_RECORDS` constant due to redundancy. Updated `windows-sys` and `socket2` dependencies in `Cargo.lock` for compatibility.
Include `price` in `PreparedChunk` to ensure complete amount details are preserved during batch processing.
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
New security tests
test_attack_underpayment_single_nodetest_attack_underpayment_half_pricetest_attack_merkle_proof_for_wrong_chunktest_attack_merkle_proof_swap_within_batchCompanion PR
Depends on WithAutonomi/ant-node — fix/merkle-underpayment-verification which fixes a critical vulnerability where the merkle payment verifier only checked
paid_amount.is_zero()instead ofpaid_amount >= candidate.price, allowing clients to underpay by submitting fake low prices in pool commitments.Test plan
cargo test -p ant-core --test e2e_security test_attack_underpayment— both single-node underpayment tests passcargo test -p ant-core --test e2e_merkle test_attack_merkle_proof— both merkle proof security tests passcargo test -p ant-core --test e2e_merkle test_merkle_data_upload_download— legitimate merkle payments still work🤖 Generated with Claude Code