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 whitelists and guardians roles #29

Merged
merged 9 commits into from
Oct 22, 2024

Conversation

garyghayrat
Copy link
Member

closes #10. The rest of the logic will be addressed in #28.

@coveralls
Copy link

coveralls commented Oct 14, 2024

Pull Request Test Coverage Report for Build 11447656675

Details

  • 0 of 15 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-2.6%) to 87.329%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contracts/CompoundGovernor.sol 0 15 0.0%
Totals Coverage Status
Change from base Build 11442502364: -2.6%
Covered Lines: 318
Relevant Lines: 370

💛 - Coveralls

/// @param _newWhitelistGuardian The address of the new whitelistGuardian.
/// @dev Only the executor (timelock) can call this function.
function setWhitelistGuardian(address _newWhitelistGuardian) public {
if (msg.sender != _executor()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should I use the stricter _checkGovernance instead which checks if a proposal has actually passed beyond checking the msg.sender?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@garyghayrat good call, that seems idiomatic. let me know if you want clarification on the implications.

Copy link
Member Author

Choose a reason for hiding this comment

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

@garyghayrat garyghayrat changed the title Add whitelists and guardians Add whitelists and guardians roles Oct 14, 2024
Copy link
Collaborator

@jferas jferas left a comment

Choose a reason for hiding this comment

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

Looks good.. 2 very small nits

event WhitelistGuardianSet(address oldGuardian, address newGuardian);

/// @notice Emitted when the proposalGuardian is set
/// @notice Emitted when the proposal guardian is set or updated.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: duplicate line to above?

Copy link
Member Author

Choose a reason for hiding this comment

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

removed in 42b14e9


/// @notice Account which has the ability to cancel proposals. This privilege expires at the given expiration
/// timestamp.
ProposalGuardian public proposalGuardian;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: not that the compiler cares, but easier reading if a struct is defined before it is referenced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved it up in 42b14e9

Copy link
Collaborator

@wildmolasses wildmolasses left a comment

Choose a reason for hiding this comment

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

great start @garyghayrat -- i was imagining that the propose/cancel functionality would be changed here to work with the whitelist. were you thinking of adding it separately? I see you mention #28, but that issue looks like it's specifically for threshold-motivated cancellation

contracts/CompoundGovernor.sol Show resolved Hide resolved
contracts/CompoundGovernor.sol Outdated Show resolved Hide resolved
contracts/CompoundGovernor.sol Outdated Show resolved Hide resolved
contracts/CompoundGovernor.sol Outdated Show resolved Hide resolved
/// @param _newWhitelistGuardian The address of the new whitelistGuardian.
/// @dev Only the executor (timelock) can call this function.
function setWhitelistGuardian(address _newWhitelistGuardian) public {
if (msg.sender != _executor()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@garyghayrat good call, that seems idiomatic. let me know if you want clarification on the implications.

contracts/CompoundGovernor.sol Show resolved Hide resolved
contracts/CompoundGovernor.sol Outdated Show resolved Hide resolved
contracts/CompoundGovernor.sol Show resolved Hide resolved
contracts/CompoundGovernor.sol Show resolved Hide resolved
contracts/CompoundGovernor.sol Outdated Show resolved Hide resolved
@garyghayrat garyghayrat force-pushed the feat/add-whitelists-and-guardians branch from dad40b8 to 77964d3 Compare October 21, 2024 17:17
contracts/CompoundGovernor.sol Outdated Show resolved Hide resolved
contracts/CompoundGovernor.sol Show resolved Hide resolved
contracts/CompoundGovernor.sol Show resolved Hide resolved
contracts/test/CompoundGovernorSetProposalGuardian.t.sol Outdated Show resolved Hide resolved
contract CompoundGovernorSetWhitelistAccountExpirationTest is ProposalTest {
function testFuzz_WhitelistAnAccountAsTimelock(address _account, uint256 _expiration) public {
vm.prank(TIMELOCK_ADDRESS);
governor.setWhitelistAccountExpiration(_account, _expiration);
Copy link
Collaborator

Choose a reason for hiding this comment

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

just making sure i understand, we're not passing a proposal here because we don't use _checkGovernance here, correct?

Copy link
Member Author

@garyghayrat garyghayrat Oct 21, 2024

Choose a reason for hiding this comment

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

you raise a good point actually. The current check we have is

       if (msg.sender != _executor() && msg.sender != whitelistGuardian) {
            revert Unauthorized("Not timelock or guardian", msg.sender);
        }

I can change it to be like

    if (msg.sender != whitelistGuardian) {
         _checkGovernance();
    }

But then we will only get the error GovernorOnlyExecutor, instead one that indicates that the msg.sender can also be a whitelistGuardian. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm fine leaving this as is

contracts/test/CompoundGovernorSetWhitelistGuardian.t.sol Outdated Show resolved Hide resolved
contracts/test/helpers/ProposalTest.sol Outdated Show resolved Hide resolved
script/CompoundGovernorConstants.sol Outdated Show resolved Hide resolved
@wildmolasses wildmolasses merged commit 099a4a3 into main Oct 22, 2024
3 checks passed
wildmolasses pushed a commit that referenced this pull request Nov 1, 2024
* Add whitelist accounts and whitelist guardian

* Add `proposalGuardian`

* Update natspec, function visibility, and test

* Assume caller is not proxy admin in tests

* Use `_checkGovernance`

* Use `@notice` in natspec

* Rename test and assume any caller

* Assume _caller is not PROXY_ADMIN_ADDRESS

* Move `PROPOSAL_GUARDIAN_EXPIRY` into test helper
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.

Feat: Create guardian / whitelist permissions and functionality
4 participants