GovernorHarness.sol 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.2;
  3. import "../patched/governance/Governor.sol";
  4. import "../patched/governance/extensions/GovernorCountingSimple.sol";
  5. import "../patched/governance/extensions/GovernorTimelockControl.sol";
  6. import "../patched/governance/extensions/GovernorVotes.sol";
  7. import "../patched/governance/extensions/GovernorVotesQuorumFraction.sol";
  8. import "../patched/token/ERC20/extensions/ERC20Votes.sol";
  9. contract GovernorHarness is
  10. Governor,
  11. GovernorCountingSimple,
  12. GovernorTimelockControl,
  13. GovernorVotes,
  14. GovernorVotesQuorumFraction
  15. {
  16. constructor(IVotes _token, TimelockController _timelock, uint256 _quorumNumeratorValue)
  17. Governor("Harness")
  18. GovernorTimelockControl(_timelock)
  19. GovernorVotes(_token)
  20. GovernorVotesQuorumFraction(_quorumNumeratorValue)
  21. {}
  22. // Harness from Votes
  23. function token_getPastTotalSupply(uint256 blockNumber) public view returns(uint256) {
  24. return token.getPastTotalSupply(blockNumber);
  25. }
  26. function token_getPastVotes(address account, uint256 blockNumber) public view returns(uint256) {
  27. return token.getPastVotes(account, blockNumber);
  28. }
  29. function token_clock() public view returns (uint48) {
  30. return token.clock();
  31. }
  32. function token_CLOCK_MODE() public view returns (string memory) {
  33. return token.CLOCK_MODE();
  34. }
  35. // Harness from Governor
  36. function getExecutor() public view returns (address) {
  37. return _executor();
  38. }
  39. function proposalProposer(uint256 proposalId) public view returns (address) {
  40. return _proposalProposer(proposalId);
  41. }
  42. function quorumReached(uint256 proposalId) public view returns (bool) {
  43. return _quorumReached(proposalId);
  44. }
  45. function voteSucceeded(uint256 proposalId) public view returns (bool) {
  46. return _voteSucceeded(proposalId);
  47. }
  48. function isExecuted(uint256 proposalId) public view returns (bool) {
  49. return _isExecuted(proposalId);
  50. }
  51. function isCanceled(uint256 proposalId) public view returns (bool) {
  52. return _isCanceled(proposalId);
  53. }
  54. function isQueued(uint256 proposalId) public view returns (bool) {
  55. return _proposalQueueId(proposalId) != bytes32(0);
  56. }
  57. function governanceCallLength() public view returns (uint256) {
  58. return _governanceCallLength();
  59. }
  60. // Harness from GovernorCountingSimple
  61. function getAgainstVotes(uint256 proposalId) public view returns (uint256) {
  62. (uint256 againstVotes,,) = proposalVotes(proposalId);
  63. return againstVotes;
  64. }
  65. function getForVotes(uint256 proposalId) public view returns (uint256) {
  66. (,uint256 forVotes,) = proposalVotes(proposalId);
  67. return forVotes;
  68. }
  69. function getAbstainVotes(uint256 proposalId) public view returns (uint256) {
  70. (,,uint256 abstainVotes) = proposalVotes(proposalId);
  71. return abstainVotes;
  72. }
  73. /// The following functions are overrides required by Solidity added by Certora.
  74. // mapping(uint256 => uint256) public ghost_sum_vote_power_by_id;
  75. //
  76. // function _castVote(
  77. // uint256 proposalId,
  78. // address account,
  79. // uint8 support,
  80. // string memory reason,
  81. // bytes memory params
  82. // ) internal virtual override returns (uint256) {
  83. // uint256 deltaWeight = super._castVote(proposalId, account, support, reason, params);
  84. // ghost_sum_vote_power_by_id[proposalId] += deltaWeight;
  85. // return deltaWeight;
  86. // }
  87. // The following functions are overrides required by Solidity added by OZ Wizard.
  88. function votingDelay() public pure override returns (uint256) {
  89. return 1; // 1 block
  90. }
  91. function votingPeriod() public pure override returns (uint256) {
  92. return 45818; // 1 week
  93. }
  94. function quorum(uint256 blockNumber)
  95. public
  96. view
  97. override(IGovernor, GovernorVotesQuorumFraction)
  98. returns (uint256)
  99. {
  100. return super.quorum(blockNumber);
  101. }
  102. function state(uint256 proposalId) public view override(Governor, GovernorTimelockControl) returns (ProposalState) {
  103. return super.state(proposalId);
  104. }
  105. function propose(
  106. address[] memory targets,
  107. uint256[] memory values,
  108. bytes[] memory calldatas,
  109. string memory description
  110. ) public override(Governor, IGovernor) returns (uint256) {
  111. return super.propose(targets, values, calldatas, description);
  112. }
  113. function _execute(
  114. uint256 proposalId,
  115. address[] memory targets,
  116. uint256[] memory values,
  117. bytes[] memory calldatas,
  118. bytes32 descriptionHash
  119. ) internal override(Governor, GovernorTimelockControl) {
  120. super._execute(proposalId, targets, values, calldatas, descriptionHash);
  121. }
  122. function _cancel(
  123. address[] memory targets,
  124. uint256[] memory values,
  125. bytes[] memory calldatas,
  126. bytes32 descriptionHash
  127. ) internal override(Governor, GovernorTimelockControl) returns (uint256) {
  128. return super._cancel(targets, values, calldatas, descriptionHash);
  129. }
  130. function _executor() internal view override(Governor, GovernorTimelockControl) returns (address) {
  131. return super._executor();
  132. }
  133. function supportsInterface(bytes4 interfaceId)
  134. public
  135. view
  136. override(Governor, GovernorTimelockControl)
  137. returns (bool)
  138. {
  139. return super.supportsInterface(interfaceId);
  140. }
  141. }