-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
core: fix canonical hash marker update #24996
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2071,8 +2071,15 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error { | |
for _, tx := range types.HashDifference(deletedTxs, addedTxs) { | ||
rawdb.DeleteTxLookupEntry(indexesBatch, tx) | ||
} | ||
// Delete any canonical number assignments above the new head | ||
number := bc.CurrentBlock().NumberU64() | ||
deletedTxs, addedTxs = nil, nil // release the references in case the slices are huge | ||
|
||
// Delete all hash markers that are not part of the new canonical chain. | ||
// Because the reorg function does not handle new chain head, all hash | ||
// markers greater than or equal to new chain head should be deleted. | ||
number := commonBlock.NumberU64() | ||
if len(newChain) > 1 { | ||
number = newChain[1].NumberU64() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as So this PR only makes any change if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I don't quite get why it is the way it is,
Why not write out the head block too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the semantic of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes exactly. It mostly for this case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds good to me (just need to get the linter silent) |
||
} | ||
for i := number + 1; ; i++ { | ||
hash := rawdb.ReadCanonicalHash(bc.db, i) | ||
if hash == (common.Hash{}) { | ||
|
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.
Heh, the linter doesn't like this
Not sure what to do here.
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.
I think this can be dropped, the GC will figure out that these things are not used anymore and will clean them up
(afaik)
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.
done