Skip to content

Block Template Validation Queue #65

@vnprc

Description

@vnprc

The current hashpool design is focused on getting ehash working ASAP so makes a lot of simplifying assumptions. One of these assumptions is that the pool does not validate miner block templates. This isn't going to work in practice. We either need to disallow miners from producing their own templates (👎 for bitcoin but faster to production) or bite the bullet and build template validation (👍 for bitcoin but more complex and time consuming to build). I intend to build for both use cases.

Currently, the pool creates a quote at the mint with status PAID immediately after verifying a mining share. The PAID status enables the miner to mint the ehash tokens immediately. Due to their privacy properties, ecash tokens cannot be revoked or invalidated after the user has taken custody. This means we cannot issue ecash tokens before fully validating the share and, if it includes one, the block template. If the share is found to be invalid after we issue the ecash token this would represent an inflation in the token supply, and a theft from all miners submitting valid shares.

We can enable template validation by creating the quote with a status of PENDING and introducing a delay before updating it to PAID. This design prevents miners from claiming the ehash immediately and decouples block template validation from the highly time sensitive pool role operations related to accepting shares.

I think this will be increasingly important as Hashpool matures and we start developing the proof of liabilities protocol, which matches accepted shares (including block templates) to issued ecash.

Current Flow

  1. Pool receives mining share submission
  2. Pool verifies proof-of-work
  3. Pool creates mint quote with status PAID
  4. Wallet can immediately mint ehash tokens

Proposed Flow for Block Template Validation

  1. Pool receives mining share submission
  2. Pool verifies proof-of-work
  3. Pool creates mint quote with status PENDING
  4. Pool pushes template verification task to Redis queue
  5. Auditor role validates the associated block template asynchronously
  6. Auditor role updates quote to PAID/FAILED
  7. Wallets periodically mint ehash for all PAID quotes

Benefits

  • Decoupling: template validation can be done in a separate process from the pool role without being subject to the pool role's strict efficiency and reliability requirements
  • Persistence: Tasks survive service restarts
  • Observability: Task queue provides metrics and monitoring
  • Scalability: Multiple worker threads can process block template validation tasks
  • Error Handling: Failed templates can be moved to a dead letter queue for later analysis

Technical Implementation

  • Add PENDING state to MintQuoteState enum
  • Create Redis task queue schemas for template validation requests/responses
  • Implement mint-side polling task to process validation results
  • Extend pubsub notifications for quote state changes

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