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

Merged
merged 2 commits into from Dec 10, 2015

Conversation

Projects
None yet
4 participants
@laanwj
Member

laanwj commented Dec 7, 2015

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

net: Fix sent reject messages for blocks and transactions
Ever since we #5913 have been sending invalid reject messages
for transactions and blocks.
@dcousens

This comment has been minimized.

Show comment
Hide comment
@dcousens

dcousens Dec 7, 2015

Contributor

Worth adding a regression test?

Contributor

dcousens commented Dec 7, 2015

Worth adding a regression test?

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Dec 7, 2015

Member

Would make sense.

Member

laanwj commented Dec 7, 2015

Would make sense.

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Dec 8, 2015

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
Member

MarcoFalke commented Dec 8, 2015

utACK 9fc6ed6

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Dec 8, 2015

Member

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

Member

laanwj commented Dec 8, 2015

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

test: Add basic test for `reject` code
Extend P2P test framework to make it possible to expect reject
codes for transactions and blocks.
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Dec 9, 2015

Member

@sdaftuar Mind taking a look at the test changes?

Member

laanwj commented Dec 9, 2015

@sdaftuar Mind taking a look at the test changes?

@sdaftuar

This comment has been minimized.

Show comment
Hide comment
@sdaftuar

sdaftuar Dec 9, 2015

Member
Member

sdaftuar commented Dec 9, 2015

@sdaftuar

This comment has been minimized.

Show comment
Hide comment
@sdaftuar

sdaftuar Dec 9, 2015

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?

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.

Show comment
Hide comment
@sdaftuar

sdaftuar Dec 9, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Dec 10, 2015

Owner

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).

Owner

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

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Dec 10, 2015

Merge pull request #7179
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

net: Fix sent reject messages for blocks and transactions
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

This comment has been minimized.

Show comment
Hide comment
@sdaftuar

sdaftuar Dec 10, 2015

Member

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

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

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: 2041190

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jan 10, 2016

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: 2041190
@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Feb 4, 2016

Member

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

Member

laanwj commented Feb 4, 2016

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

@laanwj laanwj removed the Needs backport label Feb 4, 2016

@str4d str4d referenced this pull request in zcash/zcash Jul 14, 2017

Open

Bitcoin 0.12 P2P/Net PRs 1 #2534

@dagurval dagurval referenced this pull request in bitcoinxt/bitcoinxt Aug 9, 2017

Merged

Add comptool.RejectResult #238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment