|
33 | 33 | block #1 that is not part of the assumevalid chain. |
34 | 34 | - node5 starts with no -assumevalid parameter. Reindex to hit |
35 | 35 | "assumevalid hash not in headers" and "below minimum chainwork". |
| 36 | + - node6 has -assumevalid set to the hash of block 102. Reindex |
| 37 | + with assumevalid to check that script verification is skipped during |
| 38 | + reindexing. |
36 | 39 | """ |
37 | 40 |
|
38 | 41 | from test_framework.blocktools import ( |
@@ -69,7 +72,7 @@ def send_header_for_blocks(self, new_blocks): |
69 | 72 | class AssumeValidTest(BitcoinTestFramework): |
70 | 73 | def set_test_params(self): |
71 | 74 | self.setup_clean_chain = True |
72 | | - self.num_nodes = 6 |
| 75 | + self.num_nodes = 7 |
73 | 76 | self.rpc_timeout = 120 |
74 | 77 |
|
75 | 78 | def setup_network(self): |
@@ -148,6 +151,7 @@ def run_test(self): |
148 | 151 | self.start_node(3, extra_args=[f"-assumevalid={block102.hash_hex}"]) |
149 | 152 | self.start_node(4, extra_args=[f"-assumevalid={block102.hash_hex}"]) |
150 | 153 | self.start_node(5) |
| 154 | + self.start_node(6, extra_args=[f"-assumevalid={block102.hash_hex}"]) |
151 | 155 |
|
152 | 156 |
|
153 | 157 | # nodes[0] |
@@ -253,6 +257,27 @@ def run_test(self): |
253 | 257 | self.restart_node(5, extra_args=["-reindex-chainstate", f"-assumevalid={block102.hash_hex}", "-minimumchainwork=0xffff"]) |
254 | 258 | assert_equal(self.nodes[5].getblockcount(), 1) |
255 | 259 |
|
| 260 | + # nodes[6] |
| 261 | + # Reindex with assumevalid set to block102. Should skip script verification |
| 262 | + p2p6 = self.nodes[6].add_p2p_connection(BaseNode()) |
| 263 | + p2p6.send_header_for_blocks(self.blocks[0:2000]) |
| 264 | + p2p6.send_header_for_blocks(self.blocks[2000:]) |
| 265 | + for block in self.blocks[0:101]: |
| 266 | + p2p6.send_without_ping(msg_block(block)) |
| 267 | + self.wait_until(lambda: self.nodes[6].getblockcount() == 101) |
| 268 | + # Set minimumchainwork > 2000 blocks to force background init thread |
| 269 | + # to wait for best_header to reach 2 weeks before connecting blocks. |
| 270 | + self.restart_node(6, extra_args=["-reindex", f"-assumevalid={block102.hash_hex}", "-minimumchainwork=0x0fd2"]) |
| 271 | + p2p6 = self.nodes[6].add_p2p_connection(BaseNode()) |
| 272 | + with self.nodes[6].assert_debug_log(expected_msgs=[ |
| 273 | + f"Disabling script verification at block #1 ({self.blocks[0].hash_hex}).", |
| 274 | + ]): |
| 275 | + p2p6.send_header_for_blocks(self.blocks[0:2000]) |
| 276 | + p2p6.send_header_for_blocks(self.blocks[2000:]) |
| 277 | + # Resend headers because HeadersSync m_download_state will be in REDOWNLOAD |
| 278 | + p2p6.send_header_for_blocks(self.blocks[0:2000]) |
| 279 | + p2p6.send_header_for_blocks(self.blocks[2000:]) |
| 280 | + self.wait_until(lambda: self.nodes[6].getblockcount() == 101) |
256 | 281 |
|
257 | 282 | if __name__ == '__main__': |
258 | 283 | AssumeValidTest(__file__).main() |
0 commit comments