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

fix: reject message (de)serialization #939

Merged
merged 2 commits into from Apr 20, 2022

Conversation

0xB10C
Copy link
Contributor

@0xB10C 0xB10C commented Apr 4, 2022

BIP-61 defines response-to-msg (Reject::message in rust-bitcoin; the message that triggered the reject) to be a var_str. However, by using the CommandString it was (de)serialized as 12 byte string. A test is added that de- and serializes two reject messages received from an older Bitcoin Core peer.

Reject message sending has been removed from Bitcoin Core, I'm still receiving them from older peers from time to time.

gh-ref: #323

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

FWIW, looks good to me.

@tcharding
Copy link
Member

I was surprised that this PR passed CI, I thought we had GitHub configured to ensure every patch passed but the first patch adds a failing test?

@RCasatta
Copy link
Collaborator

RCasatta commented Apr 5, 2022

The CI tests doesn't test every commit if you push them together.
But the policy is to have every commit passing to facilitate bisecting if needed, so @0xB10C could you please swap the commits?

@tcharding
Copy link
Member

Oh, awesome. Thanks for the explanation.

CommandString is (de)serialized as 12 bytes. However, BIP-61 defines
the 'response-to-msg' (message that triggered the reject) field
to be a var_str [1].

[1]: https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki#common-payload
This adds tests for the previously untested reject message
(de)serialization. The two reject messages were received from an
older Bitcoin Core peer that still sends reject messages.
@0xB10C
Copy link
Contributor Author

0xB10C commented Apr 5, 2022

Wasn't aware of the bisecting policy, but makes sense. Swaped the commits (fix, then test) and edited the commit description and the OP.

@tcharding
Copy link
Member

Thanks @0xB10C, this all looks good to me. Don't be surprised if this doesn't merge for a few days while 0.28 is being released.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 548725c

Since this is a bugfix I think we ought to slip it into 0.28.0. (On the other hand let's not hold up 0.28.0 for it.)

@apoelstra
Copy link
Member

Oops, we could've gotten this into 0.28, but I missed the second ACK, sorry. Too many github notifications..

@apoelstra apoelstra merged commit 954b8a9 into rust-bitcoin:master Apr 20, 2022
@0xB10C 0xB10C deleted the 2022-04-fix-reject-msg branch April 20, 2022 20:52
@apoelstra
Copy link
Member

@0xB10C how important is this bugfix to you? Should we try to push out a minor rev quickly?

(Right now that's possible but might not be in a few hours, depending what we merge.)

@0xB10C
Copy link
Contributor Author

0xB10C commented Apr 20, 2022

not important, but thanks for asking! I'm using a custom branch with this and a few other changes atm anyway.

ChallengeDev210 pushed a commit to ChallengeDev210/rust-bitcoin that referenced this pull request Aug 1, 2022
…ation

548725c test: reject message (de)serialization (0xb10c)
fc572ab fix: use var_str in 'reject' msgs (0xb10c)

Pull request description:

  [BIP-61 defines `response-to-msg`][bip61] (`Reject::message` in rust-bitcoin; the message that triggered the reject) to be a `var_str`. However, by using the `CommandString` it was (de)serialized as 12 byte string. A test is added that de- and serializes two reject messages received from an older Bitcoin Core peer.

  Reject message sending has been removed from Bitcoin Core, I'm still receiving them from older peers from time to time.

  [bip61]: https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki#common-payload

  gh-ref: rust-bitcoin/rust-bitcoin#323

ACKs for top commit:
  apoelstra:
    ACK 548725c

Tree-SHA512: e5cbf215a471f113b4dd7f7fada162686fc6e8c7b1e2e9e641667208a36d3db610e57e8b549756ffe597656fee5444fe95466f1b88f45366595766f7c4640eea
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.

None yet

4 participants