Module 4 BCT 2021Batch
Module 4 BCT 2021Batch
à It’s essential to ensure that every transaction in the block is valid before including it.
4. Find a nonce that makes miners block valid: To make block valid, miner need to find a
nonce that satisfies the required conditions.
à This step is the most computationally intensive and challenging part of mining.
5.Hope your block is accepted: Even after successfully finding a valid nonce, there's no
certainty that the block will be accepted into the consensus chain.
à This process involves an element of luck, as other miners might also be competing to add
their blocks at the same time.
Bitcoin Mining
6. Profit: If other miners accept block, miner earn a reward.
à It was chosen for Bitcoin because it was the strongest cryptographic hash function
à While it may become less secure over Bitcoin's lifetime, it is currently considered
reliable. Despite being developed by the U.S. National Security Agency, which has
Ø SHA-256 & Sha-512 are closely related functions in the SHA-2 family.
Ø There is also SHA-1, an earlier generation with 160-bit output, which is now considered
insecure but is still implemented in Bitcoin script.
Ø SHA-3 is in the final stages of standardization today, but it wasn’t available at the time
Bitcoin was designed.
A Closer Look at SHA-256
A Closer Look at SHA-256
1. SHA-256 maintains a 256-bit state.
2. The state is divided into eight 32-bit words, optimized for 32-bit hardware.
3. Each round uses specific words from the state, applies bitwise tweaks, and performs
modular addition (mod 32).
4. The entire state undergoes a right shift, and the result of the addition becomes the new
leftmost word.
5. The algorithm's design is loosely based on bitwise Linear Feedback Shift Registers
(LFSRs).
6. The SHA-256 compression function runs for 64 iterations.
7. Each iteration applies slightly different constants, ensuring unique processing for
every round.
A Closer Look at SHA-256
8. Miners must compute the SHA-256 function as quickly as possible to succeed in
mining. Mining speed directly impacts earnings, as miners compete to solve the
cryptographic puzzle first.
• Anyone still trying to mine Bitcoin with a CPU likely doesn't understand the
mining process or the current state of Bitcoin mining and is unlikely to earn any
rewards.
GPU Mining
Ø The second generation began when people started to get frustrated with how slow
their CPUs were and instead used their graphics cards, or graphics processing units
(GPUs).
GPUs in Modern Desktops:
Ø Built-in for high-performance graphics.
Ø Offer high throughput and high parallelism—ideal for Bitcoin mining.
Parallelizable Mining:
Ø Bitcoin mining benefits from parallel processing, as multiple hashes can be computed
simultaneously with different nonces.
OpenCL and GPU Mining
• OpenCL(Open Computing Language) Language:
• Released in 2010 as a general-purpose programming language for GPUs
• OpenCL is a framework for writing programs that execute across heterogeneous
platforms, including CPUs, GPUs, and other processors.
• Enables non-graphics computations, including Bitcoin mining.
• Allows faster computations on GPUs compared to CPUs.
• Impact on Mining:
• OpenCL facilitated the use of GPUs for efficient Bitcoin mining.
u Advantages of GPUs for Mining
• Accessibility:
• GPUs are readily available online or at consumer electronics stores.
• Simple and convenient for beginners to set up.
Why GPUs Became Popular for Bitcoin Mining
• Parallelism:
• GPUs have multiple Arithmetic Logic Units (ALUs) designed for simultaneous
computations.
• Ideal for parallel SHA-256 operations required in mining.
• User-Friendly:
• High-end hardware accessible to the general public.
• Simple to configure for mining tasks.
• Performance:
• GPUs outperformed CPUs in mining due to their ability to handle high-volume,
parallelized computations efficiently.
• Scalability:
• Multiple GPUs could be combined to scale up mining operations effectively.
Overclocking GPUs for Bitcoin Mining
• Definition of Overclocking:
• Running a GPU faster than its designed speed.
• Introduces risks of overheating or malfunction.
• Origin of Overclocking Demand:
• Originally popular among gamers.
• Adopted by Bitcoin miners for potential profit increases.
u Overclocking and SHA-256 Computation
• Benefits:
• Increases the speed of SHA-256 computations.
Potential for higher mining throughput.
•
• Risks:
• Overclocking can cause errors in SHA-256 computations.
• Errors may result in invalid solutions or missed valid solutions.
OpenCL and GPU Mining
Example: Scenario:
• GPU runs 50% faster (1.5× throughput).
• Errors occur in 30% of computations (0.7× success rate).
• Outcome:
• Combined effect: 1.5×0.7=1.05
• Result: 5% increase in expected profits.
u Optimizing Overclocking
• Error Handling:
• Invalid solutions can be double-checked on a CPU.
• Missed valid solutions cannot be recovered.
• Profit Calculation:
• Overclocking is profitable if the speed gain outweighs error-induced losses.
• Optimization:
• Miners carefully calibrate overclocking to maximize profitability without excessive risk.
Disadvantages of GPU mining
• GPUs include specialized hardware for video processing, such as a large number of
floating-point units, which are not utilized in SHA-256 computations for Bitcoin
mining.
• Additionally, GPUs are not thermally optimized for mining; when stacked together,
they are prone to overheating, limiting their efficiency and reliability.
GPU Mining
u Power Consumption of GPUs
• GPUs consume significantly more power than ordinary computers.
• Increased electricity costs make GPU mining less economical.
u Challenges in Setting Up GPUs for Mining
• Miners needed to build custom boards or purchase expensive setups to house multiple
GPUs.
• Added complexity and costs for mining operations.
u GPU Performance in Bitcoin Mining
• Performance Potential:
• A high-end GPU with aggressive tuning can achieve up to 200 million hashes per
second.
• This is 10× faster than CPU mining.
• Limitations:
• Even with 100 GPUs, it would take hundreds of years on average to mine one block at
the 2015 difficulty level.
Decline of GPU Mining for Bitcoin
• Reasons for Decline:
• Increased Bitcoin mining difficulty has rendered GPUs inefficient for mining.
• Specialized hardware (ASICs) has replaced GPUs for Bitcoin mining.
• Current Use Cases:
• GPU mining is now mostly seen in early-stage altcoins where mining difficulty is
lower.
•
Mining with field programmable gate Arrays
• Around 2011, miners began using Field Programmable Gate Arrays (FPGAs) for
Bitcoin mining after the first implementation in Verilog, a hardware design
language.
u The irreversibility of SHA-256 ensures the security of Bitcoin mining but also
guarantees that energy is consumed in the process.
u While energy consumption is inevitable, the current electricity usage for Bitcoin
mining far exceeds the theoretical minimum defined by Landauer’s
principle(Developed by Ralph Landauer in the 1960s states that any irreversible
computation must use a minimum amount of energy)
ENERGY CONSUMPTION AND ECOLOGY
Ø Even if mining were optimized to this theoretical limit, energy consumption
would still be required.
u This highlights the inherent trade-off between computation and energy efficiency
in Bitcoin mining.
u How does Bitcoin mining use energy? Three steps in the process require energy,
Ø If mining equipment becomes less frequently replaced and remains in use for
longer periods, the initial energy investment can be spread out, or amortized,
over several years of mining.
à As mining rigs become more efficient, the amount of electricity required may
decrease, reducing energy costs. However, energy consumption will never be
entirely eliminated; it will always remain a fundamental aspect of Bitcoin mining.
Continued…
3. Cooling: Bitcoin mining equipment requires effective cooling to avoid
overheating and malfunction.
à Typically, the energy needed for cooling is also provided through electricity,
adding to the overall operational costs.
Mining at Scale
Ø At large scales, embodied energy and electricity costs per unit of mining work
decrease due to efficiency in chip design and power delivery.
u If miners spent all their revenue on electricity, they could purchase 367
megajoules of energy per second, assuming an average industrial electricity cost
of $0.10 per kilowatt-hour ($0.03 per megajoule).
u The manager then distributes the block reward proportionally based on each
miner's contributed work.
u The miner who found the block does not receive any special bonus.
2. While miners can leave a pool perceived as too powerful, it is unclear how often
this happens in practice.
2. Reduced Node Participation:
1. Mining pools decrease the number of participants running fully validating Bitcoin
nodes.
2. Previously, all miners stored the entire blockchain and validated every transaction
independently, ensuring decentralization at the node level.
u Mining pools balance efficiency and accessibility for miners but come with trade-offs
in centralization and decentralization of network operations.
Mining incentives and strategies
u There are also some interesting strategic considerations that every miner has to
make before they pick which blocks to work on.
1. Choosing Transactions to Include:
• Miners select which transactions to include in a block, typically prioritizing those
with transaction fees higher than a set minimum.
2. Deciding Which Block to Mine On:
• Miners decide which block to extend, with the default strategy being to mine on
top of the longest valid chain.
3. Choosing Between Competing Blocks at the Same Height:
• When two blocks at the same height are announced simultaneously, creating a 1-
block fork, miners choose which block to extend. The default behavior is to extend
the block they heard about first.
4. Timing of Block Announcements:
• Miners decide when to announce a newly mined block. The default is to announce
immediately, but they may choose to delay the announcement for strategic reasons.
Forking attack
u Forking Attack Overview
• Objective: Perform a double-spend by creating a fork in the blockchain.
Eg: The attacker sends a payment to the victim (e.g., Bob) for a good or
service.
• Bob confirms the transaction on the blockchain and ships the goods or
performs the service.
u Fork Creation and Double Spend
• The attacker starts working on an earlier block—before the block containing
the transaction to Bob.
• On this forked chain, the attacker includes a double-spend transaction,
redirecting the coins back to their own address.
• This creates two competing chains:
• Main Chain: Includes the original transaction to Bob.
• Forked Chain: Includes the double-spend transaction.
Forking attack:Conditions for Success
• For the attack to succeed:
• The forked chain must overtake the current longest chain.
• The attacker must have majority hash power (α>0.5\alpha > 0.5α>0.5).
• This ensures that the attacker can consistently mine blocks faster than the honest
miners.
• Once successful, the transaction to Bob no longer exists on the consensus blockchain.
u Implications and Risks
• Impact on Bob:
• Bob loses the goods or service provided, as the payment no longer exists on the
blockchain.
• Importance of Hash Power Distribution:
• The attack is viable only if the attacker has majority hash power.
• Maintaining decentralized hash power is critical to preventing such attacks.
Forking attack
u
Forking attack
u Forking attack becomes feasible when an attacker controls more than 50% of the
network’s hash power (α>0.5\alpha > 0.5α>0.5), but it may also be possible with
slightly less due to factors like network latency.
u Default miners on the main chain experience delays in hearing about new blocks,
leading to stale blocks, while a centralized attacker can communicate faster and
produce fewer stale blocks, potentially gaining an efficiency advantage of 1% or more.
u However, near the 50% threshold, such attacks rely heavily on random chance and may
take a long time to succeed.
u The attack becomes increasingly efficient as the attacker’s hash power surpasses 50%,
making 51% less of a strict threshold and more of a gradual tipping point.
Forking attack via Bribery
u Challenges of a Direct Forking Attack
• Direct Approach: Buying enough hardware to control the majority of hash
power is:
• Expensive and difficult due to the scale of global mining capacity.
• Alternative Solution: Bribing existing miners to work on the attacker’s fork
instead of acquiring hash power directly.
u Methods of Bribing Miners
1. Out-of-Band Payments:
1. Locate large-scale miners and offer cash or incentives to support the fork.
2. Creating a New Mining Pool:
1. Run a pool at a loss with higher incentives than other pools to attract
miners temporarily.
3. Big Tips on the Forked Chain:
1. Leave large block rewards (tips) on the forked chain to entice miners to
leave the longest chain and work on the fork.
Forking attack via bribery:Attack Mechanics
• Goal: Use bribes to redirect existing hash power to the attacker’s fork, allowing it to
overtake the longest chain.
• Key Idea: Instead of acquiring hardware, the attacker pays miners already controlling
the capacity.
u Risks and Considerations
• Resistance from Miners:
• Miners might avoid helping the attacker to protect the currency they’ve invested
in.
• Tragedy of the Commons:
• While miners collectively benefit from a solvent currency, individual miners may
defect if they see short-term financial gain from accepting bribes.
u Implications for Network Security
• Short-Term Gain vs. Long-Term Stability:
• Attack success depends on miners prioritizing immediate rewards over the
network's health.
• Defense:A decentralized and incentivized network reduces the risk of bribery and
fork attacks.
Temporary Block-Withholding Attacks
u Selfish Mining Overview
• Default Behavior:
• Miners announce a newly found block immediately to the network.
• Selfish Mining:
• A miner withholds a block instead of announcing it.
• The goal is to secretly mine additional blocks on top of the withheld block.
u Mechanics of Selfish Mining
• Key Objective:
• Get ahead of the public blockchain by mining two secret blocks in a row.
• Outcome if Successful:
• Once two secret blocks are mined:
• The attacker announces both blocks at once.
• The attacker's chain becomes the longest valid chain.
• The block found by the rest of the network becomes orphaned, wasting their mining effort.
Temporary Block-Withholding Attacks
u Impact on the Network
• Wasted Hash Power:
• Other miners unknowingly work on what they think is the longest chain, only for their block
to become stale upon the attacker's reveal.
• Attacker’s Gain:
• Increases the attacker’s effective share of mining rewards by undermining the network’s
efficiency.
u Implications of Selfish Mining
• Network Vulnerability:
• Exploits the protocol’s reliance on the longest chain rule.
• Can reduce trust in the network if left unchecked.
• Mitigation Strategies:
• Incentive-compatible mechanisms to ensure honest behavior.
• Increased network decentralization to dilute selfish miners’ impact.
Temporary Block-Withholding Attacks
Blacklisting and Punitive Forking
u Blacklisting Transactions in Bitcoin
• What is Blacklisting?
• Preventing transactions from a specific address (e.g., address X) by making its
funds unspendable.
• Potential Motivations:
• Ransom/Extortion: Force payment to remove the blacklist.
• Legal Compliance: Government or law enforcement designates certain
addresses as "evil" and mandates miners to blacklist them.
u Challenges of Blacklisting: Conventional Wisdom:
• Blacklisting is ineffective because:
• Some miners may refuse to include transactions, but others will.
• Blacklisted transactions can still be processed by miners outside the
jurisdiction enforcing the blacklist.
Temporary Block-Withholding Attacks
u Punitive Forking as a Blacklisting Strategy
• Punitive Forking Approach:
• A miner announces they will refuse to work on a chain containing blacklisted transactions.
• If the miner controls a majority of the hash power, the threat ensures blacklisted transactions
are excluded.
• Other miners may stop trying to include these transactions to avoid their blocks being orphaned.
u Implications of Punitive Forking
• Risks and Consequences:
• Centralization Risk: A miner with majority hash power could censor transactions unilaterally.
• Undermines Decentralization: Incentivizes compliance with dominant miners instead of
independent operations.
• Legal and Ethical Issues: Raises questions about censorship and the neutrality of the Bitcoin
network.
• Potential Defense:
• Decentralization of hash power reduces the feasibility of punitive forking.
Feather Forking
u Punitive Forking and Its Limitations
• Punitive Forking:
• A miner announces they will refuse to mine on a chain containing certain
transactions (e.g., from address X).
• Challenges:
• Requires Majority Hash Power: The attacker must control more than 50% of the
network hash power to succeed.
• Risk of Self-Isolation: If the blacklisted transactions are included in the
consensus chain, the attacker’s mining efforts are wasted.
• Result: Punitive forking is not credible to other miners and often fails.
Feather Forking
u Feather Forking as a Better Strategy:
• Instead of refusing to mine indefinitely, the attacker announces they will attempt to fork
but give up after a certain number of blocks (e.g., k blocks).
Eg: If a transaction from address X is included, the attacker mines on an alternate chain for
a short time and then rejoins the longest chain if unsuccessful.
u Probabilities and Incentives
• Success Probability:
• With hash power α, the chance of replacing one block is α.
• The chance of replacing two blocks in a row is α2 .
Eg: For α=0.20(20% hash power), the chance of success is 0.04 (4%).
• Incentive for Other Miners:
• Other miners see an α2 chance that their block will be orphaned if they include
transactions from address X.
• To avoid losing rewards, rational miners may choose to avoid the blacklisted
transactions, even if α<0.5.
Feather Forking
u Collective Enforcement of Blacklists
• Cooperation Among Miners:
• Rational miners may join the attacker to enforce the blacklist.
• Motivation: Avoiding the risk of orphaned blocks outweighs the transaction fees from the
blacklisted transactions.
• Result:
• Even without majority hash power, feather forking can effectively enforce a blacklist.
u Implications for the Bitcoin Network
• Feather Forking Effectiveness:
• Works even when the attacker has less than 50% hash power.
• Increases centralization risks as miners may be coerced into enforcing blacklists.
• Defenses:
• Promote decentralization to dilute individual miners’ influence.
• Encourage transaction inclusion to resist censorship.
Transitioning to Mining rewards dominated by transaction fees
u As of 2015, transaction fees contribute minimally to miners' revenue, with block
rewards accounting for over 99% of their earnings.
u However, the scheduled halving of block rewards every four years will eventually make
transaction fees the primary source of income for miners.
u This raises open questions about how miners will adapt when transaction fees dominate
their revenue.
u Will miners become more aggressive in enforcing minimum transaction fees, or will
they cooperate to establish and enforce fee thresholds?
u These uncertainties highlight potential shifts in mining strategies and network dynamics
as the Bitcoin ecosystem evolves.