remove _burn impossible overflow

This commit is contained in:
Ricardo Guilherme Schmidt 2023-09-26 12:46:06 -03:00
parent 2ac35620c3
commit ab07801f67
4 changed files with 7 additions and 10 deletions

View File

@ -1,7 +1,7 @@
| contracts/MiniMeToken.sol:MiniMeToken contract | | | | | | | contracts/MiniMeToken.sol:MiniMeToken contract | | | | | |
|------------------------------------------------|-----------------|-------|--------|-------|---------| |------------------------------------------------|-----------------|-------|--------|-------|---------|
| Deployment Cost | Deployment Size | | | | | | Deployment Cost | Deployment Size | | | | |
| 2098051 | 11904 | | | | | | 2086437 | 11846 | | | | |
| Function Name | min | avg | median | max | # calls | | Function Name | min | avg | median | max | # calls |
| DOMAIN_SEPARATOR | 387 | 387 | 387 | 387 | 10 | | DOMAIN_SEPARATOR | 387 | 387 | 387 | 387 | 10 |
| allowance | 0 | 190 | 0 | 763 | 16 | | allowance | 0 | 190 | 0 | 763 | 16 |
@ -13,7 +13,7 @@
| claimTokens | 9559 | 40647 | 56192 | 56192 | 3 | | claimTokens | 9559 | 40647 | 56192 | 56192 | 3 |
| controller | 0 | 0 | 0 | 0 | 10 | | controller | 0 | 0 | 0 | 0 | 10 |
| decimals | 0 | 0 | 0 | 0 | 10 | | decimals | 0 | 0 | 0 | 0 | 10 |
| destroyTokens | 2098 | 4543 | 3890 | 7643 | 3 | | destroyTokens | 3864 | 5115 | 3864 | 7617 | 3 |
| enableTransfers | 0 | 0 | 0 | 0 | 3 | | enableTransfers | 0 | 0 | 0 | 0 | 3 |
| generateTokens | 0 | 16361 | 0 | 95178 | 64 | | generateTokens | 0 | 16361 | 0 | 95178 | 64 |
| name | 0 | 0 | 0 | 0 | 10 | | name | 0 | 0 | 0 | 0 | 10 |

View File

@ -11,13 +11,13 @@ ClaimTokensTest:testClaimETH() (gas: 13659)
ClaimTokensTest:testClaimSelf() (gas: 60260) ClaimTokensTest:testClaimSelf() (gas: 60260)
ClaimTokensTest:testDeployment() (gas: 26595) ClaimTokensTest:testDeployment() (gas: 26595)
CreateCloneTokenTest:testCloneFutureSnapshot() (gas: 100903) CreateCloneTokenTest:testCloneFutureSnapshot() (gas: 100903)
CreateCloneTokenTest:testCreateCloneToken() (gas: 2137113) CreateCloneTokenTest:testCreateCloneToken() (gas: 2125492)
CreateCloneTokenTest:testDeployment() (gas: 26550) CreateCloneTokenTest:testDeployment() (gas: 26550)
CreateCloneTokenTest:testGenerateTokens() (gas: 101254) CreateCloneTokenTest:testGenerateTokens() (gas: 101254)
DestroyTokensTest:testDeployment() (gas: 26595) DestroyTokensTest:testDeployment() (gas: 26595)
DestroyTokensTest:testDestroyTokens() (gas: 12143) DestroyTokensTest:testDestroyTokens() (gas: 12117)
DestroyTokensTest:testDestroyTokensNotEnoughBalance() (gas: 9246) DestroyTokensTest:testDestroyTokensNotEnoughBalance() (gas: 9220)
DestroyTokensTest:testDestroyTokensNotEnoughSupply() (gas: 7787) DestroyTokensTest:testDestroyTokensNotEnoughSupply() (gas: 9553)
GenerateTokensTest:testDeployment() (gas: 26550) GenerateTokensTest:testDeployment() (gas: 26550)
GenerateTokensTest:testGenerateTokens() (gas: 109390) GenerateTokensTest:testGenerateTokens() (gas: 109390)
GenerateTokensTest:testGenerateTokensSupplyOverflow() (gas: 3126) GenerateTokensTest:testGenerateTokensSupplyOverflow() (gas: 3126)

View File

@ -5,7 +5,6 @@ error TransfersDisabled();
error ParentSnapshotNotReached(); error ParentSnapshotNotReached();
error NotEnoughBalance(); error NotEnoughBalance();
error NotEnoughAllowance(); error NotEnoughAllowance();
error NotEnoughSupply();
error InvalidDestination(); error InvalidDestination();
error ControllerRejected(); error ControllerRejected();
error Overflow(); error Overflow();
@ -382,7 +381,6 @@ abstract contract MiniMeBase is Controlled, IERC20, IERC20Permit, EIP712, Nonces
/// @return True if the tokens are burned correctly /// @return True if the tokens are burned correctly
function _burn(address _owner, uint256 _amount) internal virtual returns (bool) { function _burn(address _owner, uint256 _amount) internal virtual returns (bool) {
uint256 curTotalSupply = totalSupply(); uint256 curTotalSupply = totalSupply();
if (curTotalSupply < _amount) revert NotEnoughSupply();
uint256 previousBalanceFrom = balanceOf(_owner); uint256 previousBalanceFrom = balanceOf(_owner);
if (previousBalanceFrom < _amount) revert NotEnoughBalance(); if (previousBalanceFrom < _amount) revert NotEnoughBalance();
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);

View File

@ -11,7 +11,6 @@ import {
TransfersDisabled, TransfersDisabled,
InvalidDestination, InvalidDestination,
NotEnoughBalance, NotEnoughBalance,
NotEnoughSupply,
NotEnoughAllowance, NotEnoughAllowance,
AllowanceAlreadySet, AllowanceAlreadySet,
ControllerRejected, ControllerRejected,
@ -705,7 +704,7 @@ contract DestroyTokensTest is MiniMeTokenTest {
vm.prank(deployer); vm.prank(deployer);
vm.resumeGasMetering(); vm.resumeGasMetering();
vm.expectRevert(NotEnoughSupply.selector); vm.expectRevert(NotEnoughBalance.selector);
minimeToken.destroyTokens(accounts[0], 11); minimeToken.destroyTokens(accounts[0], 11);
vm.pauseGasMetering(); vm.pauseGasMetering();
assertEq(minimeToken.totalSupply(), 10, "total supply should be correct"); assertEq(minimeToken.totalSupply(), 10, "total supply should be correct");