Clean and fix formal verification (#3798)
Co-authored-by: Michael George <michael@certora.com> Co-authored-by: Nick Armstrong <nick@certora.com> Co-authored-by: Michael George <mdgeorge@cs.cornell.edu> Co-authored-by: Aleksander Kryukov <firealexkryukov@gmail.com> Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
diff -ruN access/AccessControl.sol access/AccessControl.sol
|
||||
--- access/AccessControl.sol 2022-09-27 10:26:58.548890299 +0200
|
||||
+++ access/AccessControl.sol 2022-09-27 17:51:32.011301116 +0200
|
||||
diff -druN access/AccessControl.sol access/AccessControl.sol
|
||||
--- access/AccessControl.sol 2022-10-31 11:08:30.540461238 +0100
|
||||
+++ access/AccessControl.sol 2022-11-04 16:35:52.557358427 +0100
|
||||
@@ -93,7 +93,7 @@
|
||||
*
|
||||
* _Available since v4.6._
|
||||
@ -9,68 +9,82 @@ diff -ruN access/AccessControl.sol access/AccessControl.sol
|
||||
+ function _checkRole(bytes32 role) public view virtual { // HARNESS: internal -> public
|
||||
_checkRole(role, _msgSender());
|
||||
}
|
||||
|
||||
diff -ruN governance/extensions/GovernorCountingSimple.sol governance/extensions/GovernorCountingSimple.sol
|
||||
--- governance/extensions/GovernorCountingSimple.sol 2022-09-27 10:26:58.548890299 +0200
|
||||
+++ governance/extensions/GovernorCountingSimple.sol 2022-09-27 17:51:32.011301116 +0200
|
||||
|
||||
diff -druN governance/extensions/GovernorCountingSimple.sol governance/extensions/GovernorCountingSimple.sol
|
||||
--- governance/extensions/GovernorCountingSimple.sol 2022-10-31 11:08:30.540461238 +0100
|
||||
+++ governance/extensions/GovernorCountingSimple.sol 2022-11-04 16:35:52.557358427 +0100
|
||||
@@ -27,7 +27,7 @@
|
||||
mapping(address => bool) hasVoted;
|
||||
}
|
||||
|
||||
|
||||
- mapping(uint256 => ProposalVote) private _proposalVotes;
|
||||
+ mapping(uint256 => ProposalVote) internal _proposalVotes; // HARNESS: private -> internal
|
||||
|
||||
|
||||
/**
|
||||
* @dev See {IGovernor-COUNTING_MODE}.
|
||||
diff -ruN governance/extensions/GovernorPreventLateQuorum.sol governance/extensions/GovernorPreventLateQuorum.sol
|
||||
diff -druN governance/extensions/GovernorPreventLateQuorum.sol governance/extensions/GovernorPreventLateQuorum.sol
|
||||
--- governance/extensions/GovernorPreventLateQuorum.sol 2022-08-31 13:44:36.377724869 +0200
|
||||
+++ governance/extensions/GovernorPreventLateQuorum.sol 2022-09-27 17:51:32.011301116 +0200
|
||||
+++ governance/extensions/GovernorPreventLateQuorum.sol 2022-11-04 16:35:52.557358427 +0100
|
||||
@@ -21,8 +21,8 @@
|
||||
using SafeCast for uint256;
|
||||
using Timers for Timers.BlockNumber;
|
||||
|
||||
|
||||
- uint64 private _voteExtension;
|
||||
- mapping(uint256 => Timers.BlockNumber) private _extendedDeadlines;
|
||||
+ uint64 internal _voteExtension; // HARNESS: private -> internal
|
||||
+ mapping(uint256 => Timers.BlockNumber) internal _extendedDeadlines; // HARNESS: private -> internal
|
||||
|
||||
|
||||
/// @dev Emitted when a proposal deadline is pushed back due to reaching quorum late in its voting period.
|
||||
event ProposalExtended(uint256 indexed proposalId, uint64 extendedDeadline);
|
||||
diff -ruN governance/Governor.sol governance/Governor.sol
|
||||
--- governance/Governor.sol 2022-09-29 10:07:27.126075551 +0200
|
||||
+++ governance/Governor.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN governance/extensions/GovernorVotesQuorumFraction.sol governance/extensions/GovernorVotesQuorumFraction.sol
|
||||
--- governance/extensions/GovernorVotesQuorumFraction.sol 2022-10-31 11:08:30.540461238 +0100
|
||||
+++ governance/extensions/GovernorVotesQuorumFraction.sol 2022-11-04 16:35:52.557358427 +0100
|
||||
@@ -16,8 +16,8 @@
|
||||
abstract contract GovernorVotesQuorumFraction is GovernorVotes {
|
||||
using Checkpoints for Checkpoints.History;
|
||||
|
||||
- uint256 private _quorumNumerator; // DEPRECATED
|
||||
- Checkpoints.History private _quorumNumeratorHistory;
|
||||
+ uint256 internal _quorumNumerator; // DEPRECATED // MUNGED private => internal
|
||||
+ Checkpoints.History internal _quorumNumeratorHistory; // MUNGED private => internal
|
||||
|
||||
event QuorumNumeratorUpdated(uint256 oldQuorumNumerator, uint256 newQuorumNumerator);
|
||||
|
||||
diff -druN governance/Governor.sol governance/Governor.sol
|
||||
--- governance/Governor.sol 2022-11-04 16:13:34.398935222 +0100
|
||||
+++ governance/Governor.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
string private _name;
|
||||
|
||||
|
||||
- mapping(uint256 => ProposalCore) private _proposals;
|
||||
+ mapping(uint256 => ProposalCore) internal _proposals; // HARNESS: private -> internal
|
||||
|
||||
|
||||
// This queue keeps track of the governor operating on itself. Calls to functions protected by the
|
||||
// {onlyGovernance} modifier needs to be whitelisted in this queue. Whitelisting is set in {_beforeExecute},
|
||||
diff -ruN governance/TimelockController.sol governance/TimelockController.sol
|
||||
--- governance/TimelockController.sol 2022-09-29 10:07:27.126075551 +0200
|
||||
+++ governance/TimelockController.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN governance/TimelockController.sol governance/TimelockController.sol
|
||||
--- governance/TimelockController.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ governance/TimelockController.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -28,10 +28,10 @@
|
||||
bytes32 public constant PROPOSER_ROLE = keccak256("PROPOSER_ROLE");
|
||||
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
|
||||
bytes32 public constant CANCELLER_ROLE = keccak256("CANCELLER_ROLE");
|
||||
- uint256 internal constant _DONE_TIMESTAMP = uint256(1);
|
||||
+ uint256 public constant _DONE_TIMESTAMP = uint256(1); // HARNESS: internal -> public
|
||||
|
||||
|
||||
mapping(bytes32 => uint256) private _timestamps;
|
||||
- uint256 private _minDelay;
|
||||
+ uint256 public _minDelay; // HARNESS: private -> public
|
||||
|
||||
|
||||
/**
|
||||
* @dev Emitted when a call is scheduled as part of operation `id`.
|
||||
diff -ruN governance/utils/Votes.sol governance/utils/Votes.sol
|
||||
--- governance/utils/Votes.sol 2022-09-27 10:26:58.548890299 +0200
|
||||
+++ governance/utils/Votes.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN governance/utils/Votes.sol governance/utils/Votes.sol
|
||||
--- governance/utils/Votes.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ governance/utils/Votes.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -35,7 +35,25 @@
|
||||
bytes32 private constant _DELEGATION_TYPEHASH =
|
||||
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
|
||||
|
||||
|
||||
- mapping(address => address) private _delegation;
|
||||
+ // HARNESS : Hooks cannot access any information from Checkpoints yet, so I am also updating votes and fromBlock in this struct
|
||||
+ struct Ckpt {
|
||||
@ -93,7 +107,7 @@ diff -ruN governance/utils/Votes.sol governance/utils/Votes.sol
|
||||
+ mapping(address => address) public _delegation; // HARNESS: private -> public
|
||||
mapping(address => Checkpoints.History) private _delegateCheckpoints;
|
||||
Checkpoints.History private _totalCheckpoints;
|
||||
|
||||
|
||||
@@ -124,7 +142,7 @@
|
||||
*
|
||||
* Emits events {DelegateChanged} and {DelegateVotesChanged}.
|
||||
@ -102,7 +116,7 @@ diff -ruN governance/utils/Votes.sol governance/utils/Votes.sol
|
||||
+ function _delegate(address account, address delegatee) public virtual { // HARNESS: internal -> public
|
||||
address oldDelegate = delegates(account);
|
||||
_delegation[account] = delegatee;
|
||||
|
||||
|
||||
@@ -142,10 +160,10 @@
|
||||
uint256 amount
|
||||
) internal virtual {
|
||||
@ -139,21 +153,21 @@ diff -ruN governance/utils/Votes.sol governance/utils/Votes.sol
|
||||
- function _getVotingUnits(address) internal view virtual returns (uint256);
|
||||
+ function _getVotingUnits(address) public virtual returns (uint256); // HARNESS: internal -> public
|
||||
}
|
||||
diff -ruN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
|
||||
--- mocks/SafeERC20Helper.sol 2022-09-26 19:10:21.166619395 +0200
|
||||
+++ mocks/SafeERC20Helper.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
|
||||
--- mocks/SafeERC20Helper.sol 2022-11-02 19:02:32.463724228 +0100
|
||||
+++ mocks/SafeERC20Helper.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
|
||||
import "../utils/Context.sol";
|
||||
import "../token/ERC20/IERC20.sol";
|
||||
-import "../token/ERC20/extensions/draft-ERC20Permit.sol";
|
||||
import "../token/ERC20/utils/SafeERC20.sol";
|
||||
|
||||
|
||||
contract ERC20ReturnFalseMock is Context {
|
||||
@@ -106,42 +105,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-contract ERC20PermitNoRevertMock is
|
||||
- ERC20("ERC20PermitNoRevertMock", "ERC20PermitNoRevertMock"),
|
||||
- ERC20Permit("ERC20PermitNoRevertMock")
|
||||
@ -161,7 +175,15 @@ diff -ruN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
|
||||
- function getChainId() external view returns (uint256) {
|
||||
- return block.chainid;
|
||||
- }
|
||||
-
|
||||
+// Harness remove ?
|
||||
+// contract ERC20PermitNoRevertMock is
|
||||
+// ERC20("ERC20PermitNoRevertMock", "ERC20PermitNoRevertMock"),
|
||||
+// ERC20Permit("ERC20PermitNoRevertMock")
|
||||
+// {
|
||||
+// function getChainId() external view returns (uint256) {
|
||||
+// return block.chainid;
|
||||
+// }
|
||||
|
||||
- function permitThatMayRevert(
|
||||
- address owner,
|
||||
- address spender,
|
||||
@ -173,7 +195,18 @@ diff -ruN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
|
||||
- ) public {
|
||||
- super.permit(owner, spender, value, deadline, v, r, s);
|
||||
- }
|
||||
-
|
||||
+// function permitThatMayRevert(
|
||||
+// address owner,
|
||||
+// address spender,
|
||||
+// uint256 value,
|
||||
+// uint256 deadline,
|
||||
+// uint8 v,
|
||||
+// bytes32 r,
|
||||
+// bytes32 s
|
||||
+// ) public {
|
||||
+// super.permit(owner, spender, value, deadline, v, r, s);
|
||||
+// }
|
||||
|
||||
- function permit(
|
||||
- address owner,
|
||||
- address spender,
|
||||
@ -190,27 +223,6 @@ diff -ruN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
|
||||
- }
|
||||
- }
|
||||
-}
|
||||
+// Harness remove ?
|
||||
+// contract ERC20PermitNoRevertMock is
|
||||
+// ERC20("ERC20PermitNoRevertMock", "ERC20PermitNoRevertMock"),
|
||||
+// ERC20Permit("ERC20PermitNoRevertMock")
|
||||
+// {
|
||||
+// function getChainId() external view returns (uint256) {
|
||||
+// return block.chainid;
|
||||
+// }
|
||||
+
|
||||
+// function permitThatMayRevert(
|
||||
+// address owner,
|
||||
+// address spender,
|
||||
+// uint256 value,
|
||||
+// uint256 deadline,
|
||||
+// uint8 v,
|
||||
+// bytes32 r,
|
||||
+// bytes32 s
|
||||
+// ) public {
|
||||
+// super.permit(owner, spender, value, deadline, v, r, s);
|
||||
+// }
|
||||
+
|
||||
+// function permit(
|
||||
+// address owner,
|
||||
+// address spender,
|
||||
@ -227,37 +239,37 @@ diff -ruN mocks/SafeERC20Helper.sol mocks/SafeERC20Helper.sol
|
||||
+// }
|
||||
+// }
|
||||
+// }
|
||||
|
||||
|
||||
contract SafeERC20Wrapper is Context {
|
||||
using SafeERC20 for IERC20;
|
||||
diff -ruN proxy/utils/Initializable.sol proxy/utils/Initializable.sol
|
||||
--- proxy/utils/Initializable.sol 2022-09-29 10:07:27.126075551 +0200
|
||||
+++ proxy/utils/Initializable.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN proxy/utils/Initializable.sol proxy/utils/Initializable.sol
|
||||
--- proxy/utils/Initializable.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ proxy/utils/Initializable.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -59,12 +59,12 @@
|
||||
* @dev Indicates that the contract has been initialized.
|
||||
* @custom:oz-retyped-from bool
|
||||
*/
|
||||
- uint8 private _initialized;
|
||||
+ uint8 internal _initialized; // HARNESS: private -> internal
|
||||
|
||||
|
||||
/**
|
||||
* @dev Indicates that the contract is in the process of being initialized.
|
||||
*/
|
||||
- bool private _initializing;
|
||||
+ bool internal _initializing; // HARNESS: private -> internal
|
||||
|
||||
|
||||
/**
|
||||
* @dev Triggered when the contract has been initialized or reinitialized.
|
||||
diff -ruN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
|
||||
--- token/ERC1155/ERC1155.sol 2022-09-27 10:26:58.548890299 +0200
|
||||
+++ token/ERC1155/ERC1155.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
|
||||
--- token/ERC1155/ERC1155.sol 2022-10-31 11:08:30.547127922 +0100
|
||||
+++ token/ERC1155/ERC1155.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -21,7 +21,7 @@
|
||||
using Address for address;
|
||||
|
||||
|
||||
// Mapping from token ID to account balances
|
||||
- mapping(uint256 => mapping(address => uint256)) private _balances;
|
||||
+ mapping(uint256 => mapping(address => uint256)) internal _balances; // HARNESS: private -> internal
|
||||
|
||||
|
||||
// Mapping from account to operator approvals
|
||||
mapping(address => mapping(address => bool)) private _operatorApprovals;
|
||||
@@ -471,7 +471,7 @@
|
||||
@ -278,9 +290,9 @@ diff -ruN token/ERC1155/ERC1155.sol token/ERC1155/ERC1155.sol
|
||||
if (to.isContract()) {
|
||||
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
|
||||
bytes4 response
|
||||
diff -ruN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
|
||||
--- token/ERC20/ERC20.sol 2022-09-27 10:26:58.548890299 +0200
|
||||
+++ token/ERC20/ERC20.sol 2022-09-29 10:09:07.479688477 +0200
|
||||
diff -druN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
|
||||
--- token/ERC20/ERC20.sol 2022-10-31 11:08:30.547127922 +0100
|
||||
+++ token/ERC20/ERC20.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -256,7 +256,7 @@
|
||||
*
|
||||
* - `account` cannot be the zero address.
|
||||
@ -288,7 +300,7 @@ diff -ruN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
|
||||
- function _mint(address account, uint256 amount) internal virtual {
|
||||
+ function _mint(address account, uint256 amount) public virtual { // HARNESS: internal -> public
|
||||
require(account != address(0), "ERC20: mint to the zero address");
|
||||
|
||||
|
||||
_beforeTokenTransfer(address(0), account, amount);
|
||||
@@ -282,7 +282,7 @@
|
||||
* - `account` cannot be the zero address.
|
||||
@ -297,11 +309,11 @@ diff -ruN token/ERC20/ERC20.sol token/ERC20/ERC20.sol
|
||||
- function _burn(address account, uint256 amount) internal virtual {
|
||||
+ function _burn(address account, uint256 amount) public virtual { // HARNESS: internal -> public
|
||||
require(account != address(0), "ERC20: burn from the zero address");
|
||||
|
||||
|
||||
_beforeTokenTransfer(account, address(0), amount);
|
||||
diff -ruN token/ERC20/extensions/ERC20Capped.sol token/ERC20/extensions/ERC20Capped.sol
|
||||
diff -druN token/ERC20/extensions/ERC20Capped.sol token/ERC20/extensions/ERC20Capped.sol
|
||||
--- token/ERC20/extensions/ERC20Capped.sol 2022-08-31 13:44:36.381058287 +0200
|
||||
+++ token/ERC20/extensions/ERC20Capped.sol 2022-09-29 10:09:41.376517581 +0200
|
||||
+++ token/ERC20/extensions/ERC20Capped.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -30,7 +30,7 @@
|
||||
/**
|
||||
* @dev See {ERC20-_mint}.
|
||||
@ -311,9 +323,9 @@ diff -ruN token/ERC20/extensions/ERC20Capped.sol token/ERC20/extensions/ERC20Cap
|
||||
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
|
||||
super._mint(account, amount);
|
||||
}
|
||||
diff -ruN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
|
||||
--- token/ERC20/extensions/ERC20FlashMint.sol 2022-09-29 10:07:27.126075551 +0200
|
||||
+++ token/ERC20/extensions/ERC20FlashMint.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20FlashMint.sol
|
||||
--- token/ERC20/extensions/ERC20FlashMint.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ token/ERC20/extensions/ERC20FlashMint.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -51,9 +51,11 @@
|
||||
// silence warning about unused variable without the addition of bytecode.
|
||||
token;
|
||||
@ -321,25 +333,25 @@ diff -ruN token/ERC20/extensions/ERC20FlashMint.sol token/ERC20/extensions/ERC20
|
||||
- return 0;
|
||||
+ return fee; // HARNESS: made "return" nonzero
|
||||
}
|
||||
|
||||
|
||||
+ uint256 public fee; // HARNESS: added it to simulate random fee amount
|
||||
+
|
||||
/**
|
||||
* @dev Returns the receiver address of the flash fee. By default this
|
||||
* implementation returns the address(0) which means the fee amount will be burnt.
|
||||
diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
|
||||
--- token/ERC20/extensions/ERC20Votes.sol 2022-09-27 10:26:58.548890299 +0200
|
||||
+++ token/ERC20/extensions/ERC20Votes.sol 2022-09-29 10:09:45.489874234 +0200
|
||||
diff -druN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Votes.sol
|
||||
--- token/ERC20/extensions/ERC20Votes.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ token/ERC20/extensions/ERC20Votes.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -33,8 +33,8 @@
|
||||
bytes32 private constant _DELEGATION_TYPEHASH =
|
||||
keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
|
||||
|
||||
|
||||
- mapping(address => address) private _delegates;
|
||||
- mapping(address => Checkpoint[]) private _checkpoints;
|
||||
+ mapping(address => address) public _delegates; // HARNESS: private -> public
|
||||
+ mapping(address => Checkpoint[]) public _checkpoints; // HARNESS: private -> public
|
||||
Checkpoint[] private _totalSupplyCheckpoints;
|
||||
|
||||
|
||||
/**
|
||||
@@ -165,27 +165,27 @@
|
||||
/**
|
||||
@ -349,7 +361,7 @@ diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Vote
|
||||
+ function _maxSupply() public view virtual returns (uint224) { // HARNESS: internal -> public
|
||||
return type(uint224).max;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev Snapshots the totalSupply after it has been increased.
|
||||
*/
|
||||
@ -357,22 +369,22 @@ diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Vote
|
||||
+ function _mint(address account, uint256 amount) public virtual override { // HARNESS: internal -> public
|
||||
super._mint(account, amount);
|
||||
require(totalSupply() <= _maxSupply(), "ERC20Votes: total supply risks overflowing votes");
|
||||
|
||||
|
||||
- _writeCheckpoint(_totalSupplyCheckpoints, _add, amount);
|
||||
+ _writeCheckpointAdd(_totalSupplyCheckpoints, amount); // HARNESS: new version without pointer
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev Snapshots the totalSupply after it has been decreased.
|
||||
*/
|
||||
- function _burn(address account, uint256 amount) internal virtual override {
|
||||
+ function _burn(address account, uint256 amount) public virtual override { // HARNESS: internal -> public (to comply with the ERC20 harness)
|
||||
super._burn(account, amount);
|
||||
|
||||
|
||||
- _writeCheckpoint(_totalSupplyCheckpoints, _subtract, amount);
|
||||
+ _writeCheckpointSub(_totalSupplyCheckpoints, amount); // HARNESS: new version without pointer
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -208,7 +208,7 @@
|
||||
*
|
||||
@ -383,7 +395,7 @@ diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Vote
|
||||
address currentDelegate = delegates(delegator);
|
||||
uint256 delegatorBalance = balanceOf(delegator);
|
||||
_delegates[delegator] = delegatee;
|
||||
@@ -225,12 +225,13 @@
|
||||
@@ -225,36 +225,86 @@
|
||||
) private {
|
||||
if (src != dst && amount > 0) {
|
||||
if (src != address(0)) {
|
||||
@ -392,33 +404,55 @@ diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Vote
|
||||
+
|
||||
emit DelegateVotesChanged(src, oldWeight, newWeight);
|
||||
}
|
||||
|
||||
|
||||
if (dst != address(0)) {
|
||||
- (uint256 oldWeight, uint256 newWeight) = _writeCheckpoint(_checkpoints[dst], _add, amount);
|
||||
+ (uint256 oldWeight, uint256 newWeight) = _writeCheckpointAdd(_checkpoints[dst], amount); // HARNESS: new version without pointer
|
||||
emit DelegateVotesChanged(dst, oldWeight, newWeight);
|
||||
}
|
||||
}
|
||||
@@ -255,6 +256,55 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- function _writeCheckpoint(
|
||||
+ // function _writeCheckpoint(
|
||||
+ // Checkpoint[] storage ckpts,
|
||||
+ // function(uint256, uint256) view returns (uint256) op,
|
||||
+ // uint256 delta
|
||||
+ // ) private returns (uint256 oldWeight, uint256 newWeight) {
|
||||
+ // uint256 pos = ckpts.length;
|
||||
+
|
||||
+ // Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);
|
||||
+
|
||||
+ // oldWeight = oldCkpt.votes;
|
||||
+ // newWeight = op(oldWeight, delta);
|
||||
+
|
||||
+ // if (pos > 0 && oldCkpt.fromBlock == block.number) {
|
||||
+ // _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
|
||||
+ // } else {
|
||||
+ // ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
|
||||
+ // }
|
||||
+ // }
|
||||
+
|
||||
+ // HARNESS: split _writeCheckpoint() to two functions as a workaround for function pointers that cannot be managed by the tool
|
||||
+ function _writeCheckpointAdd(
|
||||
+ Checkpoint[] storage ckpts,
|
||||
+ uint256 delta
|
||||
+ ) private returns (uint256 oldWeight, uint256 newWeight) {
|
||||
+ uint256 pos = ckpts.length;
|
||||
Checkpoint[] storage ckpts,
|
||||
- function(uint256, uint256) view returns (uint256) op,
|
||||
uint256 delta
|
||||
) private returns (uint256 oldWeight, uint256 newWeight) {
|
||||
uint256 pos = ckpts.length;
|
||||
+ oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
|
||||
+ newWeight = _add(oldWeight, delta);
|
||||
+
|
||||
|
||||
- Checkpoint memory oldCkpt = pos == 0 ? Checkpoint(0, 0) : _unsafeAccess(ckpts, pos - 1);
|
||||
+ if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
|
||||
+ ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
|
||||
+ } else {
|
||||
+ ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
|
||||
- oldWeight = oldCkpt.votes;
|
||||
- newWeight = op(oldWeight, delta);
|
||||
+ function _writeCheckpointSub(
|
||||
+ Checkpoint[] storage ckpts,
|
||||
+ uint256 delta
|
||||
@ -426,14 +460,16 @@ diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Vote
|
||||
+ uint256 pos = ckpts.length;
|
||||
+ oldWeight = pos == 0 ? 0 : ckpts[pos - 1].votes;
|
||||
+ newWeight = _subtract(oldWeight, delta);
|
||||
+
|
||||
|
||||
- if (pos > 0 && oldCkpt.fromBlock == block.number) {
|
||||
- _unsafeAccess(ckpts, pos - 1).votes = SafeCast.toUint224(newWeight);
|
||||
+ if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
|
||||
+ ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
|
||||
+ } else {
|
||||
+ ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
} else {
|
||||
ckpts.push(Checkpoint({fromBlock: SafeCast.toUint32(block.number), votes: SafeCast.toUint224(newWeight)}));
|
||||
}
|
||||
}
|
||||
|
||||
+ // backup of original function
|
||||
+ //
|
||||
+ // function _writeCheckpoint(
|
||||
@ -455,9 +491,9 @@ diff -ruN token/ERC20/extensions/ERC20Votes.sol token/ERC20/extensions/ERC20Vote
|
||||
function _add(uint256 a, uint256 b) private pure returns (uint256) {
|
||||
return a + b;
|
||||
}
|
||||
diff -ruN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
|
||||
diff -druN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wrapper.sol
|
||||
--- token/ERC20/extensions/ERC20Wrapper.sol 2022-08-31 13:44:36.381058287 +0200
|
||||
+++ token/ERC20/extensions/ERC20Wrapper.sol 2022-09-28 11:25:39.319711517 +0200
|
||||
+++ token/ERC20/extensions/ERC20Wrapper.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -55,7 +55,7 @@
|
||||
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
|
||||
* function that can be exposed with access control if desired.
|
||||
@ -467,9 +503,9 @@ diff -ruN token/ERC20/extensions/ERC20Wrapper.sol token/ERC20/extensions/ERC20Wr
|
||||
uint256 value = underlying.balanceOf(address(this)) - totalSupply();
|
||||
_mint(account, value);
|
||||
return value;
|
||||
diff -ruN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/draft-ERC721Votes.sol
|
||||
--- token/ERC721/extensions/draft-ERC721Votes.sol 2022-09-29 10:07:27.126075551 +0200
|
||||
+++ token/ERC721/extensions/draft-ERC721Votes.sol 2022-09-27 17:51:32.014634743 +0200
|
||||
diff -druN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/draft-ERC721Votes.sol
|
||||
--- token/ERC721/extensions/draft-ERC721Votes.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ token/ERC721/extensions/draft-ERC721Votes.sol 2022-11-04 16:35:52.560691845 +0100
|
||||
@@ -49,7 +49,7 @@
|
||||
/**
|
||||
* @dev Returns the balance of `account`.
|
||||
@ -479,4 +515,48 @@ diff -ruN token/ERC721/extensions/draft-ERC721Votes.sol token/ERC721/extensions/
|
||||
return balanceOf(account);
|
||||
}
|
||||
}
|
||||
|
||||
diff -druN utils/Address.sol utils/Address.sol
|
||||
--- utils/Address.sol 2022-11-03 12:06:09.356515929 +0100
|
||||
+++ utils/Address.sol 2022-11-04 16:35:52.564025262 +0100
|
||||
@@ -197,7 +197,7 @@
|
||||
bool success,
|
||||
bytes memory returndata,
|
||||
string memory errorMessage
|
||||
- ) internal view returns (bytes memory) {
|
||||
+ ) internal view returns (bytes memory val) { // MUNGED undeterministic return causes error for Prover
|
||||
if (success) {
|
||||
if (returndata.length == 0) {
|
||||
// only check isContract if the call was successful and the return data is empty
|
||||
@@ -220,7 +220,7 @@
|
||||
bool success,
|
||||
bytes memory returndata,
|
||||
string memory errorMessage
|
||||
- ) internal pure returns (bytes memory) {
|
||||
+ ) internal pure returns (bytes memory val) { // MUNGED undeterministic return causes error for Prover
|
||||
if (success) {
|
||||
return returndata;
|
||||
} else {
|
||||
diff -druN utils/Checkpoints.sol utils/Checkpoints.sol
|
||||
--- utils/Checkpoints.sol 2022-11-02 12:17:36.976298213 +0100
|
||||
+++ utils/Checkpoints.sol 2022-11-04 16:35:52.564025262 +0100
|
||||
@@ -83,13 +83,13 @@
|
||||
*
|
||||
* Returns previous value and new value.
|
||||
*/
|
||||
- function push(
|
||||
- History storage self,
|
||||
- function(uint256, uint256) view returns (uint256) op,
|
||||
- uint256 delta
|
||||
- ) internal returns (uint256, uint256) {
|
||||
- return push(self, op(latest(self), delta));
|
||||
- }
|
||||
+ // function push(
|
||||
+ // History storage self,
|
||||
+ // function(uint256, uint256) view returns (uint256) op,
|
||||
+ // uint256 delta
|
||||
+ // ) internal returns (uint256, uint256) {
|
||||
+ // return push(self, op(latest(self), delta));
|
||||
+ // }
|
||||
|
||||
/**
|
||||
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
|
||||
|
||||
Reference in New Issue
Block a user