Skip to content

Implement SV2 Message Layer for Mint Statistics Communication #68

@vnprc

Description

@vnprc

Problem: Pool web dashboard cannot display real-time "Quotes Redeemed" statistics because there's no proper inter-service communication mechanism between the pool and mint services.

Current State:

  • Pool tracks quotes_created (number of quote requests sent to mint)
  • Mint tracks quotes_issued (actual ecash tokens minted and issued)
  • No way for pool to query mint for issued quote statistics
  • Dashboard shows "?" for "Quotes Redeemed" counter

Background:
In the hashpool architecture, the pool and mint are separate services that may be deployed on different machines. The pool sends mint quote requests via TCP using SV2 protocol, but there's currently no reverse communication channel for the pool to request statistics from the mint.

Technical Details:

  • Pool needs to query mint for: total issued quotes, quotes by status, ehash amounts issued
  • Current workaround attempts (all rejected for architectural reasons):
    • Direct database access with hardcoded paths
    • Config-based database path resolution
    • Local filesystem queries

Required Implementation:

  1. New SV2 Message Types:
  • MintStatsRequest - Pool requests statistics from mint
  • MintStatsResponse - Mint responds with aggregated statistics
  1. Message Fields Needed:
struct MintStatsResponse {
    total_quotes_issued: u64,
    total_ehash_issued: u64,
    quotes_by_status: HashMap<QuoteState, u64>,
    // ... other relevant metrics
}
  1. Integration Points:
  • Pool web dashboard (roles/pool/src/lib/web.rs:188-191)
  • Existing SV2 messaging infrastructure between pool and mint
  • Mint's CDK statistics aggregation

Files Requiring Changes:

  • roles/pool/src/lib/web.rs - Remove TODO and implement stats request
  • SV2 protocol definitions - Add new message types
  • Mint service - Add stats response handler
  • Pool's mint communication layer - Add stats request capability

Current Workaround:

// TODO: Implement mint stats request over SV2 message layer to get issued quotes count
// This requires adding a new SV2 message type to request statistics from the mint
// For now, quotes_redeemed stays at 0 until proper inter-service communication is implemented
let quotes_redeemed = None; // Shows as "?" in dashboard

Acceptance Criteria:

  • Pool can request real-time statistics from mint via SV2 messages
  • Dashboard displays actual "Quotes Redeemed" count instead of "?"
  • Communication works across distributed deployments (different machines)
  • Statistics include ehash amounts and quote state breakdowns
  • Backward compatible with existing pool-mint communication

This enhancement would enable a separate mint dashboard page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions