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

feat: support whitelisted proposers #116

Draft
wants to merge 61 commits into
base: develop
Choose a base branch
from
Draft

Conversation

coreyar
Copy link
Collaborator

@coreyar coreyar commented Jan 23, 2025

Description

This PR is to support whitelisted proposers that can be set and removed with a timelock. The idea is to allow programmatically creating proposals.

@coreyar coreyar force-pushed the white-list-proposers branch 5 times, most recently from 87a1dda to 753a5a5 Compare January 28, 2025 17:41
@coreyar coreyar force-pushed the white-list-proposers branch 4 times, most recently from 9754981 to d674786 Compare February 17, 2025 22:51

uint latestProposalId = latestProposalIds[msg.sender];
if (
whitelistedProposers[msg.sender] != address(0) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check this condition again, as we are already ensuring it in previous condition?

_;
}

modifier onlyGuardianOrAdmin() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove it as we are using ACM for authorisation?

* @param proposer The address of the proposer to whitelist
*/
function whitelistProposer(address proposer, ProposalType proposalType) external {
_checkAccessAllowed("whitelistProposer(address,ProposalType)");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_checkAccessAllowed("whitelistProposer(address,ProposalType)");
_checkAccessAllowed("whitelistProposer(address,ProposalType)");
ensureNonzeroAddress(proposer)

@@ -280,35 +364,61 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
emit ProposalQueued(proposalId, eta);
}

/**
* @notice Whitelists a proposer
* @param proposer The address of the proposer to whitelist
Copy link
Contributor

Choose a reason for hiding this comment

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

natspec is missing for event and access

require(c >= a, "addition overflow");
return c;
}

function sub256(uint256 a, uint256 b) internal pure returns (uint) {
function sub256(uint256 a, uint256 b) internal pure returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We don;t these functionalities to check overflows in 0.8.25 version of solidity.

@coreyar coreyar force-pushed the white-list-proposers branch from d674786 to d8b8274 Compare February 25, 2025 19:47
@@ -70,30 +73,30 @@ import "./GovernorBravoInterfaces.sol";
* The delegation of votes happens through the `XVSVault` contract by calling the `delegate` or `delegateBySig` functions. These same functions can revert
* vote delegation by calling the same function with a value of `0`.
*/
contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents {
contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoEvents, AccessControlledV8 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest inheriting from GovernorBravoDelegateStorageV2 and creating an additional storage contract. This will allow us to add new storage elements as needed, particularly for syncing votes. Additionally, we should consider moving the custom errors into GovernorBravoEvents or creating a separate file for them to help clean up the code.

@@ -102,67 +105,145 @@ contract GovernorBravoDelegate is GovernorBravoDelegateStorageV2, GovernorBravoE
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,uint8 support)");

/// @notice Mapping to store whitelisted proposers and the timelock they are authorized to use
mapping(address => address) public whitelistedProposers;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is one proposer is authorized for multiple timelocks? Correct me if I am wrong.

Suggested change
mapping(address => address) public whitelistedProposers;
mapping(address => address[]) public whitelistedProposers;

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.

2 participants