Skip to content

Commit 7f83f8d

Browse files
authored
Merge pull request bitcoin#352 from ptschip/dev_assert
Handle a special case for Parallel Validation
2 parents 6218ac2 + 92bab68 commit 7f83f8d

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

qa/rpc-tests/parallel.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ def setup_network(self, split=False):
2323
self.nodes.append(start_node(1, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
2424
self.nodes.append(start_node(2, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
2525
self.nodes.append(start_node(3, self.options.tmpdir, ["-parallel=0", "-rpcservertimeout=0", "-debug", "-use-thinblocks=0", "-excessiveblocksize=6000000", "-blockprioritysize=6000000", "-blockmaxsize=6000000"]))
26-
connect_nodes(self.nodes[0],1)
27-
connect_nodes(self.nodes[0],2)
28-
connect_nodes(self.nodes[0],3)
26+
interconnect_nodes(self.nodes)
2927
self.is_network_split=False
3028
self.sync_all()
3129

@@ -367,7 +365,7 @@ def run_test (self):
367365
sync_blocks(self.nodes)
368366

369367

370-
# Mine a block which will cause a reorg.
368+
# Mine a block which will cause a reorg back to node0
371369
print ("Mine another block...")
372370
self.nodes[0].generate(1)
373371
sync_blocks(self.nodes)

src/main.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3053,7 +3053,14 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
30533053
{
30543054
AssertLockHeld(cs_main);
30553055

3056-
assert(pindexNew->pprev == chainActive.Tip());
3056+
// With PV there is a special case where one chain may be in the process of connecting several blocks but then
3057+
// a second chain also begins to connect blocks and its block beat the first chains block to advance the tip.
3058+
// As a result pindexNew->prev on the first chain will no longer match the chaintip as the second chain continues
3059+
// connecting blocks. Therefore we must return "false" rather than "assert" as was previously the case.
3060+
//assert(pindexNew->pprev == chainActive.Tip());
3061+
if (pindexNew->pprev != chainActive.Tip())
3062+
return false;
3063+
30573064
// Read block from disk.
30583065
int64_t nTime1 = GetTimeMicros();
30593066
CBlock block;

0 commit comments

Comments
 (0)