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

Guard against deleting genesis and finalized state in DB #3842

Merged
merged 8 commits into from
Oct 24, 2019

Conversation

terencechain
Copy link
Member

@terencechain terencechain commented Oct 24, 2019

Change list:

  • Revert the order on SaveFinalizedCheckpoint and rmStatesBySlots
  • Guard DeleteState against deleting genesis and finalized states

Resolves #3841

@codecov
Copy link

codecov bot commented Oct 24, 2019

Codecov Report

Merging #3842 into master will increase coverage by 36.27%.
The diff coverage is 57.89%.

@@             Coverage Diff             @@
##           master    #3842       +/-   ##
===========================================
+ Coverage    5.77%   42.05%   +36.27%     
===========================================
  Files           3      160      +157     
  Lines         277    10555    +10278     
===========================================
+ Hits           16     4439     +4423     
- Misses        260     5383     +5123     
- Partials        1      733      +732

@terencechain terencechain changed the title Don't delete boundary state Guard against deleting genesis and finalized state in DB Oct 24, 2019
@terencechain terencechain added the Ready For Review A pull request ready for code review label Oct 24, 2019
genesisBlockRoot := bkt.Get(genesisBlockRootKey)
// Safe guard against deleting genesis or finalized state.
if bytes.Equal(blockRoot[:], finalizedCheckpt.Root) || bytes.Equal(blockRoot[:], genesisBlockRoot) {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

This should be an error

prestonvanloon
prestonvanloon previously approved these changes Oct 24, 2019
@@ -104,8 +105,21 @@ func (k *Store) SaveState(ctx context.Context, state *pb.BeaconState, blockRoot
func (k *Store) DeleteState(ctx context.Context, blockRoot [32]byte) error {
ctx, span := trace.StartSpan(ctx, "BeaconDB.DeleteState")
defer span.End()

finalizedCheckpt, err := k.FinalizedCheckpoint(ctx)
Copy link
Member

@prestonvanloon prestonvanloon Oct 24, 2019

Choose a reason for hiding this comment

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

Can you do this in the batch tx? it would make it faster with batch processing / go routines

prestonvanloon
prestonvanloon previously approved these changes Oct 24, 2019
Copy link
Member

@prestonvanloon prestonvanloon left a comment

Choose a reason for hiding this comment

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

ok 😄

@prestonvanloon prestonvanloon merged commit ae1e435 into master Oct 24, 2019
@delete-merged-branch delete-merged-branch bot deleted the keep-finalized-state branch October 24, 2019 05:39
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.

Panic on startup
2 participants