You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: discv5/discv5-theory.md
+31-66Lines changed: 31 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -472,7 +472,7 @@ Implementations may maintain additional indices for efficient retrieval by servi
472
472
IP prefix.
473
473
474
474
Expired advertisements are removed automatically. Once an advertisement expires, it is no longer returned in
475
-
lookup responses and no longer contributes to waiting-time calculations.
475
+
lookup responses.
476
476
477
477
If a registrar receives a registration request for an advertisement that is already present in its ad cache, the
478
478
registrar may treat the request as a renewal or ignore it, depending on the renewal semantics specified by the
@@ -484,7 +484,7 @@ service.
484
484
Registrars use admission control to decide whether and when an incoming registration request for an advertisement may be admitted to the
485
485
ad cache.
486
486
487
-
Admission is based on a waiting-time mechanism. If an advertisement is not admitted immediately, the registrar
487
+
Admission is based on a **waiting-time mechanism**. If an advertisement is not admitted immediately, the registrar
488
488
returns a ticket and a waiting time. This mechanism promotes diversity in the ad cache and avoids requiring
489
489
registrars to keep unbounded per-request state for pending registrations.
490
490
@@ -506,27 +506,25 @@ registrar treats the request as a new registration attempt or rejects it, depend
506
506
507
507
A ticket is a registrar-issued object that allows an advertiser to retry a registration attempt after waiting.
508
508
509
-
A ticket is bound to the advertisement, the registrar, and timing information. The advertiser uses the latest
510
-
ticket issued by the registrar when retrying the registration. The exact ticket encoding, signature format, and
511
-
signature domain are specified in the wire-format document.
509
+
A ticket is bound to the advertisement, the registrar, and timing information. The advertiser uses the latest ticket issued by the registrar when retrying the registration. The exact ticket encoding, signature format, and signature domain are specified in the wire-format document.
512
510
513
511
Algorithmically, a ticket contains enough information for the registrar to verify:
514
512
515
513
- the advertisement to which the ticket applies;
516
-
- the time at which the ticket was first issued;
517
-
- the time at which the ticket was last updated;
518
-
- the remaining waiting time reported to the advertiser;
514
+
- the registrar time at which the ticket was first issued;
515
+
- the registrar time at which the ticket was last updated;
516
+
- the remaining waiting duration reported to the advertiser;
519
517
- that the ticket was issued by the registrar.
520
518
519
+
The timestamps in the ticket are generated and interpreted by the registrar. The advertiser does not need to compare those timestamps with its own local clock. The advertiser only needs to wait for the relative waiting duration reported by the registrar before retrying.
520
+
521
521
A retry is valid only during the registration window associated with the ticket:
522
522
523
523
tmod + twait ≤ now ≤ tmod + twait + δ
524
524
525
-
where `tmod` is the ticket modification time, `twait` is the remaining wait time reported in the ticket, and `δ`
526
-
is the registration window duration.
525
+
where `tmod` is the ticket modification time according to the registrar's clock, `twait` is the remaining waiting duration reported to the advertiser, `δ` is the registration window duration, and `now` is the registrar's current time when processing the retry.
527
526
528
-
If the advertiser retries before the scheduled time, the registrar may ignore the request. If the advertiser
529
-
retries after the registration window, the advertiser loses the accumulated waiting time and must start over.
527
+
The advertiser does not use `tmod` to schedule the retry and does not need its clock to be synchronised with the registrar's clock. The advertiser waits for the relative duration `twait` using its own local timer, then retries with the ticket. The registrar validates the retry window using its own clock when the ticket is presented again.
530
528
531
529
### Waiting-Time Function
532
530
@@ -588,7 +586,7 @@ The tree is updated when advertisements are admitted or expire. When an advertis
588
586
the path corresponding to the advertiser's IP address are incremented. When the advertisement expires or is removed,
589
587
those counters are decremented.
590
588
591
-
The same principle can be applied to IPv6 by using the IPv6 address length.
589
+
TODO: IPv6
592
590
593
591
### Waiting-Time Lower Bound
594
592
@@ -646,17 +644,13 @@ An advertiser registers an advertisement by sending a registration request to a
646
644
The first registration request for an advertisement is sent without a ticket. The registrar either admits the
647
645
advertisement immediately or returns a ticket and a waiting time.
648
646
649
-
If the registrar returns a ticket, the advertiser waits for the indicated duration and retries with the latest
650
-
ticket. If the registrar recomputes the waiting time and determines that more waiting is required, it returns an
651
-
updated ticket and waiting time. The advertiser repeats this process until the advertisement is admitted or the
652
-
attempt fails.
647
+
If the registrar returns a ticket, the advertiser waits before retrying with the latest ticket. A single waiting interval SHOULD NOT exceed `E`, the advertisement expiry duration. If the registrar still cannot admit the advertisement after the retry, it may return an updated ticket and a new waiting time.
648
+
649
+
The protocol does not define a fixed maximum total duration for a registration attempt. An implementation MAY abandon an attempt after a local timeout, after a configured maximum number of retries, or if the registrar is considered unusable according to local DISC-NG liveness policy.
653
650
654
-
A registration attempt fails if the registrar is unreachable, rejects the request, returns malformed responses, or
655
-
is otherwise considered unusable according to local DISC-NG liveness policy. On failure, the advertiser removes
656
-
the registrar from the pending state for that bucket and may select another registrar.
651
+
A registration attempt fails if the registrar is unreachable, rejects the request, returns malformed responses, the registration window is missed, a local retry or timeout limit is reached, or the registrar is otherwise considered unusable according to local DISC-NG liveness policy. On failure, the advertiser removes the registrar from the pending state for that bucket and may select another registrar.
657
652
658
-
When registration succeeds, the advertisement remains stored by the registrar until it expires, unless it is removed
659
-
earlier by registrar policy.
653
+
When registration succeeds, the advertisement remains stored by the registrar until it expires, unless it is removed earlier by registrar policy.
660
654
661
655
Registration responses may include additional ENRs selected from the registrar's view of the service table. The
662
656
advertiser may use these ENRs to update its advertise table `B(s)` after validating the ENRs and checking DISC-NG
@@ -683,49 +677,31 @@ set of registrars, but to maintain sufficient active or pending placements acros
683
677
684
678
A discoverer looking for service `s` queries registrars selected from its search table `B(s)`.
685
679
686
-
Lookup starts from the furthest bucket from `s` and progresses towards the closest bucket. The discoverer queries
687
-
up to `Klookup` registrars per bucket and stops when it has collected at least `Flookup` distinct advertisers or
688
-
when no unqueried registrars remain.
689
-
690
-
For each bucket `bᵢ(s)`, the discoverer selects candidate registrars from the bucket. The same registrar should not
691
-
be queried repeatedly during a single lookup unless the implementation has exhausted other candidates and chooses
692
-
to retry according to local policy.
680
+
Lookup proceeds bucket by bucket, starting from the bucket furthest from `s` and progressing towards buckets closer to `s`. For each bucket `bᵢ(s)`, the discoverer selects candidate registrars from that bucket and queries up to `Klookup` of them.
693
681
694
-
If a queried registrar is unreachable, times out, or returns a malformed response, the discoverer treats that query
695
-
as failed and continues with another candidate. Repeated failures may cause the registrar to be temporarily excluded
696
-
from DISC-NG operations.
682
+
A registrar may return advertisements for service `s`. The discoverer validates the returned advertisements, extracts the advertised ENRs, and de-duplicates them by advertiser identity. Advertisements are candidate results for the target service.
697
683
698
-
Lookup responses may include advertisements and additional ENRs. Advertisements are candidate results for the target
699
-
service. Additional ENRs are used to improve the discoverer's search table `B(s)`.
684
+
The lookup terminates when the discoverer has collected enough distinct advertisers for its local or service-specific purpose, or when no unqueried registrars remain. The required number of advertisers is determined by the application or service using DISC-NG, rather than by the DISC-NG lookup procedure itself.
700
685
701
-
The discoverer validates returned ENRs before using them. Invalid ENRs are ignored.
686
+
The same registrar should not be queried repeatedly during a single lookup unless the implementation has exhausted other candidates and chooses to retry according to local policy.
702
687
703
-
### Lookup Responses
688
+
If a queried registrar is unreachable, times out, or returns a malformed response, the discoverer treats that query as failed and continues with another candidate. Repeated failures may cause the registrar to be temporarily excluded from DISC-NG operations.
704
689
705
-
A registrar receiving a lookup request for service `s` returns up to `Freturn` advertisements for that service from
706
-
its ad cache.
690
+
Lookup responses may also include additional ENRs. These ENRs are not lookup results; they are auxiliary routing information used to improve the discoverer's search table `B(s)`.
707
691
708
-
A registrar may also return additional ENRs selected from its view of the service table. The requester uses these
709
-
ENRs to update its local service table `B(s)`. The exact encoding of returned advertisements and neighbour ENRs is
710
-
specified in the wire-format document.
692
+
The discoverer validates returned ENRs before using them. Invalid ENRs are ignored.
711
693
712
-
The registrar should return only non-expired advertisements. It may choose which advertisements to return when more
713
-
than `Freturn` advertisements for the service are present in its ad cache.
694
+
### Lookup Responses
714
695
715
-
Additional neighbour ENRs are not themselves lookup results. They are auxiliary routing information used to improve
716
-
future registration and lookup operations.
696
+
A registrar receiving a lookup request for service `s` returns up to `Freturn` advertisements for that service from its ad cache.
717
697
718
-
### Distinct Advertisers
698
+
The registrar MUST NOT return expired advertisements. If more than `Freturn` advertisements for the service are present in its ad cache, the registrar SHOULD return a pseudo-random subset of at most `Freturn` advertisements. The selection procedure SHOULD avoid deterministic bias towards the same advertisers across repeated lookup requests.
719
699
720
-
Lookup termination is based on the number of distinct advertisers, not the number of raw advertisements or ENRs
721
-
received.
700
+
A registrar can also return additional ENRs selected from its view of the service table for `s`. These ENRs are not lookup results; they are auxiliary routing information used to improve future registration and lookup operations.
722
701
723
-
A discoverer may receive the same advertiser from multiple registrars and de-duplicates results before deciding
724
-
whether `Flookup` has been reached.
702
+
The registrar SHOULD select additional ENRs across buckets of its service table, for example by returning at most one randomly selected node from each bucket. This helps the requester improve its local service table `B(s)` across the service-centred key space, rather than only learning nodes closest to `s`.
725
703
726
-
Two advertisements identify the same advertiser if they resolve to the same advertised node identity according to
727
-
the ENR identity scheme. Implementations should use the ENR node ID, rather than response source or registrar
728
-
identity, for de-duplication.
704
+
The requester uses returned neighbour ENRs to update its local service table `B(s)` after validating the ENRs, checking DISC-NG capability, and applying local DISC-NG usability policy. The exact encoding of returned advertisements and neighbour ENRs is specified in the wire-format document.
729
705
730
706
### Updating the Search Table During Lookup
731
707
@@ -738,9 +714,7 @@ An ENR learned through lookup is eligible for insertion into `B(s)` only if:
738
714
3. the node is not temporarily excluded by local DISC-NG usability policy;
739
715
4. the node satisfies ordinary Discovery v5 liveness requirements, or is scheduled for ordinary liveness verification.
740
716
741
-
Implementations may insert learned ENRs immediately with an unverified flag and verify liveness asynchronously, or
742
-
may require liveness verification before insertion. However, implementations should avoid selecting unverified nodes
743
-
for DISC-NG operations if doing so would conflict with ordinary Discovery v5 table-maintenance rules.
717
+
Implementations may insert learned ENRs immediately with an unverified flag and verify liveness asynchronously.
744
718
745
719
## Parameters
746
720
@@ -754,12 +728,10 @@ The DISC-NG algorithms use the following parameters:
754
728
|`Flookup`| Target number of distinct advertisers collected by lookup |`30`|
0 commit comments