Skip to main content

Module payment

Module payment 

Source
Expand description

Payment verification system for ant-node.

This module implements the payment verification strategy:

  1. Check LRU cache for already-verified data
  2. Require and verify EVM/Arbitrum payment for new data

§Default Policy

Production nodes require payment by default.

  • EVM verification is always on — there is no way to disable it
  • For unit tests, pre-populate the cache via PaymentVerifier::cache_insert()

§Architecture

PUT request received
       │
       ▼
┌─────────────────────┐
│ Check LRU cache     │
└─────────┬───────────┘
          │
   ┌──────┴──────┐
   │             │
  HIT          MISS
   │             │
   ▼             ▼
Store (paid)   Require EVM payment

§Payment Flow

All new data requires EVM payment:

  1. Client requests a quote from the node
  2. Node generates PaymentQuote with ML-DSA-65 signature
  3. Client pays on Arbitrum via PaymentVault.payForQuotes()
  4. Client sends PUT with ProofOfPayment
  5. Node verifies on-chain payment and stores data

Re-exports§

pub use metrics::QuotingMetricsTracker;
pub use pricing::calculate_price;
pub use quote::wire_ml_dsa_signer;
pub use quote::QuoteGenerator;
pub use quote::XorName;
pub use wallet::is_valid_address;
pub use wallet::parse_rewards_address;
pub use wallet::WalletConfig;

Modules§

metrics
Quoting metrics tracking for ant-node.
pricing
Quadratic pricing with a baseline floor for ant-node (Phase 1 recalibration).
proof
Payment proof re-exports from ant_protocol.
quote
Payment quote generation for ant-node.
single_node
SingleNode payment re-exports from ant_protocol.
wallet
EVM wallet management for receiving payments.

Structs§

CacheStats
Cache statistics for monitoring.
EvmVerifierConfig
Configuration for EVM payment verification.
PaymentProof
A payment proof that includes both the quote-based proof and on-chain tx hashes.
PaymentVerifier
Main payment verifier for ant-node.
PaymentVerifierConfig
Configuration for the payment verifier.
SingleNodePayment
Single node payment structure for a chunk.
VerifiedCache
LRU cache for verified XorName values.

Enums§

PaymentStatus
Status returned by payment verification.
ProofType
The detected type of a payment proof.

Constants§

MAX_PAYMENT_PROOF_SIZE_BYTES
Maximum allowed size for a payment proof in bytes (256 KB).
MIN_PAYMENT_PROOF_SIZE_BYTES
Minimum allowed size for a payment proof in bytes.

Functions§

deserialize_merkle_proof
Deserialize proof bytes as a MerklePaymentProof.
deserialize_proof
Deserialize proof bytes from the PaymentProof format (single-node).
detect_proof_type
Detect the proof type from the first byte (version tag).
serialize_merkle_proof
Serialize a MerklePaymentProof with the version tag prefix.
serialize_single_node_proof
Serialize a PaymentProof (single-node) with the version tag prefix.
verify_merkle_candidate_signature
Verify a MerklePaymentCandidateNode’s ML-DSA-65 signature.
verify_quote_content
Verify that a payment quote’s content address matches the expected address.
verify_quote_signature
Verify a payment quote’s ML-DSA-65 signature.