Sunday, December 15, 2013

And now for something completely different: Mining Bitcoin with your Power Mac for fun and (not much) profit

Now that I've got some time over the holidays, the Firefox 26 port continues. Don't expect an unstable from this release (I'm not even done with JavaScript, though I'm almost done); it's just to keep things working until 29, when Australis descends like a ravenous harpy from the skies. At that point there will either be a 29-aurora or a hasty retreat.

Six months ago, Ars Technica ran a little article on Butterfly Labs' small Bitcoin miner. (For those of you unfamiliar with Bitcoin ("BTC"), this blog won't do it justice, but Wikipedia has a good overview.) The heart of "mining Bitcoin" is repeated, exponentially scaling computations to verify transactions based around the SHA-256 algorithm, for which participating computing resources receive a share of the fixed total number of Bitcoins themselves. Mining used to be done on regular general computing hardware, but this moved to GPUs as the profitability dropped, and now anyone who wants to seriously mine Bitcoin is now on dedicated ASIC hardware that simply computes SHA-256 hashes over and over as fast as possible. There are USB block erupters that generate around 300-400 MH/s (that's million hashes a second), this small BFL BitForce miner in the Ars article is a 5 GH/s miner (five billion per second), and the 28nm ASICs due in early 2014 are now in the 1-2 TH/s (trillion) range.

Bitcoin is highly speculative because there is no guarantee it will hold current value or even hold any value -- so please don't even think about BTC exchange unless you're good with obscenely high risk components in your investment portfolio. Furthermore, exchanges routinely fail, taking customer assets with them, and a large holder cashing in their hoard (Satoshi?) is likely to put the exchange price in the toilet. At the time the Ars article came out they were trading for around $130 per BTC, and I figured that a $274 investment to pick one up wasn't much money (to me) to be out if the company folded or the currency faded. I did a couple of tests on the G5 to make sure I could compile the software and it appeared to work (with CPU mining, at a pathetically low yield -- more later), so I pre-ordered one and then promptly forgot about it.

Almost six months passed. On Friday, a nondescript box arrived. It was the miner.

This particular Bitcoin miner connects over USB and appears as a serial port to the Mac. It uses standard FTDI serial drivers, which work just fine with 10.3 and 10.4 PowerPC. It draws about 35W under load, but because it requires a small amount of work from the G5 to keep it busy, I'm estimating its overall power impact at about 50W. Impressively, bfgminer says it's actually averaging around 5.6 GH/s, a nice boost over its stated capacity. The G5 is on 24/7 anyway to allow me to access files and run remote computing jobs, so it's no big deal to let the G5 run the miner also. Some people have assigned a Raspberry Pi to this task, so it's clearly not something that requires a heavy-duty computing controller.

Okay, you don't care about that. You care how much money it's making. Right now, Bitcoin trades at around $850/BTC. Bitcoin mining becomes exponentially more difficult as more BTCs enter circulation to avoid depleting the currency early, which is part of why the value increased from six months ago (simple supply and demand). At the current difficulty and exchange rate, the machine makes about $2.50/day. Given the slope of the curve, the estimated payback time is in the order of 5-6 months (this is imprecise because the difficulty is not totally predictable), but because of its very low power usage, it still remains fractionally profitable even down to making just 5 cents a day. I'm not going to be supermodels-and-Learjets rich, but it will probably make me at least a couple hundred dollars in overall profit.

However, this doesn't help you much because BFL doesn't make these things anymore, and the block erupters you buy on eBay are more than 10 times slower. A 333 MH/s USB block erupter makes about $0.15/day right now, and if one sells for $50 and the difficulty is always increasing ... well, you do the math. One argument against buying this kind of specialized hardware is that it's more profitable to make the mining devices than it is to do the actual mining. That is quite possible. ;) These little MH/s block erupters are easy to get because they don't really generate much money anymore; the heavy duty rigs take months to preorder and by then the difficulty has gone up even further.

But since we run web browsers on decade-old computers, we're clearly not here because we're excessively practical, so let's say you either want to just play around with Bitcoin or you got a block erupter or a proper ASIC miner from a generous friend. You'll need a wallet and a pool, for which the Ars Technica article has some suggestions, and then you'll need the software. Linux Power Mac users have it easiest; you can probably find a pre-built package for bfgminer or cgminer, both of which will run almost any hardware Bitcoin mining device. For 10.5 users, there is a port of cgminer that will apparently run on PowerPC with a basic interface. I'd be interested to hear if it works.

For 10.4, the situation is harder. I wasn't able to get cgminer to build at all, though I suspect I'm merely missing some of its prerequisites, and although the most current version of bfgminer can build with minor changes (3.8.0) it doesn't seem to work. Fortunately, the version of bfgminer (3.1.1) I hacked into building "back then" does work fine with the BFL miner, and as long as you have libusb installed from MacPorts or Fink it will work with most USB block erupters also. It emits a rather alarming number of hardware errors, but I suspect these are spurious because the mining pool I'm working with accepts my shares without comment and the mining pool's estimated GH/s rating matches what bfgminer is reporting. In about a week I should get my first 0.02BTC payout. So I guess that was worth my $274.

What if you just want to prospect a little with your own hardware, just for laughs? GPU mining is probably impossible on PPC OS X, though it might work on Linux (although I don't think any GPU that shipped with a Power Mac is OpenCL-capable), but you can use either software package to do CPU mining and bfgminer at least does have AltiVec support. The problem is you won't get very far even compared to a "basic ASIC" setup: a 600MHz G3 ekes out a pathetic 0.14 MH/s; a 1.67GHz 7450 G4 struggles to maintain 1.29 MH/s (source; recall that our miner is 5 GH/s == 5000 MH/s). Both are reasonably power-efficient computers, but neither will do their work in 35 or even 50 watts. Speaking of which, using the G5 for this is almost comically inefficient: my quad manages, with altivec_4way and four CPU threads, a comparatively impressive 6.7 MH/s but requires almost 300 watts of power to do it and pegs all four cores, rendering the computer essentially useless for any other purpose.

So, uh, keep clicking on the Google ads on this blog if you want to financially support this project. ;)


  1. Apple is apparently working on a JIT compiler for CSS selectors:

    1. Fascinating, though the commit doesn't shed much light.


Due to an increased frequency of spam, comments are now subject to moderation.