Skip to content

Volume dumping restriction manager - #292

Closed
samparsky wants to merge 13 commits into
PolymathNetwork:development-1.5.0from
samparsky:volume-restriction-manager
Closed

samparsky wants to merge 13 commits into
PolymathNetwork:development-1.5.0from
samparsky:volume-restriction-manager

Conversation

@samparsky

@samparsky samparsky commented Sep 28, 2018 •

Copy link
Copy Markdown

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:

@samparsky
samparsky force-pushed the volume-restriction-manager branch from 6fac7ee to c14925d Compare September 29, 2018 09:05
@satyamakgec

Copy link
Copy Markdown
Contributor

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

@samparsky

Copy link
Copy Markdown
Author

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

@samparsky
samparsky force-pushed the volume-restriction-manager branch from b76aa75 to 0937471 Compare October 3, 2018 12:54
@samparsky

Copy link
Copy Markdown
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
Copy Markdown
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
samparsky force-pushed the volume-restriction-manager branch from 5222dcf to 628cf87 Compare October 5, 2018 16:40
@samparsky

samparsky commented Oct 6, 2018 •

Copy link
Copy Markdown
Author

@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
Copy Markdown
Contributor

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

@samparsky

samparsky commented Oct 10, 2018 •

Copy link
Copy Markdown
Author

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
samparsky force-pushed the volume-restriction-manager branch from 1acfa9e to 0dcb580 Compare October 15, 2018 06:22
@samparsky

Copy link
Copy Markdown
Author

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

@satyamakgec

Copy link
Copy Markdown
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

samparsky commented Oct 18, 2018 •

Copy link
Copy Markdown
Author

@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.

@satyamakgec satyamakgec left a comment

Copy link
Copy Markdown
Contributor

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%

Comment thread migrations/2_deploy_contracts.js Resolved
Comment thread migrations/2_deploy_contracts.js Resolved
Comment thread scripts/test.sh 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

samparsky commented Oct 21, 2018 •

Copy link
Copy Markdown
Author

@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
Copy Markdown
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
Copy Markdown
Author

@satyamakgec @adamdossa I am waiting on your decision

@satyamakgec

Copy link
Copy Markdown
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

samparsky commented Oct 27, 2018 •

Copy link
Copy Markdown
Author

@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
Copy Markdown
Author

@satyamakgec @adamdossa Still waiting on you

@satyamakgec

satyamakgec commented Oct 29, 2018 via email

Copy link
Copy Markdown
Contributor

@samparsky

Copy link
Copy Markdown
Author

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

@satyamakgec

Copy link
Copy Markdown
Contributor

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

@satyamakgec

Copy link
Copy Markdown
Contributor

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

@samparsky
samparsky force-pushed the volume-restriction-manager branch from 883f8e1 to 1157d95 Compare November 10, 2018 09:39
@samparsky
samparsky force-pushed the volume-restriction-manager branch from 1157d95 to bb73259 Compare November 10, 2018 09:44
@samparsky

Copy link
Copy Markdown
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

maxsam4 commented Nov 15, 2018

Copy link
Copy Markdown
Contributor

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

@maxsam4 maxsam4 closed this Nov 15, 2018
@samparsky

Copy link
Copy Markdown
Author

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

@maxsam4

maxsam4 commented Nov 15, 2018

Copy link
Copy Markdown
Contributor

@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.

4 participants