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

Improve AccessManager tests #4613

Merged
merged 63 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
1c79698
Improve docs
ernestognw Sep 15, 2023
0218e2c
Make role's admin role more specific
ernestognw Sep 15, 2023
7f3c162
First pass through tests
ernestognw Sep 15, 2023
d27cbdc
Add _canCallSelf
ernestognw Sep 15, 2023
327a5b5
Merge branch 'audit/wip/2a-2b' into access-manager/tests
ernestognw Sep 15, 2023
febdf2a
AccessManager _canCallSelf and _canCallExecuting
ernestognw Sep 18, 2023
acfc3aa
AccessManager _canCallSelf and _canCallExecuting
ernestognw Sep 18, 2023
64a1c6e
Codespell
ernestognw Sep 18, 2023
4a8920e
Merge branch 'audit/wip/2a-2b' into access-manager/coverage-review
ernestognw Sep 18, 2023
62ff89b
Testing preview
ernestognw Sep 18, 2023
1152dbb
Merge branch 'master' into access-manager/tests
ernestognw Sep 19, 2023
d4c6480
Checkpoint
ernestognw Sep 19, 2023
6adcbf3
Finish role admin functions
ernestognw Sep 19, 2023
9d601a7
Checkpoint
ernestognw Sep 19, 2023
e2190d6
Checkpoint
ernestognw Sep 20, 2023
4c08a9d
Removed on:
ernestognw Sep 20, 2023
1d118eb
Define common admin ops path
ernestognw Sep 20, 2023
778ac91
Checkpoint
ernestognw Sep 21, 2023
3aeb3c8
Checkpoint
ernestognw Sep 21, 2023
61eea90
Update contracts/access/manager/AccessManager.sol
ernestognw Sep 21, 2023
ba8b3ca
Remove .call(this)
ernestognw Sep 23, 2023
8e3583b
Improve test names
ernestognw Sep 23, 2023
dce308e
Improve test names
ernestognw Sep 23, 2023
d0b3824
Checkpoint
ernestognw Sep 25, 2023
3a216f7
Finish execute
ernestognw Sep 25, 2023
fb0374f
Finish AccessManager tests
ernestognw Sep 25, 2023
856aa0c
Make selector decoding consistent
ernestognw Sep 25, 2023
242b19e
Merge branch 'master' into access-manager/tests
ernestognw Sep 25, 2023
d8dfe3b
Fix codespell
ernestognw Sep 25, 2023
1b66afe
Cherry pick from #4624
ernestognw Sep 26, 2023
3112045
Revert _setGrantDelay PUBLIC_ROLE case
ernestognw Sep 27, 2023
51e499b
Revert canCall hasRole path return
ernestognw Sep 27, 2023
47995ef
Update contracts/access/manager/AccessManager.sol
ernestognw Sep 27, 2023
e9cc80c
Update contracts/access/manager/AccessManager.sol
ernestognw Sep 27, 2023
bd4ab08
Update contracts/access/manager/AccessManager.sol
ernestognw Sep 27, 2023
a870c6b
Update contracts/access/manager/IAccessManager.sol
ernestognw Sep 27, 2023
d4dafda
Update test/access/manager/AccessManager.test.js
ernestognw Sep 27, 2023
04c5a9b
Implement suggestion for writing the _consumingSchedule variable
ernestognw Sep 27, 2023
9c0b8ad
Update test/helpers/access-manager.js
ernestognw Sep 27, 2023
854fbfe
Lint
ernestognw Sep 27, 2023
91cea51
Update contracts/access/manager/AccessManager.sol
ernestognw Sep 27, 2023
efce54a
Update contracts/access/manager/AccessManager.sol
ernestognw Sep 27, 2023
e955172
Update contracts/utils/types/Time.sol
ernestognw Sep 27, 2023
c0e69ee
Lint
ernestognw Sep 27, 2023
ea0973a
Recovered 100% tests coverage
ernestognw Sep 27, 2023
ee5315a
Remove console
ernestognw Sep 27, 2023
172b11f
Fix .only
ernestognw Sep 28, 2023
42e8a1a
execute+schedule tweaks
frangio Sep 29, 2023
180ef6c
fix tests
frangio Sep 30, 2023
9edb313
refactor
frangio Sep 30, 2023
7cb374d
trigger ci
frangio Oct 2, 2023
41b6880
Merge branch 'master' into access-manager/tests
ernestognw Oct 3, 2023
58e9545
Merge branch 'master' into access-manager/tests
frangio Oct 3, 2023
9d493af
fix upgradeable tests
frangio Oct 3, 2023
9291007
replace syntax `foo: function () {` -> `foo() {
frangio Oct 3, 2023
2ab4382
replace syntax (continued)
frangio Oct 3, 2023
eb914a2
lint
frangio Oct 3, 2023
da3d343
Fix consumingScheduleOp
ernestognw Oct 4, 2023
033337b
Fix consumeScheduleOp again
ernestognw Oct 4, 2023
a1011be
Apply review suggestions
ernestognw Oct 4, 2023
74009db
Check also for AccessManagedUpgradeable artifact
ernestognw Oct 4, 2023
1f4e7ca
Lint
ernestognw Oct 4, 2023
6e397cc
Merge branch 'master' into access-manager/tests
ernestognw Oct 4, 2023
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
130 changes: 80 additions & 50 deletions contracts/access/manager/AccessManager.sol

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions contracts/access/manager/IAccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ interface IAccessManager {
event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);

event RoleLabel(uint64 indexed roleId, string label);
/**
* @dev Emitted when `account` is granted `roleId`.
*
* NOTE: The meaning of the `since` argument depends on the `newMember` argument.
* If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role,
* otherwise it indicates the execution delay for this account and roleId is updated.
*/
event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);
event RoleRevoked(uint64 indexed roleId, address indexed account);
event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);
Expand Down
11 changes: 11 additions & 0 deletions contracts/mocks/AccessManagedTarget.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity ^0.8.20;

import {AccessManaged} from "../access/manager/AccessManaged.sol";
import {StorageSlot} from "../utils/StorageSlot.sol";

abstract contract AccessManagedTarget is AccessManaged {
event CalledRestricted(address caller);
Expand All @@ -17,6 +18,16 @@ abstract contract AccessManagedTarget is AccessManaged {
emit CalledUnrestricted(msg.sender);
}

function setIsConsumingScheduledOp(bool isConsuming, bytes32 slot) external {
// Memory layout is 0x....<_consumingSchedule (boolean)><authority (address)>
bytes32 mask = bytes32(uint256(1 << 160));
if (isConsuming) {
StorageSlot.getBytes32Slot(slot).value |= mask;
} else {
StorageSlot.getBytes32Slot(slot).value &= ~mask;
}
}

fallback() external {
emit CalledFallback(msg.sender);
}
Expand Down
16 changes: 10 additions & 6 deletions contracts/utils/types/Time.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,26 @@ library Time {
* enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the
* new delay becomes effective.
*/
function withUpdate(Delay self, uint32 newValue, uint32 minSetback) internal view returns (Delay, uint48) {
function withUpdate(
Delay self,
uint32 newValue,
uint32 minSetback
) internal view returns (Delay updatedDelay, uint48 effect) {
uint32 value = self.get();
uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0));
uint48 effect = timestamp() + setback;
effect = timestamp() + setback;
return (pack(value, newValue, effect), effect);
}

/**
* @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint).
*/
function unpack(Delay self) internal pure returns (uint32, uint32, uint48) {
function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) {
uint112 raw = Delay.unwrap(self);

uint32 valueAfter = uint32(raw);
uint32 valueBefore = uint32(raw >> 32);
uint48 effect = uint48(raw >> 64);
valueAfter = uint32(raw);
valueBefore = uint32(raw >> 32);
effect = uint48(raw >> 64);

return (valueBefore, valueAfter, effect);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/upgradeable/transpile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VERSION="$(jq -r .version contracts/package.json)"
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"

bash "$DIRNAME/patch-apply.sh"
sed -i "s/<package-version>/$VERSION/g" contracts/package.json
sed -i'' -e "s/<package-version>/$VERSION/g" "contracts/package.json"
Amxx marked this conversation as resolved.
Show resolved Hide resolved
git add contracts/package.json

npm run clean
Expand Down
Loading
Loading