Skip to content

feat: add WebSocket subscription service with connection manager and polling fallback#8

Merged
linuxninja39 merged 1 commit into
mainfrom
merge/ev-essv
Feb 18, 2026
Merged

feat: add WebSocket subscription service with connection manager and polling fallback#8
linuxninja39 merged 1 commit into
mainfrom
merge/ev-essv

Conversation

@linuxninja39

Copy link
Copy Markdown
Contributor

Summary

  • Adds complete WebSocket subscription infrastructure in new src/subscriptions/ module
  • SubscriptionService orchestrates subscriptions with WebSocket-first, polling fallback strategy
  • WebSocketConnectionManager handles connection lifecycle, reconnection, and health monitoring
  • NewHeadsSubscription and TransferLogsSubscription for block and ERC20 transfer events
  • PollManager provides reliable polling fallback when WebSocket unavailable
  • EventBus for decoupled event distribution across components

Test plan

  • All 985 tests pass (46 test files)
  • Clean rebase on main, no conflicts
  • New subscription tests: SubscriptionService (33), PollManager (13), NewHeads (14), TransferLogs (12), WebSocketConnectionManager (21), EventBus (8)

MQ: ev-essv | Branch: polecat/obsidian/ev-keps@mlrpglwp

…ling fallback

Implement real-time subscription infrastructure per en-p0ha architecture directive:

- WebSocketConnectionManager: connection pool (one WS per chain), lazy
  establishment, reconnection with exponential backoff (1s-30s, 10 retries),
  heartbeat (30s ping, 5s pong timeout), subscription registry
- NewHeadsSubscription: eth_subscribe('newHeads') per chain, batch-fetches
  balances for all tracked addresses on each new block
- TransferLogsSubscription: ERC-20 Transfer event logs filtered to tracked
  addresses using keccak256('Transfer(address,address,uint256)') topic
- PollManager: 30s HTTP polling fallback when WS fails, continuous WS recovery
  attempts every 60s, emits same events as WS path (transport-agnostic)
- SubscriptionService: unified API — subscribeBalances, subscribeTokenTransfers,
  subscribeNewBlocks, subscribePendingTransactions, subscribeContractEvents,
  unsubscribe, getSubscriptionStatus
- EventBus: domain event emitter for 11 event types (WEBSOCKET_CONNECTED,
  DISCONNECTED, RECONNECTING, FAILED, SUBSCRIPTION_CREATED/REMOVED,
  TRANSPORT_FALLBACK/RESTORED, LIVE_BALANCE/TRANSFER/BLOCK)
- All 8 EVM chains: Ethereum, Polygon, Arbitrum, Optimism, Base, BNB,
  Avalanche, Fantom with default WS + HTTP endpoints
- 101 new tests across 6 test files, 985 total tests passing
@linuxninja39 linuxninja39 merged commit d1f2bdd into main Feb 18, 2026
1 check passed
@linuxninja39 linuxninja39 deleted the merge/ev-essv branch February 18, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant