2016-05-06 11:23:48 +02:00
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
2019-01-07 10:55:35 +01:00
""" Test the pruning code.
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2019-01-07 10:55:35 +01:00
WARNING :
This test uses 4 GB of disk space .
This test takes 30 mins or more ( up to 2 hours )
"""
2019-03-29 18:19:20 +01:00
import os
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2019-03-29 18:19:20 +01:00
from test_framework . blocktools import create_coinbase
from test_framework . messages import CBlock , ToHex
from test_framework . script import CScript , OP_RETURN , OP_NOP
2015-05-02 12:53:35 +02:00
from test_framework . test_framework import BitcoinTestFramework
2022-09-24 14:36:35 +02:00
from test_framework . util import assert_equal , assert_greater_than , assert_raises_rpc_error , wait_until
2016-12-06 12:05:31 +01:00
2017-02-23 10:38:09 +01:00
# Rescans start at the earliest block up to 2 hours before a key timestamp, so
# the manual prune RPC avoids pruning blocks in the same window to be
# compatible with pruning based on key creation time.
2017-03-06 10:01:25 +01:00
TIMESTAMP_WINDOW = 2 * 60 * 60
2017-02-23 10:38:09 +01:00
2023-04-16 10:34:03 +02:00
EXPECTED_STDERR_NO_GOV = " Warning: You are starting with governance validation disabled. "
EXPECTED_STDERR_NO_GOV_PRUNE = EXPECTED_STDERR_NO_GOV + " This is expected because you are running a pruned node. "
2019-03-29 18:19:20 +01:00
def mine_large_blocks ( node , n ) :
# Make a large scriptPubKey for the coinbase transaction. This is OP_RETURN
# followed by 950k of OP_NOP. This would be non-standard in a non-coinbase
# transaction but is consensus valid.
2019-04-30 16:09:51 +02:00
# Set the nTime if this is the first time this function has been called.
# A static variable ensures that time is monotonicly increasing and is therefore
# different for each block created => blockhash is unique.
if " nTimes " not in mine_large_blocks . __dict__ :
mine_large_blocks . nTime = 0
2019-03-29 18:19:20 +01:00
# Get the block parameters for the first block
big_script = CScript ( [ OP_RETURN ] + [ OP_NOP ] * 950000 )
best_block = node . getblock ( node . getbestblockhash ( ) )
height = int ( best_block [ " height " ] ) + 1
2019-04-30 16:09:51 +02:00
mine_large_blocks . nTime = max ( mine_large_blocks . nTime , int ( best_block [ " time " ] ) ) + 1
2019-03-29 18:19:20 +01:00
previousblockhash = int ( best_block [ " hash " ] , 16 )
for _ in range ( n ) :
# Build the coinbase transaction (with large scriptPubKey)
coinbase_tx = create_coinbase ( height )
coinbase_tx . vin [ 0 ] . nSequence = 2 * * 32 - 1
coinbase_tx . vout [ 0 ] . scriptPubKey = big_script
coinbase_tx . rehash ( )
# Build the block
block = CBlock ( )
block . nVersion = best_block [ " version " ]
block . hashPrevBlock = previousblockhash
block . nTime = mine_large_blocks . nTime
block . nBits = int ( ' 207fffff ' , 16 )
block . nNonce = 0
block . vtx = [ coinbase_tx ]
block . hashMerkleRoot = block . calc_merkle_root ( )
block . solve ( )
# Submit to the node
node . submitblock ( ToHex ( block ) )
previousblockhash = block . sha256
height + = 1
mine_large_blocks . nTime + = 1
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def calc_usage ( blockdir ) :
2019-03-29 18:19:20 +01:00
return sum ( os . path . getsize ( blockdir + f ) for f in os . listdir ( blockdir ) if os . path . isfile ( os . path . join ( blockdir , f ) ) ) / ( 1024. * 1024. )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
class PruneTest ( BitcoinTestFramework ) :
2017-09-01 18:47:13 +02:00
def set_test_params ( self ) :
2016-05-20 15:16:51 +02:00
self . setup_clean_chain = True
2017-01-11 14:16:11 +01:00
self . num_nodes = 6
2019-12-09 19:52:38 +01:00
self . supports_cli = False
2016-05-20 15:16:51 +02:00
2017-05-02 20:02:55 +02:00
# Create nodes 0 and 1 to mine.
# Create node 2 to test pruning.
2019-03-29 18:19:20 +01:00
self . full_node_default_args = [ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -maxreceivebuffer=20000 " , " -blockmaxsize=999000 " , " -checkblocks=5 " ]
2017-01-11 14:16:11 +01:00
# Create nodes 3 and 4 to test manual pruning (they will be re-started with manual pruning later)
# Create nodes 5 to test wallet in prune mode, but do not connect
2018-09-13 12:33:15 +02:00
self . extra_args = [
self . full_node_default_args ,
self . full_node_default_args ,
[ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -maxreceivebuffer=20000 " , " -prune=550 " ] ,
[ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -maxreceivebuffer=20000 " , " -blockmaxsize=999000 " ] ,
[ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -maxreceivebuffer=20000 " , " -blockmaxsize=999000 " ] ,
[ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -prune=550 " ] ,
]
2019-09-17 19:36:30 +02:00
self . rpc_timeout = 120
2018-09-13 12:33:15 +02:00
2017-05-02 20:02:55 +02:00
def setup_network ( self ) :
self . setup_nodes ( )
2021-01-22 15:58:07 +01:00
self . prunedir = os . path . join ( self . nodes [ 2 ] . datadir , self . chain , ' blocks ' , ' ' )
2017-01-11 14:16:11 +01:00
2022-09-24 14:36:35 +02:00
self . connect_nodes ( 0 , 1 )
self . connect_nodes ( 1 , 2 )
self . connect_nodes ( 0 , 2 )
self . connect_nodes ( 0 , 3 )
self . connect_nodes ( 0 , 4 )
2020-04-14 12:00:16 +02:00
self . sync_blocks ( self . nodes [ 0 : 5 ] )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-09-01 18:47:13 +02:00
def setup_nodes ( self ) :
2018-08-02 14:31:47 +02:00
self . add_nodes ( self . num_nodes , self . extra_args )
2017-09-01 18:47:13 +02:00
self . start_nodes ( )
2022-01-06 15:02:43 +01:00
if self . is_wallet_compiled ( ) :
self . import_deterministic_coinbase_privkeys ( )
2017-09-01 18:47:13 +02:00
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def create_big_chain ( self ) :
# Start by creating some coinbases we can spend later
self . nodes [ 1 ] . generate ( 200 )
2020-04-14 12:00:16 +02:00
self . sync_blocks ( self . nodes [ 0 : 2 ] )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . nodes [ 0 ] . generate ( 150 )
2019-03-29 18:19:20 +01:00
2016-03-19 21:36:32 +01:00
# Then mine enough full blocks to create more than 550MiB of data
2019-03-29 18:19:20 +01:00
mine_large_blocks ( self . nodes [ 0 ] , 645 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2020-04-14 12:00:16 +02:00
self . sync_blocks ( self . nodes [ 0 : 5 ] )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def test_height_min ( self ) :
2019-03-29 18:19:20 +01:00
assert os . path . isfile ( os . path . join ( self . prunedir , " blk00000.dat " ) ) , " blk00000.dat is missing, pruning too early "
2017-03-09 21:16:20 +01:00
self . log . info ( " Success " )
2017-03-10 23:04:58 +01:00
self . log . info ( " Though we ' re already using more than 550MiB, current usage: %d " % calc_usage ( self . prunedir ) )
2017-03-09 21:16:20 +01:00
self . log . info ( " Mining 25 more blocks should cause the first block file to be pruned " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
2019-03-29 18:19:20 +01:00
mine_large_blocks ( self . nodes [ 0 ] , 25 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2018-03-19 17:10:29 +01:00
# Wait for blk00000.dat to be pruned
wait_until ( lambda : not os . path . isfile ( os . path . join ( self . prunedir , " blk00000.dat " ) ) , timeout = 30 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-03-09 21:16:20 +01:00
self . log . info ( " Success " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
usage = calc_usage ( self . prunedir )
2017-03-10 23:04:58 +01:00
self . log . info ( " Usage should be below target: %d " % usage )
2019-03-29 18:19:20 +01:00
assert_greater_than ( 550 , usage )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def create_chain_with_staleblocks ( self ) :
# Create stale blocks in manageable sized chunks
2017-03-09 21:16:20 +01:00
self . log . info ( " Mine 24 (stale) blocks on Node 1, followed by 25 (main chain) block reorg from Node 0, for 12 rounds " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2016-05-06 11:23:48 +02:00
for j in range ( 12 ) :
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Disconnect node 0 so it can mine a longer reorg chain without knowing about node 1's soon-to-be-stale chain
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
2022-09-24 14:36:35 +02:00
self . disconnect_nodes ( 0 , 1 )
self . disconnect_nodes ( 0 , 2 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Mine 24 blocks in node 1
2019-03-29 18:19:20 +01:00
mine_large_blocks ( self . nodes [ 1 ] , 24 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Reorg back with 25 block chain from node 0
2019-03-29 18:19:20 +01:00
mine_large_blocks ( self . nodes [ 0 ] , 25 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Create connections in the order so both nodes can see the reorg at the same time
2022-09-24 14:36:35 +02:00
self . connect_nodes ( 0 , 1 )
self . connect_nodes ( 0 , 2 )
2020-04-14 12:00:16 +02:00
self . sync_blocks ( self . nodes [ 0 : 3 ] )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-03-10 23:04:58 +01:00
self . log . info ( " Usage can be over target because of high stale rate: %d " % calc_usage ( self . prunedir ) )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def reorg_test ( self ) :
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
# This will cause Node 2 to do a reorg requiring 288 blocks of undo data to the reorg_test chain
height = self . nodes [ 1 ] . getblockcount ( )
2017-03-10 23:04:58 +01:00
self . log . info ( " Current block height: %d " % height )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2019-03-29 18:19:20 +01:00
self . forkheight = height - 287
self . forkhash = self . nodes [ 1 ] . getblockhash ( self . forkheight )
self . log . info ( " Invalidating block %s at height %d " % ( self . forkhash , self . forkheight ) )
self . nodes [ 1 ] . invalidateblock ( self . forkhash )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-08-16 00:28:57 +02:00
# We've now switched to our previously mined-24 block fork on node 1, but that's not what we want
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# So invalidate that fork as well, until we're on the same chain as node 0/2 (but at an ancestor 288 blocks ago)
2019-03-29 18:19:20 +01:00
mainchainhash = self . nodes [ 0 ] . getblockhash ( self . forkheight - 1 )
curhash = self . nodes [ 1 ] . getblockhash ( self . forkheight - 1 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
while curhash != mainchainhash :
self . nodes [ 1 ] . invalidateblock ( curhash )
2019-03-29 18:19:20 +01:00
curhash = self . nodes [ 1 ] . getblockhash ( self . forkheight - 1 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2019-03-29 18:19:20 +01:00
assert self . nodes [ 1 ] . getblockcount ( ) == self . forkheight - 1
2017-03-10 23:04:58 +01:00
self . log . info ( " New best height: %d " % self . nodes [ 1 ] . getblockcount ( ) )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2021-02-01 17:17:29 +01:00
# Mine one block to avoid automatic recovery from forks on restart
self . nodes [ 1 ] . generate ( 1 )
2019-03-29 18:19:20 +01:00
# Disconnect node1 and generate the new chain
2022-09-24 14:36:35 +02:00
self . disconnect_nodes ( 0 , 1 )
self . disconnect_nodes ( 1 , 2 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-03-09 21:16:20 +01:00
self . log . info ( " Generating new longer chain of 300 more blocks " )
2021-02-01 17:17:29 +01:00
self . nodes [ 1 ] . generate ( 299 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-03-09 21:16:20 +01:00
self . log . info ( " Reconnect nodes " )
2022-09-24 14:36:35 +02:00
self . connect_nodes ( 0 , 1 )
self . connect_nodes ( 1 , 2 )
2020-04-14 12:00:16 +02:00
self . sync_blocks ( self . nodes [ 0 : 3 ] , timeout = 120 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-03-10 23:04:58 +01:00
self . log . info ( " Verify height on node 2: %d " % self . nodes [ 2 ] . getblockcount ( ) )
2019-03-29 18:19:20 +01:00
self . log . info ( " Usage possibly still high because of stale blocks in block files: %d " % calc_usage ( self . prunedir ) )
2017-05-30 18:42:22 +02:00
2019-03-29 18:19:20 +01:00
self . log . info ( " Mine 220 more large blocks so we have requisite history " )
2017-05-30 18:42:22 +02:00
2019-03-29 18:19:20 +01:00
mine_large_blocks ( self . nodes [ 0 ] , 220 )
2019-08-05 13:48:42 +02:00
self . sync_blocks ( self . nodes [ 0 : 3 ] , timeout = 120 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
usage = calc_usage ( self . prunedir )
2017-03-10 23:04:58 +01:00
self . log . info ( " Usage should be below target: %d " % usage )
2019-03-29 18:19:20 +01:00
assert_greater_than ( 550 , usage )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def reorg_back ( self ) :
# Verify that a block on the old main chain fork has been pruned away
2019-09-25 11:34:51 +02:00
assert_raises_rpc_error ( - 1 , " Block not available (pruned data) " , self . nodes [ 2 ] . getblock , self . forkhash )
2018-12-27 21:56:11 +01:00
with self . nodes [ 2 ] . assert_debug_log ( expected_msgs = [ ' block verification stopping at height ' , ' (pruning, no data) ' ] ) :
self . nodes [ 2 ] . verifychain ( checklevel = 4 , nblocks = 0 )
2017-03-10 23:04:58 +01:00
self . log . info ( " Will need to redownload block %d " % self . forkheight )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Verify that we have enough history to reorg back to the fork point
# Although this is more than 288 blocks, because this chain was written more recently
2018-03-21 16:16:28 +01:00
# and only its other 299 small and 220 large blocks are in the block files after it,
# it is expected to still be retained
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . nodes [ 2 ] . getblock ( self . nodes [ 2 ] . getblockhash ( self . forkheight ) )
first_reorg_height = self . nodes [ 2 ] . getblockcount ( )
curchainhash = self . nodes [ 2 ] . getblockhash ( self . mainchainheight )
self . nodes [ 2 ] . invalidateblock ( curchainhash )
goalbestheight = self . mainchainheight
goalbesthash = self . mainchainhash2
# As of 0.10 the current block download logic is not able to reorg to the original chain created in
2017-08-16 00:28:57 +02:00
# create_chain_with_stale_blocks because it doesn't know of any peer that's on that chain from which to
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# redownload its missing blocks.
# Invalidate the reorg_test chain in node 0 as well, it can successfully switch to the original chain
# because it has all the block data.
# However it must mine enough blocks to have a more work chain than the reorg_test chain in order
# to trigger node 2's block download logic.
# At this point node 2 is within 288 blocks of the fork point so it will preserve its ability to reorg
if self . nodes [ 2 ] . getblockcount ( ) < self . mainchainheight :
blocks_to_mine = first_reorg_height + 1 - self . mainchainheight
2017-03-10 23:04:58 +01:00
self . log . info ( " Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed: %d " % blocks_to_mine )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . nodes [ 0 ] . invalidateblock ( curchainhash )
2019-03-29 18:19:20 +01:00
assert_equal ( self . nodes [ 0 ] . getblockcount ( ) , self . mainchainheight )
assert_equal ( self . nodes [ 0 ] . getbestblockhash ( ) , self . mainchainhash2 )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
goalbesthash = self . nodes [ 0 ] . generate ( blocks_to_mine ) [ - 1 ]
goalbestheight = first_reorg_height + 1
2017-03-09 21:16:20 +01:00
self . log . info ( " Verify node 2 reorged back to the main chain, some blocks of which it had to redownload " )
2018-03-19 17:10:29 +01:00
# Wait for Node 2 to reorg to proper height
wait_until ( lambda : self . nodes [ 2 ] . getblockcount ( ) > = goalbestheight , timeout = 900 )
2019-03-29 18:19:20 +01:00
assert_equal ( self . nodes [ 2 ] . getbestblockhash ( ) , goalbesthash )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Verify we can now have the data for a block previously pruned
2019-03-29 18:19:20 +01:00
assert_equal ( self . nodes [ 2 ] . getblock ( self . forkhash ) [ " height " ] , self . forkheight )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
2017-01-11 14:16:11 +01:00
def manual_test ( self , node_number , use_timestamp ) :
# at this point, node has 995 blocks and has not yet run in prune mode
2021-02-01 17:17:29 +01:00
self . start_node ( node_number , extra_args = [ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " ] )
2017-09-01 18:47:13 +02:00
node = self . nodes [ node_number ]
2017-01-11 14:16:11 +01:00
assert_equal ( node . getblockcount ( ) , 995 )
2021-12-20 13:32:54 +01:00
assert_raises_rpc_error ( - 1 , " Cannot prune blocks because node is not in prune mode " , node . pruneblockchain , 500 )
2017-01-11 14:16:11 +01:00
# now re-start in manual pruning mode
2023-04-16 10:34:03 +02:00
self . restart_node ( node_number , extra_args = [ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -prune=1 " ] , expected_stderr = EXPECTED_STDERR_NO_GOV )
2017-09-01 18:47:13 +02:00
node = self . nodes [ node_number ]
2017-01-11 14:16:11 +01:00
assert_equal ( node . getblockcount ( ) , 995 )
def height ( index ) :
if use_timestamp :
2017-03-06 10:01:25 +01:00
return node . getblockheader ( node . getblockhash ( index ) ) [ " time " ] + TIMESTAMP_WINDOW
2017-01-11 14:16:11 +01:00
else :
return index
2019-06-13 13:34:05 +02:00
def prune ( index ) :
2018-11-13 22:49:17 +01:00
ret = node . pruneblockchain ( height = height ( index ) )
2019-06-13 13:34:05 +02:00
assert_equal ( ret , node . getblockchaininfo ( ) [ ' pruneheight ' ] )
2017-01-12 11:49:48 +01:00
2017-01-11 14:16:11 +01:00
def has_block ( index ) :
2021-01-22 15:58:07 +01:00
return os . path . isfile ( os . path . join ( self . nodes [ node_number ] . datadir , self . chain , " blocks " , " blk {:05} .dat " . format ( index ) ) )
2017-01-11 14:16:11 +01:00
# should not prune because chain tip of node 3 (995) < PruneAfterHeight (1000)
2019-09-25 11:34:51 +02:00
assert_raises_rpc_error ( - 1 , " Blockchain is too short for pruning " , node . pruneblockchain , height ( 500 ) )
2017-01-11 14:16:11 +01:00
2018-06-14 19:38:19 +02:00
# Save block transaction count before pruning, assert value
block1_details = node . getblock ( node . getblockhash ( 1 ) )
assert_equal ( block1_details [ " nTx " ] , len ( block1_details [ " tx " ] ) )
2017-01-11 14:16:11 +01:00
# mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight)
node . generate ( 6 )
2017-01-27 16:21:57 +01:00
assert_equal ( node . getblockchaininfo ( ) [ " blocks " ] , 1001 )
2017-01-11 14:16:11 +01:00
2021-12-20 13:32:54 +01:00
# prune parameter in the future (block or timestamp) should raise an exception
future_parameter = height ( 1001 ) + 5
if use_timestamp :
assert_raises_rpc_error ( - 8 , " Could not find block with at least the specified timestamp " , node . pruneblockchain , future_parameter )
else :
assert_raises_rpc_error ( - 8 , " Blockchain is shorter than the attempted prune height " , node . pruneblockchain , future_parameter )
2018-06-14 19:38:19 +02:00
# Pruned block should still know the number of transactions
assert_equal ( node . getblockheader ( node . getblockhash ( 1 ) ) [ " nTx " ] , block1_details [ " nTx " ] )
2017-01-27 16:21:57 +01:00
# negative heights should raise an exception
2021-12-20 13:32:54 +01:00
assert_raises_rpc_error ( - 8 , " Negative block height " , node . pruneblockchain , - 10 )
2017-01-11 14:16:11 +01:00
# height=100 too low to prune first block file so this is a no-op
2017-01-12 11:49:48 +01:00
prune ( 100 )
2019-03-29 18:19:20 +01:00
assert has_block ( 0 ) , " blk00000.dat is missing when should still be there "
2017-01-11 14:16:11 +01:00
2017-01-27 16:21:57 +01:00
# Does nothing
node . pruneblockchain ( height ( 0 ) )
2019-03-29 18:19:20 +01:00
assert has_block ( 0 ) , " blk00000.dat is missing when should still be there "
2017-01-27 16:21:57 +01:00
2017-01-11 14:16:11 +01:00
# height=500 should prune first file
2017-01-12 11:49:48 +01:00
prune ( 500 )
2019-03-29 18:19:20 +01:00
assert not has_block ( 0 ) , " blk00000.dat is still there, should be pruned by now "
assert has_block ( 1 ) , " blk00001.dat is missing when should still be there "
2017-01-11 14:16:11 +01:00
# height=650 should prune second file
2017-01-12 11:49:48 +01:00
prune ( 650 )
2019-03-29 18:19:20 +01:00
assert not has_block ( 1 ) , " blk00001.dat is still there, should be pruned by now "
2017-01-11 14:16:11 +01:00
# height=1000 should not prune anything more, because tip-288 is in blk00002.dat.
2019-06-13 13:34:05 +02:00
prune ( 1000 )
2019-03-29 18:19:20 +01:00
assert has_block ( 2 ) , " blk00002.dat is still there, should be pruned by now "
2017-01-11 14:16:11 +01:00
# advance the tip so blk00002.dat and blk00003.dat can be pruned (the last 288 blocks should now be in blk00004.dat)
node . generate ( 288 )
2017-01-12 11:49:48 +01:00
prune ( 1000 )
2019-03-29 18:19:20 +01:00
assert not has_block ( 2 ) , " blk00002.dat is still there, should be pruned by now "
assert not has_block ( 3 ) , " blk00003.dat is still there, should be pruned by now "
2017-01-11 14:16:11 +01:00
2019-01-30 20:16:41 +01:00
# stop node, start back up with auto-prune at 550 MiB, make sure still runs
2023-04-16 10:34:03 +02:00
self . restart_node ( node_number , extra_args = [ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -prune=550 " ] , expected_stderr = EXPECTED_STDERR_NO_GOV_PRUNE )
2017-01-11 14:16:11 +01:00
2017-03-09 21:16:20 +01:00
self . log . info ( " Success " )
2017-01-11 14:16:11 +01:00
def wallet_test ( self ) :
# check that the pruning node's wallet is still in good shape
2017-03-09 21:16:20 +01:00
self . log . info ( " Stop and start pruning node to trigger wallet rescan " )
2023-04-16 10:34:03 +02:00
self . restart_node ( 2 , extra_args = [ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -prune=550 " ] , expected_stderr = EXPECTED_STDERR_NO_GOV_PRUNE )
2017-03-09 21:16:20 +01:00
self . log . info ( " Success " )
2017-01-11 14:16:11 +01:00
2017-06-22 20:36:16 +02:00
# check that wallet loads successfully when restarting a pruned node after IBD.
2017-01-11 14:16:11 +01:00
# this was reported to fail in #7494.
2017-03-09 21:16:20 +01:00
self . log . info ( " Syncing node 5 to test wallet " )
2022-09-24 14:36:35 +02:00
self . connect_nodes ( 0 , 5 )
2017-01-11 14:16:11 +01:00
nds = [ self . nodes [ 0 ] , self . nodes [ 5 ] ]
2020-04-14 12:00:16 +02:00
self . sync_blocks ( nds , wait = 5 , timeout = 300 )
2023-04-16 10:34:03 +02:00
self . restart_node ( 5 , extra_args = [ " -dip3params=2000:2000 " , " -dip8params=2000 " , " -disablegovernance " , " -txindex=0 " , " -prune=550 " ] , expected_stderr = EXPECTED_STDERR_NO_GOV_PRUNE ) # restart to trigger rescan
2017-03-09 21:16:20 +01:00
self . log . info ( " Success " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
def run_test ( self ) :
2019-03-29 18:19:20 +01:00
self . log . info ( " Warning! This test requires 4GB of disk space " )
2017-05-02 20:02:55 +02:00
2019-03-29 18:19:20 +01:00
self . log . info ( " Mining a big blockchain of 995 blocks " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . create_big_chain ( )
# Chain diagram key:
# * blocks on main chain
# +,&,$,@ blocks on other forks
# X invalidated block
# N1 Node 1
#
# Start by mining a simple chain that all nodes have
# N0=N1=N2 **...*(995)
2017-01-11 14:16:11 +01:00
# stop manual-pruning node with 995 blocks
2023-04-16 10:34:03 +02:00
self . stop_node ( 3 , expected_stderr = EXPECTED_STDERR_NO_GOV )
self . stop_node ( 4 , expected_stderr = EXPECTED_STDERR_NO_GOV )
2017-01-11 14:16:11 +01:00
2017-03-09 21:16:20 +01:00
self . log . info ( " Check that we haven ' t started pruning yet because we ' re below PruneAfterHeight " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . test_height_min ( )
# Extend this chain past the PruneAfterHeight
# N0=N1=N2 **...*(1020)
2017-03-09 21:16:20 +01:00
self . log . info ( " Check that we ' ll exceed disk space target if we have a very high stale block rate " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . create_chain_with_staleblocks ( )
# Disconnect N0
# And mine a 24 block chain on N1 and a separate 25 block chain on N0
# N1=N2 **...*+...+(1044)
# N0 **...**...**(1045)
#
# reconnect nodes causing reorg on N1 and N2
# N1=N2 **...*(1020) *...**(1045)
# \
# +...+(1044)
#
# repeat this process until you have 12 stale forks hanging off the
# main chain on N1 and N2
# N0 *************************...***************************(1320)
#
# N1=N2 **...*(1020) *...**(1045) *.. ..**(1295) *...**(1320)
# \ \ \
# +...+(1044) &.. $...$(1319)
# Save some current chain state for later use
2019-03-29 18:19:20 +01:00
self . mainchainheight = self . nodes [ 2 ] . getblockcount ( ) # 1320
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . mainchainhash2 = self . nodes [ 2 ] . getblockhash ( self . mainchainheight )
2017-03-09 21:16:20 +01:00
self . log . info ( " Check that we can survive a 288 block reorg still " )
2019-03-29 18:19:20 +01:00
self . reorg_test ( ) # (1033, )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# Now create a 288 block reorg by mining a longer chain on N1
# First disconnect N1
# Then invalidate 1033 on main chain and 1032 on fork so height is 1032 on main chain
# N1 **...*(1020) **...**(1032)X..
# \
# ++...+(1031)X..
#
# Now mine 300 more blocks on N1
# N1 **...*(1020) **...**(1032) @@...@(1332)
# \ \
# \ X...
# \ \
# ++...+(1031)X.. ..
#
# Reconnect nodes and mine 220 more blocks on N1
# N1 **...*(1020) **...**(1032) @@...@@@(1552)
# \ \
# \ X...
# \ \
# ++...+(1031)X.. ..
#
# N2 **...*(1020) **...**(1032) @@...@@@(1552)
# \ \
# \ *...**(1320)
# \ \
# ++...++(1044) ..
#
2016-04-10 16:54:28 +02:00
# N0 ********************(1032) @@...@@@(1552)
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
# \
# *...**(1320)
2017-03-09 21:16:20 +01:00
self . log . info ( " Test that we can rerequest a block we previously pruned if needed for a reorg " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
self . reorg_back ( )
# Verify that N2 still has block 1033 on current chain (@), but not on main chain (*)
# Invalidate 1033 on current chain (@) on N2 and we should be able to reorg to
# original main chain (*), but will require redownload of some blocks
# In order to have a peer we think we can download from, must also perform this invalidation
# on N0 and mine a new longest chain to trigger.
# Final result:
# N0 ********************(1032) **...****(1553)
# \
# X@...@@@(1552)
#
# N2 **...*(1020) **...**(1032) **...****(1553)
# \ \
# \ X@...@@@(1552)
# \
# +..
#
# N1 doesn't change because 1033 on main chain (*) is invalid
2017-03-09 21:16:20 +01:00
self . log . info ( " Test manual pruning with block indices " )
2017-01-11 14:16:11 +01:00
self . manual_test ( 3 , use_timestamp = False )
2017-03-09 21:16:20 +01:00
self . log . info ( " Test manual pruning with timestamps " )
2017-01-11 14:16:11 +01:00
self . manual_test ( 4 , use_timestamp = True )
2022-01-06 15:02:43 +01:00
if self . is_wallet_compiled ( ) :
self . log . info ( " Test wallet re-scan " )
self . wallet_test ( )
2017-01-11 14:16:11 +01:00
2021-10-01 21:19:23 +02:00
self . log . info ( " Stopping pruned nodes manually " )
for i in range ( 2 , 6 ) :
self . log . info ( " Stopping pruned node %d " % i )
2023-04-16 10:34:03 +02:00
self . stop_node ( i , expected_stderr = EXPECTED_STDERR_NO_GOV_PRUNE )
2021-10-01 21:19:23 +02:00
2017-03-09 21:16:20 +01:00
self . log . info ( " Done " )
Add block pruning functionality
This adds a -prune=N option to bitcoind, which if set to N>0 will enable block
file pruning. When pruning is enabled, block and undo files will be deleted to
try to keep total space used by those files to below the prune target (N, in
MB) specified by the user, subject to some constraints:
- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),
- N must be at least 550MB (chosen as a value for the target that could
reasonably be met, with some assumptions about block sizes, orphan rates,
etc; see comment in main.h),
- No blocks are pruned until chainActive is at least 100,000 blocks long (on
mainnet; defined separately for mainnet, testnet, and regtest in chainparams
as nPruneAfterHeight).
This unsets NODE_NETWORK if pruning is enabled.
Also included is an RPC test for pruning (pruning.py).
Thanks to @rdponticelli for earlier work on this feature; this is based in
part off that work.
2015-02-23 20:27:44 +01:00
if __name__ == ' __main__ ' :
PruneTest ( ) . main ( )