SeiNetwork, which launched its mainnet in August 2023, began to explode after several months of silence. Its token price continued to rise sharply, hitting a record high. Currently, Sei’s liquidity staking has exceeded US$3.5 million, and network TVL has exceeded US$11 million. Previously, Sei, together with Beosin and Alibaba Cloud, successfully held the CodeSei: Powering New Gaming and DeFi Exchanges hackathon competition. Beosin also completed the smart contract audit of Sei’s liquidity staking project Kryptonite to help Sei’s ecological security.
This year Sei is about to undergo a very important Sei V2 upgrade, which will improve the performance of parallel processing and introduce EVM. Today Beosin will analyze the code, technical features and ecological projects of Sei Network for everyone to help you understand the potential opportunities of Sei and its ecosystem.
Sei design features
As Layer 1 that supports order book activity and focused trading, Sei provides a built-in central limit order book (CLOB) module. Developers can use Sei's built-in order module to quickly launch and customize order book trading Dapps for spot, derivatives, options, etc. At the same time, Sei's parallel design provides a fast, high-throughput network for its ecological applications.
So how does Sei improve the processing speed of blockchain networks?
1. Build the hash locally
In most current blockchain networks, validators propose blocks and then send hashes and blocks to other validators, which creates a certain waiting time. As shown below:
Sei allows its validators to send blocks containing only transaction hashes to the Sei blockchain network. After other validators receive a block containing only the transaction hash, they will first construct the block based on the records in their local memory pool. If the corresponding transaction information does not exist in the memory pool, the validator will wait for subsequent blocks containing detailed transaction content to arrive for verification.
2. Parallel transaction processing
For blockchain networks that execute sequentially, when a block is proposed, validators need to wait for a certain length of time without actually processing the block. As shown on the left:
Sei Network processes blocks in the pre-voting and pre-commit phases in parallel through validators. Parallel processing reduces latency and increases throughput.
The implementation of Sei parallel processing in the code is shown in the figure below. In the ProcessTxs function, Sei will process the transaction. There are two types of processing: parallel processing and sequential processing. For multiple related transactions (by judging whether the key-value pairs storing transaction information overlap), Sei will process related transactions sequentially; for non-related transactions, it will process them in parallel. deal with.
During parallel transaction processing, we see that Sei uses Golang's goroutine to process multiple transactions in parallel. The current design cannot process too many transactions in parallel. For example, if thousands of transactions are processed in parallel by Sei's nodes at the same time, there is a high probability that consistency problems will occur. Therefore, Sei V2 needs to continue to be upgraded in parallel processing.
What is parallel EVM?
EVM is the virtual machine for Ethereum to process transactions related to smart contracts. To ensure network security, EVM transactions must be executed sequentially. The design of sequential execution avoids the complexity and conflicts of parallel execution, but also limits the performance of the associated blockchain network.
As a result, the concept of parallel EVM was proposed and attracted market attention.
The design of parallel EVM will allow different transactions in EVM to be conducted simultaneously, greatly improving EVM processing speed and network throughput. The current solution is to use high-performance (itself supports parallel transactions) new public chains compatible with EVM such as Solana, Aptos, and Sei. Among them, Sei's parallel EVM attracts the most market attention.
Sei will implement parallel EVM in the V2 version to be launched in 2024, supporting the operation and interaction of Cosmwasm smart contracts and EVM smart contracts. The following are the key points of the Sei V2 upgrade:
1. Optimistic parallelization: allows concurrent transaction processing, significantly improving throughput and efficiency. If a state conflict occurs, transactions are reprocessed sequentially to maintain data integrity.
2. EVM compatible: enables developers to deploy existing EVM smart contracts on Sei without changing any code, simplifying the transition to Sei v2 and improving interoperability.
3. Geth compatibility: Sei nodes will integrate Geth to handle transactions for EVM smart contracts in the future network and make any updates through the special interface created by Sei for EVM.
4. SeiDB: Sei will improve its storage layer, using more efficient data structures and databases to reduce state bloat and enhance read/write performance, facilitate easier synchronization of new nodes and improve scalability.
5. Enhanced performance: Fast transaction processing with 390 millisecond block time and finality, and high throughput of 28,300 batch transactions per second, with lower transaction costs.
This upgrade of Sei v2 will integrate the advantages of Ethereum and looks forward to providing a super-optimized execution layer that is fully compatible with the existing EVM ecosystem to attract more users and developers into the Sei ecosystem.
Sei Contract Security Advice
If developers plan to build Sei ecological applications, they will use CosmWasm to build smart contracts. Beosin recommends that developers follow the following security practices to improve the contract security of their projects:
1. Be prepared for an attack. Developers need to consider how to face attacks and fix vulnerabilities. Therefore, developers need to build upgradable smart contracts and develop risk response plans.
2. Pay attention to the deserialization addr type. CosmWasm's addr type is not validated during deserialization, indicating that the addr type has unexpected deserialization properties. Therefore, it is recommended to specify the type and verify it after deserializing addr.
3. Pay attention to operations and overflow. In the CosmWasm contract, developers need to pay attention to the risk of integer overflow or division by zero. It is recommended that developers use CosmWasm's Uint256 and Uint512 types and use the math function full_mul() that does not overflow.
4. Pay attention to infinite loops. The CosmWasm contract may get stuck in an infinite loop by calling itself back in the ACK handler. If developers transfer data packets between two CosmWasm contracts, they should be aware that this may lead to an infinite loop and consume a large amount of gas fees.
Currently, the wallets that specifically support the Sei network include Compass Wallet and Fin Wallet. There are 14 wallets compatible with the Sei network, such as OKX Wallet and the wallets Keplr and Leap Wallet that originally supported the Cosmos ecosystem.
(1) Users are advised to avoid using wallet projects that have not been audited and have not been running for a long time.
(2) To protect the assets of the wallet, the most important thing is to keep the mnemonic phrase and private key safely.
(3) In the process of using related wallets to interact with Sei projects, signatures are one of the security risks that require the most attention. Users need to check whether the transaction information is correct before signing the transaction. For example, a hacker can trick users into using cosmos.bank.v1beta1.MsgSend to transfer tokens to the hacker's address.
Kryptonite is the largest liquidity staking protocol in the Sei ecosystem. Users can stake Sei tokens on its platform to obtain stSei and earn an annualized return of 5.54%. Currently, users can also stake Seilor/Sei's LP tokens and stSei/SEIYAN's LP tokens to obtain returns from related tokens. Beosin has previously completed a contract audit of Kryptonite to improve the security of its staking business.
In the future, Kryptonite will launch the kUSD stable currency, and users can mint it by pledging Sei, BTC, ETH and other assets to provide more liquidity for the Sei ecosystem.
Yaka Finance is committed to building a multi-functional DEX and providing users with a variety of DeFi services such as trading, liquidity mining, and Launchpad. Its goal is to become the central liquidity hub of the Sei ecosystem.
Previously, Yaka Finance won first place in the DeFi track in the Code Sei: Powering New Gaming and Defi Exchanges hackathon organized by Sei, Beosin and Alibaba Cloud.
Yaka Finance is currently in the test network stage and has launched an airdrop incentive program, attracting more than 15,000 users to participate in its testing.
Pallet Exchange is the NFT trading platform of the Sei ecosystem, with a current daily trading volume of up to 1.23 million Sei (approximately US$1 million). Pallet Exchange will charge a 2% handling fee for NFT transactions on its platform to maintain the operation of the platform.
Currently, the NFT series that have attracted much attention in Sei Ecosystem include WeBump, The Colony, Seiyans, Seinsei, etc. Because the Sei ecosystem is in the early stages of development, users need to pay attention to the liquidity risks of related NFTs.
As a high-performance Layer 1 focused on transactions, Sei optimizes the generation and processing of blocks. At present, Sei's ecology is growing rapidly, and its ecological development will form a synergistic effect with Sei. Various decentralized applications will continue to amplify Sei's high-performance advantages, and Sei will also attract more liquidity and users. As the parallel EVM narrative continues, the upgrade of Sei V2 will solve the current bottleneck of Sei, attracting more attention from the market and more developers entering the Sei ecosystem.