What is Bitcoin Mining
When Bitcoin nodes connect to each other, they get transactions from each other that they do not have. However, due to the long-term accumulation of Bitcoin transactions, it is very difficult for two nodes to compare which transactions you are missing/which transactions I am missing one by one.
To solve this problem, Satoshi Nakamoto invented the important technology of Block chain . Nodes use blocks to synchronize transactions, which ensures the uniformity of all node data, and ensures the uniqueness of the blockchain by competing for block packaging rights (that is, mining).
1. Blocks and blockchains
A package made of transactions over a period of time is called a block. The entire Bitcoin network generates a block every 10 minutes on average, and each block is linked to the previous block, which in turn forms a blockchain.
2. Synchronize transaction data in blocks
Blocks are numbered from 1, so after node A connects to node B, it is easy to synchronize transaction data by checking the block number heights of both parties. For example, node A’s own block height is 100, and it is found that node B’s block height is 110, just request B to synchronize the 10 blocks 101~110.
3. Rewards for packaging blocks
In order to ensure that nodes package Bitcoin transactions, the Bitcoin rules stipulate that nodes that package transactions will receive Bitcoin as a reward. A. Part of the packaging reward comes from the transaction fee paid by the transaction creator (100~1000 satoshi fee per KB transaction size). B. The other part comes from the initial distribution of 21 million bitcoins. The initial reward is 50 bitcoins per block. After that, the reward will be halved every 210,000 blocks (about 4 years) until around 2140. Until the block reward is less than 1 satoshi, the total block reward at this time is 21 million bitcoins, which is the source of the total amount of bitcoins of 21 million (20999999.97690000 to be precise). After 2140, packaging rewards will only come from transaction fees paid by transaction creators.
4. Competition for block packaging rights
Node packaging transactions only need to consume very low-cost network and computing resources, and the existence of packaging rewards (currently, the packaging reward of 25 bitcoins per block is about 40,000 yuan), makes a large number of nodes want to package transactions. In order to ensure the uniqueness of the blockchain, the Bitcoin rules stipulate that nodes use a method similar to “tossing a coin” to compete for the right to package transactions. The node keeps tossing coins, and whoever throws the result that conforms to the rules first will get the transaction packaging right of this block and the packaging reward of this block.
5. Ways to compete for package rights
The implementation of “tossing a coin” is that the computer performs a hash (SHA-256) operation and checks whether there are enough consecutive 0s from the first digit of the operation result (it can be simply understood as tossing 256 coins at a time, and then looking at the Whether the first coin starts with enough consecutive coin heads). The only trick to “flip a coin” to win is to increase the number of coin toss per second, a node that can flip 10 billion coins per second (doing 10 billion hash calculations), the probability of grabbing the right to pack is 100 million per second. 100 times the coin node.
6. The winning node packs the transaction and broadcasts it
Once a node throws a coin result that conforms to the rules of the system (for example, the hash value of block 379543 ​​is 000000000000000008bdeb575056584429ea4be876ea7ca4ce70262d3edb8c8b), he will immediately package the transactions collected during this period into a block, with the “coin toss” attached. As a result, additional information such as block serial number 379543 ​​and the relationship of the previous block are broadcasted. Once other nodes receive block 379543 ​​and verify that they are correct, they will stop “throwing coins” to grab this block, and turn to this block. On the basis of starting to “flip a coin” to grab the next block 379544.
7. The origin of “mining” and “miners”
A large number of nodes need computer equipment and consume a lot of electricity to perform hash calculations. This process is essentially similar to gold mining (through mining equipment, energy is consumed in exchange for gold). The total amount of Bitcoin is constant, and the production method of decreasing production is also very similar to gold. Therefore, people vividly call the process of grabbing the packaging rights of Bitcoin as mining, and the bitcoin nodes that grab the packaging rights are called miners.
The evolution of mining equipment
1. CPU: The earliest miners used CPU for mining, and the mining speed was at the M level (1M=1000K=10^6=1 million hash operations per second).
2. Graphics card mining machine: The graphics card has hundreds of computing cores (stream processors), so the speed is equivalent to hundreds of CPUs, and the mining speed is at the level of 100M. Due to the different architectures of ATI and NVIDIA graphics cards, the number of stream processors of the same grade A card far exceeds that of the N card, so the A card has a huge advantage in mining. Professional miners often use motherboards with 6 PCI-E slots such as H61B. Plug in 5-6 high-end graphics cards such as ATI 7850 to form a mining machine group for mining.
3. Integrated circuit mining machine: As the price of Bitcoin continues to rise, mining is becoming more and more profitable, and integrated circuit mining machines appear. The mining machines use specially designed chips that can only do mining hash operations. , so it has great advantages over general-purpose computing devices such as CPUs and graphics cards in terms of mining speed and power consumption, at the cost of not being able to do anything except mining and making electric heaters. The CPU and graphics card can still be used as ordinary computers after the mining output is not enough and the electricity bill is eliminated. After the mining machine is eliminated, except for a few people who have free electricity to continue mining, they can only be used as electric heaters or scrapped.
The integrated circuit mining machine passes through the FPGA mining machine. In the era of ASIC mining machines (ASIC: Application-Specific Integrated Circuit), the speed has gradually evolved from G level to T level (1T=1000G), which can perform trillions of hash operations per second, equivalent to the computing power of one million CPUs . That is to say, if the Tianhe-2 supercomputer, currently ranked second in the world, is used for mining, the computing power of its 3.12 million CPU cores is only equivalent to a T-level mining machine worth several thousand yuan.
5. Since 2013, the price of Bitcoin has soared and the massive deployment of millions of ASIC mining machines has made the computing power of the entire Bitcoin network reach an astonishing 435P (1P=1000T). The picture below shows KnCMiner’s large mine in Sweden. field.
mining pool
Since there are tens of thousands of miners competing for the packaging rights, the probability of a single miner grabbing the packaging rights is very small, and the output is very unstable. It is possible to grab it once in an hour, or it may not be grabbed once a year. In order to stabilize the mining output, miners often choose to join the mining pool for mining. The mining pool integrates the computing power of a large number of miners and occupies a certain share of the total computing power of the entire network, thus obtaining a relatively stable mining output. After charging 2%~4% of the mining pool handling fee, the output is distributed to the miners according to the miners’ computing power. This is like buying a lottery ticket by one person and it is difficult to win the lottery, so the mining pool organizes many people to buy lottery tickets, and then distributes the lottery to everyone according to the investment amount.
With the development of mining pools, automatic switching mining pools like Libit (http://LTC1 BTC.com) also appeared , commonly known as machine gun pools. Smart Pool will switch to altcoin mining when various altcoins have high returns, thereby increasing miners’ income by 5%~10%.
The Meaning of Bitcoin Mining – Distributing Initial Bitcoins
Bitcoin opponents accuse mining of consuming a lot of resources for meaningless coin tossing, while supporters say that gold mining also consumes a lot of resources for meaningless digging. For the Bitcoin system, the greatest significance of this kind of mining that consumes a lot of resources is: to distribute 21 million initial bitcoins fairly, just like consuming resources to mine gold, consuming resources to mine bitcoins is the only fair distribution of initial bitcoins way of coins.
Because of its open source code, Bitcoin has seen thousands of copycats, competitors, and improvers. Usually, those that simply copy and imitate Bitcoin are called altcoins, and those that add certain new features to Bitcoin are called altcoins. Some coins add other functional modules such as smart contracts to Bitcoin, and call themselves “second-generation” currency. These thousands of coins have tried every ICO distribution model you can imagine, such as Aurcoin, which is distributed equally to every Icelander, and 73 crowdfunding participants. Nextcoin, which is controlled by developers and slowly distributes most of the initial coins, Ripple (XRP), etc.
However, the fairness of all these methods of distributing initial coins is far weaker than the mode of burning money to obtain initial bitcoins, and fairness is the core issue of a currency system. Therefore, although bitcoin mining consumes a lot of resources, It is a reasonable economic behavior like consuming resources to mine gold.