Blockchain mining is the process of securing and verifying blockchain transactions. Miners basically add transaction data to the public ledger. And wherever they do that, they receive a ‘block reward’ in the form of cryptocurrencies. So, if you’re a miner your goal would be to earn as much reward as possible through mining. This is when selfish mining comes into play.
What Is Blockchain Mining?
In order to understand what selfish mining is, you must first understand what is blockchain mining. We’ve already explained it in depth in a previous article, but here’s a quick recap.
The blockchain records the transactions in ‘blocks’. Each block has a unique ID plus the ID for the previous block. Each block is connected to the one prior to it and the one after it.
Plus, each block needs to be validated by miners. These miners have to solve a crypto puzzle to validate the block and the winners receive a ‘block reward’ as a result.
A block reward is made of:
- Block subsidy: Newly generated coins (the biggest part of a block)
- Transaction fees: All fees paid by the transactions that are included in the block
So, in order to make money, miners have to keep validating or ‘adding’ blocks. But to avoid chaos there are rules they must follow.
All miners add blocks to the longest chain they know of or the first one they heard of if there are branches of equal length.
In this case, they mine on top of chain 2. And if 1 and 2 were the same length, and they heard of 1 before, they mine on top of 1.
Moreover, the reward is proportionate to the number of blocks the miner adds. So, miners want to make sure the fraction on the main chain added by them is the highest possible.
With this information in mind, let’s move on to selfish mining.
What Is Selfish Mining?
Selfish mining refers to miners strategically mining blocks in a way that solely benefits them. But, how do they do that? Let’s take a very simple example to explain the process.
Let’s say there are 3 current publicly validated blocks: B1, B2, and B3. And two groups of miners: honest and selfish.
Honest miners continue to try solving the puzzle in order to get a reward. Once they do, they put the block into the public for everyone else to build upon. So if they discovered block 4, they add it to the existing chain.
However, when selfish miners discover a block they keep it a secret. They secretly build their own separate chain of blocks. Now selfish miners have a chain of the following secret blocks: S1, S2, and S3.
But, How Do Selfish Miners Make Money?
Alright, we understand what selfish mining is but how do these miners make money “selfishly”?
Well, now we have honest miners’ chain of one block, B4, and selfish miners’ chain of 3 blocks, S1, S2, and S3.
If selfish miners decide to put their chain public, all other miners have to build upon it. Why? Because it’s the longest one. What does this lead to?
- Other miners would’ve wasted all resources on blocks they won’t get rewards for because they won’t go public.
- Selfish miners would get rewards and would have a bigger portion of the longest chain.
But, miners don’t randomly make chains public. They make sure to stay at least one block ahead of the rest of the network. When they find that the network has discovered let’s say B4 and B5, they’re more likely to make their chain public. Otherwise, they risk being the ones at a loss.
How To Limit Selfish Mining?
Selfish mining has been elaborated on in detail by Cornell researchers in a 2013 paper titled “Majority is not Enough: Bitcoin Mining is Vulnerable”. The researchers explained in this paper that honest miners would eventually join selfish mining pools as it would be the more lucrative way for them. In the long run, this would hinder blockchain’s decentralization.
However, it’s important to note that this is only possible if selfish miners take control over 51% of the blockchain’s computational power. This is almost impossible in well established blockchains like Bitcoin and is more likely to happen with smaller networks.
Nevertheless, new methods were suggested to prevent selfish mining.
- Randomization technique: When miners stumble upon more than one fork, they randomly select which fork they continue working on.
- Branding each block with a timestamp: This timestamp will have information on when each block was mined. So, if a block was mined privately, honest miners would know and eliminate it.
In conclusion, no matter where you go, you will inevitably find people who would want to play life on their own terms. Web3 is no different and selfish mining is proof of that. It’s just one of many blockchain attacks. You can read more about blockchain attacks here. Take care!