Difference between revisions of "Mining"

Line 7: Line 7:
  
 
The blockchain structures itself in a manner that is computationally impractical to modify by any one entity. Due to this, transactions included in the blockchain are considered immutable. In addition to this quality, the blockchain establishes an authoritative order of these transactions throughout the network, thereby protecting users from attempts to re-spend coins that have already been spent elsewhere. This is the key innovation of mining and of bitcoin.
 
The blockchain structures itself in a manner that is computationally impractical to modify by any one entity. Due to this, transactions included in the blockchain are considered immutable. In addition to this quality, the blockchain establishes an authoritative order of these transactions throughout the network, thereby protecting users from attempts to re-spend coins that have already been spent elsewhere. This is the key innovation of mining and of bitcoin.
 
  
 
=== Nodes ===
 
=== Nodes ===
Line 16: Line 15:
 
Listener nodes perform no proof-of-work and therefore cannot append new blocks to the blockchain. They can neither express acceptance of valid blocks by working on extending them, nor reject invalid blocks by refusing to work on them. Listener nodes are passive entities that follow the gatekeepers of the network, the miners. An example of a listener node is a block explorer. Block explorers are a useful service that allow users to query the blockchain for block or transaction information.
 
Listener nodes perform no proof-of-work and therefore cannot append new blocks to the blockchain. They can neither express acceptance of valid blocks by working on extending them, nor reject invalid blocks by refusing to work on them. Listener nodes are passive entities that follow the gatekeepers of the network, the miners. An example of a listener node is a block explorer. Block explorers are a useful service that allow users to query the blockchain for block or transaction information.
  
 +
=== Mempool ===
 +
Before a bitcoin transaction can be committed to the blockchain it needs to be received and validated by a miner. If the miner deems the transaction has paid enough in fees, they add the transaction to their mempool. As such, the mempool is just a temporary transaction store.
 +
 +
It is important to note every miner has their own mempool and that mempools vary across miners. It is also important to note that an individual transaction can be included in many different miner’s mempools at the same time.
 +
 +
A miner takes all the transactions in its mempool and hashes them into a Merkle Tree structure and includes the resulting Merkle Root within a candidate block header. The miner then hashes this candidate block header, attempting to find a valid proof-of-work.
 +
 +
=== Hashing ===
 +
A hash is a function that converts a string of data into a fixed length value that represents the original string, called the hash value. Every hash value is unique.
 +
 +
Hashing is a one-way function, meaning it is infeasible to determine what the input data is by looking at the hash produced from it. Conversely, it is trivial to run the same input data through the same hash function and reproduce the same hash. Because of this, a hash value of input data can be thought of as the digital fingerprint of that data. In bitcoin mining, the input data is the 80-byte block header.
 +
 +
The hashing algorithm used in bitcoin mining is SHA-256. SHA-256 stands for Secure Hash Algorithm – 256 bit. Passing the block header data through this algorithm will always output a 256-bit number that is unique.
 +
 +
Bitcoin mining passes the block header data through the SHA-256 algorithm twice (SHA-256d). The reason for this is to accommodate the presumed future fracture of mining interests into separate specialized entities. A double hash allows for a hashing entity to indicate they have a valid proof-of-work to another mining related entity without having to reveal the block header input data.
  
=== Reward ===
+
The BSV network is currently making 1.3E18 attempts to find a valid block hash every second.  
When a block is discovered, the discoverer may award themselves a certain number of bitcoins, which is agreed-upon by everyone in the network. Currently this bounty is 12.5 bitcoins; this value will halve every 210,000 blocks. See [[Controlled Currency Supply]].
 
  
Additionally, the miner is awarded the fees paid by users sending transactions. The fee is an incentive for the miner to include the transaction in their block. In the future, as the number of new bitcoins miners are allowed to create in each block dwindles, the fees will make up a much more important percentage of mining income.
+
==== Proof-of-work ====
 +
Bitcoin uses the hashcash proof-of-work function.
  
== The mining ecosystem ==
+
A miner cannot create a new block without finding a valid proof-of-work hash for the block header they are hashing. To be valid, the SHA-256d hash (which is just a number) of the block header must be less than another number, called the target. The target value is defined by the nBits field in the block header that is being hashed.
 +
 +
The target adjusts so that the average time it takes to find a valid proof-of-work hash is ten minutes.
  
=== Hardware ===
+
Because of the extraordinarily large SHA-256 target space, it is extremely unlikely that any given hash will be below the target. As a result of this, hashing entities invest large amounts of capital into specialized hashing hardware along with the associated electricity costs in order to produce as many of these hashes as possible. Therefore, the only way a miner can append a block to the blockchain is through substantial financial commitment – proof-of-work.
[[File:Usb-fpga module 1.15x-hs-800.jpg|thumb|right|FPGA Module]]
 
Users have used various types of hardware over time to mine blocks. Hardware specifications and performance statistics are detailed on the [[Mining Hardware Comparison]] page.
 
==== CPU Mining ====
 
Early Bitcoin client versions allowed users to use their CPUs to mine. The advent of GPU mining made CPU mining financially unwise as the hashrate of the network grew to such a degree that the amount of bitcoins produced by CPU mining became lower than the cost of power to operate a CPU. The option was therefore removed from the core Bitcoin client's user interface.
 
  
==== GPU Mining ====
 
GPU Mining is drastically faster and more efficient than CPU mining. See the main article: [[Why a GPU mines faster than a CPU]]. A variety of popular [[Mining rig|mining rigs]] have been documented.
 
==== FPGA Mining ====
 
FPGA mining is a very efficient and fast way to mine, comparable to GPU mining and drastically outperforming CPU mining. FPGAs typically consume very small amounts of power with relatively high hash ratings, making them more viable and efficient than GPU mining. See [[Mining Hardware Comparison]] for FPGA hardware specifications and statistics.
 
==== ASIC Mining ====
 
An application-specific integrated circuit, or ''ASIC'', is a microchip designed and manufactured for a very specific purpose. ASICs designed for Bitcoin mining were first released in 2013. For the amount of power they consume, they are vastly faster than all previous technologies and already have made GPU mining financially.
 
  
==== Mining services (Cloud mining) ====
+
==== Incentive ====
[[:Category:Mining_contractors|Mining contractors]] provide mining services with performance specified by contract, often referred to as a "Mining Contract." They may, for example, rent out a specific level of mining capacity for a set price at a specific duration.
+
The first transaction in every block is called the Coinbase transaction. The Coinbase transaction is a special transaction which pays bitcoins to the creator of the block. The Coinbase payment is made up of the subsidy amount and the sum of all transaction fees paid by transactions within the mined block.  
  
 
=== Pools ===
 
=== Pools ===

Revision as of 11:11, 2 January 2020

Introduction

Mining is the process where nodes in the bitcoin network assemble newly broadcast bitcoin transactions into a data structure called a block. Nodes then compete to append their block to the public blockchain by attempting to find a hash value that satisfies a difficult proof-of-work.

When a node finds a valid proof-of-work hash for a block, it broadcasts the block to all nodes. Other nodes accept this block only if all the transactions in it are valid and not already spent. Nodes then express their acceptance of the block by working on creating the next block in the chain.

Every block is timestamped and references the hash of the block preceding it. Blocks form a backward reinforcing, timestamped chain – a ‘timechain’, the precursor to the term ‘blockchain’.

The blockchain structures itself in a manner that is computationally impractical to modify by any one entity. Due to this, transactions included in the blockchain are considered immutable. In addition to this quality, the blockchain establishes an authoritative order of these transactions throughout the network, thereby protecting users from attempts to re-spend coins that have already been spent elsewhere. This is the key innovation of mining and of bitcoin.

Nodes

Nodes are entities that run bitcoin software that adheres to the bitcoin protocol and carry out the mining functions above.

Interestingly, the bitcoin whitepaper makes no reference to the term ‘miner’ or the concept of ‘mining’. These terms are encompassed within Satoshi Nakamoto’s description of a ‘node’. It is possible however to run a node and make no attempts to find a proof-of-work. Such a setup is called a ‘listener node’ – they only participate in receiving and broadcasting transactions.

Listener nodes perform no proof-of-work and therefore cannot append new blocks to the blockchain. They can neither express acceptance of valid blocks by working on extending them, nor reject invalid blocks by refusing to work on them. Listener nodes are passive entities that follow the gatekeepers of the network, the miners. An example of a listener node is a block explorer. Block explorers are a useful service that allow users to query the blockchain for block or transaction information.

Mempool

Before a bitcoin transaction can be committed to the blockchain it needs to be received and validated by a miner. If the miner deems the transaction has paid enough in fees, they add the transaction to their mempool. As such, the mempool is just a temporary transaction store.

It is important to note every miner has their own mempool and that mempools vary across miners. It is also important to note that an individual transaction can be included in many different miner’s mempools at the same time.

A miner takes all the transactions in its mempool and hashes them into a Merkle Tree structure and includes the resulting Merkle Root within a candidate block header. The miner then hashes this candidate block header, attempting to find a valid proof-of-work.

Hashing

A hash is a function that converts a string of data into a fixed length value that represents the original string, called the hash value. Every hash value is unique.

Hashing is a one-way function, meaning it is infeasible to determine what the input data is by looking at the hash produced from it. Conversely, it is trivial to run the same input data through the same hash function and reproduce the same hash. Because of this, a hash value of input data can be thought of as the digital fingerprint of that data. In bitcoin mining, the input data is the 80-byte block header.

The hashing algorithm used in bitcoin mining is SHA-256. SHA-256 stands for Secure Hash Algorithm – 256 bit. Passing the block header data through this algorithm will always output a 256-bit number that is unique.

Bitcoin mining passes the block header data through the SHA-256 algorithm twice (SHA-256d). The reason for this is to accommodate the presumed future fracture of mining interests into separate specialized entities. A double hash allows for a hashing entity to indicate they have a valid proof-of-work to another mining related entity without having to reveal the block header input data.

The BSV network is currently making 1.3E18 attempts to find a valid block hash every second.

Proof-of-work

Bitcoin uses the hashcash proof-of-work function.

A miner cannot create a new block without finding a valid proof-of-work hash for the block header they are hashing. To be valid, the SHA-256d hash (which is just a number) of the block header must be less than another number, called the target. The target value is defined by the nBits field in the block header that is being hashed.

The target adjusts so that the average time it takes to find a valid proof-of-work hash is ten minutes.

Because of the extraordinarily large SHA-256 target space, it is extremely unlikely that any given hash will be below the target. As a result of this, hashing entities invest large amounts of capital into specialized hashing hardware along with the associated electricity costs in order to produce as many of these hashes as possible. Therefore, the only way a miner can append a block to the blockchain is through substantial financial commitment – proof-of-work.


Incentive

The first transaction in every block is called the Coinbase transaction. The Coinbase transaction is a special transaction which pays bitcoins to the creator of the block. The Coinbase payment is made up of the subsidy amount and the sum of all transaction fees paid by transactions within the mined block.

Pools

As more and more miners competed for the limited supply of blocks, individuals found that they were working for months without finding a block and receiving any reward for their mining efforts. This made mining something of a gamble. To address the variance in their income miners started organizing themselves into pools so that they could share rewards more evenly. See Pooled mining and Comparison of mining pools.

History

Bitcoin's public ledger (the "block chain") was started on January 3rd, 2009 at 18:15 UTC presumably by Satoshi Nakamoto. The first block is known as the genesis block. The first transaction recorded in the first block was a single transaction paying the reward of 50 new bitcoins to its creator.

Staking

Staking is a concept in the Delegated proof of stake coins, closely resembling pooled mining of proof of work coins. According to the proof of share principle, instead of computing powers, the partaking users are pooling their stakes, certain amounts of money, blocked on their wallets and delegated to the pool’s staking balance.

The network periodically selects a pre-defined number of top staking pools (usually between 20 and 100), based on their staking balances, and allows them to validate transactions in order to get a reward. The rewards are then shared with the delegators, according to their stakes with the pool.

Although staking doesn’t require lots of computing power as mining, it still needs very stable and fast Internet connection in order to collect, verify and sign all transactions in the queue within a small timespan, which can be as short as one second. If a pool fails to do so, it doesn’t get the reward, and it may be shared with the next pool in order.

See Also

ru:Mining