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

blockmanager.go: use btcd libs to validate headers #283

Merged
merged 5 commits into from
Aug 17, 2023

Conversation

guggero
Copy link
Member

@guggero guggero commented Jul 14, 2023

Replaces #263.

This uses btcd's HeaderCtx and ChainCtx interfaces to be able to validate headers, both contextually and context-free. This allows neutrino to call blockchain.CheckBlockHeaderContext and blockchain.CheckBlockHeaderSanity. Also included is a check to assert that when neutrino receives a p2p headers message, that each header connects to the previous one.

Fixes #255

blockmanager_test.go Show resolved Hide resolved
@Roasbeef
Copy link
Member

Small linter error:

Error: blockmanager.go:33:2: `maxTimeOffset` is unused (deadcode)

@guggero
Copy link
Member Author

guggero commented Jul 26, 2023

Small linter error:

Oops, fixed.

blockmanager.go Show resolved Hide resolved
blockmanager.go Show resolved Hide resolved
@guggero guggero requested a review from Roasbeef July 28, 2023 07:36
Crypt-iQ and others added 5 commits August 4, 2023 10:41
This check was performed for both the reorg and non-reorg cases, but
in the reorg case the headers would count for PoW before validating
that the headers connected to one another.
This uses btcd's HeaderCtx and ChainCtx interfaces to be able to
validate headers, both contextually and context-free. This allows
neutrino to call blockchain.CheckBlockHeaderContext and
blockchain.CheckBlockHeaderSanity.
@lightninglabs-deploy
Copy link

@Roasbeef: review reminder
@guggero, remember to re-request review from reviewers when ready

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🪬

@Roasbeef Roasbeef merged commit 42a196f into lightninglabs:master Aug 17, 2023
4 checks passed
@guggero guggero deleted the context-header branch August 17, 2023 08:03
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.

Regtest: "block target difficulty is higher than max"
4 participants