Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7e14084
resolver: plan the wording of an unregistered name
brenzi-agent Nov 20, 2026
e8f08a6
resolver: test that an unregistered name is not called never registered
brenzi-agent Nov 20, 2026
439643b
resolver: say an unregistered name is not registered, not never was
brenzi-agent Nov 20, 2026
adf0703
resolver, docs: a registration can end in its dispute period
brenzi-agent Nov 20, 2026
65f74f9
docs: describe registrations ended in their dispute period
brenzi-agent Nov 20, 2026
a8c98dc
resolver: test the exact answer for a name with expiry 0
brenzi-agent Nov 20, 2026
23e6aa6
docs: state who ends a registration and that renewals wait for its end
brenzi-agent Nov 20, 2026
722fd75
resolver: name the test of a zero expiry by the answer it checks
brenzi-agent Nov 20, 2026
4533251
names, resolver: plan reporting until when a registration can be ended
brenzi-agent Nov 20, 2026
2a2b29b
resolver: test until when a registration can be ended
brenzi-agent Nov 20, 2026
67f97b0
names: test that RNAME includes the dispute end of a registration
brenzi-agent Nov 20, 2026
2a65a50
resolver: report until when a registration can be ended
brenzi-agent Nov 20, 2026
ece12c2
names: pass the dispute end of a registration to clients
brenzi-agent Nov 20, 2026
5695bfd
resolver: state that available holds for any name with a zero expiry
brenzi-agent Nov 20, 2026
8593b2a
docs: list the dispute end with the other status fields
brenzi-agent Nov 20, 2026
b59646e
docs: define the dispute period by its disputeUntil field
brenzi-agent Nov 20, 2026
bf81a66
names, resolver: plan a null dispute end, and decisions without reasons
brenzi-agent Nov 20, 2026
7284418
resolver: test a null dispute end, and a subname under an ended 2LD
brenzi-agent Nov 20, 2026
437100b
resolver: answer a null dispute end, as a null reservation is answered
brenzi-agent Nov 20, 2026
ccaa9be
names: test the dispute end as a typed value, from the resolver's shape
brenzi-agent Nov 20, 2026
de62561
docs: name every registrar controller as able to end a registration
brenzi-agent Nov 20, 2026
d08ebd8
docs: state where each status field is read from, and when it is null
brenzi-agent Nov 20, 2026
57151a2
resolver: restore the docstring of the pinned key-set test
brenzi-agent Nov 20, 2026
51543e4
resolver: test a subname under an ended 2LD whose node has no owner
brenzi-agent Nov 20, 2026
a100b48
names, resolver: plan who ends a registration, and the regression tests
brenzi-agent Nov 20, 2026
30594da
names: build an old router's answer in the test by field name
brenzi-agent Nov 20, 2026
309f7e9
resolver: state why the keys of each answer are pinned
brenzi-agent Nov 20, 2026
fd5ebce
names, resolver: plan a dispute end of 0, and unknown on a node error
brenzi-agent Nov 20, 2026
5b15d53
resolver: test a dispute end of 0, and an unknown one on a node error
brenzi-agent Nov 20, 2026
a3abdc1
names: test that a dispute end of 0 is passed to clients
brenzi-agent Nov 20, 2026
ec3f03e
resolver: report 0 for a registration that cannot be ended
brenzi-agent Nov 20, 2026
edc519d
names: state a dispute end of 0, and an unknown one by its absence
brenzi-agent Nov 20, 2026
814b4f0
docs: name disputeUntil as the field left out when it could not be read
brenzi-agent Nov 20, 2026
3ea6bee
docs: complete the resolver's examples, and when a lookup is answered…
brenzi-agent Nov 20, 2026
5643f2e
names, resolver: plan a null dispute end on error, and geth's revert …
brenzi-agent Nov 20, 2026
d95489a
resolver: test geth's revert code, and a null dispute end on an error
brenzi-agent Nov 20, 2026
1bb91e2
resolver: read geth's revert code, and answer an unknown end as null
brenzi-agent Nov 20, 2026
bcca00a
resolver: build the dispute end call in tests with its helper
brenzi-agent Nov 20, 2026
2547d89
names: build the registered test answers from one body and one value
brenzi-agent Nov 20, 2026
6081b9b
docs: name the empty answer, and the v2 example's dispute end
brenzi-agent Nov 20, 2026
3832686
names, resolver: plan the lapsed state, and an empty answer as unknown
brenzi-agent Nov 20, 2026
8194afb
resolver: name the dispute end tests by what is answered
brenzi-agent Nov 20, 2026
cab5569
names: test that an unknown dispute end is left out of RNAME
brenzi-agent Nov 20, 2026
5d807a0
resolver: state how callers read a failed call and a revert
brenzi-agent Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions plans/2026-11-20-names-dispute-period.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# 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, 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](https://github.com/brenzi/simplex-namespace-contract/blob/main/docs/plans/dispute-period.md#L20), 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`: 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 |
| 9 | SMP version unchanged; a client does not read the absence of `disputeUntil` as 0 |

## What the resolver answers

```
name_status(name):
token = labelhash of the 2LD
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 JSON-RPC error, or empty -> unknown
a failed request to the node -> the lookup answered 502
```

```mermaid
stateDiagram-v2
[*] --> disputable: sponsored registration, 14 to 120 days
[*] --> 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, 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 |
| 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, or with an empty answer: null in v2 and v1, absent in RNAME.

```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: 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
```

## 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](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.
- 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.

## 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`
- `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`, null when unknown
- 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`:

- `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
- `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 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`:

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

`src/Simplex/Messaging/Protocol.hs`: `disputeUntil = Nothing` in the answer of a router before v22.

## Tests

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

`tests/RSLVTests.hs`: RNAME of that registration, direct and forwarded through a proxy.
23 changes: 17 additions & 6 deletions protocol/simplex-messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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 nobody
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
Expand All @@ -1518,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 <detail>` | 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 `<detail>`; retry only if it reads as transient |
| `ERR NAME RESOLVER <detail>` | 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 `<detail>`; 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
Expand Down Expand Up @@ -1551,14 +1552,23 @@ 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 |

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

| 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 | 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 |
Expand Down Expand Up @@ -1589,15 +1599,16 @@ 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.

A router that cannot state an answer completely MUST send `ERR NAME RESOLVER
<detail>` 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:

Expand Down
Loading
Loading