mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 05:45:05 +01:00
test: Activate all regtest softforks at height 1, unless overridden
This commit is contained in:
parent
faad1e5ffd
commit
fa4db8671b
@ -109,10 +109,8 @@ Tests
|
||||
-----
|
||||
|
||||
- For the `regtest` network the activation heights of several softforks were
|
||||
changed.
|
||||
* BIP 34 (blockheight in coinbase) from 500 to 2 (#16333)
|
||||
* BIP 66 (DERSIG) from 1251 to 102 (#22632)
|
||||
* BIP 65 (CLTV) from 1351 to 111 (#21862)
|
||||
set to block height 1. They can be changed by the runtime setting
|
||||
`-testactivationheight=name@height`. (#22818)
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
@ -390,12 +390,12 @@ public:
|
||||
consensus.signet_challenge.clear();
|
||||
consensus.nSubsidyHalvingInterval = 150;
|
||||
consensus.BIP16Exception = uint256();
|
||||
consensus.BIP34Height = 2; // BIP34 activated on regtest (Block at height 1 not enforced for testing purposes)
|
||||
consensus.BIP34Height = 1; // Always active unless overridden
|
||||
consensus.BIP34Hash = uint256();
|
||||
consensus.BIP65Height = 111; // BIP65 activated on regtest (Block at height 110 and earlier not enforced for testing purposes)
|
||||
consensus.BIP66Height = 102; // BIP66 activated on regtest (Block at height 101 and earlier not enforced for testing purposes)
|
||||
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
|
||||
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
|
||||
consensus.BIP65Height = 1; // Always active unless overridden
|
||||
consensus.BIP66Height = 1; // Always active unless overridden
|
||||
consensus.CSVHeight = 1; // Always active unless overridden
|
||||
consensus.SegwitHeight = 1; // Always active unless overridden
|
||||
consensus.MinBIP9WarningHeight = 0;
|
||||
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||
@ -502,6 +502,14 @@ static void MaybeUpdateHeights(const ArgsManager& args, Consensus::Params& conse
|
||||
}
|
||||
if (name == "segwit") {
|
||||
consensus.SegwitHeight = int{height};
|
||||
} else if (name == "bip34") {
|
||||
consensus.BIP34Height = int{height};
|
||||
} else if (name == "dersig") {
|
||||
consensus.BIP66Height = int{height};
|
||||
} else if (name == "cltv") {
|
||||
consensus.BIP65Height = int{height};
|
||||
} else if (name == "csv") {
|
||||
consensus.CSVHeight = int{height};
|
||||
} else {
|
||||
throw std::runtime_error(strprintf("Invalid name (%s) for -testactivationheight=name@height.", arg));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
|
||||
argsman.AddArg("-chain=<chain>", "Use the chain <chain> (default: main). Allowed values: main, test, signet, regtest", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
|
||||
"This is intended for regression testing tools and app development. Equivalent to -chain=regtest.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name'. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-testactivationheight=name@height.", "Set the activation height of 'name' (segwit, bip34, dersig, cltv, csv). (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-testnet", "Use the test chain. Equivalent to -chain=test.", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
|
||||
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
|
||||
|
@ -13,6 +13,11 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
struct Dersig100Setup : public TestChain100Setup {
|
||||
Dersig100Setup()
|
||||
: TestChain100Setup{{"-testactivationheight=dersig@102"}} {}
|
||||
};
|
||||
|
||||
bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
|
||||
const CCoinsViewCache& inputs, unsigned int flags, bool cacheSigStore,
|
||||
bool cacheFullScriptStore, PrecomputedTransactionData& txdata,
|
||||
@ -20,7 +25,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(txvalidationcache_tests)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
|
||||
{
|
||||
// Make sure skipping validation of transactions that were
|
||||
// validated going into the memory pool does not allow
|
||||
@ -153,7 +158,7 @@ static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t fail
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
|
||||
BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
|
||||
{
|
||||
// Test that passing CheckInputScripts with one set of script flags doesn't imply
|
||||
// that we would pass again with a different set of flags.
|
||||
|
@ -41,8 +41,14 @@ class BIP68Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [
|
||||
["-acceptnonstdtxn=1"],
|
||||
["-acceptnonstdtxn=0"],
|
||||
[
|
||||
'-testactivationheight=csv@432',
|
||||
"-acceptnonstdtxn=1",
|
||||
],
|
||||
[
|
||||
'-testactivationheight=csv@432',
|
||||
"-acceptnonstdtxn=0",
|
||||
],
|
||||
]
|
||||
|
||||
def skip_test_if_missing_module(self):
|
||||
|
@ -82,7 +82,10 @@ class FullBlockTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [['-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy
|
||||
self.extra_args = [[
|
||||
'-acceptnonstdtxn=1', # This is a consensus block test, we don't care about tx policy
|
||||
'-testactivationheight=bip34@2',
|
||||
]]
|
||||
|
||||
def run_test(self):
|
||||
node = self.nodes[0] # convenience reference to the node
|
||||
|
@ -8,7 +8,6 @@ Test that the CHECKLOCKTIMEVERIFY soft-fork activates.
|
||||
"""
|
||||
|
||||
from test_framework.blocktools import (
|
||||
CLTV_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
@ -76,10 +75,14 @@ def cltv_validate(tx, height):
|
||||
cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])
|
||||
|
||||
|
||||
CLTV_HEIGHT = 111
|
||||
|
||||
|
||||
class BIP65Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
f'-testactivationheight=cltv@{CLTV_HEIGHT}',
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
||||
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
|
||||
|
@ -41,7 +41,6 @@ from itertools import product
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import (
|
||||
CSV_ACTIVATION_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
@ -89,12 +88,16 @@ def all_rlt_txs(txs):
|
||||
return [tx['tx'] for tx in txs]
|
||||
|
||||
|
||||
CSV_ACTIVATION_HEIGHT = 432
|
||||
|
||||
|
||||
class BIP68_112_113Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.setup_clean_chain = True
|
||||
self.extra_args = [[
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
f'-testactivationheight=csv@{CSV_ACTIVATION_HEIGHT}',
|
||||
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
||||
]]
|
||||
self.supports_cli = False
|
||||
|
@ -8,7 +8,6 @@ Test the DERSIG soft-fork activation on regtest.
|
||||
"""
|
||||
|
||||
from test_framework.blocktools import (
|
||||
DERSIG_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
@ -42,10 +41,14 @@ def unDERify(tx):
|
||||
tx.vin[0].scriptSig = CScript(newscript)
|
||||
|
||||
|
||||
DERSIG_HEIGHT = 102
|
||||
|
||||
|
||||
class BIP66Test(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
self.extra_args = [[
|
||||
f'-testactivationheight=dersig@{DERSIG_HEIGHT}',
|
||||
'-whitelist=noban@127.0.0.1',
|
||||
'-par=1', # Use only one script thread to get the exact log msg for testing
|
||||
]]
|
||||
|
@ -27,8 +27,6 @@ import subprocess
|
||||
|
||||
from test_framework.address import ADDRESS_BCRT1_P2WSH_OP_TRUE
|
||||
from test_framework.blocktools import (
|
||||
CLTV_HEIGHT,
|
||||
DERSIG_HEIGHT,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
TIME_GENESIS_BLOCK,
|
||||
@ -142,11 +140,11 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert_greater_than(res['size_on_disk'], 0)
|
||||
|
||||
assert_equal(res['softforks'], {
|
||||
'bip34': {'type': 'buried', 'active': True, 'height': 2},
|
||||
'bip66': {'type': 'buried', 'active': True, 'height': DERSIG_HEIGHT},
|
||||
'bip65': {'type': 'buried', 'active': True, 'height': CLTV_HEIGHT},
|
||||
'csv': {'type': 'buried', 'active': False, 'height': 432},
|
||||
'segwit': {'type': 'buried', 'active': True, 'height': 0},
|
||||
'bip34': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'bip66': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'bip65': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'csv': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'segwit': {'type': 'buried', 'active': True, 'height': 1},
|
||||
'testdummy': {
|
||||
'type': 'bip9',
|
||||
'bip9': {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
from test_framework.blocktools import (
|
||||
COINBASE_MATURITY,
|
||||
CSV_ACTIVATION_HEIGHT,
|
||||
)
|
||||
from test_framework.address import (
|
||||
script_to_p2sh,
|
||||
@ -18,7 +17,6 @@ from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
find_vout_for_address,
|
||||
generate_to_height,
|
||||
)
|
||||
from test_framework.messages import (
|
||||
CTxInWitness,
|
||||
@ -273,7 +271,6 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||
getcontext().prec = 8
|
||||
|
||||
# Make sure CSV is active
|
||||
generate_to_height(self, self.nodes[0], CSV_ACTIVATION_HEIGHT)
|
||||
assert self.nodes[0].getblockchaininfo()['softforks']['csv']['active']
|
||||
|
||||
# Create a P2WSH script with CSV
|
||||
|
@ -53,11 +53,6 @@ TIME_GENESIS_BLOCK = 1296688602
|
||||
# Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
|
||||
COINBASE_MATURITY = 100
|
||||
|
||||
# Soft-fork activation heights
|
||||
DERSIG_HEIGHT = 102 # BIP 66
|
||||
CLTV_HEIGHT = 111 # BIP 65
|
||||
CSV_ACTIVATION_HEIGHT = 432
|
||||
|
||||
# From BIP141
|
||||
WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed"
|
||||
|
||||
|
@ -560,17 +560,6 @@ def mine_large_block(test_framework, node, utxos=None):
|
||||
test_framework.generate(node, 1)
|
||||
|
||||
|
||||
def generate_to_height(test_framework, node, target_height):
|
||||
"""Generates blocks until a given target block height has been reached.
|
||||
To prevent timeouts, only up to 200 blocks are generated per RPC call.
|
||||
Can be used to activate certain soft-forks (e.g. CSV, CLTV)."""
|
||||
current_height = node.getblockcount()
|
||||
while current_height < target_height:
|
||||
nblocks = min(200, target_height - current_height)
|
||||
current_height += len(test_framework.generate(node, nblocks))
|
||||
assert_equal(node.getblockcount(), target_height)
|
||||
|
||||
|
||||
def find_vout_for_address(node, txid, addr):
|
||||
"""
|
||||
Locate the vout index of the given transaction sending to the
|
||||
|
Loading…
Reference in New Issue
Block a user