Overview
Running a local Ephemeral Rollup validator allows you to develop and test your programs without relying on remote endpoints. This guide covers installing the validator, configuring your environment, and running tests locally.For comprehensive local development guidance, see the MagicBlock Local Development Guide.
Prerequisites
Before setting up your local environment, ensure you have:- Node.js v24.10.0 or later
- Solana CLI v2.3.13 or later
- Anchor Framework v0.32.1 or later
- Rust v1.85.0 or later
Installation
1
Install the Ephemeral Validator
Install the Verify the installation:
@magicblock-labs/ephemeral-validator package globally:2
Install mb-test-validator
The
mb-test-validator is a wrapper around Solana’s test validator that pre-configures required accounts for MagicBlock.The test scripts in the examples use
mb-test-validator which clones necessary MagicBlock program accounts automatically.3
Configure Solana CLI
Set your Solana CLI to use localhost:Create a keypair if you don’t have one:
Starting Local Validators
Starting mb-test-validator
Themb-test-validator runs on port 8899 and provides the base layer:
- Resets the ledger state
- Clones required MagicBlock program accounts from devnet
- Starts listening on
http://localhost:8899
Starting ephemeral-validator
The ephemeral validator runs on port 7799 and connects to your local base layer:- Listens on
http://localhost:7799(RPC) - Provides WebSocket on
ws://localhost:7800 - Connects to the base layer at
http://127.0.0.1:8899
Environment Variables
Configure your environment for local testing:- Localnet
- Devnet
.env
Anchor.toml Configuration
Configure yourAnchor.toml to support multiple clusters:
Anchor.toml
The
fullstack-test.sh script automatically detects the cluster from Anchor.toml and configures validators accordingly.Automated Local Testing
The examples include afullstack-test.sh script that automates the entire local testing process:
1
Script automatically starts validators
The script checks if validators are already running on ports 8899 and 7799. If not, it starts them:
2
Builds and deploys programs
3
Runs tests with proper configuration
4
Cleans up after tests
The script automatically stops validators and cleans up test ledgers when tests complete.
Manual Testing Workflow
For manual control over the testing process:1
Start validators in separate terminals
Terminal 1 - Base Layer:Terminal 2 - Ephemeral Rollup:
2
Set environment variables
3
Build and deploy
4
Run tests
Using —skip-local-validator
When you have validators already running, use the--skip-local-validator flag to avoid starting new instances:
- You want to keep validators running between test runs
- You’re manually managing validator lifecycles
- You’re debugging and need to inspect validator logs
Airdropping SOL
For local testing, airdrop SOL to your wallet:Checking Validator Health
- Base Layer (8899)
- Ephemeral Rollup (7799)
Troubleshooting
Validators won’t start
Check if ports are already in use:Clean ledger state
Check logs
View validator logs:Next Steps
- Learn about Testing Patterns
- Explore Troubleshooting Common Issues
- Try running the Anchor Counter Example