magicsvm 0.2.1

A fast and lightweight Solana + MagicBlock VM simulator for testing solana programs
docs.rs failed to build magicsvm-0.2.1
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 and adds a second ledger so you can test programs that delegate accounts, execute inside an Ephemeral Rollup, and commit state back — without a validator or an ER node.

Pair it with ephemeral-rollups-sdk to build the same CPIs and client instructions your production programs use.

Features

  • Dual ledger — base (Solana L1) and ephemeral (the rollup) in one process
  • Delegation lifecycle — sending a DLP or Magic-program instruction is enough; MagicSVM applies delegate, commit, and undelegate itself
  • Post-delegation and post-commit actions — cleartext or validator-encrypted ephemeral actions, plus CallHandler / intent bundles on base
  • Ephemeral-only accounts — create, resize, and close via the Magic program
  • Ephemeral ATAs (EATA) — SDK-built instructions; MagicSVM projects a delegated EATA onto the canonical SPL ATA on ephemeral
  • Access control — private accounts stay hidden unless the caller is a permission member
  • Programs loaded by default — DLP on base, Magic program on ephemeral, ESPL and the permission program on both, plus vaults and a validator identity
  • LiteSVM surface — airdrop, set_account, compute budget, sigverify, sysvars, and the rest of LiteSVM's API; typically 10× or more faster than solana-program-test / solana-test-validator

Installation

Rust

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

Node.js

yarn add @magicblock-labs/magicsvm

Full setup is in docs/installation.md.

Usage

Default methods hit base. Pass an explicit target for the rollup.

Rust

use magicsvm::{MagicSVM, TransactionTarget};

let mut svm = MagicSVM::new();

svm.send_transaction(tx)?; // base
svm.send_transaction_to(TransactionTarget::Ephemeral, tx)?;

let on_base = svm.get_account(&pubkey);
let on_ephemeral = svm.get_account_for(TransactionTarget::Ephemeral, &pubkey);

Node.js

import { MagicSVM } from "@magicblock-labs/magicsvm";

const svm = new MagicSVM();

svm.sendTransaction(tx); // base
svm.sendTransaction(tx, { target: "ephemeral" });

const onBase = svm.getAccount(pubkey);
const onEphemeral = svm.getAccountFor(pubkey, { target: "ephemeral" });

Runnable copies of a full delegate → increment → undelegate flow are in examples/.

Docs and examples

  • docs/ — dual ledger, delegation, EATA, ephemeral-only accounts, access control
  • examples/ — copyable Rust and Node projects

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 Aursen 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.