HomePhabricator

[Part 1] Core PR 11531: p2p-acceptblock improvements

Authored by Matt Corallo <git@bluematt.me> on Nov 28 2018, 20:11.

Description

[Part 1] Core PR 11531: p2p-acceptblock improvements

Summary:
This change includes test refactor and improvements from Core PR 11531:
3b4ac43 is nearly the entire diff, minus a few modifications to match
existing behavior. These parts of the test can be reverted to match
the backport once those behavior changes have been fully reviewed in
separate diffs.

Partial backport of Core PR 11531
Progress on T456

Co-authored-by: Jason B. Cox <contact@jasonbcox.com>

The only changes from the original Core commit are as follows:

diff --git a/test/functional/p2p-acceptblock.py b/test/functional/p2p-acceptblock.py
index c87e24532..9fd40b7ff 100755
--- a/test/functional/p2p-acceptblock.py
+++ b/test/functional/p2p-acceptblock.py
@@ -159,8 +159,13 @@ class AcceptBlockTest(BitcoinTestFramework):
         assert(tip_entry_found)

         # But this block should be accepted by node since it has equal work.
-        self.nodes[0].getblock(block_h2f.hash)
-        self.log.info("Second height 2 block accepted, but not reorg'ed to")
+        # FIXME: Replace the assert with the commented lines once Core backport
+        # 932f118 is completed. Current behavior does not accept equal work
+        # blocks ontop of unprocessed blocks.
+        #self.nodes[0].getblock(block_h2f.hash)
+        #self.log.info("Second height 2 block accepted, but not reorg'ed to")
+        assert_raises_rpc_error(-1, "Block not found on disk",
+                                self.nodes[0].getblock, block_h2f.hash)

         # 4b. Now send another block that builds on the forking chain.
         block_h3 = create_block(
@@ -262,6 +267,12 @@ class AcceptBlockTest(BitcoinTestFramework):
         # 7. Send the missing block for the third time (now it is requested)
         test_node.send_message(msg_block(block_h1f))

+        # 7.b. Send the next missing block now that it's requested.
+        # FIXME: Remove this line once Core backport 932f118 is completed.
+        # Current behavior is to not process equal work blocks building ontop
+        # of unprocessed blocks.
+        test_node.send_message(msg_block(block_h2f))
+
         test_node.sync_with_ping()
         assert_equal(self.nodes[0].getblockcount(), 290)
         self.nodes[0].getblock(all_blocks[286].hash)
@@ -347,7 +358,9 @@ class AcceptBlockTest(BitcoinTestFramework):
         headers_message = msg_headers()
         headers_message.headers.append(CBlockHeader(block_293))
         test_node.send_message(headers_message)
-        test_node.wait_for_disconnect()
+        # FIXME: Uncomment this line once Core backport 015a525 is completed.
+        # Current behavior does not ban peers that give us headers on invalid chains.
+        #test_node.wait_for_disconnect()

         # 9. Connect node1 to node0 and ensure it is able to sync
         connect_nodes(self.nodes[0], 1)

Test Plan: test_runner.py p2p-acceptblock

Reviewers: deadalnix, Fabien, #bitcoin_abc

Reviewed By: deadalnix, Fabien, #bitcoin_abc

Subscribers: teamcity

Differential Revision: https://reviews.bitcoinabc.org/D2149

Details

Committed
jasonbcoxDec 12 2018, 00:00
Pushed
jasonbcoxDec 12 2018, 00:00
Reviewer
Restricted Project
Differential Revision
D2149: [Part 1] Core PR 11531: p2p-acceptblock improvements
Parents
rABC70b73611affe: Add backporting suggestion to CONTRIBUTING.md
Branches
Unknown
Tags
Unknown

Event Timeline

jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).
jasonbcox committed rABCe55fb9e61eee: [Part 1] Core PR 11531: p2p-acceptblock improvements (authored by Matt Corallo <git@bluematt.me>).