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

Implement getchaintips RPC #1912

Closed
Sjors opened this issue Nov 1, 2022 · 6 comments · Fixed by #1918
Closed

Implement getchaintips RPC #1912

Sjors opened this issue Nov 1, 2022 · 6 comments · Fixed by #1918

Comments

@Sjors
Copy link

Sjors commented Nov 1, 2022

The Bitcoin Core getchaintips RPC returns the list of known tip candidates, including which ones are considered invalid. This makes is easier for users (and automated systems) to figure out there's a potential consensus issue.

Specifically, ForkMonitor uses this to send out an alert if any block is considered valid by one implementation yet invalid by another.

@Crypt-iQ
Copy link
Collaborator

Crypt-iQ commented Nov 1, 2022

Technically, the block isn't invalid from a consensus PoV, but it's a wire parsing issue which would cause a network split

@Sjors
Copy link
Author

Sjors commented Nov 1, 2022

I suppose in that case it wouldn't show up as invalid in getchaintips? You'd at least see there's a headers chain with more work that's being ignored.

@Roasbeef
Copy link
Member

Roasbeef commented Nov 1, 2022

I suppose in that case it wouldn't show up as invalid in getchaintips?

In the case of the last block, it never made its way to block validation so validity was never able to be determined. Instead the block wasn't decoded, and the peer was disconnected.

@Sjors
Copy link
Author

Sjors commented Nov 1, 2022

A bit tangential, but if the block is not too large, and if we requested it (after checking the header PoW), and the checksum matches the header, that's probably enough DoS protection to go ahead and pass the block to the validation logic. In which case it would show up in getchaintips (but the original bug wouldn't have happened at all, because it would have passed the validation check).

@kcalvinalvin
Copy link
Collaborator

This shouldn't be too difficult to implement. I'll pick this up

@Roasbeef
Copy link
Member

Roasbeef commented Nov 2, 2022

and if we requested it (after checking the header PoW), and the checksum matches the header,

btcd understands the sendheaders message, but it never sends it itself. As a result, we only learn about new blocks via the inv hash, so we need to fetch the entire thing to verify it (we don't see the header first).

kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 7, 2022
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 7, 2022
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 7, 2022
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 7, 2022
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 9, 2022
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Nov 11, 2022
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
kcalvinalvin added a commit to kcalvinalvin/btcd that referenced this issue Jul 16, 2023
getchaintips call is implemented and the behavior mimics that of Bitcoin
Core. Resolves btcsuite#1912.
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 a pull request may close this issue.

4 participants