-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
p2p: Disable BIP 61 by default #14054
Conversation
fad16a6
to
558bb75
Compare
Concept ACK! The changes to the test framework remove all testing of the p2p REJECT message. Shouldn't we maintain at least some minor testing of REJECT, unless(/until) REJECT is removed entirely? |
e7f5785
to
d3abdc2
Compare
Concept ACK. |
d3abdc2
to
fa17b5a
Compare
@jnewbery Added back one test case for |
Concept ACK I'm not convinced about removing REJECT completely, I think it is useful for testing and development (and have used it for that purpose a few times, for example during development of bitcoin-submittx). However I fully agree on the reasoning behind disabling it by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A few comments inline.
@@ -492,66 +485,59 @@ def send_blocks_and_test(self, blocks, rpc, success=True, request_block=True, re | |||
ensure that any getdata messages are responded to | |||
- if success is True: assert that the node's tip advances to the most recent block | |||
- if success is False: assert that the node's tip doesn't advance | |||
- if reject_code and reject_reason are set: assert that the correct reject message is received""" | |||
- if reject_code and reject_reason are set: assert that the correct reject message is logged""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/reject_code and reject_reason are/reject_reason is
"""Send txs to test node and test whether they're accepted to the mempool. | ||
|
||
- add all txs to our tx_store | ||
- send tx messages for all txs | ||
- if success is True/False: assert that the txs are/are not accepted to the mempool | ||
- if expect_disconnect is True: Skip the sync with ping | ||
- if reject_code and reject_reason are set: assert that the correct reject message is received.""" | ||
- if reject_code and reject_reason are set: assert that the correct reject message is logged.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/reject_code and reject_reason are/reject_reason is
test/functional/p2p_invalid_tx.py
Outdated
@@ -143,9 +143,6 @@ def run_test(self): | |||
"disconnecting peer=0", | |||
]): | |||
node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True) | |||
# send_txs_and_test will have waited for disconnect, so we can safely check that no reject has been received |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole sub-test can be removed (everything from # restart node with sending BIP61 messages disabled, check that it disconnects without sending the reject message
onward)
You could also update L71 higher up to test the reject reason:
+++ b/test/functional/p2p_invalid_tx.py
@@ -68,7 +68,8 @@ class InvalidTxRequestTest(BitcoinTestFramework):
# and we get disconnected immediately
self.log.info('Test a transaction that is rejected')
tx1 = create_tx_with_script(block1.vtx[0], 0, script_sig=b'\x64' * 35, amount=50 * COIN - 12000)
- node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True)
+ node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True,
+ reject_reason="{} from peer=0 was not accepted: mandatory-script-verify-flag-failed (Invalid OP_IF construction) (code 16)".format(tx1.hash))
test/functional/feature_dersig.py
Outdated
assert_equal(self.nodes[0].p2p.last_message["reject"].reason, b'block-validation-failed') | ||
else: | ||
assert b'Non-canonical DER signature' in self.nodes[0].p2p.last_message["reject"].reason | ||
assert b'Non-canonical DER signature' in self.nodes[0].p2p.last_message["reject"].reason |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a mild preference to test reject messages in their own test case (p2p_reject.py
), but not strongly enough to block this PR.
@@ -165,11 +165,11 @@ def create_test_block(self, txs, version=536870912): | |||
block.solve() | |||
return block | |||
|
|||
def sync_blocks(self, blocks, success=True, reject_code=None, reject_reason=None, request_block=True): | |||
def sync_blocks(self, blocks, success=True, *, reject_reason=None, request_block=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the calls to this function actually use the optional parameters, so this can be simplified to:
+++ b/test/functional/feature_csv_activation.py
@@ -165,11 +165,11 @@ class BIP68_112_113Test(BitcoinTestFramework):
block.solve()
return block
- def sync_blocks(self, blocks, success=True, *, reject_reason=None, request_block=True):
+ def sync_blocks(self, blocks, success=True):
"""Sends blocks to test node. Syncs and verifies that tip has advanced to most recent block.
Call with success = False if the tip shouldn't advance to the most recent block."""
- self.nodes[0].p2p.send_blocks_and_test(blocks, self.nodes[0], success=success, reject_reason=reject_reason, request_block=request_block, expect_disconnect=False, timeout=60)
+ self.nodes[0].p2p.send_blocks_and_test(blocks, self.nodes[0], success=success)
test/functional/feature_cltv.py
Outdated
class BIP65Test(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
self.extra_args = [['-whitelist=127.0.0.1']] | ||
self.extra_args = [['-whitelist=127.0.0.1', '-par=1']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment to explain why par=1
is needed.
test/functional/feature_block.py
Outdated
@@ -169,7 +169,7 @@ def run_test(self): | |||
self.log.info("Reject a block where the miner creates too much coinbase reward") | |||
self.move_tip(6) | |||
b9 = self.next_block(9, spend=out[4], additional_coinbase_value=1) | |||
self.sync_blocks([b9], False, 16, b'bad-cb-amount', reconnect=True) | |||
self.sync_blocks([b9], False, 'coinbase pays too much (actual=10000000000 vs limit=9999999999)', reconnect=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if all calls to sync_blocks
used named argument for reject_reason
, but that change should be in a future PR.
fa17b5a
to
ec1b32d
Compare
No more conflicts as of last run. |
ec1b32d
to
d3b57b2
Compare
Reject may be useful (necessary) for tracking the best-block of peers and making sure our "essential" peers are using the same consensus rules as we are. Until we have reliable peer best-block tracking implemented, I suggest we leave reject alone. |
ecb53e8
to
7d46692
Compare
bitcoind does not track peers' best blocks or consensus rules using REJECT messages. In fact, all it does with REJECT messages is log (if NET logging is enabled) and drop. I don't think it makes sense to continue sending REJECT messages on the basis that they 'may' be used for something in future. This breaks on master in feature_block.py. You need this change:
|
@jnewbery I will rebase this on
to get rid of all test changes and leave this a one-line change. Please help review that first. |
Yes, fine (although a note to say that this PR isn't seeking review would have been helpful!) |
29d8e45
to
fa14b54
Compare
utACK faea5bf |
tested ACK faea5bf |
faea5bf doc: release notes for -enablebip61 default change (MarcoFalke) fa14b54 p2p: Disable BIP 61 by default (MarcoFalke) Pull request description: The live p2p network should not be used for debugging or as development aid when implementing the p2p protocol. Instead, applications should be tested locally (e.g. by inspecting the debug log of a validating node on the local network) Using the p2p network for this purpose seems wasteful and even dangerous, as peers can not be trusted to send the correct reject messages or a reject message at all. Tree-SHA512: 9c91ad035b5110942172a3b4b8a332a84e0c0aa9ee80f8134aeab63e66ac604841e68b04038681c288b716e5e0cbe38065eb5c7eb63fa72c3bdb3255a4b2d99d
a756363 [docs] document BIP 61 deprecation (John Newbery) da14d90 [p2p] Enable BIP 61 REJECT messages by default (John Newbery) Pull request description: This PR reverts #14054 following discussion on the bitcoin-dev mailing list. It also adds release notes to clearly document that the `enablebip61` option will be disabled by default in a future release before being removed entirely. Tree-SHA512: 0c9162045a4fb95689a0cb2de19f98a83636c9a6fb7ffa6809773b593c6c00b14e0480683e4d1c48e9b7f90e89cf7c2dca18bff42f5d2da2a43c522039e9f1ee
…fault 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
Summary: faea5bfc5a975874acf763082852ed532ed81a95 doc: release notes for -enablebip61 default change (MarcoFalke) fa14b54a872ef0ff755e3c1c0775904ca33cb5ff p2p: Disable BIP 61 by default (MarcoFalke) Pull request description: The live p2p network should not be used for debugging or as development aid when implementing the p2p protocol. Instead, applications should be tested locally (e.g. by inspecting the debug log of a validating node on the local network) Using the p2p network for this purpose seems wasteful and even dangerous, as peers can not be trusted to send the correct reject messages or a reject message at all. Tree-SHA512: 9c91ad035b5110942172a3b4b8a332a84e0c0aa9ee80f8134aeab63e66ac604841e68b04038681c288b716e5e0cbe38065eb5c7eb63fa72c3bdb3255a4b2d99d Backport of Core [[bitcoin/bitcoin#14054 | PR14054]] Test Plan: ninja ninja check ninja check-functional Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6455
…s by default 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (bitcoin#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
…s by default 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (bitcoin#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
…s by default 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (bitcoin#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
faea5bf doc: release notes for -enablebip61 default change (MarcoFalke) fa14b54 p2p: Disable BIP 61 by default (MarcoFalke) Pull request description: The live p2p network should not be used for debugging or as development aid when implementing the p2p protocol. Instead, applications should be tested locally (e.g. by inspecting the debug log of a validating node on the local network) Using the p2p network for this purpose seems wasteful and even dangerous, as peers can not be trusted to send the correct reject messages or a reject message at all. Tree-SHA512: 9c91ad035b5110942172a3b4b8a332a84e0c0aa9ee80f8134aeab63e66ac604841e68b04038681c288b716e5e0cbe38065eb5c7eb63fa72c3bdb3255a4b2d99d # Conflicts: # doc/release-notes.md
…s by default 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (bitcoin#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
…s by default 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (bitcoin#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
…s by default 92f3e80 [docs] release note for disabling reject messages by default (John Newbery) Pull request description: v0.18 deprecated BIP 61 REJECT messages. v0.19 disables them by default (bitcoin#14054). This adds a release note to document that. BIP 61 REJECT messages will be removed entirely in a future version. Tree-SHA512: 575b7e2800c40cd47b8704abb3ab1e5acdd266ece7209a629e47fed1a88ca94bc0858591e8707b157e913385360a43f2695ecaae81e9881dc2a9b3c9391c80c2
The live p2p network should not be used for debugging or as development aid when implementing the p2p protocol. Instead, applications should be tested locally (e.g. by inspecting the debug log of a validating node on the local network)
Using the p2p network for this purpose seems wasteful and even dangerous, as peers can not be trusted to send the correct reject messages or a reject message at all.