Merge pull request #6140

8f0947b Increase timeouts in pruning.py and modify warning language. (Alex Morcos)
b89f307 Fix incorrect variable name in FindFilesToPrune (Suhas Daftuar)
This commit is contained in:
Wladimir J. van der Laan 2015-05-15 13:36:09 +02:00
commit 63e7016566
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
2 changed files with 14 additions and 13 deletions

View File

@ -7,7 +7,8 @@
# Test pruning code # Test pruning code
# ******** # ********
# WARNING: # WARNING:
# This test uses 4GB of disk space and takes in excess of 30 mins to run # This test uses 4GB of disk space.
# This test takes 30 mins or more (up to 2 hours)
# ******** # ********
from test_framework import BitcoinTestFramework from test_framework import BitcoinTestFramework
@ -51,11 +52,11 @@ class PruneTest(BitcoinTestFramework):
self.is_network_split = False self.is_network_split = False
# Create nodes 0 and 1 to mine # Create nodes 0 and 1 to mine
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300)) self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900))
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300)) self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900))
# Create node 2 to test pruning # Create node 2 to test pruning
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=300)) self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=900))
self.prunedir = self.options.tmpdir+"/node2/regtest/blocks/" self.prunedir = self.options.tmpdir+"/node2/regtest/blocks/"
self.address[0] = self.nodes[0].getnewaddress() self.address[0] = self.nodes[0].getnewaddress()
@ -108,7 +109,7 @@ class PruneTest(BitcoinTestFramework):
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects # Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
# Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine # Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine
stop_node(self.nodes[0],0) stop_node(self.nodes[0],0)
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300) self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)
# Mine 24 blocks in node 1 # Mine 24 blocks in node 1
self.utxo = self.nodes[1].listunspent() self.utxo = self.nodes[1].listunspent()
for i in xrange(24): for i in xrange(24):
@ -135,7 +136,7 @@ class PruneTest(BitcoinTestFramework):
# Reboot node 1 to clear its mempool (hopefully make the invalidate faster) # Reboot node 1 to clear its mempool (hopefully make the invalidate faster)
# Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks) # Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks)
stop_node(self.nodes[1],1) stop_node(self.nodes[1],1)
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=300) self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
height = self.nodes[1].getblockcount() height = self.nodes[1].getblockcount()
print "Current block height:", height print "Current block height:", height
@ -158,7 +159,7 @@ class PruneTest(BitcoinTestFramework):
# Reboot node1 to clear those giant tx's from mempool # Reboot node1 to clear those giant tx's from mempool
stop_node(self.nodes[1],1) stop_node(self.nodes[1],1)
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=300) self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
print "Generating new longer chain of 300 more blocks" print "Generating new longer chain of 300 more blocks"
self.nodes[1].generate(300) self.nodes[1].generate(300)
@ -223,7 +224,7 @@ class PruneTest(BitcoinTestFramework):
waitstart = time.time() waitstart = time.time()
while self.nodes[2].getblockcount() < goalbestheight: while self.nodes[2].getblockcount() < goalbestheight:
time.sleep(0.1) time.sleep(0.1)
if time.time() - waitstart > 300: if time.time() - waitstart > 900:
raise AssertionError("Node 2 didn't reorg to proper height") raise AssertionError("Node 2 didn't reorg to proper height")
assert(self.nodes[2].getbestblockhash() == goalbesthash) assert(self.nodes[2].getbestblockhash() == goalbesthash)
# Verify we can now have the data for a block previously pruned # Verify we can now have the data for a block previously pruned
@ -256,7 +257,7 @@ class PruneTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
print "Warning! This test requires 4GB of disk space and takes over 30 mins" print "Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)"
print "Mining a big blockchain of 995 blocks" print "Mining a big blockchain of 995 blocks"
self.create_big_chain() self.create_big_chain()
# Chain diagram key: # Chain diagram key:

View File

@ -2932,7 +2932,7 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
return; return;
} }
unsigned int nLastBlockWeMustKeep = chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP; unsigned int nLastBlockWeCanPrune = chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP;
uint64_t nCurrentUsage = CalculateCurrentUsage(); uint64_t nCurrentUsage = CalculateCurrentUsage();
// We don't check to prune until after we've allocated new space for files // We don't check to prune until after we've allocated new space for files
// So we should leave a buffer under our target to account for another allocation // So we should leave a buffer under our target to account for another allocation
@ -2952,7 +2952,7 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
break; break;
// don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip // don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeMustKeep) if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
break; break;
PruneOneBlockFile(fileNumber); PruneOneBlockFile(fileNumber);
@ -2963,10 +2963,10 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
} }
} }
LogPrint("prune", "Prune: target=%dMiB actual=%dMiB diff=%dMiB min_must_keep=%d removed %d blk/rev pairs\n", LogPrint("prune", "Prune: target=%dMiB actual=%dMiB diff=%dMiB max_prune_height=%d removed %d blk/rev pairs\n",
nPruneTarget/1024/1024, nCurrentUsage/1024/1024, nPruneTarget/1024/1024, nCurrentUsage/1024/1024,
((int64_t)nPruneTarget - (int64_t)nCurrentUsage)/1024/1024, ((int64_t)nPruneTarget - (int64_t)nCurrentUsage)/1024/1024,
nLastBlockWeMustKeep, count); nLastBlockWeCanPrune, count);
} }
bool CheckDiskSpace(uint64_t nAdditionalBytes) bool CheckDiskSpace(uint64_t nAdditionalBytes)