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

feature: Stricter permission/condition fallback mechanism for isGranted #461

Merged
merged 43 commits into from
Sep 21, 2023

Conversation

heueristik
Copy link
Contributor

@heueristik heueristik commented Sep 4, 2023

Description

This PR removes the fallback functionality ( two logical ORs ||)

function isGranted(address _where, address _who, bytes32 _permissionId, bytes memory _data) public view virtual returns (bool) {
  /*(1)*/ _isGranted(_where, _who, _permissionId, _data) ||
  /*(2)*/ _isGranted(_where, ANY_ADDR, _permissionId, _data) ||
  /*(3)*/ _isGranted(ANY_ADDR, _who, _permissionId, _data);
}

from isGranted in PermissionManager as it could lead to unintuitive behavior.
The new behavior is as follows (excerpt from the docs):

Moreover, if a condition is set, we return its isGranted result and do not fall back to a more generic one. The condition checks occur in the following order

  1. Condition with specific _who and specific where.
  2. Condition with generic _who: ANY_ADDR and specific _where.
  3. Condition with specific _where and generic _who: ANY_ADDR.

As a bonus, we save gas by, for example, not calling (2) and (3) if (1)already answered false.

Task: OS-710

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran all tests with success and extended them if necessary.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have updated the DEPLOYMENT_CHECKLIST file in the root folder.
  • I have updated the UPDATE_CHECKLIST file in the root folder.

heueristik and others added 29 commits August 23, 2023 17:51
refactor: simplifications
@heueristik heueristik marked this pull request as ready for review September 19, 2023 13:23
@heueristik heueristik force-pushed the feature/refactored-permission-manager branch from defbd8d to 0ec32c2 Compare September 19, 2023 13:24
@heueristik heueristik changed the title feature: refactored permission manager feature: Stricter permission/condition fallback mechanism for isGranted Sep 19, 2023
@heueristik heueristik force-pushed the feature/refactored-permission-manager branch from 8409e56 to 2e9f55d Compare September 21, 2023 08:31
mathewmeconry
mathewmeconry previously approved these changes Sep 21, 2023
Base automatically changed from feature/OS-669-dao-refactoring to develop September 21, 2023 09:15
@heueristik heueristik dismissed mathewmeconry’s stale review September 21, 2023 09:15

The base branch was changed.

Rekard0
Rekard0 previously approved these changes Sep 21, 2023
Copy link
Contributor

@Rekard0 Rekard0 left a comment

Choose a reason for hiding this comment

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

LGTM

@heueristik heueristik merged commit c359ed0 into develop Sep 21, 2023
12 checks passed
@heueristik heueristik deleted the feature/refactored-permission-manager branch September 21, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants