Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ensindexer): introduce label healing from reverse registry #362

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

tk-o
Copy link
Contributor

@tk-o tk-o commented Mar 10, 2025

closes #204

Suggested review order

  1. Review package/ensnode-utils updates.
  2. Review apps/ensindexer/src/lib updates.
  3. Review apps/ensindexer/src/plugins updates.
  4. Review apps/ensindexer/src/handlers updates
  5. Review ponder.config.ts updates.

Scope

This PR introduces a feature of healing labels based on reverse addresses. This feature can be toggled on and off, by setting to HEAL_REVERSE_ADDRESSES to true or false, respectively. Please note, that only the eth plugin is going to support the new feature, while base and linea plugins will not.

To complete the feature, I had to:

  • create a parser for HEAL_REVERSE_ADDRESSES env var;
  • update the ponder plugin handler args type, to include plugin-defined helper methods canHealReverseAddresses and isReverseRootNode;
  • have all plugins to provide implementations for new helper methods (some of them throw error just to manifest lack of support for the feature in question);
  • update generic handlers handleNameRegistered & handleNewOwner to attempt reverse address label healing before attempting ENSRainbow label healing;
  • make ponder config object value altered based of HEAL_REVERSE_ADDRESSES env var value

Pre-merge checklist

  • ensure every ENSIndexer and ENSApi service that runs with only eth plugin on has HEAL_REVERSE_ADDRESSES set to false

Post-merge checklist

  • create an issue for handling errors thrown by labelByReverseAddress call
  • create an issue for healing addr.reverse subnames for non-mainnet chains

Resolves #204

Uses reverse registry records to heal label from transaction sender address
Copy link

vercel bot commented Mar 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
admin.ensnode.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2025 8:17pm
ensadmin-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2025 8:17pm
ensnode.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2025 8:17pm
ensrainbow.io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 17, 2025 8:17pm


// if the label has not healed with ENSRainbow query
// and healing label from reverse addresses is enabled, give it a go
if (!healedLabel && canHealReverseAddresses()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe check that first and if not try healing with ENSRainbow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, so first we try healing based of the in memory data (using reverse address method), and only if it didn't return any result we should try healing with ENSRainbow. Did I get that right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, maybe it will be faster?

tk-o added 2 commits March 11, 2025 07:50
Only the eth plugin uses the env-based feature flag, while other plugins have reverse addresses healing turned off
tk-o added 2 commits March 12, 2025 16:03
Simplify indexing handlers code and move extra complexity to config file for each plugin.
Copy link
Contributor

@shrugs shrugs left a comment

Choose a reason for hiding this comment

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

Since only the eth plugin will perform this behavior, the configuration options need not be plugin-specific and you can use a global constant for namehash('addr.reverse') and reference the healReverseAddresses config in the shared handlers directly using a conditional like this, with the appropriate comments describing its behavior.

if (ownedName === '.eth' && healReverseAddresses && node === ADDR_REVERSE_NODE) { ... }

using this method the plugin definitions and handler args need not be updated at all.


alternatively if you'd prefer to keep the logic plugin-specific i'd suggest a simpler api like:

canHealFromNode?: (node: Node): boolean

that is simply not included for base/linea plugin definitions and the implementation for .eth looks like:

const canHealFromNode = (node: Node) => healReverseAddresses && node === ADDR_REVERSE_NODE;

and the conditional in the helpers looks like

if (canHealFromNode?.(node)) { ... }

otherwise LGTM

@tk-o
Copy link
Contributor Author

tk-o commented Mar 12, 2025

I like the alternative option suggestion as it shows (IMO) better the intent of which plugins support the new healing strategy and which don't.

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@tk-o Hey awesome work here 🚀 Reviewed and shared feedback 👍


const validArgs = {
// labelhash for `d8da6bf26964af9d7eed9e03e53415d37aa96045`
labelhash: "0x535bdae9bb214b3cc583b53384464999f2f7f48625f160728c63e73e766ff71e",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
labelhash: "0x535bdae9bb214b3cc583b53384464999f2f7f48625f160728c63e73e766ff71e",
labelhash: labelhash(vitalikEthNormalizedAddress),

);
});

it("should throw if labelhash is not a valid hash", () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it("should throw if labelhash is not a valid hash", () => {
it("should throw if labelhash is not a valid Labelhash", () => {

...validArgs,
labelhash: notMatchingLabelhash,
}),
).toThrowError(
Copy link
Member

Choose a reason for hiding this comment

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

This should return null, not throw an error.

@@ -75,3 +77,55 @@ describe("makeSubnodeNamehash", () => {
);
});
});

describe("labelByReverseAddress", () => {
const vitalikEthResolvedAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const vitalikEthResolvedAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
const address = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";

Suggest to keep it simple and more generic.


describe("labelByReverseAddress", () => {
const vitalikEthResolvedAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
const vitalikEthNormalizedAddress = "d8da6bf26964af9d7eed9e03e53415d37aa96045";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const vitalikEthNormalizedAddress = "d8da6bf26964af9d7eed9e03e53415d37aa96045";
const reverseAddressSubname = "d8da6bf26964af9d7eed9e03e53415d37aa96045";

tk-o added 4 commits March 13, 2025 07:03
…hub.com:namehash/ensnode into feat/204-reverse-registry-subnames-auto-healing
`Registrar.ts` is only for the registrars for direct subnames of .eth, linea.eth, or base.eth. It can never be a reverse registrar.
Returns `null` if healing fails. Also, all relevant tests were simplified.
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.

Automatically Heal subnames of "addr.reverse".
4 participants