Somnia’s New Multistream Consensus: Explained

08 Nov 2024

Introducing Somnia’s Multistream Consensus

Multistream Consensus is one of the key innovations that helps Somnia achieve speeds of up to 400K transactions-per-second with sub-second finality and sub-cent fees. This model is designed to overcome limitations that have been preventing mass-consumer blockchain applications from scaling in Web3.

What is Multistream Consensus?

On the Somnia network, each validator operates its own independent blockchain, called a “data chain.” This innovation was inspired by the 2024 whitepaper “Autobahn: Seamless high speed BFT”. In this design, each validator is responsible for adding data to its own chain without needing consensus checks at the individual level. Instead of a universal chain, these individual data chains function separately, while a “consensus chain” brings them together. This approach allows the Somnia network to process large amounts of data quickly and affordably.

Each consensus block captures the most recent data from every data chain, allowing the system to build a unified view without requiring every validator to check each transaction. This efficient structure allows Somnia to handle heavy data loads and keep all transactions in sync across the network without sacrificing performance.

Sequential Execution and The Problem with Parallel Approaches

Many blockchains have attempted to scale by processing multiple transactions in parallel. While this can work well for unrelated transactions, it falls short during high-traffic periods, especially when many transactions interact with the same contract. This happens often, because as we mentioned in our article on compression, blockchain transactions follow a power law, where a few contracts and accounts make up a majority of the transactions. Popular NFT mints and times of heavy trading on parallel blockchains will still cause the same congestion problems that exist on conventional blockchains.  

Sequential Execution, on the other hand, processes transactions one at a time on a single core, avoiding the congestion that occurs when multiple threads attempt to access the same data. This model is often also called “Single Threaded Execution.” Somnia’s Multistream Consensus enables accelerated sequential execution, which simply means that the transactions happen in the order they occur. This approach creates congestion problems in most conventional blockchains, but with Somnia’s performance capabilities, it is now possible to run the transactions in order because they are moving so fast.

Optimizing EVM with Custom Compilation

Somnia is an EVM compatible chain, which means that it is compatible with the Ethereum Virtual Machine, but instead of just forking the EVM bytecode like most blockchains do, Somnia compiles it into native code that can be executed directly by the CPU. This compilation reduces redundant operations and allows Somnia to achieve near-native speeds, meaning speeds close to what would be possible if the code were written by hand in a language like C++.

Hardware-Level Parallelism for Speed

Somnia also takes advantage of hardware-level parallelism available in modern CPUs. This is different from software-level parallelism, where transactions are run on separate cores. Instead, hardware-level parallelism allows a single CPU core to execute multiple instructions simultaneously by leveraging out-of-order execution and other advanced CPU features.

For example, during an ERC-20 token transfer, the CPU can work on hashing and balance lookups concurrently, rather than sequentially. This means that certain operations can overlap, significantly reducing the overall execution time. By compiling EVM bytecode to native code, Somnia enables the CPU to fully utilize this hardware-level parallelism, resulting in faster transaction execution even during load spikes.

Somnia’s Innovations

Multistream Consensus is the star of the show, but there are actually a few key innovations that work in tandem to make Somnia’s unprecedented performance possible. The Multistream model enables streaming compression, and also has the support of a custom database called IceDB. To learn more about the technical innovations behind the Somnia blockchain, read our litepaper and let us know what you think through our community channels. If you’re a developer, check out our developer page for whitelisting and grant information. 

Stay updated with Somnia

TwitterDiscordTelegramRedditLightpaperOnePager