Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Update previous epoch calculation #469

Merged
merged 17 commits into from
Apr 7, 2019

Conversation

ralexstokes
Copy link
Member

What was wrong?

Fixes #382.

Replaces #398.

How was it fixed?

Started rebasing #398 and realized we want to handle some of the tests differently.

This has the same content but keeps some of the tests... after further inspection I think what I had in #398 was actually weakening the test coverage.

Cute Animal Picture

put a cute animal picture link inside the parentheses

@ralexstokes
Copy link
Member Author

@ChihChengLiang @hwwhww @NIC619 given that you reviewed the other PR, i'll tag you here.

like stated above, i started rebasing and realized we want to handle some of the testing in a better way.

the one thing i could call special attention to is test_justification_without_mock. it seems like it should yield a bitfield 0b0 unless we provide attestations. and it doesn't seem like we will get 0b11 until we run through two epoch processings. so i think that the prior implementation was incorrect and has now been fixed (although is not testing the scenario where we do in fact hit 0b11) and that there was a bug in the previous implementation of _current_previous_epochs_justifiable. if i'm wrong, then there is a bug in the new _is_epoch_justifiable and will happily track it down so let me know :)

thanks!

@ChihChengLiang
Copy link
Contributor

ChihChengLiang commented Mar 30, 2019

@ralexstokes Feel free to fix them, those functions are implemented before v0.2.0.

Prior to this PR, previous epoch and current epoch is 0 on the genesis, that's the very reason why test_justification_without_mock is getting 0b11.

_current_previous_epochs_justifiable is also an awkward move to address the behavior of previous epoch and current epoch near genesis. As the consistent behavior introduced, it is safe to nuke _current_previous_epochs_justifiable and replace it with _is_epoch_justifiable.

@hwwhww hwwhww requested a review from NIC619 March 30, 2019 10:10
@ralexstokes ralexstokes force-pushed the update-previous-epoch branch from 09d0665 to 9439f3c Compare March 30, 2019 19:36
@ralexstokes
Copy link
Member Author

@ChihChengLiang great -- went ahead and did that! just to confirm, we do want this w/ the latest implementation correct? https://github.com/ethereum/trinity/pull/469/files#diff-9ffda674671b43bc2ac2193ad772c6a5R319

this is my understanding but we want to be extra careful about justifying the correct stuff :)

Copy link
Contributor

@NIC619 NIC619 left a comment

Choose a reason for hiding this comment

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

Probably also need @ChihChengLiang 's review on this but the refactoring makes a lot of sense! 👍

@NIC619 NIC619 requested a review from ChihChengLiang March 31, 2019 03:29
@ChihChengLiang
Copy link
Contributor

Great work! Only leave some nitpick here. Justification and finalization look good to me, their core logic did not change much in the spec and the test cases are still valid.

@ralexstokes ralexstokes force-pushed the update-previous-epoch branch from 87820e5 to 23be397 Compare April 7, 2019 04:04
@ralexstokes ralexstokes merged commit c3bb1a3 into ethereum:master Apr 7, 2019
@ralexstokes ralexstokes deleted the update-previous-epoch branch April 7, 2019 04:53
@hwwhww hwwhww mentioned this pull request Apr 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make get_previous_epoch return current_epoch - 1 in all cases
3 participants