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

PointCoin Pizza

Posted: Sat 21 February 2015

The PointCoin currency has now reached the level of stability and market acceptance, that merchants are beginning to accept it!

PointCoin Pizza is now open and accepting orders.

Note that PointCoin Pizza's opening hours are unpredicatable and unannounced, so there is no guarantee that your pizza order will be delivered within a reasonable time. The price of pizza is currently 150 PTC, but it may go up rapidly depending on market conditions.

Spend your PointCoins carefully, though. You don't want to be reading about The Bitcoin Pizza Purchase That's Worth $7 Million Today.


Class 11: Pools and Profits

Posted: Wed 18 February 2015

Schedule

  • Project 2, Part 1 is due Sunday, 22 February.

  • Quiz 2 will be in class on Wednesday, 25 February. It will be similar in length, format, and content to Quiz 1 (except will cover material from the beginning of the class through

  • Continue thinking about project ideas!

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 Model

Mining Harware on the market today: Spondoolies SP20 (this is just an example, certainly not a commercial endorsement!)

Cost: US$ 479
Hash rate: 1.7 TH/s
Power use: 1200 W
BTC Price: US$ 240
Difficulty: 44455415962 # from https://blockchain.info/stats, 18 Feb 2015

This spreadsheet has lots of information about bitcoin difficulty over time.

Please don't make any investment decisions based on any of these models! Even the best one is still much simplified and with many guesses (e.g., assumption that BTC value will not change, slow increase in difficulty).

Super Simple Model

>>> expected_hashes / (1.7 * 10**12)
112314445.6981567 # expected seconds to find block
>>> _ / (60 * 60 * 24)
1299.935714099036 # days to find block
>>> block_value = 240 * 25
>>> earnings_per_year = block_value * (365.25 / 1300)
>>> earnings_per_year
1685.769230769231
````

Why is this estimate of expected earnings totally broken?
<div class="gap">

</div>

### Better Model

Python code (excerpted below): [mining.py](|filename|./mining-simple.py)

```python
def guess_difficulty(month):
    return difficulty * ((1 + rate_of_difficulty) ** month)

hash_rate = 1.7 * 10**12 # 1.7 Th/s
hashes_in_month = hash_rate * 60 * 60 * 24 * ave_days_in_month
block_value = 25 * 240 # assumes fixed BTC value 
electricity_cost = (1.2 * kWh) * 24 * ave_days_in_month

def expected_revenue(month):
    success_probability = find_target(guess_difficulty(month)) / 2**256 
    return block_value * hashes_in_month * success_probability

def cumulative_income(months):
    income = 0.0
    for month in range(months):
        income += expected_revenue(month) - electricity_cost
    return income

Given this model, when should the miner be turned off and turned to scrap?

Bitcoin core code: GetBlockValue, ChainParams

What should happen to the bitcoin difficulty when subsidy is halved after block 420,000? (Current block is 344,044 so we should reach block 420,000 in (420000-34400 / (6 * 24)) = 527 days.)

Mining Pools

How can an open mining pool fairly determine miners share of the reward? Why is it not sensible to use actual blocks mined to estminate pool share?

What are the risks of a mining pool controlling a large fraction over the hashing power? Does anything dramatic happen when that fraction exceeds 50%?

Links

What Happens At Armageddon? (Ittay Eyal and Emin Gün Sirer, 13 June 2014)

Discussion about Eligius Block Witholding Attack


Project 2 - New Network Up

Posted: Tue 17 February 2015

The new PointCoin network is now up! This fixes the reset problem and some other issues that were discussed in Monday's class. It also sets the expected block generating time to 10 minutes and the mining reward to 10 PointCoin.

To migrate your node to the PointCoin 0.2 network follow these directions:

Once you have your node running on the new network, add your public IP address here:

There is no automatic peering. We believe this is a design decision in btcd (which pointcoind is forked from), to not trust any node that is not announced by multiple other nodes.

You can see the blockchain at: http://blockexplorer.bitcoin-class.org/. We will consider this the canonical PointCoin blockchain (at least until next Monday, when you can start launching attacks).

Because of the problems with the network, it is no longer necessary to acquire 100 PointCoin to earn full credit for Problem 1. It is sufficient to successfully mine at least one block. Earning more PointCoin will still be beneficial though! You'll have other opportunities to use it.

Thanks a bunch to Alex and Nick for tremendous work getting this working! It seems to be stable, and our nodes (including nodes running on EC2 micro instances) have been stable (no crashes) for more than 24 hours now, so we're optimistic there will not be further problems.

I'm really sorry for the confusion and trouble this has caused, not to mention the PointCoins you've lost that you may have mined successfully on the original network. I think we'll learn a lot from trying to launch a cryptocurrency, and there is plenty that can go wrong.


Class 10: More Mining

Posted: Mon 16 February 2015

Schedule

  • Project 2, Part 1 is due Sunday, 22 February. Part 2 will begin afte class on Monday, 23 February and is due on Thursday, 5 March.

  • Start (continue!) thinking of ideas for your final project. I've posted a few starting ideas on the course site. The first major deliverable for the final project will be a project proposal (due 20 March)

  • Reading: finish reading through Chapter 8: Mining and Consensus.

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.

Final Project

Your main assignment after finishing Project 2 will be an open-ended project. You can work on anything you want that is related to cryptocurrency (loosely defined), so long as you can convince me it will be interesting and worthwhile. My hope is everyone will do a project that will have significant value beyond just our class.

You can work alone or in a team of any size. The impressiveness of your project should scale with the size of your team (but not linearly, since there is added communication overhead as your team size increases). It should scale as at least N2/3 where N is the number of students in the course on your team. (You are welcome to enlist help from people not in the class, and they don't count towards your N value.)

Forking PointCoin

What causes a blockchain to fork?

If all the trans-pacific network cables (there are only about 12) were cut, what would happen to the bitcoin blockchain?

Asymptotic Analysis

When is asymptotic analysis useful?

When is asymptotic analysis useless?

The measured time to compute one SHA-256 hash on my EC2 node (2.5 GHz processor) is 750 ns. Approximately how many instructions execute to compute on SHA-256 hash?

Mining Cost

Assumption. SHA-256 produces a uniform random output. (We know this is not really true, but it is a reasonable approximation, and necessary for the analysis.) So, we can model SHA-256 on any (new) input x as drawing randomly from 2256 possible outputs:

      SHA-256(x) ← [0, 2256)

Target = Tmax / Difficulty
Tmax = (216 – 1)2256 ≈ 2224

Current (15 Feb) Bitcoin Difficulty = 44,455,415,962

>>> target = 2 ** 224 / 44455415962
606449092506427232846302685260647042725721699378946247123L
>>> success_probability = target / 2**256
5.237396582969569e-21
>>> expected_hashes = 1 / success_probability
1.9093455768686638e+20
>>> nanos_needed = expected_hashes * 760
>>> seconds_needed = nanos_needed / 10**9
145110263842018.44
>>> days = seconds_needed / (60 * 60 * 24)
1679516942.6159542
>>> years = days / 365
4601416.2811396
>>> years * 2
~ 9.2 M years to find one block on EC2 (assuming difficulty doesnt increase)

Energy

Why is energy/hash so much less for custom ASICs?

In an ASIC, it is possible to build an XOR using 4 transistors. How many transistors have to flip to do an XOR on a general purpose processor like an Intel i7?

Mining Hardware - current ASIC miners achive >5 Billion hashes per seconds and over 1500 Million hashes per Joule (the energy required to lift an apple one meter).

Inside a Chinese Bitcoin Mine, The Coinsman, 11 August 2014.

The first thing you notice as you approach the warehouse is the noise. It begins as soon as you step out of the car, at which point it sounds like massive swarm of angry bees droning away somewhere off in the distance. It becomes louder and louder the closer you get to the building, and as you step through the doors it becomes a deafening and steady roar...

Estimate for total energy use of bitcoin network with current hashrate:

>>> expected_hashes
1.9093455768686638e+20
>>> hashes_per_second = expected_hashes / 600
3.18224262811444e+17
>>> 309384699.96 * 10**9 # according to blockchain.info: 309,384,699.96 GH/s
3.0938469996e+17
>>> _ / hashes_per_second
0.9722222222361415
>>> Mhash_per_J = 1500
>>> Mhash_per_second = hashes_per_second / 10**6
>>> J = Mhash_per_second / Mhash_per_J
212149508.54096264

212 MJ per second = 212 MW

Our nearest nuclear plant, the North Anna Power Station (Lake Anna) generates 1892 MW, "enough to power 450,000 homes" or about 9x the amount needed to power the current bitcoin network (only counting the miners themselves; additional power needed for cooling, etc.)

How does the energy use of bitcoin compare to what is used by the current financial infrastructure for comparable service? (This is a very difficult question to answer, would be a good project idea, not something to answer in the blank below!)


Class 9: Mining (Wed 11 February 2015)

Project 2 (Wed 11 February 2015)

Class 8: Review and Project 2 (Mon 09 February 2015)

Starting Project 2 (Thu 05 February 2015)

Class 7: Merkle Trees (Wed 04 February 2015)

Class 6: Proofs of Work (Mon 02 February 2015)