留学生代考 IS3101 Cryptocurrency & Blockchain

IS3101 Cryptocurrency & Blockchain
Lecture 10 Bitcoin Mining

Bitcoin depends on miners to:

Copyright By PowCoder代写 加微信 powcoder

● Store and broadcast the blockchain ● Validate new transactions
● Vote (by hash power) on consensus
But who are the miners?
Recap: Bitcoin miners

The task of Bitcoin miners

So you want to be a miner?
Gold miners ascending the Chilkoot pass
Klondike gold rush of 1898

Mining Bitcoins in 6 easy steps
1. Join the network, listen for transactions ○ Validate all proposed transactions
2. Listen for new blocks, maintain blockchain Useful to ○ When a new block is proposed, validate it
Bitcoin 3. Assemble a new valid block
4. Find the nonce to make your block valid 5. Hope everybody accepts your new block 6. Profit!

• Explanation
• The difficulty is a measure of how
difficult it is to mine a Bitcoin block, or in more technical terms, to find a hash below a given target.
• A high difficulty means that it will take more computing power to mine the same number of blocks, making the network more secure against attacks.
• The difficulty adjustment is directly related to the total estimated mining power estimated in the Total Hash Rate (TH/s) chart.
Mining difficulty over time
https://www.blockchain.com/charts/difficulty

Time to find a block
10 minutes

5.2 Mining hardware

● General purpose hash function
○ Part of SHA-2 family: SHA-224,SHA-384,SHA-512
● Published in 2001
● Designed by the NSA
● Remains unbroken cryptographically
○ Weaknesses known
● SHA-3 (replacement) as official recommended standardization (i.e.,
Ethereum hash function, Keccak-256 is a variant of SHA3-256)

● A collection of 4 bytes, or 32 bits, is called a word
Bit, byte, word, doubleword
● A collection of 8 bits is called a byte
● Each individual data value in a data set is usually stored using one or more bytes of memory
● A word is typically the “native” data size of the CPU. That is, on a 16-bit CPU, a word is 16 bits, on a 32-bit CPU, it’s 32 and so on.
● For example, the first 256 bits (32 bytes) of the electronic format of a book at the lowest level, a data set is just a series of zeroes and ones like this

256 in more depth
256-bit state
Bitwise tweaks
round constants
Addition mod 32
x80 iterations

CPU mining
while (1){
HDR[kNoncePos]++;
IF (SHA256(SHA256(HDR)) < (65535 << 208)/ DIFFICULTY) two hashes Throughput on a high-end PC = 10-20 MHz ≈ 224 139,461 years to find a block today! GPU mining ● GPUs designed for high-performance graphics ○ high parallelism ○ high throughput ● First used for Bitcoin mining, October 2010 ● Implemented in OpenCL ○ Later: hacks for specific cards 1. easily available, easy to set up 2. parallel ALUs 3. bit-specific instructions 4. can drive many from 1 CPU 5. can overclock! GPU mining advantages ● Observation: some errors are okay (may miss a valid block) ● Goodput:throughput×successrate ● Worth over-clocking by 50% with 30% errors! Source: LeonardH, cryptocurren ciestalk.com 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 ≈173 years to find a block w/100 cards! FPGA mining ● Field Programmable Gate Area ● First used for Bitcoin ca. June 2011 ● Implemented in Verilog FPGA mining advantages ● higher performance than GPUs ○ excellent performance on bitwise operations ● better cooling ● extensive customisation, optimisation , thinkcomputers.org 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 25 years to find a block with 100 boards! 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! Bitcoin ASICs Case study: Terra V ● First shipped Jan 2014 ● 2 TH/s ● Cost: US$6,000 Still, 14 months to find a block! SIC Miners For Mining Cryptocurrency In 2022 https://www.softwaretestinghelp.com/best-asic-miners/ 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 have saved them! Professional mining centers ● cheap power ● good network ● cool climate BitFury mining center, Republic of Georgia Evolution of mining CPU GPU FPGA ASIC gold pan sluice box placer mining pit mining The future ● Can small miners stay in the game? ● Do ASICs violate the original Bitcoin vision? ● Would we be better off without ASICs? alt-mining will be an interesting topic! 5.3 Energy consumption & ecology Thermodynamic limits Landauer’s principle: Any non-reversible computation must consume a minimum amount of energy. Specifically, each bit changed requires (kT ln 2) joules SHA-256 is not reversible Energy consumption is inevitable 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! Estimating energy usage: top ● Each block (6.25 bitcoin) worth approximately HKD$2,000,000 ● Approximately HKD$12,000,000/hr generated ● Industrial electricity (average worldwide): HKD$1.00/kWh Upper bound on electricity consumed: ~12GWh = 12000MW https://www.globalpetrolprices.com/electricity_prices/ Estimating energy usage: bottom ● Best claimed efficiency: ● 110 TH/s/3250W =~ 33GH/s/kWh ● 2022 Network hash rate: 247EH/s ● (excludes cooling, embodied energy) Lower bound on electricity consumed: ~7.5GWh = 7500MW https://www.coinwarz.com/mining/bitcoin/hashrate-chart How much is a MW? Three Gorges Dam = 25,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 All payment systems require energy Open questions ● drive out electricity subsidies? ● require guarding power outlets? ● Can we make a currency with no proof-of-work? 4 Mining pools ANTMINER S19 PRO ● Cost: ≈HKD$80,000 ● Expected time to find a block: ≈45 months ● Expected revenue: ≈$2,000/month Economics of being a small miner Mining uncertainty # blocks found in one year probability (Poisson dist.) Time to find first block Probability density 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 How do we know how much work members perform? Mining shares Idea: prove work with “near-valid blocks” (shares) 4AA087F0A52ED2093FA816E53B9B6317F9B8C1227A61F9481AFED67301F2E3FB D3E51477DCAB108750A5BC9093F6510759CC880BB171A5B77FB4A34ACA27DEDD 00000000008534FF68B98935D090DF5669E3403BD16F1CDFD41CF17D6B474255 BB34ECA3DBB52EFF4B104EBBC0974841EF2F3A59EBBC4474A12F9F595EB81F4B 00000000002F891C1E232F687E41515637F7699EA0F462C2564233FE082BB0AF 0090488133779E7E98177AF1C765CF02D01AB4848DF555533B6C4CFCA201CBA1 460BEFA43B7083E502D36D9D08D64AFB99A100B3B80D4EA4F7B38E18174A0BFB 000000000000000078FB7E1F7E2E4854B8BC71412197EB1448911FA77BAE808A 652F374601D149AC47E01E7776138456181FA4F9D0EEDD8C4FDE3BEF6B1B7ECE 785526402143A291CFD60DA09CC80DD066BC723FD5FD20F9B50D614313529AF3 000000000041EE593434686000AF77F54CDE839A6CE30957B14EDEC10B15C9E5 9C20B06B01A0136F192BD48E0F372A4B9E6BA6ABC36F02FCED22FD9780026A8F Mining pools Hey folks! Here’s our next block to Pool manager prev: H( ) mrkl_root: H( ) 0x00000000000a87790 0x000000000001e8709 0x00000000000000003f89 0x00000000000490c6b 0x0000000000007313f 0x0000000000045a161 00... 89... 1f... 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 ● “Luke-jr” approach: no management fee ○ Miners can only get paid out in whole BTC ○ Pool owner keeps spread Mining pool protocols ● API for fetching blocks, submitting shares ○ Stratum ○ Getblockshare ● Proposed for standardization with a BIP ● Increasingly important; some hardware support Mining pool history ● First pools appear in late-2010 ○ Back in the GPU era! ● By 2014: around 90% of mining pool-based ● June 2014: GHash.io exceeds 50% https://btc.com/stats/pool Mining pools (as of Are mining pools a good thing? ○ Make mining more predictable ○ Allow small miners to participate ○ More miners using updated validation software ○ Lead to centralization ○ Discourage miners from running full nodes Can we prevent pools? ● What is Atra? ○ Services is a cloud platform that helps you build, deploy, and maintain decentralized blockchain applications. ● Installing Metamask ○ A browser wallet • Narayanan et al. Ch 5 References 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com