Skip to content

Commit

Permalink
feat: proposal guardian
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Jul 30, 2024
1 parent 5e581ef commit c13296d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
10 changes: 4 additions & 6 deletions contracts/GovernorBravoDelegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,12 @@ contract GovernorBravoDelegate is

// Proposer can cancel
if (msg.sender != proposal.proposer) {
// Whitelisted proposers can't be canceled for falling below proposal threshold
if (isWhitelisted(proposal.proposer)) {
if (msg.sender != whitelistGuardian) {
// Whitelisted proposers can't be canceled for falling below proposal threshold
require(
(comp.getPriorVotes(proposal.proposer, block.number - 1) <
proposalThreshold) && msg.sender == whitelistGuardian,
!isWhitelisted(proposal.proposer),
"GovernorBravo::cancel: whitelisted proposer"
);
} else {
require(
(comp.getPriorVotes(proposal.proposer, block.number - 1) <
proposalThreshold),
Expand Down Expand Up @@ -653,7 +651,7 @@ contract GovernorBravoDelegate is

/**
* @notice View function which returns if an account is whitelisted
* @param account Account to check white list status of
* @param account Account to check whitelist status of
* @return If the account is whitelisted
*/
function isWhitelisted(address account) public view returns (bool) {
Expand Down
2 changes: 1 addition & 1 deletion test/ForkTestSimulateUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("ForkTestSimulateUpgrade", function () {
"0xc0Da02939E1441F497fd74F78cE7Decb17B66529"
);
const proposingSigner = await ethers.getSigner(
"0x2775b1c75658Be0F640272CCb8c72ac986009e38"
"0xF977814e90dA44bFA03b6295A0616a897441aceC"
);
await hardhat.network.provider.send("hardhat_setBalance", [
proposingSigner.address,
Expand Down
30 changes: 8 additions & 22 deletions test/GovernorBravo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,14 @@ describe("Governor Bravo", function () {
).to.be.revertedWith("GovernorBravo::cancel: proposer above threshold");
});

it.only("Happy path: guardian can cancel", async function () {
const { governorBravo, otherAccount } = await loadFixture(deployFixtures);
const proposalId = await proposeAndPass(governorBravo);

await governorBravo._setWhitelistGuardian(otherAccount);
await governorBravo.connect(otherAccount).cancel(proposalId);
});

it("Error: cancel executed proposal", async function () {
const { governorBravo, owner } = await loadFixture(deployFixtures);
const tx = { to: await governorBravo.timelock(), value: 1000 };
Expand Down Expand Up @@ -740,28 +748,6 @@ describe("Governor Bravo", function () {
"GovernorBravo::cancel: whitelisted proposer"
);
});

it("Error: whitelisted proposer above threshold", async function () {
const { governorBravo, owner, otherAccount, comp } = await loadFixture(
deployFixtures
);

await governorBravo._setWhitelistAccountExpiration(
otherAccount,
(await time.latest()) + 1000
);
const proposalId = await propose(governorBravo.connect(otherAccount));
await comp.transfer(
otherAccount,
BigInt("100000") * BigInt("10") ** BigInt("18")
);
await comp.connect(otherAccount).delegate(otherAccount);

await governorBravo._setWhitelistGuardian(owner);
await expect(governorBravo.cancel(proposalId)).to.be.revertedWith(
"GovernorBravo::cancel: whitelisted proposer"
);
});
});
});

Expand Down

0 comments on commit c13296d

Please sign in to comment.