-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
Uses reverse registry records to heal label from transaction sender address
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…stry-subnames-auto-healing
|
||
// if the label has not healed with ENSRainbow query | ||
// and healing label from reverse addresses is enabled, give it a go | ||
if (!healedLabel && canHealReverseAddresses()) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
…stry-subnames-auto-healing
Only the eth plugin uses the env-based feature flag, while other plugins have reverse addresses healing turned off
…stry-subnames-auto-healing
Simplify indexing handlers code and move extra complexity to config file for each plugin.
…stry-subnames-auto-healing
There was a problem hiding this 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
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. |
There was a problem hiding this 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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labelhash: "0x535bdae9bb214b3cc583b53384464999f2f7f48625f160728c63e73e766ff71e", | |
labelhash: labelhash(vitalikEthNormalizedAddress), |
); | ||
}); | ||
|
||
it("should throw if labelhash is not a valid hash", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it("should throw if labelhash is not a valid hash", () => { | |
it("should throw if labelhash is not a valid Labelhash", () => { |
...validArgs, | ||
labelhash: notMatchingLabelhash, | ||
}), | ||
).toThrowError( |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const vitalikEthResolvedAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; | |
const address = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; |
Suggest to keep it simple and more generic.
|
||
describe("labelByReverseAddress", () => { | ||
const vitalikEthResolvedAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; | ||
const vitalikEthNormalizedAddress = "d8da6bf26964af9d7eed9e03e53415d37aa96045"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const vitalikEthNormalizedAddress = "d8da6bf26964af9d7eed9e03e53415d37aa96045"; | |
const reverseAddressSubname = "d8da6bf26964af9d7eed9e03e53415d37aa96045"; |
…stry-subnames-auto-healing
Co-authored-by: lightwalker.eth <[email protected]>
…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.
…stry-subnames-auto-healing
closes #204
Suggested review order
package/ensnode-utils
updates.apps/ensindexer/src/lib
updates.apps/ensindexer/src/plugins
updates.apps/ensindexer/src/handlers
updatesponder.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
totrue
orfalse
, respectively. Please note, that only theeth
plugin is going to support the new feature, whilebase
andlinea
plugins will not.To complete the feature, I had to:
HEAL_REVERSE_ADDRESSES
env var;canHealReverseAddresses
andisReverseRootNode
;handleNameRegistered
&handleNewOwner
to attempt reverse address label healing before attempting ENSRainbow label healing;HEAL_REVERSE_ADDRESSES
env var valuePre-merge checklist
eth
plugin on hasHEAL_REVERSE_ADDRESSES
set tofalse
Post-merge checklist
labelByReverseAddress
callResolves #204