-
Notifications
You must be signed in to change notification settings - Fork 995
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
Conversation
Codecov Report
@@ 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 |
beacon-chain/db/kv/state.go
Outdated
genesisBlockRoot := bkt.Get(genesisBlockRootKey) | ||
// Safe guard against deleting genesis or finalized state. | ||
if bytes.Equal(blockRoot[:], finalizedCheckpt.Root) || bytes.Equal(blockRoot[:], genesisBlockRoot) { | ||
return nil |
There was a problem hiding this comment.
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
beacon-chain/db/kv/state.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok 😄
Change list:
SaveFinalizedCheckpoint
andrmStatesBySlots
DeleteState
against deleting genesis and finalized statesResolves #3841