Skip to content

Commit c3a6007

Browse files
committed
discv5-theory: recommend an algorithm for auxiliary ENR selection in lookup responses
The Lookup Responses section says the registrar "may also return additional ENRs selected from its view of the service table" but doesn't specify how the selection is made. Add a recommended algorithm: when the wire-format request carries a list of topic-distances at which the requester's service table has free space, the registrar selects at most one ENR per requested distance from the corresponding bucket of its own B(s), up to an implementation-defined total cap. One-per-distance keeps responses compact and spreads coverage across the requester's free buckets rather than overrepresenting a single distance. Companion to the wire-spec definition of the topic-distance list in REGTOPIC and TOPICQUERY.
1 parent c041e92 commit c3a6007

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

discv5/discv5-theory.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,24 @@ Registration responses may include additional ENRs selected from the registrar's
656656
advertiser may use these ENRs to update its advertise table `B(s)` after validating the ENRs and checking DISC-NG
657657
capability.
658658

659+
When the wire-format request carries a list of topic-distances at which the requester's own service table has
660+
free space, the registrar SHOULD bias the selection of auxiliary ENRs toward those distances. The recommended
661+
algorithm is:
662+
663+
1. For each topic-distance in the requester's list, in order, select at most one ENR from the corresponding
664+
bucket `bd(s)` of the registrar's own service table.
665+
2. Stop once an implementation-defined cap on the number of auxiliary ENRs has been reached, or once every
666+
requested distance has been visited.
667+
668+
Picking at most one ENR per requested distance keeps the response compact and spreads coverage across the
669+
requester's free buckets rather than overrepresenting a single distance. It also serves as a security measure
670+
against Sybil and eclipse attacks: a registrar whose service table happens to contain many ENRs at one distance
671+
— for example because an attacker controls a cluster of node identities clustered in that bucket — cannot
672+
flood a single response with those ENRs and thereby colonise the requester's `B(s)` at that distance. ENRs
673+
that fail local validation rules (for example endpoint-versus-source checks) SHOULD be skipped.
674+
675+
The same auxiliary-ENR selection rule applies to lookup responses (see [Lookup Responses](#lookup-responses)).
676+
659677
### Renewal
660678

661679
An admitted advertisement remains stored until its expiry time `E`.
@@ -699,6 +717,8 @@ The registrar MUST NOT return expired advertisements. If more than `Freturn` adv
699717

700718
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.
701719

720+
The auxiliary-ENR selection rule defined for registration responses (see [Registration Procedure](#registration-procedure)) applies here as well: when the wire-format request carries a list of topic-distances, the registrar SHOULD bias its selection toward those distances using the same one-ENR-per-requested-distance algorithm.
721+
702722
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`.
703723

704724
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.

0 commit comments

Comments
 (0)