-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Feature Request: WebSocket Server for Real-Time Event Streaming
Background
Competitor Analysis Reference: QuickNode, Alchemy, Infura
XDC Gateway currently lacks real-time streaming capabilities. Leading providers like QuickNode offer WebSocket connections for subscribing to live blockchain events with low latency.
Requirements
Core Functionality
- WebSocket server supporting
eth_subscribeandeth_unsubscribemethods - Subscription types:
newHeads- New block headerslogs- Contract event logs with address/topic filteringnewPendingTransactions- Pending transaction poolsyncing- Node sync status
Technical Specifications
- Protocol: WebSocket (ws/wss) on port 8546
- Frame Size: Support up to 10MB for large log batches
- Connection Limit: 100 concurrent connections per IP (configurable)
- Heartbeat: Ping/pong every 30 seconds
- Reconnection: Client-side exponential backoff support
Performance Targets
- Latency: <50ms from block import to WebSocket delivery
- Throughput: 1000+ concurrent subscriptions
- Message delivery: At-least-once semantics
Implementation Plan
Phase 1: Core Server (Week 1-2)
// Proposed architecture
package websocket
type Server struct {
upgrader websocket.Upgrader
subscriptions map[string]*Subscription
blockFeed chan *types.Block
eventBus *EventBus
}
type Subscription struct {
ID string
Type SubscriptionType
Filters FilterCriteria
Client *ClientConn
CreatedAt time.Time
}Phase 2: Integration (Week 3)
- Hook into XDC node block import pipeline
- Subscribe to internal event feeds
- Implement filtering logic
Phase 3: Testing & Deployment (Week 4)
- Load testing with 10k concurrent connections
- Reorg handling verification
- Documentation and SDK updates
API Specification
// Subscribe request
{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_subscribe",
"params": ["logs", {"address": "0x...", "topics": ["0x..."]}]
}
// Response
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x9ce59a13059e417087c02d32e8f8f9f8"
}Acceptance Criteria
- WebSocket endpoint accessible at
wss://gateway.xdc.network/ws - All subscription types functional
- Filter criteria working for logs
- Load test: 1000 concurrent connections, 1 hour stability
- Documentation published
Competitor Comparison
| Feature | QuickNode | Alchemy | XDC Gateway (Target) |
|---|---|---|---|
| WebSocket | ✅ | ✅ | 🔄 In Progress |
| Subscription Types | 4 | 4 | 4 |
| Latency | <50ms | <100ms | <50ms |
| Concurrent | 10k+ | 10k+ | 1000+ |
References
Priority: P0 - Critical for DeFi and real-time applications
Estimated Effort: 4 weeks
Labels: enhancement, infrastructure, P0, websocket
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels