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

Add EIP-712 name and version getters #4303

Merged
merged 15 commits into from Jun 14, 2023

Conversation

RenanSouza2
Copy link
Contributor

@RenanSouza2 RenanSouza2 commented Jun 2, 2023

Fixes #4226

Add internal name and version getters for EIP712

PR Checklist

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

@changeset-bot
Copy link

changeset-bot bot commented Jun 2, 2023

🦋 Changeset detected

Latest commit: ce00023

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

IMO, eip712Domain() public should use these two new internal function (in case they are ever overriden)

EDIT: actually, if the values ever change (because of an override) that would cause a lot of trouble ... so I'll remove the virtual keyword for the 2 internal functions.

contracts/utils/cryptography/EIP712.sol Outdated Show resolved Hide resolved
contracts/utils/cryptography/EIP712.sol Outdated Show resolved Hide resolved
@RenanSouza2
Copy link
Contributor Author

RenanSouza2 commented Jun 2, 2023

IMO, eip712Domain() public should use these two new internal function (in case they are ever overriden)

EDIT: actually, if the values ever change (because of an override) that would cause a lot of trouble ... so I'll remove the virtual keyword for the 2 internal functions.

Yes, agreed

how about an internal setFunction(atring) so it can also be overriden?

Edit: saw your edit now

@Amxx
Copy link
Collaborator

Amxx commented Jun 2, 2023

I don't think this values should ever be changed. If they were, the caches would be invalid ... and we can't update the immutable cache.

Also I don't think frontends are designed to handle such changes

@RenanSouza2
Copy link
Contributor Author

Makes sense, I commited with the getters used internaly and there are no more changes to be done, right?

Also the checks / tests-upgradeable is failling but I gess it it some conflict with the upgradeable contract that already have this getters, I`ll see how to fix this

@Amxx
Copy link
Collaborator

Amxx commented Jun 6, 2023

It looks good to me, but I'd like @ernestognw and @frangio 's opinion on whether the getters should be virtual.

Its critical that the values returned by the getters are constant in time, because the eip721domain must match the (immutable) cached values.

@ernestognw ernestognw requested a review from a team June 6, 2023 16:15
Amxx
Amxx previously approved these changes Jun 9, 2023
Copy link
Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

LGTM

@ernestognw
Copy link
Member

It looks good to me, but I'd like @ernestognw and @frangio 's opinion on whether the getters should be virtual.

Its critical that the values returned by the getters are constant in time, because the eip721domain must match the (immutable) cached values.

Perhaps there's a use case in overriding any of those values. For example, if a contract wants to invalidate a domain within an upgrade (eg. reject signatures based on the version).

Still, I'm not convinced it's worth the risk of letting users override them.

Are you really sure those values will never change? @Amxx

@frangio
Copy link
Contributor

frangio commented Jun 9, 2023

@jbcarpanelli suggested making all functions virtual but adding an annotation saying whether overriding is either fully okay, or okay under certain conditions (invoking super), or probably never okay. The idea is to still allow these overrides for the shadowy coders who want that but to document the potential implications.

E.g.:

@custom:overrideability { unrestricted | restricted | discouraged }

@ernestognw ernestognw changed the title Eip712 getters Add EIP-712 name and version getters Jun 10, 2023
@ernestognw
Copy link
Member

I had to update the upgradeable scripts. However, there were a few issues related to previous changes we've merged.
I think it makes sense but since it's my first time using the upgradeable patch I'll require a review from @frangio and @Amxx again.

Almost there!

@ernestognw ernestognw requested review from Amxx and frangio June 10, 2023 00:55
@Amxx
Copy link
Collaborator

Amxx commented Jun 12, 2023

Perhaps there's a use case in overriding any of those values. For example, if a contract wants to invalidate a domain within an upgrade (eg. reject signatures based on the version).

If the internal getters are override, and the value changes during the contract's life, the eip712domain will be updated but the cache will not be modified. The domain separator used for recovery will stay the old one.

On the upgradeable version of this contract, the storage is very different. It doesn't have a cache, and recomputes the domainSeparator every time. The upgradeable version already includes getters, and they are virtual.

So any decision we make here should NOT be motivated by contract upgradeability.

Copy link
Contributor

@frangio frangio left a comment

Choose a reason for hiding this comment

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

LGTM.

@frangio frangio merged commit 6040254 into OpenZeppelin:master Jun 14, 2023
14 checks passed
@RenanSouza2 RenanSouza2 deleted the EIP712-getters branch June 14, 2023 18:04
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.

Add internal name and version getters for EIP712
4 participants