📜 ⬆️ ⬇️

Bitcoin: basic principles of mining


(a source)

About Bitcoin (BTC) on Habré wrote a lot (lately, even too much). How he works , about the interest in him from the government and special services . Bitcoin has repeatedly tried to bury and then dig back. Even conducted excursions to the ostrich farm . But somehow, looking at it, the whole picture did not develop.

I will try to partly fill this gap and present in several posts the basic principles and history of how the bitcoins were mined and mined. Mostly attention will be paid to the technological side of the issue, and not to 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 discuss the general principles of mining.

UPD : with materiel how bitcoin works itself can be found here .
')

Bitcoin mining: “who are all these people?”


To begin, let us try to answer the question, and who, in fact, is engaged in the extraction of bitcoins. Below are the main categories of people who mined or mined bitcoins, taking into account the chronology of their appearance on the scene.
1) Schoolchildren 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 extract bitcoins in between computer battles.
3) Geeks who buy several PCs for mining and which are usually stopped only by the depletion of power supply / cooling / free resources (well, or the patience of relatives and neighbors)
4) Hackers who deploy botnets and use stolen computing power for mining.
5) Communities organized for the joint purchase of equipment and the extraction of bitcoins, with the subsequent sharing of the benefits obtained.
6) Companies that managed to get funding from enthusiasts through an IPO equivalent on online exchanges trading for bitcoin. Such companies develop specialized hardware (ASIC) for subsequent bitcoin mining and distribute dividends.
As you can see, quite a motley company.

Bitcoin mining


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

(This time at all) a bit of history


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

USD / BTC rate



Figure 1. Dynamics of USD / BTC and mining complexity (data source)

Figure 1 shows the dynamics of the USD / BTC exchange rate over time. Since 2010, the course 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 jumps - one in June 2011, when Bitcoin was worth $ 31.5 and in April 2013, when the rate jumped to $ 266 (and now to $ 1000). Abrupt jumps and crashes of the course are most often associated with periods of close media attention and the heyday of fears / rumors about protocol vulnerabilities or hacking of organizations responsible for exchanging BTC for other currencies. Such rumors are every time accompanied by a wave of people willing to sell bitcoins and a collapse of the course.
The main reason for making BTC so attractive for speculation is the upper limit on the amount of BTC, equal to 21 million. If someday BTC still replaces gold as a standard for storing savings, then, equating the value of world gold reserves to the total value of bitcoins, one 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 changed over time. In less than 4 years, the complexity has increased by 50 million. time. If at the beginning the complexity corresponded to 4-8 general-purpose processor cores capable of sorting out about 7 million hashes per second (MH / s), then now the speed of the joint bruteforce effort exceeds 7 petacheshes per second (PH / s). This growth was promoted by 2 factor a. The first is that the growth of the USD / BTC rate allows you to cover the costs of operating a larger amount of mining equipment. Secondly, during this time there have been significant changes in both software and hardware for mining Bitcoins. Again, the points of decline in the BTC mining complexity correspond to the places where the USD / BTC exchange rate collapses.

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, such a phenomenon appeared as pooled mining, when a group of computers performs distributed enumeration of hashes, and, when mining a block of bitcoins, it divides 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 each day, rather than large (50 or 25 BTC) every few months.
At that time, the complexity of bitcoin block mining was about a month of work for a single Hi-End GPU. One of the key innovations that made the existence of mining pools possible was to make sure that the computer actually did the work of iterating over the hashes, which he declared to be done, and to exclude the possibility that the user would “run away” when his computer was lucky stumble upon the answer.
Unfortunately, mining pools serve as a kind of “hub”, which is contrary to the distributed nature of bitcoin and potentially jeopardizes the transaction confirmation process.
In June 2011, the first open source miner for the FPGA appeared. And then in January 2013, the first ASIC miner appears and many improvements follow it. The graph of the BTC mining complexity shows the dates of the appearance of these technologies.

performance and energy efficiency


The over-clocking Hi-End CPUs (like the Core i7 990x) achieved 33 MH / s performance, and the NVidia Hi-End GPUs (like the GTX 570) reached 155 MH / s. At the same time, GPUs from AMD (like 7970 for $ 450) were much more convincing, at 675 MH / s.
The next evolutionary step is connected with the advent of FPGA miners, which, although they were a bit less powerful than AMD's cards, cost iron per unit of performance ($ / MH / s), but consumed 60W instead of 200W. A company called Butterfly Labs (BFL) began selling FPGA miners, which in the end could gradually push out the GPU due to less power consumption.
But here ASIC miners come on the scene, giving a gain of several orders of magnitude, compared to FPGA. Due to their use, the total performance soars to the skies, and with it the complexity of block mining, which inevitably leaves out the GPU and FPGA.


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

Mining strategy


An important issue for those engaged in the extraction of bitcoins is: when investing money in hardware for mining bitcoins will bring more profit than just buying them through the stock exchange. Many specialized mining equipment for BTC mining (or shares in companies that operate such equipment for you) has a price specified in BTC. Agree, it would be foolish to buy such equipment and never return your investment, especially with regard to maintenance and electricity bills.

To answer this question, you need to evaluate the refund due to mining in bitcoins. With the exponential growth of the complexity of extracting new bitcoins, the ability of iron to extract bitcoins also drops exponentially. With an increase in complexity of approximately 1.2 times every two weeks, 66% of bitcoins, which "iron" is able to produce during its operation, account for the first quarter of work. 22% in the second quarter, 7% in the third, and the remaining time accounts for 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 bitcoin mining equipment is obtained by summing up 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 the end of its life cycle as a bitcoin miner.

Some of these parameters are known at the time of purchase; for example, the price of equipment, the USD / BTC rate at this time and the cost of operation. It is also easy to estimate the number of bitcoins mined during the first day of work, since hardware delivery times are easy to estimate (just don’t need to remember about the Post of Russia), and the performance of the same GPU in GH / s is the first thing that users begin to measure on the appropriate forums. Maintenance costs derive directly from equipment specifications and electricity bills. Evaluation of how much money in the future it will be possible to sell the iron is done (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 extracted bitcoins, and it also makes sense to leave the equipment in service for a longer period. If the rate ceases to grow or collapses, bitcoin mining becomes less attractive, and to maximize profits, it makes sense to turn off the equipment and try to sell it earlier.

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

First you need to assess the supply of which of the competing solutions will begin earlier. Then, you need to 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 bitcoin mining will have time to jump by the time the equipment gets to you, and you miss all the cream from the advent of new technology. For six months, the profit that can be obtained on the same equipment falls 15-20 times.

Equipment shutdown




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

Figure 3 shows the daily profit of 1 GH / s, which has been mined in bitcoins since 2010. This chart combines historical mining complexity data and the USD / BTC rate. A sharp collapse in the November 2012 area corresponds to a decrease in the block reward from 50 BTC to 25 BTC. The horizontal lines show 1 GH / s power consumption per day for: CPU (Core i5), GPU (AMD 7970), FPGA (Bitforce SHA256) and 110nm ASIC (AvalonBatch 1). When a profit of 1 GH / s drops below this line, mining becomes unprofitable and the corresponding equipment is turned off.

To be continued .

Source: https://habr.com/ru/post/205524/


All Articles