Skip to content

Conversation

@nimrod-teich
Copy link
Contributor

This adds WebSocket support for REST POST requests with plain JSON payloads, enabling chains like Stellar/XRP that use WebSocket with non-JSON-RPC messages.

Key changes:

  • Add RestWebsocketManager for consumer-side plain JSON WebSocket handling
  • Add RestWsConnector and RestWsConnection for provider-side WebSocket pool
  • Add RestWsChainProxy for provider to communicate with node over WebSocket
  • Modify RestChainParser to handle 'WEBSOCKET' connection type
  • Update ChainRouter to select WebSocket proxy when node URL is ws/wss
  • Allow ws/wss schemes in REST API endpoint validation
  • Propagate 'websocket' extension via AdditionalExtensions in relay data

The implementation mirrors the existing JSON-RPC WebSocket pattern:

  1. Consumer opens WebSocket, extracts 'command' or 'method' from JSON
  2. Consumer communicates with provider via gRPC with 'websocket' extension
  3. Provider routes to RestWsChainProxy which sends plain JSON to node

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • read the contribution guide
  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the main branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

This adds WebSocket support for REST POST requests with plain JSON payloads,
enabling chains like Stellar/XRP that use WebSocket with non-JSON-RPC messages.

Key changes:
- Add RestWebsocketManager for consumer-side plain JSON WebSocket handling
- Add RestWsConnector and RestWsConnection for provider-side WebSocket pool
- Add RestWsChainProxy for provider to communicate with node over WebSocket
- Modify RestChainParser to handle 'WEBSOCKET' connection type
- Update ChainRouter to select WebSocket proxy when node URL is ws/wss
- Allow ws/wss schemes in REST API endpoint validation
- Propagate 'websocket' extension via AdditionalExtensions in relay data

The implementation mirrors the existing JSON-RPC WebSocket pattern:
1. Consumer opens WebSocket, extracts 'command' or 'method' from JSON
2. Consumer communicates with provider via gRPC with 'websocket' extension
3. Provider routes to RestWsChainProxy which sends plain JSON to node
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

Test Results

    4 files   -     1     56 suites   - 71   14m 34s ⏱️ - 4m 58s
1 617 tests  - 1 290  1 613 ✅  - 1 285  1 💤 ±0  3 ❌ +1 
1 697 runs   - 1 290  1 693 ✅  - 1 285  1 💤 ±0  3 ❌ +1 

For more details on these failures, see this check.

Results for commit 91882aa. ± Comparison against base commit 248c649.

This pull request removes 1328 and adds 38 tests. Note that renamed tests count towards both.
github.com/lavanet/lava/v5/x/conflict ‑ TestGenesis
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestListConflictVote
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestListConflictVote/ByKey
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestListConflictVote/ByOffset
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestListConflictVote/Total
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestShowConflictVote
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestShowConflictVote/found
github.com/lavanet/lava/v5/x/conflict/client/cli ‑ TestShowConflictVote/not_found
github.com/lavanet/lava/v5/x/conflict/keeper ‑ TestCommit
github.com/lavanet/lava/v5/x/conflict/keeper ‑ TestCommit/BadVoteID
…
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestAddAttributeToError/Valid_conversion
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestConvertToJsonError/valid_json
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestMatchSpecApiByName/test1
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestMatchSpecApiByName/test2
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestMatchSpecApiByName/test3
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestParsingRequestedBlocksHeadersRest
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestParsingRequestedBlocksHeadersRest/no_metadata
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestParsingRequestedBlocksHeadersRest/with-metadata
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestRegexParsing
github.com/lavanet/lava/v5/protocol/chainlib ‑ TestRestChainParser_NilGuard
…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants