Download - More Mining
![Page 1: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/1.jpg)
Cryptocurrency CaféUVa cs4501 Spring 2015David Evans
Class 10:More Mining
![Page 2: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/2.jpg)
Plan for Today
Project Plans
PointCoin Forking
Bitcoin (PointCoin) Mining
Cost of Computing
Mining Economics
Return Quiz 1
1
![Page 3: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/3.jpg)
Plan for Future
• Project 2
– Part 1 (due in 1 week): mining
– Part 2 (due before spring break): attacks
• Project 3 is no more
– But, can do blockchain analysis for your project
• Open-ended Project
2
![Page 4: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/4.jpg)
Open-Ended Project
• Proposal will be due March 20
• Final project due at end of semester (April 28)
• Anything you want related to cryptocurrency(broadly defined)
• Some initial ideas posted on course site (and mentions throughout upcoming classes)
3
![Page 5: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/5.jpg)
Project Teams
You may work in a team of size 1-7B
4
N N2/3
1 1.00
2 1.58
3 2.08
4 2.52
26 8.78
Expected value of your project scales as N2/3 where N is the number of students in the class on your team.
Feel free to post ideas on course site to recruit teammates
![Page 6: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/6.jpg)
PointCoin Forking/Failing
5
UpdateBlockTime
params.go
![Page 7: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/7.jpg)
Asymptotic Analysis
6
int gaussSum (int m) {int sum = 0;for (int i = 1; i <= m; i++) {
sum = sum + i;}return sum;
}
Assuming an (unspecified) idealizedmodel of Java computation, running time of gaussSum is in θ(2N) where N is the size of the input.
![Page 8: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/8.jpg)
Asymptotic Analysis Questions
7
Is an algorithm with running time in O(N) better than one with running time in O(N2)?
![Page 9: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/9.jpg)
Asymptotic Analysis Questions
8
Is an algorithm with running time in Θ(N) better than one with running time in Θ(N2)?
![Page 10: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/10.jpg)
Cost of Mining
9
Setup:block := construct next block headerdifficulty := next difficulty// look for noncewhile true {
block.Header.nonce += 1 // guess next noncehash, _ = block.Header.BlockSha()if hash < difficulty { Success! }
}
![Page 11: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/11.jpg)
10
package mainimport "github.com/PointCoin/fastsha256"import "log"import "time"
func main() {msg := "test"hasher := fastsha256.New()
hasher.Write([]byte (msg))starttime := time.Now()num := 10000000for i := 0; i < num; i++ {
hasher.Sum(nil) // ignore result }elapsed := time.Since(starttime)log.Printf("Total time: %s", elapsed)log.Printf("Average hashing time: %d ns", elapsed.Nanoseconds() / int64(num))
}
![Page 12: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/12.jpg)
11
ubuntu@ip-172-31-39-215:~/template_miner$ go build timer.goubuntu@ip-172-31-39-215:~/template_miner$ ./timer2015/02/11 16:50:42 Result: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a082015/02/11 16:50:50 Total time: 7.650548619s2015/02/11 16:50:50 Average hashing time: 765 nsubuntu@ip-172-31-39-215:~/template_miner$ time ./timer2015/02/11 16:50:55 Result: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a082015/02/11 16:51:03 Total time: 7.676091298s2015/02/11 16:51:03 Average hashing time: 767 ns
real 0m7.681suser 0m8.541ssys 0m0.131subuntu@ip-172-31-39-215:~/template_miner$
2.5 GHz processor on M3.large EC2 node
![Page 13: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/13.jpg)
Cost of Mining
12
Setup:block := construct next block headerdifficulty := next difficulty
One attempt:block.Header.nonce += 1 // guess next noncehash, _ = block.Header.BlockSha()if hash < difficulty { Success! }
How long will it take to find a block using free EC2 nodes?
![Page 14: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/14.jpg)
Probability of Success
13
Assume: SHA-256 produces uniform random output
SHA-256(x) [0, 2256)
Target = Tmax / Difficulty
Tmax = (216 – 1)2256 ≈ 2224
Current (15 Feb) Difficulty = 44455415962
![Page 15: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/15.jpg)
14
![Page 16: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/16.jpg)
Free Money?
15
>>> target = 2 ** 224 / 44455415962606449092506427232846302685260647042725721699378946247123L>>> success_probability = target / 2**2565.237396582969569e-21>>> expected_hashes = 1 / success_probability1.9093455768686638e+20>>> nanos_needed = expected_hashes * 760>>> seconds_needed = nanos_needed / 10**9145110263842018.44>>> days = seconds_needed / (60 * 60 * 24)1679516942.6159542>>> years = days / 3654601416.2811396>>> years * 2~ 9.2 M years to find one block on EC2 (assuming difficulty doesn’t increase)
![Page 17: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/17.jpg)
Why is energy/hash so much less for custom ASICs?
16
![Page 18: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/18.jpg)
17
XOR two 32-bit values in CPU XOR two 32-bit values in ASIC
![Page 19: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/19.jpg)
18
XOR two 32-bit values in CPU XOR two 32-bit values in ASIC
4 transistors XOR design
![Page 20: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/20.jpg)
19
https://en.bitcoin.it/wiki/Mining_hardware_comparison
1J ~ “lift an apple one meter”
![Page 21: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/21.jpg)
20
>>> 10**9/(760 * 2)657894= 0.0006 GH/s
![Page 22: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/22.jpg)
Mining and Mining
21
How much coal is mined to mine a bitcoin?
![Page 23: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/23.jpg)
Bitcoin Mining
22
http://www.thecoinsman.com/2014/08/bitcoin/inside-chinese-bitcoin-mine/
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…
![Page 24: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/24.jpg)
23
Cost of electricity: ¥400,000 ($60,000 US)/month
http://www.thecoinsman.com/2014/08/bitcoin/inside-chinese-bitcoin-mine/
![Page 25: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/25.jpg)
How to Estimate Energy Cost?
24
![Page 26: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/26.jpg)
25http://shrinkthatfootprint.com/average-electricity-prices-kwh
$60,000/month × 0.08/kWh = 750,000 kWh
![Page 27: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/27.jpg)
26
![Page 28: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/28.jpg)
27
![Page 29: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/29.jpg)
Total Network Hashing Power
28
Difficulty is adjusted to mine one block every 10 minutes.
Target = Tmax / Difficulty
Expected hashes = 2255 / Target
Network hashes per second ~ Expected hashes / 600s
![Page 30: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/30.jpg)
29
>>> expected_hashes1.9093455768686638e+20>>> hashes_per_second = expected_hashes / 6003.18224262811444e+17>>> # according to blockchain.info: 309,384,699.96 GH/s>>> 309384699.96 * 10**93.0938469996e+17>>> _ / hashes_per_second0.9722222222361415
![Page 31: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/31.jpg)
Estimating Energy Use
30
https://en.bitcoin.it/wiki/Mining_hardware_comparison
ASIC Miner Ghash/s (advertised) Mhash/J Price
AntMiner S5 1,155 1957 $370
ASICMiner BE Prisma 1,400 1333 $600
HashCoins Zeus 4,500 1500 $2299
Spondooliestech S35 Yukon 5,500 1506 $2235
![Page 32: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/32.jpg)
31
>>> expected_hashes1.9093455768686638e+20>>> hashes_per_second = expected_hashes / 6003.18224262811444e+17>>> # according to blockchain.info: 309,384,699.96 GH/s>>> 309384699.96 * 10**93.0938469996e+17>>> _ / hashes_per_second0.9722222222361415>>> Mhash_per_J = 1500>>> Mhash_per_second = hashes_per_second / 10**6>>> J = Mhash_per_second / Mhash_per_J212149508.54096264
212 MJ per second = 212 MW
![Page 33: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/33.jpg)
32
Dominion PowerLake Anna Power Station1892 MW (450,000 homes)~9x entire bitcoin mining power (with efficient ASICs)
![Page 34: More Mining](https://reader030.vdocuments.net/reader030/viewer/2022020307/55a943b71a28abfd5c8b48e6/html5/thumbnails/34.jpg)
ChargeProject 2:
we hope to have PointCoin network restarted by tomorrow
still build your miner (just will operated on broken network)
Read: Chapter 8: Mining and Consensus
Start thinking about your project ideas
33
Coming up with a good way of analyzing mining energy use, and comparing it with energy cost of current financial infrastructure could be a good project…