SVM
SVM (Solana Virtual Machine)¶
SVM (Solana Virtual Machine) is the execution environment for Solana smart contracts, responsible for running eBPF bytecode programs. SVM's parallel execution capability is the core of Solana's high performance.
Core Features¶
Parallel Execution SVM's greatest innovation is the parallel execution of multiple smart contracts: - Analyzes account dependencies of transactions - Processes non-conflicting transactions in parallel - Fully utilizes multi-core CPUs
eBPF Runtime SVM executes eBPF bytecode: - Register-based virtual machine - JIT compiled to native code - Performance close to native programs
Account Model Programs and data are separated: - Programs are read-only - Data is stored in independent accounts - Supports concurrent access
Parallel Execution Mechanism¶
Sealevel Runtime Sealevel is SVM's parallel execution engine:
- Dependency Analysis
- Extracts the accounts accessed by each transaction
- Builds an account dependency graph
-
Identifies parallelizable transactions
-
Dispatch and Execution
- Assigns non-conflicting transactions to different CPU cores
- Executes conflicting transactions serially
-
Maximizes parallelism
-
State Merging
- After parallel execution completes
- Merges state updates
- Writes to AccountsDB
Comparison with EVM¶
| Feature | SVM | EVM |
|---|---|---|
| Parallelism | Supported | Not supported (serial) |
| Architecture | Register-based | Stack-based |
| Bytecode | eBPF | EVM bytecode |
| Languages | Rust, C | Solidity |
| Account Model | Program/data separation | Self-contained contracts |
| Performance | Extremely high | Moderate |
Execution Flow¶
1. Load Program Load eBPF bytecode from the chain.
2. Load Accounts Read the account data involved in the transaction.
3. Execute - JIT compile eBPF - Execute program logic - Record CU consumption
4. Verify - Check account ownership - Verify signatures - Ensure resource limits
5. Commit Write state updates to AccountsDB.
Compute Limits¶
CU Limits - Per transaction: 200,000 - 1,400,000 CU - Prevents infinite loops - Ensures fair resource allocation
Call Depth - CPI (Cross-Program Invocation) maximum depth of 4 levels - Prevents stack overflow
Account Limits - Maximum of 64 writable accounts per transaction - Accounts must be declared in advance
Security Mechanisms¶
Sandbox Isolation Programs run in a restricted environment: - Cannot access the file system - Cannot access the network - Cannot call system APIs
Static Verification The eBPF verifier checks for: - No infinite loops - No illegal memory access - Compliance with instruction limits
Runtime Checks - CU consumption monitoring - Account permission verification - Signature verification
SVM Ecosystem¶
SVM Chain Family Multiple projects adopt SVM as their execution layer: - Eclipse: SVM + Ethereum settlement - Sonic: A gaming-optimized SVM chain - Nitro: Another SVM L2
Advantages - Inherits Solana's high performance - Compatible with Solana's toolchain - Shares the developer ecosystem
Ongoing Optimization¶
Performance Improvements - Optimizing JIT compilation - Reducing account loading overhead - Improving parallel scheduling algorithms
Feature Expansion - Supporting new system calls - Enhancing cross-program invocation - Improving error handling
Impact on Developers¶
High Performance SVM enables developers to build high-throughput applications.
Parallelism-Friendly Account access patterns must be considered during design to avoid unnecessary conflicts.
Mature Toolchain Frameworks like Anchor simplify SVM program development.
Related Concepts¶
- eBPF: The bytecode format executed by SVM
- Sealevel: SVM's parallel runtime
- CU (Compute Units): The unit measuring program execution consumption
- EVM: Ethereum Virtual Machine, a counterpart to SVM
- Parallel Execution: SVM's core advantage