magicsvm 0.2.0

A fast and lightweight Solana + MagicBlock VM simulator for testing solana programs
docs.rs failed to build magicsvm-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

MagicSVM

MagicSVM is a fork of LiteSVM adapted for MagicBlock Ephemeral Rollups. It keeps LiteSVM's fast, in-process Solana VM for testing programs and adds the pieces needed to test programs that delegate accounts to, execute inside, and commit state back from an Ephemeral Rollup without spinning up a validator or an ER node.

📦 Installation

[dependencies]
magicsvm = { git = "https://github.com/magicblock-labs/magicsvm" }

🪄 Native Delegation

Use MagicSVM when a test needs to interact with both the base-layer and an ephemeral rollup. MagicSVM loads all the necessary program so you can start testing right away.

use magicsvm::{MagicSVM, TransactionTarget};

let mut svm = MagicSVM::new();

// Normal Solana transactions and delegation-program instructions run on base.
svm.send_transaction_to(TransactionTarget::Base, base_tx).unwrap();

// Get the account from the base layer
svm.get_account_for(my_account, TransactionTarget::Base).unwrap();

// Rollup-local transactions run on the ephemeral ledger.
svm.send_transaction_to(TransactionTarget::Ephemeral, ephemeral_tx)
    .unwrap()

// Get the account from the rollup
svm.get_account_for(my_account, TransactionTarget::Ephemeral).unwrap();

📚 Docs

See the tutorial for more info, including a list of features.

Some other useful resources:

⚡ Why use MagicSVM?

While many Solana developers use solana-program-test or solana-test-validator for testing, these solutions can be slow, cumbersome and difficult to use. solana-program-test runs a "banking stage" simulation that is overkill for most cases, while solana-test-validator runs a full local validator complete with networking, consensus, RPC, etc.

MagicSVM inherits LiteSVM's approach: it provides a lightweight wrapper around the Solana SVM (Solana Virtual Machine) that lets you send transactions and query state without the overhead of a full validator.

This makes testing dramatically faster: benchmarks show LiteSVM can be 10x or more faster than solana-program-test and solana-test-validator.

It also makes for a much nicer developer experience. You get simple APIs for modifying account state, time travel, copying accounts from a live network and more.

On top of that, MagicSVM is geared toward Ephemeral Rollups: it lets you exercise the delegation flow your programs rely on when running on MagicBlock, so you can test that logic in-process alongside the rest of your program.

See the tutorial for more info.

🪲 Bugs and feature requests

Please open an issue if you find a bug or have a feature request.

📜 License

MagicSVM is licensed under the Apache 2.0 license.

🙏 Credits

MagicSVM is a fork of LiteSVM by Kevin Heavey and contributors. LiteSVM draws heavily on solana-program-test and is also inspired by bankrun, Anchor Bankrun and the work of Joey Meere. Huge thanks to all of the upstream authors.