Skip to content

Commit 63e7016

Browse files
committed
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)
2 parents 16e8ea3 + 8f0947b commit 63e7016

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

qa/rpc-tests/pruning.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# Test pruning code
88
# ********
99
# WARNING:
10-
# This test uses 4GB of disk space and takes in excess of 30 mins to run
10+
# This test uses 4GB of disk space.
11+
# This test takes 30 mins or more (up to 2 hours)
1112
# ********
1213

1314
from test_framework import BitcoinTestFramework
@@ -51,11 +52,11 @@ def setup_network(self):
5152
self.is_network_split = False
5253

5354
# Create nodes 0 and 1 to mine
54-
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300))
55-
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300))
55+
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900))
56+
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900))
5657

5758
# Create node 2 to test pruning
58-
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=300))
59+
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=900))
5960
self.prunedir = self.options.tmpdir+"/node2/regtest/blocks/"
6061

6162
self.address[0] = self.nodes[0].getnewaddress()
@@ -108,7 +109,7 @@ def create_chain_with_staleblocks(self):
108109
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
109110
# Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine
110111
stop_node(self.nodes[0],0)
111-
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300)
112+
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)
112113
# Mine 24 blocks in node 1
113114
self.utxo = self.nodes[1].listunspent()
114115
for i in xrange(24):
@@ -135,7 +136,7 @@ def reorg_test(self):
135136
# Reboot node 1 to clear its mempool (hopefully make the invalidate faster)
136137
# Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks)
137138
stop_node(self.nodes[1],1)
138-
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=300)
139+
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
139140

140141
height = self.nodes[1].getblockcount()
141142
print "Current block height:", height
@@ -158,7 +159,7 @@ def reorg_test(self):
158159

159160
# Reboot node1 to clear those giant tx's from mempool
160161
stop_node(self.nodes[1],1)
161-
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=300)
162+
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
162163

163164
print "Generating new longer chain of 300 more blocks"
164165
self.nodes[1].generate(300)
@@ -223,7 +224,7 @@ def reorg_back(self):
223224
waitstart = time.time()
224225
while self.nodes[2].getblockcount() < goalbestheight:
225226
time.sleep(0.1)
226-
if time.time() - waitstart > 300:
227+
if time.time() - waitstart > 900:
227228
raise AssertionError("Node 2 didn't reorg to proper height")
228229
assert(self.nodes[2].getbestblockhash() == goalbesthash)
229230
# Verify we can now have the data for a block previously pruned
@@ -256,7 +257,7 @@ def mine_full_block(self, node, address):
256257

257258

258259
def run_test(self):
259-
print "Warning! This test requires 4GB of disk space and takes over 30 mins"
260+
print "Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)"
260261
print "Mining a big blockchain of 995 blocks"
261262
self.create_big_chain()
262263
# Chain diagram key:

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,7 +2932,7 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
29322932
return;
29332933
}
29342934

2935-
unsigned int nLastBlockWeMustKeep = chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP;
2935+
unsigned int nLastBlockWeCanPrune = chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP;
29362936
uint64_t nCurrentUsage = CalculateCurrentUsage();
29372937
// We don't check to prune until after we've allocated new space for files
29382938
// So we should leave a buffer under our target to account for another allocation
@@ -2952,7 +2952,7 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
29522952
break;
29532953

29542954
// don't prune files that could have a block within MIN_BLOCKS_TO_KEEP of the main chain's tip
2955-
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeMustKeep)
2955+
if (vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
29562956
break;
29572957

29582958
PruneOneBlockFile(fileNumber);
@@ -2963,10 +2963,10 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune)
29632963
}
29642964
}
29652965

2966-
LogPrint("prune", "Prune: target=%dMiB actual=%dMiB diff=%dMiB min_must_keep=%d removed %d blk/rev pairs\n",
2966+
LogPrint("prune", "Prune: target=%dMiB actual=%dMiB diff=%dMiB max_prune_height=%d removed %d blk/rev pairs\n",
29672967
nPruneTarget/1024/1024, nCurrentUsage/1024/1024,
29682968
((int64_t)nPruneTarget - (int64_t)nCurrentUsage)/1024/1024,
2969-
nLastBlockWeMustKeep, count);
2969+
nLastBlockWeCanPrune, count);
29702970
}
29712971

29722972
bool CheckDiskSpace(uint64_t nAdditionalBytes)

0 commit comments

Comments
 (0)