Skip to content

scalarorg/fastevm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 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)

πŸ“ˆ 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

No packages published