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

ENSIP-15 support #3000

Merged
merged 16 commits into from
Jun 23, 2023
Merged

ENSIP-15 support #3000

merged 16 commits into from
Jun 23, 2023

Conversation

fselmo
Copy link
Collaborator

@fselmo fselmo commented Jun 20, 2023

What was wrong?

Closes #2967

How was it fixed?

  • Add ENSIP-15 normalization standard support
  • Add tests

See specification here: ENSIP-15

Todo:

  • Add entry to the release notes
  • Documentation for this support... likely in a separate PR? (separate PR incoming)

Cute Animal Picture

20230620_141546

@fselmo fselmo changed the title Ensip 15 ENSIP-15 support Jun 20, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 20, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 20, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 20, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 20, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 20, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 20, 2023
@fselmo fselmo requested review from kclowes, pacrob and reedsa June 20, 2023 20:19
@fselmo fselmo marked this pull request as ready for review June 20, 2023 20:19
@fselmo
Copy link
Collaborator Author

fselmo commented Jun 20, 2023

This is ready for a first review. The way I implemented it follows pretty true to the spec descriptions through each section. This isn't necessarily the fastest way to implement it but it may be easier to read this way. I don't see it presenting much of an issue but if we want to optimize it, I think we can tackle that in a separate PR.

@fselmo
Copy link
Collaborator Author

fselmo commented Jun 20, 2023

We should also think about documenting this but I'm thinking also in a separate PR?

Copy link
Contributor

@reedsa reedsa left a comment

Choose a reason for hiding this comment

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

Looks good as far as I can tell. I like the way you used the flag here, it makes sense to flip for v7. In the long run will this flag be removed or will that be necessary?

tests/ens/test_utils.py Show resolved Hide resolved
@fselmo
Copy link
Collaborator Author

fselmo commented Jun 21, 2023

In the long run will this flag be removed or will that be necessary?

The goal for ENS is for ENSIP-15 to entirely replace ENSIP-1 for normalization so I think on our end it would make sense to remove the flag in v7 since there should only be one way to normalize a name by that point.

fselmo added 9 commits June 21, 2023 10:58
- This more accurately catches cases where more than one blank space may be passed in, which still constitutes an empty name.
- Appropriately check for empty name, not just ``None`` value
- Begin implementing ENSIP-15
- Add spec json files directly from the specification and add the tests json file
- Begin writing the normalization test(s) under tests/ens/normalization
…any``

- Asked a question on the original PR for ENSIP-15 and got a good response back. This should be ``all()`` and not ``any()``.
- Added a note for clarification
- Some cleanup, mostly linting.
fselmo added 4 commits June 21, 2023 11:00
- Add back the logic that exists for ``normalize_name`` and add a flag for normalizing via ENSIP-15 so as not to break the library. This flag will likely be removed and become the default in web3.py ``v7``.
- Add a flag on the ENS class itself that turns on ENSIP-15 normalization for all internal class methods
- Re-structure some imports and get rid of circular dependency issue
ens/_normalization.py Outdated Show resolved Hide resolved
ens/_normalization.py Outdated Show resolved Hide resolved
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 22, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 22, 2023
fselmo added a commit to fselmo/web3.py that referenced this pull request Jun 22, 2023
Copy link
Contributor

@pacrob pacrob left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

This ENSIP was a doozy! Thanks for taking it on! Overall this looks really great. Just a few observations:

  • Can we catch the warnings that are emitted in the existing ens tests? :)
  • It might be more understandable to split some of the big functions (in ens/_normalization.py in particular) into smaller functions with names that describe what they do, even though they don't get re-used. Feel free to take or leave this one
  • It might also be nice to do some smoke testing to make sure the flag is working on the static methods. For example, pass an ens name where nameprep('...', ensip15=True) return a different result than nameprep('...', ensip15=False)

ens/_normalization.py Show resolved Hide resolved
ens/ens.py Show resolved Hide resolved
ens/_normalization.py Show resolved Hide resolved
ens/_normalization.py Show resolved Hide resolved
@fselmo
Copy link
Collaborator Author

fselmo commented Jun 23, 2023

Can we catch the warnings that are emitted in the existing ens tests? :)

Which tests?

It might also be nice to do some smoke testing to make sure the flag is working on the static methods.

Coming up in a separate PR with documentation on this as well 👍🏼

t might be more understandable to split some of the big functions (in ens/_normalization.py in particular) into smaller functions with names that describe what they do, even though they don't get re-used.

These were just helped methods to help me extract information from the json files. I can do a pass-through and try to clarify some more things 👍🏼


edit: Oh I see which tests. All of them basically 😆 ... yeah that's a good point. I'll see what I can do 🤔

@fselmo fselmo merged commit a9433ff into ethereum:main Jun 23, 2023
fselmo added a commit that referenced this pull request Jun 23, 2023
fselmo added a commit that referenced this pull request Jun 23, 2023
@fselmo fselmo deleted the ensip-15 branch June 23, 2023 21:08
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.

Update ENS normalization to new standard
4 participants