Skip to content

scalarorg/fastevm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FastEVM - Engine API Bridge

A high-performance Engine API bridge connecting Reth execution clients with Mysticeti consensus clients, enabling seamless integration between Ethereum execution and DAG-based consensus protocols.

πŸš€ Overview

FastEVM provides a complete implementation of the Ethereum Engine API, allowing:

  1. Reth-compatible execution clients to serve as execution environments
  2. Mysticeti consensus clients to orchestrate consensus decisions
  3. Bidirectional communication through standardized Engine API endpoints
  4. Multi-node deployments with Docker Compose orchestration

πŸ“‹ Features

  • βœ… Full Engine API Implementation (engine_newPayloadV2, engine_forkchoiceUpdatedV2, engine_getPayloadV2)
  • βœ… Mysticeti SubDAG Processing - Convert committed SubDAGs to execution payloads
  • βœ… Concurrent Request Handling - High-throughput RPC server
  • βœ… Comprehensive Testing - Unit, integration, and performance tests
  • βœ… Docker Containerization - Production-ready deployment
  • βœ… Multi-node Support - 4-node cluster by default
  • βœ… Monitoring Integration - Prometheus metrics and health checks
  • βœ… Error Recovery - Automatic retry mechanisms

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    Engine API     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 β”‚ ◄─────────────────► β”‚                 β”‚
β”‚ Consensus       β”‚    HTTP/JSON-RPC   β”‚ Execution       β”‚
β”‚ Client          β”‚                    β”‚ Client          β”‚
β”‚ (Mysticeti)     β”‚                    β”‚ (Reth-like)     β”‚
β”‚                 β”‚                    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                       β”‚
        β–Ό                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SubDAG         β”‚                    β”‚ ExecutionPayloadβ”‚
β”‚ Processing     β”‚                    β”‚ Validation      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🚦 Quick Start

Prerequisites

  • Rust 1.75+
  • Docker & Docker Compose
  • Make (optional, for convenience commands)

1. Clone and Build

git clone <repository>
cd fastevm
make build

2. Run Tests

# Run all tests
make test

# Run integration tests specifically
make integration-test

# Run benchmarks
make benchmark

3. Start Multi-Node Cluster

# Start 4 nodes (execution + consensus pairs)
make docker-up

# Monitor logs
make docker-logs

# Stop cluster
make docker-down

4. Development Mode

# Terminal 1: Start execution client
make dev-execution

# Terminal 2: Start consensus client
make dev-consensus

πŸ“ Project Structure

fastevm/
β”œβ”€β”€ fastevm/
β”‚   β”œβ”€β”€ execution-client/          # Reth-compatible execution client
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.rs            # CLI entry point
β”‚   β”‚   β”‚   β”œβ”€β”€ engine_api.rs      # Engine API implementation
β”‚   β”‚   β”‚   └── types.rs           # Ethereum types
β”‚   β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”‚   └── Cargo.toml
β”‚   └── consensus-client/          # Mysticeti consensus client
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ main.rs            # CLI entry point
β”‚       β”‚   β”œβ”€β”€ client.rs          # Engine API client
β”‚       β”‚   └── types.rs           # Consensus types
β”‚       β”œβ”€β”€ Dockerfile
β”‚       └── Cargo.toml
β”œβ”€β”€ tests/
β”‚   └── integration_tests.rs       # Integration test suite
β”œβ”€β”€ benches/
β”‚   └── engine_api_bench.rs        # Performance benchmarks
β”œβ”€β”€ monitoring/
β”‚   └── prometheus.yml             # Monitoring configuration
β”œβ”€β”€ docker-compose.yml             # Multi-node orchestration
β”œβ”€β”€ Makefile                       # Development commands
└── README.md

πŸ”§ Configuration

Execution Client Options

./execution-client \
  --port 8551 \
  --http.addr 0.0.0.0 \
  --log-level info \
  --node-id 0

Consensus Client Options

./consensus-client \
  --execution-url http://127.0.0.1:8551 \
  --poll-interval 1000 \
  --max-retries 3 \
  --timeout 30 \
  --node-id 0 \
  --log-level info

πŸ§ͺ Testing

Unit Tests

cargo test --workspace

Integration Tests

cargo test --test integration_tests

Performance Tests

# Run benchmarks
cargo bench

# Performance test against running cluster
make perf-test

Multi-node Testing

make multi-node-test

πŸ“Š API Reference

Engine API Endpoints

engine_newPayloadV2

Submit a new execution payload for validation.

Request:

{
  "jsonrpc": "2.0",
  "method": "engine_newPayloadV2",
  "params": [
    {
      "parentHash": "0x...",
      "feeRecipient": "0x...",
      "stateRoot": "0x...",
      "receiptsRoot": "0x...",
      "logsBloom": "0x...",
      "prevRandao": "0x...",
      "blockNumber": "0x1",
      "gasLimit": "0x1c9c380",
      "gasUsed": "0x5208",
      "timestamp": "0x...",
      "extraData": "0x",
      "baseFeePerGas": "0x3b9aca00",
      "blockHash": "0x...",
      "transactions": [],
      "withdrawals": null
    }
  ],
  "id": 1
}

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "status": "VALID",
    "latestValidHash": "0x...",
    "validationError": null
  },
  "id": 1
}

engine_forkchoiceUpdatedV2

Update the forkchoice state and optionally start payload building.

engine_getPayloadV2

Retrieve a built payload by ID.

πŸ”„ Data Flow

1. Consensus β†’ Execution Flow

SubDAG Commit β†’ Payload Conversion β†’ engine_newPayloadV2 β†’ Validation Response

2. Execution β†’ Consensus Flow

Forkchoice Update β†’ engine_forkchoiceUpdatedV2 β†’ Payload Building β†’ engine_getPayloadV2

3. SubDAG to ExecutionPayload Conversion

The consensus client converts Mysticeti SubDAGs to Ethereum ExecutionPayloads:

SubDAG {
    id: "subdag-123",
    round: 42,
    transactions: [...],
    leader: "validator-1",
    timestamp: "2024-01-01T00:00:00Z"
} 
↓
ExecutionPayload {
    block_number: 42,
    block_hash: hash(subdag.id),
    transactions: encode(subdag.transactions),
    timestamp: subdag.timestamp.unix(),
    extra_data: subdag.id.bytes()
}

🐳 Docker Deployment

Single Node

# Build images
docker build -t fastevm-execution -f fastevm/execution-client/Dockerfile .
docker build -t fastevm-consensus -f fastevm/consensus-client/Dockerfile .

# Run execution client
docker run -p 8551:8551 fastevm-execution

# Run consensus client (in another terminal)
docker run fastevm-consensus --execution-url http://host.docker.internal:8551

Multi-Node Cluster

docker compose up -d

This starts:

  • 4 execution clients (ports 8551-8554)
  • 4 consensus clients
  • Prometheus monitoring (port 9090)
  • Loki log aggregation (port 3100)

🌐 Network Setup

The FastEVM network consists of a unified setup with 4 execution nodes and 4 consensus nodes, providing a robust testing and development environment.

Network Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Genesis Init  β”‚    β”‚ Consensus Init  β”‚
β”‚   Container     β”‚    β”‚   Container     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                       β”‚
          β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              EXECUTION NODES                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Execution 1 β”‚ β”‚ Execution 2 β”‚ β”‚ Execution 3 β”‚ β”‚
β”‚  β”‚ Port: 8551  β”‚ β”‚ Port: 8552  β”‚ β”‚ Port: 8553  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                 β”‚
β”‚  β”‚ Execution 4 β”‚                                 β”‚
β”‚  β”‚ Port: 8554  β”‚                                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                       β”‚
          β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              CONSENSUS NODES                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Consensus 1 β”‚ β”‚ Consensus 2 β”‚ β”‚ Consensus 3 β”‚ β”‚
β”‚  β”‚ IP: 172.20.0.10 β”‚ β”‚ IP: 172.20.0.11 β”‚ β”‚ IP: 172.20.0.12 β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                 β”‚
β”‚  β”‚ Consensus 4 β”‚                                 β”‚
β”‚  β”‚ IP: 172.20.0.13 β”‚                                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Port Mapping

Execution Nodes

Node Engine API HTTP RPC WebSocket RPC
1 8551 8545 8546
2 8552 8547 8548
3 8553 8549 8550
4 8554 8555 8556

Consensus Nodes

Node IP Address Internal Port
1 172.20.0.10 26657
2 172.20.0.11 26657
3 172.20.0.12 26657
4 172.20.0.13 26657

Monitoring

Network Management

Quick Start Commands

# Start the entire network
./scripts/run.sh start

# Check network status
./scripts/run.sh status

# View all logs
./scripts/run.sh logs

# Stop the network
./scripts/run.sh stop

Alternative Docker Compose Commands

# Start network
docker compose up -d

# Check status
docker compose ps

# View logs
docker compose logs -f [service-name]

# Stop network
docker compose down

Startup Sequence

The network follows this startup sequence:

  1. Init Containers:

    • genesis-init: Sets up genesis files and JWT secrets for all execution nodes
    • consensus-init: Generates committee configuration for consensus nodes
  2. Execution Nodes: Start in parallel after genesis setup

  3. Consensus Nodes: Start after execution nodes are healthy

  4. Monitoring: Starts after all nodes are running

Configuration Files

  • Genesis Template: execution-client/shared/genesis.template.json
  • Init Script: execution-client/shared/init.sh
  • Node Configs: consensus-client/examples/node*.yml
  • Committee Config: consensus-client/examples/committees.yml

Data Persistence

Each node has its own persistent volume:

  • execution-data-1 through execution-data-4: Execution node data
  • consensus-data-1 through consensus-data-4: Consensus node data

Network Configuration

  • Subnet: 172.20.0.0/16
  • Driver: Bridge
  • External: false (managed by docker compose)

Troubleshooting

Common Issues

  1. Port Conflicts: Ensure ports 8545-8556 are available
  2. Init Container Failures: Check logs with docker compose logs genesis-init
  3. Node Startup Issues: Verify dependencies and health checks

Debug Commands

# Check container status
docker compose ps

# View service logs
docker compose logs -f [service-name]

# Check network connectivity
docker network inspect fastevm_fastevm-network

# Access container shell
docker exec -it [container-name] /bin/sh

Reset Network

# Complete cleanup and restart
./scripts/run.sh cleanup
./scripts/run.sh start

Development

Adding New Nodes

To add more nodes:

  1. Copy existing node configuration
  2. Update ports and IP addresses
  3. Add new volumes
  4. Update monitoring dependencies

Customizing Configuration

  • Modify genesis template in execution-client/shared/genesis.template.json
  • Adjust consensus parameters in consensus-client/examples/
  • Update init scripts as needed

Security Notes

  • JWT secrets are generated automatically for each execution node
  • Each node has isolated data volumes
  • Network is isolated to the docker bridge network
  • No external access by default

πŸ“ˆ Performance

Benchmarks

Run make benchmark to see performance metrics:

  • New Payload Processing: ~50,000 payloads/second
  • Forkchoice Updates: ~100,000 updates/second
  • Concurrent Requests: 1000+ concurrent connections
  • Memory Usage: <100MB per client
  • Latency: <1ms average response time

Monitoring

Access monitoring at:

πŸ” Troubleshooting

Common Issues

  1. Connection Refused

    # Check if execution client is running
    curl -X POST http://localhost:8551 \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"engine_newPayloadV2","params":[],"id":1}'
  2. Docker Build Issues

    # Clean and rebuild
    make clean
    make docker-build
  3. Port Conflicts

    # Check port usage
    netstat -tlnp | grep 8551

Debugging

Enable debug logging:

./execution-client --log-level debug
./consensus-client --log-level debug

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Run tests (make check-all)
  4. Commit changes (git commit -m 'Add amazing feature')
  5. Push to branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Development Workflow

# Setup development environment
make setup

# Run quality checks
make check-all

# Run integration tests
make integration-test

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

  • Issues: Open a GitHub issue
  • Discussions: Use GitHub Discussions for questions
  • Security: Email security@fastevm.com for security issues

Built with ❀️ for the Ethereum and blockchain community

About

Fast evm blockchain based on Reth and Mysticeti

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors