You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rewrite p2p-acceptblock in preparation for slight behavior changes
Removes checking whitelisted behavior (which will be removed, the
difference in behavior here makes little sense) and no longer
requires that blocks at the same work as our tip be dropped if not
requested (in part because we *do* request those blocks).
Github-Pull: #11531
Rebased-From: 3b4ac43
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test processing of unrequested blocks.
6
6
7
-
Since behavior differs when receiving unrequested blocks from whitelisted peers
8
-
versus non-whitelisted peers, this tests the behavior of both (effectively two
9
-
separate tests running in parallel).
7
+
Setup: two nodes, node0+node1, not connected to each other. Node1 will have
8
+
nMinimumChainWork set to 0x10, so it won't process low-work unrequested blocks.
10
9
11
-
Setup: three nodes, node0+node1+node2, not connected to each other. Node0 does not
12
-
whitelist localhost, but node1 does. They will each be on their own chain for
13
-
this test. Node2 will have nMinimumChainWork set to 0x10, so it won't process
14
-
low-work unrequested blocks.
15
-
16
-
We have one NodeConn connection to each, test_node, white_node, and min_work_node,
17
-
respectively.
10
+
We have one NodeConn connection to node0 called test_node, and one to node1
11
+
called min_work_node.
18
12
19
13
The test:
20
14
1. Generate one block on each node, to leave IBD.
21
15
22
16
2. Mine a new block on each tip, and deliver to each node from node's peer.
23
-
The tip should advance for node0 and node1, but node2 should skip processing
24
-
due to nMinimumChainWork.
17
+
The tip should advance for node0, but node1 should skip processing due to
18
+
nMinimumChainWork.
25
19
26
-
Node2 is unused in tests 3-7:
20
+
Node1 is unused in tests 3-7:
27
21
28
-
3. Mine a block that forks the previous block, and deliver to each node from
29
-
corresponding peer.
30
-
Node0 should not process this block (just accept the header), because it is
31
-
unrequested and doesn't have more work than the tip.
32
-
Node1 should process because this is coming from a whitelisted peer.
22
+
3. Mine a block that forks from the genesis block, and deliver to test_node.
23
+
Node0 should not process this block (just accept the header), because it
24
+
is unrequested and doesn't have more or equal work to the tip.
33
25
34
-
4. Send another block that builds on the forking block.
35
-
Node0 should process this block but be stuck on the shorter chain, because
36
-
it's missing an intermediate block.
37
-
Node1 should reorg to this longer chain.
26
+
4a,b. Send another two blocks that build on the forking block.
27
+
Node0 should process the second block but be stuck on the shorter chain,
28
+
because it's missing an intermediate block.
38
29
39
-
4b.Send 288 more blocks on the longer chain.
30
+
4c.Send 288 more blocks on the longer chain (the number of blocks ahead
31
+
we currently store).
40
32
Node0 should process all but the last block (too far ahead in height).
41
-
Send all headers to Node1, and then send the last block in that chain.
42
-
Node1 should accept the block because it's coming from a whitelisted peer.
43
33
44
34
5. Send a duplicate of the block in #3 to Node0.
45
35
Node0 should not process the block because it is unrequested, and stay on
@@ -52,7 +42,7 @@
52
42
7. Send Node0 the missing block again.
53
43
Node0 should process and the tip should advance.
54
44
55
-
8. Test Node2 is able to sync when connected to node0 (which should have sufficient
45
+
8. Test Node1 is able to sync when connected to node0 (which should have sufficient
0 commit comments