Author:DAIC

Compiled by: TechFlow

The Decentralized Finance (DeFi) revolution has ignited a wave of global financial empowerment and disintermediation. However, the promise of instant peer-to-peer transactions is often dragged down by slow blockchains. Imagine waiting for transaction confirmations, or facing painful delays exposed to wild price swings. This is exactly the friction point that Sei is committed to eliminating.

The main points

  • Sei is a L1 blockchain with an architecture optimized for a variety of transaction applications, ensuring optimal performance.

  • The built-in native order matching engine is integrated directly on L1, enabling seamless order execution and excellent scalability for trading applications.

  • Sei’s Twin Turbo consensus mechanism achieves sub-second finality, providing almost instant transaction confirmation.

  • Sei adopts a market-based parallel approach, which is particularly suitable for high-frequency trading needs.

  • By batching orders, Sei prevents front-running behavior that can be exploited by malicious bots.

  • Sei V2 upgrade - parallel EVM, Optimistic parallelization and SeiDB.

Sei Overview

There are significant obstacles to the current mainstream blockchain that serves as the foundation for many crypto projects. The Sei Labs team believes that existing infrastructure cannot keep up with the demand for decentralized exchanges (DEX). They often have limits on throughput (the number of transactions processed per second) and final confirmation time (the time it takes for a transaction to be considered complete and irreversible). This results in slow performance and is a major impediment to high-frequency trading strategies and large-volume trading activities.

Sei aims to break this barrier by carefully optimizing each layer of the blockchain stack to specifically meet transaction needs. The team offers a clear value proposition: no matter what kind of transaction application - whether it is DeFi, NFT market or game - it will run smoother and faster on Sei than on any other L1 network.

With this innovative solution, Sei is positioning itself as the ultimate game-changer in the DeFi space, with the goal of becoming the infrastructure provider of choice for exchanges seeking a platform designed for the world of fast digital asset trading.

Leveraging the interoperable Cosmos SDK framework, Sei has a dedicated L1 blockchain equipped with a suite of synergistic features to enhance the transaction experience.

Its local order matching engine simplifies trading operations by eliminating external dependencies, while the innovative Twin Turbo consensus mechanism provides sub-second finality for near-instant transaction confirmation. Security and developer experience are always top priority, with features such as front-running prevention and local price Oracle, ensuring a robust and user-friendly environment.

Let’s take a deeper look at the key features that position it as the “turbo engine” of DeFi transactions.

Twin-Turbo Method

Sei relies on a Proof-of-Stake (PoS) protocol based on a modified version of the Tendermint consensus mechanism, called the Twin-Turbo consensus.

Validators play a vital role in processing transactions and confirming changes in the network state. These validators are selected based on their total stake (including self-bonded and delegated SEI tokens). Currently, only the top 39 validators by total stake participate in the consensus process and earn transaction fees and staking rewards.

SEI token holders can choose to delegate their SEI tokens to existing validators to contribute to network security. Delegators will also receive a portion of the validator's SEI rewards after deducting the commission rate selected by the validator.

When it comes to consensus, Tendermint provides a solid foundation, ensuring that transactions are finalized and irreversible once added to the blockchain (single-slot finality). However, its base block time of 6 seconds is not suitable for Sei’s vision of high-speed transactions.

Through the improvements introduced by Twin Turbo consensus, Sei Labs reduced Tendermint’s 6-second block time to less than 400 milliseconds, achieving single-slot finality.

This result is achieved through two key optimizations to Tendermint, called “smart block propagation” and “optimistic block processing”. Together, they lead to the end result Sei presented today: transaction processing during consensus takes only milliseconds.

The smart block propagation mechanism differs from the traditional block method of transmitting complete transaction details. Instead, the block proposer initiates the process by sending a proposal containing a unique identifier and hash of each transaction.

Considering that validators usually have recent transactions in their local memory pool, they can reconstruct complete blocks, avoid unnecessary bandwidth consumption and reduce waiting time for retrieving redundant data. This optimization promotes overall network efficiency, which ultimately translates into faster transaction processing speeds for users.

Optimistic block processing further speeds up transaction processing by bypassing "pre-voting" and "pre-commit" rounds. The goal is to simplify the process by allowing the consensus steps to occur simultaneously, thereby saving significant time. This approach results in faster block verification and voting, in contrast to the sequential processing common on other blockchains.

Through the synergy between Optimistic block processing and Smart block propagation, the consensus mechanism moves forward with amazing efficiency.

After receiving an initial block proposal for a given height, the system runs a plausibility check and processes it during both "pre-voting" and "pre-committing". Optimistic block processing writes the candidate state to the cache.

This innovative approach enables validators to optimistically process transactions when they receive valid block proposals, bypassing the delay of waiting for the "pre-commit" phase to end. The logic behind this strategy is the observation that in most cases, the first proposed block at a certain height wins after voting. Therefore, starting transaction processing from the beginning maximizes this trend.

If a block is accepted, the Optimistically processed candidate state cache is seamlessly integrated into the blockchain. Conversely, if a block is rejected, the cached data will be discarded and subsequent rounds of the same block height will avoid Optimistic block processing. The validator resets its position and prepares to process the next block proposal. This concept cleverly leverages the predictability of block acceptance to significantly increase transaction processing speed while reducing the risk of block rejection, which means a significant increase in throughput compared to traditional solutions.

This provides traders with a smoother user experience, minimizes confirmation times and reduces market maker risk, two major pain points in the current DeFi ecosystem.

Parallelization

On chains like Sei, running on the Cosmos SDK, validators follow a structured three-step process after receiving a block: “BeginBlock”, “DeliverTx”, and “EndBlock”. Sei customizes the latter two steps to introduce parallel processing.

Traditionally, transactions in the DeliverTx phase are processed sequentially. However, Sei modified this approach to allow for simultaneous processing, using the concept of a directed acyclic graph to manage transaction order and avoid conflicts.

In addition, Sei processes order execution in parallel at the end of a block, especially for independent orders related to its local order matching engine. These orders are considered independent if they involve different markets within the same block, and developers can define market dependencies.

Sei’s native order matching engine allows decentralized exchanges to create their own order books. We will look at this in more detail below.

The Hidden Costs of Tendermint

While Sei leverages a modified version of Tendermint consensus, known for its fast block finality, it comes with a hidden cost: quadratic communication complexity. This principle states that the number of messages required to communicate between validators grows quadratically with the number of validators in the network.

Think of a conference call — small groups communicate smoothly. But as the number of participants increases, managing the conversation becomes much more complex. Similarly, in a blockchain using Tendermint, a surge in message traffic caused by a growth in the validator set can put a strain on network bandwidth and validator processing power. This can hinder scalability, making it difficult to add many validators without affecting performance.

As the current validator set steadily expands, Sei is committed to addressing this challenge head-on by strengthening decentralization initiatives. The goal is to maintain network performance by cultivating a globally distributed network of validators, supplemented by light clients for trustless verification.

Order matching engine

Sei integrates an order matching engine at the chain level, enabling developers to create order book based exchanges on the Sei blockchain.

This feature supports the development of a central limit order book (CLOB) system, commonly used in traditional centralized trading platforms. Sei also supports automated market maker (AMM) systems commonly used in decentralized exchanges (DEX).

working principle

All transactions involving the matching engine will be executed atomically within the scope of a block. These transactions are directed to the DEX module, and each transaction may contain multiple orders. After submission, the transaction handler adds the orders of each transaction to the internal MemState of the DEX module. During block processing, the EndBlocker hook of the DEX module batches and merges the orders recorded in the MemState. This merger aggregates orders by market (for example, orders for all BTC perpetual contracts) into a single smart contract call.

Transaction order packaging

Sei introduces multi-layer order bundling to improve user experience and optimize performance:

  • Customer Order Packaging: Sei allows transactions that contain multiple exchange market orders, including orders across smart contracts (e.g., orders for the BTC/USDC spot pair and the BTC perpetual contract). During block processing, Sei accurately directs orders to their respective smart contracts, helping market makers minimize gas fees associated with position updates.

  • Chain-level order packaging: Rather than instantiating a virtual machine (VM) separately for each matching engine-related trade, Sei aggregates orders (by market) across all trades and launches only one VM instantiation. This significantly reduces order latency by approximately 1 millisecond, especially during high throughput periods.

Hook Integration

Sei allows contracts to set up "hooks" in the network. These registered hooks are triggered once per block, facilitating actions such as flash loan repayments to take place within the same block as trade settlements. Contracts can define two types of hooks: one that executes at the beginning of a block to prepare for possible trades, and another that executes at the end of a block, after orders are matched and settled, allowing the contract to perform any necessary post-trade logic.

Asset agnostic

Instead of trading tokens directly, the matching engine provides a diverse interface that allows decentralized exchanges to decide how to represent assets. For example, a decentralized exchange may choose to track positions in its smart contract state rather than tokenizing them.

Frequent batch auctions

Sei introduced a method called “Frequent Batch Auctions” to combat a phenomenon called “MEV” (Maximum Extractable Value) and ensure fair market conditions. MEV occurs when validators prioritize their own transactions to maximize profits, potentially at the expense of other participants.

To mitigate this problem, Sei consolidates all market orders and executes them at a consistent settlement price. For example, if there are two sell orders (ask) at prices P1 and P2, and two buy orders (bid), Sei calculates a unified settlement price - simply taking the average of P1 and P2. Both buy orders are then executed at this unified settlement price.

By avoiding a single transaction order, Sei eliminates the incentive for validators to manipulate transaction order for personal gain, thus creating a fairer trading environment.

Price Oracle

To facilitate asset pricing, Sei implements a local price oracle. Validators act as oracles, ensuring the reliability and accuracy of asset pricing. To keep oracle pricing fresh, the voting window can be as short as one block, allowing for rapid updates of current asset prices.

During the voting step within the voting window, validators propose exchange rates. At the end of the voting period, all exchange rate votes are aggregated and a weighted median is calculated by validator vote weight to determine the exact exchange rate for each asset. Validators who do not participate and provide inaccurate data will be penalized.

Validators have a lapse count that tracks instances where they fail to provide data or provide data that deviates significantly from the weighted median. If a validator's error count exceeds a certain threshold within a designated voting period, they will be subject to a reduction penalty for chronic misconduct.

Sei V2 upgrade

In November 2023, Sei announced the blueprint for Sei V2, marking three transformative enhancements to the network: parallel EVM, Optimistic parallelization, and SeiDB.

By cleverly combining parallel execution and EVM compatibility, Sei V2 solves performance and availability issues in a single operation, providing users and developers with the ability to escape the limitations of Ethereum while retaining the familiar environment of the EVM ecosystem. This breakthrough approach improves transaction processing efficiency and significantly alleviates Ethereum bottlenecks during periods of high demand, while providing a seamless experience for EVM veterans.

This upgrade is expected to be deployed to the mainnet in the first half of 2024. In the meantime, Sei opened a public development network in February 2024 as a testing ground for Sei V2 innovations.

(Image Source)

Sei is taking a major leap forward with Sei V2, its first major upgrade, which unleashes the power of a parallelized Ethereum Virtual Machine (EVM), provides developers with a hyper-optimized execution layer, and enhances state storage efficiency.

Additionally, a new component will be introduced to accommodate EVM smart contracts. These contracts will take advantage of advances in consensus and parallelization while seamlessly interacting with existing Cosmwasm smart contracts.

(Image Source)

This upgrade will enable Sei to have the following capabilities:

  • Backward compatibility of EVM smart contracts

  • Optimistic Parallelization

  • SeiDB - Improvements in the Storage Layer

  • Interoperability — composability between the EVM and other execution environments

Backward Compatibility

With this update, all existing and audited smart contracts on EVM-compatible chains can be seamlessly deployed on Sei without code changes and leveraging familiar tools such as Foundry, Remix, and Hardhat.

The Sei node will integrate Geth, a Go implementation of the Ethereum Virtual Machine that is responsible for processing Ethereum transactions. Any subsequent updates (such as state modifications or non-EVM contract calls) will be made through a special interface created by Sei specifically for the EVM.

(Image reference)

Optimistic Parallelization

Optimistic parallelization will apply to all transactions running on Sei, including Sei native transactions, Cosmwasm transactions, and EVM transactions.

(Image reference)

In Sei V2, developers will no longer need to manually define state access. Instead, the chain will use an optimistic approach to execute transactions in parallel.

When conflicts arise — such as transactions affecting the same state — the chain monitors which storage area each transaction interacts with. Transactions involving different storage areas will be rerun in parallel, while transactions involving the same state will be rerun sequentially.

This process will continue repeatedly until all conflicts are resolved. Since transactions within a block are ordered, this approach ensures determinism while simplifying the developer's workflow while preserving parallelism at the chain level. For other technical details, please refer to .

SeiDB

Increased transaction processing leads to the creation of more blockchain states, and it is necessary to consider not only parallelizing the runtime but also managing the states. Sei v2 introduces SeiDB as a major component, fundamentally changing the mechanisms of state access, state submission, and state storage.

(Image reference)

The current Sei implementation uses a database layer consisting of an IAVL tree data structure. However, due to its schema and additional metadata, this structure is inefficient in terms of storage and latency, resulting in write amplification and slower disk access.

Based on the foundations proposed by ADR-065 (Architecture Decision Record), the Sei Labs engineering team developed SeiDB. Its main strategy is to avoid storing all data in a single large database. Instead, the data is separated into two independent tiers:

  • State commits use a highly optimized in-memory IAVL tree to quickly commit data, allowing validators to reach consensus faster by minimizing disk access.

  • State storage facilitates low-latency direct access to raw key-value pairs, enhancing the ability of RPC nodes to efficiently process queries.

(SeiDB diagram distinguishing between state commitment and state storage)

The separation of active status and historical data significantly improves the performance of all node operators in the Sei ecosystem. This architectural decision enables Sei Lab's engineering team to use MemIAVL to represent the current chain state as a memory-mapped IAVL tree. As a result, validator nodes can track blockchain state via mmap, reducing state access time from hundreds of microseconds to just hundreds of nanoseconds. This significant advancement greatly improves state synchronization time and read/write amplification.

Storing raw key-value pairs in the state storage layer with minimal metadata improves locality in the LSM tree, while asynchronous pruning prevents nodes from falling behind. These changes reduce state storage requirements by at least 60% and reduce overall data growth by 90%, saving significant long-term disk while nodes continue to run.

In addition, Sei is thoroughly benchmarked against a variety of leading databases in the industry. Therefore, Sei V2 will transition to using PebbleDB instead of GoLevelDB. This conversion is expected to significantly improve read/write performance, especially for multi-threaded access.

SeiDB main content:

  • Reduced active state size by 60%;

  • Reduce historical data growth rate by ~90%;

  • State sync time reduced by 1200%, block sync time reduced by 2 times;

  • Reduced block submission time by 287 times;

  • Provides faster state access and state submission, increasing overall TPS by 2 times;

  • All while ensuring that Sei archive nodes can achieve the same high performance as any full node.

(Image reference)

A major upgrade to the network storage layer solves data overload issues, optimizes performance, and simplifies the onboarding process for new nodes. This ensures consistent network scalability and performance.

Interoperability

The upcoming Sei v2 upgrade will bring revolutionary features, especially advanced high-performance parallel EVM. This advancement will enhance the user experience and open up the way for innovative development possibilities.

Sei is committed to promoting seamless composability between the EVM and other supported execution environments, driving interoperability within existing chains.

(Image reference)

As an integrated blockchain, Sei will allow transactions to interact seamlessly between various Sei components (bank, EVM, Wasm, mortgage). Despite their different purposes, these transactions share common features such as gas, sender, and transaction body. Once received, the chain treats these transactions as Sei native transactions and directs them to the relevant storage part (for example, directing CosmWasm transactions to Wasm modules for execution). This integration promotes a smooth developer experience, allowing EVM developers to easily take advantage of native tokens and other chain features such as mortgages.

In addition, since Sei v2 will be enhanced to support two execution environments (CosmWasm and EVM), all token standards available on the Ethereum blockchain will also be available on Sei. Some users may worry that this will introduce too much complexity to the ecosystem and harm the user experience, but Sei has taken this into consideration.

Every token on Sei, whether it is an NFT (CW-721) or a standard token (CW-20), can be made compatible with EVM wallets and applications through pointer contracts. These contracts establish a link between the tokens of the EVM and CosmWasm, making them seamlessly usable without the need to "wrap" the assets. This ensures that the same token balance can be controlled on both the EVM and CosmWasm.

(Pointer contracts enable wallets from either environment to access all tokens)

Pointer contracts also enable CW-20, CW-721, and native tokens to be used in EVM applications and vice versa. However, they are not convenient for using EVM wallets to interact with existing Sei applications, which requires another feature called "precompile".

To solve this problem, Sei Labs implemented "precompiled" smart contracts directly within the Sei blockchain. These contracts serve as a portal for users and developers to access native Sei functionality through the EVM RPC interface, ensuring that they can interact with the smart contracts using their favorite wallet.

Precompiled contracts available on Sei include:

  • CosmWasm

  • Staking

  • Governance

Developers seeking to use these precompiled instructions can find instructions in the Example Usage section.

Once funds are deposited to your EVM address, you can seamlessly use them with your Sei address and vice versa. This integration merges them into a single account, ensuring smooth interaction between the EVM and Sei ecosystems.

User account settings on Sei

In Sei, each user "account" is associated with a separate public key. However, after upgrading to Sei V2, this public key will correspond to two types of addresses:

  • EVM address: starts with 0x and is used for Ethereum related operations.

  • SEI address: starts with Sei and is used for Sei local operations.

(Image reference)

Although these addresses may appear different on the surface, they are essentially linked to the same underlying account. This means that any action performed with one token address will inevitably affect the other.

Parallel stack of Sei

With the launch of Sei V2, the team is focused on introducing Sei’s parallel stack, which will serve as the entry point for layer 2 networks into the Sei ecosystem.

(Image reference)

Derived from the experience of building Sei V2, this open source powerhouse will empower developers to create high-performance layer 2 solutions and rollups, leveraging the magic of parallel processing. Parallel stacks solve the performance bottlenecks currently faced by layer 2 blockchains in the Ethereum ecosystem.

The framework provides developers with a strong and secure foundation on which to build innovative layer 2 solutions. Notably, the parallel stack provides unparalleled customization capabilities, allowing developers to tailor their creations to specific project needs. In addition, projects inherently benefit from the strong security features of the Ethereum blockchain or any data availability layer they integrate with. As part of the default configuration options, projects can choose to leverage Sei's proven validator set. This integration further enhances security while maximizing the project's benefits from the innovative architecture of the parallel stack.

Democratized Parallel EVM

Building a rollup from scratch can be a daunting task. Sei’s collaboration with Altlayer further inspires developers to explore the potential of high-performance DeFi.

Altlayer’s “Roundups as a Service” (RaaS) product eliminates the complexity of managing node infrastructure, allowing developers to focus on developing innovative dApps that leverage parallel stack capabilities. This saves developers a lot of time and resources.

In addition to simplification, Altlayer’s “Recollateralized Rollups” (a set of three vertically integrated active validation services) seamlessly integrate parallel stacks, adding a strong layer of security to these high-performance rollups. This translates into faster transaction finality, a more decentralized ordering environment, and continuous validation of rollup state — all key factors in fostering trust and security in DeFi applications.

Developers gain access to a powerful toolkit that allows them to create extremely fast and highly secure DeFi applications on the Ethereum ecosystem. This collaboration not only empowers developers, but also paves the way for a more scalable and accessible DeFi landscape, ultimately benefiting the entire user community.

future development

Unifying NFTs: The New xERC-721 NFT Standard

The thriving Ethereum ecosystem faces a challenge - fragmentation. As various scaling solutions emerge (layer 2 rollups, high-performance EVM), NFTs are isolated within specific platforms. This isolates the community and hinders innovation.

Sei Labs and Omni Foundation proposed a solution: the xERC-721 standard. xERC-721 NFT was introduced as a simplified upgrade of ERC-721. It provides greater freedom for NFT creators and holders, no longer restricted to a single domain name, opening the door to innovation and experimentation in the Ethereum ecosystem.

Advantages of xERC-721:

  1. xERC721 tokens are able to be moved securely across multiple domains without introducing unnecessary risk or relying on any privileged third party (such as a specific interoperability network), as described by the lockbox interface functionality. This ensures that sovereignty remains in the hands of the NFT community.

  2. The xERC721 token contract is extended with mintBatch and burnBatch functional interfaces. This was one of the pain points for developers, leading to the introduction of new standards such as ERC-1155. This problem is further exacerbated when programming across multiple blockchains, as it introduces asynchronicity and the need to compensate for the cost of validating and passing transactions across the interoperability networks.

  3. Existing NFT collections can simply be upgraded to xERC-721, making them accessible across the Rollup ecosystem by deploying a new portal contract.

This move, along with EIP-7281, lays the foundation for a standardized approach to NFTs in the decentralized Ethereum environment. By leveraging these open standards, developers can access powerful tools that pave the way for further innovation in the digital asset space.

Sei Creator Fund: $10 Million Grant Program

Committed to fostering the growth of the Sei ecosystem, the Sei Foundation has launched the Sei Creator Fund, a $10 million grant program designed to spark innovation by supporting new project development and expansion of existing projects in the NFT and social experience sectors.

Whether you are full of new infrastructure or tool ideas, want to turn your creative vision into reality, or are looking to push an existing NFT project forward, the Sei Creator Fund will support you.

in conclusion

Sei is firmly committed to solving scalability challenges through parallel execution, optimized data storage, and future upgrades, paving the way for groundbreaking advances that will enable projects to leverage the strengths of multiple platforms to address complex financial challenges.

This groundbreaking approach heralds an era of unprecedented transaction processing throughput, facilitating fast and low-cost interactions among traders. The resulting improved user experience signals the potential for broader DeFi adoption.

As Sei technology develops, its impact on the DeFi space could be transformative, ushering in an era of unprecedented scalability, efficiency, and accessibility. By promoting a more inclusive DeFi future, Sei empowers creators and users to redefine decentralized finance.