Fixate BIP65 softfork heights

- Re-introduce Params.BIP65Height
- Fixate block 1854705 for testnet
- Fixate block 3464751 for mainnet
- Fixate block 1351 for regtest
- Stop using IsSuperMajority() in validation for BIP65
- Simplify RPC SoftForkMajorityDesc
This commit is contained in:
Patrick Lodder 2021-02-13 17:21:20 +01:00
parent d96b5daafa
commit 0c600d7f9d
No known key found for this signature in database
GPG Key ID: 2D3A345B98D0DC1F
4 changed files with 9 additions and 27 deletions

View File

@ -82,7 +82,7 @@ public:
// BIP34 is never enforced in Dogecoin v2 blocks, so we enforce from v3
consensus.BIP34Height = 1034383;
consensus.BIP34Hash = uint256S("0x80d1364201e5df97e696c03bdd24dc885e8617b9de51e453c10a4f629b1e797a");
// consensus.BIP65Height = 1032483; // Not enabled in Doge yet
consensus.BIP65Height = 3464751; // 34cd2cbba4ba366f47e5aa0db5f02c19eba2adf679ceb6653ac003bdc9a0ef1f - first v4 block after the last v3 block
consensus.BIP66Height = 1034383; // 80d1364201e5df97e696c03bdd24dc885e8617b9de51e453c10a4f629b1e797a - this is the last block that could be v2, 1900 blocks past the last v2 block
consensus.powLimit = uint256S("0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20;
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
@ -237,7 +237,7 @@ public:
// BIP34 is never enforced in Dogecoin v2 blocks, so we enforce from v3
consensus.BIP34Height = 708658;
consensus.BIP34Hash = uint256S("0x21b8b97dcdb94caa67c7f8f6dbf22e61e0cfe0e46e1fff3528b22864659e9b38");
// consensus.BIP65Height = 581885; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
consensus.BIP65Height = 1854705; // 955bd496d23790aba1ecfacb722b089a6ae7ddabaedf7d8fb0878f48308a71f9
consensus.BIP66Height = 708658; // 21b8b97dcdb94caa67c7f8f6dbf22e61e0cfe0e46e1fff3528b22864659e9b38 - this is the last block that could be v2, 1900 blocks past the last v2 block
consensus.powLimit = uint256S("0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 20;
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
@ -372,7 +372,7 @@ public:
consensus.nMajorityWindow = 1000;
consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
consensus.BIP34Hash = uint256();
// consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
consensus.powLimit = uint256S("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1;
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours

View File

@ -47,7 +47,7 @@ struct Params {
int BIP34Height;
uint256 BIP34Hash;
/** Block height at which BIP65 becomes active */
// int BIP65Height;
int BIP65Height;
/** Block height at which BIP66 becomes active */
int BIP66Height;
/**

View File

@ -1071,20 +1071,7 @@ static UniValue SoftForkMajorityDesc(int version, CBlockIndex* pindex, const Con
activated = pindex->nHeight >= consensusParams.BIP66Height;
break;
case 4:
int nFound = 0;
int nRequired = consensusParams.nMajorityRejectBlockOutdated;
CBlockIndex* pstart = pindex;
for (int i = 0; i < consensusParams.nMajorityWindow && pstart != NULL; i++)
{
if (pstart->GetBaseVersion() >= version)
++nFound;
pstart = pstart->pprev;
}
activated = nFound >= nRequired;
rv.push_back(Pair("found", nFound));
rv.push_back(Pair("required", nRequired));
rv.push_back(Pair("window", consensusParams.nMajorityWindow));
activated = pindex->nHeight >= consensusParams.BIP65Height;
break;
}
rv.push_back(Pair("status", activated));

View File

@ -1852,9 +1852,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
flags |= SCRIPT_VERIFY_DERSIG;
}
// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
// blocks, when 75% of the network has upgraded:
if (block.GetBaseVersion() >= 4 && IsSuperMajority(4, pindex->pprev, chainparams.GetConsensus(0).nMajorityEnforceBlockUpgrade, chainparams.GetConsensus(0))) {
// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4 blocks
if (pindex->nHeight >= chainparams.GetConsensus(0).BIP65Height) {
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
}
@ -3035,15 +3034,11 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
// Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:
// check for version 2, 3 and 4 upgrades
// Dogecoin: Version 2 enforcement was never used
if((block.GetBaseVersion() < 3 && nHeight >= consensusParams.BIP66Height))
if((block.GetBaseVersion() < 3 && nHeight >= consensusParams.BIP66Height) ||
(block.GetBaseVersion() < 4 && nHeight >= consensusParams.BIP65Height))
return state.Invalid(false, REJECT_OBSOLETE, strprintf("bad-version(0x%08x)", block.GetBaseVersion()),
strprintf("rejected nVersion=0x%08x block", block.GetBaseVersion()));
// Dogecoin: Introduce supermajority rules for v4 blocks
if (block.GetBaseVersion() < 4 && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
return state.Invalid(error("%s : rejected nVersion=3 block", __func__),
REJECT_OBSOLETE, "bad-version");
return true;
}