Blockchain 104 (State Machines)

January 1, 0001

Problem

The distributed network of machines that I use is limited to sending financial transactions. I want to perform other actions with minimized trust.

Solution

virtual machine

State Machines

The modern concept of a blockchain is to exist as a globally replicated state machine. What this means is blockchains have been designed to run as a single machine where every user action (transaction) is interpreted relative to the state. The term ‘virtual machine (VM)’ refers to running this machine inside another, the same way one could run the Mac OS on a Windows computer using a VM. In the VM, each action is known as a state transition, and these actions can actually be bundled into one large state transition, where all the changes are passed into the state transition function to generate the new state.

This bundle of state transitions is known as a block, and the process described above is how a blockchain operates. A mempool (memory pool) of all pending transactions is made globally available. It is from this pool that block proposers choose transactions to compile into a block, before broadcasting their block proposal to the network. After it is broadcast, block validators (recordkeepers) validate that the proposed state transition lines up with their view of the history of all previous transactions. Once a certain number of validators agree to add the block, consensus is satisfied and that block becomes finalized - known as time-to-finality.

Different blockchains have different consensus designs to determine how they recognize this agreement on the global state of the chain. Clients (computer programs) are designed to run to allow anyone to create a transaction that gets added to the network, or to validate other blocks of transactions. Validators are incentivized by network rewards, where they are paid to help validate blocks of new transactions. This is commonly referred to as mining.

However, this globally replicated state machine design has its limitations. It is expensive to scale, because it takes time to calculate state transitions, add them to a block, have validators vote on the block, and pay validators for their work. It is difficult to decentralize, because validators must be dispersed and kept from colluding. It is slow to adapt, because all of the permitted actions for the VM must be carefully vetted, and changing them poses security risks. It is not flexible, because applications must conform to the rules of the VM, cannot create their own standards, and are subject to the environment imposed on them by the rest of the network (including congestion and instability). For this reason, new philosophies and technologies around modularity and sovereign chains have emerged in the past 5 years.

The EVM

At a very high level, the EVM is built with a specific set of actions (operations) that can be provided as input to give some output. Like with other machines, this set of operations forms a language, which when expressed, is called opcode - in the case of the EVM, the opcode is called ‘Yul’ [16]. For example, in Yul one can input the ADD operation with a pair of integers and expect the sum as an integer output. Combining many of these operations can yield unique and complex programs; such is the basis of computer languages. Abstraction is used to simplify the experience for developers who want to write applications - Solidity is abstracted Yul. In other words, Solidity is a high-level language that’s easy to write code in and compiles to Yul, so that the EVM can interpret it. Smart contracts are code written for the EVM to interpret, and they represent applications that are posted to the Ethereum network for anyone else to interact with. When a user interacts with one of these smart contracts, such as transacting on Uniswap, that action is represented using calldata: a set of bytes that encodes the call to the smart contract. In order to incentivize validators appropriately, users must pay ‘gas’ fees to submit transactions to the network. Any gas fee for a given transaction consists of a fixed fee and a variable fee calculated based on the burden to the network - writing to storage costs the most because of the expense validators carry to preserve a larger history for the rest of time. There are, however, plans to change this.

Modularity & Sovereignty

Modularity, made popular in large part by Celestia, is the concept of breaking out the core functions of a blockchain into different pieces. Like in other tech stacks, doing so gives applications more refined control, and helps locate bottlenecks to create a more performant system. One function that is especially tedious and costly is the validation of blocks - a modular approach introduces new ways to break out this process of waiting for a network of validators to vote on blocks from the execution of transactions that are to be appended within each block.

Sovereign chains propose that for some set of applications and networks, it is useful to organize actions not in part of a global state machine, but in a separate, local state machine. This local machine can be customized, and doesn’t have to have anything to do with other state machines should it choose to act on its own. With this approach, a sovereign chain can choose to elect its own validators, and have smaller block sizes for faster transaction speeds. By forfeiting the decentralization of a set of tested network validators, it is easier to address scalability and configurability. As one might notice, there are overlaps between the concepts of modularity and sovereign chains.

Due to these trends and an increasing focus on scaling, the last several years have been dominated by promise of Layer 2’s, also known as rollups. Specifically, Ethereum has mapped out a vision for a rollup-centric future, whereby applications can achieve optimized speed and reduced cost by deploying on a ‘rollup’. The term rollup is used to describe rolling up many transactions and compressing them to store them more efficiently on a blockchain. To understand why this is useful for Ethereum, it’s helpful to understand how EVM (Ethereum Virtual Machine) is designed.