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

[Bug] peer: prevent last block height going backwards #392

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

zquestz
Copy link
Contributor

@zquestz zquestz commented Jul 22, 2020

Fix from btcsuite/btcd#1606

This modifies the UpdateLastBlockHeight function to ensure the new
height is after the existing height before updating it in order to
prevent it from going backwards so it properly matches the intent of the
function which is to report the latest known block height for the peer.

Without this change, the value will properly start out at the latest
known block height reported by the peer during version negotiation,
however, it will be set to lower values when syncing from the peer due
to requesting old blocks and blindly updating the height.

It also adds a test to ensure proper functionality.

This is a backport of decred/dcrd#1747

I think this might be the issue we see when syncing in Neutrino and the sync progress jumps around!

@zquestz zquestz requested a review from cpacia July 22, 2020 06:19
@cpacia cpacia merged commit 5aa76f7 into master Jul 23, 2020
@cpacia cpacia deleted the peer-height-backwards branch March 16, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants