Bitcoin Mining PDF
Bitcoin Mining PDF
Chilkoot pass,
1898 Klondike gold rush
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
Useful to a. When a new block is proposed, validate it
Bitcoin
network 3. Assemble a new valid block
4. Find a nonce to make your block valid
5. Hope everybody accepts your new block
6. Profit!
Finding a valid block
prev: H( ) prev: H( )
mrkl_root: H( ) mrkl_root: H( )
nonce: 0x7a83 nonce: 0xf77e...
0xffff...
0x0000...
0x0001...
0x0002...
hash: 0x0000 hash: 0xd0c7...
0x6a1f...
0x300c...
0x0224...
0xc9c8...
0x0000...
0x3485...
H( ) H( )
All changed
H( ) H( ) H( ) H( )
0000000000000000058436000000000000000000000000000000000000000000
next_difficulty= previous_difficulty *
(2 weeks)/(time to mine last 2016 blocks)
bitcoinwisdom.com
Time to find a block
10 minutes
2 weeks
bitcoinwisdom.com
Lecture 4.2:
Bitwise tweaks
64
iterations
round
Addition mod 32 constants
CPU mining
while (1){
HDR[kNoncePos]++;
IF (SHA256(SHA256(HDR)) < (65535 << 208)/ DIFFICULTY)
return;
}
two hashes
● 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!
Market dynamics (2013/2014)
[Taylor 2013]
Bitcoin and the Age of Bespoke Silicon.
Market dynamics (2015/2016)
Professional mining centers
Needs:
● cheap power
● good network
● cool climate
375 MW
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
Mining pools
Economics of being a small miner
● Cost: ≈US$619
● Expected time to find a
block: ≈4.7 years
● Expected revenue:
≈$88/month
● Electricity cost:
Ant Miner S7 ○ $71/month (USA)
○ $140/month (EU)
Mining uncertainty (4.7 year mean)
# blocks found in probability (Poisson
4.7 one year dist.)
years
0 36.7%
Probability density
1 36.7%
2 18.3%
3+ 8.1%
vs.
Expectation(Utility) ≠ Utility(Expectation)
Idea: could small miners pool risk?
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
prev: H( )
coinbase:
mrkl_root: H( ) 25→pool
nonce:
$$$ hash:
$$
0x00000000000a877902e...
0x000000000001e8709ce... $ 0x00000000000000003f89...
0x00000000000490c6b00... 0x0000000000007313f89... 0x0000000000045a1611f...
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!
Rewards structure for pools
Goals:
● Limit risk carried by pool
● Incentivize participants to always submit blocks
● Incentivize participants to mine consistently
○ no “pool-hopping”
● Don’t discourage new participants
Usual assumptions:
○ known set of players
○ known utility functions
○ synchrony
M→M’
M→B
Attackers care about the exchange rate
Mt. Gox
hacked
Source: blockchain.info
Mining hardware is illiquid
I expect you to
die, Mr. Bitcoin
Goldfinger Attack
[Kroll, Davey, Felten 2013]
The Economics of Bitcoin Mining, or Bitcoin in the Presence of Adversaries
Forking attacks via bribery
● Buying α > 0.5 is expensive. Why not rent?
● Payment techniques:
○ Out-of-band bribery
○ Run a mining pool at a loss
○ Insert large “tips” in the block chain
[Bonneau 2016]
Why buy when you can rent? Bribery attacks on Bitcoin consensus
In-band bribery possible with scripts
B0 $$$$$$$$$$$ → K0
B2
...
Guaranteed bribes
Can we do anything with α < 50%?
Secret Block
Secret Block
Secret Block
Network race
Assume you win races with prob. ɣ
● Always withhold if ɣ = 1
○ Ideal network position
○ Obtainable through bribery?
● Withhold for α > 0.25 if ɣ > 0.5
● Always withhold for α > 0.33
Surprising theoretical finding, never observed!
25 BTC
Expected
Expected reward:
reward:
25 BTC 23
αα xx 125
125
100 BTC
25 BTC
Expected reward:
α x 25 BTC
Transaction fees will matter more
Currently, block rewards are > 99% of miner revenue. But:
Eventually,
transaction fees
will dominate
Courtesy:
Brian Warner
Transaction fees already increasing
● Cartel of miners?
○ Optimize fees x volume
○ Pressure from other currencies?
Eventually,
transaction fees
will dominate
Courtesy:
Brian Warner
Will miners cooperate to enforce fees?
Feather-forking
Goal: blacklist/censor some addresses
Strategies:
● Announce you will try to fork if blacklisted
addresses appear in a block
● Will try to make fork work until k blocks behind
Feather forking
Feather forker
works here
Block with banned tx
Chance of success
down to α3, give
up
Feather-forking
Goal: blacklist/censor some addresses
Strategies:
● Announce you will try to fork if blacklisted
addresses appear in a block
● Will try to make fork work until k blocks behind
Apparent outcome:
● Blacklister will lose some mining revenue
● Others will also lose! Optimal strategy is to enforce
blacklist (unless Tx fees are very high)
Mining pools may attack each other
Goals:
● Increase profitability of your pool
● Increase size of your pool by damaging others
Strategies:
● Participate in rival pool but withhold valid blocks
● Denial of service on the network to delay rival pools
Mining pool sabotage
Bitcoin network
0.5 0.5
0.5
0.5
α = 50% α = 50%
0.5 0.25
0.66
0.33
[Eyal 2015]
The Miner’s Dilemma
Do we want pools?
Pros:
● Allow smaller miners to participate by lowering variance
Cons:
● Fewer fully-validating nodes
● Mining pools may become too powerful
Revenue
attack
default behavior
Time
Attacks are lucrative in a simple model
Infinite:
➔ attacker capital
➔ attacker risk tolerance
Negligible:
➔ double-spend overhead
➔ bribery premium
Many explanations for
lack of attacks in practice
Miners are too simplistic?
Too much risk and capital needed?
Hard to profit from double-spends?
Honor among miners?
Games at two levels
● Human level
○ Slow
○ Can change rules/code
○ Exchange rates matter
○ Other currencies exist
● Algorithmic level
○ Fast
○ Rules are fixed
○ Closed world
○ Exchange rate fixed?
Summary
● Miners are free to implement any strategy
● Very little non-default behavior in the wild
● No complete game-theoretic model exists
● Game changes as fixed rewards dwindle