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 AccessControlDefaultAdminRules #4009

Merged

Conversation

ernestognw
Copy link
Member

@ernestognw ernestognw commented Jan 28, 2023

Fixes #3623
Fixes LIB-618

PR Checklist

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

@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2023

🦋 Changeset detected

Latest commit: b164929

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

@ernestognw ernestognw requested review from frangio and Amxx January 28, 2023 00:17
contracts/access/IAccessControlAdminRules.sol Outdated Show resolved Hide resolved
contracts/access/AccessControlAdminRules.sol Outdated Show resolved Hide resolved
contracts/access/AccessControlAdminRules.sol Outdated Show resolved Hide resolved
contracts/access/AccessControlAdminRules.sol Outdated Show resolved Hide resolved
contracts/access/AccessControlAdminRules.sol Outdated Show resolved Hide resolved
contracts/access/AccessControlAdminRules.sol Outdated Show resolved Hide resolved
contracts/access/AccessControlAdminRules.sol Outdated Show resolved Hide resolved
ernestognw and others added 2 commits January 30, 2023 11:29
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
@Amxx
Copy link
Collaborator

Amxx commented Jan 30, 2023

It feels to me that this contract is safe, but that this safety relies on the functions not being virtual, and on the user not doing "tricks".

As a dev, I just need to call AccessControl._grantRole(...) instead of _grantRole(...) to add a second admin.

@ernestognw
Copy link
Member Author

It feels to me that this contract is safe, but that this safety relies on the functions not being virtual, and on the user not doing "tricks".

Sorry, it was not intentional to avoid virtual, the contract should still be safe. However, do you have any concerns with some override?

As a dev, I just need to call AccessControl._grantRole(...) instead of _grantRole(...) to add a second admin.

Hmm, that's correct, but I wonder why that might happen.

@ernestognw ernestognw mentioned this pull request Jan 31, 2023
1 task
@frangio
Copy link
Contributor

frangio commented Jan 31, 2023

As a dev, I just need to call AccessControl._grantRole(...) instead of _grantRole(...) to add a second admin.

This same argument applies to all of our extensions. You can probably mess up ERC20Votes or something by calling ERC20._transfer somewhere and end up with nearly infinite votes (not saying this exact thing is possible). I don't think it's something that is within our threat model at all.

Our guideline is to design contracts that are difficult to misuse, not impossible to misuse or to abuse.

@ernestognw
Copy link
Member Author

Reviewing the docs made me think that the delay should be configurable... That said I want us to merge this PR and we can discuss it as a potential follow up. But let me know your thoughts.

We can discuss it further. The initial reason for not doing it was avoiding the management it comes with.
That said, we can lock the delay if there's no started transfer if that makes sense to you.

If we'll do it. I'd like to do it in a follow-up PR.

@ernestognw ernestognw requested review from frangio and Amxx February 22, 2023 01:55
frangio
frangio previously approved these changes Feb 22, 2023
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.

This is good to merge, but we should probably follow up with modifiable delay in another PR.

We could also review the naming for "delayed until".

frangio
frangio previously approved these changes Feb 24, 2023
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. Also @Amxx agreed to merge. We will follow up with configurable delay in another PR, and a final review round.

@frangio frangio enabled auto-merge (squash) February 24, 2023 19:28
@frangio
Copy link
Contributor

frangio commented Feb 24, 2023

There was a flaky test because of the use of time.increaseTo, which mines a block with the argument timestamp, but does not guarantee the timestamp of the following block. Also due to how time.latest() was being used to compute the "delayed until" timestamp, it needs to be called after the transaction that begins the transfer because latest returns the timestamp of the last block.

@frangio frangio merged commit dad7315 into OpenZeppelin:master Feb 24, 2023
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.

AccessControl Admin Rules
3 participants