-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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 transferRole
function to AccessRole
allowing transferring of roles from role bearers to a new accounts
#3593
Conversation
…roles from role bearers to a new accounts
Hello @lbeder And thank you for raising that. I'm not sure this is something we want. The roles are designed to be managed by an admin. This means that if you have a role, you can't necessarily grant it to someone else. I understand that this PR transfers the role, in the sens that it revokes it from the previous owner. However, you could use that to transfer a role to a smart contract that would allow multiple accounts to operate with it. IMO this would be breaking the assumptions that make AccessControl what it is today. Basically, I don't think users should be able to create/leverage this kind of contracts without specific approval.
|
Hey @Amxx, I understand your point but keep in mind that one can't make this assumption today either. For example, an EOA can be shared (even retroactively) between multiple parties either via a threshold ECDSA protocol (like it's done by many custody services) or even the private key itself can be just transferred (not necessarily intentionally) to a third party. I.e., in any case, you can't assume that a role receiver can't grant the role to someone else, while this PR allows it to be handled in a more transparent, observable, and explicit way. Would you prefer that I'll implement it as an |
Hey everyone! I'm Nico from Mean Finance 👋 . I came across this PR, and I just wanted to share our experience. As you say @Amxx , we have an admin that manages all other roles, but we would love to be able to transfer it from one account to the other. We wanted to migrate from EOAs to Multisigs and we had to redeploy 😅
That's it, just wanted to give our 2 cents |
I like this addition, feels like self service, (reset own password, transfer MFA to new device) ... |
) public virtual override { | ||
require(account == _msgSender(), "AccessControl: can only transfer roles from self"); | ||
|
||
if (account != recipient && hasRole(role, account) && !hasRole(role, recipient)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to require or not to require ...
... maybe all these conditions on this if
should be individual require
, that way we can explain why it does not get transferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I agree, but I wanted to make this new function as similar and idiosyncratic to the existing code (see the graceful return in _revokeRole
).
These are interesting points to consider but the implications of a If the private key is a threshold key from the start this is simply part of the assumptions when the role is granted. Personally I don't see reasons to make a role transferable except perhaps for the specific case of the admin as shared by @nchamo. But I think that should be tackled differently, as a special case rather than a general ability to transfer any role. So I think we should shelve this PR and separately discuss a design for that case. |
Closing based on the reasoning described in #3593 (comment) and #3593 (comment). Transferability for the admin role being discussed in #3623. |
In this PR, I've added a new
transferRole
function toAccessControl
, which allows role bearers to transfer their privileges to new accounts in case they are switching to a new account or compromised, without involving the role admin (which in many cases is an involved time-locked governance process).renounceRole
, theaccount
has to be the caller itself.account
torecipient
will result in:role
will be granted to therecipient.
role
will be revoked fromaccount
(the caller)account
andrecipient
are the same accounts.account
doesn't bear the targetrole
.recipient
already bears the targetrole
.I've tried to make the PR as idiosyncratic as possible, but of course, any feedback is highly appreciated and welcome. I've also ensured that all new and existing tests are passing and that the new code is fully covered.
P.S.,
If this PR is accepted and merged, I'd be more than happy to port it to AccessControlUpgradeable.sol as well.