Mining activities have been integral to blockchain technology since its advent and widespread adoption. It revitalizes the decentralized characteristics of public blockchains where miners verify transactions and add them to a block of other immutable data in the distributed ledger.
Mining in the blockchain is a process of verifying transactions and recording or admitting verified transactions into a block. The blocks are then added to the blockchain's existing chain of blocks. In addition, mining is also the process of creating new cryptocurrencies or tokens like bitcoin and altcoins. It is done by validators or verifiers called "miners." Blockchain mining can be done individually as a single miner or in a group—pooled mining—and cloud mining.
The core reason for mining is to validate transactions on the blockchain before recording them and secure the blockchain network because the more the number of miners keeps increasing in a particular blockchain, the more it is secure and less susceptible to an attack—a 51% attack.
Blockchain mining has protocols that it follows depending on each blockchain's architecture. The protocols can be proof-of-work—PoW—, proof-of-stake—PoS—or Delegated proof-of-stake—DPoS. The prominent protocol is the PoW, where miners are required to solve cryptographic puzzles by expanding their computing power.
PoW is a consensus mechanism for validating transactions in a blockchain network. It entails solving cryptographic puzzles to win the right to fill the next block. Miners in a blockchain compete to solve this puzzle; whoever solves it first before others and publishes it wins the right to fill the next block.
All these, including filling the next block, are done to win the incentives—block reward—attached to adding a block from the transaction fees paid by users who initiate transactions.
Aside from fortifying the security architecture of the particular blockchain, PoW consensus also aims to forestall double-spending by ensuring that a cryptocurrency or digital token is not spent more than once to transact. This PoW consensus mechanism is adopted by Bitcoin, Ethereum, and other bigwigs in the blockchain industry.
Selfish mining is a scenario where a miner mines a new block but fails to publish it for other miners to see and add it to the chain of blocks on their ends. It is also called "Block withholding" because the miner withholds the valid block from others, restraining it to his copy of the blockchain alone.
Selfish mining is practically harboring a private blockchain within a public blockchain. However, the withheld block will later be revealed by the miner. Still, this deceptive mining strategy could disrupt mining activities or lead to a 51% attack if done by a large group of miners.
If done successfully by a single or individual miner, other miners who had previously filled a block will lose their block reward to the selfish miner.
Let's take a practical example of selfish mining.
Let's assume there are five miners on a blockchain: Jerry, Rudolf, Chloe, Rolland, and Pete, assuming they all have equal hash rates—20% each. All the miners are trustworthy, except for Rolland, who is in for personal aggrandizement. When miners find a block, they are expected to publish it to the chain so that it is distributed across all nodes.
All four miners stick to this except for Rolland. When Rolland discovers a block, he keeps it to himself as if nothing has happened.
Assuming the miners had previously mined 91,696 blocks collectively before Rolland started acting weird. While trying to discover the next block, Rolland finds it but keeps it from others. That makes two chains; the public chain and Rolland's private chain, which is longer than the public chain. He's now trying to extend his secret chain to form a private branch.
As other miners are still attempting to find the 91,697th block, Rolland finds his 91,698th block, making his chain two blocks ahead of the public chain. If he keeps going with this pacing, he will stay ahead of the public chain. So, when others catch up, and they're one block behind him, he publishes his secret chain.
Since Rolland's chain is longer than the public chain that his contemporaries were working on, his chain will overtake the public chain and be recognized because of the "longest chain rule." The longest chain rule recognizes the chain with the most proof-of-work as the main or correct chain.
So, if a node discovers a chain with more accrued work, it will flip and commit mining power to this long chain.
Now that Jerry, Rudolf, Chloe, and Pete have seen Rolland's chain, they recognize it as the chain to follow. Therefore, any rewards the four would have earned from the snipped chain no longer exist since their chain is no longer recognized. On the other hand, Rolland earns all the rewards since he mined the blocks in the recognized chain.
However, there is a catch to this strategy; as Rolland was creating his secret chain, if Chloe, Pete, or any of the miners finds a block, then Rolland won't be able to publish his secret blocks and have the longest chain. Instead, it will be a competition between the two branches since they have the same length.
So, whoever can create the longest chain between the public chain and Rolland's secret chain wins or becomes the legitimate chain.
Selfish mining poses a single threat that could escalate if not curtailed. If miners pooled their computing power together to maximize their earnings from selfish mining, it could result in a node having a 51% hash rate or more.
Every PoW blockchain requires 51% of the nodes on its blockchain to be honest to validate a transaction and create a new block. If a single node controls this 51% hash rate, such a node can disrupt mining activities and pend transactions with a lesser gas fee.
Using the five miners above as an example, recall that a 20% hash rate is delegated to each of them. If Pete and Chloe pooled their computing power—hash rate—with Rolland such that his hash rate now increases to 60%, then Rolland will be in control of the blockchain because a 51% attack has just occurred.
Since his hash rate is greater than his contemporaries, his node will be faster; so he decides which transaction goes through and stalls whichever transaction.
Furthermore, Rolland can double-spend crypto that he has previously spent. With his newly increased hash rate, the decentralization of such blockchain has crumbled, and the ecosystem has suddenly become centralized.
However, the possibility of this is implausible because if any malfeasance is discovered, it will cause the price of the cryptocurrency to plummet and dwindle. This aftermath will also affect the value of miners' digital assets, so they'll choose to keep working honestly rather than pooling with a selfish miner.
Though selfish mining might not have occurred or been reported in any blockchain, as enthusiasts keep exploring further use cases of the technology, attackers are also becoming greedy and exploring schemes to exploit the novel technology.
However, one of the ways to forestall selfish mining from escalating is to designate threshold caps for mining pools on the network. This will prevent any selfish miner from outperforming other nodes.
Photo by Artyom Korshunov on Unsplash