Sep 18, 2023 by Arnaud Stoz | 287 views
If you have already looked at blockchain technology, you might have noticed that two different names are often opposed:
Even though those two blockchain implementations and visions rely on the same idea at the very beginning (distributed ledger and removing any central authority), they are technically very different.
The most obvious differences between these two are the following:
This blog post will focus on ethereum. If you are completely new to the blockchain world and concept, feel free to have a look at this other blog post to have a quick introduction.
From a computer science perspective, Ethereum is a deterministic state machine, consisting of a globally accessible singleton state and a virtual machine that applies changes to that state..
From a more practical perspective, Ethereum is an open-source, globally decentralized computing infrastructure that execute program called smart contracts. It relies on blockchain to synchronize, store and secure the system's state changes.
There is three big part for understanding Ethereum:
If all of this sounds a bit obscure to you, let's deep dive into how Ethereum works.
As it can be seen in the diagram above there is two main parts in a block in Ethereum:
The header contain a lot of information. We will not focus on every attributes present in the header, the interested reader can have a look at the Ethereum yellow paper .
Fields we will focus on are:
The body contains two part:
As seen in the previous section, Ethereum maintain in each block, three differents hash states:
All those state rely on a special data structure called Merkle (Patricia) tree.
As you have seen in the previous section, there is three hashes included in the block header (stateRoot, transactionsRoot and receiptsRoot). Actually those hash are the root node of a so called Merkle (Patricia) tree.
A Merkle tree is a specific data structure characterized by its balanced binary tree structure, where the leaf nodes contain actual data, and each higher-level node represents the hash of its two child nodes
This is a very convenient structure as if one data (leaf) changes, it will have an impact directly on the root hash. This allows to very quickly check if all the data are the same or if a change happened. This will be used later when explaining how Ethereum propagate blocks and check their validity.
Merkle trees are used for both transactions and receipts as those two are immutable and belong to only on block.
Those merkle tree are not stored on the blockchain, only their root hash are stored. All node keep a local copy of those Merkle tree and compute them locally
As said previously Ethereum, unlike Bitcoin, gives the possibility to store and execute code on the blockchain. This is what we call smart contract.
Smart contract are code written by a human in a specific language (solidity, vyper,....) compiled to be run by the Ethereum Virtual Machine (EVM). The EVM can be seen a bit like the JVM. It defines a set of opcode and specific operation to be completely agnostic of the underlying OS/Hardware, this is the runtime environment for smart contract. This allows for a high portability of smart contract.
Even if Ethereum is often referred as a world computer this term is a bit misleading. Once a compiled contract stored on the blockchain needs to be run, it is actually run by a physical node using the EVM.
Now that main characteristics of Ethereum has been explained let's see in practice how this works
The flow is as follows (see picture):
- For simplicity, only three node are shown. In practice there is 128 attestator and at least attestations from 2/3rd of attestators are required to be finalized and added to the blockchain.
- For simplicity, a transaction from human to human (Externally Owned Account (EOA) to EOA) was shown. When sending a transaction to a contract (calling the contract) the idea is more or less the same except the transaction body differ a bit and each node need to execute the contract to calculate the output.
You have now seen all major building blocks composing Ethereum. In the futur post we will focus on smart contract and more specially on smart contract security.
This blog post is licensed under CC BY-SA 4.0