Git Product home page Git Product logo

aiostratum_proxy's Introduction

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.

  • Requires Python 3.5 or greater (built with asyncio using async/await syntax)
  • Extensible: easily implement new coin/algorithm 'stratum-like' protocols as dynamically-loaded, external Python3 modules (via config file)
  • Can run multiple proxies at the same time (ie. mine different coins on different pools)
  • Each proxy supports up to 65536 miner connections (per pool connection), each mining a separate nonce space (dependent on miner support)
  • Supports plaintext and secure connections (ie. TLS/SSL) for both incoming miner connections and outgoing pool connections
  • Plain socket transport only (ie. not JSONRPC over HTTP, HTTP Push, or HTTP Poll); this is the defacto standard in the cryptocurrency space

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.

  • BTC: 1BS4QYAFiya4tsjyvHeY945biKnDj6bRA4
  • LTC: LTN1LPGnJjHMKq4DcuQYifQgLfT4Phmn9d
  • ETH: 0x4B005e68D323bdABD8eeD1D415117Ff1B57b3EC5
  • BTCP: b1CACK65UTwzmHGw2VvyozdPsRLMb8utGLg
  • ZCL: t1eoqTqyatJzL2rErW83waZLQHZLKuipMbi

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:

  • any coin based on Equihash (ZCash, ZClassic, Bitcoin Gold, Bitcoin Private, etc):
    • miner module: aiostratum_proxy.protocols.equihash.EquihashWorkerProtocol
    • pool module: aiostratum_proxy.protocols.equihash.EquihashPoolProtocol
  • (EXPERIMENTAL/UNTESTED/probably not working just yet) Bitcoin (and related coins):
    • miner module: aiostratum_proxy.protocols.stratum.StratumWorkerProtocol
    • pool module: aiostratum_proxy.protocols.stratum.StratumPoolProtocol

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.

  • More coin/algo support
  • Complete mining.set_extranonce support
  • Consider additional authentication improvements (currently miners aren't authenticated)
    • authenticate miners locally within proxy via config
    • authenticate miners via passthru to pool; would require per-pool mappings of username/password for fallback pools in config?
  • Consider immediate reply to miner share submissions instead of waiting for pool response
  • HAProxy PROXY protocol support

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

aiostratum_proxy's People

Contributors

wetblanketcc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aiostratum_proxy's Issues

Find out why fresh install cannot read configuration

Describe the bug
Fresh install cannot read configuration when not using Python 3.7.

To Reproduce
Steps to reproduce the behavior:
Using Python other than 3.7 and generate config, then using the configuration.

Expected behavior
Show "CRITICAL - Unable to load configuration file (aiostratum_proxy.application:132)"

System/Environment:

  • OS: Windows or Linux
  • Python3 but not 3.7
  • App Version 1.1

Fix:
The configuration generated is UTF16 LE encoded with CRLF.
Save the file as UTF8 and LF, every thing works perfectly.

ZEC Nicehash support

Hello Dev team,
Is it possible to add ZEC Nicehash pools support to this proxy?

handle_mining_get_hashrate doesn't have miner address (or correct one)

Describe the bug
Using pycharm debug tool, params variable for handle_mining_get_hashrate method only has :
0) hash rate,

  1. Random value that isnt my miner address ('0x7d74261a70efc26bcadd2ddc7353a720477861c74de671a69753d1dbf3d814a7')
  2. worker name

To Reproduce
I used zilminer with stratum paramters to connect to my system. Waited for a few seconds for it to send the handle_mining_get_hashrate method.

Expected behavior
I was hoping for the correct miner address.

System/Environment:

  • Ubuntu 16.04
  • Python3.7 version

Can't compile aiostratum-proxy

Hi,
Could you please help to solve this issue:

[root@zecproxy aiostratum_proxy]# pip --version
pip 18.0 from /usr/lib/python3.4/site-packages/pip (python 3.4)

[root@zecproxy aiostratum_proxy]# bin/pip install aiostratum-proxy
Collecting aiostratum-proxy
Could not find a version that satisfies the requirement aiostratum-proxy (from versions: )
No matching distribution found for aiostratum-proxy
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@zecproxy aiostratum_proxy]#

fresh install cannot read configuration file whatsoever

Describe the bug
after a fresh install of the package using newest version of python, when running
aiostratum-proxy -c config.yaml
I get : 2019-06-05 20:06:08,722 CRITICAL - Unable to load configuration file.

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A syntax error if its a problem with the config file, a more specific error if the file cant be found and at what location the program is looking.

System/Environment:

  • OS: windows 10
  • Python3 version 3.7.3
  • App Version 1.1

Additional context
The installation tutorial, while concise, does not help the lesser learned people like myself. Im a java guy, not python. I have tried moving the config file to various locations, including the same folder(s) as the proxy's package and such. no luck. I would think that the file needs to be in the same folder but with virtual environments and such I am not sure. when i generate the file in the first place it seems to just dump it wherever i am currently in my shell. no specification in guide as to where to put it. and this seems to be the only way i have to reach out to someone

x17 support

Hello,
are there plans to support x17 algo proxy?

XMR Support

Great Work. Can you add XMR / Monero Support? Pool: SupportXMR.com
Thanks.

ETHhash

Hi.
Its possibel to add ETH HASH.
thank.

AttributeError: 'NoneType' object has no attribute 'replace'

When i run aiostratum-proxy --version i get this error

Traceback (most recent call last):
  File "/usr/local/bin/aiostratum-proxy", line 11, in <module>
    load_entry_point('aiostratum-proxy==1.1', 'console_scripts', 'aiostratum-proxy')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 487, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2728, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2346, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/local/lib/python3.7/dist-packages/aiostratum_proxy-1.1-py3.7.egg/aiostratum_proxy/__init__.py", line 6, in <module>
AttributeError: 'NoneType' object has no attribute 'replace'

I am using Debian 9 and Python 3.7.2+
Also tried another server with Debian 9, but Python 3.5.3 and same error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.