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

Court: Polish main court contract functionality #103

Merged
merged 38 commits into from
Sep 19, 2019

Conversation

facuspagnuolo
Copy link
Contributor

@facuspagnuolo facuspagnuolo commented Aug 15, 2019

Fixes #83 and #16

Lots of polishing stuff, inline documentation and bunch of new tests happening on this PR, important pieces to take a look carefully are:

@facuspagnuolo facuspagnuolo added wip Work in progress issue component:contracts Contracts related requirements labels Aug 15, 2019
@facuspagnuolo facuspagnuolo self-assigned this Aug 15, 2019
Copy link
Contributor

@izqui izqui left a comment

Choose a reason for hiding this comment

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

Looking really good so far, some minor comments

contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
@facuspagnuolo facuspagnuolo force-pushed the polish_main_court_contract branch 3 times, most recently from 4411b03 to d877efd Compare August 23, 2019 15:12
@facuspagnuolo facuspagnuolo added component:tests Tests related requirements documentation Documentation related requirements labels Aug 23, 2019
@facuspagnuolo facuspagnuolo force-pushed the polish_main_court_contract branch 2 times, most recently from ad53add to 99ac098 Compare August 26, 2019 12:02
@facuspagnuolo facuspagnuolo changed the base branch from development to add_drafting_tests August 26, 2019 12:03
Copy link
Contributor

@izqui izqui left a comment

Choose a reason for hiding this comment

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

Some minor comments that I forgot to submit

Edit: moving them to #104

@facuspagnuolo facuspagnuolo force-pushed the polish_main_court_contract branch 6 times, most recently from 8629ab5 to 95124f4 Compare August 28, 2019 11:18
@facuspagnuolo facuspagnuolo changed the title [WIP] Polish main court functionality Polish main court functionality Aug 28, 2019
@facuspagnuolo facuspagnuolo force-pushed the polish_main_court_contract branch 2 times, most recently from b138838 to da99eeb Compare August 29, 2019 12:59
Copy link
Contributor

@bingen bingen left a comment

Choose a reason for hiding this comment

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

Still reviewing, but here you have another batch.
Before I forget, I realized there are some lint errors. I will push a small PR to add linter to CI, ok?

contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
* @dev Tell the last ensured term identification number
* @return Identification number of the last ensured term
*/
function getLastEnsuredTermId() external view returns (uint64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't call this Ensured, as it can be misunderstood as if we somehow know that we have already called ensureTerm and it's up to date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I follow the scenario you are describing. IMO this is what termId actually means, it's the last ensured term since it may be outdated.

Copy link
Contributor

@bingen bingen Sep 18, 2019

Choose a reason for hiding this comment

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

Ok, again, proceed as you want, it's just a name, but to make my point clear: if termId means "the last ensured term", I don't see the need for adding Ensured as it would be just confusing, like there are 2 different concepts, termId and ensuredTermId.
But I don't think termId is "ensured" at all, as we don't know if all needed term transitions have taken place.
Anyway, to me this is just and old plain getter:

    function getLastEnsuredTermId() external view returns (uint64) {
        return termId;
    }

And it's a common practice to name getters as get + variable name. So if you really want to call this with that (IMO) unnecessary long name instead of the classic getTermId, I would then rename the variable to lastEnsuredTermId.

[Suggestion for our style guide, section naming conventions: plain getters are called get + variable name]

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 definitely a bit of bikeshedding at this point, but what about getLastTransitionedTermId?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it's bikeshedding. Actually I don't think we even need this function at all, as we could have kept termId public and use the automatically generated getter.
[Another thing to discuss for our style guide: do we use public state variables and auto-generated getters? Or do we declare them all internal and explicitly write getters?]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like getLastTransitionedTermId and also agree about the getters pattern, I think the whole problem comes as a consequence of the state variable being called simply termId which is not always up-to-date. What about renaming the variable to lastTransitionedTermId as well?

contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Show resolved Hide resolved
Copy link
Contributor

@izqui izqui left a comment

Choose a reason for hiding this comment

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

Outstanding work on this @facuspagnuolo!

Some minor comments, but good to go on my end to merge 🔥

contracts/Court.sol Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
contracts/Court.sol Outdated Show resolved Hide resolved
test/helpers/court.js Outdated Show resolved Hide resolved
test/helpers/court.js Outdated Show resolved Hide resolved
test/court/court-appeal.js Outdated Show resolved Hide resolved
test/court/court-confirm-appeal.js Outdated Show resolved Hide resolved
test/court/court-settle.js Outdated Show resolved Hide resolved
test/court/court-settle.js Outdated Show resolved Hide resolved
test/court/court-settle.js Outdated Show resolved Hide resolved
@facuspagnuolo
Copy link
Contributor Author

facuspagnuolo commented Sep 19, 2019

@izqui I already addressed all your comments. Please take a look at the related changes, I'd recommend reviewing them by commit.

⚠️ I improved and added some other appeal tests in e2cac0b, and also noted that we may be missing the final round reduction here. LMKYT

Copy link
Contributor

@izqui izqui left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1235,6 +1235,7 @@ contract Court is IJurorsRegistryOwner, ICRVotingOwner, ISubscriptionsOwner, Tim

// Otherwise, return the times the active balance of the juror fits in the min active balance, multiplying
// it by a round factor to ensure a better precision rounding.
// TODO: review, we are not using the final round discount here
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. I don't think we should have it here though, but it should definitely be in settleReward when assigning fees for coherent jurors in the final round

accounting.assign(config.feeToken, _juror, jurorFee);

And we should definitely have a test for it. Maybe we should work on it on a specific test file for accounting?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I don't get it. round.jurorFees already has the discount applied, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I was confused. The problem was that we are not testing it 😂

@facuspagnuolo facuspagnuolo merged commit 36679bf into development Sep 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the polish_main_court_contract branch September 19, 2019 11:15
@izqui izqui added this to the Freeze #1 milestone Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:contracts Contracts related requirements component:tests Tests related requirements documentation Documentation related requirements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Court: Write full-coverage unit tests
3 participants