Make ERC20Votes independent of ERC20Permit
🧐 Motivation
We need a more clear and independent structure of ERC20 extensions.
📝 Details
Now ERC20Votes inherits ERC20Permit to use EIP712 inheritance and moreover to abuse its permit nonces. I believe we can remove the ERC20Permit constructor to keep it abstract and make ERC20Votes have its own nonces for delegation and direct inheritance from EIP712.
Moreover, I see you have Votes implementation since 4.5, so hopefully, you are going to use this implementation in ERC20Votes.
Moreover, I see you have Votes implementation since 4.5, so hopefully, you are going to use this implementation in ERC20Votes.
We would love to, but that would change the storage layout, which is a big breaking change for the upgradeable version of the contract :/
The storage layout is incompatible because of the nonces mapping in Votes, which in ERC20Votes is reused from ERC20Permit as pointed out here. Other than that, some variables were wrapped in structs which should be soon supported by the Upgrades Plugins as a valid upgrade.
The nonces are an issue but interestingly it's part of @k06a's proposa to change that as well. However:
make
ERC20Voteshave its own nonces
How would this work? The Votes interface is not standardized but the EIP712 signatures for voting by sig should use the value returned by the nonces() function so I don't see how we could change this without affecting clients that rely on this.
remove the ERC20Permit constructor to keep it abstract
This is a breaking change but we agree, we will have to do it in the next major release.
@k06a Is there something in particular that motivates these suggestions?
@frangio was just browsing library code and wondered when saw code duplications and unexpected dependencies.
Changed the title to make it clearer but as the description says this also implies changing ERC20Permit so it doesn't invoke the constructor of EIP712.
Fixed by https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3816 for future 5.0 release.