Bitcoin: the basic principles of mining


    Much has been written about Bitcoin (BTC) on Habré (recently, too much too much). How he works , about the interest in him from the government and special services . They tried to bury Bitcoin more than onceand then dig it back. Even conducted excursions to an ostrich farm . But somehow, looking at this, the whole picture did not develop.

    I will try to partially fill this gap and state in several posts the basic principles and history of how bitcoins were mined and mined. Mostly attention will be paid to the technological side of the issue, and not to high-profile scandals in the world of media and politics. Also, I will try to avoid repeating what has already been written more than once.
    This time we will talk about the general principles of mining.

    UPD : you can find out how the bitcoin works here .

    Bitcoin mining: “who are all these people?”

    First, let's try to answer the question, and who, in fact, is engaged in the extraction of bitcoins. The following are the main categories of people who have mined or mined bitcoins, taking into account the chronology of their appearance on the stage.
    1) Pupils and students with access to cheap (or completely free) electricity and hardware, at the expense of their parents and universities.
    2) Gamers using their gaming PCs to mine bitcoins in between computer battles.
    3) Geeks who buy several PCs for mining, and which are usually stopped only by exhausting the resources of power supply / cooling / free space (well, or the patience of relatives and neighbors)
    4) Hackers deploying botnets and using stolen computing power for mining.
    5) Communities organized for the joint purchase of equipment and mining of bitcoins, with the subsequent sharing of the benefits received.
    6) Companies that managed to get financing from enthusiasts through an IPO analogue on online exchanges trading with bitcoin. Such companies develop specialized hardware (ASIC) for subsequent bitcoin mining and distribute dividends.
    Apparently, a rather motley company.

    Bitcoin mining

    The essence of bitcoin mining comes down to solving some complex crypto task, for which no better approach than brute force is known.
    Bitcoins are mined not one at a time, but by "packs", or blocks. Initially, the block size was 50 BTC, but it halves after every 210 thousand blocks mined. Now more than 250 thousand blocks have been mined, which means that one block brings 25 BTC. A new block is mined approximately every 10 minutes. Due to the periodic reduction of the block reward by half, the total number of BTCs will never exceed 21 million, ~ 55% of all BTCs have already been mined and, according to forecasts, this figure will reach 99% by 2032.
    Periodically, every 2016 extracted blocks, there is an adjustment of the complexity of their production. The adjustment is based on the production rate in the last period and is needed to maintain the average block production interval at around 10 minutes.
    If the number of computers engaged in the simultaneous mining of bitcoins is generally growing, the daily reward (equal to 24 * 6 * 25 = 3600 BTC) remains unchanged. And that means that every computer has an ever smaller share of the total “pie”.
    Bitcoin mining makes sense only as long as the cost of mined BTC exceeds the cost of equipment and electricity. Because the complexity of BTC mining is steadily increasing, and the USD / BTC rate is subject to fluctuations, the least energy-efficient BTC mining tools are gradually being excluded from the process. Although, a sharp increase in the USD / BTC rate can make it profitable to return them to operation.

    (This time at all) a bit of history

    Bitcoin was the result of the development of ideas embedded in preexisting cryptocurrencies. And for the first time he appears on the scene in November 2008, when a user, under the pseudonym Satoshi Nakamoto (Satoshi Nakamoto) publishes an article describing the system of the new currency. Already in January 2009, the system begins to function, and its popularity at first grows slowly, but soon turns into exponential growth. There is a known case when one person paid 10 thousand for pizza. BTC (several million $ at the current rate). Nakamoto disappears in April 2011, and his identity is still a mystery.

    USD / BTC rate

    Figure 1. Dynamics of the USD / BTC exchange rate and mining difficulties (data source)

    Figure 1 shows the dynamics of the USD / BTC exchange rate over time. Since 2010, the rate has gone up sharply. If in July 2010 1 BTC was worth $ 0.05, then by August 2013 it had already surpassed the mark of $ 105. In this interval, there are two leaps: one in June 2011, when Bitcoin was worth $ 31.5 and in April 2013, when the rate jumped to $ 266 (and now even to $ 1000). The sharp jumps and collapses of the course are most often associated with periods of intense media attention and the heyday of fears / rumors about protocol vulnerabilities or hacks by organizations responsible for exchanging BTC for other currencies. Such rumors are each time accompanied by a wave of people wishing to sell bitcoins and a collapse in the rate.
    The main reason that makes BTC so attractive for speculation is the upper limit on the amount of BTC equal to 21 million. If BTC ever replaces gold as a benchmark for saving, then, equating the value of the world's gold reserves to the total value of bitcoins, we can say that one BTC will cost $ 71,000 - much more than now (almost two orders of magnitude, even taking into account the latest speculation).

    BTC mining difficulty

    Figure 1 also shows how the complexity of mining bitcoins has changed over time. In less than 4 years, the complexity has increased to 50 million. time. If at the beginning the complexity corresponded to 4-8 general-purpose processor cores, capable of sorting out approximately 7 million hashes per second (MH / s), now the speed of joint efforts in brute force exceeds 7 petachehes per second (PH / s). 2 factor a. First, the growth of the USD / BTC exchange rate allows you to cover the costs of operating more mining equipment. Second - during this time, significant changes have occurred in both the software and hardware for mining bitcoins. Again, the points of decline in the difficulty of mining BTC correspond to the places where the USD / BTC rate collapsed.

    Innovations in hardware and software for mining

    Progress was incredibly fast, changes followed one after another.
    In September 2010, the first publicly available CUDA miner appears. Already in October 2010, it was followed by the first miner for OpenCL.
    Almost immediately after this, in November 2010, a phenomenon such as pooled mining arose when a group of computers performs distributed enumeration of hashes and, when mining a block of bitcoins, shares the reward between the participants in proportion to their contribution to the common cause. Such pools very quickly grew to the size of thousands of participants, allowing the latter to receive small amounts every day, rather than large (50 or 25 BTC) every few months.
    At that time, the difficulty of mining a block of bitcoins was equal to about a month of operation of one Hi-End GPU. One of the key innovations that made mining pools possible was the ability to make sure that the computer really did work on sorting the hashes, which it declared to be completed, and excluding the possibility that the user would “escape” when his computer was lucky during the search stumble upon an answer.
    Unfortunately, mining pools serve as a kind of “hubs,” which contradicts the distributed nature of bitcoin and potentially jeopardizes the transaction confirmation process.
    In June 2011, the first open source miner for FPGA appeared. And then in January 2013, the first ASIC miner appears and the many improvements that followed. The BTC mining difficulty chart shows the dates of these technologies.

    performance and energy efficiency

    Overclocked Hi-End CPUs (like the Core i7 990x) achieved 33 MH / s, and NVidia's Hi-End GPUs (like the GTX 570) 155 MH / s. At the same time, AMD GPUs (like 7970 for $ 450) were much more convincing, at 675 MH / s.
    The next evolutionary step is related to the emergence of FPGA miners, which though lost a bit to AMD video cards in the cost of iron per unit of performance ($ / MH / s), but they consumed 60W instead of 200W. A company called Butterfly Labs (BFL) began selling FPGA miners, which could eventually gradually displace the GPU due to less power consumption.
    But here ASIC miners come on the scene, giving orders of magnitude gain compared to FPGA. Due to their use, the total productivity is skyrocketing, and with it the complexity of mining blocks, which inevitably leaves both GPU and FPGA out of work.

    Figure 2. Installation for mining bitcoins based on FPGA (source)

    Mining strategy

    An important issue for those involved in the mining of bitcoins is: when investing money in iron for mining bitcoins will bring more profit than simply buying them through the exchange. Many specialized BTC mining equipment (or shares in companies operating such equipment for you) has a price indicated in BTC. Agree, it would be foolish to buy such equipment and never return your investments, especially given the service and electricity bills.

    To answer this question, you need to evaluate the refund due to mining in bitcoins. With the exponential growth in the complexity of mining new bitcoins, the ability of iron to mine bitcoins also decreases exponentially. With an increase in complexity of about 1.2 times every two weeks, 66% of the bitcoins that iron can get during its operation fall on the first quarter of work. 22% for the second quarter, 7% for the third, and for the rest of the time only 4%. At the same time, on the first day of work ~ 1/80 of all bitcoins will be mined, which can be obtained on this device during its operation.
    The profit from the use of equipment for mining bitcoins is obtained by summing the exponentially decreasing amounts of mined bitcoins per unit of time, minus the costs of operation and acquisition, plus the price at which the equipment can be sold after completion of its life cycle as a bitcoin miner.

    Some of these options are known at the time of purchase; for example, the price of equipment, the USD / BTC rate at that moment, and operating costs. It is also easy to estimate the number of bitcoins mined on the first day of work, as hardware delivery times are easy to estimate (just don’t need to think about Russian Post here), and the performance of the same GPUs in GH / s is the first thing that users begin to measure in the appropriate forums. Maintenance costs are directly derived from equipment specifications and electricity bills. An assessment of how much iron can be sold in the future is made (albeit approximately) by studying sites like e-bay.

    The main risk lies in the dynamics of the USD / BTC rate. If the rate grows, so does the profit from the mined bitcoins, and it also makes sense to leave the equipment in service for a longer period. If the rate stops growing or collapses, the mining of bitcoins becomes less attractive, and to maximize profits it makes sense to turn off the equipment and try to sell it earlier.

    The change in the price of equipment over time behaves differently for different types of devices. AMD GPU price for the year of operation is reduced very slightly. At the same time, the situation with specialized equipment is exactly the opposite, as his only purpose is mining. Specialized solutions based on FPGA or ASIC have much higher risks associated with the date of delivery of the equipment - the price at which they are ready to buy, and how much you can earn from them, directly depends on the date they were entered into the mining process. Managing this risk is an important part of bitcoin mining.

    First you need to evaluate the delivery of which of the competing solutions will begin earlier. Then, you should be as close as possible to the top of the list of purchase orders. Otherwise, even if the choice in favor of this or that decision was made correctly, the complexity of mining bitcoins will have time to jump to the moment when the equipment reaches you, and you will miss all the cream from the advent of new technology. For six months, the profit that can be obtained on the same equipment drops 15-20 times.

    Equipment shutdown

    Figure 3. Daily profit from bitcoin mining and related electricity costs. (data source)

    Figure 3 shows the daily profit of 1 GH / s that bitcoin mining has brought in since 2010. This chart combines historical data on mining difficulty and the USD / BTC rate. A sharp collapse in the November 2012 area corresponds to a decrease in block rewards from 50 BTC to 25 BTC. Horizontal lines show electricity costs of 1 GH / s per day for: CPU (Core i5), GPU (AMD 7970), FPGA (Bitforce SHA256) and 110nm ASIC (AvalonBatch 1). When the profit per 1 GH / s falls below this line, mining becomes unprofitable and the corresponding equipment turns off.

    To be continued .

    Also popular now: