From 7e14084e28923f4d0110fff29cc47a6f8a77ccfa Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:03:38 +0000 Subject: [PATCH 01/44] resolver: plan the wording of an unregistered name --- ...026-11-20-resolver-unregistered-wording.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plans/2026-11-20-resolver-unregistered-wording.md diff --git a/plans/2026-11-20-resolver-unregistered-wording.md b/plans/2026-11-20-resolver-unregistered-wording.md new file mode 100644 index 000000000..4d4562af8 --- /dev/null +++ b/plans/2026-11-20-resolver-unregistered-wording.md @@ -0,0 +1,34 @@ +# Resolver: wording of an unregistered name + +Merges with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. + +## Problem + +After #51, the guardian or the admin can end a `.simplex` registration in its dispute period, and the registrar sets the name's expiry to 0. The resolver answers every name with expiry 0 with the message "this name has never been registered", and its README defines `unregistered` as never registered. + +## Decisions + +| # | Decision | +|---|---| +| 1 | `status` and `error` stay `unregistered` | +| 2 | message of a 404 `unregistered`: "this name is not registered" | +| 3 | price quotes of a name with expiry 0 unchanged | + +## Changes + +`scripts/resolver/service/snrc-resolve.py`: + +- the message of decision 2 +- the docstring of `read_oracle_prices`: a quote is safe for a name with expiry 0 + +`scripts/resolver/README.md`: + +- the status table: `unregistered` covers an ended registration +- the zero-expiry paragraph +- the error example +- the premium paragraph + +`scripts/resolver/service/test_snrc_resolve.py`: + +- new: the message of a name with expiry 0 does not state that it was never registered +- two test names that equate expiry 0 with never registered From e8f08a6b171951ac015eeab09561c121959cbfbc Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:04:22 +0000 Subject: [PATCH 02/44] resolver: test that an unregistered name is not called never registered --- scripts/resolver/service/test_snrc_resolve.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 46d756769..588bc24bc 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -267,7 +267,7 @@ def test_a_registrar_that_is_not_a_contract_is_an_error_not_a_free_name(self): with self.assertRaises(RuntimeError): snrc.name_status("alice.testing") - def test_zero_expiry_means_never_registered(self): + def test_zero_expiry_means_not_registered(self): snrc.eth_call = self._expiry(0) self.assertEqual( snrc.name_status("alice.testing"), @@ -301,7 +301,7 @@ def test_future_expiry_is_registered(self): self._keys("registered", future, future + self.GRACE), ) - def test_never_registered_is_not_confused_with_claimable(self): + def test_not_registered_is_not_confused_with_claimable(self): """`available(id)` is true for both, since 0 + GRACE < now.""" snrc.eth_call = self._expiry(0) self.assertEqual(snrc.name_status("alice.testing")["status"], "unregistered") @@ -512,6 +512,11 @@ def test_the_message_does_not_claim_a_trademark(self): _, body = snrc.resolve("acme.testing") self.assertNotIn("trademark", body["message"]) + def test_the_message_does_not_claim_the_name_was_never_registered(self): + snrc.eth_call = self._chain(0, False) + _, body = snrc.resolve("acme.testing") + self.assertNotIn("never", body["message"]) + def test_an_unregistered_name_has_no_reason(self): snrc.eth_call = self._chain(0, False) status, body = snrc.resolve("acme.testing") From 439643b7d08b8cca9b9bc20969bf89663eff3aa1 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:04:52 +0000 Subject: [PATCH 03/44] resolver: say an unregistered name is not registered, not never was --- scripts/resolver/README.md | 11 ++++++----- scripts/resolver/service/snrc-resolve.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index adc0745d8..6d16c60d9 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -220,7 +220,7 @@ name already knows when it expires. Both timestamps are Unix seconds, and | `registered` | live; `expires` is when that ends | | `grace` | lapsed, but only the previous owner may renew it, until `graceEnds` | | `expired` | lapsed and past grace; anyone may register it | -| `unregistered` | never registered, and free to take | +| `unregistered` | never registered, or its registration was ended in its dispute period; free to take | | `unknown` | no `SNRC_REGISTRAR_` configured, so status could not be read | A reservation is orthogonal to the status: a name held back by the registry @@ -232,8 +232,9 @@ rather than assumed, and `now` is the latest block's timestamp rather than the host clock, which the registrar compares against too, so a machine with a wrong clock cannot misreport a registration. That rule alone is not enough: it also holds for a name nobody ever registered (`0 + GRACE_PERIOD < now`), so a zero -expiry is what separates *never registered* from *registered and since -released*. +expiry is what separates *not registered* from *registered and since +released*. The registrar also sets a zero expiry when a registration is ended +in its dispute period. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 @@ -247,7 +248,7 @@ which is free to change. ```jsonc {"name": "nope.testing", "error": "unregistered", - "message": "this name has never been registered", + "message": "this name is not registered", "status": "unregistered", "expires": null, "graceEnds": null} ``` @@ -331,7 +332,7 @@ through `prices()`, in US cents per year, which is the unit this API carries. An ENS-shaped oracle exposes only `price1Letter()`..`price6Letter()`, in attoUSD per second, and charges a premium on a lapsed name that it does not expose. A -quote from one is therefore only safe for a name that was never registered: an +quote from one is therefore only safe for a name with a zero expiry: an `expired` name gets no price rather than one below what the registrar charges. **Set `SNRC_CONTROLLER_` wherever `SNRC_REGISTRAR_` is.** Without a diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index b017f196e..769c90b1f 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -576,7 +576,7 @@ def read_oracle_prices(controller: str, oracle: str): """SimplexPriceOracle keeps the curve in US cents per year, the unit the SMP protocol carries. An ENS-shaped oracle prices in attoUSD per second and charges a premium on lapsed names that it does not expose, so a quote from - it is only safe for a name that was never registered.""" + it is only safe for a name with a zero expiry.""" # either oracle shape is answered in the same round trip prefetch([eth_call_read(*prices_call(oracle))] + [eth_call_read(*letter_price_call(oracle, n)) for n in LETTER_TIERS]) try: @@ -1240,7 +1240,7 @@ def resolve(name: str): **reg, "error": reg["status"], "message": ( - "this name has never been registered" + "this name is not registered" if reg["status"] == "unregistered" else "this registration expired and is open to anyone" ), From adf07039c9e6858c89c8a31c561bb854214bb7c6 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:17:37 +0000 Subject: [PATCH 04/44] resolver, docs: a registration can end in its dispute period --- ...026-11-20-resolver-unregistered-wording.md | 21 ++++++++++++------- protocol/simplex-messaging.md | 6 +++--- scripts/resolver/README.md | 15 +++++++------ scripts/resolver/service/test_snrc_resolve.py | 12 +++++------ 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/plans/2026-11-20-resolver-unregistered-wording.md b/plans/2026-11-20-resolver-unregistered-wording.md index 4d4562af8..ee2f096c3 100644 --- a/plans/2026-11-20-resolver-unregistered-wording.md +++ b/plans/2026-11-20-resolver-unregistered-wording.md @@ -1,17 +1,17 @@ # Resolver: wording of an unregistered name -Merges with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. +Merged together with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. ## Problem -After #51, the guardian or the admin can end a `.simplex` registration in its dispute period, and the registrar sets the name's expiry to 0. The resolver answers every name with expiry 0 with the message "this name has never been registered", and its README defines `unregistered` as never registered. +After #51, the guardian or the admin can end a `.simplex` registration in its dispute period, and the registrar sets the name's expiry to 0. The v1 route answers every name with expiry 0 with the message "this name has never been registered"; the resolver's README and the protocol describe `unregistered` and `registered` as if a registration could end only at `expires`. ## Decisions | # | Decision | |---|---| | 1 | `status` and `error` stay `unregistered` | -| 2 | message of a 404 `unregistered`: "this name is not registered" | +| 2 | message of a v1 404 `unregistered`: "this name is not registered" | | 3 | price quotes of a name with expiry 0 unchanged | ## Changes @@ -23,12 +23,19 @@ After #51, the guardian or the admin can end a `.simplex` registration in its di `scripts/resolver/README.md`: -- the status table: `unregistered` covers an ended registration -- the zero-expiry paragraph +- `expires` and `registered`: unless the registration is ended in its dispute period +- `unregistered`: also an ended registration +- the zero-expiry paragraph, with the dispute period defined - the error example +- the label of a hashed query: kept by the registrar after an expiry or an ended registration - the premium paragraph +`protocol/simplex-messaging.md`: + +- a name never registered has no recorded label +- `registered`: unless the registration is ended in its dispute period + `scripts/resolver/service/test_snrc_resolve.py`: -- new: the message of a name with expiry 0 does not state that it was never registered -- two test names that equate expiry 0 with never registered +- new, in `ErrorCodeTests`: the message of a name with expiry 0 does not state that it was never registered +- three test names that equate expiry 0 with never registered diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index 989884e3f..9f8d7f184 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1501,8 +1501,8 @@ look up what the hash stands for without ever being told. The router is not trusted for it: a client MUST check that the record names the name it asked about, and reject the answer otherwise. A registry that does not record the label cannot answer a hashed query at all, and the router answers `ERR NAME -RESOLVER` rather than a record it knows the client will reject. An unregistered -name has no recorded label, so it cannot be looked up either. +RESOLVER` rather than a record it knows the client will reject. A name never +registered has no recorded label, so it cannot be looked up either. **Server-side validation.** The names router parses `domain` as a fully-qualified name (TLD required — bare labels are rejected) and forwards it @@ -1551,7 +1551,7 @@ MUST NOT treat an answer as current without checking it. | `type` | Meaning | |---|---| -| `registered` | held by someone until `expires`, renewable by its owner alone until `graceUntil`. It always carries `nameRecord`: where the owner set none, every field is unset and the resolver address is zero | +| `registered` | held by someone until `expires`, unless the registration is ended in its dispute period, and renewable by its owner alone until `graceUntil`. It always carries `nameRecord`: where the owner set none, every field is unset and the resolver address is zero | | `available` | held by nobody and registrable now, at `pricing` | | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 6d16c60d9..c63531f70 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -195,7 +195,7 @@ alongside its fields. "eth": null, "btc": "bc1q…", "xmr": "4ANz…", "dot": "139G…", "owner": "0xd83b…", "resolver": "0x80fa…", "status": "registered", // registered | grace | expired | unregistered | unknown - "expires": 1780000000, // Unix seconds; when the registration ends + "expires": 1780000000, // Unix seconds; when the registration ends, unless it is ended in its dispute period "graceEnds": 1787776000, // expires + GRACE_PERIOD; last moment the owner can renew "reasonCode": null, // set when the name is held back as well "reason": null // set when the name is held back as well @@ -217,7 +217,7 @@ name already knows when it expires. Both timestamps are Unix seconds, and | `status` | Meaning | |---|---| -| `registered` | live; `expires` is when that ends | +| `registered` | live; `expires` is when that ends, unless the registration is ended in its dispute period | | `grace` | lapsed, but only the previous owner may renew it, until `graceEnds` | | `expired` | lapsed and past grace; anyone may register it | | `unregistered` | never registered, or its registration was ended in its dispute period; free to take | @@ -232,9 +232,10 @@ rather than assumed, and `now` is the latest block's timestamp rather than the host clock, which the registrar compares against too, so a machine with a wrong clock cannot misreport a registration. That rule alone is not enough: it also holds for a name nobody ever registered (`0 + GRACE_PERIOD < now`), so a zero -expiry is what separates *not registered* from *registered and since -released*. The registrar also sets a zero expiry when a registration is ended -in its dispute period. +expiry is what separates `unregistered` from `expired`. The registrar also sets +a zero expiry when a registration is ended in its dispute period: the 14 to 120 +days after a registration paid through the store, within which the registry's +guardian or admin can end it. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 @@ -287,7 +288,9 @@ curl -s "http://127.0.0.1:8000/resolve/[$(printf acme | keccak-256sum | cut -d' namehash is `keccak(parent || keccak(label))`, so this reaches the same node and returns the same record. The registrar keys `nameExpires` and `reservedNames` on the labelhash too, so the status fields do not need the label either. The -resolver learns the name only by guessing the label and hashing it. +resolver learns a name never registered only by guessing the label and hashing +it; the registrar keeps the label of a name registered before, also after it +expired or its registration was ended in its dispute period. Only the second-level label is a registry key, and `status` decodes a bracket there at any depth. The record does not: a bracket is decoded only in a diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 588bc24bc..2e7e193d6 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -512,11 +512,6 @@ def test_the_message_does_not_claim_a_trademark(self): _, body = snrc.resolve("acme.testing") self.assertNotIn("trademark", body["message"]) - def test_the_message_does_not_claim_the_name_was_never_registered(self): - snrc.eth_call = self._chain(0, False) - _, body = snrc.resolve("acme.testing") - self.assertNotIn("never", body["message"]) - def test_an_unregistered_name_has_no_reason(self): snrc.eth_call = self._chain(0, False) status, body = snrc.resolve("acme.testing") @@ -719,7 +714,7 @@ def eth_call(to, data): return eth_call - def test_a_never_registered_name_is_priced_from_the_letter_curve(self): + def test_a_zero_expiry_name_is_priced_from_the_letter_curve(self): snrc.eth_call = self._chain(0) reg = snrc.name_status("ghost.testing") self.assertEqual(reg["status"], "unregistered") @@ -791,6 +786,11 @@ def test_a_registration_problem_reports_the_status_as_the_code(self): self.assertEqual(body["error"], code) self.assertEqual(body["status"], code) + def test_the_message_does_not_claim_the_name_was_never_registered(self): + snrc.eth_call = self._chain(0) + _, body = snrc.resolve("alice.testing") + self.assertNotIn("never", body["message"]) + def test_a_name_in_grace_still_resolves(self): snrc.eth_call = self._chain(int(time.time()) - 3600) status, body = snrc.resolve("alice.testing") From 65f74f9eaa6c3f31a448acc0f27cce1c98c634e8 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:33:20 +0000 Subject: [PATCH 05/44] docs: describe registrations ended in their dispute period --- ...026-11-20-resolver-unregistered-wording.md | 13 ++++++----- protocol/simplex-messaging.md | 9 +++++--- scripts/resolver/README.md | 23 +++++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/plans/2026-11-20-resolver-unregistered-wording.md b/plans/2026-11-20-resolver-unregistered-wording.md index ee2f096c3..9c6cdf773 100644 --- a/plans/2026-11-20-resolver-unregistered-wording.md +++ b/plans/2026-11-20-resolver-unregistered-wording.md @@ -1,10 +1,10 @@ # Resolver: wording of an unregistered name -Merged together with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. +To be merged together with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. ## Problem -After #51, the guardian or the admin can end a `.simplex` registration in its dispute period, and the registrar sets the name's expiry to 0. The v1 route answers every name with expiry 0 with the message "this name has never been registered"; the resolver's README and the protocol describe `unregistered` and `registered` as if a registration could end only at `expires`. +After #51, the guardian or the admin can end a `.simplex` registration in its dispute period, and the registrar sets the name's expiry to 0; no renewal is accepted before the dispute period ends. The v1 route answers every name with expiry 0 with the message "this name has never been registered". The resolver's README describes `unregistered` as never registered and `registered` as held until `expires`, and the protocol describes a registered name as held until `expires`. ## Decisions @@ -27,15 +27,16 @@ After #51, the guardian or the admin can end a `.simplex` registration in its di - `unregistered`: also an ended registration - the zero-expiry paragraph, with the dispute period defined - the error example -- the label of a hashed query: kept by the registrar after an expiry or an ended registration +- the label of a hashed query: recorded labels stay recorded +- what a hashed query hides - the premium paragraph `protocol/simplex-messaging.md`: -- a name never registered has no recorded label -- `registered`: unless the registration is ended in its dispute period +- a hashed query of a name never registered +- the dispute period, after the registration types `scripts/resolver/service/test_snrc_resolve.py`: -- new, in `ErrorCodeTests`: the message of a name with expiry 0 does not state that it was never registered +- new, in `ErrorCodeTests`: a name with expiry 0 answers 404 with "this name is not registered" - three test names that equate expiry 0 with never registered diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index 9f8d7f184..21ce3bcaa 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1501,8 +1501,9 @@ look up what the hash stands for without ever being told. The router is not trusted for it: a client MUST check that the record names the name it asked about, and reject the answer otherwise. A registry that does not record the label cannot answer a hashed query at all, and the router answers `ERR NAME -RESOLVER` rather than a record it knows the client will reject. A name never -registered has no recorded label, so it cannot be looked up either. +RESOLVER` rather than a record it knows the client will reject. The registrar +records a label only when it registers a name, so a hashed query of a name never +registered cannot be answered with its name either. **Server-side validation.** The names router parses `domain` as a fully-qualified name (TLD required — bare labels are rejected) and forwards it @@ -1551,10 +1552,12 @@ MUST NOT treat an answer as current without checking it. | `type` | Meaning | |---|---| -| `registered` | held by someone until `expires`, unless the registration is ended in its dispute period, and renewable by its owner alone until `graceUntil`. It always carries `nameRecord`: where the owner set none, every field is unset and the resolver address is zero | +| `registered` | held by someone until `expires`, renewable by its owner alone until `graceUntil`. It always carries `nameRecord`: where the owner set none, every field is unset and the resolver address is zero | | `available` | held by nobody and registrable now, at `pricing` | | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | +On `.simplex`, a registration made through the sponsor (`registerWithCredit`) has a dispute period of 14 to 120 days from its registration, which the router does not report. Within it, the registry's guardian or admin can end the registration, after which the name answers `available`, and no renewal of it is accepted. + | Field | On | JSON type | Constraints | |---|---|---|---| | `expires` | `registered` | number | absent only from a v20/v21 router, which sent the record alone | diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index c63531f70..c7e74b9ec 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -232,10 +232,11 @@ rather than assumed, and `now` is the latest block's timestamp rather than the host clock, which the registrar compares against too, so a machine with a wrong clock cannot misreport a registration. That rule alone is not enough: it also holds for a name nobody ever registered (`0 + GRACE_PERIOD < now`), so a zero -expiry is what separates `unregistered` from `expired`. The registrar also sets -a zero expiry when a registration is ended in its dispute period: the 14 to 120 -days after a registration paid through the store, within which the registry's -guardian or admin can end it. +expiry is what separates `unregistered` from `expired`. On `.simplex`, the +registrar also sets a zero expiry when the registry's guardian or admin ends a +registration within its dispute period: 14 to 120 days from a registration made +through the sponsor (`registerWithCredit`), whose end the registrar stores as +`disputeUntil`. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 @@ -287,10 +288,10 @@ curl -s "http://127.0.0.1:8000/resolve/[$(printf acme | keccak-256sum | cut -d' namehash is `keccak(parent || keccak(label))`, so this reaches the same node and returns the same record. The registrar keys `nameExpires` and `reservedNames` on -the labelhash too, so the status fields do not need the label either. The -resolver learns a name never registered only by guessing the label and hashing -it; the registrar keeps the label of a name registered before, also after it -expired or its registration was ended in its dispute period. +the labelhash too, so the status fields do not need the label either. Whoever +runs the resolver learns a name never registered only by hashing guessed labels; +a label the registrar recorded stays recorded, also after the name expired or +its registration was ended in its dispute period. Only the second-level label is a registry key, and `status` decodes a bracket there at any depth. The record does not: a bracket is decoded only in a @@ -322,8 +323,10 @@ created by the 2LD's owner. A bracket label in a subname is hashed as written, so it points at a node nobody can own. ENS tooling accepts the bracketed form at any depth; this resolver does not, on purpose. -This hides interest in a name and nothing else: the registration itself is -public, and commit-reveal covers that step. A short or well-known label is easy +This hides interest only in a name whose label the registrar has not recorded: +for a name registered before, also one expired or ended in its dispute period, +the resolver reads the recorded label (`labelOf`) with the query. The +registration itself is public, and commit-reveal covers that step. A short or well-known label is easy to guess by hashing candidates, and the reveal publishes the labelhash, so an operator who logged the query can match it to the name afterwards. From a8c98dc2fe9e71eb8e45ad38e2a979b05dad210a Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:33:20 +0000 Subject: [PATCH 06/44] resolver: test the exact answer for a name with expiry 0 --- scripts/resolver/service/test_snrc_resolve.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 2e7e193d6..6ff7f6848 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -267,7 +267,7 @@ def test_a_registrar_that_is_not_a_contract_is_an_error_not_a_free_name(self): with self.assertRaises(RuntimeError): snrc.name_status("alice.testing") - def test_zero_expiry_means_not_registered(self): + def test_zero_expiry_means_unregistered(self): snrc.eth_call = self._expiry(0) self.assertEqual( snrc.name_status("alice.testing"), @@ -301,7 +301,7 @@ def test_future_expiry_is_registered(self): self._keys("registered", future, future + self.GRACE), ) - def test_not_registered_is_not_confused_with_claimable(self): + def test_zero_expiry_is_not_confused_with_claimable(self): """`available(id)` is true for both, since 0 + GRACE < now.""" snrc.eth_call = self._expiry(0) self.assertEqual(snrc.name_status("alice.testing")["status"], "unregistered") @@ -788,8 +788,8 @@ def test_a_registration_problem_reports_the_status_as_the_code(self): def test_the_message_does_not_claim_the_name_was_never_registered(self): snrc.eth_call = self._chain(0) - _, body = snrc.resolve("alice.testing") - self.assertNotIn("never", body["message"]) + status, body = snrc.resolve("alice.testing") + self.assertEqual((status, body["message"]), (404, "this name is not registered")) def test_a_name_in_grace_still_resolves(self): snrc.eth_call = self._chain(int(time.time()) - 3600) From 23e6aa6b9f1d3b4f6a6c14df0dfe8d2bf7dd2349 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:58:24 +0000 Subject: [PATCH 07/44] docs: state who ends a registration and that renewals wait for its end --- protocol/simplex-messaging.md | 11 +++++++---- scripts/resolver/README.md | 30 ++++++++++++++---------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index 21ce3bcaa..d362d5d1f 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1501,9 +1501,9 @@ look up what the hash stands for without ever being told. The router is not trusted for it: a client MUST check that the record names the name it asked about, and reject the answer otherwise. A registry that does not record the label cannot answer a hashed query at all, and the router answers `ERR NAME -RESOLVER` rather than a record it knows the client will reject. The registrar -records a label only when it registers a name, so a hashed query of a name never -registered cannot be answered with its name either. +RESOLVER` rather than a record it knows the client will reject. A name nobody +holds is answered `available`, which contains no name, so a hashed query of it +does not depend on a recorded label. **Server-side validation.** The names router parses `domain` as a fully-qualified name (TLD required — bare labels are rejected) and forwards it @@ -1556,7 +1556,10 @@ MUST NOT treat an answer as current without checking it. | `available` | held by nobody and registrable now, at `pricing` | | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | -On `.simplex`, a registration made through the sponsor (`registerWithCredit`) has a dispute period of 14 to 120 days from its registration, which the router does not report. Within it, the registry's guardian or admin can end the registration, after which the name answers `available`, and no renewal of it is accepted. +On `.simplex`, a sponsored registration has a dispute period of 14 to 120 days +from its registration, which the router does not report. Within it, a renewal is +refused, and the registry's owner or guardian can end the registration; a router +then answers for the name as for a name never registered. | Field | On | JSON type | Constraints | |---|---|---|---| diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index c7e74b9ec..34743cc65 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -231,12 +231,12 @@ rule, `expires + GRACE_PERIOD < now`. `GRACE_PERIOD` is read from the contract rather than assumed, and `now` is the latest block's timestamp rather than the host clock, which the registrar compares against too, so a machine with a wrong clock cannot misreport a registration. That rule alone is not enough: it also -holds for a name nobody ever registered (`0 + GRACE_PERIOD < now`), so a zero -expiry is what separates `unregistered` from `expired`. On `.simplex`, the -registrar also sets a zero expiry when the registry's guardian or admin ends a -registration within its dispute period: 14 to 120 days from a registration made -through the sponsor (`registerWithCredit`), whose end the registrar stores as -`disputeUntil`. +holds for a name nobody ever registered (`0 + GRACE_PERIOD < now`), so the +resolver tells `unregistered` from `expired` by a zero expiry. On `.simplex`, a +registration made through the controller's `registerSponsored` has a dispute +period of 14 to 120 days, and the registrar stores its end as `disputeUntil`. +Within it, a renewal is refused, and the controller's owner or guardian +(`beneficiary`) can end the registration; the registrar then sets a zero expiry. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 @@ -288,10 +288,7 @@ curl -s "http://127.0.0.1:8000/resolve/[$(printf acme | keccak-256sum | cut -d' namehash is `keccak(parent || keccak(label))`, so this reaches the same node and returns the same record. The registrar keys `nameExpires` and `reservedNames` on -the labelhash too, so the status fields do not need the label either. Whoever -runs the resolver learns a name never registered only by hashing guessed labels; -a label the registrar recorded stays recorded, also after the name expired or -its registration was ended in its dispute period. +the labelhash too, so the status fields do not need the label either. Only the second-level label is a registry key, and `status` decodes a bracket there at any depth. The record does not: a bracket is decoded only in a @@ -323,12 +320,13 @@ created by the 2LD's owner. A bracket label in a subname is hashed as written, so it points at a node nobody can own. ENS tooling accepts the bracketed form at any depth; this resolver does not, on purpose. -This hides interest only in a name whose label the registrar has not recorded: -for a name registered before, also one expired or ended in its dispute period, -the resolver reads the recorded label (`labelOf`) with the query. The -registration itself is public, and commit-reveal covers that step. A short or well-known label is easy -to guess by hashing candidates, and the reveal publishes the labelhash, so an -operator who logged the query can match it to the name afterwards. +Interest in a name is hidden only while the registrar has no label recorded for +it: for a name registered before, also one expired or ended in its dispute +period, the resolver reads the recorded label (`labelOf`) with the query. The +registration itself is public, and commit-reveal covers that step. A short or +well-known label is easy to guess by hashing candidates, and the reveal +publishes the labelhash, so an operator who logged the query can match it to the +name afterwards. ### What a name costs From 722fd75af35549bd2d7515e598ee079cc9da5d46 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 09:58:29 +0000 Subject: [PATCH 08/44] resolver: name the test of a zero expiry by the answer it checks --- scripts/resolver/service/test_snrc_resolve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 6ff7f6848..cb2dba0c7 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -786,7 +786,7 @@ def test_a_registration_problem_reports_the_status_as_the_code(self): self.assertEqual(body["error"], code) self.assertEqual(body["status"], code) - def test_the_message_does_not_claim_the_name_was_never_registered(self): + def test_a_zero_expiry_is_404_not_registered(self): snrc.eth_call = self._chain(0) status, body = snrc.resolve("alice.testing") self.assertEqual((status, body["message"]), (404, "this name is not registered")) From 45332510985c2155d3bf3b8ca8e21c9f92dc1c9b Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:05:03 +0000 Subject: [PATCH 09/44] names, resolver: plan reporting until when a registration can be ended --- plans/2026-11-20-names-dispute-period.md | 131 ++++++++++++++++++ ...026-11-20-resolver-unregistered-wording.md | 42 ------ 2 files changed, 131 insertions(+), 42 deletions(-) create mode 100644 plans/2026-11-20-names-dispute-period.md delete mode 100644 plans/2026-11-20-resolver-unregistered-wording.md diff --git a/plans/2026-11-20-names-dispute-period.md b/plans/2026-11-20-names-dispute-period.md new file mode 100644 index 000000000..35509f7cb --- /dev/null +++ b/plans/2026-11-20-names-dispute-period.md @@ -0,0 +1,131 @@ +# Names: a registration in its dispute period + +To be merged together with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. + +## Problems + +1. After #51, the owner or the guardian of the `.simplex` controller can end a registration in its dispute period, and the registrar sets the name's expiry to 0. On its v1 route, the resolver answers every name with expiry 0 with the message "this name has never been registered". The resolver's README describes `unregistered` as never registered and `registered` as held until `expires`, and the protocol describes a registered name as held until `expires`. +2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after a claim moved the name to a recipient, and its renewal is refused. In the contract plan, decision D8 has clients show the dispute end before a claim. + +## Decisions + +| # | Decision | +|---|---| +| 1 | `status` and `error` stay `unregistered` | +| 2 | message of a v1 404 `unregistered`: "this name is not registered" | +| 3 | price quotes of a name with expiry 0 unchanged | +| 4 | the registrar's `disputeUntil(uint256)` read for the 2LD's token, in the round of `nameExpires` | +| 5 | `disputeUntil` reported while later than `lastBlockTs`; otherwise null in v1, absent in v2 | +| 6 | a `disputeUntil` call that reverts or answers nothing read as no dispute period; `.testing`'s registrar predates #51 | +| 7 | a subname reported with its 2LD's `disputeUntil` | +| 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields | +| 9 | no SMP version, as section "Version" states | + +## What the resolver answers + +``` +name_status(name): + token = labelhash of the 2LD + expires = registrar.nameExpires(token) + now = timestamp of the latest block + until = registrar.disputeUntil(token), 0 when the call reverts or answers nothing + disputeUntil = until when until > now, else null +``` + +```mermaid +stateDiagram-v2 + [*] --> disputable: sponsored registration, 14 to 120 days + [*] --> final: registration without a dispute period + disputable --> final: the block's timestamp reaches disputeUntil + disputable --> unregistered: ended by the controller's owner or guardian + unregistered --> [*]: available to any registration +``` + +| State | v2 `type` | v2 `disputeUntil` | v1 `status` | v1 `disputeUntil` | +|---|---|---|---|---| +| disputable | `registered` | its end | `registered` | its end | +| final | `registered` | absent | `registered` or `grace` | null | +| unregistered | `available` or `reserved` | absent | `unregistered`, "this name is not registered" | null | + +```mermaid +sequenceDiagram + participant C as Client + participant P as Proxy + participant R as Names router + participant S as Resolver + participant N as Node + C->>P: PFWD with RSLV + P->>R: RFWD + R->>S: GET /v2/resolve/query + S->>N: one multicall: nameExpires, disputeUntil (added), GRACE_PERIOD and the other reads of the round + N-->>S: disputeUntil reverted by a registrar before #51 + S-->>R: registered, with disputeUntil when later than lastBlockTs (added) + R->>R: decoded into NRRegistered with disputeUntil (added) + R-->>P: RRES with RNAME, encoded at the forwarded version, at most 23 + P-->>C: PRES +``` + +## Version + +No SMP version is added for `disputeUntil`, because a version would not tell a client "no dispute period" from "not reported": + +- forwarded RSLV, the path clients SHOULD prefer, is answered at the version the proxy negotiated, at most `proxiedSMPRelayVersion` (23, `proxyResp` in `Server.hs`); a field gated on v24 would be withheld on that path until proxies raise that version, and the session version would not show the names router's support; +- a router passes what its resolver answers, and the resolver's API is versioned apart from SMP; a v24 router with an older resolver would omit the field as well. + +The field is optional, and receivers tolerate unknown fields, so routers and clients before it decode the answers unchanged, as for `NRAvailable.nameTerms`. A client MUST NOT conclude from the field's absence that the registration cannot be ended: it is absent when no dispute period is in effect at `lastBlockTs`, and from a router or resolver that predates it. + +## Threat model + +- A router or its resolver can omit `disputeUntil` or state a false one, as it can `expires`; a client verifies it only by reading the registrar. +- `disputeUntil` is public on chain (contract plan, D9), and with it the dispute days of the payment: 0, 14 or 120. The answer discloses to the router and the client what the chain discloses. +- A JSON-RPC error of the `disputeUntil` call alone is read as a revert, as for records and `namePolicy()`, and the name is answered without a dispute end. +- A label the registrar recorded stays recorded after the registration expired or was ended, so whoever runs the resolver matches a hashed query of such a name to its label. + +## Changes + +`scripts/resolver/service/snrc-resolve.py`: + +- the message of decision 2 +- the docstring of `read_oracle_prices`: a quote is safe for a name with expiry 0 +- `dispute_until_call`, read in `lookup_reads` +- `dispute_end`: the registrar's `disputeUntil` when later than the block, else None +- `name_status`: `disputeUntil`, also in v1 answers +- `registration`: `disputeUntil` in `registered` when set + +`scripts/resolver/README.md`: + +- `expires` and `registered`: unless the registration is ended in its dispute period +- `unregistered`: also an ended registration +- the zero-expiry paragraph, with the dispute period defined +- the error example +- what a hashed query hides +- the premium paragraph +- `disputeUntil` in the v1 example, in `registered` and in the definition of the dispute period +- a subname's dispute end in v2 + +`protocol/simplex-messaging.md`: + +- a hashed query of a name nobody holds +- the dispute period, after the registration types +- `disputeUntil` in the fields of `registered` + +`src/Simplex/Messaging/Names/Record.hs`: `NRRegistered.disputeUntil`. + +`src/Simplex/Messaging/Protocol.hs`: `disputeUntil = Nothing` in the answer of a router before v22. + +## Tests + +The tests of changed behavior are committed before the change, and fail on that commit in CI. + +`scripts/resolver/service/test_snrc_resolve.py`: + +- `ErrorCodeTests`: a name with expiry 0 answered 404 with "this name is not registered" +- three test names that equate expiry 0 with never registered +- `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 not reported; a registrar that reverts or answers nothing read as none; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch +- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`; v1 with it and with null +- `BatchedReadsTests`: `disputeUntil` read in the round of `nameExpires`, in two round trips +- the fakes of the registrar answer `disputeUntil` + +`tests/SMPNamesTests.hs`: the router's answer equal to the resolver's JSON of a registration with `disputeUntil`. + +`tests/RSLVTests.hs`: RNAME, direct and forwarded through a proxy, equal to the resolver's JSON of a registration with `disputeUntil`. diff --git a/plans/2026-11-20-resolver-unregistered-wording.md b/plans/2026-11-20-resolver-unregistered-wording.md deleted file mode 100644 index 9c6cdf773..000000000 --- a/plans/2026-11-20-resolver-unregistered-wording.md +++ /dev/null @@ -1,42 +0,0 @@ -# Resolver: wording of an unregistered name - -To be merged together with simplex-network/ens-contracts#51, the dispute period for sponsored registrations. - -## Problem - -After #51, the guardian or the admin can end a `.simplex` registration in its dispute period, and the registrar sets the name's expiry to 0; no renewal is accepted before the dispute period ends. The v1 route answers every name with expiry 0 with the message "this name has never been registered". The resolver's README describes `unregistered` as never registered and `registered` as held until `expires`, and the protocol describes a registered name as held until `expires`. - -## Decisions - -| # | Decision | -|---|---| -| 1 | `status` and `error` stay `unregistered` | -| 2 | message of a v1 404 `unregistered`: "this name is not registered" | -| 3 | price quotes of a name with expiry 0 unchanged | - -## Changes - -`scripts/resolver/service/snrc-resolve.py`: - -- the message of decision 2 -- the docstring of `read_oracle_prices`: a quote is safe for a name with expiry 0 - -`scripts/resolver/README.md`: - -- `expires` and `registered`: unless the registration is ended in its dispute period -- `unregistered`: also an ended registration -- the zero-expiry paragraph, with the dispute period defined -- the error example -- the label of a hashed query: recorded labels stay recorded -- what a hashed query hides -- the premium paragraph - -`protocol/simplex-messaging.md`: - -- a hashed query of a name never registered -- the dispute period, after the registration types - -`scripts/resolver/service/test_snrc_resolve.py`: - -- new, in `ErrorCodeTests`: a name with expiry 0 answers 404 with "this name is not registered" -- three test names that equate expiry 0 with never registered From 2a2b29b2c41f809556f8aee3bc1979411f073d99 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:05:08 +0000 Subject: [PATCH 10/44] resolver: test until when a registration can be ended --- scripts/resolver/service/test_snrc_resolve.py | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index cb2dba0c7..d08f2d043 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -203,10 +203,14 @@ class NameStatusTests(unittest.TestCase): GRACE = 90 * 86400 - def _expiry(self, value): + def _expiry(self, value, dispute_until=0): def eth_call(to, data): if data.startswith(snrc.selector("GRACE_PERIOD()")): return "0x" + snrc.encode_uint(self.GRACE) + if data.startswith(snrc.selector("disputeUntil(uint256)")): + if dispute_until is None: + raise RuntimeError("execution reverted") + return "0x" + snrc.encode_uint(dispute_until) self.assertTrue(data.startswith(snrc.selector("nameExpires(uint256)"))) return "0x" + snrc.encode_uint(value) @@ -219,6 +223,7 @@ def _keys(self, status, expires, grace_ends, read_at=-1): "lastBlockTs": self.now if read_at == -1 else read_at, "expires": expires, "graceEnds": grace_ends, + "disputeUntil": None, "reasonCode": None, "reason": None, } @@ -333,6 +338,44 @@ def eth_call(to, data): snrc.name_status("x." + hashed + ".testing") self.assertTrue(seen[0].endswith(snrc.keccak(b"alice").hex())) + def test_a_dispute_end_after_the_block_is_reported(self): + snrc.eth_call = self._expiry(self.now + 3600, dispute_until=self.now + 1) + self.assertEqual(snrc.name_status("alice.testing")["disputeUntil"], self.now + 1) + + def test_a_dispute_end_not_after_the_block_is_not_reported(self): + for until in (self.now, self.now - 1, 0): + with self.subTest(until=until): + snrc.eth_call = self._expiry(self.now + 3600, dispute_until=until) + self.assertIsNone(snrc.name_status("alice.testing")["disputeUntil"]) + + def test_a_registrar_reverting_the_dispute_end_reports_none(self): + snrc.eth_call = self._expiry(self.now + 3600, dispute_until=None) + reg = snrc.name_status("alice.testing") + self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) + + def test_a_registrar_answering_nothing_for_the_dispute_end_reports_none(self): + snrc.eth_call = self._saved[2] + answers = { + snrc.selector("nameExpires(uint256)"): "0x" + snrc.encode_uint(self.now + 3600), + snrc.selector("GRACE_PERIOD()"): "0x" + snrc.encode_uint(self.GRACE), + snrc.selector("disputeUntil(uint256)"): "0x", + } + snrc.rpc = lambda method, params: answers[params[0]["data"][:10]] + reg = snrc.name_status("alice.testing") + self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) + + def test_a_subname_reports_the_dispute_end_of_its_2ld(self): + alice = snrc.selector("disputeUntil(uint256)") + snrc.encode_uint(snrc.label_token("alice")) + + def eth_call(to, data): + if data.startswith(snrc.selector("disputeUntil(uint256)")): + self.assertEqual(data, alice) + return "0x" + snrc.encode_uint(self.now + 1) + return "0x" + snrc.encode_uint(self.now + 3600) + + snrc.eth_call = eth_call + self.assertEqual(snrc.name_status("x.alice.testing")["disputeUntil"], self.now + 1) + def test_unconfigured_tld_is_unknown_rather_than_unregistered(self): snrc.REGISTRARS = {"testing": ""} snrc.eth_call = lambda *a: self.fail("must not reach the chain") @@ -347,6 +390,7 @@ def test_every_branch_returns_the_same_keys(self): "lastBlockTs", "expires", "graceEnds", + "disputeUntil", "reasonCode", "reason", } @@ -585,6 +629,8 @@ def _chain(self, expires, oracle=None, reserved=0): def eth_call(to, data): if data.startswith(snrc.selector("nameExpires(uint256)")): return "0x" + snrc.encode_uint(expires) + if data.startswith(snrc.selector("disputeUntil(uint256)")): + return "0x" + snrc.encode_uint(0) if data.startswith(snrc.selector("GRACE_PERIOD()")): return "0x" + snrc.encode_uint(self.GRACE) if data.startswith(snrc.selector("reservedNames(bytes32)")): @@ -696,6 +742,8 @@ def _chain(self, expires, letter_cents=0): def eth_call(to, data): if data.startswith(snrc.selector("nameExpires(uint256)")): return "0x" + snrc.encode_uint(expires) + if data.startswith(snrc.selector("disputeUntil(uint256)")): + return "0x" + snrc.encode_uint(0) if data.startswith(snrc.selector("GRACE_PERIOD()")): return "0x" + snrc.encode_uint(self.GRACE) if data.startswith(snrc.selector("reservedNames(bytes32)")): @@ -888,7 +936,7 @@ def _abi_bytes(value: bytes) -> str: return ("0x" + snrc.encode_uint(0x20) + snrc.encode_uint(len(value)) + (value + b"\x00" * pad).hex()) - def _chain(self, expires, reserved=0, oracle=None, label=b"acme", owner=None, holder=None, subname_holder=None): + def _chain(self, expires, reserved=0, oracle=None, label=b"acme", owner=None, holder=None, subname_holder=None, dispute_until=0): """The registry answers a zero resolver, so name_record returns the empty record a registered name still has. `label` is what the registrar recorded for the 2LD; b"" means it recorded none. `owner` is the owner of @@ -904,6 +952,8 @@ def eth_call(to, data): return self._abi_bytes(label) if data.startswith(snrc.selector("nameExpires(uint256)")): return "0x" + snrc.encode_uint(expires) + if data.startswith(snrc.selector("disputeUntil(uint256)")): + return "0x" + snrc.encode_uint(dispute_until) if data.startswith(snrc.selector("GRACE_PERIOD()")): return "0x" + snrc.encode_uint(self.GRACE) if data.startswith(snrc.selector("reservedNames(bytes32)")): @@ -953,6 +1003,19 @@ def test_a_registered_name_that_is_held_back_says_so(self): self.assertEqual(body["type"], "registered") self.assertEqual(body["reservedReason_"], "internal") + def test_a_registration_in_its_dispute_period_says_until_when(self): + snrc.eth_call = self._chain(self.now + 3600, dispute_until=self.now + 600) + _, body = registration("acme.testing") + self.assertEqual(body["type"], "registered") + self.assertEqual(body["disputeUntil"], self.now + 600) + + def test_v1_reports_the_dispute_end_and_null_without_one(self): + for until, reported in ((self.now + 600, self.now + 600), (0, None)): + with self.subTest(until=until): + snrc.eth_call = self._chain(self.now + 3600, dispute_until=until) + status, body = snrc.resolve("acme.testing") + self.assertEqual((status, body["disputeUntil"]), (200, reported)) + def test_an_unregistered_name_is_available_with_its_pricing(self): snrc.eth_call = self._chain(0) status, body = registration("acme.testing") @@ -1422,6 +1485,13 @@ def test_a_registered_name_takes_two_round_trips(self): self.assertEqual(record["simplexChannel"], ["https://a.example/c#1", "https://b.example/c#2"]) self.assertIsNone(record["btc"]) + def test_the_dispute_end_is_read_in_the_round_of_the_expiry(self): + until = self.node.chain.now + 600 + call = (FakeChain.REGISTRAR, snrc.selector("disputeUntil(uint256)") + snrc.encode_uint(snrc.label_token("acme"))) + self.node.chain.answers[call] = "0x" + snrc.encode_uint(until) + _, body = self.assert_same_answer(snrc.registration, "acme.testing", 2) + self.assertEqual(body["registration"]["disputeUntil"], until) + def test_a_hashed_query_is_named_from_the_same_round_trip(self): hashed = "[" + snrc.keccak(b"acme").hex() + "].testing" status, body = self.assert_same_answer(snrc.registration, hashed, 2) From 67f97b0b73083b4d36cd40798cd638d64202cfd8 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:05:32 +0000 Subject: [PATCH 11/44] names: test that RNAME includes the dispute end of a registration --- tests/RSLVTests.hs | 21 ++++++++++++++++++++- tests/SMPNamesTests.hs | 13 ++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/RSLVTests.hs b/tests/RSLVTests.hs index e9b931314..bb2b91b03 100644 --- a/tests/RSLVTests.hs +++ b/tests/RSLVTests.hs @@ -14,6 +14,7 @@ module RSLVTests (rslvTests) where import Control.Concurrent (threadDelay) import Control.Monad (forM_) import Control.Monad.Trans.Except (ExceptT, runExceptT) +import qualified Data.Aeson as J import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as LB import Data.IORef (IORef, readIORef) @@ -29,7 +30,7 @@ import SMPClient import Simplex.Messaging.Client import qualified Simplex.Messaging.Crypto as C import Simplex.Messaging.Encoding.String (strDecode) -import SMPNamesTests (availableBody, registeredBody, reservedBody, resolved, testNameRecord, testPricing) +import SMPNamesTests (availableBody, disputedBody, jsonValue, registeredBody, reservedBody, resolved, testNameRecord, testPricing) import Simplex.Messaging.Protocol ( BrokerMsg (..), Cmd (..), @@ -93,8 +94,10 @@ rslvTests = do describe "RSLV forwarded (PFWD)" $ do it "PFWD-wrapped RSLV reaches resolver via proxy (PCEProtocolError (NAME RESOLVER))" testRslvForwarded it "PFWD-wrapped RSLV success returns RNAME (record JSON frames over the proxy)" testRslvForwardedSuccess + it "PFWD-wrapped RNAME includes the dispute end the resolver sent" testRslvForwardedDisputeEnd describe "RSLV success path (RNAME response)" $ do it "returns RNAME with NameRecord" testRslvSuccess + it "RNAME includes the dispute end the resolver sent" testRslvDisputeEnd describe "RSLV availability (RNAME response)" $ do it "unregistered comes back AVAILABLE" testRslvAvailable it "reserved comes back with the reason" testRslvReserved @@ -175,6 +178,13 @@ testRslvForwardedSuccess = Right (Right NameResponse {registration = NRRegistered {nameRecord}}) -> nameRecord `shouldBe` testNameRecord _ -> expectationFailure $ "expected Right (Right NRRegistered), got: " <> show r +testRslvForwardedDisputeEnd :: HasTestEnv => IO () +testRslvForwardedDisputeEnd = + withProxyAndResolver (status200, disputedBody) $ + forwardedResolveAlice >>= \case + Right (Right res) -> J.toJSON res `shouldBe` jsonValue disputedBody + r -> expectationFailure $ "expected Right (Right NameResponse), got: " <> show r + testRslvSuccess :: HasTestEnv => IO () testRslvSuccess = withResolverServer (status200, registeredBody testNameRecord) $ @@ -185,6 +195,15 @@ testRslvSuccess = Right (RNAME NameResponse {registration = NRRegistered {nameRecord}}) -> nameRecord `shouldBe` testNameRecord _ -> expectationFailure $ "expected Right (RNAME NRRegistered), got: " <> show resp +testRslvDisputeEnd :: HasTestEnv => IO () +testRslvDisputeEnd = + withResolverServer (status200, disputedBody) $ + testSMPClient @TLS $ \h -> do + (_, _, resp) <- sendRslv h "rs08" (domain "alice.simplex") + case resp of + Right (RNAME res) -> J.toJSON res `shouldBe` jsonValue disputedBody + _ -> expectationFailure $ "expected Right (RNAME _), got: " <> show resp + testRslvAvailable :: HasTestEnv => IO () testRslvAvailable = withResolverServer (status200, availableBody) $ diff --git a/tests/SMPNamesTests.hs b/tests/SMPNamesTests.hs index 452c99428..9fae24c2d 100644 --- a/tests/SMPNamesTests.hs +++ b/tests/SMPNamesTests.hs @@ -3,7 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -module SMPNamesTests (smpNamesTests, testNameRecord, testPricing, registeredBody, availableBody, reservedBody, responseBody, resolved) where +module SMPNamesTests (smpNamesTests, testNameRecord, testPricing, registeredBody, disputedBody, availableBody, reservedBody, responseBody, resolved, jsonValue) where import qualified Data.Aeson as J import qualified Data.ByteString.Char8 as B @@ -56,6 +56,13 @@ registeredBody :: NameRecord -> LB.ByteString registeredBody nameRec = responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"reservedReason_\":null,\"nameRecord\":" <> J.encode nameRec <> "}" +disputedBody :: LB.ByteString +disputedBody = + responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":1813100000,\"nameRecord\":" <> J.encode testNameRecord <> "}" + +jsonValue :: LB.ByteString -> J.Value +jsonValue = either error id . J.eitherDecode + availableBody :: LB.ByteString availableBody = responseBody "{\"type\":\"available\",\"pricing\":{\"registrationPrices\":{\"3\":12793,\"4\":3198},\"basePrice\":100,\"minLabelLength\":3}}" @@ -162,6 +169,10 @@ availabilitySpec = do it "a registered name can be held back too" $ answers heldBackBody . resolved $ NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), reservedReason_ = Just NRRInternal, nameRecord = testNameRecord} + it "a registration in its dispute period is answered with its end, as the resolver sent it" $ + withResolverServer (resolveResp status200 disputedBody) $ \port _ -> do + env <- newNamesEnv (testNamesConfig port) + (fmap J.toJSON <$> resolveName env aliceQuery) `shouldReturn` Right (jsonValue disputedBody) it "an unregistered name answers with the price" $ answers availableBody (resolved NRAvailable {pricing = testPricing, nameTerms = Nothing}) it "reserved carries the reason and no price" $ From 2a65a50367b0fb1fe60c440a04c12e38021e596f Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:05:52 +0000 Subject: [PATCH 12/44] resolver: report until when a registration can be ended --- scripts/resolver/README.md | 8 ++++++-- scripts/resolver/service/snrc-resolve.py | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 34743cc65..71e98bd73 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -172,7 +172,7 @@ Error bodies carry `name` and a fixed `error` code to branch on. Only label, so a hashed query cannot be answered with a name. See [Querying by labelhash](#querying-by-labelhash). -A subname reports the expiry and grace of the 2LD above it, since that is what +A subname is answered with the expiry, grace and dispute end of its 2LD, which bounds its lifetime. A subname is answered only while it is held: owned in the registry by the 2LD's holder, or by the subname registrar that the registrar's `subnameHook()` names, while its `ownerOf` names a holder. Any other subname, @@ -197,6 +197,7 @@ alongside its fields. "status": "registered", // registered | grace | expired | unregistered | unknown "expires": 1780000000, // Unix seconds; when the registration ends, unless it is ended in its dispute period "graceEnds": 1787776000, // expires + GRACE_PERIOD; last moment the owner can renew + "disputeUntil": null, // Unix seconds; until then the registration can be ended and cannot be renewed "reasonCode": null, // set when the name is held back as well "reason": null // set when the name is held back as well } @@ -217,7 +218,7 @@ name already knows when it expires. Both timestamps are Unix seconds, and | `status` | Meaning | |---|---| -| `registered` | live; `expires` is when that ends, unless the registration is ended in its dispute period | +| `registered` | live; `expires` is when that ends, unless the registration is ended before `disputeUntil` | | `grace` | lapsed, but only the previous owner may renew it, until `graceEnds` | | `expired` | lapsed and past grace; anyone may register it | | `unregistered` | never registered, or its registration was ended in its dispute period; free to take | @@ -237,6 +238,9 @@ registration made through the controller's `registerSponsored` has a dispute period of 14 to 120 days, and the registrar stores its end as `disputeUntil`. Within it, a renewal is refused, and the controller's owner or guardian (`beneficiary`) can end the registration; the registrar then sets a zero expiry. +The resolver reports that end as `disputeUntil` while it is later than `now`, +and null otherwise. The call to a registrar from before dispute periods, such as +`.testing`'s, reverts, and is read as none. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index 769c90b1f..89d90b28a 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -508,6 +508,14 @@ def grace_period(registrar: str) -> int: return decode_uint(eth_call(*grace_call(registrar))) +def dispute_end(registrar: str, token: int, now: int): + try: + until = decode_uint(eth_call(*dispute_until_call(registrar, token))) + except RuntimeError: + return None + return until if until > now else None + + def expiry_status(expires: int, grace: int, now: int) -> str: """The registrar's `available(id)` is not enough on its own: it is also true for a name nobody registered, since 0 + GRACE_PERIOD < now.""" @@ -647,6 +655,7 @@ def name_status(name: str): "lastBlockTs": None, "expires": None, "graceEnds": None, + "disputeUntil": None, "reasonCode": None, "reason": None, } @@ -671,6 +680,7 @@ def name_status(name: str): "lastBlockTs": now, "expires": expires or None, "graceEnds": (expires + grace) if expires else None, + "disputeUntil": dispute_end(registrar, token, now), "reasonCode": reason[0] if reason else None, "reason": reason[1] if reason else None, } @@ -803,6 +813,10 @@ def expires_call(registrar: str, token: int): return registrar, selector("nameExpires(uint256)") + encode_uint(token) +def dispute_until_call(registrar: str, token: int): + return registrar, selector("disputeUntil(uint256)") + encode_uint(token) + + def grace_call(registrar: str): return registrar, selector("GRACE_PERIOD()") @@ -863,7 +877,7 @@ def lookup_reads(name: str): registrar = REGISTRARS.get(tld) if registrar and len(labels) >= 2: token = label_token(labels[-2]) - reads += [BLOCK_READ, eth_call_read(*expires_call(registrar, token)), eth_call_read(*grace_call(registrar))] + reads += [BLOCK_READ, eth_call_read(*expires_call(registrar, token)), eth_call_read(*dispute_until_call(registrar, token)), eth_call_read(*grace_call(registrar))] if len(labels) == 2 and is_encoded_labelhash(labels[0]): reads.append(eth_call_read(*label_call(registrar, token))) if len(labels) > 2: @@ -1197,6 +1211,7 @@ def registration(name: str): "type": "registered", "expires": reg["expires"], "graceUntil": reg["graceEnds"], + **({"disputeUntil": reg["disputeUntil"]} if reg["disputeUntil"] else {}), "reservedReason_": reg["reasonCode"], "nameRecord": rec, }) From ece12c238557aac60058821e66c8f7ad2e2de7d5 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:06:10 +0000 Subject: [PATCH 13/44] names: pass the dispute end of a registration to clients --- protocol/simplex-messaging.md | 3 ++- src/Simplex/Messaging/Names/Record.hs | 2 ++ src/Simplex/Messaging/Protocol.hs | 2 +- tests/RSLVTests.hs | 2 +- tests/SMPNamesTests.hs | 6 +++--- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index d362d5d1f..ac4cdf704 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1557,7 +1557,7 @@ MUST NOT treat an answer as current without checking it. | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | On `.simplex`, a sponsored registration has a dispute period of 14 to 120 days -from its registration, which the router does not report. Within it, a renewal is +from its registration, which ends at `disputeUntil`. Within it, a renewal is refused, and the registry's owner or guardian can end the registration; a router then answers for the name as for a name never registered. @@ -1565,6 +1565,7 @@ then answers for the name as for a name never registered. |---|---|---|---| | `expires` | `registered` | number | absent only from a v20/v21 router, which sent the record alone | | `graceUntil` | `registered` | number | after `expires`; until here only the owner may renew. Absent on the same condition as `expires` | +| `disputeUntil` | `registered` | number | the end of the dispute period, present only when after `lastBlockTs`. A router or resolver that predates the field omits it, so a client MUST NOT conclude from its absence that the registration cannot be ended | | `reservedReason_` | `registered` | string | a reason word, present only when the name is held back as well | | `nameRecord` | `registered` | object | the record, schema below | | `pricing` | `available` | object | `registrationPrices`, `basePrice` and `minLabelLength`, below | diff --git a/src/Simplex/Messaging/Names/Record.hs b/src/Simplex/Messaging/Names/Record.hs index 42bdc9a99..164bbca3d 100644 --- a/src/Simplex/Messaging/Names/Record.hs +++ b/src/Simplex/Messaging/Names/Record.hs @@ -87,6 +87,8 @@ data NameRegistration expires :: Maybe SystemSeconds, -- | unix seconds, > expires: until here only the owner may renew graceUntil :: Maybe SystemSeconds, + -- | unix seconds, > lastBlockTs: until here the registration can be ended and cannot be renewed; absent also from a router or resolver that predates it + disputeUntil :: Maybe SystemSeconds, -- | held back as well, which is why it will not free up at expiry reservedReason_ :: Maybe NameReservedReason, nameRecord :: NameRecord diff --git a/src/Simplex/Messaging/Protocol.hs b/src/Simplex/Messaging/Protocol.hs index 05efa40c5..783cfbef9 100644 --- a/src/Simplex/Messaging/Protocol.hs +++ b/src/Simplex/Messaging/Protocol.hs @@ -2109,7 +2109,7 @@ instance ProtocolEncoding SMPVersion ErrorType BrokerMsg where | otherwise -> fmap (RNAME . oldResponse) . J.eitherDecodeStrict . unTail <$?> _smpP where oldResponse nameRecord = - NameResponse {lastBlockTs = Nothing, registration = NRRegistered {expires = Nothing, graceUntil = Nothing, reservedReason_ = Nothing, nameRecord}} + NameResponse {lastBlockTs = Nothing, registration = NRRegistered {expires = Nothing, graceUntil = Nothing, disputeUntil = Nothing, reservedReason_ = Nothing, nameRecord}} serviceRespP resp | v >= rcvServiceSMPVersion = resp <$> _smpP <*> smpP | otherwise = resp <$> _smpP <*> pure mempty diff --git a/tests/RSLVTests.hs b/tests/RSLVTests.hs index bb2b91b03..8e03f81f1 100644 --- a/tests/RSLVTests.hs +++ b/tests/RSLVTests.hs @@ -237,7 +237,7 @@ testRslvOldClientRecord = withResolverServer (status200, registeredBody testNameRecord) $ do pc <- oldClient r <- runExceptT' (directResolveName pc NRMInteractive (domain "alice.simplex")) - r `shouldBe` NameResponse Nothing (NRRegistered Nothing Nothing Nothing testNameRecord) + r `shouldBe` NameResponse Nothing (NRRegistered Nothing Nothing Nothing Nothing testNameRecord) testRslvOldClientNotFound :: HasTestEnv => IO () testRslvOldClientNotFound = diff --git a/tests/SMPNamesTests.hs b/tests/SMPNamesTests.hs index 9fae24c2d..35e6b06dd 100644 --- a/tests/SMPNamesTests.hs +++ b/tests/SMPNamesTests.hs @@ -82,7 +82,7 @@ resolved registration = NameResponse {lastBlockTs = Just (RoundedSystemTime 1813 -- | What `registeredBody testNameRecord` resolves to. registeredAlice :: NameRegistration registeredAlice = - NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), reservedReason_ = Nothing, nameRecord = testNameRecord} + NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Nothing, nameRecord = testNameRecord} smpNamesTests :: Spec smpNamesTests = do @@ -168,7 +168,7 @@ availabilitySpec = do answers (registeredBody testNameRecord) (resolved registeredAlice) it "a registered name can be held back too" $ answers heldBackBody . resolved $ - NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), reservedReason_ = Just NRRInternal, nameRecord = testNameRecord} + NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord} it "a registration in its dispute period is answered with its end, as the resolver sent it" $ withResolverServer (resolveResp status200 disputedBody) $ \port _ -> do env <- newNamesEnv (testNamesConfig port) @@ -185,7 +185,7 @@ availabilitySpec = do mapM_ (\a -> J.eitherDecodeStrict (LB.toStrict (J.encode a)) `shouldBe` Right a) [ registeredAlice, - NRRegistered {expires = Nothing, graceUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord}, + NRRegistered {expires = Nothing, graceUntil = Nothing, disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord}, NRAvailable {pricing = testPricing, nameTerms = Nothing}, NRReserved NRRInternal, NRReserved NRRTrademark, From 5695bfd93b22f4fc6fdd181ef98d4a45b8310305 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:28:43 +0000 Subject: [PATCH 14/44] resolver: state that available holds for any name with a zero expiry --- scripts/resolver/service/snrc-resolve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index 89d90b28a..c4819c0d8 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -518,7 +518,7 @@ def dispute_end(registrar: str, token: int, now: int): def expiry_status(expires: int, grace: int, now: int) -> str: """The registrar's `available(id)` is not enough on its own: it is also - true for a name nobody registered, since 0 + GRACE_PERIOD < now.""" + true for a name with a zero expiry, since 0 + GRACE_PERIOD < now.""" if expires == 0: return "unregistered" if expires > now: From 8593b2a3ffc409dd2383ebde05fab9ec6b161c86 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:46:14 +0000 Subject: [PATCH 15/44] docs: list the dispute end with the other status fields --- protocol/simplex-messaging.md | 2 +- scripts/resolver/README.md | 47 +++++++++++++----------- scripts/resolver/service/snrc-resolve.py | 2 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index ac4cdf704..ba5ea913b 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1596,7 +1596,7 @@ refuses: a hashed query carries no length, so only the client can check it. Below v22, `RNAME` carries the bare record and nothing else, and every answer without one is `ERR NAME NOT_FOUND`. A v22 client reads such an answer as -`registered` with no expiry, grace or reservation. +`registered` with no expiry, grace, dispute end or reservation. From v22 a client MUST NOT read `ERR NAME NOT_FOUND` as "registrable": only `available` says that. diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 71e98bd73..0b42a643e 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -172,17 +172,17 @@ Error bodies carry `name` and a fixed `error` code to branch on. Only label, so a hashed query cannot be answered with a name. See [Querying by labelhash](#querying-by-labelhash). -A subname is answered with the expiry, grace and dispute end of its 2LD, which -bounds its lifetime. A subname is answered only while it is held: owned in the -registry by the 2LD's holder, or by the subname registrar that the registrar's -`subnameHook()` names, while its `ownerOf` names a holder. Any other subname, -created or not, reports as not registered. +A subname is answered with the expiry, grace and dispute end of its 2LD, on +which its lifetime depends. A subname is answered only while it is held: owned +in the registry by the 2LD's holder, or by the subname registrar that the +registrar's `subnameHook()` names, while its `ownerOf` names a holder. Any other +subname, created or not, is answered as not registered. ### v1: `/resolve/` What routers before SMP v22 call. Its shape is unrelated to v2's: the record is -flat, and `status`, `expires`, `graceEnds`, `reasonCode` and `reason` sit -alongside its fields. +flat, and `status`, `expires`, `graceEnds`, `disputeUntil`, `reasonCode` and +`reason` are keys beside its fields. #### v1 response shape @@ -211,10 +211,11 @@ identically (`bar.foobar.testing`). #### v1 registration status and expiry -A response carries `status`, `expires` and `graceEnds` whenever the resolver -read them, a successful resolve included, so a client that has just resolved a -name already knows when it expires. Both timestamps are Unix seconds, and -`null` when they could not be read. +A response contains `status`, `expires`, `graceEnds` and `disputeUntil` +whenever the resolver read them, a successful resolve included, so a client that +has just resolved a name already knows when it expires. The timestamps are Unix +seconds, and `null` when they could not be read; `disputeUntil` is also `null` +when no dispute period is in effect. | `status` | Meaning | |---|---| @@ -291,8 +292,9 @@ curl -s "http://127.0.0.1:8000/resolve/[$(printf acme | keccak-256sum | cut -d' ``` namehash is `keccak(parent || keccak(label))`, so this reaches the same node and -returns the same record. The registrar keys `nameExpires` and `reservedNames` on -the labelhash too, so the status fields do not need the label either. +returns the same record. The registrar keys `nameExpires`, `disputeUntil` and +`reservedNames` on the labelhash too, so the status fields are read without the +label as well. Only the second-level label is a registry key, and `status` decodes a bracket there at any depth. The record does not: a bracket is decoded only in a @@ -376,15 +378,16 @@ controller names, and the subname registrar a registrar names. The **registry** answers who owns a node, and `/resolve` reads the records from it. The **registrar** (ERC-721) holds `nameExpires` and `GRACE_PERIOD`, which -is where every expiry field comes from, and `labelOf`, which is how a hashed -query is answered with a name. A name registered without recording its label -cannot answer one, and `/v2/resolve` refuses it rather than answer with a name -the client will reject. Its `subnameHook()` names the subname registrar, whose -`ownerOf` says who holds a subname it owns. With no registrar for a TLD, -`/resolve` still works and reports `"status": "unknown"`, and only subnames the -2LD's holder owns in the registry are answered. The **controller** holds -`reservedNames`, which is where `reasonCode` comes from. With no controller a -held-back name reads as not reserved, and no name can be priced. +is where every expiry field comes from, `disputeUntil`, the end of a dispute +period, and `labelOf`, which is how a hashed query is answered with a name. A +name registered without recording its label cannot answer one, and +`/v2/resolve` refuses it rather than answer with a name the client will reject. +Its `subnameHook()` names the subname registrar, whose `ownerOf` says who holds +a subname it owns. With no registrar for a TLD, `/resolve` still works and +reports `"status": "unknown"`, and only subnames the 2LD's holder owns in the +registry are answered. The **controller** holds `reservedNames`, which is where +`reasonCode` comes from. With no controller a held-back name reads as not +reserved, and no name can be priced. All three default to the mainnet `.testing` deployment. `.simplex` is unset until it is deployed. diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index c4819c0d8..ab8c95474 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -660,7 +660,7 @@ def name_status(name: str): "reason": None, } - # nameExpires and reservedNames are keyed on uint256(keccak(label)). + # nameExpires, disputeUntil and reservedNames are keyed on uint256(keccak(label)). # The 2LD's label is that key at any depth. node_of decodes a bracket only # in a two-label name, so a bracket subname gets a status but no record. token = label_token(labels[-2]) From b59646edd76d09ecd75915c0a3f7239d66b71993 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:46:35 +0000 Subject: [PATCH 16/44] docs: define the dispute period by its disputeUntil field --- protocol/simplex-messaging.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index ba5ea913b..007dd8489 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1502,8 +1502,8 @@ trusted for it: a client MUST check that the record names the name it asked about, and reject the answer otherwise. A registry that does not record the label cannot answer a hashed query at all, and the router answers `ERR NAME RESOLVER` rather than a record it knows the client will reject. A name nobody -holds is answered `available`, which contains no name, so a hashed query of it -does not depend on a recorded label. +holds is answered `available` or `reserved`, neither of which contains a name, +so a hashed query of it does not depend on a recorded label. **Server-side validation.** The names router parses `domain` as a fully-qualified name (TLD required — bare labels are rejected) and forwards it @@ -1552,20 +1552,21 @@ MUST NOT treat an answer as current without checking it. | `type` | Meaning | |---|---| -| `registered` | held by someone until `expires`, renewable by its owner alone until `graceUntil`. It always carries `nameRecord`: where the owner set none, every field is unset and the resolver address is zero | +| `registered` | held by someone until `expires`, unless the registration is ended before `disputeUntil`; renewable by its owner alone until `graceUntil`, and not before `disputeUntil`. It always carries `nameRecord`: where the owner set none, every field is unset and the resolver address is zero | | `available` | held by nobody and registrable now, at `pricing` | | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | -On `.simplex`, a sponsored registration has a dispute period of 14 to 120 days -from its registration, which ends at `disputeUntil`. Within it, a renewal is -refused, and the registry's owner or guardian can end the registration; a router -then answers for the name as for a name never registered. +A registration answered with `disputeUntil` is in its dispute period: until +then, its renewal is refused, and the owner or the guardian of the registry's +controller contract can end it; a router then answers for the name as for a name +never registered. On `.simplex`, a registration made through the registry's +sponsor contract has a dispute period of 14 to 120 days from its registration. | Field | On | JSON type | Constraints | |---|---|---|---| | `expires` | `registered` | number | absent only from a v20/v21 router, which sent the record alone | | `graceUntil` | `registered` | number | after `expires`; until here only the owner may renew. Absent on the same condition as `expires` | -| `disputeUntil` | `registered` | number | the end of the dispute period, present only when after `lastBlockTs`. A router or resolver that predates the field omits it, so a client MUST NOT conclude from its absence that the registration cannot be ended | +| `disputeUntil` | `registered` | number | the end of the dispute period, present only when after `lastBlockTs`. It is also absent when it could not be read, and from a router or resolver that predates it, so a client MUST NOT conclude from its absence that the registration cannot be ended | | `reservedReason_` | `registered` | string | a reason word, present only when the name is held back as well | | `nameRecord` | `registered` | object | the record, schema below | | `pricing` | `available` | object | `registrationPrices`, `basePrice` and `minLabelLength`, below | From bf81a66b142693d4cd2f4258a6faac4cef5860c2 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:47:14 +0000 Subject: [PATCH 17/44] names, resolver: plan a null dispute end, and decisions without reasons --- plans/2026-11-20-names-dispute-period.md | 56 ++++++++++++------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/plans/2026-11-20-names-dispute-period.md b/plans/2026-11-20-names-dispute-period.md index 35509f7cb..10818669d 100644 --- a/plans/2026-11-20-names-dispute-period.md +++ b/plans/2026-11-20-names-dispute-period.md @@ -4,8 +4,8 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period ## Problems -1. After #51, the owner or the guardian of the `.simplex` controller can end a registration in its dispute period, and the registrar sets the name's expiry to 0. On its v1 route, the resolver answers every name with expiry 0 with the message "this name has never been registered". The resolver's README describes `unregistered` as never registered and `registered` as held until `expires`, and the protocol describes a registered name as held until `expires`. -2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after a claim moved the name to a recipient, and its renewal is refused. In the contract plan, decision D8 has clients show the dispute end before a claim. +1. After #51, the owner or the guardian of the `.simplex` controller can end a registration in its dispute period, and the registrar sets the name's expiry to 0. On its v1 route, the resolver answers every name with expiry 0 with the message "this name has never been registered". In the resolver's README, `unregistered` is described as never registered and `registered` as held until `expires`, and in the protocol a registered name is described as held until `expires`. +2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after a claim moved the name to a recipient, and its renewal is refused. By decision D8 of the contract plan, clients show the dispute end before a claim. ## Decisions @@ -15,11 +15,11 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period | 2 | message of a v1 404 `unregistered`: "this name is not registered" | | 3 | price quotes of a name with expiry 0 unchanged | | 4 | the registrar's `disputeUntil(uint256)` read for the 2LD's token, in the round of `nameExpires` | -| 5 | `disputeUntil` reported while later than `lastBlockTs`; otherwise null in v1, absent in v2 | +| 5 | `disputeUntil` reported while later than `lastBlockTs`, otherwise null; the router omits a null one in RNAME | | 6 | a `disputeUntil` call that reverts or answers nothing read as no dispute period; `.testing`'s registrar predates #51 | | 7 | a subname reported with its 2LD's `disputeUntil` | | 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields | -| 9 | no SMP version, as section "Version" states | +| 9 | no SMP version; a client does not read the absence of `disputeUntil` as the end of a dispute period | ## What the resolver answers @@ -36,16 +36,18 @@ name_status(name): stateDiagram-v2 [*] --> disputable: sponsored registration, 14 to 120 days [*] --> final: registration without a dispute period - disputable --> final: the block's timestamp reaches disputeUntil + disputable --> final: at disputeUntil disputable --> unregistered: ended by the controller's owner or guardian unregistered --> [*]: available to any registration ``` -| State | v2 `type` | v2 `disputeUntil` | v1 `status` | v1 `disputeUntil` | -|---|---|---|---|---| -| disputable | `registered` | its end | `registered` | its end | -| final | `registered` | absent | `registered` or `grace` | null | -| unregistered | `available` or `reserved` | absent | `unregistered`, "this name is not registered" | null | +For a 2LD: + +| State | v2 `type` | v2 `disputeUntil` | RNAME `disputeUntil` | v1 `status` | v1 `disputeUntil` | +|---|---|---|---|---|---| +| disputable | `registered` | its end | its end | `registered` | its end | +| final | `registered` | null | absent | `registered` or `grace` | null | +| unregistered | `available` or `reserved` | not a field | not a field | `unregistered`, "this name is not registered" | null | ```mermaid sequenceDiagram @@ -59,25 +61,16 @@ sequenceDiagram R->>S: GET /v2/resolve/query S->>N: one multicall: nameExpires, disputeUntil (added), GRACE_PERIOD and the other reads of the round N-->>S: disputeUntil reverted by a registrar before #51 - S-->>R: registered, with disputeUntil when later than lastBlockTs (added) - R->>R: decoded into NRRegistered with disputeUntil (added) + S-->>R: registered, with disputeUntil when later than lastBlockTs, else null (added) + R->>R: decoded into NRRegistered with disputeUntil, null decoded as Nothing (added) R-->>P: RRES with RNAME, encoded at the forwarded version, at most 23 P-->>C: PRES ``` -## Version - -No SMP version is added for `disputeUntil`, because a version would not tell a client "no dispute period" from "not reported": - -- forwarded RSLV, the path clients SHOULD prefer, is answered at the version the proxy negotiated, at most `proxiedSMPRelayVersion` (23, `proxyResp` in `Server.hs`); a field gated on v24 would be withheld on that path until proxies raise that version, and the session version would not show the names router's support; -- a router passes what its resolver answers, and the resolver's API is versioned apart from SMP; a v24 router with an older resolver would omit the field as well. - -The field is optional, and receivers tolerate unknown fields, so routers and clients before it decode the answers unchanged, as for `NRAvailable.nameTerms`. A client MUST NOT conclude from the field's absence that the registration cannot be ended: it is absent when no dispute period is in effect at `lastBlockTs`, and from a router or resolver that predates it. - ## Threat model - A router or its resolver can omit `disputeUntil` or state a false one, as it can `expires`; a client verifies it only by reading the registrar. -- `disputeUntil` is public on chain (contract plan, D9), and with it the dispute days of the payment: 0, 14 or 120. The answer discloses to the router and the client what the chain discloses. +- `disputeUntil` is public on chain (contract plan, D9), and with it the dispute days of the payment: 0, 14 or 120. In the answer, it is disclosed to the router and the client as on chain. - A JSON-RPC error of the `disputeUntil` call alone is read as a revert, as for records and `namePolicy()`, and the name is answered without a dispute end. - A label the registrar recorded stays recorded after the registration expired or was ended, so whoever runs the resolver matches a hashed query of such a name to its label. @@ -90,7 +83,9 @@ The field is optional, and receivers tolerate unknown fields, so routers and cli - `dispute_until_call`, read in `lookup_reads` - `dispute_end`: the registrar's `disputeUntil` when later than the block, else None - `name_status`: `disputeUntil`, also in v1 answers -- `registration`: `disputeUntil` in `registered` when set +- `registration`: `disputeUntil` in `registered`, null when unset +- the comment on the reads keyed on the labelhash: `disputeUntil` +- the docstring of `expiry_status`: any name with a zero expiry `scripts/resolver/README.md`: @@ -102,12 +97,15 @@ The field is optional, and receivers tolerate unknown fields, so routers and cli - the premium paragraph - `disputeUntil` in the v1 example, in `registered` and in the definition of the dispute period - a subname's dispute end in v2 +- `disputeUntil` in the lists of status fields and of the registrar's reads `protocol/simplex-messaging.md`: -- a hashed query of a name nobody holds -- the dispute period, after the registration types -- `disputeUntil` in the fields of `registered` +- a hashed query of a name nobody holds: `available` or `reserved` +- `registered`: unless ended before `disputeUntil`, and renewable not before it +- the dispute period, defined by `disputeUntil` +- `disputeUntil` in the fields of `registered`, also absent when it could not be read +- an answer below v22: no dispute end `src/Simplex/Messaging/Names/Record.hs`: `NRRegistered.disputeUntil`. @@ -122,10 +120,10 @@ The tests of changed behavior are committed before the change, and fail on that - `ErrorCodeTests`: a name with expiry 0 answered 404 with "this name is not registered" - three test names that equate expiry 0 with never registered - `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 not reported; a registrar that reverts or answers nothing read as none; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch -- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`; v1 with it and with null +- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, and null in the pinned keys of `registered`; v1 with it and with null; a subname under a 2LD with expiry 0, whose node a former holder owns: v2 `available`, v1 404 - `BatchedReadsTests`: `disputeUntil` read in the round of `nameExpires`, in two round trips - the fakes of the registrar answer `disputeUntil` -`tests/SMPNamesTests.hs`: the router's answer equal to the resolver's JSON of a registration with `disputeUntil`. +`tests/SMPNamesTests.hs`: the router's answer to a registration with `disputeUntil`, as the resolver serves it, decoded into `NRRegistered`; the JSON round trip of that value. -`tests/RSLVTests.hs`: RNAME, direct and forwarded through a proxy, equal to the resolver's JSON of a registration with `disputeUntil`. +`tests/RSLVTests.hs`: RNAME of that registration, direct and forwarded through a proxy. From 7284418b4ea14a6250d8ffc88a97266f73c8e69b Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:47:45 +0000 Subject: [PATCH 18/44] resolver: test a null dispute end, and a subname under an ended 2LD --- scripts/resolver/service/test_snrc_resolve.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index d08f2d043..ad6fb08f5 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -1009,6 +1009,11 @@ def test_a_registration_in_its_dispute_period_says_until_when(self): self.assertEqual(body["type"], "registered") self.assertEqual(body["disputeUntil"], self.now + 600) + def test_a_registration_without_a_dispute_period_has_a_null_dispute_end(self): + snrc.eth_call = self._chain(self.now + 3600) + _, body = registration("acme.testing") + self.assertIsNone(body["disputeUntil"]) + def test_v1_reports_the_dispute_end_and_null_without_one(self): for until, reported in ((self.now + 600, self.now + 600), (0, None)): with self.subTest(until=until): @@ -1069,10 +1074,10 @@ def test_a_status_it_cannot_read_is_an_error_not_a_registration(self): self.assertEqual(body["error"], "unknown") def test_each_answer_carries_exactly_its_own_fields(self): - """The relay decodes by these names; an extra or missing one is a break.""" + """The relay decodes by these names; a missing one is a break.""" cases = { "registered": (self._chain(self.now + 3600), - {"type", "expires", "graceUntil", "reservedReason_", "nameRecord"}), + {"type", "expires", "graceUntil", "disputeUntil", "reservedReason_", "nameRecord"}), "available": (self._chain(0), {"type", "pricing"}), "reserved": (self._chain(0, reserved=1), {"type", "reservedReason"}), } @@ -1129,6 +1134,16 @@ def test_a_subnode_a_former_holder_owns_is_not_registered(self): _, body = registration("sub.acme.testing") self.assertEqual(body["type"], "available") + def test_a_subname_under_a_2ld_with_zero_expiry_is_not_registered(self): + snrc.eth_call = self._chain(0, owner=self.FORMER_OWNER) + _, body = registration("sub.acme.testing") + self.assertEqual(body["type"], "available") + + def test_v1_answers_404_for_a_subname_under_a_2ld_with_zero_expiry(self): + snrc.eth_call = self._chain(0, owner=self.FORMER_OWNER) + status, body = snrc.resolve("sub.acme.testing") + self.assertEqual((status, body["error"]), (404, "unregistered")) + def test_v1_does_not_resolve_a_subnode_a_former_holder_owns(self): snrc.eth_call = self._chain(self.now + 3600, owner=self.FORMER_OWNER, holder=self.OWNER) status, body = snrc.resolve("sub.acme.testing") From 437100b8859a583fb370bdf1d1a3603f3889d856 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:47:59 +0000 Subject: [PATCH 19/44] resolver: answer a null dispute end, as a null reservation is answered --- scripts/resolver/service/snrc-resolve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index ab8c95474..f7f1c072d 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -1211,7 +1211,7 @@ def registration(name: str): "type": "registered", "expires": reg["expires"], "graceUntil": reg["graceEnds"], - **({"disputeUntil": reg["disputeUntil"]} if reg["disputeUntil"] else {}), + "disputeUntil": reg["disputeUntil"], "reservedReason_": reg["reasonCode"], "nameRecord": rec, }) From ccaa9be05188c1c5cdffe7066edf68eb0911182d Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:48:56 +0000 Subject: [PATCH 20/44] names: test the dispute end as a typed value, from the resolver's shape --- tests/RSLVTests.hs | 9 +++------ tests/SMPNamesTests.hs | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/RSLVTests.hs b/tests/RSLVTests.hs index 8e03f81f1..912acd332 100644 --- a/tests/RSLVTests.hs +++ b/tests/RSLVTests.hs @@ -14,7 +14,6 @@ module RSLVTests (rslvTests) where import Control.Concurrent (threadDelay) import Control.Monad (forM_) import Control.Monad.Trans.Except (ExceptT, runExceptT) -import qualified Data.Aeson as J import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy as LB import Data.IORef (IORef, readIORef) @@ -30,7 +29,7 @@ import SMPClient import Simplex.Messaging.Client import qualified Simplex.Messaging.Crypto as C import Simplex.Messaging.Encoding.String (strDecode) -import SMPNamesTests (availableBody, disputedBody, jsonValue, registeredBody, reservedBody, resolved, testNameRecord, testPricing) +import SMPNamesTests (availableBody, disputedAlice, disputedBody, registeredBody, reservedBody, resolved, testNameRecord, testPricing) import Simplex.Messaging.Protocol ( BrokerMsg (..), Cmd (..), @@ -182,7 +181,7 @@ testRslvForwardedDisputeEnd :: HasTestEnv => IO () testRslvForwardedDisputeEnd = withProxyAndResolver (status200, disputedBody) $ forwardedResolveAlice >>= \case - Right (Right res) -> J.toJSON res `shouldBe` jsonValue disputedBody + Right (Right res) -> res `shouldBe` resolved disputedAlice r -> expectationFailure $ "expected Right (Right NameResponse), got: " <> show r testRslvSuccess :: HasTestEnv => IO () @@ -200,9 +199,7 @@ testRslvDisputeEnd = withResolverServer (status200, disputedBody) $ testSMPClient @TLS $ \h -> do (_, _, resp) <- sendRslv h "rs08" (domain "alice.simplex") - case resp of - Right (RNAME res) -> J.toJSON res `shouldBe` jsonValue disputedBody - _ -> expectationFailure $ "expected Right (RNAME _), got: " <> show resp + resp `shouldBe` Right (RNAME (resolved disputedAlice)) testRslvAvailable :: HasTestEnv => IO () testRslvAvailable = diff --git a/tests/SMPNamesTests.hs b/tests/SMPNamesTests.hs index 35e6b06dd..c0c989845 100644 --- a/tests/SMPNamesTests.hs +++ b/tests/SMPNamesTests.hs @@ -3,7 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -module SMPNamesTests (smpNamesTests, testNameRecord, testPricing, registeredBody, disputedBody, availableBody, reservedBody, responseBody, resolved, jsonValue) where +module SMPNamesTests (smpNamesTests, testNameRecord, testPricing, registeredBody, disputedBody, disputedAlice, availableBody, reservedBody, responseBody, resolved) where import qualified Data.Aeson as J import qualified Data.ByteString.Char8 as B @@ -54,14 +54,11 @@ testNameRecord = -- from the Haskell value: the literal JSON is the contract with the resolver. registeredBody :: NameRecord -> LB.ByteString registeredBody nameRec = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"reservedReason_\":null,\"nameRecord\":" <> J.encode nameRec <> "}" + responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":null,\"reservedReason_\":null,\"nameRecord\":" <> J.encode nameRec <> "}" disputedBody :: LB.ByteString disputedBody = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":1813100000,\"nameRecord\":" <> J.encode testNameRecord <> "}" - -jsonValue :: LB.ByteString -> J.Value -jsonValue = either error id . J.eitherDecode + responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":1813100000,\"reservedReason_\":null,\"nameRecord\":" <> J.encode testNameRecord <> "}" availableBody :: LB.ByteString availableBody = responseBody "{\"type\":\"available\",\"pricing\":{\"registrationPrices\":{\"3\":12793,\"4\":3198},\"basePrice\":100,\"minLabelLength\":3}}" @@ -84,6 +81,10 @@ registeredAlice :: NameRegistration registeredAlice = NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Nothing, nameRecord = testNameRecord} +disputedAlice :: NameRegistration +disputedAlice = + NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Just (RoundedSystemTime 1813100000), reservedReason_ = Nothing, nameRecord = testNameRecord} + smpNamesTests :: Spec smpNamesTests = do describe "NameRecord JSON (Protocol)" nameRecordEncodingSpec @@ -169,10 +170,8 @@ availabilitySpec = do it "a registered name can be held back too" $ answers heldBackBody . resolved $ NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord} - it "a registration in its dispute period is answered with its end, as the resolver sent it" $ - withResolverServer (resolveResp status200 disputedBody) $ \port _ -> do - env <- newNamesEnv (testNamesConfig port) - (fmap J.toJSON <$> resolveName env aliceQuery) `shouldReturn` Right (jsonValue disputedBody) + it "a registration in its dispute period is answered with its end" $ + answers disputedBody (resolved disputedAlice) it "an unregistered name answers with the price" $ answers availableBody (resolved NRAvailable {pricing = testPricing, nameTerms = Nothing}) it "reserved carries the reason and no price" $ @@ -185,6 +184,7 @@ availabilitySpec = do mapM_ (\a -> J.eitherDecodeStrict (LB.toStrict (J.encode a)) `shouldBe` Right a) [ registeredAlice, + disputedAlice, NRRegistered {expires = Nothing, graceUntil = Nothing, disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord}, NRAvailable {pricing = testPricing, nameTerms = Nothing}, NRReserved NRRInternal, From de62561a6a5b20b4b20c5376bd78f11c60a689ee Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:33:44 +0000 Subject: [PATCH 21/44] docs: name every registrar controller as able to end a registration --- protocol/simplex-messaging.md | 9 +++++---- scripts/resolver/README.md | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index 007dd8489..8f0f4ce1e 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1557,10 +1557,11 @@ MUST NOT treat an answer as current without checking it. | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | A registration answered with `disputeUntil` is in its dispute period: until -then, its renewal is refused, and the owner or the guardian of the registry's -controller contract can end it; a router then answers for the name as for a name -never registered. On `.simplex`, a registration made through the registry's -sponsor contract has a dispute period of 14 to 120 days from its registration. +then, its renewal is refused, and a controller of the registry's registrar can +end it, such as the registry's controller contract on the request of its owner +or guardian; a router then answers for the name as for a name never registered. +On `.simplex`, a registration made through the registry's sponsor contract has a +dispute period of 14 to 120 days from its registration. | Field | On | JSON type | Constraints | |---|---|---|---| diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 0b42a643e..acdc54aa3 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -237,8 +237,9 @@ holds for a name nobody ever registered (`0 + GRACE_PERIOD < now`), so the resolver tells `unregistered` from `expired` by a zero expiry. On `.simplex`, a registration made through the controller's `registerSponsored` has a dispute period of 14 to 120 days, and the registrar stores its end as `disputeUntil`. -Within it, a renewal is refused, and the controller's owner or guardian -(`beneficiary`) can end the registration; the registrar then sets a zero expiry. +Within it, a renewal is refused, and a registrar controller can end the +registration, such as the controller on the request of its owner or guardian +(`beneficiary`); the registrar then sets a zero expiry. The resolver reports that end as `disputeUntil` while it is later than `now`, and null otherwise. The call to a registrar from before dispute periods, such as `.testing`'s, reverts, and is read as none. From d08ebd817b3d33c44cb837bca0d573a00bb0173e Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:34:17 +0000 Subject: [PATCH 22/44] docs: state where each status field is read from, and when it is null --- scripts/resolver/README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index acdc54aa3..330315769 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -214,8 +214,9 @@ identically (`bar.foobar.testing`). A response contains `status`, `expires`, `graceEnds` and `disputeUntil` whenever the resolver read them, a successful resolve included, so a client that has just resolved a name already knows when it expires. The timestamps are Unix -seconds, and `null` when they could not be read; `disputeUntil` is also `null` -when no dispute period is in effect. +seconds. All are `null` when no registrar is configured, `expires` and +`graceEnds` also for a zero expiry, and `disputeUntil` also when no dispute +period is in effect or it could not be read. | `status` | Meaning | |---|---| @@ -257,7 +258,8 @@ which is free to change. ```jsonc {"name": "nope.testing", "error": "unregistered", "message": "this name is not registered", - "status": "unregistered", "expires": null, "graceEnds": null} + "status": "unregistered", "lastBlockTs": 1780000000, "expires": null, + "graceEnds": null, "disputeUntil": null, "reasonCode": null, "reason": null} ``` The codes are `tldNotConfigured`, `notFullyQualified`, `unregistered`, @@ -293,16 +295,16 @@ curl -s "http://127.0.0.1:8000/resolve/[$(printf acme | keccak-256sum | cut -d' ``` namehash is `keccak(parent || keccak(label))`, so this reaches the same node and -returns the same record. The registrar keys `nameExpires`, `disputeUntil` and -`reservedNames` on the labelhash too, so the status fields are read without the -label as well. +returns the same record. The registrar keys `nameExpires` and `disputeUntil`, +and the name policy or the controller keys `reservedNames`, on the labelhash +too, so the status fields are read without the label as well. Only the second-level label is a registry key, and `status` decodes a bracket there at any depth. The record does not: a bracket is decoded only in a two-label name, so `sub.[].testing` is not a supported query. Subname labels stay text; a bracket label left of the 2LD is an ordinary label. Routers -from v22 send every 2LD this way, so a registrable name normally never reaches -this service. +from v22 send every 2LD this way, so the label of a name never registered +normally never reaches this service. On v2, read `type`: only `available` means the name is free. On v1, read `status`: a name is free on `unregistered` (404) and on `expired` (410), every @@ -378,9 +380,9 @@ The resolver reads three contracts, each configured per TLD, the name policy a controller names, and the subname registrar a registrar names. The **registry** answers who owns a node, and `/resolve` reads the records from -it. The **registrar** (ERC-721) holds `nameExpires` and `GRACE_PERIOD`, which -is where every expiry field comes from, `disputeUntil`, the end of a dispute -period, and `labelOf`, which is how a hashed query is answered with a name. A +it. The **registrar** (ERC-721) holds `nameExpires` and `GRACE_PERIOD`, the +source of every expiry field; `disputeUntil`, the end of a dispute period; and +`labelOf`, which is how a hashed query is answered with a name. A name registered without recording its label cannot answer one, and `/v2/resolve` refuses it rather than answer with a name the client will reject. Its `subnameHook()` names the subname registrar, whose `ownerOf` says who holds From 57151a2de68e3df9164a857d0c2269fb37bbac8f Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:34:28 +0000 Subject: [PATCH 23/44] resolver: restore the docstring of the pinned key-set test --- scripts/resolver/service/test_snrc_resolve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index ad6fb08f5..ee730a988 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -1074,7 +1074,7 @@ def test_a_status_it_cannot_read_is_an_error_not_a_registration(self): self.assertEqual(body["error"], "unknown") def test_each_answer_carries_exactly_its_own_fields(self): - """The relay decodes by these names; a missing one is a break.""" + """The relay decodes by these names; an extra or missing one is a break.""" cases = { "registered": (self._chain(self.now + 3600), {"type", "expires", "graceUntil", "disputeUntil", "reservedReason_", "nameRecord"}), From 51543e485041ad49572213014433a1bf58a6bcad Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:56:26 +0000 Subject: [PATCH 24/44] resolver: test a subname under an ended 2LD whose node has no owner --- scripts/resolver/service/test_snrc_resolve.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index ee730a988..dfba7b094 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -1135,12 +1135,12 @@ def test_a_subnode_a_former_holder_owns_is_not_registered(self): self.assertEqual(body["type"], "available") def test_a_subname_under_a_2ld_with_zero_expiry_is_not_registered(self): - snrc.eth_call = self._chain(0, owner=self.FORMER_OWNER) + snrc.eth_call = self._chain(0, owner=self.FORMER_OWNER, holder=snrc.ZERO_ADDR) _, body = registration("sub.acme.testing") self.assertEqual(body["type"], "available") def test_v1_answers_404_for_a_subname_under_a_2ld_with_zero_expiry(self): - snrc.eth_call = self._chain(0, owner=self.FORMER_OWNER) + snrc.eth_call = self._chain(0, owner=self.FORMER_OWNER, holder=snrc.ZERO_ADDR) status, body = snrc.resolve("sub.acme.testing") self.assertEqual((status, body["error"]), (404, "unregistered")) From a100b481f9d3cb58cc8e95c7e4badfe6107a8e50 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:56:57 +0000 Subject: [PATCH 25/44] names, resolver: plan who ends a registration, and the regression tests --- plans/2026-11-20-names-dispute-period.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plans/2026-11-20-names-dispute-period.md b/plans/2026-11-20-names-dispute-period.md index 10818669d..849d829f9 100644 --- a/plans/2026-11-20-names-dispute-period.md +++ b/plans/2026-11-20-names-dispute-period.md @@ -4,8 +4,8 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period ## Problems -1. After #51, the owner or the guardian of the `.simplex` controller can end a registration in its dispute period, and the registrar sets the name's expiry to 0. On its v1 route, the resolver answers every name with expiry 0 with the message "this name has never been registered". In the resolver's README, `unregistered` is described as never registered and `registered` as held until `expires`, and in the protocol a registered name is described as held until `expires`. -2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after a claim moved the name to a recipient, and its renewal is refused. By decision D8 of the contract plan, clients show the dispute end before a claim. +1. After #51, a controller of the `.simplex` registrar, such as the controller contract on the request of its owner or guardian, can end a registration in its dispute period, and the registrar sets the name's expiry to 0. On its v1 route, the resolver answers every name with expiry 0 with the message "this name has never been registered". In the resolver's README, `unregistered` is described as never registered and `registered` as held until `expires`, and in the protocol a registered name is described as held until `expires`. +2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after the name was moved to a recipient by a claim, and its renewal is refused. By decision D8 of the contract plan, clients show the dispute end before a claim. ## Decisions @@ -16,10 +16,10 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period | 3 | price quotes of a name with expiry 0 unchanged | | 4 | the registrar's `disputeUntil(uint256)` read for the 2LD's token, in the round of `nameExpires` | | 5 | `disputeUntil` reported while later than `lastBlockTs`, otherwise null; the router omits a null one in RNAME | -| 6 | a `disputeUntil` call that reverts or answers nothing read as no dispute period; `.testing`'s registrar predates #51 | +| 6 | a `disputeUntil` call that reverts or answers nothing read as no dispute period | | 7 | a subname reported with its 2LD's `disputeUntil` | | 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields | -| 9 | no SMP version; a client does not read the absence of `disputeUntil` as the end of a dispute period | +| 9 | SMP version unchanged; a client does not read the absence of `disputeUntil` as the end of a dispute period | ## What the resolver answers @@ -37,7 +37,7 @@ stateDiagram-v2 [*] --> disputable: sponsored registration, 14 to 120 days [*] --> final: registration without a dispute period disputable --> final: at disputeUntil - disputable --> unregistered: ended by the controller's owner or guardian + disputable --> unregistered: ended by a controller of the registrar unregistered --> [*]: available to any registration ``` @@ -98,6 +98,8 @@ sequenceDiagram - `disputeUntil` in the v1 example, in `registered` and in the definition of the dispute period - a subname's dispute end in v2 - `disputeUntil` in the lists of status fields and of the registrar's reads +- the source of each status field, and when it is null, also in the error example +- a hashed query: the label of a name never registered stays unknown to the service `protocol/simplex-messaging.md`: @@ -120,10 +122,12 @@ The tests of changed behavior are committed before the change, and fail on that - `ErrorCodeTests`: a name with expiry 0 answered 404 with "this name is not registered" - three test names that equate expiry 0 with never registered - `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 not reported; a registrar that reverts or answers nothing read as none; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch -- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, and null in the pinned keys of `registered`; v1 with it and with null; a subname under a 2LD with expiry 0, whose node a former holder owns: v2 `available`, v1 404 +- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, and null in the pinned keys of `registered`; v1 with it and with null - `BatchedReadsTests`: `disputeUntil` read in the round of `nameExpires`, in two round trips - the fakes of the registrar answer `disputeUntil` +Regression tests, passing before the change, in `RegistrationV2Tests`: a subname under a 2LD with expiry 0, whose node has no owner while the subnode keeps a former holder: v2 `available`, v1 404. + `tests/SMPNamesTests.hs`: the router's answer to a registration with `disputeUntil`, as the resolver serves it, decoded into `NRRegistered`; the JSON round trip of that value. `tests/RSLVTests.hs`: RNAME of that registration, direct and forwarded through a proxy. From 30594daa7d206d4e1c309443febc308e73cb0d04 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:57:09 +0000 Subject: [PATCH 26/44] names: build an old router's answer in the test by field name --- tests/RSLVTests.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RSLVTests.hs b/tests/RSLVTests.hs index 912acd332..41ae3b19a 100644 --- a/tests/RSLVTests.hs +++ b/tests/RSLVTests.hs @@ -234,7 +234,7 @@ testRslvOldClientRecord = withResolverServer (status200, registeredBody testNameRecord) $ do pc <- oldClient r <- runExceptT' (directResolveName pc NRMInteractive (domain "alice.simplex")) - r `shouldBe` NameResponse Nothing (NRRegistered Nothing Nothing Nothing Nothing testNameRecord) + r `shouldBe` NameResponse Nothing (NRRegistered {expires = Nothing, graceUntil = Nothing, disputeUntil = Nothing, reservedReason_ = Nothing, nameRecord = testNameRecord}) testRslvOldClientNotFound :: HasTestEnv => IO () testRslvOldClientNotFound = From 309f7e918afcef738ec41fd428d571c7421b916d Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:06:13 +0000 Subject: [PATCH 27/44] resolver: state why the keys of each answer are pinned --- scripts/resolver/service/test_snrc_resolve.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index dfba7b094..dc1b4bf6b 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -1074,7 +1074,8 @@ def test_a_status_it_cannot_read_is_an_error_not_a_registration(self): self.assertEqual(body["error"], "unknown") def test_each_answer_carries_exactly_its_own_fields(self): - """The relay decodes by these names; an extra or missing one is a break.""" + """The relay decodes by these names; with the set pinned, a key cannot be + renamed or added without the Haskell side.""" cases = { "registered": (self._chain(self.now + 3600), {"type", "expires", "graceUntil", "disputeUntil", "reservedReason_", "nameRecord"}), From fd5ebce94751f4153dc29f6b25a7e7ded94d86c6 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:07:01 +0000 Subject: [PATCH 28/44] names, resolver: plan a dispute end of 0, and unknown on a node error --- plans/2026-11-20-names-dispute-period.md | 53 ++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/plans/2026-11-20-names-dispute-period.md b/plans/2026-11-20-names-dispute-period.md index 849d829f9..31718c9f1 100644 --- a/plans/2026-11-20-names-dispute-period.md +++ b/plans/2026-11-20-names-dispute-period.md @@ -15,11 +15,11 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period | 2 | message of a v1 404 `unregistered`: "this name is not registered" | | 3 | price quotes of a name with expiry 0 unchanged | | 4 | the registrar's `disputeUntil(uint256)` read for the 2LD's token, in the round of `nameExpires` | -| 5 | `disputeUntil` reported while later than `lastBlockTs`, otherwise null; the router omits a null one in RNAME | -| 6 | a `disputeUntil` call that reverts or answers nothing read as no dispute period | +| 5 | `disputeUntil`: the registrar's value while later than `lastBlockTs`, otherwise 0; unknown when the node fails the read: absent in v2 and in RNAME, null in v1 | +| 6 | a revert of the `disputeUntil` call, by JSON-RPC error code 3 or a failed call in a multicall, read as 0; another error and an empty answer read as unknown | | 7 | a subname reported with its 2LD's `disputeUntil` | -| 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields | -| 9 | SMP version unchanged; a client does not read the absence of `disputeUntil` as the end of a dispute period | +| 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields; its Haddock states a date, 0 and absent | +| 9 | SMP version unchanged; a client does not read the absence of `disputeUntil` as 0 | ## What the resolver answers @@ -28,8 +28,11 @@ name_status(name): token = labelhash of the 2LD expires = registrar.nameExpires(token) now = timestamp of the latest block - until = registrar.disputeUntil(token), 0 when the call reverts or answers nothing - disputeUntil = until when until > now, else null + disputeUntil = case registrar.disputeUntil(token) of + a value > now -> the value + another value -> 0 + a revert -> 0 + another error, or empty -> unknown ``` ```mermaid @@ -46,8 +49,10 @@ For a 2LD: | State | v2 `type` | v2 `disputeUntil` | RNAME `disputeUntil` | v1 `status` | v1 `disputeUntil` | |---|---|---|---|---|---| | disputable | `registered` | its end | its end | `registered` | its end | -| final | `registered` | null | absent | `registered` or `grace` | null | -| unregistered | `available` or `reserved` | not a field | not a field | `unregistered`, "this name is not registered" | null | +| final | `registered` | 0 | 0 | `registered` or `grace` | 0 | +| unregistered | `available` or `reserved` | not a field | not a field | `unregistered`, "this name is not registered" | 0 | + +A `disputeUntil` read that the node fails: absent in v2 and in RNAME, null in v1. ```mermaid sequenceDiagram @@ -61,8 +66,8 @@ sequenceDiagram R->>S: GET /v2/resolve/query S->>N: one multicall: nameExpires, disputeUntil (added), GRACE_PERIOD and the other reads of the round N-->>S: disputeUntil reverted by a registrar before #51 - S-->>R: registered, with disputeUntil when later than lastBlockTs, else null (added) - R->>R: decoded into NRRegistered with disputeUntil, null decoded as Nothing (added) + S-->>R: registered, with disputeUntil: its end, or 0; absent when the node failed the read (added) + R->>R: decoded into NRRegistered with disputeUntil, absent decoded as Nothing (added) R-->>P: RRES with RNAME, encoded at the forwarded version, at most 23 P-->>C: PRES ``` @@ -71,7 +76,8 @@ sequenceDiagram - A router or its resolver can omit `disputeUntil` or state a false one, as it can `expires`; a client verifies it only by reading the registrar. - `disputeUntil` is public on chain (contract plan, D9), and with it the dispute days of the payment: 0, 14 or 120. In the answer, it is disclosed to the router and the client as on chain. -- A JSON-RPC error of the `disputeUntil` call alone is read as a revert, as for records and `namePolicy()`, and the name is answered without a dispute end. +- A JSON-RPC error of the `disputeUntil` call alone, other than a revert, leaves the dispute end unknown, and the name is answered without it. +- A revert answered by the node is read as 0, so the resolver relies on its node for 0 as for every other read. - A label the registrar recorded stays recorded after the registration expired or was ended, so whoever runs the resolver matches a hashed query of such a name to its label. ## Changes @@ -81,9 +87,10 @@ sequenceDiagram - the message of decision 2 - the docstring of `read_oracle_prices`: a quote is safe for a name with expiry 0 - `dispute_until_call`, read in `lookup_reads` -- `dispute_end`: the registrar's `disputeUntil` when later than the block, else None +- `CallReverted`: a JSON-RPC error with code 3, and a call failed in a multicall +- `dispute_end`: the registrar's `disputeUntil` when later than the block, 0 otherwise and on a revert, None on another error or an empty answer - `name_status`: `disputeUntil`, also in v1 answers -- `registration`: `disputeUntil` in `registered`, null when unset +- `registration`: `disputeUntil` in `registered`, absent when unknown - the comment on the reads keyed on the labelhash: `disputeUntil` - the docstring of `expiry_status`: any name with a zero expiry @@ -98,18 +105,18 @@ sequenceDiagram - `disputeUntil` in the v1 example, in `registered` and in the definition of the dispute period - a subname's dispute end in v2 - `disputeUntil` in the lists of status fields and of the registrar's reads -- the source of each status field, and when it is null, also in the error example +- the source of each status field, and when it is null or 0, also in the error example - a hashed query: the label of a name never registered stays unknown to the service `protocol/simplex-messaging.md`: - a hashed query of a name nobody holds: `available` or `reserved` - `registered`: unless ended before `disputeUntil`, and renewable not before it -- the dispute period, defined by `disputeUntil` -- `disputeUntil` in the fields of `registered`, also absent when it could not be read +- the dispute period, defined by a `disputeUntil` after `lastBlockTs` +- `disputeUntil` in the fields of `registered`: a date, 0, or absent when unknown - an answer below v22: no dispute end -`src/Simplex/Messaging/Names/Record.hs`: `NRRegistered.disputeUntil`. +`src/Simplex/Messaging/Names/Record.hs`: `NRRegistered.disputeUntil`, with the Haddock of decision 8. `src/Simplex/Messaging/Protocol.hs`: `disputeUntil = Nothing` in the answer of a router before v22. @@ -121,12 +128,16 @@ The tests of changed behavior are committed before the change, and fail on that - `ErrorCodeTests`: a name with expiry 0 answered 404 with "this name is not registered" - three test names that equate expiry 0 with never registered -- `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 not reported; a registrar that reverts or answers nothing read as none; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch -- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, and null in the pinned keys of `registered`; v1 with it and with null -- `BatchedReadsTests`: `disputeUntil` read in the round of `nameExpires`, in two round trips +- `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 reported as 0; a revert, the node's error code 3, read as 0; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch +- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, with 0, and without it when the node fails the read; 0 in the pinned keys of `registered`; v1 with it, with 0 and with null +- `BatchedReadsTests`: `disputeUntil` read in the round of `nameExpires`, in two round trips; a revert read as 0 in a multicall and in a batch - the fakes of the registrar answer `disputeUntil` -Regression tests, passing before the change, in `RegistrationV2Tests`: a subname under a 2LD with expiry 0, whose node has no owner while the subnode keeps a former holder: v2 `available`, v1 404. +Regression tests, passing before the change: + +- `RegistrationV2Tests`: a subname under a 2LD with expiry 0, whose node has no owner while the subnode keeps a former holder: v2 `available`, v1 404 +- `NameStatusTests`: another node error and an empty answer read as unknown +- `tests/SMPNamesTests.hs`: a dispute end of 0, as the resolver serves it, decoded into `NRRegistered`, and its JSON round trip `tests/SMPNamesTests.hs`: the router's answer to a registration with `disputeUntil`, as the resolver serves it, decoded into `NRRegistered`; the JSON round trip of that value. From 5b15d53069437b7f4eaa5429c04a3bca9703d713 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:08:36 +0000 Subject: [PATCH 29/44] resolver: test a dispute end of 0, and an unknown one on a node error --- scripts/resolver/service/test_snrc_resolve.py | 70 ++++++++++++------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index dc1b4bf6b..283588302 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -22,6 +22,7 @@ import time import unittest from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from unittest import mock from urllib.error import HTTPError from urllib.parse import urlparse from urllib.request import Request, urlopen @@ -208,22 +209,28 @@ def eth_call(to, data): if data.startswith(snrc.selector("GRACE_PERIOD()")): return "0x" + snrc.encode_uint(self.GRACE) if data.startswith(snrc.selector("disputeUntil(uint256)")): - if dispute_until is None: - raise RuntimeError("execution reverted") return "0x" + snrc.encode_uint(dispute_until) self.assertTrue(data.startswith(snrc.selector("nameExpires(uint256)"))) return "0x" + snrc.encode_uint(value) return eth_call - def _keys(self, status, expires, grace_ends, read_at=-1): + def _node(self, dispute_answer): + answers = { + snrc.selector("nameExpires(uint256)"): {"result": "0x" + snrc.encode_uint(self.now + 3600)}, + snrc.selector("GRACE_PERIOD()"): {"result": "0x" + snrc.encode_uint(self.GRACE)}, + snrc.selector("disputeUntil(uint256)"): dispute_answer, + } + return lambda payload: answers[payload["params"][0]["data"][:10]] + + def _keys(self, status, expires, grace_ends, read_at=-1, dispute_until=0): """Every branch answers with the same keys; only some carry values.""" return { "status": status, "lastBlockTs": self.now if read_at == -1 else read_at, "expires": expires, "graceEnds": grace_ends, - "disputeUntil": None, + "disputeUntil": dispute_until, "reasonCode": None, "reason": None, } @@ -342,27 +349,24 @@ def test_a_dispute_end_after_the_block_is_reported(self): snrc.eth_call = self._expiry(self.now + 3600, dispute_until=self.now + 1) self.assertEqual(snrc.name_status("alice.testing")["disputeUntil"], self.now + 1) - def test_a_dispute_end_not_after_the_block_is_not_reported(self): + def test_a_dispute_end_not_after_the_block_is_reported_as_0(self): for until in (self.now, self.now - 1, 0): with self.subTest(until=until): snrc.eth_call = self._expiry(self.now + 3600, dispute_until=until) - self.assertIsNone(snrc.name_status("alice.testing")["disputeUntil"]) + self.assertEqual(snrc.name_status("alice.testing")["disputeUntil"], 0) - def test_a_registrar_reverting_the_dispute_end_reports_none(self): - snrc.eth_call = self._expiry(self.now + 3600, dispute_until=None) - reg = snrc.name_status("alice.testing") - self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) + def test_a_reverted_dispute_end_is_reported_as_0(self): + snrc.eth_call = self._saved[2] + with mock.patch.object(snrc, "_send_rpc", self._node({"error": {"code": 3, "message": "execution reverted"}})): + reg = snrc.name_status("alice.testing") + self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", 0)) - def test_a_registrar_answering_nothing_for_the_dispute_end_reports_none(self): + def test_a_dispute_end_the_node_could_not_read_is_unknown(self): snrc.eth_call = self._saved[2] - answers = { - snrc.selector("nameExpires(uint256)"): "0x" + snrc.encode_uint(self.now + 3600), - snrc.selector("GRACE_PERIOD()"): "0x" + snrc.encode_uint(self.GRACE), - snrc.selector("disputeUntil(uint256)"): "0x", - } - snrc.rpc = lambda method, params: answers[params[0]["data"][:10]] - reg = snrc.name_status("alice.testing") - self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) + for answer in ({"error": {"code": -32000, "message": "header not found"}}, {"result": "0x"}): + with self.subTest(answer=answer), mock.patch.object(snrc, "_send_rpc", self._node(answer)): + reg = snrc.name_status("alice.testing") + self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) def test_a_subname_reports_the_dispute_end_of_its_2ld(self): alice = snrc.selector("disputeUntil(uint256)") + snrc.encode_uint(snrc.label_token("alice")) @@ -381,7 +385,7 @@ def test_unconfigured_tld_is_unknown_rather_than_unregistered(self): snrc.eth_call = lambda *a: self.fail("must not reach the chain") self.assertEqual( snrc.name_status("alice.testing"), - self._keys("unknown", None, None, read_at=None), + self._keys("unknown", None, None, read_at=None, dispute_until=None), ) def test_every_branch_returns_the_same_keys(self): @@ -953,6 +957,8 @@ def eth_call(to, data): if data.startswith(snrc.selector("nameExpires(uint256)")): return "0x" + snrc.encode_uint(expires) if data.startswith(snrc.selector("disputeUntil(uint256)")): + if dispute_until is None: + raise RuntimeError({"code": -32000, "message": "header not found"}) return "0x" + snrc.encode_uint(dispute_until) if data.startswith(snrc.selector("GRACE_PERIOD()")): return "0x" + snrc.encode_uint(self.GRACE) @@ -1009,13 +1015,19 @@ def test_a_registration_in_its_dispute_period_says_until_when(self): self.assertEqual(body["type"], "registered") self.assertEqual(body["disputeUntil"], self.now + 600) - def test_a_registration_without_a_dispute_period_has_a_null_dispute_end(self): + def test_a_registration_without_a_dispute_period_has_a_dispute_end_of_0(self): snrc.eth_call = self._chain(self.now + 3600) _, body = registration("acme.testing") - self.assertIsNone(body["disputeUntil"]) + self.assertEqual(body["disputeUntil"], 0) - def test_v1_reports_the_dispute_end_and_null_without_one(self): - for until, reported in ((self.now + 600, self.now + 600), (0, None)): + def test_a_dispute_end_the_node_could_not_read_is_absent(self): + snrc.eth_call = self._chain(self.now + 3600, dispute_until=None) + _, body = registration("acme.testing") + self.assertEqual(body["type"], "registered") + self.assertNotIn("disputeUntil", body) + + def test_v1_reports_the_dispute_end_0_or_null(self): + for until, reported in ((self.now + 600, self.now + 600), (0, 0), (None, None)): with self.subTest(until=until): snrc.eth_call = self._chain(self.now + 3600, dispute_until=until) status, body = snrc.resolve("acme.testing") @@ -1508,6 +1520,16 @@ def test_the_dispute_end_is_read_in_the_round_of_the_expiry(self): _, body = self.assert_same_answer(snrc.registration, "acme.testing", 2) self.assertEqual(body["registration"]["disputeUntil"], until) + def test_a_reverted_dispute_end_is_0_in_a_multicall(self): + _, body = self.assert_same_answer(snrc.registration, "acme.testing", 2) + self.assertEqual(body["registration"]["disputeUntil"], 0) + + def test_a_reverted_dispute_end_is_0_in_a_batch(self): + self.node.multicall = False + with self.assertLogs("snrc_resolve", "WARNING"): + _, body = self.assert_same_answer(snrc.registration, "acme.testing", 4) + self.assertEqual(body["registration"]["disputeUntil"], 0) + def test_a_hashed_query_is_named_from_the_same_round_trip(self): hashed = "[" + snrc.keccak(b"acme").hex() + "].testing" status, body = self.assert_same_answer(snrc.registration, hashed, 2) From a3abdc1ec85cf09c9e417695e8913e40580cecdd Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:08:37 +0000 Subject: [PATCH 30/44] names: test that a dispute end of 0 is passed to clients --- tests/SMPNamesTests.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/SMPNamesTests.hs b/tests/SMPNamesTests.hs index c0c989845..016861f24 100644 --- a/tests/SMPNamesTests.hs +++ b/tests/SMPNamesTests.hs @@ -54,7 +54,11 @@ testNameRecord = -- from the Haskell value: the literal JSON is the contract with the resolver. registeredBody :: NameRecord -> LB.ByteString registeredBody nameRec = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":null,\"reservedReason_\":null,\"nameRecord\":" <> J.encode nameRec <> "}" + responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"reservedReason_\":null,\"nameRecord\":" <> J.encode nameRec <> "}" + +finalBody :: LB.ByteString +finalBody = + responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":0,\"reservedReason_\":null,\"nameRecord\":" <> J.encode testNameRecord <> "}" disputedBody :: LB.ByteString disputedBody = @@ -81,6 +85,10 @@ registeredAlice :: NameRegistration registeredAlice = NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Nothing, nameRecord = testNameRecord} +finalAlice :: NameRegistration +finalAlice = + NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Just (RoundedSystemTime 0), reservedReason_ = Nothing, nameRecord = testNameRecord} + disputedAlice :: NameRegistration disputedAlice = NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Just (RoundedSystemTime 1813100000), reservedReason_ = Nothing, nameRecord = testNameRecord} @@ -172,6 +180,8 @@ availabilitySpec = do NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord} it "a registration in its dispute period is answered with its end" $ answers disputedBody (resolved disputedAlice) + it "a registration that cannot be ended is answered with a dispute end of 0" $ + answers finalBody (resolved finalAlice) it "an unregistered name answers with the price" $ answers availableBody (resolved NRAvailable {pricing = testPricing, nameTerms = Nothing}) it "reserved carries the reason and no price" $ @@ -184,6 +194,7 @@ availabilitySpec = do mapM_ (\a -> J.eitherDecodeStrict (LB.toStrict (J.encode a)) `shouldBe` Right a) [ registeredAlice, + finalAlice, disputedAlice, NRRegistered {expires = Nothing, graceUntil = Nothing, disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord}, NRAvailable {pricing = testPricing, nameTerms = Nothing}, From ec3f03e410bcfc4fde2b8f73585e13ddd21d6734 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:09:41 +0000 Subject: [PATCH 31/44] resolver: report 0 for a registration that cannot be ended --- scripts/resolver/README.md | 14 ++++++++------ scripts/resolver/service/snrc-resolve.py | 20 +++++++++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 330315769..a69e413c1 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -197,7 +197,7 @@ flat, and `status`, `expires`, `graceEnds`, `disputeUntil`, `reasonCode` and "status": "registered", // registered | grace | expired | unregistered | unknown "expires": 1780000000, // Unix seconds; when the registration ends, unless it is ended in its dispute period "graceEnds": 1787776000, // expires + GRACE_PERIOD; last moment the owner can renew - "disputeUntil": null, // Unix seconds; until then the registration can be ended and cannot be renewed + "disputeUntil": 0, // Unix seconds; until then the registration can be ended and cannot be renewed; 0 when it cannot be ended, null when unknown "reasonCode": null, // set when the name is held back as well "reason": null // set when the name is held back as well } @@ -215,8 +215,8 @@ A response contains `status`, `expires`, `graceEnds` and `disputeUntil` whenever the resolver read them, a successful resolve included, so a client that has just resolved a name already knows when it expires. The timestamps are Unix seconds. All are `null` when no registrar is configured, `expires` and -`graceEnds` also for a zero expiry, and `disputeUntil` also when no dispute -period is in effect or it could not be read. +`graceEnds` also for a zero expiry, and `disputeUntil` also when the node failed +its read; `disputeUntil` is 0 when the registration cannot be ended. | `status` | Meaning | |---|---| @@ -242,8 +242,10 @@ Within it, a renewal is refused, and a registrar controller can end the registration, such as the controller on the request of its owner or guardian (`beneficiary`); the registrar then sets a zero expiry. The resolver reports that end as `disputeUntil` while it is later than `now`, -and null otherwise. The call to a registrar from before dispute periods, such as -`.testing`'s, reverts, and is read as none. +and 0 otherwise. The call to a registrar from before dispute periods, such as +`.testing`'s, reverts, and is read as 0: a revert is a JSON-RPC error with code +3, or a failed call in a multicall. Any other error and an empty answer leave +`disputeUntil` unknown, and null. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 @@ -259,7 +261,7 @@ which is free to change. {"name": "nope.testing", "error": "unregistered", "message": "this name is not registered", "status": "unregistered", "lastBlockTs": 1780000000, "expires": null, - "graceEnds": null, "disputeUntil": null, "reasonCode": null, "reason": null} + "graceEnds": null, "disputeUntil": 0, "reasonCode": null, "reason": null} ``` The codes are `tldNotConfigured`, `notFullyQualified`, `unregistered`, diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index f7f1c072d..028372520 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -326,6 +326,14 @@ def request_reads(): del _request.reads +class CallReverted(RuntimeError): + pass + + +def rpc_error(error) -> RuntimeError: + return CallReverted(error) if isinstance(error, dict) and error.get("code") == 3 else RuntimeError(error) + + def rpc(method, params): reads = getattr(_request, "reads", None) if reads is not None: @@ -336,7 +344,7 @@ def rpc(method, params): return read res = _send_rpc({"jsonrpc": "2.0", "method": method, "params": params, "id": 1}) if "error" in res: - raise RuntimeError(res["error"]) + raise rpc_error(res["error"]) return res["result"] @@ -359,7 +367,7 @@ def _is_latest_call(method, params) -> bool: def _remember(reads, requests, answers): for (m, p), r in zip(requests, answers, strict=True): if r is not None and ("result" in r or "error" in r): - reads[_read_key(m, p)] = RuntimeError(r["error"]) if "error" in r else r["result"] + reads[_read_key(m, p)] = rpc_error(r["error"]) if "error" in r else r["result"] def prefetch(requests): @@ -397,7 +405,7 @@ def prefetch(requests): _remember(reads, calls, _send_batch(calls)) return for (m, p), (success, data) in zip(calls, results, strict=True): - reads[_read_key(m, p)] = "0x" + data.hex() if success else RuntimeError("execution reverted") + reads[_read_key(m, p)] = "0x" + data.hex() if success else CallReverted("execution reverted") AGGREGATE3 = "0x82ad56cb" # aggregate3((address,bool,bytes)[]) @@ -511,9 +519,11 @@ def grace_period(registrar: str) -> int: def dispute_end(registrar: str, token: int, now: int): try: until = decode_uint(eth_call(*dispute_until_call(registrar, token))) + except CallReverted: + return 0 except RuntimeError: return None - return until if until > now else None + return until if until > now else 0 def expiry_status(expires: int, grace: int, now: int) -> str: @@ -1211,7 +1221,7 @@ def registration(name: str): "type": "registered", "expires": reg["expires"], "graceUntil": reg["graceEnds"], - "disputeUntil": reg["disputeUntil"], + **({"disputeUntil": reg["disputeUntil"]} if reg["disputeUntil"] is not None else {}), "reservedReason_": reg["reasonCode"], "nameRecord": rec, }) From edc519dcb307d303d2598d63cdbe892cae22f3b6 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:10:35 +0000 Subject: [PATCH 32/44] names: state a dispute end of 0, and an unknown one by its absence --- protocol/simplex-messaging.md | 15 ++++++++------- src/Simplex/Messaging/Names/Record.hs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index 8f0f4ce1e..51857a4f0 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1556,18 +1556,19 @@ MUST NOT treat an answer as current without checking it. | `available` | held by nobody and registrable now, at `pricing` | | `reserved` | held back by the registry and not registered. It carries no price, and a router MUST NOT quote one | -A registration answered with `disputeUntil` is in its dispute period: until -then, its renewal is refused, and a controller of the registry's registrar can -end it, such as the registry's controller contract on the request of its owner -or guardian; a router then answers for the name as for a name never registered. -On `.simplex`, a registration made through the registry's sponsor contract has a -dispute period of 14 to 120 days from its registration. +A registration answered with a `disputeUntil` after `lastBlockTs` is in its +dispute period: until then, its renewal is refused, and a controller of the +registry's registrar can end it, such as the registry's controller contract on +the request of its owner or guardian; a router then answers for the name as for +a name never registered. On `.simplex`, a registration made through the +registry's sponsor contract has a dispute period of 14 to 120 days from its +registration. | Field | On | JSON type | Constraints | |---|---|---|---| | `expires` | `registered` | number | absent only from a v20/v21 router, which sent the record alone | | `graceUntil` | `registered` | number | after `expires`; until here only the owner may renew. Absent on the same condition as `expires` | -| `disputeUntil` | `registered` | number | the end of the dispute period, present only when after `lastBlockTs`. It is also absent when it could not be read, and from a router or resolver that predates it, so a client MUST NOT conclude from its absence that the registration cannot be ended | +| `disputeUntil` | `registered` | number | after `lastBlockTs`: the end of the dispute period; 0: the registration cannot be ended. A client compares a time with `lastBlockTs`, and reads one not after it as 0. Absent when unknown: when it could not be read, and from a router or resolver that predates it; a client MUST NOT read its absence as 0 | | `reservedReason_` | `registered` | string | a reason word, present only when the name is held back as well | | `nameRecord` | `registered` | object | the record, schema below | | `pricing` | `available` | object | `registrationPrices`, `basePrice` and `minLabelLength`, below | diff --git a/src/Simplex/Messaging/Names/Record.hs b/src/Simplex/Messaging/Names/Record.hs index 164bbca3d..ca075d0fe 100644 --- a/src/Simplex/Messaging/Names/Record.hs +++ b/src/Simplex/Messaging/Names/Record.hs @@ -87,7 +87,7 @@ data NameRegistration expires :: Maybe SystemSeconds, -- | unix seconds, > expires: until here only the owner may renew graceUntil :: Maybe SystemSeconds, - -- | unix seconds, > lastBlockTs: until here the registration can be ended and cannot be renewed; absent also from a router or resolver that predates it + -- | unix seconds, > lastBlockTs: until here the registration can be ended and cannot be renewed; 0: it cannot be ended; absent: unknown, as from a router or resolver that predates it disputeUntil :: Maybe SystemSeconds, -- | held back as well, which is why it will not free up at expiry reservedReason_ :: Maybe NameReservedReason, From 814b4f0d611f9f062acd73ab469836c25042e29d Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:55:18 +0000 Subject: [PATCH 33/44] docs: name disputeUntil as the field left out when it could not be read --- protocol/simplex-messaging.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index 51857a4f0..a123753c5 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1502,8 +1502,8 @@ trusted for it: a client MUST check that the record names the name it asked about, and reject the answer otherwise. A registry that does not record the label cannot answer a hashed query at all, and the router answers `ERR NAME RESOLVER` rather than a record it knows the client will reject. A name nobody -holds is answered `available` or `reserved`, neither of which contains a name, -so a hashed query of it does not depend on a recorded label. +holds is answered `available` or `reserved`; in both, the name is omitted, so a +hashed query of it is answered from the hash alone. **Server-side validation.** The names router parses `domain` as a fully-qualified name (TLD required — bare labels are rejected) and forwards it @@ -1519,7 +1519,7 @@ several configured servers can act on distinctly: | `RNAME` | the router read the registry | use it | | `ERR NAME NOT_FOUND` | below v22 only: every name that does not resolve. From v22 a router never sends it | stop, and do not read it as registrable | | `ERR NAME NO_RESOLVER` | this router has no resolver (names role not enabled) | skip this server, try the next | -| `ERR NAME RESOLVER ` | the router cannot state an answer completely: no registrar or price oracle for the TLD, an unreachable chain, a transport failure, a timeout, a registration it could not date or resolve | surface ``; retry only if it reads as transient | +| `ERR NAME RESOLVER ` | the router cannot state an answer completely: no registrar or price oracle for the TLD, an unreachable chain, a transport failure, a timeout, a registration it could not date or resolve; a `disputeUntil` that could not be read is left out instead | surface ``; retry only if it reads as transient | A client SHOULD NOT broadcast a `name` to further servers after a name-capable router has answered (`NOT_FOUND` or `RESOLVER`), since that router has already @@ -1562,7 +1562,8 @@ registry's registrar can end it, such as the registry's controller contract on the request of its owner or guardian; a router then answers for the name as for a name never registered. On `.simplex`, a registration made through the registry's sponsor contract has a dispute period of 14 to 120 days from its -registration. +registration. As with `expires`, a client does not verify `disputeUntil`: a +router can omit or misstate it. | Field | On | JSON type | Constraints | |---|---|---|---| @@ -1607,7 +1608,8 @@ From v22 a client MUST NOT read `ERR NAME NOT_FOUND` as "registrable": only A router that cannot state an answer completely MUST send `ERR NAME RESOLVER ` rather than answer partially or guess. That covers a TLD with no registrar or price oracle, an unreachable chain, a timeout, a registration it -could not date or resolve, and any status word it does not recognise. +could not date or resolve, and any status word it does not recognise. The one +exception is `disputeUntil`, which is left out when it could not be read. `nameRecord` MUST be a UTF-8 JSON object with the following schema: From 3ea6beefe4449f20aaad60b285567b512b03a253 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:55:59 +0000 Subject: [PATCH 34/44] docs: complete the resolver's examples, and when a lookup is answered 502 --- scripts/resolver/README.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index a69e413c1..9edf4652f 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -153,11 +153,12 @@ carries are specified once, in the **Name response** section of [`protocol/simplex-messaging.md`](../../protocol/simplex-messaging.md). It is the wire format, so it is documented with the wire. -Two things follow from that and are worth stating here. Expiry and grace belong -to the registration, not to the record: `expires` and `graceUntil` sit beside -`nameRecord`, not inside it. And a name nobody holds is not an error: it -answers 200 with `type: available` and its price, so no status code from this -route means "not registered". +Two things follow from that and are worth stating here. Expiry, grace and the +dispute end belong to the registration, not to the record: `expires`, +`graceUntil` and `disputeUntil` are fields beside `nameRecord`, not inside it. +And a name nobody holds is not an error: it is answered 200 with +`type: available` and its price, so no status code from this route means +"not registered". | Status | Meaning | |---|---| @@ -195,6 +196,7 @@ flat, and `status`, `expires`, `graceEnds`, `disputeUntil`, `reasonCode` and "eth": null, "btc": "bc1q…", "xmr": "4ANz…", "dot": "139G…", "owner": "0xd83b…", "resolver": "0x80fa…", "status": "registered", // registered | grace | expired | unregistered | unknown + "lastBlockTs": 1779990000, // Unix seconds; the block the status was read at "expires": 1780000000, // Unix seconds; when the registration ends, unless it is ended in its dispute period "graceEnds": 1787776000, // expires + GRACE_PERIOD; last moment the owner can renew "disputeUntil": 0, // Unix seconds; until then the registration can be ended and cannot be renewed; 0 when it cannot be ended, null when unknown @@ -215,8 +217,9 @@ A response contains `status`, `expires`, `graceEnds` and `disputeUntil` whenever the resolver read them, a successful resolve included, so a client that has just resolved a name already knows when it expires. The timestamps are Unix seconds. All are `null` when no registrar is configured, `expires` and -`graceEnds` also for a zero expiry, and `disputeUntil` also when the node failed -its read; `disputeUntil` is 0 when the registration cannot be ended. +`graceEnds` also for a zero expiry, and `disputeUntil` also when the node +answered its read with an error other than a revert; `disputeUntil` is 0 when +the registration cannot be ended. | `status` | Meaning | |---|---| @@ -244,8 +247,9 @@ registration, such as the controller on the request of its owner or guardian The resolver reports that end as `disputeUntil` while it is later than `now`, and 0 otherwise. The call to a registrar from before dispute periods, such as `.testing`'s, reverts, and is read as 0: a revert is a JSON-RPC error with code -3, or a failed call in a multicall. Any other error and an empty answer leave -`disputeUntil` unknown, and null. +3, or a failed call in a multicall. With any other JSON-RPC error, or an empty +answer, `disputeUntil` is unknown and null; when a request to the node fails, +the lookup is answered 502. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 @@ -262,6 +266,7 @@ which is free to change. "message": "this name is not registered", "status": "unregistered", "lastBlockTs": 1780000000, "expires": null, "graceEnds": null, "disputeUntil": 0, "reasonCode": null, "reason": null} +// with a price oracle configured, also registrationPrices, basePrice and minLabelLength ``` The codes are `tldNotConfigured`, `notFullyQualified`, `unregistered`, @@ -305,8 +310,8 @@ Only the second-level label is a registry key, and `status` decodes a bracket there at any depth. The record does not: a bracket is decoded only in a two-label name, so `sub.[].testing` is not a supported query. Subname labels stay text; a bracket label left of the 2LD is an ordinary label. Routers -from v22 send every 2LD this way, so the label of a name never registered -normally never reaches this service. +from v22 send every 2LD this way, so a name never registered is normally looked +up here by its hash alone. On v2, read `type`: only `available` means the name is free. On v1, read `status`: a name is free on `unregistered` (404) and on `expired` (410), every From 5643f2e5fad10f604beb4b8a0bb2194dee16f5af Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:56:51 +0000 Subject: [PATCH 35/44] names, resolver: plan a null dispute end on error, and geth's revert code --- plans/2026-11-20-names-dispute-period.md | 43 +++++++++++++----------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/plans/2026-11-20-names-dispute-period.md b/plans/2026-11-20-names-dispute-period.md index 31718c9f1..f45c19b87 100644 --- a/plans/2026-11-20-names-dispute-period.md +++ b/plans/2026-11-20-names-dispute-period.md @@ -5,7 +5,7 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period ## Problems 1. After #51, a controller of the `.simplex` registrar, such as the controller contract on the request of its owner or guardian, can end a registration in its dispute period, and the registrar sets the name's expiry to 0. On its v1 route, the resolver answers every name with expiry 0 with the message "this name has never been registered". In the resolver's README, `unregistered` is described as never registered and `registered` as held until `expires`, and in the protocol a registered name is described as held until `expires`. -2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after the name was moved to a recipient by a claim, and its renewal is refused. By decision D8 of the contract plan, clients show the dispute end before a claim. +2. Clients do not learn until when a registration can be ended. Until then, the registration can be ended also after the name was moved to a recipient by a claim, and its renewal is refused. By decision D8 of the [contract plan](https://github.com/brenzi/simplex-namespace-contract/blob/main/docs/plans/dispute-period.md#L20), clients show the dispute end before a claim. ## Decisions @@ -15,8 +15,8 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period | 2 | message of a v1 404 `unregistered`: "this name is not registered" | | 3 | price quotes of a name with expiry 0 unchanged | | 4 | the registrar's `disputeUntil(uint256)` read for the 2LD's token, in the round of `nameExpires` | -| 5 | `disputeUntil`: the registrar's value while later than `lastBlockTs`, otherwise 0; unknown when the node fails the read: absent in v2 and in RNAME, null in v1 | -| 6 | a revert of the `disputeUntil` call, by JSON-RPC error code 3 or a failed call in a multicall, read as 0; another error and an empty answer read as unknown | +| 5 | `disputeUntil`: the registrar's value while later than `lastBlockTs`, otherwise 0; unknown when the node answers the read with another error: null in v2 and v1, absent in RNAME | +| 6 | a revert of the `disputeUntil` call read as 0: a JSON-RPC error with code 3, or with code -32000 and the message "execution reverted", or a failed call in a multicall; another JSON-RPC error and an empty answer read as unknown; a failed request to the node answered 502 | | 7 | a subname reported with its 2LD's `disputeUntil` | | 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields; its Haddock states a date, 0 and absent | | 9 | SMP version unchanged; a client does not read the absence of `disputeUntil` as 0 | @@ -29,10 +29,11 @@ name_status(name): expires = registrar.nameExpires(token) now = timestamp of the latest block disputeUntil = case registrar.disputeUntil(token) of - a value > now -> the value - another value -> 0 - a revert -> 0 - another error, or empty -> unknown + a value > now -> the value + another value -> 0 + a revert -> 0 + another JSON-RPC error, or empty -> unknown + a failed request to the node -> the lookup answered 502 ``` ```mermaid @@ -52,7 +53,7 @@ For a 2LD: | final | `registered` | 0 | 0 | `registered` or `grace` | 0 | | unregistered | `available` or `reserved` | not a field | not a field | `unregistered`, "this name is not registered" | 0 | -A `disputeUntil` read that the node fails: absent in v2 and in RNAME, null in v1. +A `disputeUntil` read answered with another JSON-RPC error: null in v2 and v1, absent in RNAME. ```mermaid sequenceDiagram @@ -66,8 +67,8 @@ sequenceDiagram R->>S: GET /v2/resolve/query S->>N: one multicall: nameExpires, disputeUntil (added), GRACE_PERIOD and the other reads of the round N-->>S: disputeUntil reverted by a registrar before #51 - S-->>R: registered, with disputeUntil: its end, or 0; absent when the node failed the read (added) - R->>R: decoded into NRRegistered with disputeUntil, absent decoded as Nothing (added) + S-->>R: registered, with disputeUntil: its end, or 0; null after another JSON-RPC error (added) + R->>R: decoded into NRRegistered with disputeUntil, null decoded as Nothing (added) R-->>P: RRES with RNAME, encoded at the forwarded version, at most 23 P-->>C: PRES ``` @@ -75,7 +76,7 @@ sequenceDiagram ## Threat model - A router or its resolver can omit `disputeUntil` or state a false one, as it can `expires`; a client verifies it only by reading the registrar. -- `disputeUntil` is public on chain (contract plan, D9), and with it the dispute days of the payment: 0, 14 or 120. In the answer, it is disclosed to the router and the client as on chain. +- `disputeUntil` is public on chain ([contract plan, D9](https://github.com/brenzi/simplex-namespace-contract/blob/main/docs/plans/dispute-period.md#L21)), and with it the dispute days of the payment: 0, 14 or 120. In the answer, it is disclosed to the router and the client as on chain. - A JSON-RPC error of the `disputeUntil` call alone, other than a revert, leaves the dispute end unknown, and the name is answered without it. - A revert answered by the node is read as 0, so the resolver relies on its node for 0 as for every other read. - A label the registrar recorded stays recorded after the registration expired or was ended, so whoever runs the resolver matches a hashed query of such a name to its label. @@ -87,10 +88,10 @@ sequenceDiagram - the message of decision 2 - the docstring of `read_oracle_prices`: a quote is safe for a name with expiry 0 - `dispute_until_call`, read in `lookup_reads` -- `CallReverted`: a JSON-RPC error with code 3, and a call failed in a multicall +- `CallReverted`: a JSON-RPC error with code 3, or with code -32000 and the message "execution reverted", and a call failed in a multicall - `dispute_end`: the registrar's `disputeUntil` when later than the block, 0 otherwise and on a revert, None on another error or an empty answer - `name_status`: `disputeUntil`, also in v1 answers -- `registration`: `disputeUntil` in `registered`, absent when unknown +- `registration`: `disputeUntil` in `registered`, null when unknown - the comment on the reads keyed on the labelhash: `disputeUntil` - the docstring of `expiry_status`: any name with a zero expiry @@ -106,7 +107,9 @@ sequenceDiagram - a subname's dispute end in v2 - `disputeUntil` in the lists of status fields and of the registrar's reads - the source of each status field, and when it is null or 0, also in the error example -- a hashed query: the label of a name never registered stays unknown to the service +- a name never registered looked up by its hash alone +- `lastBlockTs` in the v1 example, the price keys of the error example, and `disputeUntil` beside `nameRecord` in v2 +- a lookup answered 502 when a request to the node fails `protocol/simplex-messaging.md`: @@ -114,6 +117,8 @@ sequenceDiagram - `registered`: unless ended before `disputeUntil`, and renewable not before it - the dispute period, defined by a `disputeUntil` after `lastBlockTs` - `disputeUntil` in the fields of `registered`: a date, 0, or absent when unknown +- `disputeUntil`, the one field left out when it could not be read, in the conditions of `ERR NAME RESOLVER` +- `disputeUntil` unverified by a client, as `expires` - an answer below v22: no dispute end `src/Simplex/Messaging/Names/Record.hs`: `NRRegistered.disputeUntil`, with the Haddock of decision 8. @@ -122,21 +127,21 @@ sequenceDiagram ## Tests -The tests of changed behavior are committed before the change, and fail on that commit in CI. +Each test of changed behavior is committed before its change, and fails in CI on the commit before that change. `scripts/resolver/service/test_snrc_resolve.py`: - `ErrorCodeTests`: a name with expiry 0 answered 404 with "this name is not registered" - three test names that equate expiry 0 with never registered -- `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 reported as 0; a revert, the node's error code 3, read as 0; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch -- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, with 0, and without it when the node fails the read; 0 in the pinned keys of `registered`; v1 with it, with 0 and with null +- `NameStatusTests`: a `disputeUntil` later than the block reported; one at the block, one before it and 0 reported as 0; a revert, the node's error with code 3 or with code -32000 and "execution reverted", read as 0; a subname read with its 2LD's token; `disputeUntil` in the keys of every branch +- `RegistrationV2Tests`: v2 `registered` with `disputeUntil`, with 0, and with null when the node answers the read with another error; 0 in the pinned keys of `registered`; v1 with it, with 0 and with null - `BatchedReadsTests`: `disputeUntil` read in the round of `nameExpires`, in two round trips; a revert read as 0 in a multicall and in a batch - the fakes of the registrar answer `disputeUntil` -Regression tests, passing before the change: +Regression tests, passing in CI on the commit before their change as well: - `RegistrationV2Tests`: a subname under a 2LD with expiry 0, whose node has no owner while the subnode keeps a former holder: v2 `available`, v1 404 -- `NameStatusTests`: another node error and an empty answer read as unknown +- `NameStatusTests`: another JSON-RPC error and an empty answer read as unknown - `tests/SMPNamesTests.hs`: a dispute end of 0, as the resolver serves it, decoded into `NRRegistered`, and its JSON round trip `tests/SMPNamesTests.hs`: the router's answer to a registration with `disputeUntil`, as the resolver serves it, decoded into `NRRegistered`; the JSON round trip of that value. From d95489a1155b9a9cf41c426bb6c09c834b215065 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:57:06 +0000 Subject: [PATCH 36/44] resolver: test geth's revert code, and a null dispute end on an error --- scripts/resolver/service/test_snrc_resolve.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 283588302..8f9a09b3c 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -357,9 +357,11 @@ def test_a_dispute_end_not_after_the_block_is_reported_as_0(self): def test_a_reverted_dispute_end_is_reported_as_0(self): snrc.eth_call = self._saved[2] - with mock.patch.object(snrc, "_send_rpc", self._node({"error": {"code": 3, "message": "execution reverted"}})): - reg = snrc.name_status("alice.testing") - self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", 0)) + for code in (3, -32000): + answer = {"error": {"code": code, "message": "execution reverted"}} + with self.subTest(code=code), mock.patch.object(snrc, "_send_rpc", self._node(answer)): + reg = snrc.name_status("alice.testing") + self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", 0)) def test_a_dispute_end_the_node_could_not_read_is_unknown(self): snrc.eth_call = self._saved[2] @@ -1020,11 +1022,11 @@ def test_a_registration_without_a_dispute_period_has_a_dispute_end_of_0(self): _, body = registration("acme.testing") self.assertEqual(body["disputeUntil"], 0) - def test_a_dispute_end_the_node_could_not_read_is_absent(self): + def test_a_dispute_end_the_node_could_not_read_is_null(self): snrc.eth_call = self._chain(self.now + 3600, dispute_until=None) _, body = registration("acme.testing") self.assertEqual(body["type"], "registered") - self.assertNotIn("disputeUntil", body) + self.assertIsNone(body["disputeUntil"]) def test_v1_reports_the_dispute_end_0_or_null(self): for until, reported in ((self.now + 600, self.now + 600), (0, 0), (None, None)): From 1bb91e28a17ec4fde914238463b907492a247a69 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:57:22 +0000 Subject: [PATCH 37/44] resolver: read geth's revert code, and answer an unknown end as null --- scripts/resolver/README.md | 7 ++++--- scripts/resolver/service/snrc-resolve.py | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 9edf4652f..34bb63b81 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -247,9 +247,10 @@ registration, such as the controller on the request of its owner or guardian The resolver reports that end as `disputeUntil` while it is later than `now`, and 0 otherwise. The call to a registrar from before dispute periods, such as `.testing`'s, reverts, and is read as 0: a revert is a JSON-RPC error with code -3, or a failed call in a multicall. With any other JSON-RPC error, or an empty -answer, `disputeUntil` is unknown and null; when a request to the node fails, -the lookup is answered 502. +3, or with code -32000 and the message "execution reverted", or a failed call in +a multicall. With any other JSON-RPC error, or an empty answer, `disputeUntil` +is unknown and null, also on v2; when a request to the node fails, the lookup is +answered 502. A subname reports the status of the 2LD above it, which is only as good as the name it sits under. A subname that is not held, as v2 defines it, answers 404 diff --git a/scripts/resolver/service/snrc-resolve.py b/scripts/resolver/service/snrc-resolve.py index 028372520..b60fb9aec 100755 --- a/scripts/resolver/service/snrc-resolve.py +++ b/scripts/resolver/service/snrc-resolve.py @@ -331,7 +331,9 @@ class CallReverted(RuntimeError): def rpc_error(error) -> RuntimeError: - return CallReverted(error) if isinstance(error, dict) and error.get("code") == 3 else RuntimeError(error) + code, message = (error.get("code"), error.get("message")) if isinstance(error, dict) else (None, None) + reverted = code == 3 or (code, message) == (-32000, "execution reverted") + return CallReverted(error) if reverted else RuntimeError(error) def rpc(method, params): @@ -1221,7 +1223,7 @@ def registration(name: str): "type": "registered", "expires": reg["expires"], "graceUntil": reg["graceEnds"], - **({"disputeUntil": reg["disputeUntil"]} if reg["disputeUntil"] is not None else {}), + "disputeUntil": reg["disputeUntil"], "reservedReason_": reg["reasonCode"], "nameRecord": rec, }) From bcca00ae3eb37618d737e5aae405c7ef41227f91 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:57:52 +0000 Subject: [PATCH 38/44] resolver: build the dispute end call in tests with its helper --- scripts/resolver/service/test_snrc_resolve.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 8f9a09b3c..e0ac2abbe 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -371,11 +371,11 @@ def test_a_dispute_end_the_node_could_not_read_is_unknown(self): self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) def test_a_subname_reports_the_dispute_end_of_its_2ld(self): - alice = snrc.selector("disputeUntil(uint256)") + snrc.encode_uint(snrc.label_token("alice")) + alice = snrc.dispute_until_call(self.REGISTRAR, snrc.label_token("alice")) def eth_call(to, data): if data.startswith(snrc.selector("disputeUntil(uint256)")): - self.assertEqual(data, alice) + self.assertEqual((to, data), alice) return "0x" + snrc.encode_uint(self.now + 1) return "0x" + snrc.encode_uint(self.now + 3600) @@ -1517,8 +1517,7 @@ def test_a_registered_name_takes_two_round_trips(self): def test_the_dispute_end_is_read_in_the_round_of_the_expiry(self): until = self.node.chain.now + 600 - call = (FakeChain.REGISTRAR, snrc.selector("disputeUntil(uint256)") + snrc.encode_uint(snrc.label_token("acme"))) - self.node.chain.answers[call] = "0x" + snrc.encode_uint(until) + self.node.chain.answers[snrc.dispute_until_call(FakeChain.REGISTRAR, snrc.label_token("acme"))] = "0x" + snrc.encode_uint(until) _, body = self.assert_same_answer(snrc.registration, "acme.testing", 2) self.assertEqual(body["registration"]["disputeUntil"], until) From 2547d8964fe14a8321d17b1e9d2c4b716df32d3b Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 12:58:42 +0000 Subject: [PATCH 39/44] names: build the registered test answers from one body and one value --- tests/SMPNamesTests.hs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/SMPNamesTests.hs b/tests/SMPNamesTests.hs index 016861f24..02c25bf21 100644 --- a/tests/SMPNamesTests.hs +++ b/tests/SMPNamesTests.hs @@ -29,7 +29,7 @@ import Simplex.Messaging.Server.Names ) import Simplex.Messaging.Server.Names.HttpResolver (ResolverError (..)) import Simplex.Messaging.SimplexName (SimplexDomain (..), SimplexTLD (..), labelHash) -import Simplex.Messaging.SystemTime (RoundedSystemTime (..)) +import Simplex.Messaging.SystemTime (RoundedSystemTime (..), SystemSeconds) import Simplex.Messaging.Transport (nameAvailSMPVersion, serverInfoSMPVersion) import Test.Hspec @@ -53,16 +53,17 @@ testNameRecord = -- | What the resolver serves on /v2/resolve. Spelled out rather than encoded -- from the Haskell value: the literal JSON is the contract with the resolver. registeredBody :: NameRecord -> LB.ByteString -registeredBody nameRec = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"reservedReason_\":null,\"nameRecord\":" <> J.encode nameRec <> "}" +registeredBody = registeredBodyWith "\"reservedReason_\":null," + +registeredBodyWith :: LB.ByteString -> NameRecord -> LB.ByteString +registeredBodyWith fields nameRec = + responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483," <> fields <> "\"nameRecord\":" <> J.encode nameRec <> "}" finalBody :: LB.ByteString -finalBody = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":0,\"reservedReason_\":null,\"nameRecord\":" <> J.encode testNameRecord <> "}" +finalBody = registeredBodyWith "\"disputeUntil\":0,\"reservedReason_\":null," testNameRecord disputedBody :: LB.ByteString -disputedBody = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"disputeUntil\":1813100000,\"reservedReason_\":null,\"nameRecord\":" <> J.encode testNameRecord <> "}" +disputedBody = registeredBodyWith "\"disputeUntil\":1813100000,\"reservedReason_\":null," testNameRecord availableBody :: LB.ByteString availableBody = responseBody "{\"type\":\"available\",\"pricing\":{\"registrationPrices\":{\"3\":12793,\"4\":3198},\"basePrice\":100,\"minLabelLength\":3}}" @@ -82,16 +83,17 @@ resolved registration = NameResponse {lastBlockTs = Just (RoundedSystemTime 1813 -- | What `registeredBody testNameRecord` resolves to. registeredAlice :: NameRegistration -registeredAlice = - NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Nothing, nameRecord = testNameRecord} +registeredAlice = aliceWith Nothing Nothing + +aliceWith :: Maybe SystemSeconds -> Maybe NameReservedReason -> NameRegistration +aliceWith dispute reason = + NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = dispute, reservedReason_ = reason, nameRecord = testNameRecord} finalAlice :: NameRegistration -finalAlice = - NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Just (RoundedSystemTime 0), reservedReason_ = Nothing, nameRecord = testNameRecord} +finalAlice = aliceWith (Just (RoundedSystemTime 0)) Nothing disputedAlice :: NameRegistration -disputedAlice = - NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Just (RoundedSystemTime 1813100000), reservedReason_ = Nothing, nameRecord = testNameRecord} +disputedAlice = aliceWith (Just (RoundedSystemTime 1813100000)) Nothing smpNamesTests :: Spec smpNamesTests = do @@ -176,8 +178,7 @@ availabilitySpec = do it "a registered name answers with its record and dates" $ answers (registeredBody testNameRecord) (resolved registeredAlice) it "a registered name can be held back too" $ - answers heldBackBody . resolved $ - NRRegistered {expires = Just (RoundedSystemTime 1813853483), graceUntil = Just (RoundedSystemTime 1821629483), disputeUntil = Nothing, reservedReason_ = Just NRRInternal, nameRecord = testNameRecord} + answers heldBackBody . resolved $ aliceWith Nothing (Just NRRInternal) it "a registration in its dispute period is answered with its end" $ answers disputedBody (resolved disputedAlice) it "a registration that cannot be ended is answered with a dispute end of 0" $ @@ -208,8 +209,7 @@ availabilitySpec = do J.encode (NRRUnknown "seasonal") `shouldBe` "\"seasonal\"" J.encode NRRTrademark `shouldBe` "\"trademark\"" where - heldBackBody = - responseBody $ "{\"type\":\"registered\",\"expires\":1813853483,\"graceUntil\":1821629483,\"reservedReason_\":\"internal\",\"nameRecord\":" <> J.encode testNameRecord <> "}" + heldBackBody = registeredBodyWith "\"reservedReason_\":\"internal\"," testNameRecord answers body a = withResolverServer (resolveResp status200 body) $ \port _ -> do env <- newNamesEnv (testNamesConfig port) From 6081b9b7e64ff06fd26e14b901388446adafa450 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:36:30 +0000 Subject: [PATCH 40/44] docs: name the empty answer, and the v2 example's dispute end --- protocol/simplex-messaging.md | 7 +++---- scripts/resolver/README.md | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/protocol/simplex-messaging.md b/protocol/simplex-messaging.md index a123753c5..82d9ff1f9 100644 --- a/protocol/simplex-messaging.md +++ b/protocol/simplex-messaging.md @@ -1558,10 +1558,9 @@ MUST NOT treat an answer as current without checking it. A registration answered with a `disputeUntil` after `lastBlockTs` is in its dispute period: until then, its renewal is refused, and a controller of the -registry's registrar can end it, such as the registry's controller contract on -the request of its owner or guardian; a router then answers for the name as for -a name never registered. On `.simplex`, a registration made through the -registry's sponsor contract has a dispute period of 14 to 120 days from its +registry's registrar can end it; a router then answers for the name as for a +name never registered. On `.simplex`, a registration made with the controller's +`registerSponsored` has a dispute period of 14 to 120 days from its registration. As with `expires`, a client does not verify `disputeUntil`: a router can omit or misstate it. diff --git a/scripts/resolver/README.md b/scripts/resolver/README.md index 34bb63b81..6d7f23205 100644 --- a/scripts/resolver/README.md +++ b/scripts/resolver/README.md @@ -80,7 +80,7 @@ curl -s http://127.0.0.1:8000/resolve/foobar.testing | jq **4. the route your router will call** (check 3 passes on an older resolver too): ```sh curl -s http://127.0.0.1:8000/v2/resolve/foobar.testing | jq -# → {"type":"registered","expires":1780000000,"graceUntil":…,"nameRecord":{…}} +# → {"lastBlockTs":1779990000,"registration":{"type":"registered","expires":1780000000,"graceUntil":…,"disputeUntil":0,"reservedReason_":null,"nameRecord":{…}}} ``` **Wire your smp-server:** in its `[NAMES]` section set @@ -218,8 +218,8 @@ whenever the resolver read them, a successful resolve included, so a client that has just resolved a name already knows when it expires. The timestamps are Unix seconds. All are `null` when no registrar is configured, `expires` and `graceEnds` also for a zero expiry, and `disputeUntil` also when the node -answered its read with an error other than a revert; `disputeUntil` is 0 when -the registration cannot be ended. +answered its read with an error other than a revert, or with an empty answer; +`disputeUntil` is 0 when the registration cannot be ended. | `status` | Meaning | |---|---| From 383268680717da0a5994b4b94882c76e92cfd11c Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:36:51 +0000 Subject: [PATCH 41/44] names, resolver: plan the lapsed state, and an empty answer as unknown --- plans/2026-11-20-names-dispute-period.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plans/2026-11-20-names-dispute-period.md b/plans/2026-11-20-names-dispute-period.md index f45c19b87..f36d1e0b1 100644 --- a/plans/2026-11-20-names-dispute-period.md +++ b/plans/2026-11-20-names-dispute-period.md @@ -15,7 +15,7 @@ To be merged together with simplex-network/ens-contracts#51, the dispute period | 2 | message of a v1 404 `unregistered`: "this name is not registered" | | 3 | price quotes of a name with expiry 0 unchanged | | 4 | the registrar's `disputeUntil(uint256)` read for the 2LD's token, in the round of `nameExpires` | -| 5 | `disputeUntil`: the registrar's value while later than `lastBlockTs`, otherwise 0; unknown when the node answers the read with another error: null in v2 and v1, absent in RNAME | +| 5 | `disputeUntil`: the registrar's value while later than `lastBlockTs`, otherwise 0; unknown when the node answers the read with another error, or with an empty answer: null in v2 and v1, absent in RNAME | | 6 | a revert of the `disputeUntil` call read as 0: a JSON-RPC error with code 3, or with code -32000 and the message "execution reverted", or a failed call in a multicall; another JSON-RPC error and an empty answer read as unknown; a failed request to the node answered 502 | | 7 | a subname reported with its 2LD's `disputeUntil` | | 8 | `NRRegistered.disputeUntil :: Maybe SystemSeconds`, after `graceUntil`, JSON derived as for the other fields; its Haddock states a date, 0 and absent | @@ -42,18 +42,21 @@ stateDiagram-v2 [*] --> final: registration without a dispute period disputable --> final: at disputeUntil disputable --> unregistered: ended by a controller of the registrar + final --> lapsed: expiry and grace passed unregistered --> [*]: available to any registration + lapsed --> [*]: available to any registration ``` -For a 2LD: +For a 2LD, with `disputeUntil` a field of `registered` alone (– in the other types): | State | v2 `type` | v2 `disputeUntil` | RNAME `disputeUntil` | v1 `status` | v1 `disputeUntil` | |---|---|---|---|---|---| | disputable | `registered` | its end | its end | `registered` | its end | | final | `registered` | 0 | 0 | `registered` or `grace` | 0 | -| unregistered | `available` or `reserved` | not a field | not a field | `unregistered`, "this name is not registered" | 0 | +| lapsed | `available` or `reserved` | – | – | `expired` (410) | 0 | +| unregistered | `available` or `reserved` | – | – | `unregistered` (404), "this name is not registered" | 0 | -A `disputeUntil` read answered with another JSON-RPC error: null in v2 and v1, absent in RNAME. +A `disputeUntil` read answered with another JSON-RPC error, or with an empty answer: null in v2 and v1, absent in RNAME. ```mermaid sequenceDiagram @@ -77,7 +80,7 @@ sequenceDiagram - A router or its resolver can omit `disputeUntil` or state a false one, as it can `expires`; a client verifies it only by reading the registrar. - `disputeUntil` is public on chain ([contract plan, D9](https://github.com/brenzi/simplex-namespace-contract/blob/main/docs/plans/dispute-period.md#L21)), and with it the dispute days of the payment: 0, 14 or 120. In the answer, it is disclosed to the router and the client as on chain. -- A JSON-RPC error of the `disputeUntil` call alone, other than a revert, leaves the dispute end unknown, and the name is answered without it. +- After a JSON-RPC error of the `disputeUntil` call alone, other than a revert, the dispute end is unknown: null from the resolver, left out of RNAME. - A revert answered by the node is read as 0, so the resolver relies on its node for 0 as for every other read. - A label the registrar recorded stays recorded after the registration expired or was ended, so whoever runs the resolver matches a hashed query of such a name to its label. @@ -142,7 +145,7 @@ Regression tests, passing in CI on the commit before their change as well: - `RegistrationV2Tests`: a subname under a 2LD with expiry 0, whose node has no owner while the subnode keeps a former holder: v2 `available`, v1 404 - `NameStatusTests`: another JSON-RPC error and an empty answer read as unknown -- `tests/SMPNamesTests.hs`: a dispute end of 0, as the resolver serves it, decoded into `NRRegistered`, and its JSON round trip +- `tests/SMPNamesTests.hs`: a dispute end of 0, as the resolver serves it, decoded into `NRRegistered`, and its JSON round trip; a null dispute end decoded as `Nothing`, and left out of RNAME `tests/SMPNamesTests.hs`: the router's answer to a registration with `disputeUntil`, as the resolver serves it, decoded into `NRRegistered`; the JSON round trip of that value. From 8194afb8845ed7fa691948b915902ca39e3ed483 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:37:05 +0000 Subject: [PATCH 42/44] resolver: name the dispute end tests by what is answered --- scripts/resolver/service/test_snrc_resolve.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index e0ac2abbe..8f6cbdbf3 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -370,7 +370,7 @@ def test_a_dispute_end_the_node_could_not_read_is_unknown(self): reg = snrc.name_status("alice.testing") self.assertEqual((reg["status"], reg["disputeUntil"]), ("registered", None)) - def test_a_subname_reports_the_dispute_end_of_its_2ld(self): + def test_a_subname_is_answered_with_the_dispute_end_of_its_2ld(self): alice = snrc.dispute_until_call(self.REGISTRAR, snrc.label_token("alice")) def eth_call(to, data): @@ -1011,7 +1011,7 @@ def test_a_registered_name_that_is_held_back_says_so(self): self.assertEqual(body["type"], "registered") self.assertEqual(body["reservedReason_"], "internal") - def test_a_registration_in_its_dispute_period_says_until_when(self): + def test_a_registration_in_its_dispute_period_is_answered_with_its_end(self): snrc.eth_call = self._chain(self.now + 3600, dispute_until=self.now + 600) _, body = registration("acme.testing") self.assertEqual(body["type"], "registered") @@ -1028,7 +1028,7 @@ def test_a_dispute_end_the_node_could_not_read_is_null(self): self.assertEqual(body["type"], "registered") self.assertIsNone(body["disputeUntil"]) - def test_v1_reports_the_dispute_end_0_or_null(self): + def test_v1_answers_contain_the_dispute_end(self): for until, reported in ((self.now + 600, self.now + 600), (0, 0), (None, None)): with self.subTest(until=until): snrc.eth_call = self._chain(self.now + 3600, dispute_until=until) From cab55699cfd1927791b8e75a242ad16e9a13f071 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 13:37:12 +0000 Subject: [PATCH 43/44] names: test that an unknown dispute end is left out of RNAME --- tests/SMPNamesTests.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/SMPNamesTests.hs b/tests/SMPNamesTests.hs index 02c25bf21..de3c581b7 100644 --- a/tests/SMPNamesTests.hs +++ b/tests/SMPNamesTests.hs @@ -183,6 +183,9 @@ availabilitySpec = do answers disputedBody (resolved disputedAlice) it "a registration that cannot be ended is answered with a dispute end of 0" $ answers finalBody (resolved finalAlice) + it "an unknown dispute end is answered as unknown, and left out of RNAME" $ do + answers (registeredBodyWith "\"disputeUntil\":null,\"reservedReason_\":null," testNameRecord) (resolved registeredAlice) + LB.toStrict (J.encode (resolved registeredAlice)) `shouldNotSatisfy` B.isInfixOf "disputeUntil" it "an unregistered name answers with the price" $ answers availableBody (resolved NRAvailable {pricing = testPricing, nameTerms = Nothing}) it "reserved carries the reason and no price" $ From 5d807a0bf2fd993f6dbcfc00ee46290bf6bcefb5 Mon Sep 17 00:00:00 2001 From: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:00:25 +0000 Subject: [PATCH 44/44] resolver: state how callers read a failed call and a revert --- scripts/resolver/service/test_snrc_resolve.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/resolver/service/test_snrc_resolve.py b/scripts/resolver/service/test_snrc_resolve.py index 8f6cbdbf3..463e74af8 100644 --- a/scripts/resolver/service/test_snrc_resolve.py +++ b/scripts/resolver/service/test_snrc_resolve.py @@ -1452,8 +1452,8 @@ def test_a_fresh_connection_that_fails_is_not_retried(self): self.assertEqual(self.node.requests, 1) def test_a_node_failure_is_not_a_reverted_call(self): - """Callers read RuntimeError as the call reverting and fall back to an - empty value, so a node failure must not look like one.""" + """Callers read RuntimeError as a failed call and CallReverted as a revert, + so a node failure must be neither.""" self.node.status = 502 with self.assertRaises(HTTPError) as cm: snrc.rpc("eth_blockNumber", [])