Stratum Work: A Tool for Real-Time Bitcoin Mining Pool Analysis

Stratum Work: A Tool for Real-Time Bitcoin Mining Pool Analysis

Understanding the dynamics of mining pools is crucial for enthusiasts, analysts, and developers alike.

Enter Stratum Work, a web application designed to stream and visualize real-time mining pool stratum messages, offering a transparent window into the operations of Bitcoin mining pools.

Created by GitHub user bboerst, Stratum Work is an open-source project inspired by the innovative ideas of 0xB10C.

Let’s explore why Stratum Work was created, what it does, and how it empowers users to analyze Bitcoin mining activity.

ON BITCOIN is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Why Was Stratum Work Created?

Stratum Work was born out of a desire to make the inner workings of Bitcoin mining pools more accessible and understandable.

The idea originated from a thread by 0xB10C, who highlighted the potential of analyzing stratum messages to gain insights into mining pool operations.

Building on this concept, bboerst developed Stratum Work to democratize access to this data, transforming raw stratum messages into a user-friendly, real-time visualization tool.

The project aims to provide a trustless, transparent platform where anyone can monitor and analyze mining pool activity without needing deep technical expertise or proprietary tools.


Sponsored by Bull Bitcoin, a Bitcoin only Exchange that helps you Buy & Sell Bitcoin, DCA + pay your bills with Bitcoin.


The motivation behind Stratum Work

Transparency

By streaming raw stratum messages and processing them client-side, Stratum Work ensures users can verify data independently, fostering trust in the insights provided.

Accessibility

The web-based interface and open-source nature of the project make it easy for a broad audience—miners, researchers, and developers—to explore mining pool dynamics.

What Is Stratum Work For?

Stratum Work is a specialized tool designed to capture, process, and display real-time mining work notifications from Stratum-based Bitcoin mining pools.

It serves as both an analytical and educational resource, enabling users to:

Monitor Mining Activity

View live mining.notify messages, which contain block templates that miners work on, including details like job IDs, previous block hashes, and coinbase transactions.

Analyze Pool Behavior

Understand how different mining pools operate, including their block construction strategies and transaction selection processes.

Perform Trustless Analysis

Process raw data client-side to ensure transparency and eliminate reliance on server-side interpretations.

Access Historical Data

Store and retrieve mining data via MongoDB integration for deeper historical analysis.

Build Custom Integrations

Use the raw data stream from the /api/stream endpoint to create alternative visualizations or integrations.

How Does Stratum Work Function?

Stratum Work is built on a modular architecture that ensures efficiency, scalability, and transparency. Here’s a breakdown of its core components and data flow:

Architecture Overview

Collector

Connects to Bitcoin mining pools via the Stratum protocol, captures mining.notify messages, stores them in MongoDB, and forwards them to RabbitMQ for real-time processing.

Here is a JSON example of a mining.notify message.

{
    "id": null,
    "method": "mining.notify",
    "params": [
        "00000001",
        "4d16b6f85af6e2198f44ae2a6de67f78487ae5611b77c6c0440b921e00000000",
        "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff20020862062f503253482f04b8864e5008",
        "072f736c7573682f000000000100f2052a010000001976a914d23fcdf86f7e756a64a7a9688ef9903327048ed988ac00000000",
        [],
        "00000002",
        "1c2ac4af",
        "504e86b9",
        true
    ]
}

Backend

Processes Bitcoin blocks from a Bitcoin node, identifies which pool mined each block by analyzing coinbase transactions, and provides block data to the web application.

Web Application

Consumes messages from RabbitMQ and displays them in a customizable, interactive table with real-time updates. It also performs client-side processing for trustless visualization.

Data Flow

Multiple collector instances connect to different mining pools, capturing mining.notify messages.

Storage and Streaming

Each message is stored in MongoDB for historical analysis and published to RabbitMQ for real-time streaming.

Visualization

The web application consumes RabbitMQ messages and renders them in a user-friendly interface, with client-side processing for decoding and formatting.

Block Analysis

The backend processes new Bitcoin blocks, matching them to pools based on coinbase transaction data.

Key Technical Features

Stratum Protocol

Stratum Work leverages the Stratum protocol’s mining.notify messages, which include critical block template details like job ID, previous block hash, coinbase transaction, merkle branches, and difficulty target.

Trustless Processing

All decoding, formatting, and visualization occur in the client’s browser, ensuring users can verify data independently.

Real-Time Streaming

The /api/stream Server-Sent Events (SSE) endpoint delivers raw data for custom integrations.

Client-Side Processing

The web application reconstructs coinbase transactions, extracts ASCII scripts, analyzes outputs, and calculates fee rates (see web/utils/formatters.ts and web/utils/bitcoinUtils.ts).

Backend Block Matching

The backend identifies pool origins of mined blocks by analyzing coinbase transactions (see backend/main.py:815-890).

Features for Users

  • Real-time display of mining.notify messages with customizable table columns.
  • Light and dark mode for user comfort.
  • Live and historical data views for flexible analysis.
  • MongoDB integration for robust data storage.
  • Trustless processing to ensure data integrity.
  • Raw data access via the /api/stream endpoint for developers.
  • Docker-Compose support for easy local development and testing.

Getting Started with Stratum Work

For those eager to explore Stratum Work, setting it up locally is straightforward thanks to its Docker-Compose configuration. Here’s how to get started:

Prerequisites: Install Docker and Docker Compose.

Clone the Repository:

bash
git clone https://github.com/bboerst/stratum-work.git
cd stratum-work

Customize Collectors: Edit the docker-compose.yml file to add or modify collector services, specifying pool names, URLs, and credentials.

Build and Run:

bash 
docker-compose up --build

This starts RabbitMQ, MongoDB, collectors, and the web application, accessible at http://localhost:3000.

View Logs: Monitor logs in the terminal to track pool connections and application events.

Stop Services:

bash
docker-compose down

Use docker-compose down -v to remove the MongoDB volume if needed.

Why Stratum Work Matters

Stratum Work fills a critical gap in the Bitcoin ecosystem by providing a transparent, accessible tool for analyzing mining pool activity.

Its trustless design, real-time capabilities, and open-source nature make it a valuable resource for anyone looking to understand the mechanics of Bitcoin mining.

By building on 0xB10C’s original idea, bboerst has created a platform that not only educates but also empowers users to explore and innovate within the Bitcoin mining space.

Ready to dive in?

Visit the Stratum Work GitHub repository to explore the code, set up your own instance, or contribute to this exciting project.

Whether you’re monitoring live mining notifications or building custom integrations, Stratum Work offers a front-row seat to the fascinating world of Bitcoin mining pools.


Sponsored by Bull Bitcoin, a Bitcoin only Exchange that helps you Buy & Sell Bitcoin, DCA + pay your bills with Bitcoin.


ON BITCOIN is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.