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

Make AccessManager.execute/schedule more conservative when delay is 0 #4644

Merged
merged 5 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-drinks-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': major
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it's major, isn't a patch although we're in pre-release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know, wasn't sure what to choose. In theory this is a breaking change, that's why I chose major. I don't think it will make any difference to the release process.

Copy link
Member

Choose a reason for hiding this comment

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

Ok make sense, also make sure it'll be picked up by the changeset versioning, which I think it will

---

`AccessManager`: Make `schedule` and `execute` more conservative when delay is 0.
11 changes: 6 additions & 5 deletions contracts/access/manager/AccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,12 @@ contract AccessManager is Context, Multicall, IAccessManager {
address caller = _msgSender();

// Fetch restrictions that apply to the caller on the targeted function
(bool immediate, uint32 setback) = _canCallExtended(caller, target, data);
(, uint32 setback) = _canCallExtended(caller, target, data);

uint48 minWhen = Time.timestamp() + setback;

// if call is not authorized, or if requested timing is too soon
if ((!immediate && setback == 0) || (when > 0 && when < minWhen)) {
// if call with delay is not authorized, or if requested timing is too soon
if (setback == 0 || (when > 0 && when < minWhen)) {
revert AccessManagerUnauthorizedCall(caller, target, _checkSelector(data));
}

Expand Down Expand Up @@ -644,11 +644,12 @@ contract AccessManager is Context, Multicall, IAccessManager {
revert AccessManagerUnauthorizedCall(caller, target, _checkSelector(data));
}

// If caller is authorised, check operation was scheduled early enough
bytes32 operationId = hashOperation(caller, target, data);
uint32 nonce;

if (setback != 0) {
// If caller is authorised, check operation was scheduled early enough
// Consume an available schedule even if there is no currently enforced delay
if (setback != 0 || getSchedule(operationId) != 0) {
nonce = _consumeScheduledOp(operationId);
}

Expand Down
2 changes: 2 additions & 0 deletions test/access/manager/AccessManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ contract('AccessManager', function (accounts) {

describe(description, function () {
beforeEach(async function () {
if (!delay || fnRole === ROLES.PUBLIC) this.skip(); // TODO: Fixed in #4613

// setup
await Promise.all([
this.manager.$_setTargetClosed(this.target.address, closed),
Expand Down
Loading