Posted on 1 Comment

Cloud Mining and Network Centralization Explained

This post is a follow up to my Bitcoin Mining 101 post where I covered mining basics. Here I’m going to talk about a few more topics related to mining, most of which have an impact on network centralization and scalability. Those of you who have no plans to start mining should still find this post relevant to the future of bitcoin.

Cloud Mining

CloudHashingIn part one I talked about pooled mining and how it arose as a response to the extreme variance of solo mining. A potentially even more convenient solution is cloud mining. Instead of purchasing and maintaining the hardware yourself, you can essentially outsource that responsibility to a cloud mining company. These firms will purchase and maintain the hardware themselves, sometimes fabricating it themselves as well, and sell you a portion of the hash rate. For example, CloudHashing.com (seen to the right) is currently selling 250 Gh/s (gigahashs per second) for $1,000. If you purchase the Gh/s from them you are entitled to any bitcoins earned with those Gh/s. According to CloudHashing the $1,000 contract earned .29 BTC in June or about $170.

If you extrapolate $170/mo out for 12 months you get a ROI on that contract of about 100%. Unfortunately, it isn’t that easy. If you recall from part one, the total hash rate in the network is climbing rapidly.

hashrate

What this means is that the return on your cloud mining contract is going to decline pretty sharply from month to month. So just like miners who operate their own hardware, you would need to forecast the network hashrate into the future to get an estimate of what kind of return you would get on your mining contract.

Pros and Cons

As I mentioned, a major benefit of going the cloud mining route is you don’t have to operate your own hardware. Not only does this mean that people who lack the technical skills can participate in mining but you don’t have to deal with the frustration and delays of trying to acquire hardware in a timely manner. Neither do you have to worry about permanent brain damage from heat stroke when you have your miners running in your bedroom in the summer (I’m half kidding).

Additionally, mining hardware isn’t very liquid. If you decide you want to get out of mining, you usually have to try to dump your used hardware on eBay or with a friend if you have any who are interested. Mining contracts, on the other hand, are typically easier to sell. Some cloud mining companies have set up their own markets for trading cloud mining contracts. That’s an extra benefit you don’t have if you operate the hardware yourself.

But, there are some downsides to cloud mining as well. In theory you should be able to earn more by operating the hardware yourself since a portion of your return isn’t going to pay a third party to operate the hardware for you. In practice, I don’t know if this is true. Typically, large mining firms find it easier to acquire hardware from suppliers in a timely manner compared to individuals with limited resources and connections. So, all other things equal, running the hardware yourself should be more profitable, but I’m not sure all other things are equal. Perhaps a good case study could shed some more light here.

Finally, cloud mining does create some concerns about network centralization. Remember, the primary security proposition of Bitcoin is that no one person or group should be able to control more than 50% of the network hashing power. If that happens, either by a single person/group acquiring that much processing power or by separate groups colluding with each other, they could prevent transactions from confirming, double spend bitcoins, crowd out all legitimate miners, etc. In other words, it would prevent the network from being useful and would undermine confidence in the currency.

In an ideal world there would be 50,000+ individual miners, each with only a tiny sliver of the total hashing power. The existence of cloud mining, however, introduces large firms with a sizable portion of the network hashrate. It has been reported, for example, that GHash.io owns about 10% of the hashing power in the network as a result of their cloud mining operation. Unlike pooled mining for which there are theoretical solutions to the problem of centralization, there really isn’t anything stopping cloud mining companies from amassing large amounts of hardware. If you get a few cloud mining companies the size of GHash.io, they could easily collude and take over the network.

I say all this to give you something to consider if you do get into cloud mining. It’s best to go with firms that don’t own a large share of the network hashrate.

Block Size Issues

I’m going to switch gears a little bit and talk about a hot topic of late ― block size and relay times. For a while now Gavin Andresen has been working on implementing floating transaction fees into the bitcoin protocol. As it stands, miners have discretion to decide which transactions they include in their blocks and which they don’t. This implies they can set their own policies regarding how low of a transaction fee they will accept. Up until this point, however, wallets have no idea what these miner policies are and just use a hard coded default transaction fee. What this floating fee code will do is scan the block chain see how long it’s taking transactions to make it into blocks at different fees and feed that information to the user who can than use that information to decide on a fee.

In theory, so long as the fee is higher than cost to process and store the transaction on disk, profit maximizing miners should always include it in their blocks. So transaction fees should basically be negligible. However, that isn’t what we are seeing. The following is a chart compiled by Gavin after running a node and recording estimates once per day:

transaction fees

Basically it shows that transaction fees are non-negligible. What’s going on is that miners are intentionally keeping the number transactions in their blocks below the total number of outstanding transaction, foregoing the transaction fees from those additional transactions. Why would they do this? Essentially, the problem stems from situations where two miners solve in block at approximately the same time. When this happens, which ever block propagates the network quicker and reaches more nodes is more likely to be accepted earning the miner the block reward (approximately $15,000 at the moment).

As it happens, blocks which contain a smaller number of transactions propagate quicker than blocks which contain more. Rather than risk losing $15,000 for an extra couple bits in transaction fees, miners just accept a small number of transactions with the largest fees and reject the rest. This creates artificial scarcity where none exists and drives up transactions fees, eliminating part of Bitcoin’s competitive advantage in the process.

So what’s the solution? There have been a lot of ideas floating around but most of them revolve around relaying a fixed size header instead of a full block of transactions and defining some other method for acquiring the transactions in the block. Gavin alluded to something along these lines in a tweet the other day:

All in all this is a fairly serious issue. Failure to fix it will ruin one of Bitcoin’s primary value propositions. But fixing is requires a pretty drastic change to the core protocol, something which has the potential to damaging if implemented incorrectly and which requires a near consensus to implement.

My hope is it gets fixed sooner rather than later.

Original content by Chris, copyleft, tips welcome // < ![CDATA[
// < ![CDATA[
//

Posted on 1 Comment

Bitcoin Mining 101

Whenever I introduce new people to Bitcoin I tend to get asked quite a few questions about mining. What is it? Can anyone mine Bitcoin? What do I have to do to get started mining? Etc. In the next couple blog posts I’m going to answer these questions and hopefully give a fairly comprehensive intro to Bitcoin mining. Even if you don’t plan on mining yourself, chances are you’ll still come away with a good understand of what makes Bitcoin tick. So stay tuned!

What The Heck Is Mining Anyway?

BkqH8SQCcAASCSm

I think part of the problem we have when introducing people to Bitcoin is that we have all these confusing words that don’t accurately describe what’s going on. “Mining” is one of them. Bitcoin mining is essentially transaction validation. When transactions are broadcast to the peer to peer network, someone (or some computer) needs to verify that the transaction is valid and record it the public transaction database (the blockchain). That is essentially what “miners” do ― process and verify transactions and record them in the blockchain. They are rewarded for their efforts with newly created bitcoins (more on this in a little bit), which explains the origins of the term “mining”.

The process of verifying transactions is actually very easy to do. It only takes a computer a fraction of a second. Adding new transactions to the blockchain, however, is intentionally designed to be much more difficult. I’ve gone into much more detail on the reasons for this in past blog posts. To recap, trying to get millions of Bitcoin uses around the world to agree on a single version of the transaction database is no easy task. In fact, it’s a bit of miracle that it happens at all. The secret here is something called “proof of work”. The Bitcoin protocol requires that those wishing to add additional blocks of transactions to the blockchain provide proof that they expended a scare resource, in this case processing power. In this sense miners sort of “vote” with their processing power. But since there is a very real opportunity cost to expending processing power, miners will only want to “vote” for the transaction history which is supported by the majority of other miners. To vote for an alternative transaction history is to waste the processing power and risk losing reward. It’s this opportunity cost that ends up driving the network towards a consensus in regards to the transaction history.

The “work” part here consists of running the block header including a random nonce through a cryptographic hash function (SHA-256 to be exact) and checking to see if the function’s output meets the requirements set forth by the protocol. In this case the output needs to be less than a certain difficulty target. To put it another way, the output needs to start with a minimum number of zeros. For example:

000000000000002e9067f1cf7252333f7aeb619c89d220985a70ac0e015248e0

If the output does not meet the difficulty requirement, the nonce is incremented and header is run through the function again. This is done over and over until one miner in the network finds a nonce that produces a valid output. Consider the following example: Suppose we want to find a nonce such that when concatenated with “Hello, world!” produces a hash output that starts with at least three zeros. We would start with a nonce of zero and keep incrementing until we get the output we’re looking for.

"Hello, world!0" => 1312af178c253f84028d480a6adc1e25e81caa44c749ec81976192e2ec934c64
"Hello, world!1" => e9afc424b79e4f6ab42d99c81156d3a17228d6e1eef4139be78e948a9332a7d8
"Hello, world!2" => ae37343a357a8297591625e7134cbea22f5928be8ca2a32aa475cf05fd4266b7
...
"Hello, world!4248" => 6e110d98b388e77e9c6f042ac6b497cec46660deef75a55ebc7cfdf65cc0b965
"Hello, world!4249" => c004190b822f1669cac8dc37e761cb73652e7832fb814565702245cf26ebb9e6
"Hello, world!4250" => 0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9

In this example it took 4,251 tries to produce an output hash that starts with at least three zeros. This is basically how the proof of work in bitcoin works. Miners run the block header through the (double) SHA-256 hash function over and over, incrementing the nonce each attempt in hopes of producing a hash output that meets the difficult target. The difficulty is automatically re-calibrated by the protocol every two weeks to target to target a block interval of 10 minutes. That is, since the output of the hash function is random, it should take an average of 10 minutes for one miner in the network to solve the proof of work for any given block of transactions.

The miner who finds the valid block earns the block reward ― currently set at 25 bitcoins. The protocol halves the reward every four years according to the following schedule:

37-expansion

Megahashes, Gigahashes, and Terrahashes

Bitcoin Mining

Because the rate with which bitcoins are rewarded is regulated by the protocol, Bitcoin mining is essentially a zero-sum game. That is, more total processing power in the network does not generate more total bitcoins, it only reduces the reward per unit of processing power. This means that the faster you can perform the SHA-256 calculations, the greater percentage of the total block reward you will earn. We typically measure the speed of a mining rig in terms of the number of hash operations it can perform per second (h/s).

Back in the old days, circa 2009, Bitcoin was a Windows only software and most mining was done right on your CPU using the GUI. Fairly quickly people figured out that GPUs (graphics processing units) were more efficient at calculating hashes than CPUs. Those who switched to mining on GPUs saw their bitcoin earnings increase at the expense of those who stuck with CPUs. And thus a mining arms race was born that continues to this day.

After a brief period of FPGA mining, the first ASICs (application-specific integrated circuits) hit the market in early 2013. An ASIC is a custom built computer chip designed to do nothing but perform double SHA-256 calculations very fast. As more and more ASICs were brought online, the total hashrate in the network skyrocketed driving non-ASIC miners out of the market in the process.

hashrate

Today the total hash rate in the network is around 83 petahashes/sec. That’s 83,000,000,000,000,000 hash operations per second. Way more than top 500 supercomputers in the world can do combined.

Pooled Mining

Back in the early days all miners looked for blocks individually. Given that blocks are only created on average every ten minutes miners would frequently go days if not weeks without mining a block. When a block was found, the payoff would be fairly large (50 bitcoins originally, now 25), but the variance in returns was extremely high. The solution to the variance problem came in the form of pooled mining. Basically, miners would pool their resources together to find blocks faster and split the rewards according to how much work each miner contributed.

The technicalities work like this ― in addition to looking for valid blocks, miners also look for “shares”. The difficulty for finding a share is usually set by the pool operator well below the difficulty for finding a block.

For example, a valid block may need to start with 14 zeros, say. Whereas a valid share needs only 5, say.

Block: 000000000000002e9067f1cf7252333f7aeb619c89d220985a70ac0e015248e0
Share: 00000b3709b05939f04cf2e92f7d0897fc2596f9ad0b8a9ea855c7bfebaae892

Since the difficulty is much lower for shares, miners will find these much more frequently. Each share is submitted to the pool operator and when a block is found the reward is paid out to miners in proportion to the number of shares they submit.

Of course, pooled mining is not without significant controversy. As I already mentioned, in the early days miners looked for blocks individually. They maintained their own copy of the blockchain, and retained control of which transactions they include in blocks. With pooled mining, miners are essentially delegating those responsibilities to the pool operator. Today most miners don’t even have a copy of the blockchain nor do they have any control over which transactions make it into their blocks. This not only creates a worrisome degree of centralization but it gives pool operators an inordinate amount of power. For example, a pool operator controlling 30% of the network mining power can double spend his own transactions with a 30% success rate. Want to tilt the odds of a gambling site in your favor? That’s how you do it. Worse, if that pool operator colluded with another pool operated with, say, just over 20% hashing power, the two could double spend transactions with 100% success, among other things. Here’s the current hashrate distribution:

hashratedistribution

The saving grace is the fact that pool operators do not actually own or control the physical hardware. So the thinking is should a pool operator(s) turn malicious, miners would quickly abandon the pool limiting the damage. It seems every few months a mining pool gets close to 50% of the hashrate and the bitcoin community panics and directs their wrath at the pool operator. Public enemy number one these days is GHash.io. The cycle looks something like this:

AX4NSyK

Developers have created several tools to address the problem of mining centralization. First is the getblocktemplate mining protocol which allows miners to retain control over the blocks they create. Unfortunately miners and mining pools have shunned it in favor of the centralized stratum mining protocol. There is work planned for a getblocktemplate 2.0 which would be even more decentralized, but it remains to be seen whether miners will actually adopt it.

There’s also P2Pool, a peer-to-peer mining pool that was developed with grant money from the Bitcoin Foundation. Yet, it only manages a meager 1% of the network hashrate, likely because it’s much more complex than stratum. If you plan on mining bitcoin, you really should do the network a favor and at minimum pick a pool with a lesser hashrate or better yet use P2Pool.

I can speak for myself, I have a couple 330 Mh/s USB miners. The total miner power is negligible and cost far more to operate than they would ever generate mining. So every now and then when I leave the house I turn them on solo mining for the off chance they will mine a 25 BTC block. It’s kind of like playing the lottery. The odds certainly aren’t in your favor, but you can’t win if you don’t play. And it supports the network, so in that sense it’s worth it.

What do I need to start mining?

You’ll need to get an ASIC for one. Unfortunately it isn’t very easy to get one, at least not within a reasonable time frame. ASIC manufacturers are notorious for long production delays. Given that the mining difficulty has been increasing at a fast pace, it’s critical to get your hardware mining as soon as possible. The longer it takes for the hardware to be fabricated and delivered to you, the more money you are losing. What’s worse is manufactures tend to prioritize orders from large mining firms that purchase hardware in bunk. This puts individuals with limited resources at a competitive disadvantage.

If you do acquire an ASIC you’ll also need to install some software. BFGMiner and CGMiner are two of the most popular. Both are command line only and will likely be difficult to use for people who are not tech savvy. Butterfly Labs has a GUI wrapper (EasyMiner) for both CG and BFGMiner. Once everything is installed, you can usually start mining with a single command. For example:

bfgminer -o stratum+tcp://stratum.mining.eligius.st:3334 -O 1CBKzGN7TkcJ9YGCxfCCMsxjhSperRcyUX

Is it a good investment?

There are quite a few variables that determine whether an investment in mining hardware will be profitable or not:

  • The cost of the hardware (including shipping)
  • The shipping delay (it will take a while)
  • The cost of the electricity
  • The difficult rate
  • The current Bitcoin exchange rate
  • The expected future value of bitcoins

To figure out if you will earn a profit or loss on the mining hardware you need to estimate all these variables and come to your own conclusion about profitability. There are profit/loss calculators you can use as well. I will say this, however ― your hardware will almost certainly start depreciating the moment you plug it in. As other miners bring additional hardware online, and as the difficulty increases, your share of the mining reward will go down. Eventually, it will get to a point where you are spending more money on electricity to operate the hardware than you are earning in block rewards. At that point you will likely want to shut the hardware down. You could continue mining at a loss and speculate that the bitcoin price will increase to cover your losses, but that adds additional risk.

What this all means for you is that your hardware likely has an expiration date. When you first plug it in, that will be the most you ever earn. The profits will continue to decline until they turn negative. Typically you can expect to get about six months out of your hardware and that’s about it. If you’ve calculated correctly, you will have earned enough in Bitcoin to cover the cost of the hardware and earn a small return on your investment. If you didn’t, you’ll take a loss. If you earn a profit, you have to decide whether to take your profits and run, or reinvest some or all of it in more hardware.

A word of caution ― there have been people who continually reinvested their mining profits in more and more hardware, amassing a large hashrate in the process. It sounds impressive, yet as the price of Bitcoin climbed towards $1,000 they found themselves with zero actual bitcoin while everyone around them were counting their riches. So you have to find a good rate to reinvest.

A final point I want to make is relate to shipping delays when purchasing hardware. Delays can be the difference between earning a positive return on your investment or a loss. To illustrate how crucial timing is, let me tell you a little story. Back in early 2013 prior to ASICs hitting the market, I was considering dropping $2,500 dollars on a 50 Gh/s ASIC. At that point I did the math and calculated that if I was able to receive the hardware within the next week or two, I would earn some ridiculous amount of money. Somewhere around $150,000/month. Not bad for a $2,500 investment. The problem was I knew the order wouldn’t ship in two weeks, more like 5 or 6 months. So I was left to try to estimate the hashrate six months out and calculate my would-be profits. Naturally, forecasting the hashrate that far out was practically impossible, but if it skyrocketed during that period, I would take a loss on the hardware. So despite the promise of $150,000/month, I declined and just purchased bitcoins with the money. And good thing! The hashrate did, in fact, skyrocket. And the shipping delays were even worse than expected. People who ordered at that point ended up waiting 8 months or more. I almost certainly would have taken a loss. Instead I earned a big profit just by buying Bitcoin outright.

This still likely hold true today. At this point there is so much hashing power in the network that I suspect most miners are operating at a loss while speculating that they can recover that loss through future increases in the price of bitcoin. If you do decide to get into mining, you need to take that into consideration and adjust your expectations accordingly.

So that’s it for now. In the next post I’m going to cover some mining topics that weren’t covered in this post. Stay tuned.

Original content by Chris, copyleft, tips welcome