Skip to content

fix(service-disco): wait time cap#2834

Merged
SionoiS merged 9 commits into
masterfrom
fix--wait-time-cap
Jul 16, 2026
Merged

fix(service-disco): wait time cap#2834
SionoiS merged 9 commits into
masterfrom
fix--wait-time-cap

Conversation

@SionoiS

@SionoiS SionoiS commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

A much better version of #2825

Thanks @jm-clius

@SionoiS SionoiS self-assigned this Jul 15, 2026
@SionoiS
SionoiS requested review from jm-clius and tinniaru3005 July 15, 2026 13:51
@SionoiS SionoiS changed the title fix wait time cap fix(service-disco): wait time cap Jul 15, 2026
@codecov-commenter

codecov-commenter commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.23%. Comparing base (bb37d02) to head (5bc2bf7).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
libp2p/protocols/service_discovery/registrar.nim 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2834   +/-   ##
=======================================
  Coverage   81.23%   81.23%           
=======================================
  Files         170      170           
  Lines       30750    30750           
  Branches       13       12    -1     
=======================================
+ Hits        24979    24981    +2     
+ Misses       5771     5769    -2     
Files with missing lines Coverage Δ
libp2p/protocols/service_discovery/registrar.nim 67.25% <66.66%> (+0.66%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SionoiS
SionoiS marked this pull request as ready for review July 15, 2026 15:53
@SionoiS
SionoiS requested review from a team, gmelodie and richard-ramos July 15, 2026 15:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves Service Discovery registrar behavior by capping computed wait times to advertExpiry (so the registrar never asks an advertiser to wait longer than the advert’s own lifetime) and by making registration() use second-level time granularity consistently.

Changes:

  • Clamp waitingTime()’s returned Duration to <= discoConfig.advertExpiry.
  • Replace the max/min pair with a single clamp() call for bounding the floating-point wait value.
  • Quantize registration()’s now timestamp to whole seconds and add tests covering both the wait cap and the timestamp granularity.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
libp2p/protocols/service_discovery/registrar.nim Adds an advertExpiry cap to waitingTime() and truncates registration()’s now to whole-second granularity.
tests/libp2p/service_discovery/test_registrar.nim Adds coverage for the advertExpiry cap behavior and verifies second-granularity timestamps emitted by registration().

Comment thread libp2p/protocols/service_discovery/registrar.nim Outdated
@github-project-automation github-project-automation Bot moved this from new to In Progress in nim-libp2p Jul 15, 2026
Comment thread libp2p/protocols/service_discovery/registrar.nim
Comment thread libp2p/protocols/service_discovery/registrar.nim Outdated
@SionoiS
SionoiS added this pull request to the merge queue Jul 16, 2026
Merged via the queue into master with commit 502a36a Jul 16, 2026
40 checks passed
@SionoiS
SionoiS deleted the fix--wait-time-cap branch July 16, 2026 17:41
@github-project-automation github-project-automation Bot moved this from In Progress to done in nim-libp2p Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: done

Development

Successfully merging this pull request may close these issues.

6 participants