What is selfish mining on a blockchain?
Decentralization is crucial in most projects and networks on the blockchain. Bitcoin delegates transaction validation to nodes with computational power rather than relying on a central authority. On a proof of work (PoW) blockchain like Bitcoin, the process is called mining. Participants validate crypto transactions and receive rewards.
Security of the PoW blockchain depends on the assumption that the nodes will remain honest and share new blocks in the chain. But it is impossible to guarantee the honesty of every node. Some may fail to publish newly discovered blocks to win more rewards in a process called selfish mining.
What is selfish mining?
Selfish mining involves a miner or group of miners fraudulently withholding new blocks on the blockchain in order to monopolize the rewards for validating blocks. Mining refers to validating transactions on the Bitcoin network in exchange for the block reward and transaction fees, which is how Bitcoin mining works.
Selfish mining occurs when a miner keeps the information about a newly discovered block secret in order to collect more blocks than the public chain and get most of the block rewards.
Selfish miners, if successful in their attack, can change the trajectory of the blockchain. Their primary purpose is to subvert the public chain by creating more blocks, enough to dominate the main chain and monopolize the block rewards. Once they can replace the main chain with their private chain, the blocks and transactions in the blocks on the chain are completely different from what would normally be recorded.
How does selfish mining work?
To understand selfish mining, it is crucial to understand how blockchain mining works. When you send crypto from one wallet to another, the transaction is grouped with others to form a block encrypted with a 64-digit hexadecimal number called a hash. Miners compete to solve with computational power to guess the hash. The successful miner gets the right to validate the transactions in that block, add it to the public chain and receive the reward.
A selfish miner will compete with other miners to guess the hash and get the right to add the block to the blockchain. But instead of adding (publishing) the new block, a selfish miner hides that block and continues to mine blocks on top of it. The blocks mined selfishly are only revealed to get the maximum reward on the blocks.
The mining process happens simultaneously – not at the same time. On a large network like Bitcoin, thousands of transactions are processed. To save time, the transactions are grouped into blocks. Miners compete to be the fastest to solve the hash for a block, so they get to be the ones to add it to the chain.
But when a selfish miner mines and hides a block, he doesn’t hide it under a bushel. Instead, the miner fails to add it to the distributed ledger and creates what is referred to as an “accidental fork”. A random fork is just a series of blocks running alongside, but not part of, the blockchain. Although it is selfish mining, it is not really random.
While the other crypto miners continuously work on the public part of the blockchain, selfish miners build on their fork, intending to collect more blocks than the public chain, after which they publish it.
At this point one of three things can happen; if the public chain is longer than the selfish miner’s fork, they lose, and the (honest) public chain miners get their rewards. If the public chain is shorter, they win and the random fork is adopted as the valid chain. This is because a proof of work blockchain is built on the assumption that the longest chain is the valid chain. The “selfish” fork then becomes part of the main chain, and duplicate blocks on the main chain are discarded, causing miners who contributed to that chain to lose their rewards.
The PoW blockchain requires a lot of computational power to validate transactions, so a group of miners often perform a mining activity called a pool, which combines their computational power to increase their chances of getting rewards. A selfish miner needs to keep between five to ten percent of the hash rate on the network.
Is selfish mining dangerous?
One effect of a selfish mining attack is the centralization of the network. Nodes on PoW blockchains are required to use the longest chain as the valid version of the blockchain. Because honest nodes risk losing their reward if the selfish chain turns out to be longer upon publication, they are more likely to join the pool of selfish miners. Eventually, the selfish pool grows to become the majority on the blockchain and eliminates the decentralization on the network.
Mining centralization on the Bitcoin network can also cause delays in transactions. When a selfish pool becomes the majority in a network, it can dictate which transactions are added to the public chain. Selfish miners are more likely to prioritize blocks with higher rewards. This selection of transactions will lead to a pile of transactions and make the network inefficient.
Additionally, by introducing centralization to the blockchain, selfish mining creates the perfect environment for malicious actors. Problems like double spending can also be performed because the task of validating transactions lies in the power of dishonest nodes.
Strategies to combat selfish mining
Several strategies have been proposed to combat selfish mining on the Bitcoin network, and each strategy has a different approach. While some suggest making changes to the network, other strategies include giving nodes incentives to remain honest.
The first solution proposed is a randomization technique. This is known as a backwards compatible change. It requires miners who stumble upon more than one fork on the blockchain to randomly choose which fork to continue working on. In addition to choosing blocks at random, miners must publish information about all discovered blocks and forks. Because selfish mining relies on a private chain and deliberately continuously mining on that chain, introducing a random selection process undermines the activity.
A separate strategy involves marking each block with a timestamp. The timestamp will contain information about when each block was mined, so when a block is privately mined and then added to the main chain with its outdated timestamp, it can easily be picked from the rest and discarded.
Selfish mining reduces Bitcoin’s value
Regardless of their lucrative appeal, selfish mining attacks can negatively impact the blockchain network. They can lead to centralization and transaction delays, creating the perfect environment for malicious actors.
Several strategies have been proposed to combat selfish mining, including making changes to the protocol and encouraging nodes to remain honest. Ultimately, for miners to be profitable, it is in their best interest to act honestly and maintain the value proposition of the cryptocurrency.