Giter Site home page Giter Site logo

ryanorendorff / node-gateway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from satsuma-xyz/node-gateway

0.0 2.0 0.0 270 KB

Blockchain node gateway.

Home Page: https://satsuma.xyz/

License: Apache License 2.0

Shell 3.40% Go 95.75% Makefile 0.60% Dockerfile 0.26%

node-gateway's Introduction

⛩ node-gateway

Test GitHub release (latest by date) Docker Image Version (latest by date) contributions welcome License

An L7 load balancer for EVM-based blockchain nodes that provides better reliability and proper data consistency.

Introduction

Whether you're running your own nodes or using a managed provider, node RPCs often go down or fall behind. Naive load balancing between nodes doesn't account for data consistency issues.

node-gateway makes it easier to run reliable and accurate node infrastructure for dApp developers, traders, and stakers.

Example use cases

  • Run your own nodes instead of paying for node providers. For very high availability, fall back on node providers in case your own nodes are unavailable. In our benchmarks, a single on-demand im4gn.4xlarge AWS EC2 machine that costs ~$1050 can serve over 1000 requests / second. This is > 10x cheaper than the well known node providers.
  • Use a primary node provider and fall back on another node provider for even higher availability. The well known node providers tout 99.9% uptime (~9 hours of downtime a year) but often have degraded performance even if they're "up".

Quick start

Run with Docker

git clone https://github.com/satsuma-data/node-gateway.git
cd node-gateway
cp configs/config.sample.yml config.yml

docker run -d -p 8080:8080 -p 9090:9090 \
  -v $PWD/config.yml:/satsuma/config.yml \
  -e ENV=production \
  satsumaxyz/node-gateway:latest

Usage

curl --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8080

{"jsonrpc":"2.0","id":1,"result":"0xe9a0a1"}

Configuration

See the sample config.

Features

  • Round-robin load balancing for EVM-based JSON RPCs.
  • Health checks for block height and peer count.
  • Automated routing to nodes at max block height for data consistency.
  • Node groups with priority levels (e.g. primary/fallback).
  • Multichain support.
  • Intelligent routing to archive/full nodes based on type of JSON RPC request (state vs nonstate).
  • Method based routing.
  • Support for self-hosted nodes and node providers with basic authentication.
  • Prometheus metrics.
  • And much more!

🔮 Roadmap

  • Better support for managed node providers (e.g. rate limits/throttling).
  • Automatic retry / fallback.
  • Caching.
  • WebSockets.
  • Additional data consistency measures (broadcasting to multiple nodes, uncled blocks, etc).
  • Additional routing strategies (intelligent routing to archive/full nodes based on recency of data requested, etc).
  • Filter support (eth_newBlockFilter, eth_newFilter, and eth_newPendingTransactionFilter).

Interested in a specific feature? Join our Telegram group chat to let us know.

Metrics

By default, Prometheus metrics are exposed on port 9090. See metrics.go for more details.

Development

Running locally

  1. Install Go 1.19.
  2. Install dependencies: go mod download.
  3. Run go run cmd/gateway/main.go.

Testing

Generate mocks by first installing mockery, then running:

go generate ./...

This command will generate mocks for interfaces/types annotated with go:generate mockery ... and place them in the mocks folder

Run tests with:

go build -v ./...
go test -v ./...

Linting

This project relies on golangci-lint for linting. You can set up an integration with your code editor to run lint checks locally.

Commit messages

All commit messages should follow the conventional commit format.

For convenience of local development, there's a commit-msg Git hook that you can use:

ln -s $PWD/scripts/git_hooks/* .git/hooks

License

This repo is licensed under the Apache License, Version 2.0. See LICENSE for details.

Copyright © Riser Data, Inc.

node-gateway's People

Contributors

androbwebb avatar brianluong avatar dependabot[bot] avatar dianwen avatar ivanvergiliev avatar jonathankau avatar kevin-satsuma avatar

Watchers

 avatar  avatar

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.