mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
partial bitcoin#11389: Support having SegWit always active in regtest
excludes:
- d618458184
This commit is contained in:
parent
b60ab41f8c
commit
e1d3be4adc
@ -136,6 +136,7 @@ public:
|
|||||||
CMainParams() {
|
CMainParams() {
|
||||||
strNetworkID = CBaseChainParams::MAIN;
|
strNetworkID = CBaseChainParams::MAIN;
|
||||||
consensus.nSubsidyHalvingInterval = 210240; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050)
|
consensus.nSubsidyHalvingInterval = 210240; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050)
|
||||||
|
consensus.BIP16Height = 0;
|
||||||
consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
consensus.nMasternodePaymentsStartBlock = 100000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
|
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
|
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
|
||||||
@ -182,7 +183,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 19999999999; // TODO: To be determined later
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 19999999999; // TODO: To be determined later
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 4032;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 4032;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 3226; // 80% of 4032
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 3226; // 80% of 4032
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 2420; // 60% of 4032
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 2420; // 60% of 4032
|
||||||
@ -190,7 +191,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 19999999999; // TODO: To be determined later
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 19999999999; // TODO: To be determined later
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 4032;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 4032;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 3226; // 80% of 4032
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 3226; // 80% of 4032
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 2420; // 60% of 4032
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 2420; // 60% of 4032
|
||||||
@ -332,6 +333,7 @@ public:
|
|||||||
CTestNetParams() {
|
CTestNetParams() {
|
||||||
strNetworkID = CBaseChainParams::TESTNET;
|
strNetworkID = CBaseChainParams::TESTNET;
|
||||||
consensus.nSubsidyHalvingInterval = 210240;
|
consensus.nSubsidyHalvingInterval = 210240;
|
||||||
|
consensus.BIP16Height = 0;
|
||||||
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 4030;
|
consensus.nMasternodePaymentsIncreaseBlock = 4030;
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
||||||
@ -378,7 +380,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 19999999999; // TODO: To be determined later
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 19999999999; // TODO: To be determined later
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 100;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 100;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 80; // 80% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 80; // 80% of 100
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 60; // 60% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 60; // 60% of 100
|
||||||
@ -386,7 +388,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 19999999999; // TODO: To be determined later
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 19999999999; // TODO: To be determined later
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 100;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 100;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 80; // 80% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 80; // 80% of 100
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 60; // 60% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 60; // 60% of 100
|
||||||
@ -503,6 +505,7 @@ public:
|
|||||||
explicit CDevNetParams(const ArgsManager& args) {
|
explicit CDevNetParams(const ArgsManager& args) {
|
||||||
strNetworkID = CBaseChainParams::DEVNET;
|
strNetworkID = CBaseChainParams::DEVNET;
|
||||||
consensus.nSubsidyHalvingInterval = 210240;
|
consensus.nSubsidyHalvingInterval = 210240;
|
||||||
|
consensus.BIP16Height = 0;
|
||||||
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
consensus.nMasternodePaymentsStartBlock = 4010; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 4030;
|
consensus.nMasternodePaymentsIncreaseBlock = 4030;
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
||||||
@ -548,7 +551,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 1661990400; // Sep 1st, 2022
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 1661990400; // Sep 1st, 2022
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 120;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 120;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 80; // 80% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 80; // 80% of 100
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 60; // 60% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 60; // 60% of 100
|
||||||
@ -556,7 +559,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 1661990400; // Sep 1st, 2022
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 1661990400; // Sep 1st, 2022
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 120;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 120;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 80; // 80% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 80; // 80% of 100
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 60; // 60% of 100
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 60; // 60% of 100
|
||||||
@ -739,6 +742,7 @@ public:
|
|||||||
explicit CRegTestParams(const ArgsManager& args) {
|
explicit CRegTestParams(const ArgsManager& args) {
|
||||||
strNetworkID = CBaseChainParams::REGTEST;
|
strNetworkID = CBaseChainParams::REGTEST;
|
||||||
consensus.nSubsidyHalvingInterval = 150;
|
consensus.nSubsidyHalvingInterval = 150;
|
||||||
|
consensus.BIP16Height = 0; // always enforce P2SH BIP16 on regtest
|
||||||
consensus.nMasternodePaymentsStartBlock = 240;
|
consensus.nMasternodePaymentsStartBlock = 240;
|
||||||
consensus.nMasternodePaymentsIncreaseBlock = 350;
|
consensus.nMasternodePaymentsIncreaseBlock = 350;
|
||||||
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
consensus.nMasternodePaymentsIncreasePeriod = 10;
|
||||||
@ -781,11 +785,11 @@ public:
|
|||||||
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
|
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].bit = 9;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 0;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nStartTime = 0;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 480;
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nWindowSize = 480;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 384; // 80% of 480
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdStart = 384; // 80% of 480
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 288; // 60% of 480
|
consensus.vDeployments[Consensus::DEPLOYMENT_V20].nThresholdMin = 288; // 60% of 480
|
||||||
@ -793,7 +797,7 @@ public:
|
|||||||
|
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].bit = 10;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 0;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nStartTime = 0;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = 999999999999ULL;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 1030;
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nWindowSize = 1030;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 800; // 80% of 1000
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdStart = 800; // 80% of 1000
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 600; // 60% of 1000
|
consensus.vDeployments[Consensus::DEPLOYMENT_MN_RR].nThresholdMin = 600; // 60% of 1000
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <uint256.h>
|
#include <uint256.h>
|
||||||
#include <llmq/params.h>
|
#include <llmq/params.h>
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace Consensus {
|
namespace Consensus {
|
||||||
@ -39,6 +40,15 @@ struct BIP9Deployment {
|
|||||||
int64_t nThresholdMin{0};
|
int64_t nThresholdMin{0};
|
||||||
/** A coefficient which adjusts the speed a required number of signaling blocks is decreasing from nThresholdStart to nThresholdMin at with each period. */
|
/** A coefficient which adjusts the speed a required number of signaling blocks is decreasing from nThresholdStart to nThresholdMin at with each period. */
|
||||||
int64_t nFalloffCoeff{0};
|
int64_t nFalloffCoeff{0};
|
||||||
|
|
||||||
|
/** Constant for nTimeout very far in the future. */
|
||||||
|
static constexpr int64_t NO_TIMEOUT = std::numeric_limits<int64_t>::max();
|
||||||
|
|
||||||
|
/** Special value for nStartTime indicating that the deployment is always active.
|
||||||
|
* This is useful for testing, as it means tests don't need to deal with the activation
|
||||||
|
* process (which takes at least 3 BIP9 intervals). Only tests that specifically test the
|
||||||
|
* behaviour during activation cannot use this. */
|
||||||
|
static constexpr int64_t ALWAYS_ACTIVE = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,6 +58,8 @@ struct Params {
|
|||||||
uint256 hashGenesisBlock;
|
uint256 hashGenesisBlock;
|
||||||
uint256 hashDevnetGenesisBlock;
|
uint256 hashDevnetGenesisBlock;
|
||||||
int nSubsidyHalvingInterval;
|
int nSubsidyHalvingInterval;
|
||||||
|
/** Block height at which BIP16 becomes active */
|
||||||
|
int BIP16Height;
|
||||||
int nMasternodePaymentsStartBlock;
|
int nMasternodePaymentsStartBlock;
|
||||||
int nMasternodePaymentsIncreaseBlock;
|
int nMasternodePaymentsIncreaseBlock;
|
||||||
int nMasternodePaymentsIncreasePeriod; // in blocks
|
int nMasternodePaymentsIncreasePeriod; // in blocks
|
||||||
|
@ -369,24 +369,6 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple"));
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple"));
|
||||||
m_node.mempool->clear();
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// invalid (pre-p2sh) txn in mempool, template creation fails
|
|
||||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
|
||||||
tx.vin[0].prevout.n = 0;
|
|
||||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
|
||||||
tx.vout[0].nValue = BLOCKSUBSIDY-LOWFEE;
|
|
||||||
script = CScript() << OP_0;
|
|
||||||
tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
|
|
||||||
hash = tx.GetHash();
|
|
||||||
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
|
||||||
tx.vin[0].prevout.hash = hash;
|
|
||||||
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end());
|
|
||||||
tx.vout[0].nValue -= LOWFEE;
|
|
||||||
hash = tx.GetHash();
|
|
||||||
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
|
||||||
// Should throw block-validation-failed
|
|
||||||
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("block-validation-failed"));
|
|
||||||
m_node.mempool->clear();
|
|
||||||
|
|
||||||
// double spend txn pair in mempool, template creation fails
|
// double spend txn pair in mempool, template creation fails
|
||||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||||
@ -426,6 +408,25 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
// ::ChainActive().SetTip(next);
|
// ::ChainActive().SetTip(next);
|
||||||
// }
|
// }
|
||||||
//BOOST_CHECK(pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey));
|
//BOOST_CHECK(pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey));
|
||||||
|
|
||||||
|
// invalid (pre-p2sh) txn in mempool, template creation fails
|
||||||
|
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||||
|
tx.vin[0].prevout.n = 0;
|
||||||
|
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||||
|
tx.vout[0].nValue = BLOCKSUBSIDY-LOWFEE;
|
||||||
|
script = CScript() << OP_0;
|
||||||
|
tx.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(script));
|
||||||
|
hash = tx.GetHash();
|
||||||
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
|
tx.vin[0].prevout.hash = hash;
|
||||||
|
tx.vin[0].scriptSig = CScript() << std::vector<unsigned char>(script.begin(), script.end());
|
||||||
|
tx.vout[0].nValue -= LOWFEE;
|
||||||
|
hash = tx.GetHash();
|
||||||
|
m_node.mempool->addUnchecked(entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||||
|
// Should throw block-validation-failed
|
||||||
|
BOOST_CHECK_EXCEPTION(AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("block-validation-failed"));
|
||||||
|
m_node.mempool->clear();
|
||||||
|
|
||||||
// // Delete the dummy blocks again.
|
// // Delete the dummy blocks again.
|
||||||
// while (::ChainActive().Tip()->nHeight > nHeight) {
|
// while (::ChainActive().Tip()->nHeight > nHeight) {
|
||||||
// CBlockIndex* del = ::ChainActive().Tip();
|
// CBlockIndex* del = ::ChainActive().Tip();
|
||||||
|
@ -32,6 +32,12 @@ public:
|
|||||||
int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, paramsDummy, cache); }
|
int GetStateSinceHeightFor(const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor(pindexPrev, paramsDummy, cache); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TestAlwaysActiveConditionChecker : public TestConditionChecker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int64_t BeginTime(const Consensus::Params& params) const override { return Consensus::BIP9Deployment::ALWAYS_ACTIVE; }
|
||||||
|
};
|
||||||
|
|
||||||
#define CHECKERS 6
|
#define CHECKERS 6
|
||||||
|
|
||||||
class VersionBitsTester
|
class VersionBitsTester
|
||||||
@ -43,6 +49,8 @@ class VersionBitsTester
|
|||||||
// The first one performs all checks, the second only 50%, the third only 25%, etc...
|
// The first one performs all checks, the second only 50%, the third only 25%, etc...
|
||||||
// This is to test whether lack of cached information leads to the same results.
|
// This is to test whether lack of cached information leads to the same results.
|
||||||
TestConditionChecker checker[CHECKERS];
|
TestConditionChecker checker[CHECKERS];
|
||||||
|
// Another 6 that assume always active activation
|
||||||
|
TestAlwaysActiveConditionChecker checker_always[CHECKERS];
|
||||||
|
|
||||||
// Test counter (to identify failures)
|
// Test counter (to identify failures)
|
||||||
int num;
|
int num;
|
||||||
@ -56,6 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < CHECKERS; i++) {
|
for (unsigned int i = 0; i < CHECKERS; i++) {
|
||||||
checker[i] = TestConditionChecker();
|
checker[i] = TestConditionChecker();
|
||||||
|
checker_always[i] = TestAlwaysActiveConditionChecker();
|
||||||
}
|
}
|
||||||
vpblock.clear();
|
vpblock.clear();
|
||||||
return *this;
|
return *this;
|
||||||
@ -82,6 +91,7 @@ public:
|
|||||||
for (int i = 0; i < CHECKERS; i++) {
|
for (int i = 0; i < CHECKERS; i++) {
|
||||||
if (InsecureRandBits(i) == 0) {
|
if (InsecureRandBits(i) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(checker[i].GetStateSinceHeightFor(vpblock.empty() ? nullptr : vpblock.back()) == height, strprintf("Test %i for StateSinceHeight", num));
|
BOOST_CHECK_MESSAGE(checker[i].GetStateSinceHeightFor(vpblock.empty() ? nullptr : vpblock.back()) == height, strprintf("Test %i for StateSinceHeight", num));
|
||||||
|
BOOST_CHECK_MESSAGE(checker_always[i].GetStateSinceHeightFor(vpblock.empty() ? nullptr : vpblock.back()) == 0, strprintf("Test %i for StateSinceHeight (always active)", num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
@ -92,6 +102,7 @@ public:
|
|||||||
for (int i = 0; i < CHECKERS; i++) {
|
for (int i = 0; i < CHECKERS; i++) {
|
||||||
if (InsecureRandBits(i) == 0) {
|
if (InsecureRandBits(i) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::DEFINED, strprintf("Test %i for DEFINED", num));
|
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::DEFINED, strprintf("Test %i for DEFINED", num));
|
||||||
|
BOOST_CHECK_MESSAGE(checker_always[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE (always active)", num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
@ -102,6 +113,7 @@ public:
|
|||||||
for (int i = 0; i < CHECKERS; i++) {
|
for (int i = 0; i < CHECKERS; i++) {
|
||||||
if (InsecureRandBits(i) == 0) {
|
if (InsecureRandBits(i) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::STARTED, strprintf("Test %i for STARTED", num));
|
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::STARTED, strprintf("Test %i for STARTED", num));
|
||||||
|
BOOST_CHECK_MESSAGE(checker_always[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE (always active)", num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
@ -112,6 +124,7 @@ public:
|
|||||||
for (int i = 0; i < CHECKERS; i++) {
|
for (int i = 0; i < CHECKERS; i++) {
|
||||||
if (InsecureRandBits(i) == 0) {
|
if (InsecureRandBits(i) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::LOCKED_IN, strprintf("Test %i for LOCKED_IN", num));
|
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::LOCKED_IN, strprintf("Test %i for LOCKED_IN", num));
|
||||||
|
BOOST_CHECK_MESSAGE(checker_always[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE (always active)", num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
@ -122,6 +135,7 @@ public:
|
|||||||
for (int i = 0; i < CHECKERS; i++) {
|
for (int i = 0; i < CHECKERS; i++) {
|
||||||
if (InsecureRandBits(i) == 0) {
|
if (InsecureRandBits(i) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE", num));
|
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE", num));
|
||||||
|
BOOST_CHECK_MESSAGE(checker_always[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE (always active)", num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
@ -132,6 +146,7 @@ public:
|
|||||||
for (int i = 0; i < CHECKERS; i++) {
|
for (int i = 0; i < CHECKERS; i++) {
|
||||||
if (InsecureRandBits(i) == 0) {
|
if (InsecureRandBits(i) == 0) {
|
||||||
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::FAILED, strprintf("Test %i for FAILED", num));
|
BOOST_CHECK_MESSAGE(checker[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::FAILED, strprintf("Test %i for FAILED", num));
|
||||||
|
BOOST_CHECK_MESSAGE(checker_always[i].GetStateFor(vpblock.empty() ? nullptr : vpblock.back()) == ThresholdState::ACTIVE, strprintf("Test %i for ACTIVE (always active)", num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
num++;
|
num++;
|
||||||
|
@ -1966,11 +1966,12 @@ static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_
|
|||||||
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
|
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
|
|
||||||
// BIP16 didn't become active until Apr 1 2012
|
unsigned int flags = SCRIPT_VERIFY_NONE;
|
||||||
int64_t nBIP16SwitchTime = 1333238400;
|
|
||||||
bool fStrictPayToScriptHash = (pindex->GetBlockTime() >= nBIP16SwitchTime);
|
|
||||||
|
|
||||||
unsigned int flags = fStrictPayToScriptHash ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE;
|
// Start enforcing P2SH (BIP16)
|
||||||
|
if (pindex->nHeight >= consensusparams.BIP16Height) {
|
||||||
|
flags |= SCRIPT_VERIFY_P2SH;
|
||||||
|
}
|
||||||
|
|
||||||
// Start enforcing the DERSIG (BIP66) rule
|
// Start enforcing the DERSIG (BIP66) rule
|
||||||
if (pindex->nHeight >= consensusparams.BIP66Height) {
|
if (pindex->nHeight >= consensusparams.BIP66Height) {
|
||||||
|
@ -11,6 +11,11 @@ ThresholdState AbstractThresholdConditionChecker::GetStateFor(const CBlockIndex*
|
|||||||
int64_t nTimeStart = BeginTime(params);
|
int64_t nTimeStart = BeginTime(params);
|
||||||
int64_t nTimeTimeout = EndTime(params);
|
int64_t nTimeTimeout = EndTime(params);
|
||||||
|
|
||||||
|
// Check if this deployment is always active.
|
||||||
|
if (nTimeStart == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
|
||||||
|
return ThresholdState::ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
// A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1.
|
// A block's state is always the same as that of the first of its period, so it is computed based on a pindexPrev whose height equals a multiple of nPeriod - 1.
|
||||||
if (pindexPrev != nullptr) {
|
if (pindexPrev != nullptr) {
|
||||||
pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod));
|
pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1) % nPeriod));
|
||||||
@ -161,6 +166,11 @@ BIP9Stats AbstractThresholdConditionChecker::GetStateStatisticsFor(const CBlockI
|
|||||||
|
|
||||||
int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const
|
int AbstractThresholdConditionChecker::GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const
|
||||||
{
|
{
|
||||||
|
int64_t start_time = BeginTime(params);
|
||||||
|
if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
|
const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
|
||||||
|
|
||||||
// BIP 9 about state DEFINED: "The genesis block is by definition in this state for each deployment."
|
// BIP 9 about state DEFINED: "The genesis block is by definition in this state for each deployment."
|
||||||
|
@ -145,7 +145,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
'bip9': {
|
'bip9': {
|
||||||
'status': 'defined',
|
'status': 'defined',
|
||||||
'start_time': 0,
|
'start_time': 0,
|
||||||
'timeout': 999999999999,
|
'timeout': 9223372036854775807,
|
||||||
'since': 0
|
'since': 0
|
||||||
}, 'active': False},
|
}, 'active': False},
|
||||||
'mn_rr': {
|
'mn_rr': {
|
||||||
@ -153,7 +153,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
'bip9': {
|
'bip9': {
|
||||||
'status': 'defined',
|
'status': 'defined',
|
||||||
'start_time': 0,
|
'start_time': 0,
|
||||||
'timeout': 999999999999,
|
'timeout': 9223372036854775807,
|
||||||
'since': 0
|
'since': 0
|
||||||
},
|
},
|
||||||
'active': False},
|
'active': False},
|
||||||
@ -163,7 +163,7 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
'status': 'started',
|
'status': 'started',
|
||||||
'bit': 28,
|
'bit': 28,
|
||||||
'start_time': 0,
|
'start_time': 0,
|
||||||
'timeout': 999999999999, # testdummy does not have a timeout so is set to the max int64 value
|
'timeout': 9223372036854775807, # testdummy does not have a timeout so is set to the max int64 value
|
||||||
'since': 144,
|
'since': 144,
|
||||||
'statistics': {
|
'statistics': {
|
||||||
'period': 144,
|
'period': 144,
|
||||||
|
Loading…
Reference in New Issue
Block a user