Hi BTC3 Team,
As the BTC3 blockchain is stuck for more than 18 hours, and we have no pool so far, something has to be done.
To survive similar situation in future as well as to fix the current issue, I'm proposing to add new logic to the BTC3 core to recover from bad stale (attack) situation.
Please have a look the following code change and if similar code can be added to BTC3 core, we can at least go through now.
Note I put a logic that every 50 minutes ("10" times of the target space) halves the difficulty. And sure to make it's not less than the minimum target.
I've tested with two nodes and working correctly.
Anyone feel free to comment as well.
stale_target:
diff --git a/src/pow.cpp b/src/pow.cpp
index 45237b2..e444c2a 100644
--- a/src/pow.cpp
+++ b/src/pow.cpp
@@ -35,6 +35,10 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
return pindex->nBits;
}
}
+ else if ((pindexLast->nHeight + 1) >= 1821 && pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*10)
+ {
+ return CalculateNextWorkRequiredStale(pindexLast, (pblock->GetBlockTime() - pindexLast->GetBlockTime()) / params.nPowTargetSpacing*10, params);
+ }
return pindexLast->nBits;
}
@@ -72,6 +76,29 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF
return bnNew.GetCompact();
}
+unsigned int CalculateNextWorkRequiredStale(const CBlockIndex* pindexLast, int shift, const Consensus::Params& params)
+{
+ if (params.fPowNoRetargeting)
+ return pindexLast->nBits;
+
+ // Retarget
+ const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
+ arith_uint256 bnNew;
+ bnNew.SetCompact(pindexLast->nBits);
+
+ for (int i=0; i+ {
+ bnNew *= 2;
+ if (bnNew > bnPowLimit)
+ {
+ bnNew = bnPowLimit;
+ break;
+ }
+ }
+
+ return bnNew.GetCompact();
+}
+
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
{
bool fNegative;
This could be great modification since if someone has lot of hashing power they can stall the blockchain, as i believe that has happened. They just mine the difficulty to skyrocket and leave. If no action will be taken the blockchain can be stopped.