Skip to content

Commit 658dae0

Browse files
committed
Merge #505: [0.17] Activate CSV from genesis block for custom chains
91dd327 Disable functional tests for bitcoin_functional build (Gregory Sanders) b8820d1 Activate CSV from genesis block for custom chains (Gregory Sanders) Pull request description: Guts the test for elements mode, can add back later if worked on. Tree-SHA512: a2b7633fa02dae582616ac26d25cd08f895d5940e3775c70cacdd3f678f01a21cbcaf56c6c540b91bd8535bb1aab7bdc59e2a79b5a1124cbd9d3f03f29d0b40e
2 parents fd9bdc6 + 91dd327 commit 658dae0

6 files changed

Lines changed: 18 additions & 4 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,6 @@ jobs:
143143
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libssl1.0-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
144144
NO_DEPENDS=1
145145
RUN_BITCOIN_TESTS=true
146+
RUN_FUNCTIONAL_TESTS=false
146147
GOAL="install"
147148
BITCOIN_CONFIG="--enable-zmq --with-incompatible-bdb --enable-glibc-back-compat --enable-reduce-exports --with-gui=qt5 CPPFLAGS=-DDEBUG_LOCKORDER"

src/chainparams.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,12 @@ class CCustomParams : public CRegTestParams {
567567
parent_bech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt");
568568

569569
// END ELEMENTS fields
570-
//
570+
571+
// CSV always active by default, unlike regtest
572+
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
573+
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = args.GetArg("-con_csv_deploy_start", Consensus::BIP9Deployment::ALWAYS_ACTIVE);
574+
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
575+
571576
}
572577

573578
void SetGenesisBlock() {

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void SetupChainParamsBaseOptions()
4242
gArgs.AddArg("-enforce_pak", "Causes standardness checks to enforce Pegout Authorization Key(PAK) validation, and miner to include PAK commitments when configured. Can not be set when acceptnonstdtx is set to true.", false, OptionsCategory::ELEMENTS);
4343
gArgs.AddArg("-multi_data_permitted", "Allow relay of multiple OP_RETURN outputs. (default: true)", false, OptionsCategory::ELEMENTS);
4444
gArgs.AddArg("-pak", "Entries in the PAK list. Order of entries matter.", false, OptionsCategory::ELEMENTS);
45+
gArgs.AddArg("-con_csv_deploy_start", "Starting height for CSV deployment. (default: -1, which means ACTIVE from genesis)", false, OptionsCategory::ELEMENTS);
4546
}
4647

4748
static std::unique_ptr<CBaseChainParams> globalChainBaseParams;

test/bitcoin_functional/functional/test_framework/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def initialize_datadir(dirname, n, chain):
315315
f.write("con_bip65height=1351\n")
316316
f.write("con_bip66height=1251\n")
317317
f.write("con_genesis_style=bitcoin\n")
318+
f.write("con_csv_deploy_start=0\n") # Default is -1 (always active)
318319
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
319320
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
320321
return datadir

test/functional/feature_block_v4.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22
# Copyright (c) 2015-2018 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
"""Test BIP 34, 65, 66 activation at block 0"""
5+
"""Test BIP 34, 65, 66, CSV activation at block 0"""
66

77
from test_framework.blocktools import create_coinbase, create_block, create_transaction
88
from test_framework.messages import msg_block
99
from test_framework.mininode import P2PInterface
1010
from test_framework.test_framework import BitcoinTestFramework
11-
from test_framework.util import assert_equal
11+
from test_framework.util import assert_equal, get_bip9_status
1212

1313
from feature_cltv import cltv_validate
1414

1515
class BlockV4Test(BitcoinTestFramework):
1616
def set_test_params(self):
1717
self.num_nodes = 1
18-
self.extra_args = [['-whitelist=127.0.0.1', '-con_bip34height=0', '-con_bip65height=0', '-con_bip66height=0']]
18+
self.extra_args = [['-whitelist=127.0.0.1', '-con_bip34height=0', '-con_bip65height=0', '-con_bip66height=0', '-con_csv_deploy_start=-1']]
1919
self.setup_clean_chain = True
2020

2121
def run_test(self):
22+
23+
# First, quick check that CSV is ACTIVE at genesis
24+
assert_equal(self.nodes[0].getblockcount(), 0)
25+
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'active')
26+
2227
self.nodes[0].add_p2p_connection(P2PInterface())
2328

2429
self.nodeaddress = self.nodes[0].getnewaddress()

test/functional/test_framework/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ def initialize_datadir(dirname, n, chain):
321321
f.write("con_bip34height=100000000\n")
322322
f.write("con_bip65height=1351\n")
323323
f.write("con_bip66height=1251\n")
324+
f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line
324325
os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True)
325326
os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True)
326327
return datadir

0 commit comments

Comments
 (0)