Activate CSV from genesis block for custom chains

This commit is contained in:
Gregory Sanders 2019-02-14 08:27:19 -05:00
parent fd9bdc6d55
commit b8820d1836
5 changed files with 17 additions and 4 deletions

View file

@ -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() {

View file

@ -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<CBaseChainParams> globalChainBaseParams;

View file

@ -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

View file

@ -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()

View file

@ -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