Bitcoin Mining

Back when the Pentium 4E "Prescotts" were causing an outrage in the computer modding community for notoriously overheating, and around when Steve Jobs failed to deliver on his promise of 3GHz from the G5, I was an avid folder. Folding is the term for running a distributed computing program on your computer, Folding@Home, that donates your spare CPU cycles to help Stanford learn more about diseases created from misfolded proteins. This project became and is still hyper-competitive. People join folding teams, install it on as many computers as they can find and let them run 24/7 in hopes of completing many WUs (workunits) and ranking higher.

How does this relate to the title? Well I have recently been playing around with bitcoin mining and I can't help but draw similarities between the two. Just like folding you must run a program that uses (lots of) your computer resources to generate, or mine, bitcoins. But that's where the similarities end. So what exactly is bitcoin? A recently published Slate article, My Money Is Cooler Than Yours, has the scoop:

Bitcoin is a peer-to-peer currency, meaning it is not issued by a central authority, like the dollar or yen. The money supply grows as the network grows and will max out at about 21 million bitcoins. But right now, you can purchase them online on the Mt. Gox currency exchange or an over-the counter market. They do not exist in physical form—only electronically, owned and traded by members of a special, anonymous peer-to-peer network. No third-party intermediary, such as a payment processor or a bank, needs to keep tabs on or process the electronic transactions. The network itself does, with each participating computer running a special, secure program that ensures no user can spend a coin twice or create new money out of thin air.

GigaOm published a similar exploratory piece about Bitcoins: How Bitcoin Wants to Make Money Even More Virtual. As did TechDirt with Can Bitcoin Really Succeed Long Term? Bitcoin is just getting mainstream media attention. I briefly mined for bitcoins some six months ago but didn't really "get it" and the big vision, so I stopped mining. If only I had held onto my bitcoins instead of deleting the app!

Bitcoin app osx
My massive bitcoin empire is worth... ~14 cents. And I got those 0.02BTC from the bitcoin faucet. Been mining for all of 2 days on my slow MacBook Pro.

Unlike Folding@Home where you more or less knew how much progress you were making, mining bitcoins is fairly random. You might generate your first bitcoin in one hour or it may take 3 weeks. It depends if you are among the first in the community to solve that block with a hash; the more hashes your computer can generate, the better.

It's important to realize that block generation is not a long, set problem (like doing a million hashes), but more like a lottery. Each hash basically gives you a random number between 0 and the maximum value of a 256-bit number (which is huge). If your hash is below the target, then you win. If not, you increment the nonce (completely changing the hash) and try again.

Bitcoin Wiki

It becomes harder to solve a block as the total computational power of the network increases. As such, bitcoin miners often join pools where the pot is shared (depends on the pool but often in relation to your contributed power). Currently a single bitcoin can be sold on one of several bitcoin exchange websites for around 7. You can buy bitcoins or generate them yourself to then spend online. But wait.. how do you spend them?

I'm only skimming the surface about bitcoin mining and its specifics, but one thing is certain: bitcoin has some pretty lofty goals. If this is to be a viable virtual currency people must begin accepting them as currency. And that's exactly what is happening. Take for example this software developer that has begun accepting bitcoins for payment. And there are more and more directories of bitcoin-accepting service providers popping up; everything from online stores to flash games and web hosts.

To be frank, I'm not 100% on the viability of bitcoin as a currency but I am fascinated about the geeky bits: optimizing computers to mine bitcoins and achieving higher and higher Mhashes/sec rates. Lots of folks are working on custom mining setups to get the most out of their hardware.

While not cost effective in anyway at the moment, I'm currently tinkering around with bitcoin mining on an Amazon EC2 GPU Cluster. Below is completely unoptimized bitcoin install running on a cg1.4xlarge instance with 22GB of RAM and 2 NVIDIA Tesla “Fermi” M2050 GPUs. With some tweaking it's possible to get it up to around 140Mhashes/sec — still a far cry from the 800Mhashes/sec capable from an ATI 5970 Radeon HD video card or overclocked dual 5870s.

[ec2-user@ip-XXX-XXX-XXX-XXX 64] ./bitcoind getinfo
    "version" : 32100,
    "balance" : 0.00000000,
    "blocks" : 125020,
    "connections" : 78,
    "proxy" : "",
    "generate" : true,
    "genproclimit" : -1,
    "difficulty" : 244139.48158254,
    "hashespersec" : 16347145,
    "testnet" : false,
    "keypoololdest" : 1305759224,
    "paytxfee" : 0.00000000,
    "errors" : ""

I think a commenter on TechDirt put it best:

Bitcoiners don't know if Bitcoin will succeed but they're working hard on making bitcoin success.

Thoughts on bitcoin? I'm still pretty new to bitcoin and have a lot to learn. This post was just to share my enthusiasm for a budding new technology trend and virtual currency. I have yet to join a mining pool, but that seems to be the best way to get started, unless you happen to have a cluster of your own computers with beefy GPUs.