@@ -203,13 +203,19 @@ the result set. The recommended result limit for FINDNODE queries is 16 nodes.
203203 message-type = 0x04
204204 total = total number of responses to the request
205205
206- NODES is the response to a FINDNODE or TOPICQUERY message . Multiple NODES messages may be
207- sent as responses to a single query. Implementations may place a limit on the allowed
208- maximum for ` total ` . If exceeded, additional responses may be ignored.
206+ NODES is sent as a response to FINDNODE, REGTOPIC, or TOPICQUERY. Multiple NODES messages
207+ may be sent as responses to a single query. Implementations may place a limit on the
208+ allowed maximum for ` total ` . If exceeded, additional responses may be ignored.
209209
210210When handling NODES as a response to FINDNODE, the recipient should verify that the
211211received nodes match the requested distances.
212212
213+ When NODES appears as a response to REGTOPIC or TOPICQUERY, it carries auxiliary ENRs
214+ selected from the responder's view of the service table for the requested topic. These
215+ ENRs are routing information for the requester to populate or refresh its own service
216+ table ` B(s) ` . They are not themselves topic registrants; the actual registered nodes are
217+ returned via TOPICNODES.
218+
213219### TALKREQ Request (0x05)
214220
215221 message-data = [request-id, protocol, request]
@@ -234,62 +240,102 @@ response data.
234240
235241### REGTOPIC Request (0x07)
236242
237- ** NOTE: the content and semantics of this message are not final.**
238- ** Implementations should not respond to or send these messages.**
243+ message-data = [request-id, topic, ENR, ticket,
244+ [topic-distance₁, topic-distance₂, ..., topic-distanceₙ]]
245+ message-type = 0x07
246+ topic = 32-byte service / topic identifier
247+ ENR = current node record of sender
248+ ticket = opaque byte array containing a ticket previously issued by the
249+ recipient registrar; empty (`0x80`) on first attempt
250+ topic-distanceₙ = positive integer log2 distance from `topic` where the sender's
251+ service table `B(topic)` still has space
239252
240- message-data = [request-id, topic, ENR, ticket]
241- message-type = 0x07
242- node-record = current node record of sender
243- ticket = byte array containing ticket content
253+ REGTOPIC asks the recipient registrar to register the sender (identified by ` ENR ` ) for
254+ service ` topic ` . If the sender has a ticket from a previous registration attempt with this
255+ registrar, it must present the ticket; otherwise ` ticket ` is the empty byte array.
244256
245- REGTOPIC attempts to register the sender for the given topic. If the requesting node has a
246- ticket from a previous registration attempt, it must present the ticket. Otherwise
247- ` ticket ` is the empty byte array (RLP: ` 0x80 ` ). The ticket must be valid and its waiting
248- time must have elapsed before using the ticket .
257+ The ` topic-distance ` list carries the sender's "send me ENRs at these distances" hint to
258+ the recipient: when returning auxiliary ENRs, the recipient should prefer ENRs whose log2
259+ distance to ` topic ` matches one of the listed values, so the response helps the sender
260+ populate its service table .
249261
250- REGTOPIC is always answered by a TICKET response. The requesting node may also receive a
251- REGCONFIRMATION response when registration is successful. It may take up to 10s for the
252- confirmation to be sent .
262+ REGTOPIC is always answered with a single REGCONFIRMATION response. The recipient may
263+ additionally send zero or more NODES responses carrying auxiliary ENRs selected from its
264+ view of the service table .
253265
254- ### TICKET Response (0x08)
266+ See the [ theory section on tickets] and [ theory section on registrar admission control]
267+ for the registrar's waiting-time semantics.
255268
256- ** NOTE: the content and semantics of this message are not final.**
257- ** Implementations should not respond to or send these messages.**
269+ ### REGCONFIRMATION Response (0x08)
258270
259- message-data = [request-id, ticket, wait-time]
271+ message-data = [request-id, total, ticket, wait-time]
260272 message-type = 0x08
261- ticket = an opaque byte array representing the ticket
262- wait-time = time to wait before registering, in seconds
263-
264- TICKET is the response to REGTOPIC. It contains a ticket which can be used to register for
265- the requested topic after ` wait-time ` has elapsed. See the [ theory section on tickets] for
266- more information.
267-
268- ### REGCONFIRMATION Response (0x09)
269-
270- ** NOTE: the content and semantics of this message are not final.**
271- ** Implementations should not respond to or send these messages.**
272-
273- message-data = [request-id, topic]
274- message-type = 0x09
275273 request-id = request-id of REGTOPIC
274+ total = total number of responses (REGCONFIRMATION + NODES) to the request
275+ ticket = ticket issued by the registrar for the next attempt;
276+ empty byte array (RLP: `0x80`) when the registration was admitted
277+ wait-time = milliseconds to wait before submitting the next REGTOPIC attempt
278+ with the returned `ticket`. When `ticket` is empty, `wait-time` carries
279+ the advertisement lifetime instead.
280+
281+ REGCONFIRMATION is the response to REGTOPIC. It is sent immediately by the registrar and
282+ plays two roles, distinguished by the length of ` ticket ` :
283+
284+ - If ` ticket ` is the empty byte array, the advertisement has been admitted to the
285+ registrar's ad cache. ` wait-time ` indicates the advertisement lifetime; the advertiser
286+ should renew before that lifetime elapses to remain in the cache.
287+ - If ` ticket ` is non-empty, the advertisement was not admitted on this attempt. The
288+ sender must wait at least ` wait-time ` milliseconds and re-attempt the registration with
289+ the returned ` ticket ` . See the [ theory section on tickets] and the [ theory section on
290+ the waiting-time function] .
291+
292+ The ` total ` field announces the total number of responses (this REGCONFIRMATION plus any
293+ NODES messages carrying auxiliary ENRs) that the registrar will send for this request.
294+
295+ ### TOPICQUERY Request (0x09)
296+
297+ message-data = [request-id, topic,
298+ [topic-distance₁, topic-distance₂, ..., topic-distanceₙ]]
299+ message-type = 0x09
300+ topic = 32-byte service / topic identifier
301+ topic-distanceₙ = positive integer log2 distance from `topic` where the sender's
302+ service table `B(topic)` still has space
303+
304+ TOPICQUERY asks the recipient to return registered advertisers for the given ` topic ` from
305+ its ad cache. The recipient sends zero or more TOPICNODES responses containing matching
306+ advertiser ENRs, and may additionally send zero or more NODES responses carrying
307+ auxiliary ENRs selected from its service-table view (see NODES).
308+
309+ The ` topic-distance ` list serves the same purpose as in REGTOPIC: it tells the recipient
310+ which log2 distances from ` topic ` the sender's service table still has room for, so the
311+ recipient can choose useful auxiliary ENRs to include in its NODES responses.
312+
313+ See the [ theory section on lookup responses] for the discoverer-side termination semantics
314+ (distinct-advertisers count) and the [ theory section on parameters] for ` Freturn ` .
315+
316+ ### TOPICNODES Response (0x0A)
276317
277- REGCONFIRMATION notifies the recipient about a successful registration for the given
278- topic. This call is sent by the advertisement medium after the time window for
279- registration has elapsed on a topic queue.
318+ message-data = [request-id, total, [ENR, ...]]
319+ message-type = 0x0a
320+ request-id = request-id of TOPICQUERY
321+ total = total number of responses (NODES + TOPICNODES) to the request
280322
281- ### TOPICQUERY Request (0x0A)
323+ TOPICNODES is the dedicated response to TOPICQUERY carrying advertiser ENRs that are
324+ currently registered for the requested topic in the recipient's ad cache. Multiple
325+ TOPICNODES messages may be sent for a single TOPICQUERY.
282326
283- ** NOTE: the content and semantics of this message are not final.**
284- ** Implementations should not respond to or send these messages.**
327+ The ` total ` field announces the total number of responses (TOPICNODES messages plus any
328+ NODES messages carrying auxiliary ENRs) the recipient will send for this request.
329+ Implementations may place a limit on the allowed maximum for ` total ` ; if exceeded,
330+ additional responses may be ignored.
285331
286- message-data = [request-id, topic]
287- message-type = 0x0a
288- topic = 32-byte topic hash
332+ The recipient should return only non-expired advertisements from its ad cache. When the
333+ ad cache contains more than ` Freturn ` advertisements for the topic, the recipient
334+ selects which advertisements to return; the exact selection policy is implementation
335+ defined.
289336
290- TOPICQUERY requests nodes in the [ topic queue] of the given topic. The recipient of this
291- request must send one or more NODES messages containing node records registered for the
292- topic.
337+ TOPICNODES carries only registered advertisers. Auxiliary routing information for the
338+ sender's service table is carried separately via NODES responses.
293339
294340## Test Vectors
295341
@@ -299,5 +345,9 @@ A collection of test vectors for this specification can be found at
299345[ handshake section ] : ./discv5-theory.md#handshake-steps
300346[ topic queue ] : ./discv5-theory.md#topic-table
301347[ theory section on tickets ] : ./discv5-theory.md#tickets
348+ [ theory section on registrar admission control ] : ./discv5-theory.md#admission-control
349+ [ theory section on the waiting-time function ] : ./discv5-theory.md#waiting-time-function
350+ [ theory section on lookup responses ] : ./discv5-theory.md#lookup-responses
351+ [ theory section on parameters ] : ./discv5-theory.md#parameters
302352[ EIP-778 ] : ../enr.md
303353[ discv5 wire test vectors ] : ./discv5-wire-test-vectors.md
0 commit comments