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

Add DeleteBlock() #10203

Merged
merged 5 commits into from
Feb 8, 2022
Merged

Add DeleteBlock() #10203

merged 5 commits into from
Feb 8, 2022

Conversation

potuz
Copy link
Contributor

@potuz potuz commented Feb 8, 2022

Exposes a method do delete blocks from DB. If the given root is for a finalized block, then the function panics.

@potuz potuz requested a review from a team as a code owner February 8, 2022 19:06
@potuz potuz requested review from kasey, terencechain and uncdr February 8, 2022 19:06
@potuz potuz added the Ready For Review A pull request ready for code review label Feb 8, 2022
return s.db.Update(func(tx *bolt.Tx) error {
bkt := tx.Bucket(finalizedBlockRootsIndexBucket)
if b := bkt.Get(root[:]); b != nil {
panic(errFinalizedInvalid)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
panic(errFinalizedInvalid)
return errFinalizedInvalid

Copy link
Contributor

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

Copy link
Member

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

Copy link
Contributor Author

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/error.go Outdated Show resolved Hide resolved
beacon-chain/db/kv/error.go Outdated Show resolved Hide resolved
return s.db.Update(func(tx *bolt.Tx) error {
bkt := tx.Bucket(finalizedBlockRootsIndexBucket)
if b := bkt.Get(root[:]); b != nil {
panic(errFinalizedInvalid)
Copy link
Member

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

@prylabs-bulldozer prylabs-bulldozer bot merged commit 18ef760 into develop Feb 8, 2022
@delete-merged-branch delete-merged-branch bot deleted the db_delete_block branch February 8, 2022 23:26
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.

3 participants