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

Default reverse resolver #335

Conversation

makoto
Copy link
Member

@makoto makoto commented Feb 26, 2024

  • Add DefaultResolver
  • Add SignatureResolver which is the super class of DefaultResolver and L2ReverseRegistrar
  • Change signature to use eip 191 version 0

contracts/reverseRegistrar/L2ReverseRegistrar.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/L2ReverseRegistrar.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/L2ReverseRegistrar.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
* @param addr The node to update.
* @param signature A signature proving ownership of the node.
*/
function clearRecordsWithSignature(
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 this works with signed messages; someone replaying a series of messages could choose to include or omit the clear signed message, producing different results either way.

Perhaps instead we can include a version in each signature message, and if the version is greater than the one stored, increment it, effectively erasing all past records?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am failing to understand why this is only issue for clearRecords but not for other set* functions. Also the inclusion of the version doesn't help when the someone keeps omitting to include the clear signed message.
Isn't inceptionDate enough against most abuses?

Copy link
Member

Choose a reason for hiding this comment

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

You're right; to be properly secure, inception dates would need to be recorded on each individual record (in the case of parameterised values such as text, on each key of each record); otherwise someone can replay just the last event, making it impossible to set earlier ones.

If someone omits a message, someone else can supply it - the issue is cases where omitting an earlier message but including a later one makes it impossible to supply the missing message later and arrive at the same end result.

Copy link
Member Author

Choose a reason for hiding this comment

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

otherwise someone can replay just the last event, making it impossible to set earlier ones. That would be problematic if we have a counter logic (eg: n=n+1) where the state depends on previous state. However, all setter* message simply overrides the previous state so there isn't much point supplying the missing message later.

I also didn't fully understand for inception dates would need to be recorded on each individual record

Are you suggesting to change from

    function _setLastUpdated(bytes32 node, uint256 inceptionDate) internal {
        lastUpdated[node] = inceptionDate;
    }

to

    function _setTextLastUpdated(bytes32 node, string key, uint256 inceptionDate) internal {
        lastUpdated[node][key] = inceptionDate;
    }

then change isAuthorisedWithSignature to take key ?

Copy link
Member

Choose a reason for hiding this comment

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

That would be problematic if we have a counter logic (eg: n=n+1) where the state depends on previous state. However, all setter* message simply overrides the previous state so there isn't much point supplying the missing message later.

They don't, though - setting the address for one coin type invalidates all other previous messages to set addresses for other coin types. The same goes for text records.

Either the last updated value needs to be per-key as you illustrate, or we need to change this to function differently - for example, by taking a complete set of records to set in a single operation, and increment the version at the same time. If going with the former, probably the last updated check should be moved outside isAuthorisedWithSignature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, it's getting a bit more complicating than simple fixes. You have been pointing out many changes to the functions not related to this PR but introduced at #265 (you only noticed because I moved the code to different file).

May I suggest to leave it for the separate PR by @jefflau

contracts/reverseRegistrar/ReverseRegistrar.sol Outdated Show resolved Hide resolved
@makoto
Copy link
Member Author

makoto commented Mar 28, 2024

I think it should be incorporated, there's no reason for it to be a separate parameter here. at #335 (comment) , addr is used to derive node at bytes32 node = _getNamehash(addr); line 73 @Arachnid

contracts/reverseRegistrar/L2ReverseRegistrar.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/L2ReverseRegistrar.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
contracts/reverseRegistrar/SignatureReverseResolver.sol Outdated Show resolved Hide resolved
* @param addr The node to update.
* @param signature A signature proving ownership of the node.
*/
function clearRecordsWithSignature(
Copy link
Member

Choose a reason for hiding this comment

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

You're right; to be properly secure, inception dates would need to be recorded on each individual record (in the case of parameterised values such as text, on each key of each record); otherwise someone can replay just the last event, making it impossible to set earlier ones.

If someone omits a message, someone else can supply it - the issue is cases where omitting an earlier message but including a later one makes it impossible to supply the missing message later and arrive at the same end result.

@Arachnid
Copy link
Member

Arachnid commented Apr 3, 2024

I think it should be incorporated, there's no reason for it to be a separate parameter here. at #335 (comment) , addr is used to derive node at bytes32 node = _getNamehash(addr); line 73 @Arachnid

Line 73 of what file? I can't see anywhere that would require this to be a separate parameter to the outer signature.

@makoto makoto merged commit 1736e33 into feature/crosschain-resolver-with-reverse-registrar Apr 9, 2024
2 checks passed
@makoto makoto deleted the default-reverse-resolver branch April 18, 2024 09:50
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.

None yet

4 participants