Friday, December 22, 2017

BitCoin Mining

What is BitCoin Mining:
  • People send bitcoins to each other over the bitcoin network all the time, but unless someone (Data Miner's) keeps a record of all these transactions, no-one would be able to keep track of who had paid what. 
  • The bitcoin network deals with this by collecting all of the transactions made during a set period into a list, called a BLOCK. 
  • Now it’s data miners’ job to confirm those transactions, and write them into a general ledger (A long list of blocks, known as the 'BLOCKCHAIN).

  • Thus Bitcoin mining is the process of adding transaction records to Bitcoin's public ledger of past transactions or blockchain. 
  • OR Bitcoin mining is the process by which transactions are verified and added to the public ledger, known as the block chain.
  • Or Bitcoin mining process involves compiling recent transactions into blocks and trying to solve a computationally difficult puzzle.  

  • The participant who first solves the puzzle gets to place the next block on the block chain and claim the rewards.  
  • The rewards, which incentivize mining, are both the transaction fees associated with the transactions compiled in the block as well as newly released bitcoin.
  • Anyone with access to the internet and suitable software & hardware (if you are not using pool) can participate in mining.  
    • Software - 
      • Standard Bitcoin Client - This enables to connect your computer to the network and enables it to interact with the bitcoin clients. (https://bitcoin.org/en/download)
      • Bitcoin Mining Software  - This is what instructs the hardware to do the hard work, passing through transaction blocks for it to solve.
    • Hardware - Bitcoin Mining Hardware (Three Categries)
      • CPU/GPU Bitcoin Mining
      • FPGA Bitcoin Mining
      • ASIC Bitcoin Miners

What is BitCoin Mining Process: 
  • As discussed above:
    • People send bitcoins to each other over the bitcoin network all the time.
    • The bitcoin network deals with this by collecting all of the transactions made during a set period into a list, called a BLOCK. 
    • These transactions/blocks are then confirmed and written to a general ledger.
    • This general ledger (used to explore any transaction made between any bitcoin addresses) is a long list of blocks, known as the 'blockchain'. 
    • Whenever a new block of transactions is created, it is added to the blockchain, creating an increasingly lengthy list of all the transactions.
    • A constantly updated copy of the block is shared with everyone who participates, so that they know what is going on.
  • But this general ledger has to be trusted and ensure that blockchain stays intact, and is never tampered with... This is where the MINERS come in picture.
    • Check this - Link
    • It’s Miners job to record & confirm those transactions (otherwise no-one would be able to keep track of who had paid what), and write them into a general ledger (A long list of blocks, known as the 'BLOCKCHAIN).
    • Process:
      • When a block of transactions is created, miners put it through a process. 
      • They take the information in the block, and apply a mathematical formula to it, turning it into something else. 
      • That something else is a far shorter, seemingly random sequence of letters and numbers known as a HASH. 
      • This hash is stored along with the block, at the end of the blockchain at that point in time.
    • Note: 
      • Miners don’t just use the transactions in a block to generate a hash. Some other pieces of data are used too. 
      • One of these pieces of data is the hash of the last block stored in the blockchain.
    • Because each block’s hash is produced using the hash of the block before it, it becomes a digital version of a wax seal. It confirms that this block – and every block after it – is legitimate.
    • I.e. Because each block’s hash is used to help produce the hash of the next block in the chain, tampering with a block would also make the subsequent block’s hash wrong too. 
    • That would continue all the way down the chain, throwing everything out of whack.

BitCoin Mining Competetion:
  • As discussed above: Miners 'seal off’ a block by recording/creating transation and creating hash/attaching block to BlockChain (General Ledger)
  • Well in this process - 
    • Multiple Miners compete with each other to do this, using software written specifically to mine blocks. 
    • Every time someone successfully creates a hash, they get a reward of 25 bitcoins, the blockchain is updated, and everyone on the network hears about it. 
    • That’s the incentive to keep mining, and keep the transactions working.
  • This hashing process is the competing factor here. Whosoever creates fast, wins the incentive.
  • Proof of Work - 
    • The bitcoin protocol deliberately makes  hashing process more difficult, by introducing something called ‘proof of work’.
    • The bitcoin protocol won’t just accept any old hash. It demands that a block’s hash has to look a certain way; it must have a certain number of zeroes at the start. 
  • Nonce:
    • Miners aren’t supposed to meddle with the transaction data in a block, but they must change the data they’re using to create a different hash. 
    • They do this using another, random piece of data called a ‘nonce’. This is used with the transaction data to create a hash. 
    • If the hash doesn’t fit the required format, the nonce is changed, and the whole thing is hashed again. 
    • It can take many attempts to find a nonce that works, and all the miners in the network are trying to do it at the same time. 
    • That’s how miners earn their bitcoins.

Mining Hardware - Bitcoin Mining Hardware (Three Categries)
  • By this stage, you will understand how bitcoin works, and what mining means. 
  • Now you need to set up a bitcoin mining hardware and start generating some digital cash.
  • There are two main things to think about h/w when choosing it:
    • Hashing Rate - MHash/sec, GHash/sec, and THash/sec - Higher your hash rate,  more likely you are to solve a transaction block.
    • Energy Consumption
  • Three main hardware categories
    • CPU/GPU Bitcoin Mining
      • CPU - Least powerful category of bitcoin mining hardware is your computer.
      • GPU - Enhance Bitcoin Hash Rate.  You can buy from two main vendors: ATI and Nvidia
    • FPGA Bitcoin Mining (Field Programmable Gate Array)
      • Is an integrated circuit designed to be configured after being built. 
      • This enables a mining hardware manufacturer to buy the chips in volume, and then customize them for bitcoin mining before putting them into their own equipment.
      • Range: 750 Megahashes/sec
    • ASIC Bitcoin Miners (Application Specific Integrated Circuits)
    • This is where the action’s really at. 
    • They are specifically designed to do just one thing: mine bitcoins at mind-crushing speeds, with relatively low power consumption.
    • Range 5-500 GHash/sec

Mining Software
  • Depending on which equipment you choose, you will need to run software to make use of it. 
  • Typically when using GPUs and FPGAs, you will need a host computer running two things: 
    • Standard Bitcoin Client - This enables to connect your computer to the network and enables it to interact with the bitcoin clients. (https://bitcoin.org/en/download)
    • Bitcoin Mining Software  - This is what instructs the hardware to do the hard work, passing through transaction blocks for it to solve.

Bitcoin Mining Pools
  • Important ques.. anyone interested in mining cryptocurrencies faces is whether to mine SOLO or join a 'POOL'. 
  • There are a multitude of reasons both for and against mining pools. 
  • Pool is always good for high hash rate distribution but you have to share the benefit.
  • Going solo means you won’t have to share the reward, but your odds of getting a reward are significantly decreased.
  • List of Mining Pools: https://www.litecoinpool.org/pools

Ref: 
Ref: Mining Profitability Calculator
Hope this helps.

Arun Manglick