Skip to content

Add BIP324 V2 p2p network message support#3792

Merged
apoelstra merged 1 commit into
rust-bitcoin:masterfrom
nyonson:add-v2-network-message-encoding
Jan 9, 2025
Merged

Add BIP324 V2 p2p network message support#3792
apoelstra merged 1 commit into
rust-bitcoin:masterfrom
nyonson:add-v2-network-message-encoding

Conversation

@nyonson

@nyonson nyonson commented Dec 19, 2024

Copy link
Copy Markdown
Contributor

Migrating over the BIP324's library's V2 network message encoding and decoding. As discussed over in #2959, this is probably the natural home for it and also cleans up some gross copy/pasta of some of the encoding/decoding chain logic.

This patch adds V2NetworkMessage which wraps a NetworkMessage, but handles the V2 encoding and decoding. It is a parallel of the existing RawNetworkMessage (which mentioned before, may be better described as V1NetworkMessage #3157). A priority of this patch was to not re-invent any wheels and try to use the existing patterns as much as possible.

@github-actions github-actions Bot added the C-bitcoin PRs modifying the bitcoin crate label Dec 19, 2024
Comment thread bitcoin/src/p2p/message.rs Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ideally this error returned the unknown short ID, but I think this requires a change to the encode::ParseError which lives over in the concensus module...not sure if we want to touch that API at the moment with all the refactoring.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good decision. The consensus::ParseErrror is horrible, I linked to this comment in #3795.

@nyonson nyonson force-pushed the add-v2-network-message-encoding branch from 06067ee to ba99a07 Compare January 6, 2025 17:20
@coveralls

coveralls commented Jan 6, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 12645318125

Details

  • 169 of 182 (92.86%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 83.035%

Changes Missing Coverage Covered Lines Changed/Added Lines %
bitcoin/src/p2p/message.rs 169 182 92.86%
Totals Coverage Status
Change from base Build 12634085718: 0.07%
Covered Lines: 20856
Relevant Lines: 25117

💛 - Coveralls

@nyonson nyonson marked this pull request as ready for review January 6, 2025 17:56
tcharding
tcharding previously approved these changes Jan 6, 2025

@tcharding tcharding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK ba99a078ac9014bb402d510b4daac22ca8987973

Comment thread bitcoin/src/p2p/message.rs Outdated
@tcharding

Copy link
Copy Markdown
Member

Formatting changes have snuck in mate (and stable ones at that :)

BIP324 introduced the second version of p2p network messages which
are designed to be used with the new encrypted transport. This patch
adds a V2NetworkMessage type which wraps a NetworkMessage and handles
the V2 encoding and decoding. It is a parallel of the existing
RawNetworkMessage type (which may be better described as
V1NetworkMessage). A priority of this patch was to not re-invent any
wheels and try to use the existing patterns as much as possible.
@nyonson nyonson force-pushed the add-v2-network-message-encoding branch from bd39623 to e09bdb5 Compare January 7, 2025 04:41
@nyonson

nyonson commented Jan 7, 2025

Copy link
Copy Markdown
Contributor Author

Formatting changes have snuck in mate (and stable ones at that :)

Oof my bad, iron'd out.

@tcharding tcharding left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK e09bdb5

@tcharding

Copy link
Copy Markdown
Member

Thanks man, nice one.

@apoelstra apoelstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK e09bdb5; successfully ran local tests; nice!

@apoelstra apoelstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK e09bdb5; successfully ran local tests; nice!

@apoelstra apoelstra merged commit 653ea70 into rust-bitcoin:master Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bitcoin PRs modifying the bitcoin crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants