Ethereum is a distributed computer composed of a large number of distributed nodes, where each node can execute bytecode (the so-called smart contracts) and store the results on the blockchain. The entire network is distributed, applications can save state information, and with state information, applications can provide rich and varied services. Ethereum has no centralized nodes - third parties cannot interfere with the entire network’s operation. It can be considered a world computer that never stops running.

1. Ethereum - The World Computer

picture 35

The image above describes Ethereum’s functionality. It places a virtual computer on the blockchain. The colored blocks in the image are blocks connected by hash values. Each block contains a list of transactions, which are executed in the computer and cause changes to the computer’s state.

In Ethereum, this virtual computer’s state is called the “World State,” which can be considered the storage area of the “World Computer.” The World State constantly changes by executing transactions in Ethereum blocks. Each time a block is added to the chain’s tail, it causes the world’s state to change. The World State is independently maintained by each node in the database.

  1. From this perspective, this state management method is similar to Git - each block is a new version. Each block can obtain the current state of all accounts. The last block represents the current state of all accounts in the system.
  2. The World Computer runs on every Ethereum node, and the World State is the same on every node. Code triggered by transactions runs once on all nodes’ virtual machines.

2. Accounts

picture 27

The World State consists of the states of all accounts. There are two types of accounts: Externally Owned Accounts (EOA) and Contract Accounts. Account properties include balance, nonce, code, and storage. Only contract accounts have code and storage. Externally owned accounts are controlled by private keys, while contract accounts are controlled by contract code.

Every internal account has its own independent storage area. Once smart contract code is deployed on Ethereum, it cannot be upgraded or modified. The codeHash ensures the code cannot be modified.

The image above shows only two accounts, but there are many accounts in the actual World State.

3. Transactions

Transactions in Ethereum are initiated by network users. There are two types: regular message calls and creating internal accounts (which generates a new address and initializes a smart contract).

picture 28

The image above shows that after transaction execution, there’s a new internal account in the World State.

4. EVM - Virtual Machine

picture 30

As the World Computer, there’s not only storage but also a virtual machine for executing smart contract code, called the EVM. Contract code executes in the EVM and can cause changes to storage (World State).

Smart contract development uses high-level languages, which are compiled into binary code that the EVM can recognize when deploying to Ethereum. Once a contract is deployed, it needs to execute on all nodes that maintain the World State. Note: it’s not executed on just one node - when there are contract-related operations in the transaction list, the corresponding code for those operations must execute on all nodes. Ethereum nodes update the World State by executing contract-related code.

Using the World Computer is chargeable - each execution requires an advance fee (called gas), which is continuously deducted during execution. Once the advance fee is exhausted, instructions can no longer be executed, and the smart contract call fails. This mechanism also enhances system reliability. If there’s a bug in a smart contract - like writing an infinite loop - it can at least stop due to running out of fees.