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

[N23] Unused code #2905

Merged
merged 6 commits into from
Feb 25, 2020
Merged

[N23] Unused code #2905

merged 6 commits into from
Feb 25, 2020

Conversation

asaj
Copy link
Contributor

@asaj asaj commented Feb 23, 2020

Description

This PR removes unused code, except for FractionUtil, which is removed in #2890.

Note that the maximum values were being exposed for testing purposes, and the existing code already has tests showing transactions that would cause overflows properly revert. For posterity, these maximum values are instead preserved as part of the docstring on the relevant functions.

Tested

Not tested

Other changes

Describe any minor or "drive-by" changes here.

Related issues

Backwards compatibility

Yes

Copy link
Contributor

@m-chrzan m-chrzan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments I don't feel super strongly about but please take a look. Otherwise, looks fixed 😎
Oh, also looks like this affects transfer costs, so e2e tests are broken.

* Test add(maxFixedAdd(),maxFixedAdd()) equals maxFixedAdd() + maxFixedAdd()
* Test add(maxFixedAdd()+1,maxFixedAdd()+1) throws
*/
function maxFixedAdd() internal pure returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so I think this could still be a potentially useful number to keep in this file, at least in a comment. Can be useful information for consumers of this library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to keeping as a comment

@@ -214,6 +191,7 @@ library FixidityLib {
* Test multiply(maxFixedMul()+1,maxFixedMul()+1) fails
*/
function multiply(Fraction memory x, Fraction memory y) internal pure returns (Fraction memory) {
require(x.value <= maxFixedMul() && y.value <= maxFixedMul());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there are unit tests that verify this reverts anyways without this check when the inputs are too large. I understand being conservative, as this library aims to be safe, but it also aims to be efficient, do we need an additional require here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will make the functions that expose these values external, so that clients that consume this code can do input sanitation more easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually nevermind, as this increases bytecode size. Going to move everything to comments.

packages/protocol/contracts/common/FixidityLib.sol Outdated Show resolved Hide resolved
@m-chrzan m-chrzan assigned asaj and unassigned m-chrzan Feb 24, 2020
@codecov
Copy link

codecov bot commented Feb 25, 2020

Codecov Report

Merging #2905 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #2905    +/-   ##
========================================
  Coverage   73.37%   73.37%            
========================================
  Files         570      570            
  Lines       14277    14277            
  Branches     1722     1482   -240     
========================================
  Hits        10476    10476            
+ Misses       3516     3514     -2     
- Partials      285      287     +2
Flag Coverage Δ
#mobile 73.75% <ø> (ø) ⬆️
#web 72.85% <ø> (ø) ⬆️
Impacted Files Coverage Δ
packages/web/src/utils/utils.ts 71.69% <0%> (ø) ⬆️
packages/web/src/utils/abortableFetch.ts 71.42% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9869bf9...2017226. Read the comment docs.

@asaj asaj added the automerge Have PR merge automatically when checks pass label Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit audit-fix automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants