This article is a followup to https://www.yours.org/content/selfish-mining-for-the-laymen-40b049d49d19 that explores the inconsistency between the claims made in the Selfish Mining paper https://arxiv.org/pdf/1311.0243.pdf and results I obtained via running a simulation.

Background

A selfish miner has some percentage of the total network hashrate α

The selfish mining paper states that an attack is possible in the range

1/3 < α < 1/2

In the previous article the results from running a simulation demonstrated that SM would always earn less total revenue than they would for mining honestly for 0 < α < 1/2

I wanted to know what could account for this difference?

The Ghost in the Machine

When I ran the simulation, the results showed that SM would always get a better share than α would suggest compared to HM. However this was always at the total expense of everyone involved. From this it seemed clear that, despite making relatively more than HM. They could still make *even more* by just mining honestly.

My first clue as to why this was the case came from Peter Rizun chief scientist for Bitcoin Unlimited:

Encouraging words, with the pointer:

"Your main error was not accounting for difficulty adjusting downwards. If you had, you'd see that the SM _does_ come out ahead."

At this point it was still not clear to me why that would be the case. It would affect SM and HM both the same, and their repsective rate of finding block would be the same.

To make things more complicated, the results I obtained were independently corroborated by Jochen Hoenicke as part of this discussion on Reddit:

Again I failed to realise the significance of this statement from Jochen:

"It is only profitable after the next difficulty update"

So I tried to come at the issue from a different angle. It was clear to me that the number of blocks a miner solves is always dictated by how much hash they have. That is over time, blocks are found at a constant rate. So it also seemed fair that no amount of shuffling the timing of when you publish a block could change this. Therefore it seemed self evident that a selfish miner could not simply increase the number of blocks they mine over time in this fashion. Indeed this matched the results from my simulation that SM can only orphan HM blocks.

Whilst there is some truth in this, I was still overlooking that pesky difficulty adjustment.

A Difficult(y) Realisation

It was not until today that I realised what it was that I was missing. I came across a comment in a discussion about SM, suggesting that the Selfish Miner Paper does not mention difficulty:

I knew that it did (though I still beleived this was a moot point). Regardless, it's important to keep public discussion honest so I felt I should respond with the relvant information from the paper. So I opened it up and scrolled down to the end of section 4.2 to find the actual text to quote:

Once I'd posted this I sat and looked, and then realised the significance of the highlighted text. It was saying that as difficulty adjusts, then the orphan blocks are taken out of the equation. It's as if they never existed. This was the missing piece! I was assuming the difficulty adjustment did not alter the fact that a large number of blocks were being discarded (eg ~20% for A=0.35) and along with them, the potential revenue.

The selfish mining attack is about manipulating difficulty down through massively increasing orphan rate in order that SM can claim more blocks under the new easier difficulty (and proportionally more than the HM due to block withholding/orphaning).

Once I saw this I realised that it was theoretically possible for SM attack to work for 1/3 < α < 1/2.

Conclusion

The math in the Selfish Mining paper was never in question. That much has always been true for me. The question I was trying to find the answer for was why does the conclusion not match my data.

The conclusion drawn from the math in the paper relied on fully understanding how difficulty was leveraged by SM. My simulation lacked that, and my understanding of the effect of difficulty was also incorrect, which led me to false reasoning about how an SM cannot profit over time. Now I understand the effect that DA has over time, I can see how SM could work in theory.

Final Thoughts