GithubHelp home page GithubHelp logo

eth-proxy's Introduction

eth-proxy

Reverse proxy for ethereum nodes. Warning: This is very experimental.

Features:

  • Status endpoint for all your beacon nodes
  • Beacon chain API path based allow list. Allows you to restrict which API endpoints you're exposing.
  • Execution JSON RPC method allow list

Endpoints

Status: Shows you the configured nodes and some additional information about them.

curl http://localhost:5555/status

Example response:

{
    "beacon_nodes": {
        "node1": {
            "version": "Lighthouse/v2.3.2-rc.0-828d5bc/x86_64-linux",
            "syncing": {
                "head_slot": "366025",
                "sync_distance": "0",
                "is_syncing": false,
                "is_optimistic": false
            },
            "peer_count": {
                "disconnected": 561,
                "connected": 110
            },
            "last_check": 1658315108
        },
        "node2": {
            "version": "Lodestar/v0.38.0-dev.b5e24f7138",
            "syncing": {
                "head_slot": "366025",
                "sync_distance": "0",
                "is_syncing": false,
                "is_optimistic": false
            },
            "peer_count": {
                "disconnected": 0,
                "connected": 50
            },
            "last_check": 1658315108
        }
    },
    "execution_nodes": {
        "node1": {
            "head_block": 12630114,
            "chain_id": 3,
            "peer_count": 9,
            "is_syncing": false,
            "last_check": 1658315108
        },
        "node2": {
            "head_block": 12630114,
            "chain_id": 3,
            "peer_count": 12,
            "is_syncing": false,
            "last_check": 1658315108
        }
    }
}

Reverse proxy to a specific node by name

# Beacon HTTP API
curl -X GET 'http://localhost:5555/proxy/beacon/node1/eth/v1/node/identity'

# Execution JSON RPC API
curl -X POST 'http://localhost:5555/proxy/execution/node1/' \
     --header 'Content-Type: application/json' --data-raw '{
        "jsonrpc":"2.0",
        "method":"eth_blockNumber",
        "params":[],
        "id":1
}'

Load balance (round-robin) across nodes

# Beacon HTTP API
curl -X GET 'http://localhost:5555/lb/beacon/eth/v1/node/identity'

# Execution JSON RPC API
curl -X POST 'http://localhost:5555/lb/execution/' \
     --header 'Content-Type: application/json' --data-raw '{
        "jsonrpc":"2.0",
        "method":"eth_blockNumber",
        "params":[],
        "id":1
}'

Building and running

Adjust the configuration file for your needs. An example can be seen in example_config.yaml

go build -o bin/eth-proxy ./cmd/eth-proxy && ./bin/eth-proxy --config example_config.yaml

eth-proxy's People

Contributors

skylenet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

trajan0x

eth-proxy's Issues

Add load balancing support

Some requirements:

  • Only load balance to synced nodes
  • If state is different, then trust the majority.
  • Show which nodes are ready on the /status endpoint

Add metric support

Per endpoint and upstream, we want to see the HTTP/RPC result status and response times.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.