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

epoch trans at end of epoch and fix finality conditions #492

Merged
merged 35 commits into from
Jan 28, 2019
Merged

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Jan 23, 2019

@djrtwo djrtwo requested review from JustinDrake and vbuterin and removed request for JustinDrake January 23, 2019 23:15
@vbuterin
Copy link
Contributor

vbuterin commented Jan 24, 2019

Here's a PR to your PR 🤣

#495

The logic that you actually changes all looks good, it's more about a couple other things that still need to be changed.

A few more state.slot -> current/previous/next epoch start slot changes
@djrtwo
Copy link
Contributor Author

djrtwo commented Jan 24, 2019

Thanks! Merged the PR into my PR

@vbuterin
Copy link
Contributor

Looks good to me at the moment. Maybe after merging this one and the light client one we can do a final pass on the epoch transition logic. I think for cleanliness reasons it may be a good idea to remove use of state.slot entirely (in favor of current/next/previous epoch start slot) but best do that after these two PRs as they both modify the epoch transition section quite a bit.

@djrtwo
Copy link
Contributor Author

djrtwo commented Jan 25, 2019

  • handled merge conflict
  • modified where current_epoch_calculation_slot is being updated to be the start of the next epoch when it is updated.
  • updating latest_index_roots for the next_epoch instead of the current. using this root in the seed generation for the shuffling starting at next epoch
  • created a function generate_seed to handle the complexity of the seed generation. Also handles the edge case when slot < SEED_LOOKAHEAD to prevent underflow
  • set latest_index_roots for genesis slot/epoch
  • use generate_seed to properly embed the active index root in the initial shuffling seed

Did not yet handle the next_ functionality to guarantee 1 epoch lookahead.

I'm starting to think that a lot of these vars and state attributes should just reference epochs. We are doing a lot of error prone math everywhere to get the start of epochs and convert slots to epochs. And we inconsistently use epochs vs slots

@djrtwo
Copy link
Contributor Author

djrtwo commented Jan 25, 2019

I'm working on a PR to this PR that makes epochs a first class citizen. Seeing if it cleans things up.

edit: PR here #499

djrtwo and others added 3 commits January 27, 2019 21:29
Adds a minimum slot number large enough that integer underflows involving epochs and slots will not happen; simplifies some logic that was more complex to handle them.
Minimum slot number, simplify excessive anti-underflow logic
@djrtwo
Copy link
Contributor Author

djrtwo commented Jan 28, 2019

Genesis slot changes look good to me @vbuterin

Copy link
Contributor

@vbuterin vbuterin left a comment

Choose a reason for hiding this comment

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

Good!

@hwwhww
Copy link
Contributor

hwwhww commented Jan 28, 2019

I think #505 could close #224.

@hwwhww hwwhww mentioned this pull request Jan 28, 2019
29 tasks
@@ -189,24 +190,36 @@ Code snippets appearing in `this style` are to be interpreted as Python code. Be
| Name | Value |
| - | - |
| `GENESIS_FORK_VERSION` | `0` |
| `GENESIS_SLOT` | `0` |
| `GENESIS_SLOT` | `2**19` |
| `GENESIS_EPOCH` | `slot_to_epoch(GENESIS_SLOT)` |
Copy link
Contributor

@ChihChengLiang ChihChengLiang Jan 28, 2019

Choose a reason for hiding this comment

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

Note that slot_to_epoch use EPOCH_LENGTH that is defined in the next section. So in the chain config, this will look like:

genesis_slot = SlotNumber(2**19)
epoch_length = 2**6
SERENITY_CONFIG = BeaconConfig(
    ...
    GENESIS_SLOT=genesis_slot,
    GENESIS_EPOCH=slot_to_epoch(genesis_slot, epoch_length),
    ...
    EPOCH_LENGTH=epoch_length
    ...
)

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 the prettiest. I think we want to move to #504 which will use chain start time to seed the initial state rather than config.

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