From b8820d18366d1940bb2c1fe666f0f825644e6b77 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Thu, 14 Feb 2019 08:27:19 -0500 Subject: [PATCH] Activate CSV from genesis block for custom chains --- src/chainparams.cpp | 7 ++++++- src/chainparamsbase.cpp | 1 + .../functional/test_framework/util.py | 1 + test/functional/feature_block_v4.py | 11 ++++++++--- test/functional/test_framework/util.py | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9d8c6ca12e..3a9533ff1a 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -567,7 +567,12 @@ class CCustomParams : public CRegTestParams { parent_bech32_hrp = args.GetArg("-parent_bech32_hrp", "bcrt"); // END ELEMENTS fields - // + + // CSV always active by default, unlike regtest + consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0; + consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = args.GetArg("-con_csv_deploy_start", Consensus::BIP9Deployment::ALWAYS_ACTIVE); + consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT; + } void SetGenesisBlock() { diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 44d3864230..9f856be51f 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -42,6 +42,7 @@ void SetupChainParamsBaseOptions() 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); gArgs.AddArg("-multi_data_permitted", "Allow relay of multiple OP_RETURN outputs. (default: true)", false, OptionsCategory::ELEMENTS); gArgs.AddArg("-pak", "Entries in the PAK list. Order of entries matter.", false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-con_csv_deploy_start", "Starting height for CSV deployment. (default: -1, which means ACTIVE from genesis)", false, OptionsCategory::ELEMENTS); } static std::unique_ptr globalChainBaseParams; diff --git a/test/bitcoin_functional/functional/test_framework/util.py b/test/bitcoin_functional/functional/test_framework/util.py index 8ad0b8951b..3d4c3e471c 100644 --- a/test/bitcoin_functional/functional/test_framework/util.py +++ b/test/bitcoin_functional/functional/test_framework/util.py @@ -315,6 +315,7 @@ def initialize_datadir(dirname, n, chain): f.write("con_bip65height=1351\n") f.write("con_bip66height=1251\n") f.write("con_genesis_style=bitcoin\n") + f.write("con_csv_deploy_start=0\n") # Default is -1 (always active) os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True) os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True) return datadir diff --git a/test/functional/feature_block_v4.py b/test/functional/feature_block_v4.py index f803cb39e1..55bc4b00d3 100755 --- a/test/functional/feature_block_v4.py +++ b/test/functional/feature_block_v4.py @@ -2,23 +2,28 @@ # Copyright (c) 2015-2018 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -"""Test BIP 34, 65, 66 activation at block 0""" +"""Test BIP 34, 65, 66, CSV activation at block 0""" from test_framework.blocktools import create_coinbase, create_block, create_transaction from test_framework.messages import msg_block from test_framework.mininode import P2PInterface from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal +from test_framework.util import assert_equal, get_bip9_status from feature_cltv import cltv_validate class BlockV4Test(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 - self.extra_args = [['-whitelist=127.0.0.1', '-con_bip34height=0', '-con_bip65height=0', '-con_bip66height=0']] + self.extra_args = [['-whitelist=127.0.0.1', '-con_bip34height=0', '-con_bip65height=0', '-con_bip66height=0', '-con_csv_deploy_start=-1']] self.setup_clean_chain = True def run_test(self): + + # First, quick check that CSV is ACTIVE at genesis + assert_equal(self.nodes[0].getblockcount(), 0) + assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'active') + self.nodes[0].add_p2p_connection(P2PInterface()) self.nodeaddress = self.nodes[0].getnewaddress() diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 56fe3fcf53..b2d9c347fc 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -321,6 +321,7 @@ def initialize_datadir(dirname, n, chain): f.write("con_bip34height=100000000\n") f.write("con_bip65height=1351\n") f.write("con_bip66height=1251\n") + f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line os.makedirs(os.path.join(datadir, 'stderr'), exist_ok=True) os.makedirs(os.path.join(datadir, 'stdout'), exist_ok=True) return datadir