Before we begin the configuration of the stratum proxy software, now would be a good time to summarize the progress we have made so far:
At this point we should have an assembled ASIC rig with 1-10 boards seated and configured for our backend network. Each board should feature a unique IP address that is of the form 192.168.2.x where x is a value greater than or equal to 200 and a netmask value of 255.255.255.0.
Each of our boards should be connected via Ethernet cable to a multiport switch large enough to accommodate all of our mining boards plus an Ethernet connection coming from our stratum proxy host's _second_ Ethernet port. From our stratum proxy host, this interface should have an IP address of the form 192.168.2.2 (or anything less than 200 and greater than or equal to 2 really) with a netmask of 255.255.255.0.
The first Ethernet port on our stratum proxy host should be connected to our internet accessible home network. This interface should have an IP address and netmask that is compatible with the settings of the internet router.
On the stratum proxy host, the first interface will generally be the device eth0 and the second interface the device eth1, however depending upon your particular hardware configuration, your mileage may vary. For instance, should you choose to use a laptop as your stratum proxy host, you might use wlan0 (the wireless device) as one of your interfaces. In the end, the important feature is that the stratum proxy host should have two interfaces so that it can sit comfortably on two networks acting as the bridge between your mining network and your internet connected network. This will enable the proxy to 'talk' privately to the boards in your mining rig, while exchanging data with whichever pool you bind your processing to.
With these pieces in place, we can move on to configuring the stratum proxy host:
Configuring the Stratum Proxy Host:
Configuration of the stratum proxy host begins with downloading and installing the BFGminer program. This program is responsible for requesting work from the mining pool as well as aggregating and passing along the results from our ASIC mining rig.
You may find the latest version of BFGMiner here.
In fairness there are other programs that provide this function, however once built, I found BFGminer to be the easiest to use and the most stable. If you have adapted these instructions to work under Windows, you can use the precompiled windows binary (32 bit, 64 bit). If (as is the case with the author) you are using Linux as your mining platform, depending upon your distribution, you may need to build and install it from source code first.
If you are using a supported Linux distribution (as shown on the BFGminer web page) HOORAY! Simply follow the simple instructions provided to get your distribution's package manager to install the software for you and skip past the painful process that I'm about to detail below. If you find that you're going to have to build the package from its source code, buckle up and we will go through it step by step and hope for the best. In short, this is the painful part! However, I'm an old pro, and I'm sure that you're an attentive reader, so we'll struggle through it together although I can't help but to recall a saying that a dear friend once shared with me concerning such circumstances:
Nobody rides for free...
And with that let's build us a BFGMiner stratum proxy package!
If you have built software from source code before, much of what follows may seem like an exercise in worshipping at the Temple of the Obvious. If you can or have already built BFGMiner, you may skip to the section on configuration. If you are unfamiliar with building Unix software packages from source code, the first step will be to insure that you have all of the program development tools loaded into your operating system. Typically these tools will include your C compiler and linker as well as any libraries you may need to have installed prior to building the package.
The package manager (software for installing software) will vary depending upon your Linux distribution. If you are attempting this via BSD*nix, it may be different altogether (the differences of which lie far beyond the scope of this article). Generally amongst Linux distributions, the flavors are roughly divided between the Debian and Redhat based distributions. As a result, where applicable, you can expect your package manager to be either APT or YUM respectively. Armed with the appropriate package manager, knowledge of the actual package names is the only remaining thing required to setup the build environment we'll need to compile BFGMiner.
To install the build environment using APT on a Debian based system, AS THE ROOT USER use the command:
apt-get install build-essential
To install the build environment using YUM on a RedHat based system, AS THE ROOT USER use the command:
yum groupinstall "Development Tools"
For RedHat based distributions, the names will be slightly different (of course, nothing can be easy right?):
Install packages under RedHat based distributions as follows:
It is important that all of these packages be installed prior to attempting to build BFGMiner from source code, especially libmicrohttpd which we will use to enable proxy service. Once the prerequisite software has been installed, we are clear to extract the source code from the BFGMiner package we downloaded earlier using the following commands:
mkdir bfg
cd bfg
unzip /path/to/downloaded/source_code.zip
./configure
If everything configures without error (it is of utmost importance that everything does prior to attempting the next step), you'll be ready to build the software package using the command:
make
What follows should be screens and screens of compiler output. If you see the message "Warning" at this stage, you may ignore it. Discrepancies between Linux distributions occasionally show up as slight differences between the include library files used to compile and link executable files. On the other hand, if you see "Error" messages, you'll have to revisit checking to see that all of the prerequisite software is installed, followed by potentially re-running the ./configure command.
Unfortunately, this part of the process involves some level of trial and error. To the extent that you find yourself unable to build BFGMiner from its sources, the problem will almost always be a case of missing prerequisites, either in the form of missing libraries or libraries that are present but of incompatible versions.
Once the make completes, the BFGMiner program will be ready to use. Copy the BFGMiner executable into your /usr/local/bin directory.
At this point, to make your new setup easier to use, using 'vi' or your favorite text editor, you can copy the following lines into your own customizable shell script (This one works for slush):
# slush.sh - script for configuring proxy host to mine with slush
/usr/local/bin/bfgminer -G --http-port 8334 -o stratum+tcp://stratum.bitcoin.cz:3333 -u your-worker -p your-password
DP
Building and Installing the BFGMiner Software Package:
If you have built software from source code before, much of what follows may seem like an exercise in worshipping at the Temple of the Obvious. If you can or have already built BFGMiner, you may skip to the section on configuration. If you are unfamiliar with building Unix software packages from source code, the first step will be to insure that you have all of the program development tools loaded into your operating system. Typically these tools will include your C compiler and linker as well as any libraries you may need to have installed prior to building the package.
The package manager (software for installing software) will vary depending upon your Linux distribution. If you are attempting this via BSD*nix, it may be different altogether (the differences of which lie far beyond the scope of this article). Generally amongst Linux distributions, the flavors are roughly divided between the Debian and Redhat based distributions. As a result, where applicable, you can expect your package manager to be either APT or YUM respectively. Armed with the appropriate package manager, knowledge of the actual package names is the only remaining thing required to setup the build environment we'll need to compile BFGMiner.
To install the build environment using APT on a Debian based system, AS THE ROOT USER use the command:
apt-get install build-essential
To install the build environment using YUM on a RedHat based system, AS THE ROOT USER use the command:
yum groupinstall "Development Tools"
For their respective distributions, these commands will typically install the C compiler, libraries, and include files needed to compile most computer software packages from source code. Unfortunately, BFGMiner is not so average in that we will need to install additional libraries before we'll be able to successfully compile this package. From the README file included with the source code package these are (Debian):
autoconf automake libtool pkg-config libcurl4-gnutls-dev
libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev
libevent-dev libmicrohttpd-dev hidapi
Install packages under Debian based distributions as follows:
apt-get install autoconf automake libtool pkg-config libcurl4-gnutls-dev\ libjansson-dev uthash-dev libncursesw5-dev libudev-dev libusb-1.0-0-dev\
libevent-dev libmicrohttpd-dev hidapi
For RedHat based distributions, the names will be slightly different (of course, nothing can be easy right?):
autoconf automake libtool pkg-config libcurl libcurl4 uthash ncurses\ ncurses-devel libudev libusb libevent libmicrohttpd hidapi
Install packages under RedHat based distributions as follows:
yum install autoconf automake libtool pkg-config libcurl libcurl4 uthash ncurses ncurses-devel libudev libusb libevent libmicrohttpd hidapi
It is important that all of these packages be installed prior to attempting to build BFGMiner from source code, especially libmicrohttpd which we will use to enable proxy service. Once the prerequisite software has been installed, we are clear to extract the source code from the BFGMiner package we downloaded earlier using the following commands:
mkdir bfg
cd bfg
unzip /path/to/downloaded/source_code.zip
./configure
If everything configures without error (it is of utmost importance that everything does prior to attempting the next step), you'll be ready to build the software package using the command:
make
What follows should be screens and screens of compiler output. If you see the message "Warning" at this stage, you may ignore it. Discrepancies between Linux distributions occasionally show up as slight differences between the include library files used to compile and link executable files. On the other hand, if you see "Error" messages, you'll have to revisit checking to see that all of the prerequisite software is installed, followed by potentially re-running the ./configure command.
Unfortunately, this part of the process involves some level of trial and error. To the extent that you find yourself unable to build BFGMiner from its sources, the problem will almost always be a case of missing prerequisites, either in the form of missing libraries or libraries that are present but of incompatible versions.
Once the make completes, the BFGMiner program will be ready to use. Copy the BFGMiner executable into your /usr/local/bin directory.
At this point, to make your new setup easier to use, using 'vi' or your favorite text editor, you can copy the following lines into your own customizable shell script (This one works for slush):
#!/bin/sh
# slush.sh - script for configuring proxy host to mine with slush
/usr/local/bin/bfgminer -G --http-port 8334 -o stratum+tcp://stratum.bitcoin.cz:3333 -u your-worker -p your-password
The important parts of this script are the --http-port nnnn which is the place where our ASIC erupter boards will find our proxy, and the -o, -u, and -p options which identify the URL of the mining pool we want to work with, our worker's login id for the pool, and the worker's password associated with our login id. Obviously, you may substitute other URLs in the -o option to mine for other pools. The strength of this set up is that only the stratum proxy need know anything about the outside mining pool. Our ASIC Erupter Blades only need to know about the proxy. They could care less about the world beyond our stratum proxy host and are content to do their work without concern.
In the next and final installment of this series, we will bring everything we've covered together so that you can get up and mining.
Until next time,
DP
donation btc: 1HSFkXyLqPv1iHTjcRRw9DgiFb7SftiCxA