Skip to content

Add Canonical Name#217

Closed
adraffy wants to merge 12 commits intomainfrom
feat/canonical-name
Closed

Add Canonical Name#217
adraffy wants to merge 12 commits intomainfrom
feat/canonical-name

Conversation

@adraffy
Copy link
Member

@adraffy adraffy commented Feb 19, 2026

  • changed IRegistry
    • added getCanonicalName() returns (name)
    • added event CanonicalNameUpdated
  • changed IStandardRegistry
    • added setCanonicalName(name)
  • changed PermissionedRegistry
    • added ROLE_SET_CANONICAL_NAME
    • implemented setCanonicalName() and getCanonicalName()
    • added tests
  • changed LibRegistry
    • added findCanonicalRegistry(root, name, offset) returns (registry)
      • tries to avoid reverting and returns null when reasonable
    • added tests
  • changed UniversalResolverV2
    • added isCanonical(name) returns (bool)unsure if this is the right function to expose


⭐️ Personally, I like the #209 approach (as immediate access to the parent seems useful and it avoids someone using an non-canonical name) but this matches the original design that was discussed. It's also cleaner when you move things around, since only 1 canonical reference needs changed, instead of every descendant.

@adraffy adraffy mentioned this pull request Feb 19, 2026
@adraffy adraffy marked this pull request as ready for review February 23, 2026 09:31
@immunefi-magnus
Copy link

immunefi-magnus bot commented Feb 23, 2026

🛡️ Immunefi PR Reviews

This pull request is not eligible for a PR Reviews review. Please contact Immunefi support.

Reason: This PR can't be reviewed because no PR Reviews plan is configured for your organisation. Please ask your admin to set up a plan to enable reviews.

@adraffy adraffy requested a review from Arachnid February 23, 2026 09:36
Copy link
Member

@Arachnid Arachnid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this a while ago and you made a good argument that having a (registry, token id) pair was a better option than a name. Have you changed your mind?

@adraffy
Copy link
Member Author

adraffy commented Feb 23, 2026

Yeah, there's a slack discussion (where I'm arguing with myself 🤣️) and #209 is the other implementation.

They're basically equivalent and only differ in their properties:

#209 (registry, label) uses slightly more storage for short names and the only way to get the canonical name is to construct it. This means you never have a non-canonical "canonical" name: you either have a canonical name or nothing.

#217 name gives each registry a name, but you must check that its actually canonical. The "fix" is requiring that each ancestor is also canonical and the optimization is checking that each parents canonical name has a common suffix with the child:

/// @dev `name` is canonical if it's ancestors are canonical and share parential suffixes:
/// eg.        Canonical    not-Canonical     not-Canonical
///            =========    =============     =============
///     abc.sub.test.eth          abc.eth      a.b.test.eth
///         sub.test.eth            > xyz <      b.test.eth
///             test.eth            <root>       > nick.eth <
///                  eth                                eth
///                <root>                             <root>

Ignoring storage, it's ultimately the choice between:

  • The registry has an explicit parent but UR.findCanonicalName(registry) returns (name?) is required to derive the name
  • The registry has an explicit name but can only be used if UR.isCanonical(name) returns (bool) is true

@adraffy adraffy requested a review from Arachnid February 24, 2026 22:32
@adraffy adraffy marked this pull request as draft February 26, 2026 09:23
@adraffy
Copy link
Member Author

adraffy commented Mar 2, 2026

Using #209

@adraffy adraffy closed this Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants