Crypto Primitives: Ethereum
From a decentralised computer to the base layer of the "web 3" internet?
The [crypto] room where it happens
Whenever someone is talking about the broader crypto space, chances are that they will mention Ethereum. After all, it is the blockchain every other blockchain is measured against [sometimes even Bitcoin...].
Sounds hyperbolic? Well, do you remember the first time you heard about Ethereum? I suspect it wasn’t just now. It was quite likely in one of these settings:
A Bitcoin maxi showing off that they have heard of other cryptocurrencies too. [before dismissing them all as scams, naturally]
A supporter of a competitor chain, explaining why their pick is better than Ethereum. [which is why they sold all their ETH tokens, obvious trade really]
A non-crypto person complaining about NFTs. [they showed you how to right-click-save that overpriced ape picture, didn't they?]
Someone baffled by the latest multi-million dollar crypto hack. [where does the money these crypto people keep losing come from anyways?!]
It doesn’t really matter if your first exposure to Ethereum was from a sceptic. The important question is - why is so much attention captured by the second largest cryptocurrency asset? While the largest one, Bitcoin, is left to “reign supreme” in peace, why is almost everyone else coming after Ethereum? [except Dogecoin, Dogecoin is coming after Bitcoin]
Well, because Ethereum has from its very beginning had the status of being an impressively eventful cryptocurrency. It is a blockchain on which multitudes of other applications can be built. These applications and the Ethereum protocol updates needed to support them generate so much activity that there are people running daily podcasts and writing weekly blogs on all the latest developments in the Ethereum ecosystem. This is a financially lucrative position for Ethereum, and many challengers are in close pursuit.
Let’s start our learning journey into the protocol.
So, what is Ethereum?
While Bitcoin is a decentralised database, Ethereum is a decentralised computer. Simply put, it is a global computer that everyone can interact with and build on but no single party is in charge of. Any proposed computations are run on thousands of separate machines who verify their accuracy and validity before another large groups of computers, called miners, is allowed to update the state of the network. As a result of the complexity of maintaining a blockchain which is both decentralised and secure (resistant to attacks), Ethereum can currently only processes around 15 transactions per second [yes, developers are working on improving this].
Does this sounds like the internet? The thing we already have which works just fine? There are some large differences. Imagine an internet where governments can’t take down people’s websites, one where everyone has access to the data behind every application and website [without having to hack into them]. Crucially, imagine an internet where people can take full possession and ownership of all their digital assets and data [money, art, tweets, you name it], instead of having them hosted in password-protected accounts managed by separate companies. This is what Ethereum aspires to be.
If you were a citizen of this world, what could you build in it? A lot of things, actually. You could:
launch your own cryptocurrency [Vaska-coin sounds nice to me]
build an automated token exchange [banking stuff but without the bankers]
create and sell a digital art collection [yes, this is about NFTs]
run a decentralised autonomous organisation [DAO, like a company but weirder]
build a digital game whose assets that are tradable all over the blockchain
In practice, the crypto space is still in its infancy [Ethereum as only founded in 2015!] that the creative possibilities are largely bounded by the scope of people’s imaginations [and network transaction costs]. As a result, a lot of my excitement about Ethereum’s prospects is not really about Ethereum itself. It is about the activities that Ethereum has made possible and will make possible in the future.
How did we get from Bitcoin, which just moves money around, to a platform that hosts decentralised applications and communities worth billions of dollars?
Let’s dig into the technical details [but without the math].
Accounts and Transactions
Unlike Bitcoin, Ethereum has two types of accounts:
One for “normal” users. These are called externally-owned accounts (EOAs) and are managed using their private keys. Similarly to Bitcoin accounts, users can authenticate themselves and authorise various transactions using a “digital signature”. User authentication is verified by a cryptographic algorithm and is performed without the necessity for a third party intermediary
One for computer programmes [AIs are people too!]. This second “class” of accounts, computer programmes, are referred to as smart contracts or contract-owned accounts (COAs).
Both account types can send and receive crypto tokens, and interact with one another. However, a major difference is that smart contracts cannot initiate transactions. All transactions must originate with an externally-owned account (EOA). What does this mean in practice? If a smart contract owes you tokens, you will have to send a transaction to request them from the contract, as it won’t be able to directly send them to you otherwise [unless another user initiates a transaction to do so].
Once a smart contract has been contacted, it can then interact with other contracts in order to execute the instructions it has received from the user (EOA). So, if you deposit your money in a contract whose purpose is to generate the highest returns on your deposit, it can then reach out to other smart contracts to find the best available yield and deposit your money with them.
What types of assets can you exchange directly over the network and via smart contracts?
Popular Token Standards
All accounts keep track of the various crypto tokens they own and the size of their holdings [smart contracts can also store additional programme variables]. Most active accounts will contain Ether (ETH), which is the native currency of Ethereum. It is used to pay protocol transaction fees and reward block miners for their efforts in updating the blockchain. Other tokens are often created based on one of the two major token standards:
ERC-20 is a standard smart contract template that people use when they create crypto tokens on Ethereum. Using the template, anyone can create their own tokens with a given maximum supply and name. Tokens can then be exchanged on the blockchain for various purposes.
ERC-721 is the standard contract template for Non-Fungible Tokens (NFTs). With it, people can generate their own collections of digital art, community membership passes, or other non-fungible assets. Each NFT object has a unique id, but at the same time belongs to a common group of tokens.
Think about the differences in this way - money is fungible, so it doesn’t matter which specific dollar bill you own. Therefore, money-like tokens are represented by the ERC-20 standard. In contrast, each da Vinci painting is unique (non-fungible). So if da Vinci were alive today, he could issue a digital collection of his art as NFTs using the ERC-721 standard.
While these standards were created to make your life easier, you are not obliged to follow them. Anyone can write a smart contract and launch it on the blockchain! Or, much easier, they can customise existing code to better suit their needs.
Crucially, both tokens and NFTs are uniquely identified by the address of the smart contract that issued them [and unique ids within the contract for NFTs], not by their names. This is important, as scammers often issue cryptocurrencies and NFTs with the same names as those of popular projects [stay safe pls].
Protocol Fees
Basics
Some things in life are free. Connecting your wallet to a blockchain application and proving that you own [control] a given account is achieved via “cryptographic” digital signatures and is free on Ethereum. In contrast, executing transactions on the network is not free, and incurs a fee that all users must pay. Transactions can be transfers of tokens, initialising a smart contract, or running a smart contract function.
While fees are annoying, they are also necessary. First, they help prevent spam by imposing a cost to using the network. Second, they create a quick way to rank transactions for inclusion, as blockchain miners can just pick the higher-paying transactions [which they mostly do, but aren’t forced to do]. In practice, this leads to higher-value transactions being prioritised when the network is busy.
This because users optimise their behaviour. They are willing to pay more in transaction fees if they perceive the value of their transactions to be higher. Otherwise, they can wait out the higher fees and transact when the costs are cheaper. For those with limited resources, “flash loans” allow borrowing without a collateral if the transaction profit can be realised in the same transaction group (block) and the loan can be repaid in full in the same period.
Fee mechanics
Ethereum developers are constantly working hard to improve the protocol. As part of these efforts, in August 2021, the network underwent the “London” upgrade which introduced the EIP-1559 fee market change. Users now pay a “base” fee which is adjusted depending on how "busy” the network is, and a “tip” fee, also called “priority fee”, which goes to the block miner. Under the current Proof of Work system, Ethereum block miners are responsible for selecting new transactions and including them in the next block, similar to what Bitcoin miners do.
Crucially, the base fee gets “burned” [destroyed], which removes ether from circulation. Does this mean we will eventually run out of Ether? Unlikely! In addition to the “tip” fees, miners also receive newly issued ETH as a reward for creating new blocks. In periods of high network usage, when burned ETH is higher than newly issued ETH, the net impact on the circulating ETH supply can be negative, making ether deflationary [yes, this has important implications for ETH investors]. But in other periods it remains an inflationary asset.
Crucially, the base and tip fees are paid per unit of computing power used. But, we don’t really know how much computing power will be used by a given smart contract, so ethereum developers have come up with a list of costs for different computations (addition, subtraction, etc.) to proxy for these costs. When a mismatch between estimated and real usage costs is discovered, the costs are updated to be more precise. All transactions use a minimum of 21,000 “gas” [gwei, 1 gwei = 0.000000001 ETH]. This is also the gas cost of a simple ETH transfer [“gas” was perhaps an unfortunate name choice, but here we are].
If you are starting to develop a headache, consider that without a complexity adjustment, a user could write an infinite loop in a contract and bring Ethereum to a halt as the network computers (nodes and miners) keep executing it. Since Ethereum charges for computational costs, such a user would eventually run out of money to pay the gas cost needed to keep running the contract, their transaction would fail, and Ethereum would keep running.
So we need this stuff [or a form of it]! Bitcoin doesn't have such concerns as all bitcoin users can do is move money around [which is still revolutionary as it is done without an intermediary party].
Calculation
The formula for the total transaction fee that a user pays is:
Total Fee Paid = gas used * (base fee + tip fee)
Users cannot control the base fee that they are charged, as this depends on how busy the network is. But they do set the tip that they wish to give to the miner as well as the maximum amount of gas that they are willing to use to execute a transaction. If they reach their gas limit and the transaction hasn’t finished executing, it gets cancelled but they are still charged for the gas fee used until that moment [ouch].
Users also have the option to set a maximum fee (“base + tip”) that they are willing to pay. What happens if the maximum fee ends up being lower than the base + tip fees? Well, the tip fee is in fact a “maximum” tip fee, so it can be reduced to accommodate the maximum fee. However, if other users are offering higher tips than you, the transaction may not be included in the current block and could get waitlisted. But what if the maximum fee ends up being lower than even the base fee? Well, then you are out of luck and your transaction will be pending until the base fee goes down sufficiently.
In practice, your crypto wallet will suggest a maximum fee which should avoid such delays but if you do end up stuck in “fee limbo” there are also ways to override the transactions with one that has higher limits.
Maximal Extractable Value (MEV)
Does this sound complicated? Well, it is! In fact, there are people making money from including, excluding and rearranging pending transactions on the Ethereum blockchain. Common use cases are DEX (Decentralised Exchange) arbitrages, where an algorithm buys tokens cheaply on one exchange and sells them on another exchange for a higher price. In the NFT space, users mistakenly listing their digital collectibles for a low price have had them snapped within seconds by a bot who will then put them on sale for a wiser price [yes, this has happened to a bored ape NFT].
The profits of these agents are referred to as MEV, which stands for Maximal Extractable Value, but are sometimes also referred to as Miner Extractable Value. In practice, the MEV is split between the block miners and MEV coders. The coders create algorithms to spot profitable transaction opportunities. But they then need to give some of the profit back to the block miners as a bribe to include their transactions before those of other MEV participants who have spotted the same opportunity, or before any transaction that they are attempting to front-run.
This is a big industry! Flashbots estimate that since 2020 there has been over USD 600mn in MEV extracted from Ethereum users. It is a dog eat dog world out there.
The Merge
Recap of Proof of Work
Currently Ethereum is a proof of work (PoW) blockchain. Block miners compete process transactions and update user and smart contract accounts accordingly. The miner who wins the contest is the one who first successfully solves a cryptographic puzzle by brute force. The more computing power (energy) a miner extends towards solving the puzzle the more likely they are to win the competition.
In addition the the transaction fee tips that they receive from users, the successful miner also gets rewarded with newly issued ether by the network (2 ETH per block). If there is a tie, the miners choose which competing version of the blockchain to extend and eventually converge on the longest one.
Proof of Stake
Background
Proof of Work is the past and present of Ethereum, but Proof of Stake (PoS) is its future. During the Merge, Ethereum will transition from a PoW blockchain to a PoS one. This transition is called the Merge as it represents the point where the last proof-of-work block will be mined and the consensus mechanism will be handed over to the Proof of Stake “beacon chain”. From then onwards, the Ethereum validators will (ideally) seamlessly continue updating the blockchain.
Sounds tricky? It certainly is. Imagine a car changing its wheels mid-drive! Ethereum has had plans to transition to PoS since its very formation, but this year it is looking like its time has finally come. In preparation for the merge, over 12 million ETH has already been “staked”, which is about 10% of the ETH supply currently in existence! [do not send ETH directly to the staking contract]
Based on recent Merge-related developer calls and pronouncements at conferences, I estimate that the Merge will happen this year, likely in Q3.
Economics
Under PoS, ETH holders can “stake” 32 ETH and become a validator on the network. Validators are then chosen at random to mine the next transaction block and receive ETH from network rewards and user tips. When not chosen to compile the block, validators can get selected to “attest”(confirm) that a proposed block is valid. In that case, they will also receive an ETH reward for helping maintain network security. These are the “carrots” of being a staker. But there are also some “sticks”.
If validators are caught breaking the rules of the blockchain, by mistake or in an attempt to behave fraudulently, their stakes are “slashed” and they lose parts or all of them. Partial slashing also happens if validators are offline for long periods of time. Because of fears of slashing many ethereum stakers do not stake on their own and prefer to use staking providers.
In practice, the PoS system will result in ETH stakers receiving an ETH-denominted yield, similar to an equity investor receiving stock dividends. The more stakers, the lower the yield, as fees and rewards need to be distributed among more parties. In contrast, the fewer stakers the higher the yield each one receives. Since new ETH is being issued, in a way stakers are avoiding having their ETH ownership stakes being diluted [this can raise equity concerns]. In contrast, non-staking ETH holders should ensure the they use their ETH to generate similar or higher profits to those of staking.
Reasons for the transition
What is so special about Proof of Stake [why are we doing this exactly]? Let’s go over the main arguments.
Pros:
PoS has the benefit of being less energy consuming, making Ethereum more ecologically friendly. Instead of extending energy resources to secure the network as in PoW, in PoS, weight is given to the level of ETH ownership. All the energy that a PoW chain extends on randomly selecting the next block miner is eliminated.
PoS should reduce ETH selling pressure, as miners need to finance their energy costs with their ETH rewards, while stakers would only be forced to sell to pay taxes.
PoS makes tracking the blockchain updaters harder. If a governments wanted to round up all PoW miners in an attempt to halt the blockchain, they could search for regions with disproportionately high energy use. But they would not have an obvious way to track PoS validators (as long as they use a VPN).
Cons:
PoS is technologically harder to implement and is less battle-tested than PoW. There are many edge cases to consider, which is why ETH developers have taken years to come up with a robust implementation that will hopefully be free of vulnerabilities and errors. If new issues are discovered, they could delay the Merge.
It is unclear which type of blockchain would best withstand an external attack.
Some argue that to launch an attack on a PoW chain you need to find a spare large energy source, making this unlikely. However, what if you could suddenly take over all the data centres in the world and convert them into blockchain miners for a few hours? Unlikely, but perhaps possible under an extreme situation.
Similarly, a PoS chain can be attacked by a wealthy adversary buying up the network’s native token, staking it and taking over the validation process. However, if their initial attack is unsuccessful their stake would be slashed and they would need to spend even more money to buy tokens to attempt a repeated takeover.
In practice, trying to completely obliterate a blockchain is unprofitable. Once taken-over, the blockchain would lose censorship-resistance, which is its main appeal. Its token price would crash, resulting in a pyrrhic victory for the attacker. So unless you are simply aiming to destroy the entire crypto space, you would not want to attack the most valuable protocols in it. Instead, it is much more profitable to take ever some of the smaller ones and convert their tokens for a valuable non-compromised blockchain token [yes, this can result in protocols to attempting to become too “big to fail”].
My view
By transitioning from PoW to PoS, Ethereum is giving up a valuable connection to the real world that is provided by mining using brute force. It can no longer compete to be a commodity-like asset such as Bitcoin, or attempt to form symbiotic relationships with energy grids. In many ways Bitcoiners should be grateful to Ethereans. In the absence of from Ethereum this narrative use case will be dominated by their blockchain.
Instead, Ethereum is embracing its future as a software-first product, an innovative open-garden app-store, and perhaps the new “settlement layer” of the internet. It will live or die by the success of the applications built in its ecosystem. This may sound like a daunting and uncertain path, because it is [I am scared too]. But it is also one that I hope will provide much-needed clarity and focus for the protocol, and ultimately work to its advantage.
At this point skeptics will invariably object: Oh come on! How big can a decentralised computing platform that only processes 15 TPS (transactions per second) realistically get? Well, let’s talk about that.
Scaling Ethereum
The blockchain trilemma
Unsurprisingly, this is an issue that developers have considered. Ethereum’s scaling issues are a version of the “blockchain trilemma” problem. This is the view that no one blockchain can achieve all three of decentralisation, security and scalability. Instead, they can only achieve two out of the three.
A scalable blockchain is one that can quickly process many transactions. This can be done by expensive specialised computers with high-processing power, but is hard to achieve using the types of hardware normal blockchain users have access to. A decentralised blockchain is one which is not controlled by a small number of agents, on whom we would need to rely to behave honestly. Finally, a secure blockchain is one that cannot be easily attacked and would require over 50% of nodes to turn adversarial before being compromised.
Source: Vitalik
So far, both Bitcoin and Ethereum have optimised for decentralisation and scalability, at the expense of scalability.
Escaping the blockchain trilemma
The plan is for Ethereum to achieve scalability will be achieved using a combination of layer 2s and sharding.
Layer 2s
This is also called the modular blockchain approach. Under this vision, Ethereum is considered a “Layer 1” blockchain, and other blockchain protocols called “Layer 2s” are built on top of it. The majority of transactions in the Ethereum ecosystem will be processed on these layer 2 blockchains which will optimise for transaction volume and/or data storage. They can be implemented in several different manners such as rollups, zero knowledge rollups, validiums, and volitions.
What these all have in common is that they have the ability to process significantly higher transaction volumes than Ethereum but leave minimum footprint on its base layer. This is because layer 2s only post compressed versions of their transaction data to Ethereum, and sometimes even post only “proofs” that they have performed their calculations accurately. In the same way that Ethereum is “outsourcing” scalability to layer 2s, that are “outsourcing” their security to Ethereum.
Multiple layer 2s are already active and scaling up (check out Arbitrum and Optimism). Solutions which will specialise in data storage are also under development. In order to use them, existing Ethereum users need to “bridge” [move] their assets to the layer 2 that they wish to transact on. Centralised exchanges are also working on and have already implemented direct exporting of client assets to popular layer 2s.
Sharding
A second manner in which Ethereum developers plan to scale the blockchain is by implementing sharding. This is a technique to split Ethereum’s processing power by splitting validators into groups that can then process different transactions, effectively allowing Ethereum to execute parallel processing. Deploying sharding will be prioritised after the Merge has been completed.
Expected improvements
How much will these help? Vitalik (the founder of Ethereum) estimates that the combination of layer 2s and sharding can increase TPS to around 100k TPS. For comparison, Polynya [a prominent researcher of blockchain scaling] has estimated that Visa processes around 63k TPS. The future is bright. Long-term, Polynya has suggested that by 2030 Ethereum could achieve up to 50 million TPS (as a highly optimistic upper bound).
So, in conclusion, yes, Ethereans are aware that 15 TPS is not going to cut it in the long run [duh!]. And yes, they are working on massively expanding network processing capacity in a sustainable manner.
To be continued…
I hope this introduction has gotten you all excited about the potential of Ethereum! We will continue our journey in my next blog posts, which [fear not] will be much less technical.
We will go over the main decentralised applications [dapps] which have been built on Ethereum. Most importantly, I will also discuss the potential has Ethereum to reshape the world we live in.
Stay tuned, digital frens.
For the hobbyists
Check out the processing power costs for different computation procedures.
Complete some crypto zombies tutorials on writing smart contracts.
Read more about the different MEV strategies on Ethereum.
Have a look at specific MEV examples on the blockchain.
Critically examine Vitalik’s post in favour of Proof of Stake.
Familiarise yourselves with Polynya’s post on how modular blockchain structures will resemble advances in processing chip design.
Listen to some of the latest updates on the Merge.