ant_node/payment/mod.rs
1//! Payment verification system for ant-node.
2//!
3//! This module implements the payment verification strategy:
4//! 1. Check LRU cache for already-verified data
5//! 2. Require and verify EVM/Arbitrum payment for new data
6//!
7//! # Default Policy
8//!
9//! **Production nodes require payment by default.**
10//!
11//! - EVM verification is always on — there is no way to disable it
12//! - For unit tests, pre-populate the cache via `PaymentVerifier::cache_insert()`
13//!
14//! # Architecture
15//!
16//! ```text
17//! PUT request received
18//! │
19//! ▼
20//! ┌─────────────────────┐
21//! │ Check LRU cache │
22//! └─────────┬───────────┘
23//! │
24//! ┌──────┴──────┐
25//! │ │
26//! HIT MISS
27//! │ │
28//! ▼ ▼
29//! Store (paid) Require EVM payment
30//! ```
31//!
32//! # Payment Flow
33//!
34//! All new data requires EVM payment:
35//! 1. Client requests a quote from the node
36//! 2. Node generates `PaymentQuote` with ML-DSA-65 signature
37//! 3. Client pays on Arbitrum via `PaymentVault.payForQuotes()`
38//! 4. Client sends PUT with `ProofOfPayment`
39//! 5. Node verifies on-chain payment and stores data
40
41mod cache;
42pub mod metrics;
43pub mod pricing;
44pub mod proof;
45pub mod quote;
46pub mod single_node;
47mod verifier;
48pub mod wallet;
49
50pub use cache::{CacheStats, VerifiedCache};
51pub use metrics::QuotingMetricsTracker;
52pub use pricing::calculate_price;
53pub use proof::{
54 deserialize_merkle_proof, deserialize_proof, detect_proof_type, serialize_merkle_proof,
55 serialize_single_node_proof, PaymentProof, ProofType,
56};
57pub use quote::{
58 verify_merkle_candidate_signature, verify_quote_content, wire_ml_dsa_signer, QuoteGenerator,
59 XorName,
60};
61pub use single_node::SingleNodePayment;
62pub use verifier::{EvmVerifierConfig, PaymentStatus, PaymentVerifier, PaymentVerifierConfig};
63pub use wallet::{is_valid_address, parse_rewards_address, WalletConfig};