wetblanketcc / aiostratum_proxy

aiostratum_proxy is a modular/extensible stratum protocol mining proxy built using Python3's asyncio.
MIT License
29 stars 16 forks source link

aiostratum_proxy is a Stratum Protocol proxy (ie cryptocurrency/mining) built using Python3. It was built to be a modern, code-concise, extensible, and fast replacement for existing aging Stratum Protocol proxy solutions & implementations.

Donations

I built this on my own time, outside of my day job. If you find this mining proxy useful, donate to help continue development. I value my time.

Installation

Installation is simple:

pip install aiostratum-proxy

However, for an isolated and more robust installation, you should consider using Python virtual environments:

# this will create a directory 'containing' the Python3 virtual environment
python3 -m venv aiostratum_proxy

cd aiostratum_proxy

# this will install the aiostratum-proxy package
bin/pip install aiostratum-proxy

# verify the installation by checking the package version
bin/aiostratum-proxy --version

Usage

Installation creates a new command-line shortcut called aiostratum-proxy; it has built-in command-line help, just run:

bin/aiostratum-proxy --help

A config file is needed for the proxy to run; you can generate one:

bin/aiostratum-proxy --generate-config > proxy-config.yaml

Open and edit the generated proxy-config.yaml in a text editor. The config file's syntax is YAML (here's a good guide to YAML).

To run aiostratum-proxy, pass it your edited config file:

bin/aiostratum-proxy --config proxy-config.yaml

Supported Algorithms/Coins

aiostratum-proxy was designed to be modular and extensible when it comes to coin and algorithm support. This is done via miner+pool protocol module pairs (more on this below).

Current support includes:

As you can see, it is possible for a protocol implementation (ie. both the worker & pool sides) to support multiple coins, assuming they share some common ancestry or have heavily borrowed technical decisions.

Add Support for New Coins & Algorithms

The terms 'Stratum' and 'Stratum Protocol' are used broadly (perhaps too much so) in the cryptocurrency ecosystem. The concept behind the Stratum protocol started with the specific desire to improve the efficiency of Bitcoin mining pools.

In time, the rise of altcoins demanded a similar approach to managing the communications between miners and pools. For whatever reason, most altcoins have tweaked the original Stratum spec to their needs, borrowing and learning from prior mistakes.

To add support for a new coin or algorithm, there are two options:

  1. Use an existing protocol implementation and tweak; note that this means if there are future changes, it may have cascading impacts (see the Equihash protocol pair as an example, it is based off of the Stratum protocol pair)
  2. Create a new protocol pairing by implementing both BasePoolProtocol (to handle connections to pools) and BaseWorkerProtocol (to handle incoming miner connections)

For example, if you were implementing Monero support:

  1. Create a new Python module with the Monero 'worker' and 'pool' protocol class implementations
  2. Add the new Monero worker/pool classes to your proxy config file
  3. You will need to ensure your Python module is visible within PYTHONPATH to use it within your proxy YAML config file
  4. Consider submitting it as a pull request to aiostratum_proxy! If so, you would place the new module alongside the existing Equihash implementation at aiostratum_proxy.protocols.monero

Future Considerations

Community involvement is appreciated. Code review, pull requests for bug fixes & new protocols, reporting issues, spreading the word - all appreciated.

TODO:

Community feedback on the following is appreciated.

Related & Informative Links

  1. Stratum Protocol Specification
  2. Stratum Protocol Specification Draft
  3. Stratum Protocol Bitcoin Wiki Page
  4. Original Bitcointalk.org Stratum Announcement
  5. Follow-on Bitcointalk.org Stratum Discussion