applyHarness.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. diff -ruN .gitignore .gitignore
  2. --- .gitignore 1969-12-31 16:00:00.000000000 -0800
  3. +++ .gitignore 2022-06-01 15:28:29.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-06-01 15:28:29.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-06-01 15:28:29.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-06-01 15:28:29.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-06-01 15:28:29.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-06-01 15:28:29.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-06-01 15:28:29.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 proxy/utils/Initializable.sol proxy/utils/Initializable.sol
  136. --- proxy/utils/Initializable.sol 2022-05-25 14:01:12.000000000 -0700
  137. +++ proxy/utils/Initializable.sol 2022-06-01 17:10:12.000000000 -0700
  138. @@ -59,12 +59,12 @@
  139. * @dev Indicates that the contract has been initialized.
  140. * @custom:oz-retyped-from bool
  141. */
  142. - uint8 private _initialized;
  143. + uint8 internal _initialized;
  144. /**
  145. * @dev Indicates that the contract is in the process of being initialized.
  146. */
  147. - bool private _initializing;
  148. + bool internal _initializing;
  149. /**
  150. * @dev Triggered when the contract has been initialized or reinitialized.
  151. @@ -130,7 +130,7 @@
  152. _setInitializedVersion(type(uint8).max);
  153. }
  154. - function _setInitializedVersion(uint8 version) private returns (bool) {
  155. + function _setInitializedVersion(uint8 version) internal returns (bool) {
  156. // If the contract is initializing we ignore whether _initialized is set in order to support multiple
  157. // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
  158. // of initializers, because in other contexts the contract may have been reentered.
  159. diff -ruN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
  160. --- token/ERC1155/ERC1155.sol 2022-05-25 09:38:35.000000000 -0700
  161. +++ token/ERC1155/ERC1155.sol 2022-06-01 15:28:29.000000000 -0700
  162. @@ -268,7 +268,7 @@
  163. uint256 id,
  164. uint256 amount,
  165. bytes memory data
  166. - ) internal virtual {
  167. + ) public virtual { // HARNESS: internal -> public
  168. require(to != address(0), "ERC1155: mint to the zero address");
  169. address operator = _msgSender();
  170. @@ -301,7 +301,7 @@
  171. uint256[] memory ids,
  172. uint256[] memory amounts,
  173. bytes memory data
  174. - ) internal virtual {
  175. + ) public virtual { // HARNESS: internal -> public
  176. require(to != address(0), "ERC1155: mint to the zero address");
  177. require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
  178. @@ -334,7 +334,7 @@
  179. address from,
  180. uint256 id,
  181. uint256 amount
  182. - ) internal virtual {
  183. + ) public virtual { // HARNESS: internal -> public
  184. require(from != address(0), "ERC1155: burn from the zero address");
  185. address operator = _msgSender();
  186. @@ -367,7 +367,7 @@
  187. address from,
  188. uint256[] memory ids,
  189. uint256[] memory amounts
  190. - ) internal virtual {
  191. + ) public virtual { // HARNESS: internal -> public
  192. require(from != address(0), "ERC1155: burn from the zero address");
  193. require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
  194. @@ -471,7 +471,7 @@
  195. uint256 id,
  196. uint256 amount,
  197. bytes memory data
  198. - ) private {
  199. + ) public { // HARNESS: private -> public
  200. if (to.isContract()) {
  201. try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
  202. if (response != IERC1155Receiver.onERC1155Received.selector) {
  203. @@ -492,7 +492,7 @@
  204. uint256[] memory ids,
  205. uint256[] memory amounts,
  206. bytes memory data
  207. - ) private {
  208. + ) public { // HARNESS: private -> public
  209. if (to.isContract()) {
  210. try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
  211. bytes4 response
  212. diff -ruN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
  213. --- token/ERC20/ERC20.sol 2022-05-25 09:38:35.000000000 -0700
  214. +++ token/ERC20/ERC20.sol 2022-06-01 15:28:29.000000000 -0700
  215. @@ -277,7 +277,7 @@
  216. * - `account` cannot be the zero address.
  217. * - `account` must have at least `amount` tokens.
  218. */
  219. - function _burn(address account, uint256 amount) internal virtual {
  220. + function _burn(address account, uint256 amount) public virtual { // HARNESS: internal -> public
  221. require(account != address(0), "ERC20: burn from the zero address");
  222. _beforeTokenTransfer(account, address(0), amount);
  223. diff -ruN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
  224. --- token/ERC20/extensions/ERC20FlashMint.sol 2022-05-25 09:38:35.000000000 -0700
  225. +++ token/ERC20/extensions/ERC20FlashMint.sol 2022-06-01 15:28:29.000000000 -0700
  226. @@ -40,9 +40,11 @@
  227. require(token == address(this), "ERC20FlashMint: wrong token");
  228. // silence warning about unused variable without the addition of bytecode.
  229. amount;
  230. - return 0;
  231. + return fee; // HARNESS: made "return" nonzero
  232. }
  233. + uint256 public fee; // HARNESS: added it to simulate random fee amount
  234. +
  235. /**
  236. * @dev Returns the receiver address of the flash fee. By default this
  237. * implementation returns the address(0) which means the fee amount will be burnt.
  238. diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
  239. --- token/ERC20/extensions/ERC20Votes.sol 2022-05-06 13:43:21.000000000 -0700
  240. +++ token/ERC20/extensions/ERC20Votes.sol 2022-06-01 15:28:29.000000000 -0700
  241. @@ -33,8 +33,8 @@
  242. bytes32 private constant _DELEGATION_TYPEHASH =
  243. keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
  244. - mapping(address => address) private _delegates;
  245. - mapping(address => Checkpoint[]) private _checkpoints;
  246. + mapping(address => address) public _delegates;
  247. + mapping(address => Checkpoint[]) public _checkpoints;
  248. Checkpoint[] private _totalSupplyCheckpoints;
  249. /**
  250. @@ -169,7 +169,7 @@
  251. /**
  252. * @dev Snapshots the totalSupply after it has been decreased.
  253. */
  254. - function _burn(address account, uint256 amount) internal virtual override {
  255. + function _burn(address account, uint256 amount) public virtual override {
  256. super._burn(account, amount);
  257. _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
  258. diff -ruN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
  259. --- token/ERC20/extensions/ERC20Wrapper.sol 2022-05-25 09:38:35.000000000 -0700
  260. +++ token/ERC20/extensions/ERC20Wrapper.sol 2022-06-01 15:28:29.000000000 -0700
  261. @@ -55,7 +55,7 @@
  262. * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
  263. * function that can be exposed with access control if desired.
  264. */
  265. - function _recover(address account) internal virtual returns (uint256) {
  266. + function _recover(address account) public virtual returns (uint256) { // HARNESS: internal -> public
  267. uint256 value = underlying.balanceOf(address(this)) - totalSupply();
  268. _mint(account, value);
  269. return value;
  270. diff -ruN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/draft-ERC721Votes.sol
  271. --- token/ERC721/extensions/draft-ERC721Votes.sol 2022-05-25 09:38:35.000000000 -0700
  272. +++ token/ERC721/extensions/draft-ERC721Votes.sol 2022-06-01 15:28:29.000000000 -0700
  273. @@ -34,7 +34,7 @@
  274. /**
  275. * @dev Returns the balance of `account`.
  276. */
  277. - function _getVotingUnits(address account) internal view virtual override returns (uint256) {
  278. + function _getVotingUnits(address account) public view virtual override returns (uint256) {
  279. return balanceOf(account);
  280. }
  281. }
  282. diff -ruN utils/Address.sol utils/Address.sol
  283. --- utils/Address.sol 2022-05-25 09:38:35.000000000 -0700
  284. +++ utils/Address.sol 2022-06-01 15:28:29.000000000 -0700
  285. @@ -131,6 +131,7 @@
  286. uint256 value,
  287. string memory errorMessage
  288. ) internal returns (bytes memory) {
  289. + return ""; // external calls havoc
  290. require(address(this).balance >= value, "Address: insufficient balance for call");
  291. require(isContract(target), "Address: call to non-contract");