This is the archived Spring 2015 version of the course. For the most recent version, see http://bitcoin-class.org.

# Class 14: Selfish Mining

Posted: Mon 02 March 2015

## Schedule

• Project 2 Part 2 is due next Thursday, 5 March. Submission is by email, send a PDF with your answers to questions 5-9.

• Keep thinking about ideas for your project. The first deliverable for the project will be a preliminary proposal due on March 19.

Note: due to a bug in slideshare's updated player, ink markings no longer appear in the viewer.
If you download the slides, they are present though. Hopefully, the player will be fixed someday.

## Mining the Last Bitcoin

Computing the block value:

```CAmount GetBlockValue(int nHeight, const CAmount& nFees)
{
CAmount nSubsidy = 50 * COIN;
int halvings = nHeight / Params().SubsidyHalvingInterval();

// Force block reward to zero when right shift is undefined.
if (halvings >= 64)
return nFees;

// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
nSubsidy >>= halvings;

return nSubsidy + nFees;
}
```

Interestingly, the first commit version of this code in github (29 August 2009) is missing the `halvings >= 64` line we talked about in class:

```int64 CBlock::GetBlockValue(int64 nFees) const
{
int64 nSubsidy = 50 * COIN;

// Subsidy is cut in half every 4 years
nSubsidy >>= (nBestHeight / 210000);

return nSubsidy + nFees;
}
```

Will a node running the early version of this code (assuming the global `nBestHeight` is equal to `nHeight`) ever compute a different block value than a node running the current version of the code?

Python code for estimating block time: subsidy.py

```> expect_block(6929999)
2132-05-19 00:50:38.200000
```

Why is it likely that the expected final bitcoin generation block is found in 2132 instead of 2140 (as estimated by 10 minute expected block generation rate)?

## Selfish Mining

What are the risks and benefits of witholding a found block?

Based on the submarine cable map, where should you put your bitcoin mining operation?

Suppose you (and no other bitcoin nodes) had access to an under-Artic fiberoptic cable, providing faster than currently possible routes between Japan and Anchorage. Would this provide a valuable advantage in bitcoin? Would you prefer to have a fast microwave link between Japan and Finland?

This is the paper about selfish mining: Ittay Eyal and Emin Gün Sirer, Majority is not Enough: Bitcoin Mining is Vulnerable (Nov 2013). There has been a lot of debate about this paper and the claim that rational miners will behave selfishly: