0% found this document useful (0 votes)
11 views50 pages

3 Bitcoin

blockchain lecture 3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views50 pages

3 Bitcoin

blockchain lecture 3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Blockchain Technology

and Cryptocurrencies
3 - Bitcoin

Dr. Stefan Obernberger


Today

• The mechanics of Bitcoin

• Economics of the mechanics

• Limitations and challenges of Bitcoin

Stefan Obernberger - ESE 2


Goals of this lecture

1. Get to know the critical design choices inherent in Bitcoin

2. Work out the economics of mining Bitcoin

3. Understand why it’s very difficult to realize decentralization,


consensus, and efficiency at the same time

Stefan Obernberger - ESE 3


Bitcoin (Euro) 2011 – 09/09/2024

2011: 3 €
2012: 10 €
2015: 250 €

Stefan Obernberger - ESE 4


Bitcoin

• Bitcoin is a virtual currency traded and recorded by


a peer-to-peer network on a “blockchain”
– Peers are equally privileged, equipotent participants in the
application.
– They form a peer-to-peer network of nodes.
– One node == Bitcoin client

• In order to maintain distributed consensus, the


following questions need to be answered
– Who maintains the ledger of transactions?
– Who has authority over which transactions are valid?
– Who creates new bitcoins?

Stefan Obernberger - ESE 5


Bitcoin consensus algorithm

1. New transactions are broadcast to all nodes


2. Each node collects new transactions into a block
3. In each round, proof-of-work determines a random
node to broadcast its block
4. Other nodes accept the block only if all
transactions in it are valid
5. Nodes express their acceptance of the block by
including its hash in the next block they create

Stefan Obernberger - ESE 6


Bitcoin mining

• Procedure
• Economics
• Mining hardware and network
• Mining pools

Stefan Obernberger - ESE 7


Mining

• Mining is the process of adding a new block of


transactions to the blockchain
– With every block, new Bitcoins are created (coinbase
transaction) and rewarded to the node that mines the block
– To mine the block, nodes have to solve a puzzle known as
proof-of-work

• Consensus mechanism needs to prevent


– Theft of bitcoins
– Denial-of-service attack
– Double spend attack

Stefan Obernberger - ESE 8


The task of bitcoin miners

1. Listen for transactions


2. Maintain blockchain and listen for new blocks
3. Assemble a candidate block
4. Find a nonce that creates a valid hash of your
block
5. Hope your block is accepted
6. Receive a reward in terms of minted bitcoins and
transaction fees

Stefan Obernberger - ESE 9


Discussion question

• Why is mining necessary for a decentral platform to


work?
– Mining requires miners to make an investment (computing
power and hardware) in order to make a profit
– To ensure the integrity of the blockchain = maximize
expected return
• Check newly added blocks for consistency and
accuracy
• Keep copies of the blockchain
– Mining ensures that a large number of independent nodes
validates the blockchain continuously.

Stefan Obernberger - ESE 10


Bitcoin rewards for mining a block half
every 210,000 blocks
Total Bitcoin
Year BTC per block Blocks created Bitcoin created created
2009 50 210,000 10,500,000 10,500,000
2013 25.000000 420,000 5,250,000 15,750,000
2017 12.500000 630,000 2,625,000 18,375,000
2023 6.250000 840,000 1,312,500 19,687,500
Sep-24 3.125000 860595 64,362 19,751,862
2025 3.125000 1,050,000 656,250 20,343,750
2029 1.562500 1,260,000 328,125 20,671,875
2033 0.781250 1,470,000 164,063 20,835,938
2037 0.390625 1,680,000 82,031 20,917,969
2041 0.195313 1,890,000 41,016 20,958,984
2045 0.097656 2,100,000 20,508 20,979,492
2049 0.048828 2,310,000 10,254 20,989,746
2053 0.024414 2,520,000 5,127 20,994,873
2057 0.012207 2,730,000 2,563 20,997,437


2140 0.000001 5,460,000 0 21,000,000

Stefan Obernberger - ESE 11


The evolution of mining. An arms race?

Stefan Obernberger - ESE 12


Hash rate of the network and difficulty
of proof-of-work

The difficulty of the hash puzzle depends on the network’s total hash rate and is
adjusted every 2016 blocks such that the expected time to mine a block is 10 minutes.

Stefan Obernberger - ESE 13


Profitability of mining

• E(Profit) = E(Revenues) – E(costs)

• E(Revenues) = pmining x [E(PBTC) x NBTC + E(∑Tx-


Fees)]

• pmining = Hash-rate / Network hash-rate

• Network hash-rate = f(Costs, PBTC, Innovation)

• E(Costs) = E(Electricity-costs) + Hardware

Stefan Obernberger - ESE 14


Profits from ASIC miner

Stefan Obernberger - ESE 15


Profits from Antminer S19j Pro

Network Hash rate: 125 1,000,000 TH Price Antminer 11,000


Antminer: 100 TH Lifetime (days) 1,460
p(mining) 0.00000080 $ cost hardware per day 7.53
N(BTC) 6.25 KWH Antminer 3.050
P(BTC) 50,000 $ per KwH electricity 0.10
N(BTC) x P(BTC) 312,500 $ Cost of electricity per hour 0.31
$ Income per block 0.25000 $ Cost of electricity per day 7.32
Blocks per day = 6 x 24 144

$ Income per day 36 $ cost per day 14.85

$ profit per day 21.15


Is this the right way to evaluate an
$ profit per year 7,718
investment opportunity?

Stefan Obernberger - ESE 16


Mining revenue and hash rate of the
network

Stefan Obernberger - ESE 17


Centralized mining pools and
blockchain governance

• Mining pools
– can be joined by any miner willing to contribute “hashes” to
the pool
– provide insurance to miners: pay out block reward even if
miner does not solve the puzzle
– earn a (insurance) fee in return

• Insurance contract components:


– Pay per share (of hash rate in the network)
– With or without transaction fees
– Dependent or independent of pool’s success

Stefan Obernberger - ESE 18


Mining pools – hash rate distribution
over time

Stefan Obernberger - ESE 19


Bitmain and corporate capture of
blockchain governance

• Bitmain produces ASIC miners, 75% market share


– affiliated with AntPool, BTC.com, ViaBTC
– a business partner of BTC.Top, OKExPool, Huobi.pool, 1THash
– Bitmain affiliated pools consistently have at least 30% of total
network hash rate (Ferreira, Li, Nikolowa, 2021)

→ Reality is different from Nakamoto’s (2008) vision of


perfect competition among independent computer nodes

• How decentralized is Bitcoin really? How fool-proof is


proof-of-work really?

Stefan Obernberger - ESE 20


What are the implications of centralized pools
for decentralized mining? (Cong, He, Li, 2021)

• Centralized pools and risk sharing


– Certainty equivalent more than doubles
– Risk sharing benefits increase in pool size, no other economies of scale
→ Centralized mining pools allow small miners to contribute to the network

• Centralized pools and network hash rates


– Acquisition of hash rates hurts others’ payoffs
– Others’ will in turn acquire hash rates, too
→ Mining pools escalate arms race, driving up energy consumption

• Centralized pools and decentralized networks


– Fees increase in pool size, implying a limit to pool size as long as miners can
freely allocate their hash rates over several pools
– Pool sizes should mean-revert endogenously
→ Mining pools centralize the network, but there are limits to it

Stefan Obernberger - ESE 21


Transactions

• Transaction logic
• Transaction-based ledger
• Transaction blocks
• Fees

Stefan Obernberger - ESE 22


Transaction structure

Meta: Transaction-ID

Input: Reference Transaction-ID,


Output-Index
Output: Bitcoin -> Recipient-Address(es)
Bitcoin -> Change-address

The transaction has to be signed by the input-address

Input = Output + Transaction fee


=> Transaction fee = Input - Output

Stefan Obernberger - ESE 23


Example: Transaction content and
history

Transaction-ID: 87428FC522803D31065E7BCE3CF03FE475096631E5E07BBD7A0FDE60C4CF25C7
IN: -,- Coinbase
transaction
OUT: 6.25, 569C7F0B41CE9649602A0218CD02ED0B0A3D93130329451CC782B7DFDA79CE71

Transaction-ID: 9485F2843ED1CCC679CB4F1A3D21B3C540A5EC6DD81D9CFA0584698C8CA5A311
IN: 87428FC522803D31065E7BCE3CF03FE475096631E5E07BBD7A0FDE60C4CF25C7, 0 Signed
by
0.20, A3A5E715F0CC574A73C3F9BEBB6BC24F32FFD5B67B387244C2C909DA779A1478
0.40, 6695BE395E92389B2C42D9DEE795D7E7B36B4314AA4420CF70E717BADF6634AD
“569…”
5.60, 569C7F0B41CE9649602A0218CD02ED0B0A3D93130329451CC782B7DFDA79CE71

Transaction-ID: A9642928DD2F79B36B62B2E32199791F32F46E849F202A4281CD7AA88260A4E3
Signed
IN: 9485F2843ED1CCC679CB4F1A3D21B3C540A5EC6DD81D9CFA0584698C8CA5A311, 2
by
0.23, A3A5E715F0CC574A73C3F9BEBB6BC24F32FFD5B67B387244C2C909DA779A1478 “569…”
5.10, 569C7F0B41CE9649602A0218CD02ED0B0A3D93130329451CC782B7DFDA79CE71

Stefan Obernberger - ESE 24


Example: Transaction content and
history
Reference to output in earlier
transaction that is spent in this
transaction
Reference to earlier transaction

Transaction-ID: 9485F2843ED1CCC679CB4F1A3D21B3C540A5EC6DD81D9CFA0584698C8CA5A311
IN: 87428FC522803D31065E7BCE3CF03FE475096631E5E07BBD7A0FDE60C4CF25C7, 0 Signed
by
0.20, A3A5E715F0CC574A73C3F9BEBB6BC24F32FFD5B67B387244C2C909DA779A1478
0.40, 6695BE395E92389B2C42D9DEE795D7E7B36B4314AA4420CF70E717BADF6634AD
“569…”
5.60, 569C7F0B41CE9649602A0218CD02ED0B0A3D93130329451CC782B7DFDA79CE71

Change address

Fees = Input – Output = 6.25 – 6.20 = 0.05 BTC = 5,000,000 Satoshis

Stefan Obernberger - ESE 25


Transaction-based ledger

T-ID Input Output-0 Output-1 Output-2

T-ID Input Output-0

T-ID Input Output-0 Output-1

T-ID Input Output-0 Output-1 Output-2

T-ID Input Output-0

T-ID Input-1 Input-2 Output-0

T-ID Input Output-0 Output-1 Output-2 Output-2

Stefan Obernberger - ESE 26


Transaction-based ledger

T-ID Input Output-0 Output-1 Output-2

T-ID Input Output-0

T-ID Input Output-0 Output-1

T-ID Input Output-0 Output-1 Output-2


unspent transaction
output (UTXO)
T-ID Input Output-0
spent output

T-ID Input-1 Input-2 Output-0

T-ID Input Output-0 Output-1 Output-2 Output-2

Stefan Obernberger - ESE 27


Bitcoin scripts

• Transaction code contains bitcoin scripts


– Script is a simple, stack based language
– Turing incomplete (cannot run loops)
– Supposed to be very simple and robust, to protect from
denial-of-service attacks
• Scripts are used to sign transactions, MULTISIG
allows to define more than one signee

Stefan Obernberger - ESE 28


Escrow transaction

Alice purchases a laptop for 150 Satoshis from Bob. Alice does not know Bob and decides
to ask Judy to act as an escrow in case there is a dispute between her and Bob. Bob agrees.
Scenario 1: All goes well.

MULTISIG- SCRIPT requiring that at least two of three


ADDRESS signatures are provided in a transaction
that wants to use the output parked in the
MULTISIG-ADDRESS

T-ID Input Output-0 CHECKMULTISIG Signature Alice 1. Alice sends MULTISIG-Transaction


2. Bob sends Laptop
3. Alice checks Laptop and is happy
4. Alice sends and signs second transaction
spending the MULTISIG-output
5. Bob signs too and validates transaction
T-ID Input Output-0 Signature Alice Signature Bob

BTC are transferred


to Bob’s address

Stefan Obernberger - ESE 29


Escrow transaction

Alice purchases a laptop for 150 Satoshis from Bob. Alice does not know Bob and decides
To ask Judy to act as an escrow in case there is a dispute between her and Bob. Bob agrees.
Scenario 2: Bob’s laptop does not work. Alice wants to keep the BTC. Judy agrees.

T-ID Input Output-0 CHECKMULTISIG Signature Alice

T-ID Input Output-0 Signature Alice Signature Judy

BTC are transferred 1. Alice sends MULTISIG-Transaction


2. Bob sends Laptop
back to Alice’s address 3. Alice checks Laptop and is unhappy
4. Judy checks Laptop and agrees with Alice
5. Alice sends and signs second transaction
spending the MULTISIG-output
6. Judy signs too and validates the transaction

Stefan Obernberger - ESE 30


A simple transaction in raw code

{
"txid" : "c80b343d2ce2b5d829c2de9854c7c8d423c0e33bda264c4013\ 8d834aab4c0638",
"hash" : "c80b343d2ce2b5d829c2de9854c7c8d423c0e33bda264c40138d834aab4c0638",
"size" : 85,
"vsize" : 85,
"version" : 1,
"locktime" : 0,
"vin" : [
{
"txid" : "3f4fa19803dec4d6a84fae3821da7ac7577080ef75\ 451294e71f9b20e0ab1e7b",
"vout" : 0,
"scriptSig" : {
"asm" : "",
"hex" : "“
},
"sequence" : 4294967295
} ],
"vout" : [
{
"value" : 49.99990000,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 cbc20a7664f2f69e5355a\ a427045bc15e7c6c772
OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914cbc20a7664f2f69e5355aa427045bc15e\ 7c6c77288ac",
"reqSigs" : 1,
"type" :
"pubkeyhash",
"addresses" : [ "mz6KvC4aoUeo6wSxtiVQTo7FDwPnkp6URG" ]
}}]}

Stefan Obernberger - ESE 31


Block size

• Each block has a limit of 1 MB, each transaction has


a size of at least 250 bytes
– Limit of 4000 transactions per block
– Maximum throughput: 7 transactions per second
– Visa can handle 10K transactions per second, handles 2K
on average

• What happens if transactions > throughput?


– Miners can choose freely which transactions to include
– Transaction fees become critical in getting a transaction
recorded on the blockchain

Stefan Obernberger - ESE 32


Block size

Intro SegWit

Stefan Obernberger - ESE 33


Segregated Witness (SegWit)

• SegWit: protocol update to disable transaction malleability


– Bitcoin improvement Proposal 141 made in 2015
– Proposals happen all the time, need to be adopted by the majority of the
network, hardly go through
• Problem: transaction malleability
– After transaction is signed, the receiver can change the witness data
and, hence, the transaction ID (flaw in code)
– Sender will not notice this change and will resend transaction
– Receivers have used this trick to get double payment
• Solution: segregated witness
– Proposes to separate the witness data from the transaction data
– Side effect: SegWit increases block size to 4MB
– Soft fork: Adopters and non-adopters can mine the same
blockchain, adoption hence optional.

Stefan Obernberger - ESE 34


Transaction fees

• Default set in Bitcoin Core: 0.00001 BTC per kilobyte

• Any bitcoin service that creates transactions (including


wallets) must implement dynamic fees
– Third party service
– Own algorithm

• Parameters for determining dynamic fees: capacity,


priority, average fees recently paid, etc.
– Fees are chosen such that recording of the blockchain is likely
– Many services allow users to indicate priority

Stefan Obernberger - ESE 35


Congestion and transaction fees

Stefan Obernberger - ESE 36


Ransomware activity and blockchain
congestion (Sokolov, 2021)

• Ransomware activity exogenous shock to transaction demand


– Ransom usually has to be paid in BTC
– Ransom usually comes with a deadline
→ Network congestion

• RQ: Does congestion have an impact on transaction fees?


– Impact of congestion on transaction fees
– Impact of congestion on regular transaction demand

• Results
– Demand for transaction settlement positively related to fees
– Regular users forgo blockchain settlement in times of congestion
– Will transaction fees alone be able to compensate miners?

Stefan Obernberger - ESE 37


From mining to markets: The evolution
of bitcoin transaction fees
• Easley, O’Hara, Basu (2019):
– Transaction fees are not welfare-improving and they
induce some users to drop out of the market
– Transaction fees are driven by queuing problems, not by
reductions in miner rewards.

“The bitcoin processing issues, combined with trans-


action cost issues, raise the prospect that while bitcoin
can continue to develop as a financial asset, its
development as a transactional medium is more
problematic.”

Stefan Obernberger - ESE 38


Current challenges

• Does Bitcoin create value and for whom?


• Bitcoin’s impossibility triangle
• Anonymity
• Sustainability

Stefan Obernberger - ESE 39


How much legal, real-world activity is financed
through Bitcoin?

• Foley et al, 2019: $76bn of illegal activity per year involve bitcoin
– 46% of transactions in 2015, 20% in 2017
– Equivalent in size to the whole US market for illegal drugs
– Crypto enables illegal e-commerce

• Makarov and Schoar, 2021: $5bn of illegal activity in 2020


– Only 4% of transactions are illegal if speculative trades are included, and
spurious trades are excluded
– Most illegal activity associated with dark net payments and gambling
– The majority of Bitcoin transactions is linked to speculation

• Cong et al, 2021: Most trades on unregulated exchanges are wash trades
– Same party on both sides of the trade in 70% of volume
– Unregulated exchanges account for 99% of volume
– Much of the “speculative” transaction volume used to increase exchange
rankings and distort prices?

Stefan Obernberger - ESE 40


Bitcoin’s impossibility triangle

Stefan Obernberger - ESE 41


Bitcoin’s impossibility triangle
• Buterin (2015): goal of the blockchain technology is to achieve
decentralization.
– To receive wide adoption and application, consensus provision needs to
be accurate and scalable.
– Bitcoin blockchain achieves decentralization and consensus record at
the same time, but doing so reduces its scalability.
– Records made in large scales with decentralization are hard to
synchronize and achieve consensus.

• Abadi and Brunnermeier (2018) outline the economic trilemma:


– When a blockchain is decentralized, compensating various
recordkeepers necessarily implies that the system is costly;
– when the system is decentralized and maintained at low cost,
recordkeepers may misreport;
– when the consensus is correct and maintenance of the system is cheap,
the outcome is incompatible with free entry and information portability
(compared with traditional reputation-based system) conditions.

Stefan Obernberger - ESE 42


Anonymity

• Is Bitcoin anonymous?

• Do we want a cryptocurrency that is truly


anonymous?
– Beneficial for stakeholder?
– For society?

• Anonymity: “Interacting without a name”


– Bitcoin: You do not use your real name, but a pseudo-
identity (address)
→Bitcoin provides pseudonimity

Stefan Obernberger - ESE 43


Anonymity

• In computer science, anonymity comes from a


combination of pseudonymity and unlinkability
– Hard to link different addresses by same user?
– Hard to link different transactions by same user?
– Hard to link sender of a payment to its recipient?

• Does Bitcoin ensure unlinkability?


– All transactions of one address can be linked
– Addresses can be linked to the user through
• Hacking wallets
• Obtaining home/mail addresses from counterparties
• Revealing your identity in real world transactions (“buying a cup of coffee”)

Stefan Obernberger - ESE 44


Energy consumption
(Source: Digiconomist, 2021)

Stefan Obernberger - ESE 45


Energy consumption
(Source: Digiconomist, 2021)

Stefan Obernberger - ESE 46


Recent developments to make Bitcoin
future-ready

• Lightning network:
– So-called layer-2 application
– First transaction opens a channel (between) two peers
– (Bilateral) transactions off-chain
– Final balance of (bilateral) transactions on-chain

• Taproot protocol:
– Update to the Bitcoin protocol, soft fork with wide adoption
– Smart contract functionality
– Bitcoin ordinals: NFT-like functionality

Stefan Obernberger - ESE 47


Conclusion

• Blockchain Technology might have a bright future,


but the present of Bitcoin looks dim:
– Bitcoin seems to facilitate speculation and criminal activity,
but not much else
– Bitcoin is a significant source of environmental pollution

• Will Bitcoin manage to move towards a more


efficient consensus mechanism or will it become a
niche crypto-asset?
– Less decentralization and more scalability?
– Less security, but more scalability?

Stefan Obernberger - ESE 48


Next lecture

• Next lecture: We take a close look at Ethereum, which was


designed to fully enable the potential in the Bitcoin blockchain
– Smart contracts
– Proof of stake

• Required readings and questions will be posted online shortly.

Stefan Obernberger - ESE 49


Reference list
Cong, L. W., Li, X., Tang, K., & Yang, Y. (2021). Crypto wash
trading. arXiv preprint arXiv:2108.10984.
Easley, D., O'Hara, M., & Basu, S. (2019). From mining to
markets: The evolution of bitcoin transaction fees. Journal of
Financial Economics, 134(1), 91-109.
Foley, S., Karlsen, J. R., & Putniņš, T. J. (2019). Sex, drugs, and
bitcoin: How much illegal activity is financed through
cryptocurrencies?. The Review of Financial Studies, 32(5), 1798-
1853.
Makarov, I., & Schoar, A. (2021). Blockchain analysis of the
bitcoin market (No. w29396). National Bureau of Economic
Research.
Sokolov, K. (2021). Ransomware activity and blockchain
congestion. Journal of Financial Economics, 141(2), 771-782.

Stefan Obernberger - ESE 50

You might also like