mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-21 06:18:39 +02:00
Set minimum block height for forks (algo switch, BIP66, BIP65, seq algo count)
This commit is contained in:
+35
-26
@@ -1974,14 +1974,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
unsigned int flags = SCRIPT_VERIFY_P2SH;
|
||||
|
||||
// Start enforcing the DERSIG (BIP66) rules, for block.nVersion=3 blocks, when 75% of the network has upgraded:
|
||||
if (block.nVersion >= 3 && IsSuperMajority(3, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
|
||||
flags |= SCRIPT_VERIFY_DERSIG;
|
||||
}
|
||||
if (pindex->nHeight >= chainparams.GetConsensus().nFork1MinBlock)
|
||||
{
|
||||
if (block.nVersion >= 3 && IsSuperMajority(3, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
|
||||
flags |= SCRIPT_VERIFY_DERSIG;
|
||||
}
|
||||
|
||||
// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
|
||||
// blocks, when 75% of the network has upgraded:
|
||||
if (block.nVersion >= 4 && IsSuperMajority(4, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
|
||||
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
|
||||
// Start enforcing CHECKLOCKTIMEVERIFY, (BIP65) for block.nVersion=4
|
||||
// blocks, when 75% of the network has upgraded:
|
||||
if (block.nVersion >= 4 && IsSuperMajority(4, pindex->pprev, chainparams.GetConsensus().nMajorityEnforceBlockUpgrade, chainparams.GetConsensus())) {
|
||||
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
|
||||
}
|
||||
}
|
||||
|
||||
CBlockUndo blockundo;
|
||||
@@ -2952,7 +2955,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
// previous YESCRYPT block was mined or;
|
||||
// mining majority and fork height reached
|
||||
bool bAlgoSwitch1 = false;
|
||||
if (nHeight >= consensusParams.nAlgoSwitchBlock1)
|
||||
if (nHeight >= consensusParams.nFork1MinBlock)
|
||||
{
|
||||
bAlgoSwitch1 = IsAlgoSwitch1Active(pindexPrev, consensusParams);
|
||||
if (!bAlgoSwitch1)
|
||||
@@ -2986,20 +2989,23 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d)", __func__, nHeight));
|
||||
}
|
||||
|
||||
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
// if (block.nVersion < 2 && IsSuperMajority(2, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
// return state.Invalid(error("%s: rejected nVersion=1 block", __func__),
|
||||
// REJECT_OBSOLETE, "bad-version");
|
||||
if (nHeight >= consensusParams.nFork1MinBlock)
|
||||
{
|
||||
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
// if (block.nVersion < 2 && IsSuperMajority(2, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
// return state.Invalid(error("%s: rejected nVersion=1 block", __func__),
|
||||
// REJECT_OBSOLETE, "bad-version");
|
||||
|
||||
// Reject block.nVersion=2 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
if (block.nVersion < 3 && IsSuperMajority(3, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
return state.Invalid(error("%s : rejected nVersion=2 block", __func__),
|
||||
REJECT_OBSOLETE, "bad-version");
|
||||
// Reject block.nVersion=2 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
if (block.nVersion < 3 && IsSuperMajority(3, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
return state.Invalid(error("%s : rejected nVersion=2 block", __func__),
|
||||
REJECT_OBSOLETE, "bad-version");
|
||||
|
||||
// Reject block.nVersion=3 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
if (block.nVersion < 4 && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
return state.Invalid(error("%s : rejected nVersion=3 block", __func__),
|
||||
REJECT_OBSOLETE, "bad-version");
|
||||
// Reject block.nVersion=3 blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
if (block.nVersion < 4 && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
|
||||
return state.Invalid(error("%s : rejected nVersion=3 block", __func__),
|
||||
REJECT_OBSOLETE, "bad-version");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -3022,12 +3028,15 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
|
||||
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
|
||||
// if 750 of the last 1,000 blocks are version 2 or greater (51/100 if testnet):
|
||||
if (block.nVersion >= 2 && IsSuperMajority(3, pindexPrev, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))
|
||||
if (nHeight >= consensusParams.nFork1MinBlock)
|
||||
{
|
||||
CScript expect = CScript() << nHeight;
|
||||
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() ||
|
||||
!std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) {
|
||||
return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height");
|
||||
if (block.nVersion >= 2 && IsSuperMajority(3, pindexPrev, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))
|
||||
{
|
||||
CScript expect = CScript() << nHeight;
|
||||
if (block.vtx[0].vin[0].scriptSig.size() < expect.size() ||
|
||||
!std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) {
|
||||
return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3076,7 +3085,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
||||
|
||||
// Maximum sequence count allowed
|
||||
int nMaxSeqCount;
|
||||
if ( (nHeight > chainparams.GetConsensus().nBlockSequentialAlgoRuleStart3) &&
|
||||
if ( (nHeight > chainparams.GetConsensus().nFork1MinBlock) &&
|
||||
(block.nVersion > 3) &&
|
||||
IsSuperMajority(4, pindexPrev, chainparams.GetConsensus().nMajorityEnableAlgoSwitch1, chainparams.GetConsensus()) )
|
||||
nMaxSeqCount = chainparams.GetConsensus().nBlockSequentialAlgoMaxCount3;
|
||||
|
||||
Reference in New Issue
Block a user