Proof of Work (PoW) blockchains use a form of State Machine Replication (SMR) system wherein anyone can join and be able to receive incentives given that they follow the set of protocols. The participants for this kind of system are called miners. As the system grew, more miners were able to get incentives. However, some miners found loopholes to the protocol allowing them to earn more — this is called Selfish Mining.
Defining Selfish Mining
In selfish mining, a miner, or group of miners, increases their revenue by strategically withholding and releasing blocks to the network. Per protocol, miners announce a block as soon as they find it. If the block is confirmed, they will get the block reward. But by not broadcasting it (technically keeping it a secret to others), these miners technically create their own private branch of the blockchain. The rest of the network continues to build on the previous block, while the selfish miner builds on top of this new chain. From that point, both chains will look completely different.
The goal of the selfish miner is to remain at least one block ahead of the rest of the network. Nodes work by accepting the chain with the most accumulated proof-of-work as the valid blockchain. When nodes start working, this is the perfect time for selfish miners to reveal the chain they hid. If this newly revealed block is longer than the rest of the network, the existing blocks will be discarded and transactions will be reversed. The selfish miner then collects all of the rewards from these blocks, putting those honest miners’s effort and resources to waste.
How does Selfish Mining work?
The most comprehensive exploration of selfish mining can be found in the 2013 paper Majority is not Enough: Bitcoin Mining is Vulnerable by Cornell researchers Ittay Eyal and Emin Gun Sirer. They proved that it was possible to earn more bitcoins by hiding newly-generated blocks from the main blockchain, creating a blockchain fork. Their thesis also states that, contrary to popular belief, the incentives for Bitcoin miners are flawed and may ultimately lead to the centralization of the network.
Here is an example to elaborate how Selfish Mining works:
Suppose that the total hash rate is evenly divided up amongst 4 miners: Alice, Bob, Carol, and Dan (each with 25%). Alice, Bob, and Carol play by the rules, but Dan is trying to exploit the system for his own gain.
Under normal circumstances, we would expect the miner that finds a block to append it to the chain immediately. And this is what Alice, Bob, and Carol do as honest participants. But if Dan finds a block, he withholds it (it’s a valid solution, but it has yet to be added). Dan may get lucky and find two blocks in a row before anyone else.
Let’s suppose that 100,000 blocks have been mined. So now we have Alice, Bob, and Carol attempting to propose the 100,001st block. Dan finds it but keeps this information private. There are now two chains, the public one and Dan’s secret (and longer) one. While the others are still trying to find block 100,001, he finds 100,002.
Dan’s chain is now two blocks ahead. Provided his luck doesn’t run out and he is always able to remain ahead of the other chain with this distance, he keeps going. When the others catch up so that they’re only one block behind, he unveils his chain.
Dan’s now-public chain is longer than the one the other participants were working on. According to a rule that we call the longest chain rule, the “correct” chain to work on is that which has accrued the most Proof-of-Work (a metric also referred to as chainwork). So, if a node detects a chain that has more accumulated work, it will switch and dedicate mining power to this longer chain.
Now, Alice, Bob, and Carol see Dan’s chain — they now recognize this one as the chain to follow. Any rewards they would have earned on the other chain will no longer exist. And since Dan has mined those blocks on the current chain, he keeps all of the rewards.
Solutions to prevent Selfish Mining
While selfish mining poses real threats to blockchain, two possible solutions have been proposed to prevent selfish mining attacks from occurring. The first is to randomly assign miners to branches of the blockchain when a fork occurs, and the second is to set threshold limits for mining pools on the network that would prevent selfish miners from gaining a significant advantage over other miners operating on the network.
Final Thoughts
Indeed, selfish mining is an attractive and lucrative way to boost crypto earnings, only if miners can successfully execute its daunting process. The worst-case scenario is that honest miners will be recruited by selfish miners by offering them better incentives, causing a huge toll on the blockchain and its decentralized nature.
Realizing the whole scenario of selfish mining, it makes little to no sense at all for parties to be involved in this illicit act as staging an undermined security of the network can cause a drastic drop on the blockchain’s price, which directly impacts the profitability of a whole mining operation. As the technology continues to improve, it will only be a matter of time when all selfish miners will be terminated from the blockchain network.