Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mislabeled maximum scaling factor post-condition #69

Open
Hadyn opened this issue Aug 13, 2020 · 4 comments
Open

Mislabeled maximum scaling factor post-condition #69

Hadyn opened this issue Aug 13, 2020 · 4 comments

Comments

@Hadyn
Copy link

Hadyn commented Aug 13, 2020

The following error message and comment should say that the check is for if the max scaling factor was set too high.

// make sure the mint didnt push maxScalingFactor too low
require(yamsScalingFactor <= _maxScalingFactor(), "max scaling factor too low");
@brockelmore
Copy link
Contributor

Since we update the init supply, and not the yamsScalingFactor, the real check is on maxScalingFactor moving against the current scaling factor. i.e. yamsScalingFactor is the invariant in the function, and maxScalingFactor changes.

If you still disagree let me know

@Hadyn
Copy link
Author

Hadyn commented Aug 15, 2020

Ah I see. You're right, my apologies. I think it might be helpful to imply that the change in initSupply caused a change in the _maxScalingFactor either by passing the initSupply as a parameter or even elaborating on the comment. I tripped over trying to understand this condition a few times. Also, isn't this condition redundant as the initSupply would overflow if this condition held true?

@brockelmore
Copy link
Contributor

brockelmore commented Aug 15, 2020

overflow condition is initSupply * yamsScalingFactor >= 2**256, so it is possible that initSupply wouldnt be overflowing while initSupply * yamsScalingFactor would be, so the check is necessary (if i am understanding your question)

@Hadyn
Copy link
Author

Hadyn commented Aug 15, 2020

Ah sorry I meant total supply:

// increase totalSupply
totalSupply = totalSupply.add(amount);

I remembered it was one of the two but I wasn't sure which one. I'm missing my targets here. So I assume here if I am understanding the code correctly that for all the addresses in the contract, the sum of all the account balances using balanceOf(address) is less than or equal to totalSupply. It would follow then that totalSupply would overflow before the condition later in the code is met because the only time the supply could ever overflow is if one account was holding all the tokens. So wouldn't that render the condition later in the code redundant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants