π° Waterway
A high-performance JSON-RPC 2.0 proxy for Sei blockchain nodes with WebSocket pooling, automatic HTTP fallback, and response caching.
Features
- Dual transport support β Routes requests via WebSocket or HTTP based on method compatibility
- WebSocket connection pooling β Maintains a pool of persistent connections for low-latency requests
- Automatic fallback β Falls back to HTTP when WebSocket calls fail or return incompatible errors
- Response caching β Memcached integration for cacheable RPC methods
- Batch requests β Handles JSON-RPC batch requests with configurable concurrency limits
- Method filtering β Allowlist/blocklist support for controlling exposed RPC methods
- Metrics & health checks β Prometheus metrics endpoint and health status reporting
- TLS support β Optional HTTPS/WSS termination
Quick Start
waterway, err := NewWaterway(ctx,
WithListenAddr(":8545"),
WithSeiWSEndpoint("ws://localhost:26657/websocket"),
WithSeiHTTPEndpoint("http://localhost:26657"),
)
if err != nil {
log.Fatal(err)
}
waterway.Start(ctx)
Endpoints
| Path |
Description |
/ |
JSON-RPC endpoint (HTTP POST or WebSocket upgrade) |
/health |
Health check with pool status |
/metrics |
Prometheus metrics |
Configuration Options
Configure via Option functions passed to NewWaterway():
WithListenAddr β Server bind address
WithSeiWSEndpoint β Upstream WebSocket URL
WithSeiHTTPEndpoint β Upstream HTTP URL
WithAllowedMethods / WithBlockedMethods β Method filtering
WithHTTPOnlyMethods β Force specific methods to use HTTP
WithCacheableMethods β Enable caching for specific methods
WithMemcachedServers β Memcached server addresses
WithMaxWSConnections β WebSocket pool size
WithTLS β TLS certificate and key paths
How It Works
- Incoming requests are validated against JSON-RPC 2.0 spec and method filters
- Cacheable methods check Memcached first
- Subscription methods (
eth_subscribe/eth_unsubscribe) always use WebSocket
- Other methods try WebSocket first, falling back to HTTP on failure
- Methods that consistently fail over WebSocket are automatically routed to HTTP