Skip to content

Conversation

@weboko
Copy link
Collaborator

@weboko weboko commented Aug 8, 2025

Problem / Description

We observed some questionable behavior of PX discovery in tests and a lot of them were commented for a while.

For example:
https://github.com/waku-org/js-waku/blob/459fe96fe6beeec61f1403829b49bd07d2d559ef/packages/tests/tests/peer-exchange/query.spec.ts#L144

Additionally while investigating how js-waku behaves during cold/warm start - I observed that behavior can be improved.

Solution

This PR brings following changes:

  • increases query window from 10 peers pers query to 60 peers;
  • implements recurring quarries to existing connections with time interval of 30s;
  • lightens implementation of PX/Discovery by removing dead and unnecessary code;
  • adds UT and E2E tests;

Notes

Resolves:

Relevant to: #2276


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.

@weboko weboko requested a review from a team as a code owner August 8, 2025 13:36
@weboko weboko requested a review from Copilot August 8, 2025 13:37
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 significant improvements to the peer exchange discovery functionality to address questionable behavior observed in tests and enhance the cold/warm start behavior of js-waku.

  • Increases query window from 10 to 60 peers per query and implements 30-second recurring queries
  • Replaces the existing peer exchange implementation with a more efficient one that removes dead code
  • Adds comprehensive unit tests and re-enables previously commented E2E tests

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/tests/tests/peer-exchange/query.spec.ts Completely removed flaky test file that was causing CI issues
packages/tests/tests/peer-exchange/peer_exchange.spec.ts Updated tests to use new API and re-enabled previously skipped tests
packages/tests/tests/peer-exchange/pe.optional.spec.ts Moved DNS discovery test to appropriate location
packages/tests/tests/peer-exchange/continuous_discovery.spec.ts Removed obsolete continuous discovery test file
packages/tests/tests/peer-exchange/compliance.spec.ts Updated to use new peer exchange implementation
packages/tests/tests/dns-discovery/dns_discovery.optional.spec.ts New DNS discovery test file moved from peer exchange
packages/tests/tests/dns-discovery/dns-peer-discovery.spec.ts Fixed import path
packages/tests/tests/connection-mananger/discovery_dialer.spec.ts Re-enabled discovery dialer tests
packages/discovery/src/peer-exchange/waku_peer_exchange_discovery.ts Removed old peer exchange discovery implementation
packages/discovery/src/peer-exchange/peer_exchange_discovery.ts New streamlined peer exchange discovery implementation
packages/discovery/src/peer-exchange/peer_exchange_discovery.spec.ts Comprehensive unit tests for new implementation
packages/discovery/src/peer-exchange/peer_exchange.ts Refactored peer exchange class with improved error handling
packages/discovery/src/peer-exchange/peer_exchange.spec.ts Unit tests for the peer exchange class
packages/discovery/src/peer-exchange/index.ts Updated exports to use new implementation
packages/discovery/src/peer-exchange/constants.ts New constants file with updated peer request limits
packages/discovery/src/index.ts Updated exports structure
packages/discovery/src/dns/dns.spec.ts Removed debug console.log statement

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku node 70.34 KB (-0.08% 🔽) 1.5 s (-0.08% 🔽) 853 ms (+28.09% 🔺) 2.3 s
Waku Simple Light Node 121.66 KB (-0.12% 🔽) 2.5 s (-0.12% 🔽) 785 ms (+48.62% 🔺) 3.3 s
ECIES encryption 20.8 KB (0%) 417 ms (0%) 466 ms (+171.28% 🔺) 882 ms
Symmetric encryption 20.3 KB (0%) 407 ms (0%) 267 ms (+32.45% 🔺) 673 ms
DNS discovery 51.6 KB (-0.03% 🔽) 1.1 s (-0.03% 🔽) 686 ms (+46.2% 🔺) 1.8 s
Peer Exchange discovery 52.34 KB (-0.06% 🔽) 1.1 s (-0.06% 🔽) 564 ms (-15.32% 🔽) 1.7 s
Local Peer Cache Discovery 46.03 KB (-0.21% 🔽) 921 ms (-0.21% 🔽) 615 ms (+80.6% 🔺) 1.6 s
Privacy preserving protocols 53.61 KB (+0.14% 🔺) 1.1 s (+0.14% 🔺) 451 ms (-2.72% 🔽) 1.6 s
Waku Filter 55.35 KB (+0.05% 🔺) 1.2 s (+0.05% 🔺) 732 ms (+12.66% 🔺) 1.9 s
Waku LightPush 52.98 KB (-0.05% 🔽) 1.1 s (-0.05% 🔽) 539 ms (-4.99% 🔽) 1.6 s
History retrieval protocols 59.31 KB (+0.01% 🔺) 1.2 s (+0.01% 🔺) 702 ms (+3.24% 🔺) 1.9 s
Deterministic Message Hashing 28.44 KB (0%) 569 ms (0%) 525 ms (+58.07% 🔺) 1.1 s

@weboko weboko force-pushed the weboko/px-improve branch from 3861807 to 3e80fda Compare August 12, 2025 21:31
@weboko weboko merged commit 95da57a into master Aug 14, 2025
12 checks passed
@weboko weboko deleted the weboko/px-improve branch August 14, 2025 07:47
@weboko weboko mentioned this pull request Aug 14, 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.

3 participants