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

net: Fix sent reject messages for blocks and transactions #7179

Merged
merged 2 commits into from Dec 10, 2015

Conversation

@laanwj
Copy link
Member

laanwj commented Dec 7, 2015

Ever since we #5913 have been sending invalid reject messages for transactions and blocks.

Ever since we #5913 have been sending invalid reject messages
for transactions and blocks.
@dcousens
Copy link
Contributor

dcousens commented Dec 7, 2015

Worth adding a regression test?

@laanwj
Copy link
Member Author

laanwj commented Dec 7, 2015

Would make sense.

@laanwj
Copy link
Member Author

laanwj commented Dec 8, 2015

To be clear, this solves the following issue:

Normal reject message

2015-12-07 20:16:52 peer=1096 Reject tx code 64: non-final: hash 54fae12b1dc553ec56137138ad28304569c9b3a69791fca5a02664b379a7d6ba

Reject message from 0.11.99+

2015-12-04 16:07:00 peer=322 Reject tx code 66: : hash 6e6f69746361736e617274206565726620646574696d696c20657461721d0000

Reason seems empty, and part of the reason message ends up in the "hash". This is due to the reject code being sent as multiple bytes instead of one, misaligning the message.

Edit: trying to think of a test. Hopefully it could fit somewhere in the Python P2P test framework, without creating a new script.

@laanwj laanwj added this to the 0.12.0 milestone Dec 8, 2015
@MarcoFalke
Copy link
Member

MarcoFalke commented Dec 8, 2015

utACK 9fc6ed6

@laanwj
Copy link
Member Author

laanwj commented Dec 8, 2015

Added basic tests for rejection of blocks and transactions.
(tested that they pass with this patch, and fail without)

@laanwj laanwj force-pushed the laanwj:2015_12_fix_reject_message branch 3 times, most recently Dec 8, 2015
Extend P2P test framework to make it possible to expect reject
codes for transactions and blocks.
@laanwj laanwj force-pushed the laanwj:2015_12_fix_reject_message branch to 2041190 Dec 9, 2015
@laanwj
Copy link
Member Author

laanwj commented Dec 9, 2015

@sdaftuar Mind taking a look at the test changes?

@sdaftuar
Copy link
Member

sdaftuar commented Dec 9, 2015

@sdaftuar

This comment has been minimized.

Would it make sense for this object to also check the other parts of the reject message? For instance you noted in this PR that the block hash being returned in the reject message was incorrect; any reason not to check that as well?

This comment has been minimized.

Copy link

sdaftuar replied Dec 9, 2015

Disregard, just realized that you use the data field to store the reject message.

This comment has been minimized.

Copy link
Owner Author

laanwj replied Dec 10, 2015

Right - it checks every field, the hash (used for addressing), the code, even 'reason' which isn't strictly defined by any BIP, but according to our own convention where the prefix is an abbreviated error name (hence the starts_with).

@laanwj laanwj merged commit 2041190 into bitcoin:master Dec 10, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
laanwj added a commit that referenced this pull request Dec 10, 2015
2041190 test: Add basic test for `reject` code (Wladimir J. van der Laan)
9fc6ed6 net: Fix sent reject messages for blocks and transactions (Wladimir J. van der Laan)
laanwj added a commit that referenced this pull request Dec 10, 2015
Ever since we #5913 have been sending invalid reject messages
for transactions and blocks.

test: Add basic test for `reject` code

Extend P2P test framework to make it possible to expect reject
codes for transactions and blocks.

Github-Pull: #7179
Rebased-From: 9fc6ed6 2041190
@sdaftuar
Copy link
Member

sdaftuar commented Dec 10, 2015

post-merge ACK. The extension to the test framework seems like a good idea!

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jan 10, 2016
Extend P2P test framework to make it possible to expect reject
codes for transactions and blocks.

Github-Pull: bitcoin#7179
Rebased-From: 2041190
luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jan 10, 2016
Extend P2P test framework to make it possible to expect reject
codes for transactions and blocks.

Github-Pull: bitcoin#7179
Rebased-From: 2041190
@laanwj
Copy link
Member Author

laanwj commented Feb 4, 2016

This is cherry-picked to 0.12 as 44fef99, removing needs backport label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.