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

core: fixed unwinding bad hash #3347

Merged
merged 1 commit into from
Nov 28, 2016
Merged

Conversation

obscuren
Copy link
Contributor

Fixed unwinding of bad hashes when already on the canon chain

@obscuren obscuren added this to the 1.5.4 milestone Nov 25, 2016
@mention-bot
Copy link

@obscuren, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zsfelfoldi, @karalabe and @fjl to be potential reviewers.

@obscuren obscuren force-pushed the unwind-fix branch 3 times, most recently from 7ee324e to 52d3a36 Compare November 26, 2016 10:17
@@ -152,6 +152,11 @@ func NewBlockChain(chainDb ethdb.Database, config *params.ChainConfig, pow pow.P
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
for hash, _ := range BadHashes {
if header := bc.GetHeaderByHash(hash); header != nil {
// make sure the headerByNumber (if present) is in our current canonical chain
if headerByNumber := bc.GetHeaderByNumber(header.Number.Uint64()); headerByNumber != nil && headerByNumber.Hash() != header.Hash() {
Copy link
Member

Choose a reason for hiding this comment

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

This check should be either of:

  • if headerByNumber != nil && headerByNumber.Hash() == header.Hash() { rewind }
  • if headerByNumber == nil || headerByNumber.Hash() != header.Hash() { continue } rewind

Although in theory the current implementation should also work, the conditions are imho not the cleanest combo :)

Fixed unwinding of bad hashes when already on the canon chain
@obscuren obscuren merged commit 801a13f into ethereum:master Nov 28, 2016
@obscuren obscuren deleted the unwind-fix branch November 28, 2016 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants