Skip to content

Conversation

@adklempner
Copy link
Member

@adklempner adklempner commented Jul 17, 2025

Problem / Description

js-waku only supported the LightPush v2 protocol.
Clients could not benefit from the new LightPush v3 specification which:

  1. Defines a cleaner request/response structure (requestId, statusCode, statusDesc, …)
  2. Returns machine-readable status codes so that applications can react to failures

Solution

This PR adds full LightPush v3 support while remaining 100 % backward-compatible with v2.

Key changes

  1. Core Protocol
    • Added PushRpcV3 handler (packages/core/src/lib/light_push/push_rpc_v3.ts) and new codec /vac/waku/lightpush/3.0.0.
    • Generated V3 proto messages (LightPushRequestV3, LightPushResponseV3) with correct field numbers.
    LightPushCore now negotiates the protocol per peer: try v3, fall back to v2 if the peer does not advertise or rejects v3.

  2. Error Handling
    • Introduced LightPushStatusCode enum and toLightPushError/getStatusDescription helpers.
    LightPushCore maps status codes ↔ meaningful LightPushError values.
    • SDK returns per-peer protocolVersion and full failure details (statusCode + statusDesc).

  3. SDK Enhancements
    packages/sdk/src/light_push/light_push.ts automatically selects v3 when available, else v2 – no API changes for users.
    • Added retry/back-off and richer logging including protocol version.

  4. Interfaces / Utils
    • Extended @waku/interfaces with new enums and typed results (LightPushSDKResult, LightPushFailure, …).
    • Utility funcs for protocol-version inference and RLN-specific checks.

  5. Tests
    • Unit: push_rpc_v3.spec.ts covers encode/decode & status helpers.
    • Integration: Updated LightPush e2e tests to run against both v2 and v3 peers and ensure correct fallback.
    • Updated generated fixtures & mocks.

  6. Protobuf
    • Added light_push_v3.proto definitions and regenerated TypeScript (packages/proto/src/generated/light_push.ts).

Notes

• No breaking changes – the public LightPush SDK API is unchanged.
• v3 is preferred but the library gracefully downgrades to v2, enabling mixed-version networks.


Checklist

  • Code changes are covered by unit tests.
  • Code changes are covered by e2e tests.
  • Dogfooding has been performed, if feasible.
  • A test version has been published, if required.
  • All CI checks pass successfully.

@adklempner adklempner changed the title Feat/lp v3 sdk feat: implement lp-v3 error codes with backwards compatibility Jul 17, 2025
@github-actions
Copy link

github-actions bot commented Jul 17, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 72.26 KB (+1.46% 🔺) 1.5 s (+1.46% 🔺) 442 ms (+39.38% 🔺) 1.9 s
Waku Simple Light Node 123.66 KB (+0.95% 🔺) 2.5 s (+0.95% 🔺) 454 ms (+11.19% 🔺) 3 s
ECIES encryption 22.52 KB (0%) 451 ms (0%) 301 ms (+49.98% 🔺) 751 ms
Symmetric encryption 21.96 KB (0%) 440 ms (0%) 311 ms (+49.14% 🔺) 750 ms
DNS discovery 52.12 KB (+0.94% 🔺) 1.1 s (+0.94% 🔺) 273 ms (-18.94% 🔽) 1.4 s
Peer Exchange discovery 52.82 KB (+0.67% 🔺) 1.1 s (+0.67% 🔺) 317 ms (+22.39% 🔺) 1.4 s
Peer Cache Discovery 46.57 KB (+1.07% 🔺) 932 ms (+1.07% 🔺) 258 ms (-6.66% 🔽) 1.2 s
Privacy preserving protocols 54.18 KB (+1.02% 🔺) 1.1 s (+1.02% 🔺) 447 ms (+49.3% 🔺) 1.6 s
Waku Filter 55.97 KB (+0.83% 🔺) 1.2 s (+0.83% 🔺) 373 ms (-17.99% 🔽) 1.5 s
Waku LightPush 54.16 KB (+2.14% 🔺) 1.1 s (+2.14% 🔺) 348 ms (+10.98% 🔺) 1.5 s
History retrieval protocols 59.86 KB (+0.78% 🔺) 1.2 s (+0.78% 🔺) 449 ms (+28.54% 🔺) 1.7 s
Deterministic Message Hashing 28.87 KB (+1.59% 🔺) 578 ms (+1.59% 🔺) 239 ms (+22.42% 🔺) 816 ms

@adklempner adklempner force-pushed the feat/lp-v3-sdk branch 13 times, most recently from e7fe9f4 to ec4c460 Compare July 24, 2025 16:07
@adklempner adklempner force-pushed the feat/lp-v3-sdk branch 2 times, most recently from 038bb62 to a64cf0a Compare July 25, 2025 05:05
@adklempner adklempner marked this pull request as ready for review July 25, 2025 05:31
@adklempner adklempner requested a review from a team as a code owner July 25, 2025 05:31
@adklempner adklempner force-pushed the feat/lp-v3-sdk branch 6 times, most recently from e7a829e to 0edbf29 Compare July 26, 2025 00:59
* improve light push core

* move back to singualar multicodec property, enable array prop only for light push

* implement v2/v3 interop e2e test, re-add useLegacy flag, ensure e2e runs for v2 and v3
Copy link
Collaborator

@weboko weboko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will address the final changes

@weboko
Copy link
Collaborator

weboko commented Sep 2, 2025

Problem with E2E tests is due to preparation and stream aquisition taking a lot of time so that push to 2 peers results in two different messages hashes being sent due to difference in timestamp.

image

Proof:
image

Solution:
adf8408

@weboko weboko requested a review from Copilot September 3, 2025 22:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements LightPush v3 protocol support with backwards compatibility to v2. The implementation adds machine-readable status codes, cleaner request/response structure, and automatic protocol negotiation while maintaining 100% backward compatibility.

Key changes:

  • Added LightPush v3 protocol support with new codecs and message structures
  • Implemented automatic protocol negotiation (v3 preferred, fallback to v2)
  • Enhanced error handling with specific status codes and improved failure reporting

Reviewed Changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/tests/tests/light-push/v2_interop.spec.ts New integration test for v2/v3 interoperability
packages/tests/tests/light-push/multiple_pubsub.node.spec.ts Updated to test both v2 and v3 protocols with parametric tests
packages/tests/tests/light-push/index.node.spec.ts Enhanced test suite to run against both protocol versions
packages/sdk/src/waku/waku.ts Updated multicodec handling to support array of codecs
packages/sdk/src/waku/wait_for_remote_peer.ts Enhanced peer waiting logic for multiple protocol versions
packages/sdk/src/peer_manager/peer_manager.ts Added support for light-push-v2 protocol distinction
packages/sdk/src/light_push/*.ts Updated LightPush SDK with v3 support and new error types
packages/relay/src/relay.ts Updated error types from ProtocolError to LightPushError
packages/interfaces/src/*.ts Added new error enums, status codes, and result types
packages/core/src/lib/light_push/*.ts Core v3 implementation with protocol handlers and RPC classes
packages/core/src/lib/filter/filter.ts Updated to use FilterError instead of ProtocolError

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@weboko
Copy link
Collaborator

weboko commented Sep 3, 2025

dogfooding shows that this branch is stable
image

https://github.com/waku-org/js-waku/actions/runs/17447341560/job/49544923504

}
message: IMessage,
peerId: PeerId,
useLegacy: boolean = false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should eventually replace this with some kind of generic backwards-compatibility strategy for all (or at least the main) protocols

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adklempner don't understand your comment

}

if (decodedRpcV3.relayPeerCount !== undefined) {
log.info(`Message relayed to ${decodedRpcV3.relayPeerCount} peers`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the relayPeerCount be exposed to the library consumer beyond logging it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would they need this?

@weboko weboko merged commit 1625302 into master Sep 4, 2025
10 of 11 checks passed
@weboko weboko deleted the feat/lp-v3-sdk branch September 4, 2025 22:52
@weboko weboko mentioned this pull request Sep 4, 2025
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.

feat: lightPush v3

4 participants