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:attempt to implement L1ETHRegistry for ejected names #20

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

Conversation

mdtanrikulu
Copy link
Contributor

@mdtanrikulu mdtanrikulu commented Feb 26, 2025

Using @hiddentao 's ETHRegistry as a reference I tried to implement L1ETHRegistry.

Note: Just now I see that the ticket is assigned today already. So feel free to skip if there is another effort.

One design decision yet to be determined is whether renewal of ejected names
occurs on L2 or L1. If it occurs on L2, the L1 ejection controller is responsible for
updating the L1 .eth registry with new expiration dates propagated from L2.
Otherwise, a controller on the L1 .eth registry is responsible for renewing names
natively and sending a message to L2 to update the L2 .eth registry on the
change.

The code implements L1-native renewals, based on the feedback, but open to discussion.

  1. Not sure about uri function implementation, at the moment it returns emtpy string just as ETHRegistry, but I thought
function uri(uint256 tokenId) public view override returns (string memory) {
  (address resolver,) = datastore.getResolver(tokenId);
  return IResolver(resolver).uri(tokenId);
}

could be also an approach.

@coveralls
Copy link

coveralls commented Feb 26, 2025

Pull Request Test Coverage Report for Build 13589122509

Details

  • 92 of 92 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+10.1%) to 68.71%

Totals Coverage Status
Change from base Build 13540426288: 10.1%
Covered Lines: 298
Relevant Lines: 424

💛 - Coveralls

@hiddentao
Copy link
Contributor

Feel free to take the ticket!

@mdtanrikulu mdtanrikulu marked this pull request as ready for review February 28, 2025 13:28
@mdtanrikulu mdtanrikulu requested a review from Arachnid February 28, 2025 13:28
event NameRenewed(uint256 indexed tokenId, uint64 newExpiration, address renewedBy);
event NameRelinquished(uint256 indexed tokenId, address relinquishedBy);
event NameMigratedToL2(uint256 indexed tokenId, address sendTo);
event FallbackResolverSet(address resolver);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need an event for this, since the registry will emit an event in any case.

event TokenObserverSet(uint256 indexed tokenId, address observer);

// Address of the fallback resolver for names not found in this registry
address public fallbackResolver;
Copy link
Member

Choose a reason for hiding this comment

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

This will be resolved via the parent registry's resolver field, no need to store it here.

_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

function uri(uint256 /*tokenId*/ ) public pure override returns (string memory) {
Copy link
Member

Choose a reason for hiding this comment

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

Best add a TODO here.

* @param expires Expiration timestamp
* @return tokenId The token ID of the ejected name
*/
function ejectFromL2(string calldata label, address owner, IRegistry registry, uint96 flags, uint64 expires)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should probably be using the label hash here, not the plaintext label.

flags = (flags & FLAGS_MASK) | (uint96(expires) << 32);

// If there is a previous owner, burn the token
address previousOwner = super.ownerOf(tokenId);
Copy link
Member

Choose a reason for hiding this comment

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

We need to check that the previous name is expired first, so that a malicious ejection controller can't override L1 names.

* @param expires Expiration timestamp
* @return tokenId The token ID of the ejected name
*/
function ejectFromL2(string calldata label, address owner, IRegistry registry, uint96 flags, uint64 expires)
Copy link
Member

Choose a reason for hiding this comment

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

Either we should accept only a uint32 of flags, or we should accept a combined flags+expiration as a single field. Accepting a uint96 of which 64 bits have to be zero seems odd.

* @dev Relinquish an ejected name
* @param tokenId The token ID of the name to relinquish
*/
function relinquish(uint256 tokenId) external onlyTokenOwner(tokenId) {
Copy link
Member

Choose a reason for hiding this comment

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

How does this differ from migrateToL2?

* @param tokenId The token ID of the name to migrate
* @param sendTo The address to send the name to on L2
*/
function migrateToL2(uint256 tokenId, address sendTo)
Copy link
Member

Choose a reason for hiding this comment

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

This needs to notify the ejection controller, so that control can be given back to the user on L2.

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.

4 participants