applyHarness.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. diff -ruN .gitignore .gitignore
  2. --- .gitignore 1969-12-31 16:00:00.000000000 -0800
  3. +++ .gitignore 2022-05-27 01:31:23.000000000 -0700
  4. @@ -0,0 +1,2 @@
  5. +*
  6. +!.gitignore
  7. diff -ruN access/AccessControl.sol access/AccessControl.sol
  8. --- access/AccessControl.sol 2022-05-25 09:38:35.000000000 -0700
  9. +++ access/AccessControl.sol 2022-05-27 01:31:23.000000000 -0700
  10. @@ -93,7 +93,7 @@
  11. *
  12. * _Available since v4.6._
  13. */
  14. - function _checkRole(bytes32 role) internal view virtual {
  15. + function _checkRole(bytes32 role) public view virtual { // HARNESS: internal -> public
  16. _checkRole(role, _msgSender());
  17. }
  18. diff -ruN governance/Governor.sol governance/Governor.sol
  19. --- governance/Governor.sol 2022-05-25 09:38:35.000000000 -0700
  20. +++ governance/Governor.sol 2022-05-27 01:31:23.000000000 -0700
  21. @@ -44,7 +44,7 @@
  22. string private _name;
  23. - mapping(uint256 => ProposalCore) private _proposals;
  24. + mapping(uint256 => ProposalCore) internal _proposals;
  25. // This queue keeps track of the governor operating on itself. Calls to functions protected by the
  26. // {onlyGovernance} modifier needs to be whitelisted in this queue. Whitelisting is set in {_beforeExecute},
  27. diff -ruN governance/TimelockController.sol governance/TimelockController.sol
  28. --- governance/TimelockController.sol 2022-05-25 09:38:35.000000000 -0700
  29. +++ governance/TimelockController.sol 2022-05-27 01:31:23.000000000 -0700
  30. @@ -28,10 +28,10 @@
  31. bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
  32. bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
  33. bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
  34. - uint256 internal constant _DONE_TIMESTAMP = uint256(1);
  35. + uint256 public constant _DONE_TIMESTAMP = uint256(1);
  36. mapping(bytes32 => uint256) private _timestamps;
  37. - uint256 private _minDelay;
  38. + uint256 public _minDelay;
  39. /**
  40. * @dev Emitted when a call is scheduled as part of operation `id`.
  41. diff -ruN governance/extensions/GovernorCountingSimple.sol governance/extensions/GovernorCountingSimple.sol
  42. --- governance/extensions/GovernorCountingSimple.sol 2022-05-25 09:38:35.000000000 -0700
  43. +++ governance/extensions/GovernorCountingSimple.sol 2022-05-27 03:15:40.000000000 -0700
  44. @@ -27,7 +27,7 @@
  45. mapping(address => bool) hasVoted;
  46. }
  47. - mapping(uint256 => ProposalVote) private _proposalVotes;
  48. + mapping(uint256 => ProposalVote) internal _proposalVotes;
  49. /**
  50. * @dev See {IGovernor-COUNTING_MODE}.
  51. diff -ruN governance/extensions/GovernorPreventLateQuorum.sol governance/extensions/GovernorPreventLateQuorum.sol
  52. --- governance/extensions/GovernorPreventLateQuorum.sol 2022-05-25 09:38:35.000000000 -0700
  53. +++ governance/extensions/GovernorPreventLateQuorum.sol 2022-05-27 01:31:23.000000000 -0700
  54. @@ -21,8 +21,8 @@
  55. using SafeCast for uint256;
  56. using Timers for Timers.BlockNumber;
  57. - uint64 private _voteExtension;
  58. - mapping(uint256 => Timers.BlockNumber) private _extendedDeadlines;
  59. + uint64 internal _voteExtension;
  60. + mapping(uint256 => Timers.BlockNumber) internal _extendedDeadlines;
  61. /// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
  62. event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
  63. diff -ruN governance/utils/Votes.sol governance/utils/Votes.sol
  64. --- governance/utils/Votes.sol 2022-05-25 09:38:35.000000000 -0700
  65. +++ governance/utils/Votes.sol 2022-05-27 01:31:23.000000000 -0700
  66. @@ -35,7 +35,25 @@
  67. bytes32 private constant _DELEGATION_TYPEHASH =
  68. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  69. - mapping(address => address) private _delegation;
  70. + // HARNESS : Hooks cannot access any information from Checkpoints yet, so I am also updating votes and fromBlock in this struct
  71. + struct Ckpt {
  72. + uint32 fromBlock;
  73. + uint224 votes;
  74. + }
  75. + mapping(address => Ckpt) public _checkpoints;
  76. +
  77. + // HARNESSED getters
  78. + function numCheckpoints(address account) public view returns (uint32) {
  79. + return SafeCast.toUint32(_delegateCheckpoints[account]._checkpoints.length);
  80. + }
  81. + function ckptFromBlock(address account, uint32 pos) public view returns (uint32) {
  82. + return _delegateCheckpoints[account]._checkpoints[pos]._blockNumber;
  83. + }
  84. + function ckptVotes(address account, uint32 pos) public view returns (uint224) {
  85. + return _delegateCheckpoints[account]._checkpoints[pos]._value;
  86. + }
  87. +
  88. + mapping(address => address) public _delegation;
  89. mapping(address => Checkpoints.History) private _delegateCheckpoints;
  90. Checkpoints.History private _totalCheckpoints;
  91. @@ -124,7 +142,7 @@
  92. *
  93. * Emits events {DelegateChanged} and {DelegateVotesChanged}.
  94. */
  95. - function _delegate(address account, address delegatee) internal virtual {
  96. + function _delegate(address account, address delegatee) public virtual {
  97. address oldDelegate = delegates(account);
  98. _delegation[account] = delegatee;
  99. @@ -142,10 +160,10 @@
  100. uint256 amount
  101. ) internal virtual {
  102. if (from == address(0)) {
  103. - _totalCheckpoints.push(_add, amount);
  104. + _totalCheckpoints.push(_totalCheckpoints.latest() + amount); // Harnessed to remove function pointers
  105. }
  106. if (to == address(0)) {
  107. - _totalCheckpoints.push(_subtract, amount);
  108. + _totalCheckpoints.push(_totalCheckpoints.latest() - amount); // Harnessed to remove function pointers
  109. }
  110. _moveDelegateVotes(delegates(from), delegates(to), amount);
  111. }
  112. @@ -160,11 +178,13 @@
  113. ) private {
  114. if (from != to && amount > 0) {
  115. if (from != address(0)) {
  116. - (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_subtract, amount);
  117. + (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[from].push(_delegateCheckpoints[from].latest() - amount); // HARNESSED TO REMOVE FUNCTION POINTERS
  118. + _checkpoints[from] = Ckpt({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newValue)}); // HARNESS
  119. emit DelegateVotesChanged(from, oldValue, newValue);
  120. }
  121. if (to != address(0)) {
  122. - (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_add, amount);
  123. + (uint256 oldValue, uint256 newValue) = _delegateCheckpoints[to].push(_delegateCheckpoints[to].latest() + amount); // HARNESSED TO REMOVE FUNCTION POINTERS
  124. + _checkpoints[to] = Ckpt({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newValue)}); // HARNESS
  125. emit DelegateVotesChanged(to, oldValue, newValue);
  126. }
  127. }
  128. @@ -207,5 +227,5 @@
  129. /**
  130. * @dev Must return the voting units held by an account.
  131. */
  132. - function _getVotingUnits(address) internal view virtual returns (uint256);
  133. + function _getVotingUnits(address) public virtual returns (uint256); // HARNESS: internal -> public
  134. }
  135. diff -ruN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
  136. --- token/ERC1155/ERC1155.sol 2022-05-25 09:38:35.000000000 -0700
  137. +++ token/ERC1155/ERC1155.sol 2022-05-27 01:31:23.000000000 -0700
  138. @@ -268,7 +268,7 @@
  139. uint256 id,
  140. uint256 amount,
  141. bytes memory data
  142. - ) internal virtual {
  143. + ) public virtual { // HARNESS: internal -> public
  144. require(to != address(0), "ERC1155: mint to the zero address");
  145. address operator = _msgSender();
  146. @@ -301,7 +301,7 @@
  147. uint256[] memory ids,
  148. uint256[] memory amounts,
  149. bytes memory data
  150. - ) internal virtual {
  151. + ) public virtual { // HARNESS: internal -> public
  152. require(to != address(0), "ERC1155: mint to the zero address");
  153. require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
  154. @@ -334,7 +334,7 @@
  155. address from,
  156. uint256 id,
  157. uint256 amount
  158. - ) internal virtual {
  159. + ) public virtual { // HARNESS: internal -> public
  160. require(from != address(0), "ERC1155: burn from the zero address");
  161. address operator = _msgSender();
  162. @@ -367,7 +367,7 @@
  163. address from,
  164. uint256[] memory ids,
  165. uint256[] memory amounts
  166. - ) internal virtual {
  167. + ) public virtual { // HARNESS: internal -> public
  168. require(from != address(0), "ERC1155: burn from the zero address");
  169. require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
  170. @@ -471,7 +471,7 @@
  171. uint256 id,
  172. uint256 amount,
  173. bytes memory data
  174. - ) private {
  175. + ) public { // HARNESS: private -> public
  176. if (to.isContract()) {
  177. try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
  178. if (response != IERC1155Receiver.onERC1155Received.selector) {
  179. @@ -492,7 +492,7 @@
  180. uint256[] memory ids,
  181. uint256[] memory amounts,
  182. bytes memory data
  183. - ) private {
  184. + ) public { // HARNESS: private -> public
  185. if (to.isContract()) {
  186. try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
  187. bytes4 response
  188. diff -ruN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
  189. --- token/ERC20/ERC20.sol 2022-05-25 09:38:35.000000000 -0700
  190. +++ token/ERC20/ERC20.sol 2022-05-27 01:31:23.000000000 -0700
  191. @@ -277,7 +277,7 @@
  192. * - `account` cannot be the zero address.
  193. * - `account` must have at least `amount` tokens.
  194. */
  195. - function _burn(address account, uint256 amount) internal virtual {
  196. + function _burn(address account, uint256 amount) public virtual { // HARNESS: internal -> public
  197. require(account != address(0), "ERC20: burn from the zero address");
  198. _beforeTokenTransfer(account, address(0), amount);
  199. diff -ruN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
  200. --- token/ERC20/extensions/ERC20FlashMint.sol 2022-05-25 09:38:35.000000000 -0700
  201. +++ token/ERC20/extensions/ERC20FlashMint.sol 2022-05-27 01:31:23.000000000 -0700
  202. @@ -40,9 +40,11 @@
  203. require(token == address(this), "ERC20FlashMint: wrong token");
  204. // silence warning about unused variable without the addition of bytecode.
  205. amount;
  206. - return 0;
  207. + return fee; // HARNESS: made "return" nonzero
  208. }
  209. + uint256 public fee; // HARNESS: added it to simulate random fee amount
  210. +
  211. /**
  212. * @dev Returns the receiver address of the flash fee. By default this
  213. * implementation returns the address(0) which means the fee amount will be burnt.
  214. diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
  215. --- token/ERC20/extensions/ERC20Votes.sol 2022-05-06 13:43:21.000000000 -0700
  216. +++ token/ERC20/extensions/ERC20Votes.sol 2022-05-27 01:31:23.000000000 -0700
  217. @@ -33,8 +33,8 @@
  218. bytes32 private constant _DELEGATION_TYPEHASH =
  219. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  220. - mapping(address => address) private _delegates;
  221. - mapping(address => Checkpoint[]) private _checkpoints;
  222. + mapping(address => address) public _delegates;
  223. + mapping(address => Checkpoint[]) public _checkpoints;
  224. Checkpoint[] private _totalSupplyCheckpoints;
  225. /**
  226. @@ -169,7 +169,7 @@
  227. /**
  228. * @dev Snapshots the totalSupply after it has been decreased.
  229. */
  230. - function _burn(address account, uint256 amount) internal virtual override {
  231. + function _burn(address account, uint256 amount) public virtual override {
  232. super._burn(account, amount);
  233. _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
  234. diff -ruN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
  235. --- token/ERC20/extensions/ERC20Wrapper.sol 2022-05-25 09:38:35.000000000 -0700
  236. +++ token/ERC20/extensions/ERC20Wrapper.sol 2022-05-27 01:31:23.000000000 -0700
  237. @@ -55,7 +55,7 @@
  238. * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
  239. * function that can be exposed with access control if desired.
  240. */
  241. - function _recover(address account) internal virtual returns (uint256) {
  242. + function _recover(address account) public virtual returns (uint256) { // HARNESS: internal -> public
  243. uint256 value = underlying.balanceOf(address(this)) - totalSupply();
  244. _mint(account, value);
  245. return value;
  246. diff -ruN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/draft-ERC721Votes.sol
  247. --- token/ERC721/extensions/draft-ERC721Votes.sol 2022-05-25 09:38:35.000000000 -0700
  248. +++ token/ERC721/extensions/draft-ERC721Votes.sol 2022-05-27 01:31:23.000000000 -0700
  249. @@ -34,7 +34,7 @@
  250. /**
  251. * @dev Returns the balance of `account`.
  252. */
  253. - function _getVotingUnits(address account) internal view virtual override returns (uint256) {
  254. + function _getVotingUnits(address account) public view virtual override returns (uint256) {
  255. return balanceOf(account);
  256. }
  257. }
  258. diff -ruN utils/Address.sol utils/Address.sol
  259. --- utils/Address.sol 2022-05-25 09:38:35.000000000 -0700
  260. +++ utils/Address.sol 2022-05-27 01:31:23.000000000 -0700
  261. @@ -131,6 +131,7 @@
  262. uint256 value,
  263. string memory errorMessage
  264. ) internal returns (bytes memory) {
  265. + return ""; // external calls havoc
  266. require(address(this).balance >= value, "Address: insufficient balance for call");
  267. require(isContract(target), "Address: call to non-contract");