Discover more from Smart Platform by Mirror World
Solana V.S EVM: A Detail Breakdown From Developers' Perspective
The conceptual differences between EVM and Solana from our contract developer's experience building on both platforms
Overview of the Key Differences
Key differences we see in in these two networks lines within the underlying the procession architecture. The EVM is a stack-based machine, where each instruction pops two operands from the stack, performs an operation, and pushes the result back onto the stack. This makes EVM execution very predictable and easy to reason about. However, it also makes EVM execution relatively slow.
Solana's architecture is radically different. We have a register-based machine, where each instruction pops one operand from the stack and pushes the result back onto the stack.
This makes Solana execution much faster - we can process tens of thousands of contracts in parallel on modern hardware. The Solana runtime is able to process tens of thousands of contracts in parallel because it uses a data flow architecture. This means that contracts do not need to wait for each other to finish before they can execute. Instead, the runtime assigns each contract a set of data and instructions that it can operate on independently. This allows contracts to be processed in parallel, which results in a much faster and more efficient blockchain.
Account System in Solana
In Solana, Accounts are any place where data is stored on the blockchain. What makes the blockchain unique compared to other blockchains like Ethereum is how this data is stored and managed. There are three different account categories:
- Program Accounts store executable code and the equivalent of Ethereum smart contracts.
- Storage Accounts store the data connected to programs.
- Token Accounts track an account balance of tokens and allow for transferring or receiving tokens between accounts.
Stateful V.S Stateless:
The difference in Solana and Ethereum is that in Solana, the program is separate from the data/state of the program, while in Ethereum, the smart contract and the data of that smart contract are located in one location on the blockchain.
EVM is a stateful network in that it includes state data such as the current state of the contract, the account balance, and the storage at each address. In other words, each address is associated with what these states mean, at any given time - for instance, there can only be one "canonical" state from block to block in the chain (and every new input makes this determination).
Solana's stateless design means that contracts do not need to keep track of their own state. This reduces code complexity and improves scalability. It also makes contracts easier to debug, since you can simply look at the account's contents to see what is going on. This difference allows programs on the Solana blockchain to be more efficient and faster because they do not have to process the data of the program in addition to the code.
Solana's Rent System
Because of the unique structure of Solana storing data into unique accounts, there is a fee associated with all the account created, which is not seen in EVM.
Solana rent is a time-and-space based fee that validators on the network need to maintain a working copy of account state in memory. This rent is charged for the use of this resource consumption. Accounts which maintain a minimum balance equivalent to 2 years of rent payments are exempt from paying rent. The 2 years is drawn from the fact that hardware cost drops by 50% in price every 2 years and the resulting convergence due to being a geometric series.
Accounts whose balance falls below this threshold are charged rent at a rate specified in genesis, in Lamport per byte-year. The network charges rent on a per-epoch basis, in credit for the next epoch, and Account::rent_epoch keeps track of the next time rent should be collected from the account.
Decodable v.s Not-decodeable
It is easier to decompile contracts on the EVM, as there are various online tools that can do this. This makes it easier to understand the content and behavior of deployed contracts. One key difference between Solana and EVM is that Solana does not use a traditional virtual machine, which makes it difficult to decompile code. This makes it more difficult for someone to copy and paste a chunk of code and re-brand it as their own program.
Differences in the Application Layer:
The EVM-based smart contracts cannot be updated natively because they are executed in a virtual machine which is immutable. Any change to the code will result in a new contract address and execution of the new code.
Separating the code from data makes it easy to upgrade programs.pdates in Solana are much easier because there is no need to redeploy the entire program when upgrading. Instead, a new version of the program can be deployed to the same address while reusing the same data account. This upgrade process is much more efficient and minimizes any potential loss of data.
One advantage of the System Program is that it helps to ensure the security of the data within accounts. The System Program is a native program on Solana that is responsible for creating accounts, allocating data on accounts, and assigning ownership of accounts to the connected programs. This means that it is trusted by all validators on Solana and can be relied upon to handle transfers of tokens securely. Additionally, because the System Program is required to be run by all validator, it helps to ensure consistency across the network.
In this workshop, we also went through two code repos to demonstrate the differences stated above, which can be found here:
Decentralized applications are still in their early stages, with many protocols vying for the top spot. With Ethereum’s explosive growth in popularity, it has become the go-to platform for decentralized app development.
However, Solana may provide stiff competition to Ethereum in the coming years due to its faster transaction speed and lower costs. In the meantime, if you're interested in building decentralized applications, be sure to check out Mirror World SDK. With its easy-to-use interfaces and comprehensive documentation, Mirror World SDK makes it simple for anyone to get started with decentralized app development.
Join our developer community for more workshops like this and connect with fellow developers !
Talk to us: https://calendly.com/chriszhu-1