Skip to content

feat(sds): adds ephemeral messages, delivered message callback and event #2302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

adklempner
Copy link
Member

@adklempner adklempner commented Mar 11, 2025

Problem / Description

Per the spec, SDS optionally supports ephemeral messages. These are messages that do not have the same persistence/reliability requirements as regular messages, and effectively skip the buffers.

Part of the requirement is that they are delivered right away upon receipt, which revealed that there's currently no way to notify the library consumer when a message reaches the delivered state.

Solution

Add a function for sending ephemeral messages.
Add an optional callback for delivered messages that is called whenever a message reaches that state.
Use libp2p event emitter to emit an event with the message ID when a message is delivered.
The number of optional arguments in the class constructor was getting large so I replaced it with a single options struct.

Notes


Checklist

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

Copy link

github-actions bot commented Mar 11, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 61.96 KB (0%) 1.3 s (0%) 482 ms (+31.5% 🔺) 1.8 s
Waku Simple Light Node 113.99 KB (0%) 2.3 s (0%) 601 ms (+25.54% 🔺) 2.9 s
ECIES encryption 22.93 KB (0%) 459 ms (0%) 267 ms (+64.09% 🔺) 726 ms
Symmetric encryption 22.37 KB (0%) 448 ms (0%) 253 ms (+9.12% 🔺) 701 ms
DNS discovery 50.3 KB (0%) 1.1 s (0%) 254 ms (-13.85% 🔽) 1.3 s
Peer Exchange discovery 50.71 KB (0%) 1.1 s (0%) 609 ms (-3.3% 🔽) 1.7 s
Local Peer Cache Discovery 43.81 KB (0%) 877 ms (0%) 378 ms (+24.9% 🔺) 1.3 s
Privacy preserving protocols 52.86 KB (0%) 1.1 s (0%) 358 ms (-7.53% 🔽) 1.5 s
Waku Filter 54.84 KB (0%) 1.1 s (0%) 251 ms (-30.04% 🔽) 1.4 s
Waku LightPush 52.24 KB (0%) 1.1 s (0%) 382 ms (+55.21% 🔺) 1.5 s
History retrieval protocols 52.43 KB (0%) 1.1 s (0%) 320 ms (-21.18% 🔽) 1.4 s
Deterministic Message Hashing 7.33 KB (0%) 147 ms (0%) 79 ms (-38.5% 🔽) 225 ms

@adklempner adklempner marked this pull request as ready for review March 11, 2025 22:46
@adklempner adklempner requested a review from a team as a code owner March 11, 2025 22:46
* @param payload - The payload to send.
* @param callback - A callback function that returns a boolean indicating whether the message was sent successfully.
*/
public sendEphemeralMessage(
Copy link
Collaborator

Choose a reason for hiding this comment

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

generally curious why you separate ephemeral from regular messages and not doing single send entry?

Copy link
Member Author

@adklempner adklempner Mar 13, 2025

Choose a reason for hiding this comment

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

Initially I tried that but decided that:

  1. the logic is different enough that it doesn't look clean in the code
  2. the concept is different enough that I want it to be as explicit/obvious as possible for the library consumer when an ephemeral message is being used. I don't believe it will be used often but we will see

@adklempner adklempner force-pushed the feat/sds-ephemeral branch 2 times, most recently from f43d4d9 to 3ba0f16 Compare March 25, 2025 21:07
@@ -59,6 +59,7 @@
"node": ">=20"
},
"dependencies": {
"@libp2p/interface": "^2.7.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's make it strictly 2.7.0

@adklempner adklempner merged commit 18e08f9 into master Apr 22, 2025
10 of 11 checks passed
@adklempner adklempner deleted the feat/sds-ephemeral branch April 22, 2025 14:38
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.

sds: add optional support for ephemeral messages
3 participants