Skip to main content

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 @magicblock-labs/ephemeral-validator package globally:
Verify the installation:
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

The mb-test-validator runs on port 8899 and provides the base layer:
This command:
  • Resets the ledger state
  • Clones required MagicBlock program accounts from devnet
  • Starts listening on http://localhost:8899
Logs are written to /tmp/mb-test-validator.log when using the automated test scripts.

Starting ephemeral-validator

The ephemeral validator runs on port 7799 and connects to your local base layer:
The ephemeral validator:
  • 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:
.env

Anchor.toml Configuration

Configure your Anchor.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 a fullstack-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:
This is useful when:
  • You want to keep validators running between test runs
  • You’re manually managing validator lifecycles
  • You’re debugging and need to inspect validator logs
Make sure validators are actually running before using --skip-local-validator, or tests will fail with connection errors.

Airdropping SOL

For local testing, airdrop SOL to your wallet:
The automated test script does this automatically:

Checking Validator Health

Troubleshooting

Validators won’t start

Check if ports are already in use:
Kill existing processes:

Clean ledger state

Check logs

View validator logs:

Next Steps