Bitcoin technology Part 1: the network
I don't believe we shall ever have a good money again before we take the thing out of the hands of government, that is, we can't take it violently out of the hands of government, all we can do is by some sly roundabout way introduce something that they can't stop. — F.A. Hayek (1984)
The Bitcoin network is the set of interconnected computers (nodes) that participate maintaining the integrity of a distributed log/database/ledger that shows historic messages containing orders to transfer balance, and that collaborate to securely register new orders verifying that they follow the Bitcoin rules. That set of rules is known as the Bitcoin Protocol.
The Bitcoin client or implementation is a piece of code (software) that anyone can run on their computer to become a node.
That piece of code is free and open-source (anyone can review the code). There are different versions of that software, all of them follow the same rules but may have slightly different configurations. The reference implementation which is the most reviewed is called Bitcoin Core. The last version can be downloaded from here: https://bitcoincore.org/en/download/
Using the ledger, current balances can be tracked.
The ledger is called blockchain, and the set of balances is called UTXO set.
Each balance is associated with an account (pkh). Any user can create as many accounts as he wants, it is a simple and free process which a programs called wallet help to assist. Most nodes include a wallet function but it is not necessary to be connected to the Network in order to create addresses. Each address have a password associated called Private Key.
First it is necessary to choose a secret random number -> public key derivation. PK, ->public key hash <-> address.
tx: PKH1 says ",,,,,". Fdo por PKH1.
Ledger -> current balances can be tracked -> UTXO set. Bitcoin unit.
UTXO set = chart.
Accounts=addresses. Private key=password.
Tx: message saying change ma balance. signed statement.
Transactions start as messages digitally signed by the owner of a balance that are propagated from a node.
That ledger is called BlockChain. It is distributed because each node keeps a copy of it.
-Blocks are produced at an average rate of 10'. Each new block contains a more recent list of txs.
Analogy: blocks are the pages of the ledger.
-Chain: each block is linked to the previous one, so that if a block changes, the newer blocks that follow it will be invalid. The last block contains the last state of txs.
Analogy: each page of the ledger contains a small photo of the previous page, so that if previous page changes, all the subsequent pages will be invalidated.
The unit of account of the blockchain is bitcoin (with a lowecase "b"). Each bitcoin is divisible into 100,000,000 satoshis. 1.000000001 ₿ btc = 1bitcoin and 1 satoshi. (a monetary unit of what there will be only ..21 million and which rate of issuance halves every 4 years).
Txs are not considered confirmed until they are included in a block.
The set of unconfirmed txs is called mempool.
Each node keeps a copy of the blockchain and a mempool.
Nowadays balances are usually allocated into addresses.
Any user can create as many addresses as he wants, it is a simple free process using a wallet: a program that creates and manages
An unconfirmed tx is a broadcasted signed message by the owner of the bitcoin.
A node is a mobile phone in a whatsapp group. Its the central bank?
Bitcoin nodes enforce the rules by receiving, validating/verifying and propagating/relaying/passing information that consists of unconfirmed txs and blocks.
They may also create new txs through wallet functionality and to produce new blocks which is called mining.
Inside each block that is created there is also tx with a reward in bitcoin to its producer, also called miner.
Basic mechanics / Simplified scheme of the process:
To simplify let's assume no bitcoin node has a mempool yet. A node decides to create a tx with ID g7s (represented as .....) which will include information about the amount sent, the inputs (sending addresses), and the outputs (recieving addresses). That tx is transmitted like a gossip from node to node:
A new tx with the ID m2z (represented as .) is published by other node. The tx is also propagated, some of the nodes receive this new tx before than tx .....:
The mempool may vary between nodes, each node has its own set and order of unconfirmed txs.
As more transactions are publish and propagated, the mempool of each node grows:
Opposite to the mempool, the list of txs in a block is set in stone. The list order and content can not be altered. The goal is to get all nodes keeping a copy of the same blockchain.
One node (miner) will take the lead and will produce a block. He decides which txs are allocated inside it, so he has the power to transform unconfirmed txs into confirmed ones. He will publish the block and if valid, it will be passed from node to node:
Txs that are included in a block, are removed from the mempool.
Nodes will accept the first block seen, so in case that 2 blocks are mined at almost the same time and are not linked each other, some nodes will accept one block valid (yellow block in the example) and discard the other (pink block in the example) while the rest of nodes will do the opposite:
At these point there would be 2 different blockchains coexisting for a short period of time, but this kind of conflict can only last while both chains have the same number of blocks. That dispute is solved when another block is created (a pink block in this example). Nodes follow the chain with "the most accumulated PoW", that almost always is, and we will understand for now, as the longest chain (the chain with a bigger number of blocks). So the nodes that were following the shorter chain will forget about it and will embrace the longer one.
The txs that were included into the discarded block are returned to the meempool if they are not included in the new accepted chain.
The block discarded in called an orphan block and the process of discarding the shorter chain is called a reorg.
Two different tx are published. Tx .,. and tx ._.. Some nodes have incorporated them into their mempool, others not yet.
Vocabulary: distributed network
Spreadsheet. Adresses, wallets. Hash?
Creating new accounts. Controlling created accounts. Nodes and accounts are not linked
That is enough for a basic knowledge about the network.
More advanced explanation of some topics.
A monetary system IS a spreadsheet of balances (balancesheet). Different spreadsheets imply different monetary systems.
........ (gold, fiat, bitcoin UTXO set).
Physical: individual have part.
Centralized digital: in one location
->Decentralized digital: in different locations. Why? Decentralized balancesheet
Transactions simply are changes in the spreadsheet.
execution(2) There is an order of execution that determines validity of txs.
Gold: 2 made by individuals.
Fiat: 1)Commercial banks apply and the 2)CB make the changes.
->Bitcoin: users send its desired txs, if valid (comparing to their spreadsheet) txs are relayed, one node takes the lead updating his spreadsheet (creating a block), the new spreedsheet have to be accepted by the rest of nodes. It is executed by that node but it will not but completely executed until the rest of nodes update the balance sheet. Decentralized execution.
Naive approach: meempool -> spreadsheet using unconfimed tx as the execution txs.
Even if we somehow get the same initial mempool by all nodes, they will end up differing at least in order.
This is necessarily so because each node receives txs in different order. This means the spreadsheet will differ when conflicting transactions arrive at different order. This can happen involuntarily or voluntarily "Double spend attack. Different spreadsheets = different monetary systems.
No possible to know exactly wich tx was sent first.
A common ledger is needed.
A common order of txs is needed. How to agree? no majority, in a decentralized way.
Someone should lead, but he should not lead always. Easily remplazable. Privacy of identity. Permisionless.
Lottery. If nodes->not possible, sybil attack. Effort to create that block, if 100% of network working on that would find a "fish at an average of 10'"
The fisher send the order to everybodyesle and miners have the incentive to write that order because this way they have more probability to get the next reward.
Then we consider tx is finalized. To prevent double spend, wait more.
low probability of creating a fork.
Sheet limited and also the updates. Fees. incentivize to continue in the chain by miners that already mined by reward (it prevent double-spending). Other miners dont care much, they are incentivized to start mining in the longest chain as soon as possible
Mechanism for updating the spreadsheet.
Ledger of txs. Ledger is a register of the changes produced in the database. In Bitcoin is the power is limited to simply accept and order desired txs.
In Bitcoin new spreadsheet have to be accepted by the users.
Physical -> nature HISTORY. Each part of a tx knows about it.
Digital -> 1 Ledger of txs. Centralized: 1 location Distributed: same ledger different locations.
initial txs: not 1 ledger.
Why the need of agreeing on a ?
Why the need of keeping txs in a ledger?
To maintain scarcity.
Why the need of a common ledger?
In a pure physical monetary system, like gold bullion, that common ledger is imposed by the laws of nature.
The physical nature maintains scarcity because it avoids the infinite creation of new units and it avoids the double spend problem (an user could spend the same balance more than once).
......gold. ships. countries.
If the monetary system is digital, the monetary units are only data in a spreadsheet, so scarcity is not guaranteed by the force of nature. Anyone with the power to change that database can create new units or could perform a double spend.
E.g. Current fiat system:
then a common ledger (=a commonly accepted order/hierarchy or txs) is needed to keep track of each balance. If not, the "double spend problem" arises.
E.g. Traditional banking system: the ledger of the reserves of all commercial banks is keeped by the Central Bank who has control over it. When a commercial bank A wants to make a transfer to commercial bank B, commercial bank A simply noticies the Central Bank and the Central Bank will make a new entry on its ledger removing balance from commercial bank A and adding the same balance to commercial bank B.
If commercial bank A tries to spend its balance twice, usually the Central Bank will declare invalid the second tx recieved.
In a decentralized network there is no central authority to validate txs. Each node is an authority, so the same ledger is needed in every node.
A naive approach would be to use the mempool as that ledger and when conflicting txs appear, validate only the first one. But then mempools would vary between nodes. In a decentralized network it is not possible to proof exactly wich tx was sent first if txs were sent within a relatively small timeframe (=more than just a few seconds in a distributed digital network), each node can only know which tx it received first. It takes different time for data to get to different nodes, also, balances are not linked to specific nodes, any user can control different nodes so two conflicting txs could be sent at the same time. So if following a "only the first received conflicting tx is valid" approach, databases would differ/there would different versions of the s because different nodes receive txs in different order. No common database-> double spend problem: a bitcoin owner may try to spend the same coin on different txs:
From the same node, each tx initially goes to different connecting nodes.
From different nodes, each node publishes a different tx.
A naive approach would be to make only use of the mempool. Txs would be peer-to-peer and each peer would update its spreadsheets of balances. The first and biggest problem is that different peers would have different versions of the spreadsheet. If so, One of those txs should be declared invalid by all of the network.
It is necessary to establish an order of txs, to proof which fish came first. E.g. with
So a ledger is needed.
and it would make sense to declare the first tx sent as the valid one
Unconfirmed txs could be seen as gossips. Different gossips can be transmitted to different persons or from different places. E.g. one gossip says "It's going to be a rainy day" and other says "It's going to be a sunny day", both can not be true at the same time, so maybe people will assume the one received first is the true one. If the different gossips starts to propagate in whatsapp nearly at the same time to different groups, not all people will receive the same message first.
In a decentralized network a mechanism is needed to make possible for users to agree on an specific order.
Txs are not ordered in mempools.
A mempool it is like
There would be a dispute between different nodes that recognize a different tx as valid.
When establishing an order, only the 1st tx would be recognized as valid.
Blocks have a limited space of data that depends on the txs included. The theoretical maximum size is 4 megabytes and the more realistic maximum size is 2 megabytes maximum which allows around 3500 transactions.
Txs compete to enter in the block, this is why the sender can choose a fee to incentive miners to choose that tx with a higher/lower priority.
The miner that produces a block collects the fees of txs that end up inside the block, and also he collects the block subsidy.
The block subsidy is a fixed quantity of bitcoin that the miner earns automatically when creating a block. When Bitcoin first started, 50 Bitcoins per block were given but that subsidy halves every every 210,000 blocks (approximately every 4 years) and will keep on halving until the block reward per block becomes 0 (approximately by year 2140). As of now, the block reward is 12.5 coins per block and will decrease to 6.25 coins per block post halving.
Block subsidy + fees = block reward.
Competition to create blocks is so high that the probability of creating a block for a single miner is extremely low. So some users join forces forming mining pools. When a mining pool is able to create a block and gets the reward, it is distributed between the mining pool members/miners.
Mining. Proof of work.
Reality is that normal nodes are most certain of not being able to main. Specialized.
Tx. Addresses. Private key, public key.
PoW 10' average but randomly.
Each node when it is connected, it can download mempool and blockchain.
That reward consists in a subsidy and fees collected from txs allocated into that block.
Fees: limited space.
A node that possesses access to the keys of an address with a balance of 1 btc: publish the tx, if it is valid it is propagated from node to node like a gossip.
One of the nodes that knows about that tx create a block and includes that tx. The block is propagated through the network from node to node. The nodes that receive the block, after verifying its validity, update their copy of the blockchain and relay that block to other nodes than don't know yet about it.
Nodes maintain a mempool with unconfirmed txs they received, and a copy of the blockchain.
When unconfirmed txs are included in a new valid block, they remove them from the mempol update their blockchain with the new block and remove
deeper in the blockchain more secure, like a mosquito en ambar vs corteza.
Why is it necessary to record the txs in the blockchain?
To prevent double-spending.
common list. legder
blocks: convinient to check, easy to verify. more secure. organize. easy to verify miners y nodes. check what came late. more secure.
They can store it partially or the entire copy (full node).
Txs->blocks: prevent double-spending
How to allow censorship resistance -> decentralization? Easy verifiability.
It is important to establish a previous order, because this way is not necessary to verify everything at any moment. It is easy to verify new information since the last check. So user can easily verify new information.
Miners sign only the most recent block of tx while still, indirectly via the previous block ID pointer, signing all historic txs.
who establishes the new order?
Lottery. Decentralization. Permisionless. Resilience (no identity, no fixed location), physical world. PoW.
To agree in the established order. Nakamoto Consensus.
How to agree?
Most accumulated PoW. Nakamoto Consensus.
A more detailed explanation:
Tx: Pub key, private key. Address.
Block: hash. Reorgs, orphans, empty blocks.
Who is going to want to include that tx in a block? How can people get new bitcoins in a permissionless way? Physical world.
-Agreeing on the "right" blockchain
Txs are considered confirmed/ when they are included into a block, that is, the are registered in the blockchain. So in order to send a tx, a node needs to first have bitcoin, later send the information, be included in ab block.
Number of tx is limited so, they compete to be included by paying a fee.
Who collects that fee?
Miners, are nodes that include info of requested tx into blocks. PoW consensus or nakamoto consensus. Energy. Real world. preventing double spend, all together. archivar en carpetas, todo el mundo deacuerdo, hashes asi que ocupa menos. prevent disputes and changes about history. m
Private key and public key.