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

Compute state up to slot #5035

Merged
merged 9 commits into from Mar 8, 2020
Merged

Compute state up to slot #5035

merged 9 commits into from Mar 8, 2020

Conversation

terencechain
Copy link
Member

Added replay function to compute state up to slot, this is really useful if one's interest to know the state at of a given slot. This functionality will also be used for both hot and cold mgmt. Also added tests to go with this

@codecov
Copy link

codecov bot commented Mar 7, 2020

Codecov Report

Merging #5035 into master will increase coverage by 1.10%.
The diff coverage is 44.00%.

@@            Coverage Diff             @@
##           master    #5035      +/-   ##
==========================================
+ Coverage   42.99%   44.10%   +1.10%     
==========================================
  Files         267      214      -53     
  Lines       20111    16628    -3483     
==========================================
- Hits         8647     7333    -1314     
+ Misses       9987     8000    -1987     
+ Partials     1477     1295     -182     

@terencechain terencechain self-assigned this Mar 8, 2020
@terencechain terencechain added Ready For Review A pull request ready for code review new-state-mgmt labels Mar 8, 2020
// ComputeStateUpToSlot returns a processed state up to input target slot.
// If the last processed block is at slot 32, given input target slot at 40, this
// returns processed state up to slot 40 via empty slots.
func (s *State) ComputeStateUpToSlot(ctx context.Context, targetSlot uint64) (*state.BeaconState, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Ok , what if you have two blocks at slot 30 ? how would you know which state to return ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It returns the canonical one (ie ancestor of the canonical chain from the node's point of view)
Will update the comment

@terencechain terencechain merged commit 962fe85 into master Mar 8, 2020
@delete-merged-branch delete-merged-branch bot deleted the replay-methods branch March 8, 2020 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants