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

Volume dumping restriction manager #292

Conversation

samparsky
Copy link

@samparsky samparsky commented Sep 28, 2018

Please check if the PR fulfills these requirements

  • The commit message follows our Submission guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

#268

What is the current behavior?

(You can also link to an open issue here)

What is the new behavior?

(Define and describe any new functionality. Clarify if this is a feature change)

Does this PR introduce a breaking change?

No

Any Other information:

@satyamakgec
Copy link
Contributor

Hey, @samparsky Should I start reviewing this PR or still you are adding some code in it?

@samparsky
Copy link
Author

@satyamakgec Currently adding more tests. Will let you know when I am done

@samparsky
Copy link
Author

@satyamakgec Please kindly review this PR

@samparsky samparsky changed the title [WIP] Volume dumping restriction manager Volume dumping restriction manager Oct 3, 2018
@satyamakgec
Copy link
Contributor

@samparsky left some comments on the PR. and you can also improve the test coverage of your contracts although it is good please try to make it 95% - 98%

@samparsky
Copy link
Author

samparsky commented Oct 6, 2018

@satyamakgec I have made the changes suggested above.
The test seems to be failing due to some issue I can't figure out

This returns

$ node_modules/.bin/solidity-coverage

the following error which seems odd, given that truffle compile works perfectly

* Line 1, Column 1
  Syntax error: value, object or array expected.
* Line 1, Column 1
  A valid JSON document must be either an array or an object value.

@satyamakgec
Copy link
Contributor

Yes @samparsky we are facing this issue, Once we resolve that then your PR also start building in Travis.

@samparsky
Copy link
Author

samparsky commented Oct 10, 2018

@satyamakgec Please review, the changes suggested have been implemented

@samparsky samparsky force-pushed the volume-restriction-manager branch 2 times, most recently from c2028d7 to 1acfa9e Compare October 11, 2018 06:53
@samparsky
Copy link
Author

@satyamakgec Please review, the changes suggested have been implemented


if (_amount <= allowedRemainingAmount){
volumeTally[_from][periodId] = volumeTally[_from][periodId].add(_amount);
return Result.VALID;
Copy link
Contributor

Choose a reason for hiding this comment

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

As above should return Result.NA here not Result.VALID

Copy link
Author

Choose a reason for hiding this comment

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

When should Result.VALID be used?

@samparsky
Copy link
Author

@adamdossa @satyamakgec Please review, the changes suggested have been implemented

@satyamakgec
Copy link
Contributor

@samparsky Thanks for all your hard work and patience. we are in the process of reviewing the code. it may take a couple of days to finalize the module. So please bear me. I will try to send you an update as soon as possible.

@samparsky
Copy link
Author

samparsky commented Oct 18, 2018

@satyamakgec @adamdossa It would be helpful if this PR can be reviewed & merged.
Merge conflicts occurs when other PRs get merged in. I have had to rebase & fix several times cos of this, it gets frustrating after some time.

Copy link
Contributor

@satyamakgec satyamakgec left a comment

Choose a reason for hiding this comment

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

Also, try to increase the branch coverage it is 80 % but we are expecting b/w 95% - 100%

migrations/2_deploy_contracts.js Outdated Show resolved Hide resolved
migrations/2_deploy_contracts.js Outdated Show resolved Hide resolved
scripts/test.sh Outdated Show resolved Hide resolved
@samparsky samparsky force-pushed the volume-restriction-manager branch 6 times, most recently from 6b6ca11 to 579c596 Compare October 21, 2018 13:05
@samparsky
Copy link
Author

samparsky commented Oct 21, 2018

@satyamakgec I have implemented the changes you have suggested.
The code coverage for the files added is at 96% & 98%.

VolumeDumpingRestrictionTMFactory.sol - 96%
VolumeDumpingRestrictionTM.sol - 98%

I still have some questions,
Regarding this below, I haven't gotten any clear response from you yet as it doesn't quite agree with the design I was given https://www.lucidchart.com/documents/edit/c96ff64c-5b89-4b9c-985a-01637266bf88/0?shared=true&

This will give you a wrong calculation
ex- A will have the balance of 1000 tokens
percentage allowed - 10% = 100 tokens
First txn deduct the 50 tokens and after first txn A will get the 1000 tokens from B.
for the second transaction(same periodId) calculation will look like this
(1950 + 50 ) * (10)/100 -- it is totally wrong because now it will allow him to deduct 200 tokens instead of more 50 tokens.

It would be awesome to get a response

@satyamakgec
Copy link
Contributor

@samparsky Thanks for the changes Yes you are right it is not matching with the design. I will give you more information after the internal discussion on design.

@samparsky
Copy link
Author

@satyamakgec @adamdossa I am waiting on your decision

@satyamakgec
Copy link
Contributor

Hey @samparsky sorry for the delay. The logic looks as -
let’s assume the limit is 10,000 tokens in a rolling 30 days. If SUM (all sales in the last 29 days) + sale requested now < 10,000 then the transaction can proceed, else the transaction reverts. and yes you are doing right as per the lucidchart. Always takes the user current balance in the calculation. But please keep in mind the logic of rolling period which seems off to me in your current code.

@samparsky
Copy link
Author

samparsky commented Oct 27, 2018

@satyamakgec That means the calculation of the limit is correct,

As for the logic of the rolling period is calculated thus

The assumption is there is no rollover of tokens transfer i.e. if you have 10k limit in a period & you only transfer 5k you don't get the remaining 5k rolled over to the next period

endtime - 200
starttime - 100
rollingperiod - 10

currentTime = 101
unit256 periodId = (101-100) / 10 = 0

currentTime = 102
uint256 periodId = (102 -100) / 10 = 0

currentTime = 120
uint256 periodId = (120-100) / 10 = 2

currentTime = 150
uint256 periodId = (150-100) / 10 = 5

It would be great if we can work together to close the PR asap, its taken quite a very long time.

@samparsky
Copy link
Author

@satyamakgec @adamdossa Still waiting on you

@satyamakgec
Copy link
Contributor

satyamakgec commented Oct 29, 2018 via email

@samparsky
Copy link
Author

@satyamakgec Hello, how was Devcon? Hoping we can conclude on this, this week

@satyamakgec
Copy link
Contributor

@samparsky Devcon was good and yes we can conclude this week.

@satyamakgec
Copy link
Contributor

@samparsky please do resolve the above issues and update your branch so I can give this module a green light

@samparsky
Copy link
Author

@satyamakgec I have implemented the suggested changes. I changed the implementation of the periodId to be more dynamic to allow changing the rollingPeriod without affecting the periodId calculation.

@maxsam4
Copy link
Contributor

maxsam4 commented Nov 15, 2018

Bounty paid. Thanks a lot for your contribution @samparsky .

@maxsam4 maxsam4 closed this Nov 15, 2018
@samparsky
Copy link
Author

@maxsam4 Any reason why the PR wasn't merged?

@maxsam4
Copy link
Contributor

maxsam4 commented Nov 15, 2018

@samparsky We have decided to merge this module and #320

It would not have been fair of us to ask you guys to do the required change so we'll be doing them ourselves.
If you want to work on merging them in your free time, feel free and I'll reopen this PR. Thank you for all your effort, we really appreciate your work.

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

Successfully merging this pull request may close these issues.

None yet

4 participants