@@ -3,11 +3,7 @@ pragma solidity ^0.8.0;
33
44import "@forge-std/console.sol " ;
55
6- import {
7- IGovernorBravo,
8- ITimelockBravo,
9- IERC20VotesComp
10- } from "@interface/IGovernorBravo.sol " ;
6+ import {IERC20VotesComp , IGovernorBravo, ITimelockBravo} from "@interface/IGovernorBravo.sol " ;
117
128import {Address} from "@utils/Address.sol " ;
139
@@ -26,18 +22,8 @@ abstract contract GovernorBravoProposal is Proposal {
2622 }
2723
2824 /// @notice Getter function for `GovernorBravoDelegate.propose()` calldata
29- function getCalldata ()
30- public
31- view
32- virtual
33- override
34- returns (bytes memory data )
35- {
36- (
37- address [] memory targets ,
38- uint256 [] memory values ,
39- bytes [] memory calldatas
40- ) = getProposalActions ();
25+ function getCalldata () public view virtual override returns (bytes memory data ) {
26+ (address [] memory targets , uint256 [] memory values , bytes [] memory calldatas ) = getProposalActions ();
4127 string [] memory signatures = new string [](targets.length );
4228
4329 data = abi.encodeWithSignature (
@@ -52,21 +38,12 @@ abstract contract GovernorBravoProposal is Proposal {
5238
5339 /// @notice Check if there are any on-chain proposals that match the
5440 /// proposal calldata
55- function getProposalId ()
56- public
57- view
58- override
59- returns (uint256 proposalId )
60- {
41+ function getProposalId () public view override returns (uint256 proposalId ) {
6142 uint256 proposalCount = governor.proposalCount ();
6243
6344 while (proposalCount > 0 ) {
64- (
65- address [] memory targets ,
66- uint256 [] memory values ,
67- string [] memory signatures ,
68- bytes [] memory calldatas
69- ) = governor.getActions (proposalCount);
45+ (address [] memory targets , uint256 [] memory values , string [] memory signatures , bytes [] memory calldatas ) =
46+ governor.getActions (proposalCount);
7047
7148 bytes memory onchainCalldata = abi.encodeWithSignature (
7249 "propose(address[],uint256[],string[],bytes[],string) " ,
@@ -81,10 +58,7 @@ abstract contract GovernorBravoProposal is Proposal {
8158
8259 if (keccak256 (proposalCalldata) == keccak256 (onchainCalldata)) {
8360 if (DEBUG) {
84- console.log (
85- "Proposal calldata matches on-chain calldata with proposalId: " ,
86- proposalCount
87- );
61+ console.log ("Proposal calldata matches on-chain calldata with proposalId: " , proposalCount);
8862 }
8963 return proposalCount;
9064 }
@@ -98,13 +72,19 @@ abstract contract GovernorBravoProposal is Proposal {
9872 function simulate () public override {
9973 address proposerAddress = address (1 );
10074 IERC20VotesComp governanceToken = governor.comp ();
75+ ITimelockBravo timelock = ITimelockBravo (governor.timelock ());
76+
77+ // Compound has migrated the Governor to 0x309a862bbC1A00e45506cB8A802D1ff10004c8C0,
78+ // so the timelock admin doesn't correspond to the governor address on mainnet anymore
79+ // This is a workaround since this proposal is not compatible with the new Compound governor
80+ // In Compound's timelock, admin is stored at slot 0
81+ vm.store (address (timelock), bytes32 (uint256 (0 )), bytes32 (uint256 (uint160 (address (governor)))));
82+
10183 {
10284 // Ensure proposer has meets minimum proposal threshold and quorum votes to pass the proposal
10385 uint256 quorumVotes = governor.quorumVotes ();
10486 uint256 proposalThreshold = governor.proposalThreshold ();
105- uint256 votingPower = quorumVotes > proposalThreshold
106- ? quorumVotes
107- : proposalThreshold;
87+ uint256 votingPower = quorumVotes > proposalThreshold ? quorumVotes : proposalThreshold;
10888 deal (address (governanceToken), proposerAddress, votingPower);
10989 // Delegate proposer's votes to itself
11090 vm.prank (proposerAddress);
@@ -120,40 +100,31 @@ abstract contract GovernorBravoProposal is Proposal {
120100 uint256 proposalId = abi.decode (data, (uint256 ));
121101
122102 // Check proposal is in Pending state
123- require (
124- governor.state (proposalId) == IGovernorBravo.ProposalState.Pending
125- );
103+ require (governor.state (proposalId) == IGovernorBravo.ProposalState.Pending);
126104
127105 // Roll to Active state (voting period)
128106 vm.roll (block .number + governor.votingDelay () + 1 );
129- require (
130- governor.state (proposalId) == IGovernorBravo.ProposalState.Active
131- );
107+ require (governor.state (proposalId) == IGovernorBravo.ProposalState.Active);
132108
133109 // Vote YES
134110 vm.prank (proposerAddress);
135111 governor.castVote (proposalId, 1 );
136112
137113 // Roll to allow proposal state transitions
138114 vm.roll (block .number + governor.votingPeriod ());
139- require (
140- governor.state (proposalId) == IGovernorBravo.ProposalState.Succeeded
141- );
115+ require (governor.state (proposalId) == IGovernorBravo.ProposalState.Succeeded);
142116
143117 // Queue the proposal
144118 governor.queue (proposalId);
145- require (
146- governor.state (proposalId) == IGovernorBravo.ProposalState.Queued
147- );
119+ require (governor.state (proposalId) == IGovernorBravo.ProposalState.Queued);
148120
149121 // Warp to allow proposal execution on timelock
150122 ITimelockBravo timelock = ITimelockBravo (governor.timelock ());
123+
151124 vm.warp (block .timestamp + timelock.delay ());
152125
153126 // Execute the proposal
154127 governor.execute (proposalId);
155- require (
156- governor.state (proposalId) == IGovernorBravo.ProposalState.Executed
157- );
128+ require (governor.state (proposalId) == IGovernorBravo.ProposalState.Executed);
158129 }
159130}
0 commit comments