waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
162 stars 41 forks source link

feat: add keep alive to Filter #1970

Closed weboko closed 2 months ago

weboko commented 2 months ago

Problem

Filter doesn't keep keep subscription forever and requires periodic pings.

Solution

Implement keep alive feature to do automatic pings to the peers.

Notes

weboko commented 2 months ago

Draft for now before https://github.com/waku-org/js-waku/pull/1958 is merged.

github-actions[bot] commented 2 months ago

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 181.09 KB (+0.16% 🔺) 3.7 s (+0.16% 🔺) 1.4 s (-17.96% 🔽) 5 s
Waku Simple Light Node 181.03 KB (-0.09% 🔽) 3.7 s (-0.09% 🔽) 1.7 s (+9.31% 🔺) 5.3 s
ECIES encryption 23.08 KB (0%) 462 ms (0%) 448 ms (+181.83% 🔺) 909 ms
Symmetric encryption 22.55 KB (0%) 452 ms (0%) 330 ms (-25.77% 🔽) 781 ms
DNS discovery 72.42 KB (0%) 1.5 s (0%) 837 ms (+3% 🔺) 2.3 s
Peer Exchange discovery 74.1 KB (0%) 1.5 s (0%) 1.1 s (+4% 🔺) 2.5 s
Local Peer Cache Discovery 67.64 KB (0%) 1.4 s (0%) 657 ms (-31.03% 🔽) 2.1 s
Privacy preserving protocols 38.87 KB (0%) 778 ms (0%) 496 ms (-7.34% 🔽) 1.3 s
Waku Filter 111.76 KB (+0.23% 🔺) 2.3 s (+0.23% 🔺) 1.2 s (+62.87% 🔺) 3.4 s
Waku LightPush 110.11 KB (0%) 2.3 s (0%) 938 ms (-5.49% 🔽) 3.2 s
History retrieval protocols 110.72 KB (0%) 2.3 s (0%) 828 ms (+0.55% 🔺) 3.1 s
Deterministic Message Hashing 7.29 KB (0%) 146 ms (0%) 77 ms (+17.66% 🔺) 223 ms
adklempner commented 2 months ago

Why can't we use the existing keep alive manager for this? Or why is it insufficient?

weboko commented 2 months ago

Why can't we use the existing keep alive manager for this? Or why is it insufficient?

This is because keepAliveManager does libp2p pings Overall something like that can be implemented for filter pings once logic becomes more sophisticated: perhaps if next steps are implemented from here https://github.com/waku-org/js-waku/issues/1923#issuecomment-2070939508