Mining, network, economics Joseph Bonneau Recap: Bitcoin miners - - PowerPoint PPT Presentation

mining network economics
SMART_READER_LITE
LIVE PREVIEW

Mining, network, economics Joseph Bonneau Recap: Bitcoin miners - - PowerPoint PPT Presentation

Lecture 2 Mining, network, economics Joseph Bonneau Recap: Bitcoin miners Bitcoin depends on miners to: Store and broadcast the block chain Validate new transactions Vote (by hash


slide-1
SLIDE 1

Mining, network, economics

Lecture 2 Joseph Bonneau

经济学 采矿业 计算机网络 電學

slide-2
SLIDE 2

Recap: Bitcoin miners

Bitcoin depends on miners to:

  • Store and broadcast the block chain
  • Validate new transactions
  • Vote (by hash power) on consensus

Miners rewarded with new coins Who are the miners?

slide-3
SLIDE 3

Lecture 2.1: The task of Bitcoin miners

slide-4
SLIDE 4

Mining Bitcoins in 6 easy steps

  • 1. Join the network, listen for transactions
  • a. Validate all proposed transactions
  • 2. Listen for new blocks, maintain block chain
  • a. When a new block is proposed, validate it
  • 3. Assemble a new valid block
  • 4. Find a nonce to make your block valid
  • 5. Hope everybody accepts your new block
  • 6. Profit!
slide-5
SLIDE 5

Mining Bitcoins in 6 easy steps

  • 1. Join the network, listen for transactions
  • a. Validate all proposed transactions
  • 2. Listen for new blocks, maintain block chain
  • a. When a new block is proposed, validate it
  • 3. Assemble a new valid block
  • 4. Find a nonce to make your block valid
  • 5. Hope everybody accepts your new block
  • 6. Profit!

easy very hard

slide-6
SLIDE 6

Bitcoin P2P network

  • Ad-hoc protocol (runs on TCP port 8333)
  • Ad-hoc network with random topology
  • All nodes are equal
  • New nodes can join at any time
  • Forget non-responding nodes after 3 hr
slide-7
SLIDE 7

Joining the Bitcoin P2P network

1 6 4 7 3 5 2 8 Hello World! I’m ready to Bitcoin!

slide-8
SLIDE 8

Joining the Bitcoin P2P network

1 6 4 7 3 5 2 8 getaddr() 1, 7

slide-9
SLIDE 9

Joining the Bitcoin P2P network

1 6 4 7 3 5 2 8 getaddr() getaddr() getaddr()

slide-10
SLIDE 10

Joining the Bitcoin P2P network

1 6 4 7 3 5 2 8

slide-11
SLIDE 11

Transaction propagation (flooding)

1 6 4 7 3 5 2 8 New tx! A→B

A→B

slide-12
SLIDE 12

Transaction propagation (flooding)

1 6 4 7 3 5 2 8

A→B A→B A→B

A→B A→B

slide-13
SLIDE 13

Transaction propagation (flooding)

1 6 4 7 3 5 2 8

A→B A→B A→B A→B

A→B A→B A→B A→B A→B

A→B

slide-14
SLIDE 14

Nodes may differ on transaction pool

1 6 4 7 3 5 2 8

A→B A→B A→B A→B A→B

New tx! A→C

A→C A→B

A→C

A→C

slide-15
SLIDE 15

Nodes may differ on transaction pool

1 6 4 7 3 5 2 8

A→B A→B A→B A→B A→B

A→B A→C A→C A→B

A→C A→C ???

A→C

slide-16
SLIDE 16

Yonatan Sompolinsky and Aviv Zohar: “Accelerating Bitcoin’s Transaction Processing” 2014

slide-17
SLIDE 17

Lecture 2.2: Finding a valid block

slide-18
SLIDE 18

It’s never easy being a miner

Chilkoot pass, 1898 Klondike gold rush

slide-19
SLIDE 19

Finding a valid nonce is the hard part!

H( ) H( ) H( ) H( ) H( ) H( )

25.0→A coinbase: 0x0000...00 transaction transaction transaction

mrkl_root: H( ) prev: H( ) mrkl_root: H( ) hash: 0x0000 nonce: 0x7a83 prev: H( ) hash: hash: 0x3485... hash: 0x6a1f... nonce: 0x0000... nonce: 0x0001... hash: 0xc9c8... nonce: 0x0002... hash: 0x300c... nonce: 0xffff... hash: nonce: 0x0000...

25.0→A coinbase: 0x0000...01

hash: 0xd0c7...

25.0→A coinbase: 0x3df5...65

slide-20
SLIDE 20

Finding a valid nonce is the hard part!

H( ) H( ) H( ) H( ) H( ) H( )

25.0→A coinbase: 0x0000...00 transaction transaction transaction

mrkl_root: H( ) prev: H( ) mrkl_root: H( ) hash: 0x0000 nonce: 0x7a83 prev: H( ) hash: hash: 0x3485... hash: 0x6a1f... nonce: 0x0000... nonce: 0x0001... hash: 0xc9c8... nonce: 0x0002... hash: 0x300c... nonce: 0xffff... hash: nonce: 0x0000...

25.0→A coinbase: 0x0000...01

hash: 0xd0c7... nonce: 0x0001... hash: 0x0224...

25.0→A coinbase: 0x3df5...65

slide-21
SLIDE 21

Finding a valid nonce is the hard part!

H( ) H( ) H( ) H( ) H( ) H( )

25.0→A coinbase: 0x0000...00 transaction transaction transaction

mrkl_root: H( ) prev: H( ) mrkl_root: H( ) hash: 0x0000 nonce: 0x7a83 prev: H( ) hash: hash: 0x3485... hash: 0x6a1f... nonce: 0x0000... nonce: 0x0001... hash: 0xc9c8... nonce: 0x0002... hash: 0x300c... nonce: 0xffff... hash: nonce: 0x0000...

25.0→A coinbase: 0x0000...01

hash: 0xd0c7... nonce: 0x0001... hash: 0x0224...

25.0→A coinbase: 0x3df5...65

hash: 0x590e... nonce: 0xffff...

slide-22
SLIDE 22

Finding a valid nonce is the hard part!

H( ) H( ) H( ) H( ) H( ) H( )

25.0→A coinbase: 0x0000...00 transaction transaction transaction

mrkl_root: H( ) prev: H( ) mrkl_root: H( ) hash: 0x0000 nonce: 0x7a83 prev: H( ) hash: hash: 0x3485... hash: 0x6a1f... nonce: 0x0000... nonce: 0x0001... hash: 0xc9c8... nonce: 0x0002... hash: 0x300c... nonce: 0xffff... hash: nonce: 0x0000...

25.0→A coinbase: 0x0000...01

All changed

hash: 0xd0c7...

25.0→A coinbase: 0x3df5...65

slide-23
SLIDE 23

Finding a valid nonce is the hard part!

H( ) H( ) H( ) H( ) H( ) H( )

25.0→A coinbase: 0x0000...00 transaction transaction transaction

mrkl_root: H( ) prev: H( ) mrkl_root: H( ) hash: 0x0000 nonce: 0x7a83 prev: H( ) hash: nonce: 0x0000... nonce: 0x0001... nonce: 0x0002... nonce: 0xffff... nonce: 0x88fc...

25.0→A coinbase: 0x0000...01 25.0→A coinbase: 0x3df5...65

hash: 0x0000

slide-24
SLIDE 24

Mining difficulty (2017-01-14)

0000000000000000058436000000000000000000000000000000000000000000 256 bit “target” 70+ leading zero bits required

Number of blocks tried per 10 min. 270.6 = 1,767,408,003,483,225,292,800 Network hash rate = 2,743,378 TH/s

slide-25
SLIDE 25

SHA-256 is “puzzle-friendly”

Optimization-free No better strategy than trying random nonces Progress-free You don’t get any closer the more work you do Parameterizable Easy to adjust difficulty

slide-26
SLIDE 26

Time to solution is probabilistic

Time to next block (entire network) Probability density 10 minutes

slide-27
SLIDE 27

Setting the mining difficulty

next_difficulty= previous_difficulty * (2 weeks)/(time to mine last 2016 blocks)

Expected number of blocks in 2 weeks at 10 minutes/block

Every two weeks, compute:

slide-28
SLIDE 28

Mining difficulty over time

bitcoinwisdom.com

slide-29
SLIDE 29

Time to find a block

bitcoinwisdom.com 10 minutes 2 weeks

slide-30
SLIDE 30

Lecture 2.3: Mining hardware (Bitcoin)

slide-31
SLIDE 31

Addition mod 32 256-bit state 64 iterations round constants Bitwise tweaks

SHA-256 in more depth

slide-32
SLIDE 32

CPU mining

while (1){ HDR[kNoncePos]++; IF (SHA256(SHA256(HDR)) < (65535 << 208)/ DIFFICULTY) return; }

two hashes

>2 million years to find a block today!

Throughput on a high-end PC = 10-20 MHz ≈ 224

slide-33
SLIDE 33

GPU mining

  • GPUs designed for high-performance graphics

○ high parallelism ○ high throughput

  • First used for Bitcoin ca. October 2010
  • Implemented in OpenCL

○ Later: hacks for specific cards

slide-34
SLIDE 34

GPU mining advantages

  • easily available, easy to set up
  • parallel ALUs
  • bit-specific instructions
  • can drive many from 1 CPU
  • can overclock!
slide-35
SLIDE 35

“Effective throughput”

Observation: some errors are okay (may miss a valid block) Effective throughput: throughput × success rate Worth over-clocking by 50% with 30% errors!

slide-36
SLIDE 36

Source: LeonardH, cryptocurrencies talk.com

slide-37
SLIDE 37

GPU mining disadvantages

  • poor utilization of hardware
  • poor cooling
  • large power draw
  • few boards to hold multiple GPUs

Throughput on a good card = 20-200 MHz ≈ 227 ≈17,000 years to find a block w/100 cards!

Instead of time-to-find-block, compare to a lottery. What’s the chance of finding one in day?

slide-38
SLIDE 38

FPGA mining

  • Field Programmable Gate Area
  • First used for Bitcoin ca. June 2011
  • Implemented in Verilog
slide-39
SLIDE 39

FPGA mining advantages

  • higher performance than GPUs

○ excellent performance on bitwise operations

  • better cooling
  • extensive customisation, optimisation
slide-40
SLIDE 40

Bob Buskirk, thinkcomputers.org

slide-41
SLIDE 41

FPGA mining disadvantages

  • higher power draw than GPUs designed for

○ frequent malfunctions, errors

  • poor optimization of 32-bit adds
  • fewer hobbyists with sufficient expertise
  • more expensive than GPUs
  • marginal performance/cost advantage over GPUs

Throughput on a good card = 100-1000 MHz ≈ 230

2,000 years to find a block w/100 boards!

slide-42
SLIDE 42

Bitcoin ASICs

  • special purpose

○ approaching known limits on feature sizes ○ less than 10x performance improvement expected

  • designed to be run constantly for life
  • require significant expertise, long lead-times
  • perhaps the fastest chip development ever!
slide-43
SLIDE 43

Market dynamics (2013/2014)

  • Most boards obsolete within 3-6 months

○ Half of profits made in first 6 weeks

  • Shipping delays are devastating to customers
  • Most companies require pre-orders
  • Most individual customers should have lost...

But... rising prices saved them!

slide-44
SLIDE 44

Bitcoin ASICs

slide-45
SLIDE 45

Current hardware (2015/2016)

slide-46
SLIDE 46

Case study: Ant Miner S7

  • First shipped 2015
  • 4.7 TH/s
  • 1210 W
  • Cost: US$619

Still, 4.8 years to find a block!

slide-47
SLIDE 47

Market dynamics (2015/2016)

  • Growth rate leveling off
  • Mining hardware approaching fab. limits
  • Mining becoming professionalized

[Taylor 2013] Bitcoin and the Age of Bespoke Silicon.

slide-48
SLIDE 48

Market dynamics (2015/2016)

slide-49
SLIDE 49

Evolution of mining

CPU GPU FPGA ASIC gold pan sluice box placer mining pit mining

slide-50
SLIDE 50

Professional mining centers

Industrial mining

Needs:

  • cheap power
  • good network
  • cool climate
slide-51
SLIDE 51

Bitcoin mining in China ~ 70%

slide-52
SLIDE 52

Mining hardware is illiquid

➔ High entry costs ➔ Low salvage value Conclusion: Miners care about future exchange rate

slide-53
SLIDE 53

Philosophical questions

  • Can small miners stay in the game?
  • Do ASICs violate the original Bitcoin vision?
  • Would we be better off without ASICs?
slide-54
SLIDE 54

Lecture 2.4: Energy consumption & ecology

slide-55
SLIDE 55

Energy aspects of Bitcoin mining

  • Embodied energy: used to manufacture

mining chips & other equipment

○ should decrease over time ○ returns to scale

  • Electricity: used to perform computation

○ should increase over time ○ returns to scale

  • Cooling: required to protect equipment

○ costs more with increased scale!

slide-56
SLIDE 56

Estimating energy usage: top-down

  • Each block worth approximately US$10,000
  • Approximately $17/s generated
  • Industrial electricity (US): $0.03/MJ

○ $0.10/kWh Upper bound on electricity consumed:

550 MJ/s = 550 MW

slide-57
SLIDE 57

Estimating energy usage: bottom-up

  • Best claimed efficiency: 0.1 GHz/W
  • Network hash rate: 270,000,000 GHz
  • (excludes cooling, embodied energy)

Lower bound on electricity consumed:

270 MW

slide-58
SLIDE 58

How much is a MW?

Three Gorges Dam = 10,000 MW typical hydro plant ≈ 1,000 MW Kashiwazaki-Kariwa nuclear power plant = 7,000 MW typical nuclear plant ≈ 4,000 MW major coal-fired plant ≈ 2,000 MW

slide-59
SLIDE 59

Cooling costs matter as well!

slide-60
SLIDE 60

All payment systems require energy

slide-61
SLIDE 61

Data furnaces

  • ASICs are ~as efficient as electric heaters
  • Why not install mining rigs as home heaters?
  • Challenges:

○ Ownership/maintenance model ○ Gas heaters still at least 10x more efficient ○ What happens in summer?

slide-62
SLIDE 62

Open questions

  • Will Bitcoin drive out electricity subsidies?
  • Will Bitcoin require guarding power outlets?
  • Can we make a currency with no proof-of-work?
slide-63
SLIDE 63

Electricity theft: a growing problem?

slide-64
SLIDE 64

Lecture 2.5: Mining pools

slide-65
SLIDE 65

Economics of being a small miner

  • Cost: ≈US$619
  • Expected time to find a

block: ≈4.7 years

  • Expected revenue: ≈

$88/month

  • Electricity cost:

○ $71/month (USA) ○ $140/month (EU)

Ant Miner S7

slide-66
SLIDE 66

Mining uncertainty (4.7 year mean)

Probability density 4.7 years Time to find first block

# blocks found in

  • ne year

probability (Poisson dist.)

36.7% 1 36.7% 2 18.3% 3+ 8.1%

slide-67
SLIDE 67

Risk aversion

vs.

guaranteed 50% chance

Expectation(Utility) ≠ Utility(Expectation)

slide-68
SLIDE 68

Idea: could small miners pool risk?

slide-69
SLIDE 69

Mining pools

  • Goal: pool participants all attempt to mine

a block with the same coinbase recipient

○ send money to key owned by pool manager

  • Distribute revenues to members based on

how much work they have performed

○ minus a cut for pool manager How do we know how much work members perform?

slide-70
SLIDE 70

Show work with near-valid blocks (shares)

4AA087F0A52ED2093FA816E53B9B6317F9B8C1227A61F9481AFED67301F2E3FB D3E51477DCAB108750A5BC9093F6510759CC880BB171A5B77FB4A34ACA27DEDD 00000000008534FF68B98935D090DF5669E3403BD16F1CDFD41CF17D6B474255 BB34ECA3DBB52EFF4B104EBBC0974841EF2F3A59EBBC4474A12F9F595EB81F4B 00000000002F891C1E232F687E41515637F7699EA0F462C2564233FE082BB0AF 0090488133779E7E98177AF1C765CF02D01AB4848DF555533B6C4CFCA201CBA1 460BEFA43B7083E502D36D9D08D64AFB99A100B3B80D4EA4F7B38E18174A0BFB 000000000000000078FB7E1F7E2E4854B8BC71412197EB1448911FA77BAE808A 652F374601D149AC47E01E7776138456181FA4F9D0EEDD8C4FDE3BEF6B1B7ECE 785526402143A291CFD60DA09CC80DD066BC723FD5FD20F9B50D614313529AF3 000000000041EE593434686000AF77F54CDE839A6CE30957B14EDEC10B15C9E5 9C20B06B01A0136F192BD48E0F372A4B9E6BA6ABC36F02FCED22FD9780026A8F

slide-71
SLIDE 71

Mining pools

0x00000000000490c6b00... 0x00000000000000003f89... 0x000000000001e8709ce... 0x0000000000007313f89... 0x0000000000045a1611f... 0x00000000000a877902e...

Pool manager

$$$ $$ $

Hey folks! Here’s

  • ur next block to

work on

coinbase: 25→pool

mrkl_root: H( ) prev: H( ) nonce: hash:

slide-72
SLIDE 72

Mining pool variations

  • Pay per share: flat reward per share

○ Typically minus a significant fee ○ What if miners never send in valid blocks?

  • Proportional: typically since last block

○ Lower risk for pool manager ○ More work to verify

  • Pay per-last-N-shares

○ Minimize “pool hopping” ○ Some pool hopping still exists!

slide-73
SLIDE 73

Mining pool protocols

  • API for fetching blocks, submitting shares

○ Stratum ○ Getwork ○ Getblockshare

  • Proposed for standardization with a BIP
  • Increasingly important; some hardware

support

slide-74
SLIDE 74

Mining pools (Jan 2017)

slide-75
SLIDE 75

Mining pools (June 2014)

slide-76
SLIDE 76

Do we want pools?

Pros:

  • Allow smaller miners to participate by lowering variance

Cons:

  • Fewer fully-validating nodes
  • Mining pools may become too powerful

Interesting result [Miller et al. 2015]: we can design a cryptocurrency so that pools are impossible

slide-77
SLIDE 77

Lecture 2.6: The rules of Bitcoin

slide-78
SLIDE 78

Bitcoin requires 3 layers of consensus

Agree on the protocol Agree on a blockchain to use Agree that coins are valuable

slide-79
SLIDE 79

Agreement on the blockchain

Genesis block chosen by fiat Chosen by Satoshi Hard-coded into all clients New genesis block=new coin!

slide-80
SLIDE 80

Agreement on the protocol

Originally designed by Satoshi BUT... can change!

slide-81
SLIDE 81

Bitcoin’s three main protocols

Consensus: How can we agree on one global history? Transactions: How can we agree what the history means? Network: How can we share transactions & history?

Can change easily Can change, but slow and risky Nearly impossible to change

slide-82
SLIDE 82

Soft forks

Majority agrees to change the protocol

  • validation rules become stricter only

Minority can read new blocks, can’t write

Soft fork

slide-83
SLIDE 83

Hard forks

Majority agrees to change the protocol

  • new blocks allowed which weren’t valid

Minority can’t read new blocks

Hard fork

slide-84
SLIDE 84

Altcoins

Re-write the rules from scratch (usually) start a new genesis block

slide-85
SLIDE 85

Lecture 2.7: Economics of Bitcoin

slide-86
SLIDE 86

Last question: why are bitcoins valuable?

slide-87
SLIDE 87

There is a finite supply: 21M bitcoin

Courtesy: Brian Warner

Currently, block rewards are > 99% of miner revenue. But: Eventually, transaction fees will dominate

slide-88
SLIDE 88

Some sellers are willing to accept Bitcoin

slide-89
SLIDE 89

Bitcoin exchange rate is market-set

Buyers Sellers BitStamp order book, Jan 2017 Market price

slide-90
SLIDE 90

Tinker bell effect

Bitcoins are valuable because a group of people believe they are valuable

slide-91
SLIDE 91

Is Bitcoin a currency?

  • Means of exchange
  • Store of value
  • Unit of account
slide-92
SLIDE 92

A convenient means of exchange?

Bitcoin is too cumbersome for some people

slide-93
SLIDE 93

A reliable store of value?

Bitcoin is more volatile than some state currencies

slide-94
SLIDE 94

A useful unit of account?

Bitcoin is too cumbersome for some people

slide-95
SLIDE 95

Looming problems

slide-96
SLIDE 96

Transaction fees are increasing

[Möser, Böhme 2015]

slide-97
SLIDE 97

Monetary policy is deflationary

slide-98
SLIDE 98

Summary

Bitcoin is the most important technology developed since the Internet vs. The history of Bitcoin is a community removing all elements of modern government, finance and banking only to discover one-by-one why they were created in the first place...