Ethereum part 1
sec 1-2: gas per block and per miner

Introductions
What is a cryptocurrency?
Crypto (short for cryptocurrency) is a new form of digital money powered by cryptography.
It all started in 2008 with Bitcoin. You could use it to send funds to anyone anywhere globally. What made crypto different from normal bank transfers or other financial services like Paypal or Alipay is that there was no middle man for the first time.
Wait, what is a middle man?
A middle-man is a central authority like a bank or government that intervenes in a transaction between the sender and recipient. They have the power to surveill, censor or revert transactions and they can share the sensitive data they collect about you with third parties. They also often dictate which financial services you have access to.
Things are different with crypto. Transactions directly connect sender and recipient without having to deal with any central authority. Nobody else will have access to your funds and nobody can tell you what services you can use. This is possible because of the blockchain technology upon which cryptocurrencies operate.
What is the difference between Ethereum and Bitcoin?
Launched in 2015, Ethereum builds on Bitcoin's innovation, with some big differences.
Both let you use digital money without payment providers or banks. But Ethereum is programmable, so you can also build and deploy decentralized applications on its network.
Ethereum being programmable means that you can build apps that use the blockchain to store data or control what your app can do. This results in a general purpose blockchain that can be programmed to do anything. As there is no limit to what Ethereum can do, it allows for great innovation to happen on the Ethereum network.
While Bitcoin is only a payment network, Ethereum is more like a marketplace of financial services, games, social networks and other apps that respect your privacy and cannot censor you.
Who runs Ethereum?
Ethereum is not controlled by any one entity. It exists solely through the decentralized participation and cooperation of the community. Ethereum makes use of nodes (a computer with a copy of the Ethereum blockchain data) run by volunteers to replace individual server and cloud systems owned by major internet providers and services.
These distributed nodes, run by individuals and businesses all over the world, provide resiliency to the Ethereum network infrastructure. It is therefore much less vulnerable to hacks or shutdowns. Since its launch in 2015, Ethereum has never suffered downtime. There are thousands of individual nodes running Ethereum network. This makes Ethereum one of the most decentralized cryptocurrencies out there, second only to bitcoin.
WHAT IS GAS?
Gas refers to the unit that measures the amount of computational effort required to execute specific operations on the Ethereum network.
Since each Ethereum transaction requires computational resources to execute, each transaction requires a fee. Gas refers to the fee required to conduct a transaction on Ethereum successfully.
Gas fees are paid in Ethereum's native currency, ether (ETH). Gas prices are denoted in gwei, which itself is a denomination of ETH - each gwei is equal to 0.000000001 ETH (10-9 ETH). For example, instead of saying that your gas costs 0.000000001 ether, you can say your gas costs 1 gwei. The word 'gwei' itself means 'giga-wei', and it is equal to 1,000,000,000 wei. Wei itself (named after Wei Dai, creator of b-money) is the smallest unit of ETH.
PRIOR TO THE LONDON UPGRADE
The way transaction fees on the Ethereum network were calculated changed with the London Upgrade of August 2021. Here is a recap of how things used to work:
Let's say Alice had to pay Bob 1 ETH. In the transaction, the gas limit is 21,000 units, and the gas price is 200 gwei.
Total fee would have been: Gas units (limit) * Gas price per unit
i.e 21,000 * 200 = 4,200,000 gwei
or 0.0042 ETH
AFTER THE LONDON UPGRADE
Let's say Jordan has to pay Taylor 1 ETH. In the transaction, the gas limit is 21,000 units and the base fee is 10 gwei. Jordan includes a tip of 2 gwei.
The total fee would now be: units of gas used * (base fee + priority fee)
where the base fee
is a value set by the protocol and the priority fee
is a value set by the user as a tip to the validator.
i.e 21,000 * (10 + 2) = 252,000 gwei
or 0.000252 ETH.
When Jordan sends the money, 1.000252 ETH will be deducted from Jordan's account. Taylor will be credited 1.0000 ETH. Validator receives the tip of 0.000042 ETH. Base fee of 0.00021 ETH is burned.
Additionally, Jordan can also set a max fee (maxFeePerGas
) for the transaction. The difference between the max fee and the actual fee is refunded to Jordan, i.e. refund = max fee - (base fee + priority fee)
. Jordan can set a maximum amount to pay for the transaction to execute and not worry about overpaying "beyond" the base fee when the transaction is executed.
Block size
Before the London Upgrade, Ethereum had fixed-sized blocks. In times of high network demand, these blocks operated at total capacity. As a result, users often had to wait for high demand to reduce to get included in a block, which led to a poor user experience.
The London Upgrade introduced variable-size blocks to Ethereum. Each block has a target size of 15 million gas, but the size of blocks will increase or decrease in accordance with network demand, up until the block limit of 30 million gas (2x the target block size). The protocol achieves an equilibrium block size of 15 million on average through the process of tâtonnement. This means if the block size is greater than the target block size, the protocol will increase the base fee for the following block. Similarly, the protocol will decrease the base fee if the block size is less than the target block size. The amount by which the base fee is adjusted is proportional to how far the current block size is from the target. More on blocks.
Base fee
Every block has a base fee which acts as a reserve price. To be eligible for inclusion in a block the offered price per gas must at least equal the base fee. The base fee is calculated independently of the current block and is instead determined by the blocks before it - making transaction fees more predictable for users. When the block is mined this base fee is "burned", removing it from circulation.
The base fee is calculated by a formula that compares the size of the previous block (the amount of gas used for all the transactions) with the target size. The base fee will increase by a maximum of 12.5% per block if the target block size is exceeded. This exponential growth makes it economically non-viable for block size to remain high indefinitely[2].
