-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add DeleteBlock() #10203
Add DeleteBlock() #10203
Conversation
beacon-chain/db/kv/blocks.go
Outdated
return s.db.Update(func(tx *bolt.Tx) error { | ||
bkt := tx.Bucket(finalizedBlockRootsIndexBucket) | ||
if b := bkt.Get(root[:]); b != nil { | ||
panic(errFinalizedInvalid) |
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.
panic(errFinalizedInvalid) | |
return errFinalizedInvalid |
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.
Do we need to delete the associated state as well? States are stored by block root I believe
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.
+1
We shouldn't panic. Panic shouldn't be a DB behavior, rather a caller side behavior. Otherwise, we are assuming DeleteBlock
could only be used for optimistic syncing
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.
Indeed, this was moved from my implementation in Kintsugi that was only for optimistic sync, I think it's fixed now, will panic in the caller but that's going to be in the Kintsugi branch
beacon-chain/db/kv/blocks.go
Outdated
return s.db.Update(func(tx *bolt.Tx) error { | ||
bkt := tx.Bucket(finalizedBlockRootsIndexBucket) | ||
if b := bkt.Get(root[:]); b != nil { | ||
panic(errFinalizedInvalid) |
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.
+1
We shouldn't panic. Panic shouldn't be a DB behavior, rather a caller side behavior. Otherwise, we are assuming DeleteBlock
could only be used for optimistic syncing
Exposes a method do delete blocks from DB. If the given root is for a finalized block, then the function panics.