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

[Proposal] rework rewards/penalties to be more granular #1747

Merged
merged 18 commits into from May 11, 2020
Merged

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Apr 23, 2020

More granular rewards/penalty function to allow us to write and publish tests specific to each of source, target, head, inclusion delay, and inactivity leak.

Includes tests for each and a new rewards generator type

@hwwhww
Copy link
Contributor

hwwhww commented Apr 23, 2020

Is this proposal targeting at v011x or v012x?

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

First quick scan. 👀

I like going back to this more granular pattern (once upon a time, v0.5.0...). And yes, we really need more tests for these. 👍

specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
specs/phase0/beacon-chain.md Show resolved Hide resolved
specs/phase0/beacon-chain.md Show resolved Hide resolved
specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
@hwwhww hwwhww added general:RFC Request for Comments phase0 labels Apr 23, 2020
Co-Authored-By: Hsiao-Wei Wang <hwwang156@gmail.com>
@djrtwo
Copy link
Contributor Author

djrtwo commented Apr 29, 2020

@protolambda I've done some work to de-duplicate the tests across source, target, head (want to run same scenarios against each essentially).

Curious if you see any less verbose but clean way to further reduce the verbosity here.

Essentially helpers/rewards.py contains the meat of the tests and a separate test file for each source, target, and head call the helper-tests from rewards.py. Problem is that source, target ,and head test files look almost exactly the same but have a different runner being passed in.

edit: and this is all obviously in the context of having good generators

specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
specs/phase0/beacon-chain.md Show resolved Hide resolved
specs/phase0/beacon-chain.md Outdated Show resolved Hide resolved
@djrtwo
Copy link
Contributor Author

djrtwo commented May 4, 2020

One problem I'm thinking about here is that ultimately, for each test case I right for a particular deltas function, it might as well have test vector outputs for each of the deltas functions against that test.

That leads me to consider default outputing rewards/penalties for each deltas function for each deltas test instead of essentially copying over some tests and having them run separate deltas.

The nice thing is that this would de-duplicate pre-states in deltas tests and would ensure that no-ops have the intended effect on tests that don't really concern a deltas function.

The bad thing is that it muddies up the output a bit and makes it less clear what is actually being tested (but still shows granularity).

not sure. To start, I'll have the proposal ready for review shortly without combining all deltas vectors into one format

@djrtwo
Copy link
Contributor Author

djrtwo commented May 5, 2020

okay @protolambda and @hwwhww, this is finally ready for review (including tests)

EDIT: the tests are much more comprehensive, but still keep an eye out for cases that are not covered. happy to add more

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

Great work! I reviewed the content correctness, but still thinking about more edge cases. 🤔

tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
djrtwo and others added 2 commits May 5, 2020 13:08
Co-authored-by: Hsiao-Wei Wang <hwwang156@gmail.com>
Copy link
Collaborator

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

Partial review, going to refresh for latest changes.

specs/phase0/beacon-chain.md Show resolved Hide resolved
tests/core/pyspec/eth2spec/test/helpers/rewards.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

You can batch apply these, the comments were inconsistent after the change to deltas

djrtwo and others added 2 commits May 5, 2020 16:28
"rewards/penalties" -> "deltas" in throughout test comments/descriptions

Co-authored-by: Diederik Loerakker <proto@protolambda.com>
specs/phase0/beacon-chain.md Show resolved Hide resolved
specs/phase0/beacon-chain.md Show resolved Hide resolved
@djrtwo
Copy link
Contributor Author

djrtwo commented May 8, 2020

@hwwhww or @protolambda, I'm looking to get this merged asap for v0.12 release. Let me know if there's anything else you want to see right now

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

The PR looks good to me 👍
We can still come up with other new test cases after this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:RFC Request for Comments phase0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants