-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
blockchain: refactor and export header validation checks #1931
Conversation
Pull Request Test Coverage Report for Build 5415613990
💛 - Coveralls |
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.
Looks good! Only blocking comments are about the nil checks vs. interfaces (need to also read up on the specifics, when a normal nil check works and when not).
You can nil-check an interface, but it's a bit weird. See here: https://go.dev/play/p/9NVSUoFo2oI If |
Aaah, I see. Thanks for the example. I guess that makes sense. That's why you had that explicit |
I do wonder if there's not a way to get around nil-checking and to instead use some dummy value to compare against |
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.
Left some comments, this pattern is kind of worrying since I feel like I've seen it before in our codebases, but can't exactly grep for it
7abd38f
to
7abdd05
Compare
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.
LGTM 🌪️
7abdd05
to
cd583a4
Compare
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.
LGTM 🎉
Changed |
This change will allow an external program to provide its own HeaderCtx and ChainCtx and be able to perform contextual block header checks.
cd583a4
to
ee6c0e1
Compare
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.
LGTM 🧱
This PR allows an external library like
neutrino
to be able to perform contextual and context-free header validation. This is achieved by introducing two new interfacesHeaderCtx
(which replaces*blockNode
in the relevant functions) andChainCtx
(which replaces*BlockChain
in the relevant functions). A library calling into these functions needs to only satisfy the interface to be able to validate any received headers.