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

p2p: Disable BIP 61 by default #14054

Merged
merged 2 commits into from
Sep 10, 2018
Merged

p2p: Disable BIP 61 by default #14054

merged 2 commits into from
Sep 10, 2018

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Aug 24, 2018

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.

@jnewbery
Copy link
Contributor

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?

@maflcko maflcko force-pushed the Mf1808-noBIP61 branch 2 times, most recently from e7f5785 to d3abdc2 Compare August 24, 2018 21:00
@gmaxwell
Copy link
Contributor

Concept ACK.

@maflcko
Copy link
Member Author

maflcko commented Aug 24, 2018

@jnewbery Added back one test case for -enablebip61

@laanwj
Copy link
Member

laanwj commented Aug 27, 2018

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.

Copy link
Contributor

@jnewbery jnewbery left a 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"""
Copy link
Contributor

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."""
Copy link
Contributor

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

@@ -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
Copy link
Contributor

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

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
Copy link
Contributor

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):
Copy link
Contributor

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)

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']]
Copy link
Contributor

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.

@@ -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)
Copy link
Contributor

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.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 29, 2018

No more conflicts as of last run.

@luke-jr
Copy link
Member

luke-jr commented Aug 30, 2018

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.

@jnewbery
Copy link
Contributor

jnewbery commented Sep 6, 2018

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.

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:

@@ -824,7 +824,7 @@ class FullBlockTest(BitcoinTestFramework):
         tx.vin.append(CTxIn(COutPoint(b64a.vtx[1].sha256, 0)))
         b64a = self.update_block("64a", [tx])
         assert_equal(len(b64a.serialize()), MAX_BLOCK_BASE_SIZE + 8)
-        self.sync_blocks([b64a], success=False, reject_code=1, reject_reason=b'error parsing message')
+        self.sync_blocks([b64a], success=False, reject_reason='non-canonical ReadCompactSize(): iostream error')

@maflcko
Copy link
Member Author

maflcko commented Sep 6, 2018

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

@jnewbery
Copy link
Contributor

jnewbery commented Sep 7, 2018

Please help review that first.

Yes, fine (although a note to say that this PR isn't seeking review would have been helpful!)

@maflcko maflcko force-pushed the Mf1808-noBIP61 branch 2 times, most recently from 29d8e45 to fa14b54 Compare September 8, 2018 20:44
@ken2812221
Copy link
Contributor

utACK faea5bf

@jnewbery
Copy link
Contributor

tested ACK faea5bf

@laanwj laanwj merged commit faea5bf into bitcoin:master Sep 10, 2018
laanwj added a commit that referenced this pull request Sep 10, 2018
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
@maflcko maflcko deleted the Mf1808-noBIP61 branch September 10, 2018 17:12
maflcko pushed a commit that referenced this pull request Mar 14, 2019
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
laanwj added a commit that referenced this pull request Mar 16, 2019
…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
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 9, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2021
…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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
…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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
…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
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Jul 1, 2021
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
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Sep 21, 2021
…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
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Sep 21, 2021
…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
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Sep 27, 2021
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants