diff options
author | fanquake <fanquake@gmail.com> | 2022-09-01 07:40:28 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-09-01 07:45:42 +0100 |
commit | 6ab84709fc1dca62a7db4693e2ff72f40a7eb650 (patch) | |
tree | 45c32d63543672aefba942d531e0dabc6ac31895 /test | |
parent | 83434208035fda9c2b50df7b9f3ede896797cf04 (diff) | |
parent | 94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97 (diff) |
Merge bitcoin/bitcoin#25960: p2p: Headers-sync followups
94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97 Fix typo from PR25717 (Suhas Daftuar)
e5982ecdc4650e9b6de38f190f3a97d792499e2a Bypass headers anti-DoS checks for NoBan peers (Suhas Daftuar)
132ed7eaaa4a47ab94db72ebfab0ef0e03caa488 Move headerssync logging to BCLog::NET (Suhas Daftuar)
Pull request description:
Remove BCLog::HEADERSSYNC and move all headerssync logging to BCLog::NET.
Bypass headers anti-DoS checks for NoBan peers
Also fix a typo that was introduced in PR25717.
ACKs for top commit:
Sjors:
tACK 94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97
ajtowns:
ACK 94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97
sipa:
ACK 94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97
naumenkogs:
ACK 94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97
w0xlt:
ACK https://github.com/bitcoin/bitcoin/pull/25960/commits/94af3e43e20aa00b18e7a3f6d0f5fe3ad9494d97
Tree-SHA512: 612d594eddace977359bcc8234b2093d273fd50662f4ac70cb90903d28fb831f6e1aecff51a4ef6c0bb0f6fb5d1aa7ff1eb8798fac5ac142783788f3080717dc
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/p2p_headers_sync_with_minchainwork.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/test/functional/p2p_headers_sync_with_minchainwork.py b/test/functional/p2p_headers_sync_with_minchainwork.py index 6e17525c28..016375222d 100755 --- a/test/functional/p2p_headers_sync_with_minchainwork.py +++ b/test/functional/p2p_headers_sync_with_minchainwork.py @@ -28,9 +28,9 @@ NODE2_BLOCKS_REQUIRED = 2047 class RejectLowDifficultyHeadersTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True - self.num_nodes = 3 + self.num_nodes = 4 # Node0 has no required chainwork; node1 requires 15 blocks on top of the genesis block; node2 requires 2047 - self.extra_args = [["-minimumchainwork=0x0", "-checkblockindex=0"], ["-minimumchainwork=0x1f", "-checkblockindex=0"], ["-minimumchainwork=0x1000", "-checkblockindex=0"]] + self.extra_args = [["-minimumchainwork=0x0", "-checkblockindex=0"], ["-minimumchainwork=0x1f", "-checkblockindex=0"], ["-minimumchainwork=0x1000", "-checkblockindex=0"], ["-minimumchainwork=0x1000", "-checkblockindex=0", "-whitelist=noban@127.0.0.1"]] def setup_network(self): self.setup_nodes() @@ -40,17 +40,34 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework): def disconnect_all(self): self.disconnect_nodes(0, 1) self.disconnect_nodes(0, 2) + self.disconnect_nodes(0, 3) def reconnect_all(self): self.connect_nodes(0, 1) self.connect_nodes(0, 2) + self.connect_nodes(0, 3) def test_chains_sync_when_long_enough(self): self.log.info("Generate blocks on the node with no required chainwork, and verify nodes 1 and 2 have no new headers in their headers tree") with self.nodes[1].assert_debug_log(expected_msgs=["[net] Ignoring low-work chain (height=14)"]), self.nodes[2].assert_debug_log(expected_msgs=["[net] Ignoring low-work chain (height=14)"]): self.generate(self.nodes[0], NODE1_BLOCKS_REQUIRED-1, sync_fun=self.no_op) - for node in self.nodes[1:]: + # Node3 should always allow headers due to noban permissions + self.log.info("Check that node3 will sync headers (due to noban permissions)") + + def check_node3_chaintips(num_tips, tip_hash, height): + node3_chaintips = self.nodes[3].getchaintips() + assert(len(node3_chaintips) == num_tips) + assert { + 'height': height, + 'hash': tip_hash, + 'branchlen': height, + 'status': 'headers-only', + } in node3_chaintips + + check_node3_chaintips(2, self.nodes[0].getbestblockhash(), NODE1_BLOCKS_REQUIRED-1) + + for node in self.nodes[1:3]: chaintips = node.getchaintips() assert(len(chaintips) == 1) assert { @@ -63,7 +80,7 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework): self.log.info("Generate more blocks to satisfy node1's minchainwork requirement, and verify node2 still has no new headers in headers tree") with self.nodes[2].assert_debug_log(expected_msgs=["[net] Ignoring low-work chain (height=15)"]): self.generate(self.nodes[0], NODE1_BLOCKS_REQUIRED - self.nodes[0].getblockcount(), sync_fun=self.no_op) - self.sync_blocks(self.nodes[0:2]) + self.sync_blocks(self.nodes[0:2]) # node3 will sync headers (noban permissions) but not blocks (due to minchainwork) assert { 'height': 0, @@ -74,10 +91,13 @@ class RejectLowDifficultyHeadersTest(BitcoinTestFramework): assert(len(self.nodes[2].getchaintips()) == 1) - self.log.info("Generate long chain for node0/node1") + self.log.info("Check that node3 accepted these headers as well") + check_node3_chaintips(2, self.nodes[0].getbestblockhash(), NODE1_BLOCKS_REQUIRED) + + self.log.info("Generate long chain for node0/node1/node3") self.generate(self.nodes[0], NODE2_BLOCKS_REQUIRED-self.nodes[0].getblockcount(), sync_fun=self.no_op) - self.log.info("Verify that node2 will sync the chain when it gets long enough") + self.log.info("Verify that node2 and node3 will sync the chain when it gets long enough") self.sync_blocks() def test_peerinfo_includes_headers_presync_height(self): |