How Sei Became the Fastest Blockchain: Twin Turbo Consensus

How Sei Became the Fastest Blockchain: Twin Turbo Consensus

Breaking down Sei’s Twin-Turbo Consensus

It is often said that Sei is the fastest blockchain. But what does this mean, and how did Sei Labs achieve it?

In this post, we peel back the layers of Sei’s "Twin-Turbo consensus" mechanism that made Sei the fastest chain to finality, at under 400 ms. This is a key design choice that ensures that Sei can approach “web 2 like'' user experiences, which have so far been difficult for existing blockchains to achieve. 

Identifying the Most Impactful Optimizations

In the journey to build the fastest blockchain, there are numerous optimisations that are possible to make.

Consider that on most blockchains, the slowest part of the lifecycle of a transaction is determined by the “time to finality”, in other words, the time taken for the globally distributed set of validators to reach consensus. Therefore, this is where Sei Labs identified the largest improvements and efficiency gains can be made.

Attestation and Block Building take up the Vast Majority of time in the lifecycle of a tx

In reality the lifecycle of a transaction is more complex, however we can see that the most significant time is taken by consensus. The complexity of it comes down to a few portions: 

1. Transaction Creation / Submission (negligible time)

2. Mempool (1-N seconds, highly variable)

3. Block Proposal (negligible time)

4. Attestation and Block Building (~12 seconds)

5. Block Finalization (minutes to hours)

The fourth step here is the main focus of this blog post - consensus. On Ethereum, the process of validators attesting and building out a block takes 12 seconds in total. 

In the case of Sei, Sei Labs opted for a different consensus mechanism to Ethereum, known as “tendermint consensus”, which has a 6 second block time.

Tendermint offers a unique feature known as “single slot finality”, which means that once a block is added to the chain, it's immediately final. This means that pont 5 above is negated entirely, as block finalization is instant.

This was the starting point to begin optimizing for the fastest time to finality possible; Sei Labs underwent rigorous performance testing to understand the bottlenecks, and was able to push Tendermint to its limits. 

Through the improvements introduced by Twin Turbo consensus, Sei Labs had taken Tendermint’s 6 second blocktimes to <400 ms, with single slot finality. Considering that Ethereum takes one to two epochs to reach finality aka 13 minutes, that is over 2000x faster.

The net result of this optimization is unlocking “web-2” like speeds, with a globally distributed network of nodes.

Sei’s time to finality speed of <400 ms was mentioned in a recent blog: Sei V2 - The First Parallelized EVM. Every contract and application on Sei will benefit from this. 

What’s Twin-Turbo Consensus?

In a nutshell, Twin-Turbo Consensus is the optimization of block propagation and block processing to help create the fastest chain in production today.

Time to Finality of Sei, Ethereum, Ethereum Layer 2s and Solana

Time to Finality (TTF) is the time it takes for a transaction to be completed and considered irreversible. Sei's Twin-Turbo consensus drastically reduces TTF to milliseconds, which means your transactions on the blockchain are almost instant (<400 ms). 

Sei’s transaction finalization is comparable with the immediate response you would experience when playing a song on Spotify - there's no waiting, just immediate action upon clicking ‘play’.

The consensus mechanism designed delivers the immediacy you would experience from web-2 applications, where actions are instant and seamless. This approach addresses the common problem that still exists in blockchains today - too slow for everyday on-chain usage. 

The two key optimizations made towards Tendermint are known as “optimistic block processing” and “intelligent block propagation”. 

Both of them add up to produce the ultimate result Sei presents today - transaction processing that takes just milliseconds during consensus. 

Technical Deep Dive into Twin-Turbo Consensus

Before getting into the optimizations made, let’s unpack Tendermint’s underlying technology first.

Under the hood, a block proposer first creates a block with all the transactions in it. A block proposal containing the block’s hash will then be created and distributed across the global network of validators. 

Upon receiving the block proposal, validators must wait to receive the complete block with all key information needed to verify its contents, then only be able to proceed with consensus before committing the block to the blockchain. 

However, when a full node receives a transaction, it gets broadcasted to other nodes in the network. This leads to redundant data transmission and increased waiting time, as 99.99% of the time, validators already have all transactions required in their mempools to form a block locally. 

With the basics of Tendermint understood, let’s get into the optimizations made to the Tendermint consensus algorithm:

Optimization 1: Intelligent Block Propagation

Block proposals with transaction identifiers

The first potential optimization identified with Tendermint was this “unnecessary wait time”. Sei flips this on its head with its block propagation technique: instead of initially sending out the entire block to other validators of the network, block proposers will send a compact block proposal (as a single message) containing unique transaction identifiers, together with a reference to the full block. 

Proposers will first disseminate the proposal to the validators, followed by the entire block containing the full contents of each transaction. The block will then be broken into smaller parts and randomly gossiped to the other validators. 

If a validator already has all the necessary transactions, it can immediately reconstruct the full block locally without waiting for individual block parts to be sent across the network. If not, it will wait until it has the complete content of the block then reconstruct it with all of its transactions. 

This process is known as “intelligent block propagation”, an optimization that significantly reduces the time validators would spend waiting for data to form a block, thereby enhancing the network's throughput and reducing latency. 


Optimization 2: Optimistic Block Processing

A second potential optimization was identified in the overall consensus steps taken in tendermint. The idea here was to modify the overall process so that consensus steps can happen simultaneously; saving significant time.

Block processing with example times. Left: Block processing after precommit; Right: Optimistic block processing

After block proposal, prevote and precommit are crucial steps that traditionally must happen before block processing and committing takes place. This is because the block might potentially be rejected by validators if it doesn’t comply with the consensus rules, or in other words fail block validation. 

Byzantine nodes may also exist in the network - if a sufficient number of validators act differently and broadcast an invalid or conflicting block, the block could be rejected if detected by honest validators. 

Although it doesn’t happen often, these are crucial precautionary steps that must be taken. 

Optimistic block processing dovetails with intelligent block propagation to expedite consensus further:

It takes the first block at any given height where the validator would receive it, run sanity checks and start processing it simultaneously during prevote and precommit. The optimistic block processing will then write the candidate state to a cache. 

This allows validators to process transactions optimistically as soon as they receive a valid block proposal, rather than waiting until the precommit step ends. The logic behind adopting this approach is that in most cases, the first proposed block at any given height is the one that gets accepted after voting. Therefore, initiating the processing of transactions from the first block right away capitalizes on this likelihood. 

Should the block be accepted, the candidate state cache processed optimistically will be committed to the blockchain instantaneously. 

However if the block gets rejected, then the data from the cache will be discarded, and future rounds of that block height will not use optimistic block processing. The validator will then reset and prepare to process the next block proposal. 

This concept leverages the typically predictable behavior of block acceptance in order to significantly speed up transaction processing time, while countering the potential rejection a block might face, underscoring Sei Labs’ commitment to high performance.

The theoretical improvement in latency due to optimistic block processing can be described with:

In which Tprevote represents prevote latency, Tprecommit as precommit latency, N as the number of transactions, and T as the average latency of a single transaction. 

This illustrates the potential efficiency gains, significantly reducing overall time to finality, especially in this given case where transaction processing (N * T) is much faster compared to the consensus stages (Tprevote + Tprecommit).

The two pillars crafting the Twin-Turbo consensus mechanism have been pivotal to Sei achieving <400 ms block time that it presents today - the fastest chain to finality in existence.

If you haven’t noticed already, every millisecond matters for Sei

The specifics of the optimistic block processing proposal in August 2022 can be found here

Trade-Offs

With Sei achieving these rapid times to finality, it may seem like a no-brainer to implement these same enhancements on other blockchains. However, it’s important to acknowledge tradeoffs do exist to achieve this web2-like user experience:

Quadratic Communication Complexity

We mentioned that tendermint ensures rapid finality, which accelerates the “decision making” process within the network. However, it also establishes a key communication pattern where each validator has to communicate with every other validator to reach consensus. The trade-off here is quadratic communication complexity, which means the number of messages grows significantly as more validators join the network. 

This makes it more difficult to increase the number of nodes in the network than usual, since a much larger set of validators will result in increased bandwidth and processing requirements. While the existing validator set will continue to grow at a steady pace, with nodes already distributed across multiple continents, Sei plans to further address this issue through its decentralization efforts covered in its roadmap, aiming to maintain network performance with the globally distributed set of validators alongside light clients for trustless verification. Despite this trade-off, the mechanism's benefit of much faster finality remains a substantial advantage for network efficiency, which Sei Labs believes is important to deliver the best possible user experiences.

Conclusion

Sei's Twin-Turbo consensus represents great enhancement in blockchain technology, pushing the boundaries of finality speed to deliver the user experience that is unparalleled today. 

By reducing TTF to <400ms, Sei has set a new standard in transaction processing speed, making it the fastest blockchain to finality currently available. 

Both TTC’s concepts enhance the well understood and proven tendermint consensus mechanism used by all cosmos blockchains today; where the former allows validators to quickly construct blocks from existing mempool transactions, while the latter slashes idle time by enabling immediate transaction processing upon receiving the block proposal’s receipt. 

As Sei continues to evolve, its focus on optimizing every aspect of the blockchain lifecycle, ensures to maintain its lead in providing fast, reliable, and user-friendly blockchain experiences - seamlessly running at an unmatched speed.