Skip to content

etherGC.sol +reputationGC.sol#756

Draft
orenyodfat wants to merge 7 commits intomasterfrom
dxdao_gc
Draft

etherGC.sol +reputationGC.sol#756
orenyodfat wants to merge 7 commits intomasterfrom
dxdao_gc

Conversation

@orenyodfat
Copy link
Contributor

No description provided.

@dkent600
Copy link
Contributor

dkent600 commented May 22, 2020

Can you spell out "GC" in the contract name? No idea what it means...

Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bit a confusing comment

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe call it "periodLength"? and add in the comment that the unit is blocks

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what this is fore, this is just set in the initliaze call... if you need it, give it a more meaningful name perhaps?

Copy link
Contributor

Choose a reason for hiding this comment

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

totalAmountSentPerPeriod, a mapping from period indexes to amounts

Copy link
Contributor

Choose a reason for hiding this comment

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

this needs some explanation, I think. So the constraint holds for what? it is a limit on how much the funds from the avatar the controller is allowed to spend per period.

Copy link
Contributor

Choose a reason for hiding this comment

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

"and throws an error if the constraint is violated"

test/etherGC.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

comment says 10 blocks, code says 20

Copy link
Contributor

Choose a reason for hiding this comment

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

you have a GlobalConstraint interface to inherit from?

Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need the controller as a separate argument, can't you get that from the avatar_?

test/etherGC.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to explain in a comment why this statement is not failing. Afaics, if this and the previous lines fall within the same period, you have sent 9 ether and violated the constraint. So by some coincidence, this last transfer happens in the next period?

@orenyodfat orenyodfat closed this May 22, 2020
@orenyodfat orenyodfat reopened this May 22, 2020
Oren Sokolowsky added 2 commits May 23, 2020 00:09
@orenyodfat orenyodfat changed the title etherGC.sol etherGC.sol +reputationGC.sol May 23, 2020
Copy link
Contributor

@leviadam leviadam left a comment

Choose a reason for hiding this comment

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

I added some comments. Mainly about time/blocks.
Mostly, looks ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think period should not be in blocks, as block time is changing.
The timestamp cannot be trusted up to seconds, but it can be for large periods, as in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Start time/block is actually not really required, as you can pick any point in time to count from. But it makes the mapping more readable (start from index 0 instead of a random shift). Guessing it is worth the one-time 20k gas.

using SafeMath for uint256;

uint256 public periodLength; //the period length in blocks units
uint256 public amountAllowedPerPeriod;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this should be percentage-wise, or absolute values. Probably better to keep it absolute.

totalAmountSentPerPeriod[currentPeriodIndex] =
totalAmountSentPerPeriod[currentPeriodIndex].add(avatarBalanceBefore.sub(address(avatar).balance));
require(totalAmountSentPerPeriod[currentPeriodIndex] <= amountAllowedPerPeriod,
"Violation of Global constraint EtherGC:amount sent exceed in current period");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should set back avatarBalanceBefore to zero, as it will save gas.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as in EtherGC

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.

5 participants

Comments